Fixes #172
This commit is contained in:
parent
caca45d86b
commit
8a494a392c
3 changed files with 23 additions and 0 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue