Skip to content

Commit

Permalink
Merge pull request #3123 from iTitus/fix-3119
Browse files Browse the repository at this point in the history
Fix #3119
  • Loading branch information
asiekierka committed Nov 9, 2015
2 parents 294def3 + ec39cec commit 16831f6
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions common/buildcraft/robotics/EntityRobot.java
Expand Up @@ -11,9 +11,11 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.WeakHashMap;

import com.google.common.collect.Iterables;
import com.google.common.collect.Sets;
import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property;
import io.netty.buffer.ByteBuf;
Expand All @@ -26,6 +28,7 @@
import net.minecraft.entity.monster.IMob;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemSkull;
import net.minecraft.item.ItemStack;
Expand Down Expand Up @@ -99,6 +102,8 @@ public class EntityRobot extends EntityRobotBase implements
DefaultProps.TEXTURE_PATH_ROBOTS + "/robot_base.png");
public static final int MAX_WEARABLES = 8;

private static Set<Integer> blacklistedItemsForUpdate = Sets.newHashSet();

public LaserData laser = new LaserData();
public DockingStation linkedDockingStation;
public BlockIndex linkedDockingStationIndex;
Expand Down Expand Up @@ -368,6 +373,18 @@ public void onEntityUpdate() {
}
}


// tick all carried itemstacks
for (int i = 0; i < inv.length; i++) {
updateItem(inv[i], i, false);
}

// tick the item the robot is currently holding
updateItem(itemInUse, 0, true);

// do not tick wearables or equipment from EntityLiving


super.onEntityUpdate();
this.worldObj.theProfiler.endSection();
}
Expand Down Expand Up @@ -1494,4 +1511,20 @@ public int receiveEnergy(int maxReceive, boolean simulate) {
public List<ItemStack> getWearables() {
return wearables;
}

private void updateItem(ItemStack stack, int i, boolean held) {
if (stack != null && stack.getItem() != null) {
int id = Item.getIdFromItem(stack.getItem());
// did this item not throw an exception before?
if (!blacklistedItemsForUpdate.contains(id)) {
try {
stack.getItem().onUpdate(stack, worldObj, this, i, held);
} catch (Exception e) {
// the item threw an exception, print it and do not let it update once more
e.printStackTrace();
blacklistedItemsForUpdate.add(id);
}
}
}
}
}

0 comments on commit 16831f6

Please sign in to comment.