mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-02-15 03:41:23 +01:00
Check minecart metadata presence instead of always setting default as stone
This commit is contained in:
parent
7e87f2ff27
commit
7a99819c0a
@ -1869,8 +1869,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
||||||
}
|
}
|
||||||
|
@ -1927,8 +1927,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
||||||
}
|
}
|
||||||
|
@ -1935,8 +1935,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(Block.getByCombinedId(mat.getId()).getBlock().getBlockData());
|
minecart.setDisplayBlock(Block.getByCombinedId(mat.getId()).getBlock().getBlockData());
|
||||||
}
|
}
|
||||||
|
@ -2036,8 +2036,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
||||||
}
|
}
|
||||||
|
@ -2110,8 +2110,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
||||||
}
|
}
|
||||||
|
@ -2149,14 +2149,13 @@ public class NMSImpl implements NMSBridge {
|
|||||||
return navigation.m();
|
return navigation.m();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static void minecartItemLogic(EntityMinecartAbstract minecart) {
|
public static void minecartItemLogic(EntityMinecartAbstract minecart) {
|
||||||
NPC npc = ((NPCHolder) minecart).getNPC();
|
NPC npc = ((NPCHolder) minecart).getNPC();
|
||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
||||||
}
|
}
|
||||||
|
@ -2146,8 +2146,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
minecart.setDisplayBlock(IRegistry.BLOCK.get(MinecraftKey.a(mat.getKey().toString())).getBlockData());
|
||||||
}
|
}
|
||||||
|
@ -2146,8 +2146,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
|
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (minecart.hasCustomDisplay()) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlockState(
|
minecart.setDisplayBlockState(
|
||||||
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
||||||
|
@ -2154,8 +2154,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
|
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (minecart.hasCustomDisplay()) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlockState(
|
minecart.setDisplayBlockState(
|
||||||
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
Registry.BLOCK.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
||||||
|
@ -2387,8 +2387,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
|
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (minecart.hasCustomDisplay()) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
||||||
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
||||||
|
@ -2462,8 +2462,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
|
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (minecart.hasCustomDisplay()) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
||||||
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
.get(ResourceLocation.tryParse(mat.getKey().toString())).defaultBlockState());
|
||||||
|
@ -2346,8 +2346,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.setCustomDisplay(npc.getItemProvider().get() != null);
|
minecart.setCustomDisplay(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (minecart.hasCustomDisplay()) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
minecart.setDisplayBlockState(BuiltInRegistries.BLOCK
|
||||||
.getValue(ResourceLocation.parse(mat.getKey().toString())).defaultBlockState());
|
.getValue(ResourceLocation.parse(mat.getKey().toString())).defaultBlockState());
|
||||||
|
@ -1731,8 +1731,8 @@ public class NMSImpl implements NMSBridge {
|
|||||||
if (npc == null)
|
if (npc == null)
|
||||||
return;
|
return;
|
||||||
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
int offset = npc.data().get(NPC.Metadata.MINECART_OFFSET, 0);
|
||||||
minecart.a(npc.getItemProvider().get() != null);
|
minecart.a(npc.data().has(NPC.Metadata.ITEM_ID));
|
||||||
if (npc.getItemProvider().get() != null) {
|
if (npc.data().has(NPC.Metadata.ITEM_ID)) {
|
||||||
Material mat = npc.getItemProvider().get().getType();
|
Material mat = npc.getItemProvider().get().getType();
|
||||||
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
minecart.setDisplayBlock(Block.getById(mat.getId()).fromLegacyData(0));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user