Fix new minecart with block breaking furnace minecart display (#717)

This handles DISPLAY_ITEM and related properties separately on furnace minecarts in order to prevent overwriting furnace minecart graphics.

Co-authored-by: DoctorMacc <toy.fighter1@gmail.com>
This commit is contained in:
rtm516 2020-06-01 20:59:46 +01:00 committed by GitHub
parent ac5ab229f9
commit 5bb345daa6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 15 deletions

View file

@ -34,6 +34,11 @@ import org.geysermc.connector.network.translators.world.block.BlockTranslator;
public class FurnaceMinecartEntity extends MinecartEntity {
private int customBlock = 0;
private int customBlockOffset = 0;
private boolean showCustomBlock = false;
private boolean hasFuel = false;
public FurnaceMinecartEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
super(entityId, geyserId, entityType, position, motion, rotation);
@ -43,12 +48,39 @@ public class FurnaceMinecartEntity extends MinecartEntity {
@Override
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
if (entityMetadata.getId() == 13) {
boolean hasFuel = (boolean) entityMetadata.getValue();
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId(hasFuel ? BlockTranslator.JAVA_RUNTIME_FURNACE_LIT_ID : BlockTranslator.JAVA_RUNTIME_FURNACE_ID));
// Custom block
if (entityMetadata.getId() == 10) {
customBlock = (int) entityMetadata.getValue();
}
// Custom block offset
if (entityMetadata.getId() == 11) {
customBlockOffset = (int) entityMetadata.getValue();
}
// If the custom block should be enabled
if (entityMetadata.getId() == 12) {
if ((boolean) entityMetadata.getValue()) {
showCustomBlock = true;
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId(customBlock));
metadata.put(EntityData.DISPLAY_OFFSET, customBlockOffset);
} else {
showCustomBlock = false;
updateFurnaceMetadata();
}
}
if (entityMetadata.getId() == 13 && !showCustomBlock) {
hasFuel = (boolean) entityMetadata.getValue();
updateFurnaceMetadata();
}
super.updateBedrockMetadata(entityMetadata, session);
}
private void updateFurnaceMetadata() {
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId(hasFuel ? BlockTranslator.JAVA_RUNTIME_FURNACE_LIT_ID : BlockTranslator.JAVA_RUNTIME_FURNACE_ID));
metadata.put(EntityData.DISPLAY_OFFSET, 6);
}
}

View file

@ -55,20 +55,22 @@ public class MinecartEntity extends Entity {
metadata.put(EntityData.HURT_TIME, Math.min((int) (float) entityMetadata.getValue(), 15));
}
// Custom block
if (entityMetadata.getId() == 10) {
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
}
if (!(this instanceof FurnaceMinecartEntity)) { // Handled in FurnaceMinecartEntity.java
// Custom block
if (entityMetadata.getId() == 10) {
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
}
// Custom block offset
if (entityMetadata.getId() == 11) {
metadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getValue());
}
// Custom block offset
if (entityMetadata.getId() == 11) {
metadata.put(EntityData.DISPLAY_OFFSET, entityMetadata.getValue());
}
// If the custom block should be enabled
if (entityMetadata.getId() == 12) {
// Needs a byte based off of Java's boolean
metadata.put(EntityData.HAS_DISPLAY, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
// If the custom block should be enabled
if (entityMetadata.getId() == 12) {
// Needs a byte based off of Java's boolean
metadata.put(EntityData.HAS_DISPLAY, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
}
}
super.updateBedrockMetadata(entityMetadata, session);