Finish port to 1.18, release alpha
This commit is contained in:
parent
1a1c07d532
commit
e58f9d9591
|
@ -19,16 +19,15 @@
|
|||
package com.teammoeg.steampowered.content.boiler;
|
||||
|
||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.teammoeg.steampowered.FluidRegistry;
|
||||
import com.teammoeg.steampowered.SPConfig;
|
||||
import com.teammoeg.steampowered.content.burner.IHeatReceiver;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluids;
|
||||
|
@ -42,7 +41,7 @@ import net.minecraftforge.fluids.capability.templates.FluidTank;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BoilerTileEntity extends BlockEntity implements IHeatReceiver, IHaveGoggleInformation {
|
||||
public abstract class BoilerTileEntity extends SmartTileEntity implements IHeatReceiver, IHaveGoggleInformation {
|
||||
FluidTank input = new FluidTank(10000,s->s.getFluid() == Fluids.WATER);
|
||||
FluidTank output = new FluidTank(10000);
|
||||
private IFluidHandler ft = new IFluidHandler() {
|
||||
|
@ -98,57 +97,47 @@ public abstract class BoilerTileEntity extends BlockEntity implements IHeatRecei
|
|||
super(type, pos, state);
|
||||
}
|
||||
|
||||
// Easy, easy
|
||||
public void readCustomNBT(CompoundTag nbt) {
|
||||
input.readFromNBT(nbt.getCompound("in"));
|
||||
output.readFromNBT(nbt.getCompound("out"));
|
||||
heatreceived = nbt.getInt("hu");
|
||||
lastheat=nbt.getInt("lasthu");
|
||||
}
|
||||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {}
|
||||
|
||||
// Easy, easy
|
||||
public void writeCustomNBT(CompoundTag nbt) {
|
||||
@Override
|
||||
public void write(CompoundTag nbt, boolean clientPacket) {
|
||||
nbt.put("in", input.writeToNBT(new CompoundTag()));
|
||||
nbt.put("out", output.writeToNBT(new CompoundTag()));
|
||||
nbt.putInt("hu", heatreceived);
|
||||
nbt.putInt("lasthu", lastheat);
|
||||
super.write(nbt, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
readCustomNBT(nbt);
|
||||
public void read(CompoundTag nbt, boolean clientPacket) {
|
||||
input.readFromNBT(nbt.getCompound("in"));
|
||||
output.readFromNBT(nbt.getCompound("out"));
|
||||
heatreceived = nbt.getInt("hu");
|
||||
lastheat=nbt.getInt("lasthu");
|
||||
super.read(nbt, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag nbt) {
|
||||
super.saveAdditional(nbt);
|
||||
writeCustomNBT(nbt);
|
||||
}
|
||||
// @Override
|
||||
// public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
// CompoundTag nbt = new CompoundTag();
|
||||
// this.writeCustomNBT(nbt);
|
||||
// return ClientboundBlockEntityDataPacket.create(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
// this.readCustomNBT(pkt.getTag());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CompoundTag getUpdateTag() {
|
||||
// CompoundTag nbt = super.getUpdateTag();
|
||||
// writeCustomNBT(nbt);
|
||||
// return nbt;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
this.writeCustomNBT(nbt);
|
||||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
this.readCustomNBT(pkt.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag() {
|
||||
CompoundTag nbt = super.getUpdateTag();
|
||||
writeCustomNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
|
||||
//TODO: implement tick logic
|
||||
public void tick() {
|
||||
|
||||
|
||||
//debug
|
||||
if (this.level != null && !this.level.isClientSide) {
|
||||
boolean flag=false;
|
||||
|
|
|
@ -21,6 +21,8 @@ package com.teammoeg.steampowered.content.burner;
|
|||
import java.util.List;
|
||||
|
||||
import com.simibubi.create.content.contraptions.goggles.IHaveGoggleInformation;
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.teammoeg.steampowered.SPConfig;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
|
@ -43,7 +45,7 @@ import net.minecraftforge.items.CapabilityItemHandler;
|
|||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public abstract class BurnerTileEntity extends BlockEntity implements IHaveGoggleInformation {
|
||||
public abstract class BurnerTileEntity extends SmartTileEntity implements IHaveGoggleInformation {
|
||||
private ItemStackHandler inv = new ItemStackHandler() {
|
||||
|
||||
@Override
|
||||
|
@ -60,48 +62,41 @@ public abstract class BurnerTileEntity extends BlockEntity implements IHaveGoggl
|
|||
super(type, pos, state);
|
||||
}
|
||||
|
||||
// Easy, easy
|
||||
public void readCustomNBT(CompoundTag nbt) {
|
||||
@Override
|
||||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {}
|
||||
|
||||
@Override
|
||||
public void read(CompoundTag nbt, boolean clientPacket) {
|
||||
inv.deserializeNBT(nbt.getCompound("inv"));
|
||||
HURemain = nbt.getInt("hu");
|
||||
super.read(nbt, clientPacket);
|
||||
}
|
||||
|
||||
// Easy, easy
|
||||
public void writeCustomNBT(CompoundTag nbt) {
|
||||
@Override
|
||||
public void write(CompoundTag nbt, boolean clientPacket) {
|
||||
nbt.put("inv", inv.serializeNBT());
|
||||
nbt.putInt("hu", HURemain);
|
||||
super.write(nbt, clientPacket);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag nbt) {
|
||||
super.load(nbt);
|
||||
readCustomNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAdditional(CompoundTag nbt) {
|
||||
super.saveAdditional(nbt);
|
||||
writeCustomNBT(nbt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
this.writeCustomNBT(nbt);
|
||||
return ClientboundBlockEntityDataPacket.create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
this.readCustomNBT(pkt.getTag());
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getUpdateTag() {
|
||||
CompoundTag nbt = super.getUpdateTag();
|
||||
writeCustomNBT(nbt);
|
||||
return nbt;
|
||||
}
|
||||
// @Override
|
||||
// public ClientboundBlockEntityDataPacket getUpdatePacket() {
|
||||
// CompoundTag nbt = new CompoundTag();
|
||||
// this.writeCustomNBT(nbt);
|
||||
// return ClientboundBlockEntityDataPacket.create(this);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onDataPacket(Connection net, ClientboundBlockEntityDataPacket pkt) {
|
||||
// this.readCustomNBT(pkt.getTag());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public CompoundTag getUpdateTag() {
|
||||
// CompoundTag nbt = super.getUpdateTag();
|
||||
// writeCustomNBT(nbt);
|
||||
// return nbt;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public <T> LazyOptional<T> getCapability(Capability<T> cap, Direction side) {
|
||||
|
@ -119,7 +114,6 @@ public abstract class BurnerTileEntity extends BlockEntity implements IHaveGoggl
|
|||
oldCap.invalidate();
|
||||
}
|
||||
|
||||
//TODO: implement tick logic
|
||||
public void tick() {
|
||||
if (level != null && !level.isClientSide) {
|
||||
BlockState state = this.level.getBlockState(this.worldPosition);
|
||||
|
|
Loading…
Reference in a new issue