diff --git a/src/main/java/techreborn/blocks/storage/BlockIDSU.java b/src/main/java/techreborn/blocks/storage/BlockIDSU.java index 6c9e1403b..24cd618f7 100644 --- a/src/main/java/techreborn/blocks/storage/BlockIDSU.java +++ b/src/main/java/techreborn/blocks/storage/BlockIDSU.java @@ -4,7 +4,9 @@ import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; +import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; @@ -67,4 +69,13 @@ public class BlockIDSU extends BlockMachineBase { return true; } + @Override + public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack itemstack) { + super.onBlockPlacedBy(world, x, y, z, player, itemstack); + TileEntity tile = world.getTileEntity(x, y, z); + if (tile instanceof TileIDSU) { + ((TileIDSU) tile).ownerUdid = player.getUniqueID().toString(); + } + } + } diff --git a/src/main/java/techreborn/tiles/idsu/IDSUManager.java b/src/main/java/techreborn/tiles/idsu/IDSUManager.java index 53c44b3d1..e74765b43 100644 --- a/src/main/java/techreborn/tiles/idsu/IDSUManager.java +++ b/src/main/java/techreborn/tiles/idsu/IDSUManager.java @@ -119,6 +119,9 @@ public class IDSUManager { } public IDSUValueSaveData getSaves(String udid) { + if(udid == null){ + return null; + } if (idsuValues.containsKey(udid)) { return idsuValues.get(udid); } else { diff --git a/src/main/java/techreborn/tiles/idsu/TileIDSU.java b/src/main/java/techreborn/tiles/idsu/TileIDSU.java index a8b2156ea..ad72fbb7c 100644 --- a/src/main/java/techreborn/tiles/idsu/TileIDSU.java +++ b/src/main/java/techreborn/tiles/idsu/TileIDSU.java @@ -15,11 +15,17 @@ public class TileIDSU extends TilePowerAcceptor { @Override public double getEnergy() { + if(ownerUdid == null){ + return 0; + } return IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower; } @Override public void setEnergy(double energy) { + if(ownerUdid == null){ + return; + } IDSUManager.INSTANCE.getSaveDataForWorld(worldObj, ownerUdid).storedPower = energy; } @@ -92,6 +98,9 @@ public class TileIDSU extends TilePowerAcceptor { public void writeToNBT(NBTTagCompound nbttagcompound) { super.writeToNBT(nbttagcompound); + if(this.ownerUdid == null){ + return; + } nbttagcompound.setString("ownerUdid", this.ownerUdid); }