Fix tooltip for cables and typo for solar panels.

This commit is contained in:
drcrazy 2019-09-27 16:42:17 +03:00
parent f77bc65316
commit 106b8e25ba
4 changed files with 23 additions and 14 deletions

View file

@ -44,7 +44,7 @@ import team.reborn.energy.Energy;
import team.reborn.energy.EnergySide;
import team.reborn.energy.EnergyStorage;
import team.reborn.energy.EnergyTier;
import techreborn.blocks.cable.BlockCable;
import techreborn.blocks.cable.CableBlock;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
@ -68,11 +68,22 @@ public class CableBlockEntity extends BlockEntity
public CableBlockEntity() {
super(TRBlockEntities.CABLE);
}
public CableBlockEntity(TRContent.Cables type) {
super(TRBlockEntities.CABLE);
this.cableType = type;
}
private TRContent.Cables getCableType() {
if (cableType != null) {
return cableType;
}
if (world == null) {
return TRContent.Cables.COPPER;
}
Block block = world.getBlockState(pos).getBlock();
if(block instanceof BlockCable){
return ((BlockCable) block).type;
if(block instanceof CableBlock){
return ((CableBlock) block).type;
}
//Something has gone wrong if this happens
return TRContent.Cables.COPPER;
@ -161,13 +172,11 @@ public class CableBlockEntity extends BlockEntity
// IListInfoProvider
@Override
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
if (isReal) {
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": "
+ Formatting.GOLD
+ PowerSystem.getLocaliszedPowerFormatted(transferRate) + "/t"));
+ PowerSystem.getLocaliszedPowerFormatted(getCableType().transferRate) + "/t"));
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": "
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(cableType.tier.toString())));
}
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getCableType().tier.toString())));
}
// IToolDrop

View file

@ -156,7 +156,7 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.day") + ": "
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)));
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.day") + ": "
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.night") + ": "
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)));
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("reborncore.tooltip.energy.tier") + ": "

View file

@ -60,7 +60,7 @@ import javax.annotation.Nullable;
/**
* Created by modmuss50 on 19/05/2017.
*/
public class BlockCable extends BlockWithEntity {
public class CableBlock extends BlockWithEntity {
public static final BooleanProperty EAST = BooleanProperty.of("east");
public static final BooleanProperty WEST = BooleanProperty.of("west");
@ -71,7 +71,7 @@ public class BlockCable extends BlockWithEntity {
public final TRContent.Cables type;
public BlockCable(TRContent.Cables type) {
public CableBlock(TRContent.Cables type) {
super(Block.Settings.of(Material.STONE).strength(1f, 8f));
this.type = type;
setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false)
@ -127,7 +127,7 @@ public class BlockCable extends BlockWithEntity {
@Nullable
@Override
public BlockEntity createBlockEntity(BlockView worldIn) {
return new CableBlockEntity();
return new CableBlockEntity(type);
}
// Block

View file

@ -50,7 +50,7 @@ import techreborn.blockentity.machine.tier1.*;
import techreborn.blockentity.machine.tier3.*;
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
import techreborn.blocks.*;
import techreborn.blocks.cable.BlockCable;
import techreborn.blocks.cable.CableBlock;
import techreborn.blocks.generator.*;
import techreborn.blocks.lighting.BlockLamp;
import techreborn.blocks.storage.*;
@ -258,7 +258,7 @@ public class TRContent {
public final String name;
public final BlockCable block;
public final CableBlock block;
public int transferRate;
public int defaultTransferRate;
@ -276,7 +276,7 @@ public class TRContent {
this.canKill = canKill;
this.defaultCanKill = canKill;
this.tier = tier;
this.block = new BlockCable(this);
this.block = new CableBlock(this);
InitUtils.setup(block, name + "_cable");
}