Fixes IDSU not setting the players udid when placed.

This commit is contained in:
modmuss50 2017-06-02 16:16:34 +01:00
parent 029a75522c
commit b4c873f54c
No known key found for this signature in database
GPG key ID: 773D17BE8BF49C82
2 changed files with 11 additions and 2 deletions

View file

@ -65,4 +65,13 @@ public class BlockIDSU extends BlockEnergyStorage {
list.add(new ItemStack(this, 1, 2));
return list;
}
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
TileEntity tile = world.getTileEntity(pos);
if (tile instanceof TileIDSU) {
((TileIDSU) tile).ownerUdid = placer.getUniqueID().toString();
}
}
}

View file

@ -58,7 +58,7 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable {
@Override
public double getEnergy() {
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {
if (ownerUdid == null || ownerUdid.isEmpty()) {
return 0.0;
}
return IDSUManager.INSTANCE.getSaveDataForWorld(world, ownerUdid).storedPower;
@ -66,7 +66,7 @@ public class TileIDSU extends TilePowerAcceptor implements IWrenchable {
@Override
public void setEnergy(double energy) {
if (ownerUdid == null && StringUtils.isBlank(ownerUdid) || StringUtils.isEmpty(ownerUdid)) {
if (ownerUdid == null || ownerUdid.isEmpty()) {
return;
}
IDSUManager.INSTANCE.getSaveDataForWorld(world, ownerUdid).storedPower = energy;