Reduce copying of positions from block states

This commit is contained in:
md_5
2018-12-22 11:32:11 +11:00
parent 91cae6efbf
commit dff66dfccd
10 changed files with 25 additions and 32 deletions

View File

@@ -85,7 +85,7 @@
EntityHuman entityhuman = itemactioncontext.getEntity();
BlockPosition blockposition = itemactioncontext.getClickPosition();
ShapeDetectorBlock shapedetectorblock = new ShapeDetectorBlock(itemactioncontext.getWorld(), blockposition, false);
@@ -106,12 +146,147 @@
@@ -106,12 +146,144 @@
if (entityhuman != null && !entityhuman.abilities.mayBuild && !this.b(itemactioncontext.getWorld().F(), shapedetectorblock)) {
return EnumInteractionResult.PASS;
} else {
@@ -178,12 +178,9 @@
+ }
+
+ for (BlockState blockstate : blocks) {
+ int x = blockstate.getX();
+ int y = blockstate.getY();
+ int z = blockstate.getZ();
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
+ IBlockData oldBlock = ((CraftBlockState) blockstate).getHandle();
+ BlockPosition newblockposition = new BlockPosition(x, y, z);
+ BlockPosition newblockposition = ((CraftBlockState) blockstate).getPosition();
+ IBlockData block = world.getType(newblockposition);
+
+ if (!(block.getBlock() instanceof BlockTileEntity)) { // Containers get placed automatically
@@ -234,7 +231,7 @@
return enuminteractionresult;
}
@@ -135,7 +310,7 @@
@@ -135,7 +307,7 @@
nbttagcompound.setString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbttagcompound.setByte("Count", (byte) this.count);
if (this.tag != null) {
@@ -243,7 +240,7 @@
}
return nbttagcompound;
@@ -213,6 +388,11 @@
@@ -213,6 +385,11 @@
if (this.isDamaged(i, entityliving.getRandom(), entityliving instanceof EntityPlayer ? (EntityPlayer) entityliving : null)) {
entityliving.c(this);
Item item = this.getItem();
@@ -255,7 +252,7 @@
this.subtract(1);
if (entityliving instanceof EntityHuman) {
@@ -336,6 +516,17 @@
@@ -336,6 +513,17 @@
return this.tag;
}
@@ -273,7 +270,7 @@
public NBTTagCompound getOrCreateTag() {
if (this.tag == null) {
this.setTag(new NBTTagCompound());
@@ -480,6 +671,14 @@
@@ -480,6 +668,14 @@
}
public void setRepairCost(int i) {
@@ -288,7 +285,7 @@
this.getOrCreateTag().setInt("RepairCost", i);
}
@@ -522,6 +721,13 @@
@@ -522,6 +718,13 @@
nbttaglist.add((NBTBase) nbttagcompound);
}