Fixing some compile errors
This commit is contained in:
parent
bf7bcd8f98
commit
f5c29cc5bf
|
@ -43,6 +43,7 @@ public class EntityTypes1_8 {
|
|||
|
||||
// Objects
|
||||
FISH_HOOK(-1, ENTITY),
|
||||
LIGHTNING(-1, ENTITY),
|
||||
|
||||
ENDER_EYE(15, ENTITY),
|
||||
ITEM(1, ENTITY),
|
||||
|
|
|
@ -20,8 +20,8 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata;
|
|||
import com.viaversion.viaversion.api.minecraft.EulerAngle;
|
||||
import com.viaversion.viaversion.api.minecraft.Vector;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.MetaType;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
|
@ -70,14 +70,15 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter<ClientboundPackets1
|
|||
metadata.setValue(((Integer) value).byteValue());
|
||||
}
|
||||
// After writing the last one
|
||||
if (metaIndex == MetaIndex.ENTITY_STATUS && type == EntityTypes1_10.EntityType.PLAYER) {
|
||||
if (metaIndex == MetaIndex.ENTITY_STATUS && type == EntityTypes1_8.EntityType.PLAYER) {
|
||||
byte val = 0;
|
||||
if ((((Byte) value) & 0x10) == 0x10) { // Player eating/aiming/drinking
|
||||
val = 1;
|
||||
}
|
||||
int newIndex = MetaIndex.PLAYER_HAND.getNewIndex();
|
||||
MetaType metaType = MetaIndex.PLAYER_HAND.getNewType();
|
||||
event.createExtraMeta(new Metadata(newIndex, metaType, val));
|
||||
// TODO: Should we include 1.9 metadata into the index?
|
||||
// int newIndex = MetaIndex.PLAYER_HAND.getNewIndex();
|
||||
// MetaType metaType = MetaIndex.PLAYER_HAND.getNewType();
|
||||
// event.createExtraMeta(new Metadata(newIndex, metaType, val));
|
||||
}
|
||||
break;
|
||||
case OptUUID:
|
||||
|
@ -108,7 +109,7 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter<ClientboundPackets1
|
|||
metadata.setValue(value);
|
||||
break;
|
||||
case Boolean:
|
||||
if (metaIndex == MetaIndex.AGEABLE_AGE)
|
||||
if (metaIndex == MetaIndex.ENTITY_AGEABLE_AGE)
|
||||
metadata.setValue((Byte) value < 0);
|
||||
else
|
||||
metadata.setValue((Byte) value != 0);
|
||||
|
@ -140,11 +141,12 @@ public class MetadataRewriter1_9To1_8 extends EntityRewriter<ClientboundPackets1
|
|||
|
||||
@Override
|
||||
public EntityType typeFromId(int type) {
|
||||
return EntityTypes1_10.getTypeFromId(type, false);
|
||||
return EntityTypes1_8.getEntityType(type, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType objectTypeFromId(int type) {
|
||||
return EntityTypes1_10.getTypeFromId(type, true);
|
||||
// TODO: Track data int properly
|
||||
return EntityTypes1_8.getEntityType(type, 0, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8.packets;
|
|||
import com.google.gson.JsonObject;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.ClientWorld;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
|
@ -173,7 +174,7 @@ public class PlayerPackets {
|
|||
handler(wrapper -> {
|
||||
int entityId = wrapper.get(Type.INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityId, EntityTypes1_10.EntityType.PLAYER);
|
||||
tracker.addEntity(entityId, EntityTypes1_8.EntityType.PLAYER);
|
||||
tracker.setClientEntityId(entityId);
|
||||
});
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Player Gamemode
|
||||
|
|
|
@ -19,6 +19,7 @@ package com.viaversion.viaversion.protocols.protocol1_9to1_8.packets;
|
|||
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.data.entity.EntityTracker;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
|
@ -60,14 +61,6 @@ public class SpawnPackets {
|
|||
});
|
||||
map(Type.BYTE); // 2 - Type
|
||||
|
||||
// Parse this info
|
||||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
int typeID = wrapper.get(Type.BYTE, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, true));
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divided by 32
|
||||
|
@ -77,6 +70,15 @@ public class SpawnPackets {
|
|||
|
||||
map(Type.INT); // 8 - Data
|
||||
|
||||
// Parse this info
|
||||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
int typeID = wrapper.get(Type.BYTE, 0);
|
||||
int data = wrapper.get(Type.INT, 3);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_8.getEntityType(typeID, data, true));
|
||||
});
|
||||
|
||||
// Create last 3 shorts
|
||||
handler(wrapper -> {
|
||||
int data = wrapper.get(Type.INT, 0); // Data (1st Integer)
|
||||
|
@ -101,7 +103,7 @@ public class SpawnPackets {
|
|||
final int data = wrapper.get(Type.INT, 0); // Data
|
||||
|
||||
int typeID = wrapper.get(Type.BYTE, 0);
|
||||
if (EntityTypes1_10.getTypeFromId(typeID, true) == EntityTypes1_10.EntityType.SPLASH_POTION) {
|
||||
if (EntityTypes1_8.getEntityType(typeID, data, true) == EntityTypes1_8.EntityType.POTION) {
|
||||
// Convert this to meta data, woo!
|
||||
PacketWrapper metaPacket = wrapper.create(ClientboundPackets1_9.ENTITY_METADATA, wrapper1 -> {
|
||||
wrapper1.write(Type.VAR_INT, entityID);
|
||||
|
@ -131,7 +133,7 @@ public class SpawnPackets {
|
|||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.EXPERIENCE_ORB);
|
||||
tracker.addEntity(entityID, EntityTypes1_8.EntityType.XP_ORB);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 1 - X - Needs to be divided by 32
|
||||
|
@ -152,7 +154,7 @@ public class SpawnPackets {
|
|||
// Currently only lightning uses this
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.LIGHTNING);
|
||||
tracker.addEntity(entityID, EntityTypes1_8.EntityType.LIGHTNING);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
|
||||
|
@ -178,7 +180,7 @@ public class SpawnPackets {
|
|||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
int typeID = wrapper.get(Type.UNSIGNED_BYTE, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.getTypeFromId(typeID, false));
|
||||
tracker.addEntity(entityID, EntityTypes1_8.getEntityType(typeID, null, false));
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
|
||||
|
@ -224,7 +226,7 @@ public class SpawnPackets {
|
|||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PAINTING);
|
||||
tracker.addEntity(entityID, EntityTypes1_8.EntityType.PAINTING);
|
||||
});
|
||||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
|
@ -248,7 +250,7 @@ public class SpawnPackets {
|
|||
handler(wrapper -> {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
tracker.addEntity(entityID, EntityTypes1_10.EntityType.PLAYER);
|
||||
tracker.addEntity(entityID, EntityTypes1_8.EntityType.PLAYER);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
|
||||
|
|
|
@ -24,6 +24,7 @@ import com.viaversion.viaversion.api.legacy.bossbar.BossBar;
|
|||
import com.viaversion.viaversion.api.legacy.bossbar.BossColor;
|
||||
import com.viaversion.viaversion.api.legacy.bossbar.BossStyle;
|
||||
import com.viaversion.viaversion.api.minecraft.Position;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.item.DataItem;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
|
@ -73,7 +74,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
private Item itemInSecondHand = null;
|
||||
|
||||
public EntityTracker1_9(UserConnection user) {
|
||||
super(user, EntityType.PLAYER);
|
||||
super(user, EntityTypes1_8.EntityType.PLAYER);
|
||||
}
|
||||
|
||||
public UUID getEntityUUID(int id) {
|
||||
|
@ -161,6 +162,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
blockInteractions.add(p);
|
||||
}
|
||||
|
||||
@Deprecated // TODO most of this code seems to be wrong and should be removed
|
||||
public void handleMetadata(int entityId, List<Metadata> metadataList) {
|
||||
com.viaversion.viaversion.api.minecraft.entities.EntityType type = entityType(entityId);
|
||||
if (type == null) {
|
||||
|
@ -169,34 +171,34 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
|
||||
for (Metadata metadata : new ArrayList<>(metadataList)) {
|
||||
// Fix: wither (crash fix)
|
||||
if (type == EntityType.WITHER) {
|
||||
if (type == EntityTypes1_8.EntityType.WITHER) {
|
||||
if (metadata.id() == 10) {
|
||||
metadataList.remove(metadata);
|
||||
//metadataList.add(new Metadata(10, NewType.Byte.getTypeID(), Type.BYTE, 0));
|
||||
}
|
||||
}
|
||||
// Fix: enderdragon (crash fix)
|
||||
if (type == EntityType.ENDER_DRAGON) {
|
||||
if (type == EntityTypes1_8.EntityType.ENDER_DRAGON) {
|
||||
if (metadata.id() == 11) {
|
||||
metadataList.remove(metadata);
|
||||
// metadataList.add(new Metadata(11, NewType.Byte.getTypeID(), Type.VAR_INT, 0));
|
||||
}
|
||||
}
|
||||
|
||||
if (type == EntityType.SKELETON) {
|
||||
if (type == EntityTypes1_8.EntityType.SKELETON) {
|
||||
if ((getMetaByIndex(metadataList, 12)) == null) {
|
||||
metadataList.add(new Metadata(12, MetaType1_9.Boolean, true));
|
||||
}
|
||||
}
|
||||
|
||||
//ECHOPET Patch
|
||||
if (type == EntityType.HORSE) {
|
||||
if (type == EntityTypes1_8.EntityType.HORSE) {
|
||||
// Wrong metadata value from EchoPet, patch since it's discontinued. (https://github.com/DSH105/EchoPet/blob/06947a8b08ce40be9a518c2982af494b3b99d140/modules/API/src/main/java/com/dsh105/echopet/compat/api/entity/HorseArmour.java#L22)
|
||||
if (metadata.id() == 16 && (int) metadata.getValue() == Integer.MIN_VALUE)
|
||||
metadata.setValue(0);
|
||||
}
|
||||
|
||||
if (type == EntityType.PLAYER) {
|
||||
if (type == EntityTypes1_8.EntityType.PLAYER) {
|
||||
if (metadata.id() == 0) {
|
||||
// Byte
|
||||
byte data = (byte) metadata.getValue();
|
||||
|
@ -221,7 +223,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
));
|
||||
}
|
||||
}
|
||||
if (type == EntityType.ARMOR_STAND && Via.getConfig().isHologramPatch()) {
|
||||
if (type == EntityTypes1_8.EntityType.ARMOR_STAND && Via.getConfig().isHologramPatch()) {
|
||||
if (metadata.id() == 0 && getMetaByIndex(metadataList, 10) != null) {
|
||||
Metadata meta = getMetaByIndex(metadataList, 10); //Only happens if the armorstand is small
|
||||
byte data = (byte) metadata.getValue();
|
||||
|
@ -250,11 +252,11 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
}
|
||||
// Boss bar
|
||||
if (Via.getConfig().isBossbarPatch()) {
|
||||
if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
|
||||
if (type == EntityTypes1_8.EntityType.ENDER_DRAGON || type == EntityTypes1_8.EntityType.WITHER) {
|
||||
if (metadata.id() == 2) {
|
||||
BossBar bar = bossBarMap.get(entityId);
|
||||
String title = (String) metadata.getValue();
|
||||
title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE) : title;
|
||||
title = title.isEmpty() ? (type == EntityTypes1_8.EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE) : title;
|
||||
if (bar == null) {
|
||||
bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, BossColor.PINK, BossStyle.SOLID);
|
||||
bossBarMap.put(entityId, bar);
|
||||
|
@ -269,10 +271,10 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
|||
} else if (metadata.id() == 6 && !Via.getConfig().isBossbarAntiflicker()) { // If anti flicker is enabled, don't update health
|
||||
BossBar bar = bossBarMap.get(entityId);
|
||||
// Make health range between 0 and 1
|
||||
float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
|
||||
float maxHealth = type == EntityTypes1_8.EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
|
||||
float health = Math.max(0.0f, Math.min(((float) metadata.getValue()) / maxHealth, 1.0f));
|
||||
if (bar == null) {
|
||||
String title = type == EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE;
|
||||
String title = type == EntityTypes1_8.EntityType.ENDER_DRAGON ? DRAGON_TRANSLATABLE : WITHER_TRANSLATABLE;
|
||||
bar = Via.getAPI().legacyAPI().createLegacyBossBar(title, health, BossColor.PINK, BossStyle.SOLID);
|
||||
bossBarMap.put(entityId, bar);
|
||||
bar.addConnection(user());
|
||||
|
|
Loading…
Reference in New Issue