fixed deuterium machines, cable switch, added deprecation annotations

This commit is contained in:
Boblet 2021-11-18 15:59:54 +01:00
parent 3f731951ce
commit f39a6f9ca1
12 changed files with 41 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package com.hbm.blocks.network;
import com.hbm.lib.RefStrings;
import com.hbm.tileentity.network.TileEntityCableBaseNT;
import com.hbm.tileentity.network.TileEntityCableSwitch;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -37,7 +38,7 @@ public class CableSwitch extends BlockContainer {
@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileEntityCableBaseNT(); //TODO: extends this and implement switching
return new TileEntityCableSwitch();
}
@Override
@ -56,6 +57,9 @@ public class CableSwitch extends BlockContainer {
world.playSoundEffect(x, y, z, "hbm:block.reactorStart", 1.0F, 0.85F);
}
TileEntityCableSwitch te = (TileEntityCableSwitch) world.getTileEntity(x, y, z);
te.updateState();
return true;
} else {
return false;

View File

@ -30,6 +30,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
@Deprecated //use the NBT control packet instead
public class AuxButtonPacket implements IMessage {
int x;
@ -274,6 +275,7 @@ public class AuxButtonPacket implements IMessage {
}
/// yes ///
//no fuck off
if(te instanceof TileEntityMachineBase) {
TileEntityMachineBase base = (TileEntityMachineBase)te;
base.handleButtonPacket(m.value, m.id);

View File

@ -10,6 +10,7 @@ import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
@Deprecated //use the NBT packet instead
public class AuxElectricityPacket implements IMessage {
int x;

View File

@ -37,7 +37,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.tileentity.TileEntity;
@Spaghetti("Changing all machines to use TileEntityMachineBase will reduce the total chaos in this class")
@Deprecated
@Deprecated //use the NBT packet instead
public class AuxGaugePacket implements IMessage {
int x;

View File

@ -14,25 +14,19 @@ public class PlayerInformPacket implements IMessage {
String dmesg = "";
public PlayerInformPacket()
{
}
public PlayerInformPacket() { }
public PlayerInformPacket(String dmesg)
{
public PlayerInformPacket(String dmesg) {
this.dmesg = dmesg;
}
@Override
public void fromBytes(ByteBuf buf) {
dmesg = ByteBufUtils.readUTF8String(buf);
}
@Override
public void toBytes(ByteBuf buf) {
ByteBufUtils.writeUTF8String(buf, dmesg);
}
@ -42,7 +36,6 @@ public class PlayerInformPacket implements IMessage {
@SideOnly(Side.CLIENT)
public IMessage onMessage(PlayerInformPacket m, MessageContext ctx) {
try {
MainRegistry.proxy.displayTooltip(m.dmesg);
} catch (Exception x) { }

View File

@ -164,6 +164,7 @@ public abstract class TileEntityMachineBase extends TileEntity implements ISided
public void networkUnpack(NBTTagCompound nbt) { }
@Deprecated
public void handleButtonPacket(int value, int meta) { }
@Override

View File

@ -33,5 +33,6 @@ public abstract class TileEntityTickingBase extends TileEntity implements INBTPa
public void networkUnpack(NBTTagCompound nbt) { }
@Deprecated
public void handleButtonPacket(int value, int meta) { }
}

View File

@ -193,6 +193,7 @@ public class TileMappings {
put(TileEntityBobble.class, "tileentity_ntm_bobblehead");
put(TileEntityCableBaseNT.class, "tileentity_cable", "tileentity_wirecoated");
put(TileEntityCableSwitch.class, "tileentity_cable_switch");
putBombs();
putTurrets();

View File

@ -47,7 +47,7 @@ public class TileEntityDeuteriumExtractor extends TileEntityMachineBase implemen
this.tanks[0].updateTank(xCoord, yCoord, zCoord, worldObj.provider.dimensionId);
age++;
if(age >= 2) {
if(age >= 10) {
age = 0;
if(hasPower() && hasEnoughWater()) {
int convert = Math.min(tanks[0].getFill(), tanks[1].getMaxFill() - tanks[1].getFill());

View File

@ -11,12 +11,12 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityDeuteriumTower extends TileEntityDeuteriumExtractor {
public static final long maxPower = 10000000;
public static final long maxPower = 1000000;
public TileEntityDeuteriumTower() {
tanks = new FluidTank[2];
tanks[0] = new FluidTank(FluidType.WATER, 5000000, 0);
tanks[1] = new FluidTank(FluidType.HEAVYWATER, 500000, 0);
tanks[0] = new FluidTank(FluidType.WATER, 50000, 0);
tanks[1] = new FluidTank(FluidType.HEAVYWATER, 5000, 0);
}
public void fillFluidInit(FluidType type) {

View File

@ -8,7 +8,7 @@ import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityCableBaseNT extends TileEntity implements IEnergyConductor {
private IPowerNet network;
protected IPowerNet network;
@Override
public void updateEntity() {

View File

@ -0,0 +1,22 @@
package com.hbm.tileentity.network;
import net.minecraft.tileentity.TileEntity;
public class TileEntityCableSwitch extends TileEntityCableBaseNT {
@Override
public boolean canUpdate() {
//only update if the meta is 1 (ON), updating causes the net to form and allows transmission
return this.getBlockMetadata() == 1 && super.canUpdate();
}
public void updateState() {
//if the meta is 0 (OFF) and there is a net present, destroy and de-reference it.
//that should be all, since the state being 0 also prevents the TE from updating and joining the new net.
if(this.getBlockMetadata() == 0 && this.network != null) {
this.network.destroy();
this.network = null;
}
}
}