TankUnit IO scaled with capacity. Closes TechReborn/TechReborn/#2193
This commit is contained in:
parent
b01526f66d
commit
a49f4016d9
1 changed files with 24 additions and 27 deletions
|
@ -71,15 +71,21 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
this.tank = new Tank("TankStorage", type.capacity, this);
|
this.tank = new Tank("TankStorage", type.capacity, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ItemStack getDropWithNBT() {
|
||||||
|
ItemStack dropStack = new ItemStack(getBlockType(), 1);
|
||||||
|
final CompoundTag blockEntity = new CompoundTag();
|
||||||
|
this.toTag(blockEntity);
|
||||||
|
dropStack.setTag(new CompoundTag());
|
||||||
|
dropStack.getOrCreateTag().put("blockEntity", blockEntity);
|
||||||
|
return dropStack;
|
||||||
|
}
|
||||||
|
|
||||||
|
// MachineBaseBlockEntity
|
||||||
@Override
|
@Override
|
||||||
public void tick() {
|
public void tick() {
|
||||||
super.tick();
|
super.tick();
|
||||||
|
|
||||||
if (world == null){
|
if (world == null || world.isClient()){
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (world.isClient()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,24 +129,25 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
return tagCompound;
|
return tagCompound;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getDropWithNBT() {
|
@Override
|
||||||
ItemStack dropStack = new ItemStack(getBlockType(), 1);
|
public FluidValue fluidTransferAmount() {
|
||||||
final CompoundTag blockEntity = new CompoundTag();
|
// Full capacity should be filled in four minutes (4 minutes * 20 ticks per second / slotTransferSpeed equals 4)
|
||||||
this.toTag(blockEntity);
|
return type.capacity.fraction(1200);
|
||||||
dropStack.setTag(new CompoundTag());
|
|
||||||
dropStack.getOrCreateTag().put("blockEntity", blockEntity);
|
|
||||||
return dropStack;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ItemHandlerProvider
|
// InventoryProvider
|
||||||
@Override
|
@Override
|
||||||
public RebornInventory<TankUnitBaseBlockEntity> getInventory() {
|
public RebornInventory<TankUnitBaseBlockEntity> getInventory() {
|
||||||
return this.inventory;
|
return this.inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IToolDrop
|
||||||
|
@Override
|
||||||
|
public ItemStack getToolDrop(PlayerEntity playerEntity) {
|
||||||
|
return getDropWithNBT();
|
||||||
|
}
|
||||||
|
|
||||||
// IListInfoProvider
|
// IListInfoProvider
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
@Override
|
@Override
|
||||||
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
public void addInfo(final List<Text> info, final boolean isReal, boolean hasData) {
|
||||||
if (isReal || hasData) {
|
if (isReal || hasData) {
|
||||||
|
@ -157,17 +164,12 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
info.add(
|
info.add(
|
||||||
new TranslatableText("techreborn.tooltip.unit.capacity")
|
new TranslatableText("techreborn.tooltip.unit.capacity")
|
||||||
.formatted(Formatting.GRAY)
|
.formatted(Formatting.GRAY)
|
||||||
.append(
|
.append(new LiteralText(String.valueOf(this.tank.getCapacity()))
|
||||||
new LiteralText(String.valueOf(this.tank.getCapacity()))
|
.formatted(Formatting.GOLD))
|
||||||
.formatted(Formatting.GOLD)
|
|
||||||
.append(" (")
|
|
||||||
.append(String.valueOf(this.tank.getCapacity().getRawValue() / 1000))
|
|
||||||
.append(")")
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// IContainerProvider
|
// BuiltScreenHandlerProvider
|
||||||
@Override
|
@Override
|
||||||
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
public BuiltScreenHandler createScreenHandler(int syncID, final PlayerEntity player) {
|
||||||
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
|
return new ScreenHandlerBuilder("tank").player(player.inventory).inventory().hotbar()
|
||||||
|
@ -185,9 +187,4 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
|
||||||
public void setTank(Tank tank) {
|
public void setTank(Tank tank) {
|
||||||
this.tank.setFluid(null, tank.getFluidInstance());
|
this.tank.setFluid(null, tank.getFluidInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack getToolDrop(PlayerEntity playerEntity) {
|
|
||||||
return getDropWithNBT();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue