Clean up misc disguise constructor a little
This commit is contained in:
		@@ -199,7 +199,7 @@ public class PacketsManager {
 | 
			
		||||
            mods.write(2, loc.getBlockY());
 | 
			
		||||
            mods.write(3, loc.getBlockZ());
 | 
			
		||||
            mods.write(4, ((int) loc.getYaw()) % 4);
 | 
			
		||||
            int id = ((MiscDisguise) disguise).getId();
 | 
			
		||||
            int id = ((MiscDisguise) disguise).getData();
 | 
			
		||||
            if (id == -1)
 | 
			
		||||
                id = new Random().nextInt(EnumArt.values().length);
 | 
			
		||||
            mods.write(5, EnumArt.values()[id % EnumArt.values().length].B);
 | 
			
		||||
@@ -275,17 +275,21 @@ public class PacketsManager {
 | 
			
		||||
 | 
			
		||||
            int id = disguise.getType().getEntityId();
 | 
			
		||||
            int data = 0;
 | 
			
		||||
            if (((MiscDisguise) disguise).getId() >= 0)
 | 
			
		||||
            if (((MiscDisguise) disguise).getId() >= 0) {
 | 
			
		||||
                if (((MiscDisguise) disguise).getData() >= 0)
 | 
			
		||||
                    data = (((MiscDisguise) disguise).getId() | ((MiscDisguise) disguise).getData() << 16);
 | 
			
		||||
                else
 | 
			
		||||
                    data = ((MiscDisguise) disguise).getId();
 | 
			
		||||
            }
 | 
			
		||||
            // This won't actually work.
 | 
			
		||||
            // But if someone constructing the disguise uses it properly. It will work.
 | 
			
		||||
            if (disguise.getType() == DisguiseType.FISHING_HOOK)
 | 
			
		||||
                data = disguise.getEntity().getEntityId();
 | 
			
		||||
            else if (disguise.getType() == DisguiseType.ITEM_FRAME)
 | 
			
		||||
                data = (int) Math.abs(loc.getYaw() % 4);
 | 
			
		||||
            else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
 | 
			
		||||
                data = (int) loc.getYaw();
 | 
			
		||||
                if (data < 0)
 | 
			
		||||
                    data = -data;
 | 
			
		||||
            }
 | 
			
		||||
            spawnPackets[0] = new PacketContainer(Packets.Server.VEHICLE_SPAWN);
 | 
			
		||||
            StructureModifier<Object> mods = spawnPackets[0].getModifier();
 | 
			
		||||
            mods.write(0, disguisedEntity.getEntityId());
 | 
			
		||||
 
 | 
			
		||||
@@ -133,11 +133,11 @@ public enum DisguiseType {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private int defaultData;
 | 
			
		||||
 | 
			
		||||
    private int defaultId;
 | 
			
		||||
    private int entityId;
 | 
			
		||||
    private EntityType entityType;
 | 
			
		||||
    private Class watcherClass;
 | 
			
		||||
 | 
			
		||||
    private DisguiseType(EntityType newType, int... obj) {
 | 
			
		||||
        entityType = newType;
 | 
			
		||||
        for (int i = 0; i < obj.length; i++) {
 | 
			
		||||
 
 | 
			
		||||
@@ -15,15 +15,40 @@ public class MiscDisguise extends Disguise {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int id, int data) {
 | 
			
		||||
        if (id == -1)
 | 
			
		||||
            id = disguiseType.getDefaultId();
 | 
			
		||||
        switch (disguiseType) {
 | 
			
		||||
        // The only disguises which should use a custom data.
 | 
			
		||||
        case FISHING_HOOK:
 | 
			
		||||
        case ARROW:
 | 
			
		||||
        case SPLASH_POTION:
 | 
			
		||||
        case SMALL_FIREBALL:
 | 
			
		||||
        case FIREBALL:
 | 
			
		||||
        case WITHER_SKULL:
 | 
			
		||||
        case PAINTING:
 | 
			
		||||
        case FALLING_BLOCK:
 | 
			
		||||
            break;
 | 
			
		||||
        default:
 | 
			
		||||
            data = -1;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        if (disguiseType == DisguiseType.FALLING_BLOCK && id != -1) {
 | 
			
		||||
            this.id = id;
 | 
			
		||||
        } else {
 | 
			
		||||
            this.id = disguiseType.getDefaultId();
 | 
			
		||||
        }
 | 
			
		||||
        if (data == -1)
 | 
			
		||||
            data = disguiseType.getDefaultData();
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.data = data;
 | 
			
		||||
        createDisguise(disguiseType, replaceSounds);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int addictionalData) {
 | 
			
		||||
        this(disguiseType, replaceSounds, -1, addictionalData);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MiscDisguise(DisguiseType disguiseType, int id, int data) {
 | 
			
		||||
        this(disguiseType, true, id, data);
 | 
			
		||||
    }
 | 
			
		||||
@@ -40,13 +65,7 @@ public class MiscDisguise extends Disguise {
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public MiscDisguise(EntityType entityType, boolean replaceSounds, int id, int data) {
 | 
			
		||||
        if (id == -1)
 | 
			
		||||
            id = DisguiseType.getType(entityType).getDefaultId();
 | 
			
		||||
        if (data == -1)
 | 
			
		||||
            data = DisguiseType.getType(entityType).getDefaultData();
 | 
			
		||||
        this.id = id;
 | 
			
		||||
        this.data = data;
 | 
			
		||||
        createDisguise(DisguiseType.getType(entityType), replaceSounds);
 | 
			
		||||
        this(DisguiseType.getType(entityType), replaceSounds, id, data);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
@@ -56,7 +75,7 @@ public class MiscDisguise extends Disguise {
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public MiscDisguise clone() {
 | 
			
		||||
        MiscDisguise disguise = new MiscDisguise(getType(), replaceSounds(), getId(), getData());
 | 
			
		||||
        MiscDisguise disguise = new MiscDisguise(getType(), replaceSounds(), getData());
 | 
			
		||||
        disguise.setViewSelfDisguise(viewSelfDisguise());
 | 
			
		||||
        disguise.setHearSelfDisguise(canHearSelfDisguise());
 | 
			
		||||
        disguise.setHideArmorFromSelf(isHidingArmorFromSelf());
 | 
			
		||||
@@ -70,8 +89,4 @@ public class MiscDisguise extends Disguise {
 | 
			
		||||
        return data;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getId() {
 | 
			
		||||
        return id;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user