Check minecart metadata presence instead of always setting default as stone

This commit is contained in:
fullwall 2025-01-09 21:39:56 +08:00
parent 7e87f2ff27
commit 7a99819c0a
13 changed files with 26 additions and 27 deletions

View File

@ -1869,8 +1869,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
}

View File

@ -1927,8 +1927,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
}

View File

@ -1935,8 +1935,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(Block.getByCombinedId(mat.getId()).getBlock().getBlockData());
}

View File

@ -2036,8 +2036,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
}

View File

@ -2110,8 +2110,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
}

View File

@ -2149,14 +2149,13 @@ public class NMSImpl implements NMSBridge {
return navigation.m();
}
@SuppressWarnings("deprecation")
public static void minecartItemLogic(EntityMinecartAbstract minecart) {
NPC npc = ((NPCHolder) minecart).getNPC();
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
}

View File

@ -2146,8 +2146,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
}

View File

@ -2146,8 +2146,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
if (minecart.hasCustomDisplay()) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlockState(
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());

View File

@ -2154,8 +2154,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
if (minecart.hasCustomDisplay()) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlockState(
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());

View File

@ -2387,8 +2387,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
if (minecart.hasCustomDisplay()) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());

View File

@ -2462,8 +2462,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
if (minecart.hasCustomDisplay()) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());

View File

@ -2346,8 +2346,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
if (minecart.hasCustomDisplay()) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
.getValue(ResourceLocation.parse(mat.getKey().toString())).defaultBlockState());

View File

@ -1731,8 +1731,8 @@ public class NMSImpl implements NMSBridge {
if (npc == null)
return;
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
minecart.a(npc.getItemProvider().get() != null);
if (npc.getItemProvider().get() != null) {
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
Material mat = npc.getItemProvider().get().getType();
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
}