generated from tilera/1710mod
fix: accelerator
- added powered state and pipe connections to datapacket - fixed nonsensical partial `writeToNBT` (WTF) closes #10
This commit is contained in:
parent
9326d1ce37
commit
3d9ef7a3a1
4 changed files with 22 additions and 32 deletions
|
@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
|
|
||||||
import org.lwjgl.opengl.GL11;
|
import org.lwjgl.opengl.GL11;
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class TileAccel
|
||||||
return TileAccel.this;
|
return TileAccel.this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private boolean hasChanged = false;
|
|
||||||
public int ConMask = -1;
|
public int ConMask = -1;
|
||||||
public int conCache = -1;
|
public int conCache = -1;
|
||||||
|
|
||||||
|
@ -80,7 +79,6 @@ public class TileAccel
|
||||||
} else {
|
} else {
|
||||||
item.side = (byte) side;
|
item.side = (byte) side;
|
||||||
this.flow.add(item);
|
this.flow.add(item);
|
||||||
this.hasChanged = true;
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -100,7 +98,6 @@ public class TileAccel
|
||||||
public void addTubeItem(TubeItem ti) {
|
public void addTubeItem(TubeItem ti) {
|
||||||
ti.side = (byte) (ti.side ^ 1);
|
ti.side = (byte) (ti.side ^ 1);
|
||||||
this.flow.add(ti);
|
this.flow.add(ti);
|
||||||
this.hasChanged = true;
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,11 +180,8 @@ public class TileAccel
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if (this.flow.update()) {
|
|
||||||
this.hasChanged = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (this.hasChanged) {
|
if (this.flow.update()) {
|
||||||
if (!super.worldObj.isRemote) {
|
if (!super.worldObj.isRemote) {
|
||||||
this.markForUpdate();
|
this.markForUpdate();
|
||||||
}
|
}
|
||||||
|
@ -253,6 +247,10 @@ public class TileAccel
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void writeToPacket(NBTTagCompound data) {
|
protected void writeToPacket(NBTTagCompound data) {
|
||||||
|
super.writeToPacket(data);
|
||||||
|
data.setInteger("cc", this.conCache);
|
||||||
|
data.setBoolean("po", this.powered);
|
||||||
|
|
||||||
int cs = this.flow.contents.size();
|
int cs = this.flow.contents.size();
|
||||||
if (cs > 6) {
|
if (cs > 6) {
|
||||||
cs = 6;
|
cs = 6;
|
||||||
|
@ -267,26 +265,19 @@ public class TileAccel
|
||||||
ti.writeToPacket(itag);
|
ti.writeToPacket(itag);
|
||||||
data.setTag("cs" + i, itag);
|
data.setTag("cs" + i, itag);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasChanged) {
|
|
||||||
this.hasChanged = false;
|
|
||||||
data.setBoolean("data", true);
|
|
||||||
super.writeToPacket(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void readFromPacket(NBTTagCompound data) {
|
protected void readFromPacket(NBTTagCompound data) {
|
||||||
|
super.readFromPacket(data);
|
||||||
|
this.conCache = data.getInteger("cc");
|
||||||
|
this.powered = data.getBoolean("p");
|
||||||
|
|
||||||
this.flow.contents.clear();
|
this.flow.contents.clear();
|
||||||
int cs = data.getInteger("cs");
|
int cs = data.getInteger("cs");
|
||||||
|
|
||||||
for (int i = 0; i < cs; ++i) {
|
for (int i = 0; i < cs; ++i) {
|
||||||
this.flow.contents.add(TubeItem.newFromPacket((NBTTagCompound
|
this.flow.contents.add(TubeItem.newFromPacket(data.getCompoundTag("cs" + i)));
|
||||||
) data.getTag("cs" + i)));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.hasKey("data")) {
|
|
||||||
super.readFromPacket(data);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.IBlockAccess;
|
||||||
public class TileMachinePanel extends TileMultipart implements IRotatable, IFrameSupport {
|
public class TileMachinePanel extends TileMultipart implements IRotatable, IFrameSupport {
|
||||||
public int Rotation = 0;
|
public int Rotation = 0;
|
||||||
public boolean Active = false;
|
public boolean Active = false;
|
||||||
public boolean Powered = false;
|
public boolean powered = false;
|
||||||
public boolean Delay = false;
|
public boolean Delay = false;
|
||||||
public boolean Charged = false;
|
public boolean Charged = false;
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
@Override
|
@Override
|
||||||
public void writeFramePacket(NBTTagCompound tag) {
|
public void writeFramePacket(NBTTagCompound tag) {
|
||||||
tag.setByte("rot", (byte) this.Rotation);
|
tag.setByte("rot", (byte) this.Rotation);
|
||||||
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
int ps = (this.Active ? 1 : 0) | (this.powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
||||||
| (this.Charged ? 8 : 0);
|
| (this.Charged ? 8 : 0);
|
||||||
tag.setByte("ps", (byte) ps);
|
tag.setByte("ps", (byte) ps);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
this.Rotation = tag.getByte("rot");
|
this.Rotation = tag.getByte("rot");
|
||||||
int ps = tag.getByte("ps");
|
int ps = tag.getByte("ps");
|
||||||
this.Active = (ps & 1) > 0;
|
this.Active = (ps & 1) > 0;
|
||||||
this.Powered = (ps & 2) > 0;
|
this.powered = (ps & 2) > 0;
|
||||||
this.Delay = (ps & 4) > 0;
|
this.Delay = (ps & 4) > 0;
|
||||||
this.Charged = (ps & 8) > 0;
|
this.Charged = (ps & 8) > 0;
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
byte k = data.getByte("ps");
|
byte k = data.getByte("ps");
|
||||||
this.Rotation = data.getByte("rot");
|
this.Rotation = data.getByte("rot");
|
||||||
this.Active = (k & 1) > 0;
|
this.Active = (k & 1) > 0;
|
||||||
this.Powered = (k & 2) > 0;
|
this.powered = (k & 2) > 0;
|
||||||
this.Delay = (k & 4) > 0;
|
this.Delay = (k & 4) > 0;
|
||||||
this.Charged = (k & 8) > 0;
|
this.Charged = (k & 8) > 0;
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
@Override
|
@Override
|
||||||
public void writeToNBT(NBTTagCompound data) {
|
public void writeToNBT(NBTTagCompound data) {
|
||||||
super.writeToNBT(data);
|
super.writeToNBT(data);
|
||||||
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
int ps = (this.Active ? 1 : 0) | (this.powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
||||||
| (this.Charged ? 8 : 0);
|
| (this.Charged ? 8 : 0);
|
||||||
data.setByte("ps", (byte) ps);
|
data.setByte("ps", (byte) ps);
|
||||||
data.setByte("rot", (byte) this.Rotation);
|
data.setByte("rot", (byte) this.Rotation);
|
||||||
|
@ -182,7 +182,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
this.Rotation = data.getByte("rot");
|
this.Rotation = data.getByte("rot");
|
||||||
int ps = data.getByte("ps");
|
int ps = data.getByte("ps");
|
||||||
this.Active = (ps & 1) > 0;
|
this.Active = (ps & 1) > 0;
|
||||||
this.Powered = (ps & 2) > 0;
|
this.powered = (ps & 2) > 0;
|
||||||
this.Delay = (ps & 4) > 0;
|
this.Delay = (ps & 4) > 0;
|
||||||
this.Charged = (ps & 8) > 0;
|
this.Charged = (ps & 8) > 0;
|
||||||
this.updateLight();
|
this.updateLight();
|
||||||
|
@ -191,7 +191,7 @@ public class TileMachinePanel extends TileMultipart implements IRotatable, IFram
|
||||||
@Override
|
@Override
|
||||||
protected void writeToPacket(NBTTagCompound data) {
|
protected void writeToPacket(NBTTagCompound data) {
|
||||||
data.setByte("rot", (byte) this.Rotation);
|
data.setByte("rot", (byte) this.Rotation);
|
||||||
int ps = (this.Active ? 1 : 0) | (this.Powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
int ps = (this.Active ? 1 : 0) | (this.powered ? 2 : 0) | (this.Delay ? 4 : 0)
|
||||||
| (this.Charged ? 8 : 0);
|
| (this.Charged ? 8 : 0);
|
||||||
data.setByte("ps", (byte) ps);
|
data.setByte("ps", (byte) ps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,12 +93,12 @@ public class TilePump
|
||||||
if (RedPowerLib.isPowered(
|
if (RedPowerLib.isPowered(
|
||||||
super.worldObj, super.xCoord, super.yCoord, super.zCoord, 16777215, 63
|
super.worldObj, super.xCoord, super.yCoord, super.zCoord, 16777215, 63
|
||||||
)) {
|
)) {
|
||||||
if (!super.Powered) {
|
if (!super.powered) {
|
||||||
super.Powered = true;
|
super.powered = true;
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.Powered = false;
|
super.powered = false;
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ public class TilePump
|
||||||
this.updateBlock();
|
this.updateBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (super.Charged && super.Powered) {
|
if (super.Charged && super.powered) {
|
||||||
super.Active = true;
|
super.Active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +181,7 @@ public class TilePump
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTileTick() {
|
public void onTileTick() {
|
||||||
if (!super.worldObj.isRemote && !super.Powered) {
|
if (!super.worldObj.isRemote && !super.powered) {
|
||||||
super.Active = false;
|
super.Active = false;
|
||||||
this.updateBlock();
|
this.updateBlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue