Worked on atomic machines

This commit is contained in:
Robert S 2014-08-07 02:57:34 -04:00
parent d751b54b3a
commit 0474addef6
11 changed files with 194 additions and 311 deletions

View file

@ -1,5 +1,6 @@
package resonantinduction.atomic.machine.accelerator;
import net.minecraft.inventory.IInventory;
import resonantinduction.atomic.Atomic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -14,17 +15,17 @@ public class ContainerAccelerator extends ContainerBase
{
private TileAccelerator tileEntity;
public ContainerAccelerator(InventoryPlayer par1InventoryPlayer, TileAccelerator tileEntity)
public ContainerAccelerator(EntityPlayer player, TileAccelerator tileEntity)
{
super(tileEntity);
super(player, (IInventory)tileEntity);
this.tileEntity = tileEntity;
// Inputs
addSlotToContainer(new Slot(tileEntity, 0, 132, 26));
addSlotToContainer(new Slot(tileEntity, 1, 132, 51));
addSlotToContainer(new Slot((IInventory)tileEntity, 0, 132, 26));
addSlotToContainer(new Slot((IInventory)tileEntity, 1, 132, 51));
// Output
addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, tileEntity, 2, 132, 75));
addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, tileEntity, 3, 106, 75));
addPlayerInventory(par1InventoryPlayer.player);
addSlotToContainer(new SlotFurnace(player, (IInventory)tileEntity, 2, 132, 75));
addSlotToContainer(new SlotFurnace(player, (IInventory)tileEntity, 3, 106, 75));
addPlayerInventory(player);
}
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */

View file

@ -17,6 +17,7 @@ import net.minecraftforge.common.ForgeChunkManager.Type;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.api.IElectromagnet;
import resonant.lib.prefab.poison.PoisonRadiation;
import resonantinduction.atomic.Atomic;
import resonantinduction.core.Reference;
import universalelectricity.core.transform.vector.Vector3;
@ -120,7 +121,7 @@ public class EntityParticle extends Entity implements IEntityAdditionalSpawnData
/** Play sound fxs. */
if (this.ticksExisted % 10 == 0)
{
this.worldObj.playSoundAtEntity(this, Reference.PREFIX + "accelerator", 1f, (float) (0.6f + (0.4 * (this.getParticleVelocity() / TileAccelerator.clientParticleVelocity))));
this.worldObj.playSoundAtEntity(this, Reference.prefix() + "accelerator", 1f, (float) (0.6f + (0.4 * (this.getParticleVelocity() / TileAccelerator.clientParticleVelocity))));
}
/** Check if the accelerator tile entity exists. */

View file

@ -2,8 +2,7 @@ package resonantinduction.atomic.machine.accelerator;
import net.minecraft.entity.player.InventoryPlayer;
import resonant.lib.gui.GuiContainerBase;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import universalelectricity.api.UnitDisplay;
import universalelectricity.core.transform.vector.Vector3;
public class GuiAccelerator extends GuiContainerBase
@ -23,13 +22,13 @@ public class GuiAccelerator extends GuiContainerBase
@Override
public void drawGuiContainerForegroundLayer(int x, int y)
{
this.fontRenderer.drawString(tileEntity.getInvName(), 40, 10, 4210752);
this.fontRendererObj.drawString("Accelerator", 40, 10, 4210752);
String status = "";
Vector3 position = new Vector3(this.tileEntity);
position.add(this.tileEntity.getDirection().getOpposite());
if (!EntityParticle.canSpawnParticle(this.tileEntity.worldObj, position))
if (!EntityParticle.canSpawnParticle(this.tileEntity.world(), position))
{
status = "\u00a74Fail to emit; try rotating.";
}
@ -42,17 +41,17 @@ public class GuiAccelerator extends GuiContainerBase
status = "\u00a72Idle";
}
this.fontRenderer.drawString("Velocity: " + Math.round((this.tileEntity.velocity / TileAccelerator.clientParticleVelocity) * 100) + "%", 8, 27, 4210752);
this.fontRenderer.drawString("Energy Used:", 8, 38, 4210752);
this.fontRenderer.drawString(UnitDisplay.getDisplay(this.tileEntity.totalEnergyConsumed, Unit.JOULES), 8, 49, 4210752);
this.fontRenderer.drawString(UnitDisplay.getDisplay(TileAccelerator.energyPerTick * 20, Unit.WATT), 8, 60, 4210752);
this.fontRenderer.drawString(UnitDisplay.getDisplay(this.tileEntity.getVoltageInput(null), Unit.VOLTAGE), 8, 70, 4210752);
this.fontRenderer.drawString("Antimatter: " + this.tileEntity.antimatter + " mg", 8, 80, 4210752);
this.fontRenderer.drawString("Status:", 8, 90, 4210752);
this.fontRenderer.drawString(status, 8, 100, 4210752);
this.fontRenderer.drawString("Buffer: " + UnitDisplay.getDisplayShort(this.tileEntity.getEnergyHandler().getEnergy(), Unit.JOULES) + "/" + UnitDisplay.getDisplayShort(this.tileEntity.getEnergyHandler().getEnergyCapacity(), Unit.JOULES), 8, 110,
this.fontRendererObj.drawString("Velocity: " + Math.round((this.tileEntity.velocity / TileAccelerator.clientParticleVelocity) * 100) + "%", 8, 27, 4210752);
this.fontRendererObj.drawString("Energy Used:", 8, 38, 4210752);
this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.totalEnergyConsumed).toString(), 8, 49, 4210752);
this.fontRendererObj.drawString(new UnitDisplay(UnitDisplay.Unit.WATT, TileAccelerator.energyPerTick * 20).toString(), 8, 60, 4210752);
this.fontRendererObj.drawString("N?A", 8, 70, 4210752);
this.fontRendererObj.drawString("Antimatter: " + this.tileEntity.antimatter + " mg", 8, 80, 4210752);
this.fontRendererObj.drawString("Status:", 8, 90, 4210752);
this.fontRendererObj.drawString(status, 8, 100, 4210752);
this.fontRendererObj.drawString("Buffer: " + this.tileEntity.electricNode().getEnergy() + "/" + new UnitDisplay(UnitDisplay.Unit.JOULES, this.tileEntity.electricNode().getEnergyCapacity(),true ), 8, 110,
4210752);
this.fontRenderer.drawString("Facing: " + this.tileEntity.getDirection().getOpposite(), 100, 123, 4210752);
this.fontRendererObj.drawString("Facing: " + this.tileEntity.getDirection().getOpposite(), 100, 123, 4210752);
}
/** Draw the background layer for the GuiContainer (everything behind the items) */

View file

@ -1,35 +1,33 @@
package resonantinduction.atomic.machine.accelerator;
import atomic.Atomic;
import net.minecraft.block.material.Material;
import net.minecraft.network.Packet;
import resonant.engine.ResonantEngine;
import resonant.lib.network.discriminator.PacketAnnotation;
import resonant.lib.utility.BlockUtility;
import resonantinduction.atomic.Atomic;
import resonantinduction.atomic.items.ItemAntimatter;
import resonantinduction.atomic.items.ItemDarkMatter;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.util.ForgeDirection;
import resonant.api.IElectromagnet;
import resonant.api.IRotatable;
import resonant.lib.network.Synced;
import resonant.lib.prefab.tile.TileElectricalInventory;
import atomic.items.ItemAntimatter;
import resonantinduction.atomic.items.ItemDarkMatter;
import resonantinduction.core.Reference;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import universalelectricity.api.UniversalElectricity;
import universalelectricity.api.electricity.IVoltageInput;
import universalelectricity.api.energy.EnergyStorageHandler;
import universalelectricity.api.energy.IEnergyInterface;
import universalelectricity.api.core.grid.INodeProvider;
import universalelectricity.api.core.grid.electric.IEnergyNode;
import universalelectricity.core.transform.vector.Vector3;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import resonant.lib.content.prefab.java.TileElectricInventory;
/** Accelerator TileEntity */
public class TileAccelerator extends TileElectricalInventory implements IElectromagnet, IRotatable, IInventory, ISidedInventory, IVoltageInput
public class TileAccelerator extends TileElectricInventory implements IElectromagnet, IRotatable
{
/** Joules required per ticks. */
public static final int energyPerTick = 4800000;
@ -50,7 +48,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
public float velocity;
@Synced
private long clientEnergy = 0;
private double clientEnergy = 0;
private int lastSpawnTick = 0;
@ -60,42 +58,19 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
public TileAccelerator()
{
super(UniversalElectricity.machine);
energy = new EnergyStorageHandler(energyPerTick * 2, energyPerTick / 20);
maxSlots = 4;
super(Material.iron);
this.setSizeInventory(4);
antiMatterDensityMultiplyer = DENSITY_MULTIPLYER_DEFAULT;
}
@Override
public boolean canConnect(ForgeDirection direction, Object obj)
public void update()
{
return obj instanceof IEnergyInterface;
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
{
if (doReceive)
{
totalEnergyConsumed += receive;
}
if (getStackInSlot(0) != null && (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord) || worldObj.getBlockPowerInput(xCoord, yCoord, zCoord) > 0))
{
return super.onReceiveEnergy(from, receive, doReceive);
}
return 0;
}
@Override
public void updateEntity()
{
super.updateEntity();
super.update();
if (!worldObj.isRemote)
{
clientEnergy = energy.getEnergy();
clientEnergy = electricNode().energy().getEnergy();
velocity = 0;
// Calculate accelerated particle velocity if it is spawned.
@ -116,7 +91,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
if (getStackInSlot(2) != null)
{
// Increase the existing amount of anti-matter if stack already exists.
if (getStackInSlot(2).itemID == Atomic.itemAntimatter.itemID)
if (getStackInSlot(2).getItem() == Atomic.itemAntimatter)
{
ItemStack newStack = getStackInSlot(2).copy();
if (newStack.stackSize < newStack.getMaxStackSize())
@ -145,7 +120,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
// Check if redstone signal is currently being applied.
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord))
{
if (energy.checkExtract())
if (electricNode().energy().checkExtract())
{
if (entityParticle == null)
{
@ -180,7 +155,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
// On particle collision we roll the dice to see if dark-matter is generated.
if (entityParticle.didParticleCollide)
{
if (worldObj.rand.nextFloat() <= Settings.darkMatterSpawnChance)
if (worldObj.rand.nextFloat() <= Settings.darkMatterSpawnChance())
{
incrStackSize(3, new ItemStack(Atomic.itemDarkMatter));
}
@ -191,7 +166,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
else if (velocity > clientParticleVelocity)
{
// Play sound of anti-matter being created.
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.PREFIX + "antimatter", 2f, 1f - worldObj.rand.nextFloat() * 0.3f);
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix() + "antimatter", 2f, 1f - worldObj.rand.nextFloat() * 0.3f);
// Create anti-matter in the internal reserve.
int generatedAntimatter = 5 + worldObj.rand.nextInt(antiMatterDensityMultiplyer);
@ -207,11 +182,11 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
// Plays sound of particle accelerating past the speed based on total velocity at the time of anti-matter creation.
if (entityParticle != null)
{
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.PREFIX + "accelerator", 1.5f, (float) (0.6f + (0.4 * (entityParticle.getParticleVelocity()) / TileAccelerator.clientParticleVelocity)));
worldObj.playSoundEffect(xCoord, yCoord, zCoord, Reference.prefix() + "accelerator", 1.5f, (float) (0.6f + (0.4 * (entityParticle.getParticleVelocity()) / TileAccelerator.clientParticleVelocity)));
}
}
energy.extractEnergy();
electricNode().energy().extractEnergy();
}
else
{
@ -233,12 +208,12 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
entityParticle = null;
}
if (ticks % 5 == 0)
if (ticks() % 5 == 0)
{
for (EntityPlayer player : getPlayersUsing())
{
PacketDispatcher.sendPacketToPlayer(getDescriptionPacket(), (Player) player);
}
//for (EntityPlayer player : getPlayersUsing())
//{
// ResonantEngine.instance.packetHandler.sendtoPlayer(new PacketAnnotation(this), player);
//}
}
lastSpawnTick++;
@ -246,7 +221,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
}
@Override
protected boolean use(EntityPlayer player, int side, Vector3 hit)
public boolean use(EntityPlayer player, int side, Vector3 hit)
{
if (!world().isRemote)
{
@ -264,11 +239,11 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
antiMatterDensityMultiplyer = DENSITY_MULTIPLYER_DEFAULT;
try
{
Block potentialBlock = Block.blocksList[itemToAccelerate.getItem().itemID];
Block potentialBlock = Block.getBlockFromItem(itemToAccelerate.getItem());
if (potentialBlock != null)
{
// Prevent negative numbers and disallow zero for density multiplier.
antiMatterDensityMultiplyer = (int) Math.abs(potentialBlock.blockHardness);
antiMatterDensityMultiplyer = (int) Math.abs(BlockUtility.getBlockHardness(potentialBlock));
if (antiMatterDensityMultiplyer <= 0)
{
antiMatterDensityMultiplyer = 1;
@ -288,7 +263,7 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
@Override
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_ANNOTATION.getPacket(this);
return ResonantEngine.instance.packetHandler.toMCPacket(new PacketAnnotation(this));
}
/** Reads a tile entity from NBT. */
@ -309,12 +284,6 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
par1NBTTagCompound.setInteger("antimatter", antimatter);
}
@Override
public long getVoltageInput(ForgeDirection dir)
{
return 1000;
}
@Override
public int[] getAccessibleSlotsFromSide(int side)
{
@ -352,22 +321,21 @@ public class TileAccelerator extends TileElectricalInventory implements IElectro
return false;
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
return 0;
}
@Override
public void onWrongVoltage(ForgeDirection direction, long voltage)
{
}
@Override
public boolean isRunning()
{
return true;
}
@Override
public ForgeDirection getDirection()
{
return ForgeDirection.getOrientation(getBlockMetadata());
}
@Override
public void setDirection(ForgeDirection direction)
{
world().setBlockMetadataWithNotify(xCoord, yCoord, zCoord, direction.ordinal(), 3);
}
}

View file

@ -1,60 +0,0 @@
package resonantinduction.atomic.machine.boiler;
import atomic.Atomic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import resonant.lib.prefab.block.BlockRotatable;
import resonant.lib.render.block.BlockRenderingHandler;
import universalelectricity.api.UniversalElectricity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/** Nuclear boiler block */
public class BlockNuclearBoiler extends BlockRotatable
{
public BlockNuclearBoiler(int ID)
{
super(ID, UniversalElectricity.machine);
}
/** Called when the block is right clicked by the player */
@Override
public boolean onMachineActivated(World par1World, int x, int y, int z, EntityPlayer par5EntityPlayer, int side, float hitX, float hitY, float hitZ)
{
int metadata = par1World.getBlockMetadata(x, y, z);
if (!par1World.isRemote)
{
par5EntityPlayer.openGui(Atomic.INSTANCE, 0, par1World, x, y, z);
return true;
}
return true;
}
@SideOnly(Side.CLIENT)
@Override
public int getRenderType()
{
return BlockRenderingHandler.ID;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileNuclearBoiler();
}
@Override
public boolean renderAsNormalBlock()
{
return false;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
}

View file

@ -1,83 +0,0 @@
package resonantinduction.atomic.machine.boiler;
import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import atomic.machine.extractor.TileChemicalExtractor;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase;
import resonantinduction.atomic.machine.extractor.ContainerChemicalExtractor;
import universalelectricity.api.energy.UnitDisplay.Unit;
public class GuiChemicalExtractor extends GuiContainerBase
{
private TileChemicalExtractor tileEntity;
public GuiChemicalExtractor(InventoryPlayer par1InventoryPlayer, TileChemicalExtractor tileEntity)
{
super(new ContainerChemicalExtractor(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
@Override
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 4210752);
this.renderUniversalDisplay(8, 112, TileChemicalExtractor.ENERGY * 20, mouseX, mouseY, Unit.WATT);
this.renderUniversalDisplay(100, 112, this.tileEntity.getVoltageInput(null), mouseX, mouseY, Unit.VOLTAGE);
this.fontRenderer.drawString("The extractor can extract", 8, 75, 4210752);
this.fontRenderer.drawString("uranium, deuterium and tritium.", 8, 85, 4210752);
this.fontRenderer.drawString("Place them in the input slot.", 8, 95, 4210752);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
if (this.isPointInRegion(8, 18, this.meterWidth, this.meterHeight, mouseX, mouseY) && this.tileEntity.inputTank.getFluid() != null)
{
if (this.tileEntity.inputTank.getFluid() != null)
{
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop + 10, this.tileEntity.inputTank.getFluid().getFluid().getLocalizedName(), this.tileEntity.inputTank.getFluid().amount + " L");
}
}
if (this.isPointInRegion(154, 18, this.meterWidth, this.meterHeight, mouseX, mouseY) && this.tileEntity.outputTank.getFluid() != null)
{
if (this.tileEntity.outputTank.getFluid() != null)
{
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop + 10, this.tileEntity.outputTank.getFluid().getFluid().getLocalizedName(), this.tileEntity.outputTank.getFluid().amount + " L");
}
}
if (this.isPointInRegion(134, 49, 18, 18, mouseX, mouseY))
{
if (this.tileEntity.getStackInSlot(4) == null)
{
// this.drawTooltip(x - this.guiLeft, y - this.guiTop + 10, "Place empty cells.");
}
}
if (this.isPointInRegion(52, 24, 18, 18, mouseX, mouseY))
{
if (this.tileEntity.outputTank.getFluidAmount() > 0 && this.tileEntity.getStackInSlot(3) == null)
{
this.drawTooltip(mouseX - this.guiLeft, mouseY - this.guiTop + 10, "Input slot");
}
}
}
/** Draw the background layer for the GuiContainer (everything behind the items) */
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int x, int y)
{
super.drawGuiContainerBackgroundLayer(par1, x, y);
drawSlot(79, 49, SlotType.BATTERY);
drawSlot(52, 24);
drawSlot(106, 24);
drawBar(75, 24, (float) tileEntity.time / (float) TileChemicalExtractor.TICK_TIME);
drawMeter(8, 18, (float) tileEntity.inputTank.getFluidAmount() / (float) tileEntity.inputTank.getCapacity(), tileEntity.inputTank.getFluid());
drawSlot(24, 18, SlotType.LIQUID);
drawSlot(24, 49, SlotType.LIQUID);
drawMeter(154, 18, (float) tileEntity.outputTank.getFluidAmount() / (float) tileEntity.outputTank.getCapacity(), tileEntity.outputTank.getFluid());
drawSlot(134, 18, SlotType.LIQUID);
drawSlot(134, 49, SlotType.LIQUID);
}
}

View file

@ -5,10 +5,10 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import org.lwjgl.opengl.GL11;
import resonant.lib.render.RenderUtility;
import resonant.lib.render.model.TechneAdvancedModel;
import resonantinduction.core.Reference;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -16,8 +16,8 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderNuclearBoiler extends TileEntitySpecialRenderer
{
public static final TechneAdvancedModel MODEL = (TechneAdvancedModel) AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "nuclearBoiler.tcn");
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "nuclearBoiler.png");
public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(new ResourceLocation(Reference.domain(), Reference.modelDirectory() + "nuclearBoiler.tcn"));
public static final ResourceLocation TEXTURE = new ResourceLocation(Reference.domain(), Reference.modelPath() + "nuclearBoiler.png");
public void renderAModelAt(TileNuclearBoiler tileEntity, double x, double y, double z, float f)
{
@ -25,16 +25,17 @@ public class RenderNuclearBoiler extends TileEntitySpecialRenderer
GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glRotatef(90, 0, 1, 0);
if (tileEntity.worldObj != null)
if (tileEntity.world() != null)
{
RenderUtility.rotateBlockBasedOnDirection(tileEntity.getDirection());
}
bindTexture(TEXTURE);
MODEL.renderOnlyAroundPivot(Math.toDegrees(tileEntity.rotation), 0, 1, 0, "FUEL BAR SUPPORT 1 ROTATES", "FUEL BAR 1 ROTATES");
MODEL.renderOnlyAroundPivot(-Math.toDegrees(tileEntity.rotation), 0, 1, 0, "FUEL BAR SUPPORT 2 ROTATES", "FUEL BAR 2 ROTATES");
MODEL.renderAllExcept("FUEL BAR SUPPORT 1 ROTATES", "FUEL BAR SUPPORT 2 ROTATES", "FUEL BAR 1 ROTATES", "FUEL BAR 2 ROTATES");
MODEL.renderAll(); //TODO re-add rotation
//MODEL.renderOnlyAroundPivot(Math.toDegrees(tileEntity.rotation), 0, 1, 0, "FUEL BAR SUPPORT 1 ROTATES", "FUEL BAR 1 ROTATES");
//MODEL.renderOnlyAroundPivot(-Math.toDegrees(tileEntity.rotation), 0, 1, 0, "FUEL BAR SUPPORT 2 ROTATES", "FUEL BAR 2 ROTATES");
//MODEL.renderAllExcept("FUEL BAR SUPPORT 1 ROTATES", "FUEL BAR SUPPORT 2 ROTATES", "FUEL BAR 1 ROTATES", "FUEL BAR 2 ROTATES");
GL11.glPopMatrix();
}

View file

@ -1,11 +1,18 @@
package resonantinduction.atomic.machine.boiler;
import io.netty.buffer.ByteBuf;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.network.Packet;
import resonant.engine.ResonantEngine;
import resonant.lib.network.discriminator.PacketTile;
import resonant.lib.network.discriminator.PacketType;
import resonant.lib.network.handle.IPacketReceiver;
import resonantinduction.atomic.Atomic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.packet.Packet;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
@ -14,23 +21,18 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import resonant.api.IRotatable;
import resonant.lib.network.IPacketReceiver;
import resonant.lib.network.Synced;
import resonant.lib.prefab.tile.TileElectricalInventory;
import resonantinduction.atomic.Atomic;
import resonantinduction.core.ResonantInduction;
import resonantinduction.core.Settings;
import universalelectricity.api.electricity.IVoltageInput;
import universalelectricity.api.energy.EnergyStorageHandler;
import com.google.common.io.ByteArrayDataInput;
import cpw.mods.fml.common.network.PacketDispatcher;
import cpw.mods.fml.common.network.Player;
import resonant.lib.content.prefab.java.TileElectricInventory;
import universalelectricity.core.transform.vector.Vector3;
/** Nuclear boiler TileEntity */
public class TileNuclearBoiler extends TileElectricalInventory implements ISidedInventory, IPacketReceiver, IFluidHandler, IRotatable, IVoltageInput
public class TileNuclearBoiler extends TileElectricInventory implements IPacketReceiver, IFluidHandler, IRotatable
{
public final static long DIAN = 50000;
public final int SHI_JIAN = 20 * 15;
@ -45,25 +47,15 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
public TileNuclearBoiler()
{
energy = new EnergyStorageHandler(DIAN * 2);
maxSlots = 4;
super(Material.iron);
electricNode().energy().setCapacity(DIAN * 2);
this.setSizeInventory(4);
}
@Override
public long onReceiveEnergy(ForgeDirection from, long receive, boolean doReceive)
public void update()
{
if (this.nengYong())
{
return super.onReceiveEnergy(from, receive, doReceive);
}
return 0;
}
@Override
public void updateEntity()
{
super.updateEntity();
super.update();
if (timer > 0)
{
@ -83,7 +75,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
{
if (this.fill(ForgeDirection.UNKNOWN, liquid, false) > 0)
{
ItemStack resultingContainer = getStackInSlot(1).getItem().getContainerItemStack(getStackInSlot(1));
ItemStack resultingContainer = getStackInSlot(1).getItem().getContainerItem(getStackInSlot(1));
if (resultingContainer == null && getStackInSlot(1).stackSize > 1)
{
@ -104,7 +96,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
{
this.discharge(getStackInSlot(0));
if (this.energy.extractEnergy(DIAN, false) >= TileNuclearBoiler.DIAN)
if (electricNode().energy().extractEnergy(DIAN, false) >= TileNuclearBoiler.DIAN)
{
if (this.timer == 0)
{
@ -126,7 +118,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
this.timer = 0;
}
this.energy.extractEnergy(DIAN, true);
electricNode().energy().extractEnergy(DIAN, true);
}
}
else
@ -134,7 +126,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
this.timer = 0;
}
if (this.ticks % 10 == 0)
if (this.ticks() % 10 == 0)
{
this.sendDescPack();
}
@ -142,7 +134,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
}
@Override
public void onReceivePacket(ByteArrayDataInput data, EntityPlayer player, Object... extra)
public void read(ByteBuf data, EntityPlayer player, PacketType type)
{
try
{
@ -159,20 +151,33 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
@Override
public Packet getDescriptionPacket()
{
return ResonantInduction.PACKET_TILE.getPacket(this, this.timer, Atomic.getFluidAmount(this.waterTank.getFluid()), Atomic.getFluidAmount(this.gasTank.getFluid()));
return ResonantEngine.instance.packetHandler.toMCPacket(getDescPacket());
}
public PacketTile getDescPacket()
{
return new PacketTile(this, this.timer, Atomic.getFluidAmount(this.waterTank.getFluid()), Atomic.getFluidAmount(this.gasTank.getFluid()));
}
public void sendDescPack()
{
if (!this.worldObj.isRemote)
{
for (EntityPlayer player : this.getPlayersUsing())
{
PacketDispatcher.sendPacketToPlayer(getDescriptionPacket(), (Player) player);
}
//for (EntityPlayerMP player : this.getPlayersUsing())
//{
// ResonantEngine.instance.packetHandler.sendToPlayer(getDescPacket(), player);
//}
}
}
@Override
public boolean use(EntityPlayer player, int side, Vector3 hit)
{
openGui(player, Atomic.INSTANCE);
return true;
}
// Check all conditions and see if we can start smelting
public boolean nengYong()
{
@ -182,7 +187,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
{
if (getStackInSlot(3) != null)
{
if (Atomic.itemYellowCake.itemID == getStackInSlot(3).itemID || Atomic.isItemStackUraniumOre(getStackInSlot(3)))
if (Atomic.itemYellowCake == getStackInSlot(3).getItem() || Atomic.isItemStackUraniumOre(getStackInSlot(3)))
{
if (Atomic.getFluidAmount(this.gasTank.getFluid()) < this.gasTank.getCapacity())
{
@ -203,7 +208,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
{
this.waterTank.drain(FluidContainerRegistry.BUCKET_VOLUME, true);
FluidStack liquid = Atomic.FLUIDSTACK_URANIUM_HEXAFLOURIDE.copy();
liquid.amount = Settings.uraniumHexaflourideRatio * 2;
liquid.amount = Settings.uraniumHexaflourideRatio() * 2;
this.gasTank.fill(liquid, true);
this.decrStackSize(3, 1);
}
@ -303,7 +308,7 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
}
else if (slotID == 3)
{
return itemStack.itemID == Atomic.itemYellowCake.itemID;
return itemStack.getItem() == Atomic.itemYellowCake;
}
return false;
@ -330,20 +335,12 @@ public class TileNuclearBoiler extends TileElectricalInventory implements ISided
}
@Override
public long onExtractEnergy(ForgeDirection from, long extract, boolean doExtract)
{
return 0;
public ForgeDirection getDirection() {
return null;
}
@Override
public long getVoltageInput(ForgeDirection from)
{
return 1000;
}
@Override
public void onWrongVoltage(ForgeDirection direction, long voltage)
{
public void setDirection(ForgeDirection direction) {
}
}

View file

@ -0,0 +1,51 @@
package resonantinduction.atomic.machine.extractor;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.StatCollector;
import resonant.lib.gui.GuiContainerBase;
import universalelectricity.api.UnitDisplay;
public class GuiChemicalExtractor extends GuiContainerBase
{
private TileChemicalExtractor tileEntity;
public GuiChemicalExtractor(InventoryPlayer par1InventoryPlayer, TileChemicalExtractor tileEntity)
{
super(new ContainerChemicalExtractor(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity;
}
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
@Override
public void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
this.fontRendererObj.drawString("Chemical Extractor", 45, 6, 4210752);
this.renderUniversalDisplay(8, 112, TileChemicalExtractor.ENERGY * 20, mouseX, mouseY, UnitDisplay.Unit.WATT);
this.renderUniversalDisplay(100, 112, this.tileEntity.getVoltageInput(null), mouseX, mouseY, UnitDisplay.Unit.VOLTAGE);
this.fontRendererObj.drawString("The extractor can extract", 8, 75, 4210752);
this.fontRendererObj.drawString("uranium, deuterium and tritium.", 8, 85, 4210752);
this.fontRendererObj.drawString("Place them in the input slot.", 8, 95, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
/** Draw the background layer for the GuiContainer (everything behind the items) */
@Override
protected void drawGuiContainerBackgroundLayer(float par1, int x, int y)
{
super.drawGuiContainerBackgroundLayer(par1, x, y);
drawSlot(79, 49, SlotType.BATTERY);
drawSlot(52, 24);
drawSlot(106, 24);
drawBar(75, 24, (float) tileEntity.time / (float) TileChemicalExtractor.TICK_TIME);
drawMeter(8, 18, (float) tileEntity.inputTank.getFluidAmount() / (float) tileEntity.inputTank.getCapacity(), tileEntity.inputTank.getFluid());
drawSlot(24, 18, SlotType.LIQUID);
drawSlot(24, 49, SlotType.LIQUID);
drawMeter(154, 18, (float) tileEntity.outputTank.getFluidAmount() / (float) tileEntity.outputTank.getCapacity(), tileEntity.outputTank.getFluid());
drawSlot(134, 18, SlotType.LIQUID);
drawSlot(134, 49, SlotType.LIQUID);
}
}

View file

@ -1,5 +1,6 @@
package resonantinduction.atomic.machine.extractor;
import net.minecraft.block.material.Material;
import resonantinduction.atomic.Atomic;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
@ -43,8 +44,9 @@ public class TileChemicalExtractor extends TileProcess implements ISidedInventor
public TileChemicalExtractor()
{
energy = new EnergyStorageHandler(ENERGY * 2);
maxSlots = 7;
super(Material.iron);
electricNode().energy().setCapacity(ENERGY * 2);
this.setSizeInventory(7);
inputSlot = 1;
outputSlot = 2;
tankInputFillSlot = 3;
@ -54,9 +56,9 @@ public class TileChemicalExtractor extends TileProcess implements ISidedInventor
}
@Override
public void updateEntity()
public void update()
{
super.updateEntity();
super.update();
if (time > 0)
{
@ -69,7 +71,7 @@ public class TileChemicalExtractor extends TileProcess implements ISidedInventor
{
discharge(getStackInSlot(0));
if (energy.checkExtract(ENERGY))
if (electricNode().energy().checkExtract(ENERGY))
{
if (time == 0)
{
@ -106,12 +108,12 @@ public class TileChemicalExtractor extends TileProcess implements ISidedInventor
time = 0;
}
if (ticks % 10 == 0)
if (ticks() % 10 == 0)
{
for (EntityPlayer player : getPlayersUsing())
{
PacketDispatcher.sendPacketToPlayer(getDescriptionPacket(), (Player) player);
}
//for (EntityPlayer player : getPlayersUsing())
//{
// PacketDispatcher.sendPacketToPlayer(getDescriptionPacket(), (Player) player);
//}
}
}
}

View file

@ -1,17 +1,18 @@
package resonantinduction.atomic.machine.extractor;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTank;
import resonant.api.recipe.MachineRecipes;
import resonant.api.recipe.RecipeResource;
import resonant.lib.prefab.tile.TileElectricalInventory;
import resonant.lib.content.prefab.java.TileElectricInventory;
/** General class for all machines that do traditional recipe processing
*
* @author Calclavia */
public abstract class TileProcess extends TileElectricalInventory
public abstract class TileProcess extends TileElectricInventory
{
protected int inputSlot;
protected int outputSlot;
@ -23,10 +24,15 @@ public abstract class TileProcess extends TileElectricalInventory
protected String machineName;
@Override
public void updateEntity()
public TileProcess(Material material)
{
super.updateEntity();
super(material);
}
@Override
public void update()
{
super.update();
if (getInputTank() != null)
{
@ -47,7 +53,7 @@ public abstract class TileProcess extends TileElectricalInventory
if (FluidContainerRegistry.isFilledContainer(inputStack))
{
FluidStack fluidStack = FluidContainerRegistry.getFluidForFilledItem(inputStack);
ItemStack result = inputStack.getItem().getContainerItemStack(inputStack);
ItemStack result = inputStack.getItem().getContainerItem(inputStack);
if (result != null && tank.fill(fluidStack, false) >= fluidStack.amount && (outputStack == null || result.isItemEqual(outputStack)))
{