mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 19:59:58 +00:00
Start work on machines and fix some mistakes.
This commit is contained in:
1 parent
ec975567b2
commit
5f5e856ceb
30 files changed
+239
-199
No files matched your search
@@ -35,8 +35,8 @@ public class PacketOpenConduitUI extends MessageTileEntity<TileEntity> implement
|
||||
|
||||
public IMessage onMessage(PacketOpenConduitUI message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity tile = getWorld(ctx).getTileEntity(x, y, z);
|
||||
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + dir.ordinal(), player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
TileEntity tile = message.getWorld(ctx).getTileEntity(x, y, z);
|
||||
player.openGui(EnderIO.instance, GuiHandler.GUI_ID_EXTERNAL_CONNECTION_BASE + message.dir.ordinal(), player.worldObj, tile.xCoord, tile.yCoord, tile.zCoord);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,8 +37,8 @@ public class PacketConnectionMode extends AbstractConduitPacket<IConduit> implem
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketConnectionMode message, MessageContext ctx) {
|
||||
getTileCasted(ctx).setConnectionMode(dir, mode);
|
||||
getWorld(ctx).markBlockForUpdate(x, y, z);
|
||||
message.getTileCasted(ctx).setConnectionMode(message.dir, message.mode);
|
||||
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,9 +41,9 @@ public class PacketExtractMode extends AbstractConduitPacket<IExtractor> impleme
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketExtractMode message, MessageContext ctx) {
|
||||
getTileCasted(ctx).setExtractionRedstoneMode(mode, dir);
|
||||
getTileCasted(ctx).setExtractionSignalColor(dir, color);
|
||||
getWorld(ctx).markBlockForUpdate(x, y, z);
|
||||
message.getTileCasted(ctx).setExtractionRedstoneMode(message.mode, message.dir);
|
||||
message.getTileCasted(ctx).setExtractionSignalColor(message.dir, message.color);
|
||||
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,20 +82,20 @@ public class PacketItemConduitFilter extends AbstractConduitPacket<IItemConduit>
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketItemConduitFilter message, MessageContext ctx) {
|
||||
IItemConduit conduit = getTileCasted(ctx);
|
||||
conduit.setSelfFeedEnabled(dir, loopMode);
|
||||
conduit.setRoundRobinEnabled(dir, roundRobin);
|
||||
conduit.setInputColor(dir, colIn);
|
||||
conduit.setOutputColor(dir, colOut);
|
||||
conduit.setOutputPriority(dir, priority);
|
||||
applyFilter(conduit, inputFilter, true);
|
||||
applyFilter(conduit, outputFilter, false);
|
||||
IItemConduit conduit = message.getTileCasted(ctx);
|
||||
conduit.setSelfFeedEnabled(message.dir, message.loopMode);
|
||||
conduit.setRoundRobinEnabled(message.dir, message.roundRobin);
|
||||
conduit.setInputColor(message.dir, message.colIn);
|
||||
conduit.setOutputColor(message.dir, message.colOut);
|
||||
conduit.setOutputPriority(message.dir, message.priority);
|
||||
applyFilter(message.dir, conduit, message.inputFilter, true);
|
||||
applyFilter(message.dir, conduit, message.outputFilter, false);
|
||||
|
||||
getWorld(ctx).markBlockForUpdate(x, y, z);
|
||||
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void applyFilter(IItemConduit conduit, ItemFilter filter, boolean isInput) {
|
||||
private void applyFilter(ForgeDirection dir, IItemConduit conduit, ItemFilter filter, boolean isInput) {
|
||||
if(filter == null) {
|
||||
if(isInput) {
|
||||
conduit.setInputFilter(dir, filter);
|
||||
|
||||
+2
-2
@@ -36,8 +36,8 @@ public class PacketRedstoneConduitSignalColor extends AbstractConduitPacket<IIns
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketRedstoneConduitSignalColor message, MessageContext ctx) {
|
||||
getTileCasted(ctx).setSignalColor(dir, col);
|
||||
getWorld(ctx).markBlockForUpdate(x, y, z);
|
||||
message.getTileCasted(ctx).setSignalColor(message.dir, message.col);
|
||||
message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class PacketOpenRemoteUi implements IMessage, IMessageHandler<PacketOpenR
|
||||
public IMessage onMessage(PacketOpenRemoteUi message, MessageContext ctx) {
|
||||
EntityPlayerMP player = (EntityPlayerMP) ctx.getServerHandler().playerEntity;
|
||||
net.minecraft.inventory.Container c = player.openContainer;
|
||||
PlayerProxy pp = new PlayerProxy(player, x, y, z);
|
||||
PlayerProxy pp = new PlayerProxy(player, message.x, message.y, message.z);
|
||||
EntityPlayerMP proxy = createPlayerProxy(player, pp);
|
||||
proxy.playerNetServerHandler = player.playerNetServerHandler;
|
||||
proxy.inventory = player.inventory;
|
||||
|
||||
@@ -35,11 +35,11 @@ public class YetaWrenchPacketProcessor implements IMessage, IMessageHandler<Yeta
|
||||
@Override
|
||||
public IMessage onMessage(YetaWrenchPacketProcessor message, MessageContext ctx) {
|
||||
ItemStack stack = null;
|
||||
if(slot > -1 && slot < 9) {
|
||||
if(message.slot > -1 && message.slot < 9) {
|
||||
stack = ctx.getServerHandler().playerEntity.inventory.getStackInSlot(slot);
|
||||
}
|
||||
if(stack != null) {
|
||||
ConduitDisplayMode.setDisplayMode(stack, mode);
|
||||
ConduitDisplayMode.setDisplayMode(stack, message.mode);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class PacketDarkSteelPowerPacket implements IMessage, IMessageHandler<Pac
|
||||
}
|
||||
|
||||
public IMessage onMessage(PacketDarkSteelPowerPacket message, MessageContext ctx) {
|
||||
DarkSteelController.instance.usePlayerEnergy(ctx.getServerHandler().playerEntity, ItemDarkSteelArmor.forArmorType(armorType), powerUse);
|
||||
DarkSteelController.instance.usePlayerEnergy(ctx.getServerHandler().playerEntity, ItemDarkSteelArmor.forArmorType(armorType), message.powerUse);
|
||||
ctx.getServerHandler().playerEntity.fallDistance = 0;
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -45,17 +45,12 @@ public class PacketClientState implements IMessage, IMessageHandler<PacketClient
|
||||
}
|
||||
|
||||
public IMessage onMessage(PacketClientState message, MessageContext ctx) {
|
||||
handle(ctx.getServerHandler().playerEntity);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void handle(EntityPlayer player) {
|
||||
TileEntity te = player.worldObj.getTileEntity(x, y, z);
|
||||
TileEntity te = ctx.getServerHandler().playerEntity.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof TileAlloySmelter) {
|
||||
TileAlloySmelter me = (TileAlloySmelter) te;
|
||||
me.setMode(mode);
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
me.setMode(message.mode);
|
||||
ctx.getServerHandler().playerEntity.worldObj.markBlockForUpdate(message.x, message.y, message.z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.farm;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -16,7 +17,7 @@ import crazypants.enderio.network.PacketHandler;
|
||||
public class BlockFarmStation extends AbstractMachineBlock<TileFarmStation> {
|
||||
|
||||
public static BlockFarmStation create() {
|
||||
PacketHandler.INSTANCE.registerPacket(PacketFarmAction.class);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketFarmAction.class, PacketFarmAction.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
BlockFarmStation result = new BlockFarmStation();
|
||||
result.init();
|
||||
return result;
|
||||
|
||||
@@ -9,9 +9,12 @@ import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.ClientUtil;
|
||||
|
||||
public class PacketFarmAction implements IMessage {
|
||||
public class PacketFarmAction implements IMessage, IMessageHandler<PacketFarmAction, IMessage> {
|
||||
|
||||
private static Random rand = new Random();
|
||||
|
||||
@@ -46,21 +49,12 @@ public class PacketFarmAction implements IMessage {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
for (BlockCoord bc : coords) {
|
||||
public IMessage onMessage(PacketFarmAction message, MessageContext ctx) {
|
||||
for (BlockCoord bc : message.coords) {
|
||||
for (int i = 0; i < 15; i++) {
|
||||
double xOff = 0.5 + (rand.nextDouble() - 0.5) * 1.1;
|
||||
double yOff = 0.5 + (rand.nextDouble() - 0.5) * 0.2;
|
||||
double zOff = 0.5 + (rand.nextDouble() - 0.5) * 1.1;
|
||||
player.worldObj.spawnParticle("portal", bc.x + xOff, bc.y + yOff, bc.z + zOff,
|
||||
(rand.nextDouble() - 0.5) * 1.5, -rand.nextDouble(), (rand.nextDouble() - 0.5) * 1.5);
|
||||
ClientUtil.spawnFarmParcticles(rand, bc);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -238,7 +238,7 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
if(harvest != null) {
|
||||
if(harvest.getDrops() != null) {
|
||||
PacketFarmAction pkt = new PacketFarmAction(harvest.getHarvestedBlocks());
|
||||
PacketHandler.INSTANCE.sendToAllAround(new TargetPoint(worldObj.provider.dimensionId, bc.x, bc.y, bc.z, 64), pkt);
|
||||
PacketHandler.INSTANCE.sendToAllAround(pkt, new TargetPoint(worldObj.provider.dimensionId, bc.x, bc.y, bc.z, 64));
|
||||
for (EntityItem ei : harvest.getDrops()) {
|
||||
if(ei != null) {
|
||||
insertHarvestDrop(ei);
|
||||
@@ -247,7 +247,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity /*implements IEnt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -22,7 +23,7 @@ public class BlockCombustionGenerator extends AbstractMachineBlock<TileCombustio
|
||||
public static int renderId = -1;
|
||||
|
||||
public static BlockCombustionGenerator create() {
|
||||
PacketHandler.INSTANCE.registerPacket(PacketTanks.class);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketCombustionTank.class, PacketCombustionTank.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
BlockCombustionGenerator gen = new BlockCombustionGenerator();
|
||||
gen.init();
|
||||
|
||||
+3
-3
@@ -122,7 +122,7 @@ public class CombustionGeneratorRenderer extends TileEntitySpecialRenderer imple
|
||||
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float var8) {
|
||||
|
||||
TileCombustionGenerator gen = (TileCombustionGenerator) tileentity;
|
||||
if(gen.coolantTank.getFluidAmount() <= 0 && gen.fuelTank.getFluidAmount() <= 0) {
|
||||
if(gen.getCoolantTank().getFluidAmount() <= 0 && gen.getFuelTank().getFluidAmount() <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,8 +143,8 @@ public class CombustionGeneratorRenderer extends TileEntitySpecialRenderer imple
|
||||
tes.startDrawingQuads();
|
||||
|
||||
BoundingBox bb = BoundingBox.UNIT_CUBE.scale(0.96, 0.96, 0.96);
|
||||
renderTank(gen, bb, gen.coolantTank, true);
|
||||
renderTank(gen, bb, gen.fuelTank, false);
|
||||
renderTank(gen, bb, gen.getCoolantTank(), true);
|
||||
renderTank(gen, bb, gen.getFuelTank(), false);
|
||||
tes.draw();
|
||||
tes.setTranslation(0, 0, 0);
|
||||
|
||||
|
||||
+12
-12
@@ -31,11 +31,11 @@ public class GuiCombustionGenerator extends GuiMachineBase {
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
String heading = Lang.localize("combustionGenerator.coolantTank");
|
||||
if(gen.coolantTank.getFluid() != null) {
|
||||
heading += ": " + gen.coolantTank.getFluid().getFluid().getLocalizedName();
|
||||
if(gen.getCoolantTank().getFluid() != null) {
|
||||
heading += ": " + gen.getCoolantTank().getFluid().getFluid().getLocalizedName();
|
||||
}
|
||||
text.add(heading);
|
||||
text.add(Fluids.toCapactityString(gen.coolantTank));
|
||||
text.add(Fluids.toCapactityString(gen.getCoolantTank()));
|
||||
}
|
||||
|
||||
});
|
||||
@@ -46,11 +46,11 @@ public class GuiCombustionGenerator extends GuiMachineBase {
|
||||
protected void updateText() {
|
||||
text.clear();
|
||||
String heading = Lang.localize("combustionGenerator.fuelTank");
|
||||
if(gen.fuelTank.getFluid() != null) {
|
||||
heading += ": " + gen.fuelTank.getFluid().getFluid().getLocalizedName();
|
||||
if(gen.getFuelTank().getFluid() != null) {
|
||||
heading += ": " + gen.getFuelTank().getFluid().getFluid().getLocalizedName();
|
||||
}
|
||||
text.add(heading);
|
||||
text.add(Fluids.toCapactityString(gen.fuelTank));
|
||||
text.add(Fluids.toCapactityString(gen.getFuelTank()));
|
||||
}
|
||||
|
||||
});
|
||||
@@ -98,10 +98,10 @@ public class GuiCombustionGenerator extends GuiMachineBase {
|
||||
|
||||
int x = guiLeft + 48;
|
||||
int y = guiTop + 21;
|
||||
if(gen.coolantTank.getFluidAmount() > 0) {
|
||||
if(gen.getCoolantTank().getFluidAmount() > 0) {
|
||||
x = guiLeft + 114;
|
||||
//right tank
|
||||
RenderUtil.renderGuiTank(gen.coolantTank.getFluid(), 4000, gen.coolantTank.getFluidAmount() - 1000, x, y, zLevel, 15, 47);
|
||||
RenderUtil.renderGuiTank(gen.getCoolantTank().getFluid(), 4000, gen.getCoolantTank().getFluidAmount() - 1000, x, y, zLevel, 15, 47);
|
||||
|
||||
if(gen.isActive()) {
|
||||
txt = gen.getNumTicksPerMbCoolant() + " t/MB";
|
||||
@@ -112,19 +112,19 @@ public class GuiCombustionGenerator extends GuiMachineBase {
|
||||
x = guiLeft + 72;
|
||||
y = guiTop + 14;
|
||||
//center coolant chamber
|
||||
RenderUtil.renderGuiTank(gen.coolantTank.getFluid(), 1000, Math.min(gen.coolantTank.getFluidAmount(), 1000), x, y, zLevel, 33, 33);
|
||||
RenderUtil.renderGuiTank(gen.getCoolantTank().getFluid(), 1000, Math.min(gen.getCoolantTank().getFluidAmount(), 1000), x, y, zLevel, 33, 33);
|
||||
//draw some gui over the top again to make the center shape
|
||||
RenderUtil.bindTexture("enderio:textures/gui/combustionGen.png");
|
||||
drawTexturedModalRect(x, y + 14, 0, 223, 33, 33);
|
||||
y += 7;
|
||||
}
|
||||
|
||||
if(gen.fuelTank.getFluidAmount() > 0) {
|
||||
if(gen.getFuelTank().getFluidAmount() > 0) {
|
||||
//left tank
|
||||
x = guiLeft + 48;
|
||||
|
||||
//RenderUtil.renderGuiTank(gen.fuelTank.getFluid(), 4000, gen.fuelTank.getFluidAmount() - 1000, x, y, zLevel, 15, 47);
|
||||
RenderUtil.renderGuiTank(gen.fuelTank.getFluid(), 4000, gen.fuelTank.getFluidAmount() - 1000, x, y, zLevel, 15, 47);
|
||||
RenderUtil.renderGuiTank(gen.getFuelTank().getFluid(), 4000, gen.getFuelTank().getFluidAmount() - 1000, x, y, zLevel, 15, 47);
|
||||
|
||||
if(gen.isActive()) {
|
||||
txt = gen.getNumTicksPerMbFuel() + " t/MB";
|
||||
@@ -134,7 +134,7 @@ public class GuiCombustionGenerator extends GuiMachineBase {
|
||||
|
||||
//center tank
|
||||
//RenderUtil.renderGuiTank(gen.fuelTank.getFluid(), 1000, Math.min(gen.fuelTank.getFluidAmount(), 1000), guiLeft + 81, guiTop + 5, zLevel, 14, 14);
|
||||
RenderUtil.renderGuiTank(gen.fuelTank.getFluid(), 1000, Math.min(gen.fuelTank.getFluidAmount(), 1000), guiLeft + 81, guiTop + 5, zLevel, 14, 14);
|
||||
RenderUtil.renderGuiTank(gen.getFuelTank().getFluid(), 1000, Math.min(gen.getFuelTank().getFluidAmount(), 1000), guiLeft + 81, guiTop + 5, zLevel, 14, 14);
|
||||
}
|
||||
|
||||
RenderUtil.bindTexture("enderio:textures/gui/combustionGen.png");
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
import crazypants.util.ClientUtil;
|
||||
|
||||
public class PacketCombustionTank extends MessageTileEntity<TileCombustionGenerator> implements IMessageHandler<PacketCombustionTank, IMessage> {
|
||||
|
||||
public NBTTagCompound nbtRoot;
|
||||
|
||||
public PacketCombustionTank() {
|
||||
}
|
||||
|
||||
public PacketCombustionTank(TileCombustionGenerator tile) {
|
||||
super(tile);
|
||||
nbtRoot = new NBTTagCompound();
|
||||
if(tile.getCoolantTank().getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
tile.getCoolantTank().writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("coolantTank", tankRoot);
|
||||
}
|
||||
if(tile.getFuelTank().getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
tile.getFuelTank().writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("fuelTank", tankRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
NetworkUtil.writeNBTTagCompound(nbtRoot, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
nbtRoot = NetworkUtil.readNBTTagCompound(buf);
|
||||
}
|
||||
@Override
|
||||
public IMessage onMessage(PacketCombustionTank message, MessageContext ctx) {
|
||||
ClientUtil.setTankNBT(message, message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,61 +0,0 @@
|
||||
package crazypants.enderio.machine.generator.combustion;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
|
||||
public class PacketTanks extends MessageTileEntity<TileCombustionGenerator> {
|
||||
|
||||
private NBTTagCompound nbtRoot;
|
||||
|
||||
public PacketTanks() {
|
||||
}
|
||||
|
||||
public PacketTanks(TileCombustionGenerator tile) {
|
||||
super(tile);
|
||||
nbtRoot = new NBTTagCompound();
|
||||
if(tile.coolantTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
tile.coolantTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("coolantTank", tankRoot);
|
||||
}
|
||||
if(tile.fuelTank.getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
tile.fuelTank.writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("fuelTank", tankRoot);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(ctx, buf);
|
||||
NetworkUtil.writeNBTTagCompound(nbtRoot, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(ctx, buf);
|
||||
nbtRoot = NetworkUtil.readNBTTagCompound(buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleClientSide(EntityPlayer player, World worldObj, TileCombustionGenerator tile) {
|
||||
if(nbtRoot.hasKey("coolantTank")) {
|
||||
NBTTagCompound tankRoot = nbtRoot.getCompoundTag("coolantTank");
|
||||
tile.coolantTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
tile.coolantTank.setFluid(null);
|
||||
}
|
||||
if(nbtRoot.hasKey("fuelTank")) {
|
||||
NBTTagCompound tankRoot = nbtRoot.getCompoundTag("fuelTank");
|
||||
tile.fuelTank.readFromNBT(tankRoot);
|
||||
} else {
|
||||
tile.fuelTank.setFluid(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+37
-29
@@ -26,8 +26,8 @@ import crazypants.util.FluidUtil;
|
||||
|
||||
public class TileCombustionGenerator extends AbstractMachineEntity implements IPowerEmitter, IFluidHandler {
|
||||
|
||||
final FluidTank coolantTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 5);
|
||||
final FluidTank fuelTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 5);
|
||||
private final FluidTank coolantTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 5);
|
||||
private final FluidTank fuelTank = new FluidTank(FluidContainerRegistry.BUCKET_VOLUME * 5);
|
||||
private boolean tanksDirty;
|
||||
|
||||
private int ticksRemaingFuel;
|
||||
@@ -117,10 +117,10 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
}
|
||||
tanksDirty = true;
|
||||
if(IronEngineCoolant.isCoolant(resource.getFluid())) {
|
||||
return coolantTank.fill(resource, doFill);
|
||||
return getCoolantTank().fill(resource, doFill);
|
||||
}
|
||||
if(IronEngineFuel.getFuelForFluid(resource.getFluid()) != null) {
|
||||
return fuelTank.fill(resource, doFill);
|
||||
return getFuelTank().fill(resource, doFill);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -169,7 +169,7 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
}
|
||||
|
||||
if(tanksDirty) {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketTanks(this), this);
|
||||
PacketHandler.sendToAllAround(new PacketCombustionTank(this), this);
|
||||
tanksDirty = false;
|
||||
}
|
||||
|
||||
@@ -197,12 +197,12 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
|
||||
generated = 0;
|
||||
|
||||
Fuel fuel = fuelTank.getFluid() == null ? null : IronEngineFuel.getFuelForFluid(fuelTank.getFluid().getFluid());
|
||||
Fuel fuel = getFuelTank().getFluid() == null ? null : IronEngineFuel.getFuelForFluid(getFuelTank().getFluid().getFluid());
|
||||
if(fuel == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(coolantTank.getFluidAmount() <= 0 || storedEnergy >= powerHandler.getMaxEnergyStored()) {
|
||||
if(getCoolantTank().getFluidAmount() <= 0 || storedEnergy >= powerHandler.getMaxEnergyStored()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -213,7 +213,7 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
}
|
||||
inPause = false;
|
||||
|
||||
Coolant coolant = IronEngineCoolant.getCoolant(coolantTank.getFluid());
|
||||
Coolant coolant = IronEngineCoolant.getCoolant(getCoolantTank().getFluid());
|
||||
if(coolant == null) {
|
||||
return false;
|
||||
}
|
||||
@@ -221,14 +221,14 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
boolean res = false;
|
||||
ticksRemaingFuel--;
|
||||
if(ticksRemaingFuel <= 0) {
|
||||
fuelTank.drain(1, true);
|
||||
getFuelTank().drain(1, true);
|
||||
ticksRemaingFuel = getNumTicksPerMbFuel(fuel);
|
||||
res = true;
|
||||
tanksDirty = true;
|
||||
}
|
||||
ticksRemaingCoolant--;
|
||||
if(ticksRemaingCoolant <= 0) {
|
||||
coolantTank.drain(1, true);
|
||||
getCoolantTank().drain(1, true);
|
||||
ticksRemaingCoolant = getNumTicksPerMbCoolant(coolant, fuel);
|
||||
res = true;
|
||||
tanksDirty = true;
|
||||
@@ -239,22 +239,22 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
generated = fuel.powerPerCycle;
|
||||
storedEnergy = Math.min(storedEnergy, capacitorType.capacitor.getMaxEnergyStored());
|
||||
|
||||
return fuelTank.getFluidAmount() > 0 && coolantTank.getFluidAmount() > 0;
|
||||
return getFuelTank().getFluidAmount() > 0 && getCoolantTank().getFluidAmount() > 0;
|
||||
}
|
||||
|
||||
public int getNumTicksPerMbFuel() {
|
||||
if(fuelTank.getFluidAmount() <= 0) {
|
||||
if(getFuelTank().getFluidAmount() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
return getNumTicksPerMbFuel(IronEngineFuel.getFuelForFluid(fuelTank.getFluid().getFluid()));
|
||||
return getNumTicksPerMbFuel(IronEngineFuel.getFuelForFluid(getFuelTank().getFluid().getFluid()));
|
||||
}
|
||||
|
||||
public int getNumTicksPerMbCoolant() {
|
||||
if(fuelTank.getFluidAmount() <= 0) {
|
||||
if(getFuelTank().getFluidAmount() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
Fuel fuel = IronEngineFuel.getFuelForFluid(fuelTank.getFluid().getFluid());
|
||||
Coolant coolant = IronEngineCoolant.getCoolant(coolantTank.getFluid());
|
||||
Fuel fuel = IronEngineFuel.getFuelForFluid(getFuelTank().getFluid().getFluid());
|
||||
Coolant coolant = IronEngineCoolant.getCoolant(getCoolantTank().getFluid());
|
||||
return getNumTicksPerMbCoolant(coolant, fuel);
|
||||
}
|
||||
|
||||
@@ -305,7 +305,7 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
if(isSideDisabled(from.ordinal())) {
|
||||
return new FluidTankInfo[0];
|
||||
}
|
||||
return new FluidTankInfo[] { coolantTank.getInfo(), fuelTank.getInfo() };
|
||||
return new FluidTankInfo[] { getCoolantTank().getInfo(), getFuelTank().getInfo() };
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -321,23 +321,23 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
if(nbtRoot.hasKey("coolantTank")) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("coolantTank");
|
||||
if(tankRoot != null) {
|
||||
coolantTank.readFromNBT(tankRoot);
|
||||
getCoolantTank().readFromNBT(tankRoot);
|
||||
} else {
|
||||
coolantTank.setFluid(null);
|
||||
getCoolantTank().setFluid(null);
|
||||
}
|
||||
} else {
|
||||
coolantTank.setFluid(null);
|
||||
getCoolantTank().setFluid(null);
|
||||
}
|
||||
|
||||
if(nbtRoot.hasKey("fuelTank")) {
|
||||
NBTTagCompound tankRoot = (NBTTagCompound) nbtRoot.getTag("fuelTank");
|
||||
if(tankRoot != null) {
|
||||
fuelTank.readFromNBT(tankRoot);
|
||||
getFuelTank().readFromNBT(tankRoot);
|
||||
} else {
|
||||
fuelTank.setFluid(null);
|
||||
getFuelTank().setFluid(null);
|
||||
}
|
||||
} else {
|
||||
fuelTank.setFluid(null);
|
||||
getFuelTank().setFluid(null);
|
||||
}
|
||||
|
||||
ticksRemaingFuel = nbtRoot.getInteger("ticksRemaingFuel");
|
||||
@@ -347,14 +347,14 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
@Override
|
||||
public void writeCommon(NBTTagCompound nbtRoot) {
|
||||
super.writeCommon(nbtRoot);
|
||||
if(coolantTank.getFluidAmount() > 0) {
|
||||
if(getCoolantTank().getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
coolantTank.writeToNBT(tankRoot);
|
||||
getCoolantTank().writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("coolantTank", tankRoot);
|
||||
}
|
||||
if(fuelTank.getFluidAmount() > 0) {
|
||||
if(getFuelTank().getFluidAmount() > 0) {
|
||||
NBTTagCompound tankRoot = new NBTTagCompound();
|
||||
fuelTank.writeToNBT(tankRoot);
|
||||
getFuelTank().writeToNBT(tankRoot);
|
||||
nbtRoot.setTag("fuelTank", tankRoot);
|
||||
}
|
||||
nbtRoot.setInteger("ticksRemaingFuel", ticksRemaingFuel);
|
||||
@@ -377,14 +377,22 @@ public class TileCombustionGenerator extends AbstractMachineEntity implements IP
|
||||
|
||||
@Override
|
||||
public float getPowerUsePerTick() {
|
||||
if(fuelTank.getFluidAmount() <= 0) {
|
||||
if(getFuelTank().getFluidAmount() <= 0) {
|
||||
return 0;
|
||||
}
|
||||
Fuel fuel = IronEngineFuel.getFuelForFluid(fuelTank.getFluid().getFluid());
|
||||
Fuel fuel = IronEngineFuel.getFuelForFluid(getFuelTank().getFluid().getFluid());
|
||||
if(fuel == null) {
|
||||
return 0;
|
||||
}
|
||||
return fuel.powerPerCycle;
|
||||
}
|
||||
|
||||
public FluidTank getCoolantTank() {
|
||||
return coolantTank;
|
||||
}
|
||||
|
||||
public FluidTank getFuelTank() {
|
||||
return fuelTank;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-1
@@ -2,6 +2,7 @@ package crazypants.enderio.machine.generator.stirling;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.machine.AbstractMachineBlock;
|
||||
@@ -11,7 +12,7 @@ public class BlockStirlingGenerator extends AbstractMachineBlock<TileEntityStirl
|
||||
|
||||
public static BlockStirlingGenerator create() {
|
||||
|
||||
PacketHandler.INSTANCE.registerPacket(PacketBurnTime.class);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketBurnTime.class, PacketBurnTime.class, PacketHandler.nextID(), Side.CLIENT);
|
||||
|
||||
BlockStirlingGenerator gen = new BlockStirlingGenerator();
|
||||
gen.init();
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
package crazypants.enderio.machine.generator.stirling;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.util.ClientUtil;
|
||||
|
||||
public class PacketBurnTime extends MessageTileEntity<TileEntityStirlingGenerator> {
|
||||
public class PacketBurnTime extends MessageTileEntity<TileEntityStirlingGenerator> implements IMessageHandler<PacketBurnTime, IMessage> {
|
||||
|
||||
private int burnTime;
|
||||
private int totalBurnTime;
|
||||
public int burnTime;
|
||||
public int totalBurnTime;
|
||||
|
||||
public PacketBurnTime() {
|
||||
}
|
||||
@@ -21,22 +23,19 @@ public class PacketBurnTime extends MessageTileEntity<TileEntityStirlingGenerato
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(ctx, buf);
|
||||
buf.writeInt(burnTime);
|
||||
buf.writeInt(totalBurnTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(ctx, buf);
|
||||
burnTime = buf.readInt();
|
||||
totalBurnTime = buf.readInt();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleClientSide(EntityPlayer player, World worldObj, TileEntityStirlingGenerator tile) {
|
||||
tile.burnTime = burnTime;
|
||||
tile.totalBurnTime = totalBurnTime;
|
||||
public IMessage onMessage(PacketBurnTime message, MessageContext ctx) {
|
||||
ClientUtil.setStirlingBurnTime(message, message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -22,8 +22,8 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
public static final float ENERGY_PER_TICK = 2;
|
||||
|
||||
/** How many ticks left until the item is burnt. */
|
||||
int burnTime = 0;
|
||||
int totalBurnTime;
|
||||
public int burnTime = 0;
|
||||
public int totalBurnTime;
|
||||
|
||||
private PowerDistributor powerDis;
|
||||
|
||||
@@ -172,7 +172,7 @@ public class TileEntityStirlingGenerator extends AbstractMachineEntity implement
|
||||
}
|
||||
}
|
||||
if(!needsUpdate && sendBurnTimePacket) {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketBurnTime(this), this);
|
||||
PacketHandler.sendToAllAround(new PacketBurnTime(this), this);
|
||||
}
|
||||
|
||||
return needsUpdate;
|
||||
|
||||
@@ -21,7 +21,7 @@ public class BlockZombieGenerator extends AbstractMachineBlock<TileZombieGenerat
|
||||
|
||||
public static BlockZombieGenerator create() {
|
||||
|
||||
PacketHandler.INSTANCE.registerPacket(PacketTank.class);
|
||||
PacketHandler.INSTANCE.registerPacket(PacketZombieTank.class);
|
||||
|
||||
BlockZombieGenerator gen = new BlockZombieGenerator();
|
||||
gen.init();
|
||||
|
||||
+4
-5
@@ -8,14 +8,14 @@ import net.minecraft.world.World;
|
||||
import crazypants.enderio.network.MessageTileEntity;
|
||||
import crazypants.enderio.network.NetworkUtil;
|
||||
|
||||
public class PacketTank extends MessageTileEntity<TileZombieGenerator> {
|
||||
public class PacketZombieTank extends MessageTileEntity<TileZombieGenerator> {
|
||||
|
||||
private NBTTagCompound nbtRoot;
|
||||
|
||||
public PacketTank() {
|
||||
public PacketZombieTank() {
|
||||
}
|
||||
|
||||
public PacketTank(TileZombieGenerator tile) {
|
||||
public PacketZombieTank(TileZombieGenerator tile) {
|
||||
super(tile);
|
||||
nbtRoot = new NBTTagCompound();
|
||||
if(tile.fuelTank.getFluidAmount() > 0) {
|
||||
@@ -27,16 +27,15 @@ public class PacketTank extends MessageTileEntity<TileZombieGenerator> {
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(ctx, buf);
|
||||
NetworkUtil.writeNBTTagCompound(nbtRoot, buf);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(ctx, buf);
|
||||
nbtRoot = NetworkUtil.readNBTTagCompound(buf);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void handleClientSide(EntityPlayer player, World worldObj, TileZombieGenerator tile) {
|
||||
if(nbtRoot.hasKey("tank")) {
|
||||
@@ -157,7 +157,7 @@ public class TileZombieGenerator extends AbstractMachineEntity implements IPower
|
||||
}
|
||||
|
||||
if(tanksDirty) {
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketTank(this), this);
|
||||
PacketHandler.INSTANCE.sendToAllAround(new PacketZombieTank(this), this);
|
||||
tanksDirty = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package crazypants.enderio.network;
|
||||
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
|
||||
public class PacketHandler {
|
||||
public class PacketHandler
|
||||
{
|
||||
|
||||
public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("smt");
|
||||
|
||||
@@ -16,4 +17,14 @@ public class PacketHandler {
|
||||
{
|
||||
return ID++;
|
||||
}
|
||||
|
||||
public static void sendToAllAround(IMessage message, TileEntity te, int range)
|
||||
{
|
||||
INSTANCE.sendToAllAround(message, new TargetPoint(te.getWorldObj().provider.dimensionId, te.xCoord, te.yCoord, te.zCoord, range));
|
||||
}
|
||||
|
||||
public static void sendToAllAround(IMessage message, TileEntity te)
|
||||
{
|
||||
sendToAllAround(message, te, 16);
|
||||
}
|
||||
}
|
||||
@@ -46,11 +46,11 @@ public class PacketAccessMode implements IMessage, IMessageHandler<PacketAccessM
|
||||
|
||||
public IMessage onMessage(PacketAccessMode message, MessageContext ctx) {
|
||||
EntityPlayer player = ctx.getServerHandler().playerEntity;
|
||||
TileEntity te = player.worldObj.getTileEntity(x, y, z);
|
||||
TileEntity te = player.worldObj.getTileEntity(message.x, message.y, message.z);
|
||||
if(te instanceof TileTravelAnchor) {
|
||||
((TileTravelAnchor) te).setAccessMode(mode);
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
player.worldObj.markTileEntityChunkModified(x,y,z,te);
|
||||
((TileTravelAnchor) te).setAccessMode(message.mode);
|
||||
player.worldObj.markBlockForUpdate(message.x, message.y, message.z);
|
||||
player.worldObj.markTileEntityChunkModified(message.x, message.y, message.z, te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ public class PacketDrainStaff implements IMessage, IMessageHandler<PacketDrainSt
|
||||
EntityPlayer ep = ctx.getServerHandler().playerEntity;
|
||||
|
||||
if(ItemTravelStaff.isEquipped(ep)) {
|
||||
EnderIO.itemTravelStaff.extractInternal(ep.getCurrentEquippedItem(), powerUse);
|
||||
EnderIO.itemTravelStaff.extractInternal(ep.getCurrentEquippedItem(), message.powerUse);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PacketOpenAuthGui implements IMessage, IMessageHandler<PacketOpenAu
|
||||
}
|
||||
|
||||
public IMessage onMessage(PacketOpenAuthGui message, cpw.mods.fml.common.network.simpleimpl.MessageContext ctx) {
|
||||
ctx.getServerHandler().playerEntity.openGui(EnderIO.instance, GuiHandler.GUI_ID_TRAVEL_AUTH, ctx.getServerHandler().playerEntity.worldObj, x, y, z);
|
||||
ctx.getServerHandler().playerEntity.openGui(EnderIO.instance, GuiHandler.GUI_ID_TRAVEL_AUTH, ctx.getServerHandler().playerEntity.worldObj, message.x, message.y, message.z);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -57,21 +57,21 @@ public class PacketTravelEvent implements IMessage, IMessageHandler<PacketTravel
|
||||
|
||||
ep.playSound("mob.endermen.portal", 1.0F, 1.0F);
|
||||
|
||||
ep.setPositionAndUpdate(x + 0.5, y + 1.1, z + 0.5);
|
||||
ep.setPositionAndUpdate(message.x + 0.5, message.y + 1.1, message.z + 0.5);
|
||||
|
||||
ep.worldObj.playSoundEffect(x, y, z, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
ep.worldObj.playSoundEffect(message.x, message.y, message.z, "mob.endermen.portal", 1.0F, 1.0F);
|
||||
ep.fallDistance = 0;
|
||||
|
||||
if(conserveMotion) {
|
||||
if(message.conserveMotion) {
|
||||
Vector3d velocityVex = Util.getLookVecEio(ep);
|
||||
S12PacketEntityVelocity p = new S12PacketEntityVelocity(ep.getEntityId(), velocityVex.x, velocityVex.y, velocityVex.z);
|
||||
|
||||
ctx.getServerHandler().sendPacket(p);
|
||||
}
|
||||
|
||||
if(powerUse > 0 && ep.getCurrentEquippedItem() != null && ep.getCurrentEquippedItem().getItem() == EnderIO.itemTravelStaff) {
|
||||
if(message.powerUse > 0 && ep.getCurrentEquippedItem() != null && ep.getCurrentEquippedItem().getItem() == EnderIO.itemTravelStaff) {
|
||||
ItemStack item = ep.getCurrentEquippedItem().copy();
|
||||
EnderIO.itemTravelStaff.extractInternal(item, powerUse);
|
||||
EnderIO.itemTravelStaff.extractInternal(item, message.powerUse);
|
||||
ep.setCurrentItemOrArmor(0, item);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,22 @@
|
||||
package crazypants.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import crazypants.enderio.conduit.IConduitBundle;
|
||||
import crazypants.enderio.conduit.TileConduitBundle;
|
||||
import crazypants.enderio.conduit.liquid.ILiquidConduit;
|
||||
import crazypants.enderio.conduit.liquid.PacketFluidLevel;
|
||||
import crazypants.enderio.machine.generator.combustion.PacketCombustionTank;
|
||||
import crazypants.enderio.machine.generator.combustion.TileCombustionGenerator;
|
||||
import crazypants.enderio.machine.generator.stirling.PacketBurnTime;
|
||||
import crazypants.enderio.machine.generator.stirling.TileEntityStirlingGenerator;
|
||||
|
||||
/**
|
||||
* To avoid integrated server crashes when calling client-only methods
|
||||
*
|
||||
* @author Garrett Spicer-Davis
|
||||
*/
|
||||
public class ClientUtil
|
||||
@@ -16,15 +24,51 @@ public class ClientUtil
|
||||
public static void doFluidLevelUpdate(int x, int y, int z, PacketFluidLevel pkt)
|
||||
{
|
||||
TileEntity tile = Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
|
||||
|
||||
if(pkt.tc == null || !(tile instanceof IConduitBundle)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (pkt.tc == null || !(tile instanceof IConduitBundle)) { return; }
|
||||
IConduitBundle bundle = (IConduitBundle) tile;
|
||||
ILiquidConduit con = bundle.getConduit(ILiquidConduit.class);
|
||||
if(con == null) {
|
||||
return;
|
||||
}
|
||||
if (con == null) { return; }
|
||||
con.readFromNBT(pkt.tc, TileConduitBundle.NBT_VERSION);
|
||||
}
|
||||
|
||||
public static void spawnFarmParcticles(Random rand, BlockCoord bc)
|
||||
{
|
||||
double xOff = 0.5 + (rand.nextDouble() - 0.5) * 1.1;
|
||||
double yOff = 0.5 + (rand.nextDouble() - 0.5) * 0.2;
|
||||
double zOff = 0.5 + (rand.nextDouble() - 0.5) * 1.1;
|
||||
Minecraft.getMinecraft().theWorld.spawnParticle("portal", bc.x + xOff, bc.y + yOff, bc.z + zOff, (rand.nextDouble() - 0.5) * 1.5, -rand.nextDouble(), (rand.nextDouble() - 0.5) * 1.5);
|
||||
}
|
||||
|
||||
public static void setTankNBT(PacketCombustionTank message, int x, int y, int z)
|
||||
{
|
||||
TileCombustionGenerator tile = (TileCombustionGenerator) Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
|
||||
|
||||
if (message.nbtRoot.hasKey("coolantTank"))
|
||||
{
|
||||
NBTTagCompound tankRoot = message.nbtRoot.getCompoundTag("coolantTank");
|
||||
tile.getCoolantTank().readFromNBT(tankRoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.getCoolantTank().setFluid(null);
|
||||
}
|
||||
if (message.nbtRoot.hasKey("fuelTank"))
|
||||
{
|
||||
NBTTagCompound tankRoot = message.nbtRoot.getCompoundTag("fuelTank");
|
||||
tile.getFuelTank().readFromNBT(tankRoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
tile.getFuelTank().setFluid(null);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setStirlingBurnTime(PacketBurnTime message, int x, int y, int z)
|
||||
{
|
||||
TileEntityStirlingGenerator tile = (TileEntityStirlingGenerator) Minecraft.getMinecraft().theWorld.getTileEntity(x, y, z);
|
||||
|
||||
tile.burnTime = message.burnTime;
|
||||
tile.totalBurnTime = message.totalBurnTime;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user