Fix & Improve state comparison when checking vanilla block replacements (#5922)
This commit is contained in:
parent
1bd70ac5ab
commit
ae3d002ac6
|
@ -387,6 +387,7 @@ project(':forge') {
|
|||
fmllauncherImplementation 'com.google.guava:guava:21.0'
|
||||
fmllauncherImplementation 'com.google.code.gson:gson:2.8.0'
|
||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.0.0'
|
||||
testImplementation 'org.junit.vintage:junit-vintage-engine:5.+'
|
||||
testImplementation 'org.opentest4j:opentest4j:1.0.0' // needed for junit 5
|
||||
testImplementation 'org.hamcrest:hamcrest-all:1.3' // needs advanced matching for list order
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
world.func_184133_a(playerentity, blockpos, this.func_219983_a(blockstate1), SoundCategory.BLOCKS, (soundtype.func_185843_a() + 1.0F) / 2.0F, soundtype.func_185847_b() * 0.8F);
|
||||
itemstack.func_190918_g(1);
|
||||
return ActionResultType.SUCCESS;
|
||||
@@ -189,6 +189,10 @@
|
||||
@@ -189,10 +189,18 @@
|
||||
}
|
||||
|
||||
public Block func_179223_d() {
|
||||
|
@ -20,3 +20,11 @@
|
|||
return this.field_150939_a;
|
||||
}
|
||||
|
||||
public void func_195946_a(Map<Block, Item> p_195946_1_, Item p_195946_2_) {
|
||||
p_195946_1_.put(this.func_179223_d(), p_195946_2_);
|
||||
}
|
||||
+
|
||||
+ public void removeFromBlockToItemMap(Map<Block, Item> blockToItemMap, Item itemIn) {
|
||||
+ blockToItemMap.remove(this.func_179223_d());
|
||||
+ }
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
--- a/net/minecraft/item/WallOrFloorItem.java
|
||||
+++ b/net/minecraft/item/WallOrFloorItem.java
|
||||
@@ -41,4 +41,9 @@
|
||||
super.func_195946_a(p_195946_1_, p_195946_2_);
|
||||
p_195946_1_.put(this.field_195947_b, p_195946_2_);
|
||||
}
|
||||
+
|
||||
+ public void removeFromBlockToItemMap(Map<Block, Item> blockToItemMap, Item itemIn) {
|
||||
+ super.removeFromBlockToItemMap(blockToItemMap, itemIn);
|
||||
+ blockToItemMap.remove(this.field_195947_b);
|
||||
+ }
|
||||
}
|
|
@ -88,8 +88,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static net.minecraftforge.registries.ForgeRegistry.REGISTRIES;
|
||||
|
||||
import net.minecraftforge.fml.common.EnhancedRuntimeException.WrappedPrintStream;
|
||||
|
||||
/**
|
||||
* INTERNAL ONLY
|
||||
* MODDERS SHOULD HAVE NO REASON TO USE THIS CLASS
|
||||
|
@ -375,15 +373,9 @@ public class GameData
|
|||
{
|
||||
StateContainer<Block, BlockState> oldContainer = oldBlock.getStateContainer();
|
||||
StateContainer<Block, BlockState> newContainer = block.getStateContainer();
|
||||
ImmutableList<BlockState> oldValidStates = oldContainer.getValidStates();
|
||||
ImmutableList<BlockState> newValidStates = newContainer.getValidStates();
|
||||
|
||||
// Test vanilla blockstates, if the number matches, make sure they also match in their string representations
|
||||
if (block.getRegistryName().getNamespace().equals("minecraft") && (
|
||||
oldValidStates.size() != newValidStates.size() ||
|
||||
!Streams.zip(oldValidStates.stream().map(Object::toString),
|
||||
newValidStates.stream().map(Object::toString),
|
||||
String::equals).allMatch(v -> v)))
|
||||
if (block.getRegistryName().getNamespace().equals("minecraft") && !oldContainer.getProperties().equals(newContainer.getProperties()))
|
||||
{
|
||||
String oldSequence = oldContainer.getProperties().stream()
|
||||
.map(s -> String.format("%s={%s}", s.getName(),
|
||||
|
@ -482,8 +474,8 @@ public class GameData
|
|||
if (oldItem instanceof BlockItem)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
BiMap<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, BiMap.class);
|
||||
blockToItem.remove(((BlockItem)oldItem).getBlock());
|
||||
Map<Block, Item> blockToItem = owner.getSlaveMap(BLOCK_TO_ITEM, Map.class);
|
||||
((BlockItem)oldItem).removeFromBlockToItemMap(blockToItem, item);
|
||||
}
|
||||
if (item instanceof BlockItem)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue