mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-14 01:24:09 +00:00
Keep entity hash consistent with equals, and campfire interaction handled
ScriptEntity.hashCode included tempData while equals compares only the entity, so two wrappers of the same entity hashed differently - and tempData is mutable and swapped wholesale by copyTempData, so an entry's hash could change while it sat in a map. BlockCampfire.onBlockActivated went from returning true to false, which lets the held item be used or placed on top of the interaction. Restored.
This commit is contained in:
1 parent
22a8ef5036
commit
67ddaaab6f
2 files changed
+6
-3
No files matched your search
@@ -39,7 +39,7 @@ public class BlockCampfire extends BlockLightable {
|
||||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
|
||||
ItemStack item = player.inventory.getCurrentItem();
|
||||
if (item == null)
|
||||
return false;
|
||||
return true;
|
||||
|
||||
if ((item.getItem() == Items.flint || item.getItem() == Items.flint_and_steel) && unlitBlock() == this) {
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
@@ -55,7 +55,7 @@ public class BlockCampfire extends BlockLightable {
|
||||
super.onBlockActivated(world, x, y, z, player, par6, par7, par8, par9);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -982,7 +982,10 @@ public class ScriptEntity<T extends Entity> implements IEntity {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(entity, tempData);
|
||||
// Must key on exactly what equals compares. tempData is mutable and swapped wholesale by
|
||||
// copyTempData, so including it would give two wrappers of the same entity different
|
||||
// hashes - and would change an entry's hash while it sat in a map.
|
||||
return Objects.hashCode(entity);
|
||||
}
|
||||
|
||||
public void updateEntity() {
|
||||
|
||||
Reference in new issue
Block a user