Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-11-03 14:50:19 +01:00
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>
Dieser Commit ist enthalten in:
Ursprung
ac5ab229f9
Commit
5bb345daa6
@ -34,6 +34,11 @@ import org.geysermc.connector.network.translators.world.block.BlockTranslator;
|
|||||||
|
|
||||||
public class FurnaceMinecartEntity extends MinecartEntity {
|
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) {
|
public FurnaceMinecartEntity(long entityId, long geyserId, EntityType entityType, Vector3f position, Vector3f motion, Vector3f rotation) {
|
||||||
super(entityId, geyserId, entityType, position, motion, rotation);
|
super(entityId, geyserId, entityType, position, motion, rotation);
|
||||||
|
|
||||||
@ -43,12 +48,39 @@ public class FurnaceMinecartEntity extends MinecartEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateBedrockMetadata(EntityMetadata entityMetadata, GeyserSession session) {
|
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);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,6 +55,7 @@ public class MinecartEntity extends Entity {
|
|||||||
metadata.put(EntityData.HURT_TIME, Math.min((int) (float) entityMetadata.getValue(), 15));
|
metadata.put(EntityData.HURT_TIME, Math.min((int) (float) entityMetadata.getValue(), 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(this instanceof FurnaceMinecartEntity)) { // Handled in FurnaceMinecartEntity.java
|
||||||
// Custom block
|
// Custom block
|
||||||
if (entityMetadata.getId() == 10) {
|
if (entityMetadata.getId() == 10) {
|
||||||
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
|
metadata.put(EntityData.DISPLAY_ITEM, BlockTranslator.getBedrockBlockId((int) entityMetadata.getValue()));
|
||||||
@ -70,6 +71,7 @@ public class MinecartEntity extends Entity {
|
|||||||
// Needs a byte based off of Java's boolean
|
// Needs a byte based off of Java's boolean
|
||||||
metadata.put(EntityData.HAS_DISPLAY, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
|
metadata.put(EntityData.HAS_DISPLAY, (byte) ((boolean) entityMetadata.getValue() ? 1 : 0));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.updateBedrockMetadata(entityMetadata, session);
|
super.updateBedrockMetadata(entityMetadata, session);
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren