3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Fix commandblock minecarts

Dieser Commit ist enthalten in:
Mats 2016-03-06 12:18:18 +01:00
Ursprung 840c90f871
Commit a314b86f57
3 geänderte Dateien mit 23 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -1,7 +1,6 @@
package us.myles.ViaVersion.metadata; package us.myles.ViaVersion.metadata;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.entity.minecart.CommandMinecart;
public enum MetaIndex { public enum MetaIndex {
@ -107,8 +106,8 @@ public enum MetaIndex {
MINECART_BLOCK_Y(Minecart.class, 21, Type.Int, 9, NewType.VarInt), MINECART_BLOCK_Y(Minecart.class, 21, Type.Int, 9, NewType.VarInt),
MINECART_SHOWBLOCK(Minecart.class, 22, Type.Byte, 10, NewType.Boolean), MINECART_SHOWBLOCK(Minecart.class, 22, Type.Byte, 10, NewType.Boolean),
// Command minecart (they are still broken) // Command minecart (they are still broken)
MINECART_COMMANDBLOCK_COMMAND(CommandMinecart.class,23,Type.String,11,NewType.String), MINECART_COMMANDBLOCK_COMMAND(Minecart.class, 23, Type.String, 11, NewType.String),
MINECART_COMMANDBLOCK_OUTPUT(CommandMinecart.class,24,Type.String,12,NewType.Chat), MINECART_COMMANDBLOCK_OUTPUT(Minecart.class, 24, Type.String, 12, NewType.Chat),
// furnace cart // furnace cart
FURNACECART_ISPOWERED(org.bukkit.entity.minecart.PoweredMinecart.class, 16, Type.Byte, 11, NewType.Boolean), FURNACECART_ISPOWERED(org.bukkit.entity.minecart.PoweredMinecart.class, 16, Type.Byte, 11, NewType.Boolean),
// item drop // item drop
@ -167,14 +166,14 @@ public enum MetaIndex {
public static MetaIndex getIndex(EntityType type, int index) { public static MetaIndex getIndex(EntityType type, int index) {
Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass(); Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass();
if(entityClass == null){ if (entityClass == null) {
System.out.println("Could not get entity class for " + type); System.out.println("Could not get entity class for " + type);
return null; return null;
} }
for (MetaIndex mi : MetaIndex.values()) { for (MetaIndex mi : MetaIndex.values()) {
if (mi.getIndex() == index) { if (mi.getIndex() == index) {
// To fix issue with armour stands colliding with new values // To fix issue with armour stands colliding with new values
if(mi.getApplicableClass().equals(LivingEntity.class)) continue; if (mi.getApplicableClass().equals(LivingEntity.class)) continue;
if ((mi.getApplicableClass().isAssignableFrom(entityClass) || if ((mi.getApplicableClass().isAssignableFrom(entityClass) ||
mi.getApplicableClass().equals(entityClass))) { mi.getApplicableClass().equals(entityClass))) {

Datei anzeigen

@ -1,20 +1,19 @@
package us.myles.ViaVersion.metadata; package us.myles.ViaVersion.metadata;
import io.netty.buffer.ByteBuf;
import org.bukkit.entity.EntityType;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import us.myles.ViaVersion.slot.ItemSlotRewriter;
import us.myles.ViaVersion.slot.ItemSlotRewriter.ItemStack;
import us.myles.ViaVersion.transformers.OutgoingTransformer;
import us.myles.ViaVersion.util.PacketUtil;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.entity.EntityType;
import org.bukkit.util.EulerAngle;
import org.bukkit.util.Vector;
import io.netty.buffer.ByteBuf;
import us.myles.ViaVersion.slot.ItemSlotRewriter;
import us.myles.ViaVersion.slot.ItemSlotRewriter.ItemStack;
import us.myles.ViaVersion.util.PacketUtil;
public class MetadataRewriter { public class MetadataRewriter {
public static void writeMetadata1_9(EntityType type, List<Entry> list, ByteBuf output) { public static void writeMetadata1_9(EntityType type, List<Entry> list, ByteBuf output) {
@ -88,7 +87,7 @@ public class MetadataRewriter {
PacketUtil.writeString((String) value, output); PacketUtil.writeString((String) value, output);
break; break;
case Boolean: case Boolean:
if(metaIndex == MetaIndex.AGEABLE_AGE) if (metaIndex == MetaIndex.AGEABLE_AGE)
output.writeBoolean(((Byte) value).byteValue() < 0); output.writeBoolean(((Byte) value).byteValue() < 0);
else else
output.writeBoolean(((Byte) value).byteValue() != 0); output.writeBoolean(((Byte) value).byteValue() != 0);
@ -110,6 +109,9 @@ public class MetadataRewriter {
output.writeFloat((float) angle.getY()); output.writeFloat((float) angle.getY());
output.writeFloat((float) angle.getZ()); output.writeFloat((float) angle.getZ());
break; break;
case Chat:
PacketUtil.writeString(OutgoingTransformer.fixJson((String) value), output);
break;
default: default:
System.out.println("[Out] Unhandled MetaDataType: " + metaIndex.getNewType()); System.out.println("[Out] Unhandled MetaDataType: " + metaIndex.getNewType());
break; break;
@ -159,7 +161,7 @@ public class MetadataRewriter {
e.printStackTrace(); e.printStackTrace();
} }
} }
break; break;
case Position: { case Position: {
int x = buf.readInt(); int x = buf.readInt();
int y = buf.readInt(); int y = buf.readInt();

Datei anzeigen

@ -216,6 +216,11 @@ public class IncomingTransformer {
PacketUtil.writeString(command, output); PacketUtil.writeString(command, output);
output.writeBoolean(flag); output.writeBoolean(flag);
return; return;
} else if (name.equals("MC|AdvCmd")) {
output.clear();
PacketUtil.writeVarInt(PacketType.PLAY_PLUGIN_MESSAGE_REQUEST.getPacketID(), output);
PacketUtil.writeString("MC|AdvCdm", output);
output.writeBytes(b);
} }
output.writeBytes(b); output.writeBytes(b);
} }