Cables got tooltip update. Closes #1627
This commit is contained in:
parent
9f3a3eb026
commit
7ce4a022af
2 changed files with 24 additions and 11 deletions
|
@ -145,7 +145,7 @@ public class BlockCable extends BlockContainer {
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||||
return new TileCable();
|
return new TileCable(getStateFromMeta(meta).getValue(TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Block
|
// Block
|
||||||
|
|
|
@ -60,8 +60,22 @@ public class TileCable extends TileEntity
|
||||||
private ArrayList<EnumFacing> sendingFace = new ArrayList<EnumFacing>();
|
private ArrayList<EnumFacing> sendingFace = new ArrayList<EnumFacing>();
|
||||||
int ticksSinceLastChange = 0;
|
int ticksSinceLastChange = 0;
|
||||||
|
|
||||||
private EnumCableType getCableType() {
|
//MC calls this during world load. Keep it, please.
|
||||||
return world.getBlockState(pos).getValue(BlockCable.TYPE);
|
public TileCable() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public TileCable(EnumCableType cableType) {
|
||||||
|
this.cableType = cableType;
|
||||||
|
this.transferRate = cableType.transferRate * RebornCoreConfig.euPerFU;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCableType() {
|
||||||
|
if (cableType == null) {
|
||||||
|
cableType = world.getBlockState(pos).getValue(BlockCable.TYPE);
|
||||||
|
transferRate = cableType.transferRate * RebornCoreConfig.euPerFU;
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canReceiveFromFace(EnumFacing face) {
|
public boolean canReceiveFromFace(EnumFacing face) {
|
||||||
|
@ -132,8 +146,7 @@ public class TileCable extends TileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cableType == null ){
|
if (cableType == null ){
|
||||||
cableType = getCableType();
|
updateCableType();
|
||||||
transferRate = cableType.transferRate * RebornCoreConfig.euPerFU;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ticksSinceLastChange++;
|
ticksSinceLastChange++;
|
||||||
|
@ -187,8 +200,9 @@ public class TileCable extends TileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
int energyReceived = Math.min(getMaxEnergyStored() - getEnergyStored(), Math.min(transferRate, maxReceive));
|
int energyReceived = Math.min(getMaxEnergyStored() - getEnergyStored(), Math.min(transferRate, maxReceive));
|
||||||
if (!simulate)
|
if (!simulate) {
|
||||||
power += energyReceived;
|
power += energyReceived;
|
||||||
|
}
|
||||||
return energyReceived;
|
return energyReceived;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,8 +213,9 @@ public class TileCable extends TileEntity
|
||||||
}
|
}
|
||||||
|
|
||||||
int energyExtracted = Math.min(getEnergyStored(), Math.min(transferRate, maxExtract));
|
int energyExtracted = Math.min(getEnergyStored(), Math.min(transferRate, maxExtract));
|
||||||
if (!simulate)
|
if (!simulate) {
|
||||||
power -= energyExtracted;
|
power -= energyExtracted;
|
||||||
|
}
|
||||||
return energyExtracted;
|
return energyExtracted;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,18 +248,16 @@ public class TileCable extends TileEntity
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(List<String> info, boolean isRealTile) {
|
public void addInfo(List<String> info, boolean isRealTile) {
|
||||||
if (isRealTile) {
|
|
||||||
info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": "
|
info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": "
|
||||||
+ TextFormatting.GOLD
|
+ TextFormatting.GOLD
|
||||||
+ PowerSystem.getLocaliszedPowerFormatted(transferRate / RebornCoreConfig.euPerFU) + "/t");
|
+ PowerSystem.getLocaliszedPowerFormatted(transferRate / RebornCoreConfig.euPerFU) + "/t");
|
||||||
info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": "
|
info.add(TextFormatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": "
|
||||||
+ TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(this.cableType.tier.toString()));
|
+ TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(cableType.tier.toString()));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IToolDrop
|
// IToolDrop
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
public ItemStack getToolDrop(EntityPlayer playerIn) {
|
||||||
return getCableType().getStack();
|
return cableType.getStack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue