Added GUI and containers for basic machines
Also from Basic Components but they are just temporary to get things rolling. I do not plan to create release with this code. Most of it will rewritten to support my collective block designs.
This commit is contained in:
parent
05af492258
commit
90c98c3e1e
10 changed files with 632 additions and 10 deletions
|
@ -2,6 +2,8 @@ package dark.core.client;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.client.FMLClientHandler;
|
||||
|
@ -12,6 +14,9 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
import dark.core.client.renders.RenderBlockWire;
|
||||
import dark.core.common.CommonProxy;
|
||||
import dark.core.common.CoreRecipeLoader;
|
||||
import dark.core.common.machines.TileEntityBatteryBox;
|
||||
import dark.core.common.machines.TileEntityCoalGenerator;
|
||||
import dark.core.common.machines.TileEntityElectricFurnace;
|
||||
import dark.core.common.transmit.TileEntityWire;
|
||||
import dark.core.prefab.ModPrefab;
|
||||
|
||||
|
@ -20,7 +25,7 @@ public class ClientProxy extends CommonProxy
|
|||
{
|
||||
|
||||
/** Renders a laser beam from one power to another by a set color for a set time
|
||||
*
|
||||
*
|
||||
* @param world - world this laser is to be rendered in
|
||||
* @param position - start vector3
|
||||
* @param target - end vector3
|
||||
|
@ -43,4 +48,28 @@ public class ClientProxy extends CommonProxy
|
|||
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityWire.class, new RenderBlockWire());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityBatteryBox)
|
||||
{
|
||||
return new GuiBatteryBox(player.inventory, ((TileEntityBatteryBox) tileEntity));
|
||||
}
|
||||
else if (tileEntity instanceof TileEntityCoalGenerator)
|
||||
{
|
||||
return new GuiCoalGenerator(player.inventory, ((TileEntityCoalGenerator) tileEntity));
|
||||
}
|
||||
else if (tileEntity instanceof TileEntityElectricFurnace)
|
||||
{
|
||||
return new GuiElectricFurnace(player.inventory, ((TileEntityElectricFurnace) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
64
src/dark/core/client/GuiBatteryBox.java
Normal file
64
src/dark/core/client/GuiBatteryBox.java
Normal file
|
@ -0,0 +1,64 @@
|
|||
package dark.core.client;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.common.machines.ContainerBatteryBox;
|
||||
import dark.core.common.machines.TileEntityBatteryBox;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiBatteryBox extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation batteryBoxTexture = new ResourceLocation(DarkMain.getInstance().DOMAIN, DarkMain.GUI_DIRECTORY + "battery_box.png");
|
||||
|
||||
private TileEntityBatteryBox tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiBatteryBox(InventoryPlayer par1InventoryPlayer, TileEntityBatteryBox batteryBox)
|
||||
{
|
||||
super(new ContainerBatteryBox(par1InventoryPlayer, batteryBox));
|
||||
this.tileEntity = batteryBox;
|
||||
}
|
||||
|
||||
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 65, 6, 4210752);
|
||||
String displayJoules = ElectricityDisplay.getDisplayShort(tileEntity.getEnergyStored(), ElectricUnit.JOULES) + " of";
|
||||
String displayMaxJoules = ElectricityDisplay.getDisplay(tileEntity.getMaxEnergyStored(), ElectricUnit.JOULES);
|
||||
String displayVoltage = "Voltage: " + (int) (this.tileEntity.getVoltage() * 1000);
|
||||
|
||||
this.fontRenderer.drawString(displayJoules, 122 - this.fontRenderer.getStringWidth(displayJoules) / 2, 30, 4210752);
|
||||
this.fontRenderer.drawString(displayMaxJoules, 122 - this.fontRenderer.getStringWidth(displayMaxJoules) / 2, 40, 4210752);
|
||||
this.fontRenderer.drawString(displayVoltage, 122 - this.fontRenderer.getStringWidth(displayVoltage) / 2, 60, 4210752);
|
||||
this.fontRenderer.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 par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.func_110577_a(batteryBoxTexture);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
this.containerWidth = (this.width - this.xSize) / 2;
|
||||
this.containerHeight = (this.height - this.ySize) / 2;
|
||||
// Background energy bar
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
// Foreground energy bar
|
||||
int scale = (int) ((this.tileEntity.getEnergyStored() / this.tileEntity.getMaxEnergyStored()) * 72);
|
||||
this.drawTexturedModalRect(containerWidth + 87, containerHeight + 52, 176, 0, scale, 20);
|
||||
}
|
||||
}
|
72
src/dark/core/client/GuiCoalGenerator.java
Normal file
72
src/dark/core/client/GuiCoalGenerator.java
Normal file
|
@ -0,0 +1,72 @@
|
|||
package dark.core.client;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.common.machines.ContainerCoalGenerator;
|
||||
import dark.core.common.machines.TileEntityCoalGenerator;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiCoalGenerator extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation coalGeneratorTexture = new ResourceLocation(DarkMain.getInstance().DOMAIN,DarkMain.GUI_DIRECTORY+ "coal_generator.png");
|
||||
|
||||
private TileEntityCoalGenerator tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiCoalGenerator(InventoryPlayer par1InventoryPlayer, TileEntityCoalGenerator tileEntity)
|
||||
{
|
||||
super(new ContainerCoalGenerator(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 55, 6, 4210752);
|
||||
String displayText = "Generating";
|
||||
this.fontRenderer.drawString(displayText, 122 - this.fontRenderer.getStringWidth(displayText) / 2, 33, 4210752);
|
||||
|
||||
if (this.tileEntity.generateWatts <= 0)
|
||||
{
|
||||
displayText = "Not Generating";
|
||||
}
|
||||
else if (this.tileEntity.generateWatts < TileEntityCoalGenerator.MIN_GENERATE_WATTS)
|
||||
{
|
||||
displayText = "Hull Heat: " + (int) (this.tileEntity.generateWatts / TileEntityCoalGenerator.MIN_GENERATE_WATTS * 100) + "%";
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = ElectricityDisplay.getDisplay(tileEntity.generateWatts * 20, ElectricUnit.WATT);
|
||||
}
|
||||
|
||||
this.fontRenderer.drawString(displayText, 122 - this.fontRenderer.getStringWidth(displayText) / 2, 45, 4210752);
|
||||
displayText = "Voltage: " + (int) (this.tileEntity.getVoltage() * 1000);
|
||||
this.fontRenderer.drawString(displayText, 122 - this.fontRenderer.getStringWidth(displayText) / 2, 60, 4210752);
|
||||
this.fontRenderer.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 par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.func_110577_a(coalGeneratorTexture);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
}
|
||||
}
|
75
src/dark/core/client/GuiElectricFurnace.java
Normal file
75
src/dark/core/client/GuiElectricFurnace.java
Normal file
|
@ -0,0 +1,75 @@
|
|||
package dark.core.client;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import universalelectricity.core.electricity.ElectricityDisplay;
|
||||
import universalelectricity.core.electricity.ElectricityDisplay.ElectricUnit;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import dark.core.common.DarkMain;
|
||||
import dark.core.common.machines.ContainerElectricFurnace;
|
||||
import dark.core.common.machines.TileEntityElectricFurnace;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElectricFurnace extends GuiContainer
|
||||
{
|
||||
private static final ResourceLocation electricFurnaceTexture = new ResourceLocation(DarkMain.getInstance().DOMAIN,DarkMain.GUI_DIRECTORY+ "electric_furnace.png");
|
||||
|
||||
private TileEntityElectricFurnace tileEntity;
|
||||
|
||||
private int containerWidth;
|
||||
private int containerHeight;
|
||||
|
||||
public GuiElectricFurnace(InventoryPlayer par1InventoryPlayer, TileEntityElectricFurnace tileEntity)
|
||||
{
|
||||
super(new ContainerElectricFurnace(par1InventoryPlayer, tileEntity));
|
||||
this.tileEntity = tileEntity;
|
||||
}
|
||||
|
||||
/** Draw the foreground layer for the GuiContainer (everything in front of the items) */
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2)
|
||||
{
|
||||
this.fontRenderer.drawString(this.tileEntity.getInvName(), 45, 6, 4210752);
|
||||
this.fontRenderer.drawString("Smelting:", 10, 28, 4210752);
|
||||
this.fontRenderer.drawString("Battery:", 10, 53, 4210752);
|
||||
String displayText = "";
|
||||
|
||||
if (this.tileEntity.processTicks > 0)
|
||||
{
|
||||
displayText = "Smelting";
|
||||
}
|
||||
else
|
||||
{
|
||||
displayText = "Idle";
|
||||
}
|
||||
|
||||
this.fontRenderer.drawString("Status: " + displayText, 82, 45, 4210752);
|
||||
this.fontRenderer.drawString(ElectricityDisplay.getDisplay(tileEntity.WATTS_PER_TICK * 20, ElectricUnit.WATT), 82, 56, 4210752);
|
||||
this.fontRenderer.drawString("Voltage: " + (int) (this.tileEntity.getVoltage() * 1000), 82, 68, 4210752);
|
||||
this.fontRenderer.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 par2, int par3)
|
||||
{
|
||||
this.mc.renderEngine.func_110577_a(electricFurnaceTexture);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
containerWidth = (this.width - this.xSize) / 2;
|
||||
containerHeight = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(containerWidth, containerHeight, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
if (this.tileEntity.processTicks > 0)
|
||||
{
|
||||
int scale = (int) (((double) this.tileEntity.processTicks / (double) TileEntityElectricFurnace.PROCESS_TIME_REQUIRED) * 23);
|
||||
this.drawTexturedModalRect(containerWidth + 77, containerHeight + 24, 176, 0, 23 - scale, 20);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -2,11 +2,20 @@ package dark.core.common;
|
|||
|
||||
import java.awt.Color;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import universalelectricity.core.vector.Vector3;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import dark.core.common.machines.ContainerBatteryBox;
|
||||
import dark.core.common.machines.ContainerCoalGenerator;
|
||||
import dark.core.common.machines.ContainerElectricFurnace;
|
||||
import dark.core.common.machines.TileEntityBatteryBox;
|
||||
import dark.core.common.machines.TileEntityCoalGenerator;
|
||||
import dark.core.common.machines.TileEntityElectricFurnace;
|
||||
import dark.core.network.PacketManagerEffects;
|
||||
|
||||
public class CommonProxy
|
||||
public class CommonProxy implements IGuiHandler
|
||||
{
|
||||
public static final int GUI_COAL_GEN = 0, GUI_FUEL_GEN = 1, GUI_FURNACE_ELEC = 2, GUI_BATTERY_BOX = 3;
|
||||
|
||||
|
@ -29,7 +38,7 @@ public class CommonProxy
|
|||
}
|
||||
|
||||
/** Renders a laser beam from one power to another by a set color for a set time
|
||||
*
|
||||
*
|
||||
* @param world - world this laser is to be rendered in
|
||||
* @param position - start vector3
|
||||
* @param target - end vector3
|
||||
|
@ -40,4 +49,35 @@ public class CommonProxy
|
|||
PacketManagerEffects.sendClientLaserEffect(world, position, target, color, age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
if (tileEntity instanceof TileEntityBatteryBox)
|
||||
{
|
||||
return new ContainerBatteryBox(player.inventory, ((TileEntityBatteryBox) tileEntity));
|
||||
}
|
||||
else if (tileEntity instanceof TileEntityCoalGenerator)
|
||||
{
|
||||
return new ContainerCoalGenerator(player.inventory, ((TileEntityCoalGenerator) tileEntity));
|
||||
}
|
||||
else if (tileEntity instanceof TileEntityElectricFurnace)
|
||||
{
|
||||
return new ContainerElectricFurnace(player.inventory, ((TileEntityElectricFurnace) tileEntity));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
@ -30,6 +31,7 @@ import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
|||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLServerStoppingEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry;
|
||||
import dark.api.ProcessorRecipes;
|
||||
import dark.core.common.BlockRegistry.BlockData;
|
||||
import dark.core.common.blocks.BlockBasalt;
|
||||
|
@ -87,6 +89,7 @@ public class DarkMain extends ModPrefab
|
|||
public static boolean overPressureDamage;
|
||||
|
||||
public static BlockMulti blockMulti;
|
||||
public static Block basicMachine;
|
||||
|
||||
@Instance(MOD_ID)
|
||||
private static DarkMain instance;
|
||||
|
@ -114,9 +117,10 @@ public class DarkMain extends ModPrefab
|
|||
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
MinecraftForge.EVENT_BUS.register(new FluidHelper());
|
||||
|
||||
UniversalElectricity.initiate();
|
||||
Compatibility.initiate();
|
||||
|
||||
NetworkRegistry.instance().registerGuiHandler(this, proxy);
|
||||
proxy.preInit();
|
||||
}
|
||||
|
||||
|
|
111
src/dark/core/common/machines/ContainerBatteryBox.java
Normal file
111
src/dark/core/common/machines/ContainerBatteryBox.java
Normal file
|
@ -0,0 +1,111 @@
|
|||
package dark.core.common.machines;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.prefab.SlotSpecific;
|
||||
|
||||
public class ContainerBatteryBox extends Container
|
||||
{
|
||||
private TileEntityBatteryBox tileEntity;
|
||||
|
||||
public ContainerBatteryBox(InventoryPlayer par1InventoryPlayer, TileEntityBatteryBox batteryBox)
|
||||
{
|
||||
this.tileEntity = batteryBox;
|
||||
// Top slot for battery output
|
||||
this.addSlotToContainer(new SlotSpecific(batteryBox, 0, 33, 24, IItemElectric.class));
|
||||
// Bottom slot for batter input
|
||||
this.addSlotToContainer(new SlotSpecific(batteryBox, 1, 33, 48, IItemElectric.class));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int slotID)
|
||||
{
|
||||
ItemStack returnStack = null;
|
||||
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||||
|
||||
if (slot != null && slot.getHasStack())
|
||||
{
|
||||
ItemStack itemStack = slot.getStack();
|
||||
returnStack = itemStack.copy();
|
||||
|
||||
if (slotID != 0 && slotID != 1)
|
||||
{
|
||||
if (this.getSlot(0).isItemValid(itemStack))
|
||||
{
|
||||
if (((IItemElectric) itemStack.getItem()).getElectricityStored(itemStack) > 0)
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.mergeItemStack(itemStack, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if (slotID >= 30 && slotID < 38 && !this.mergeItemStack(itemStack, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(itemStack, 3, 38, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == 0)
|
||||
{
|
||||
slot.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
|
||||
if (itemStack.stackSize == returnStack.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
slot.onPickupFromSlot(par1EntityPlayer, itemStack);
|
||||
}
|
||||
|
||||
return returnStack;
|
||||
}
|
||||
}
|
97
src/dark/core/common/machines/ContainerCoalGenerator.java
Normal file
97
src/dark/core/common/machines/ContainerCoalGenerator.java
Normal file
|
@ -0,0 +1,97 @@
|
|||
package dark.core.common.machines;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class ContainerCoalGenerator extends Container
|
||||
{
|
||||
private TileEntityCoalGenerator tileEntity;
|
||||
|
||||
public ContainerCoalGenerator(InventoryPlayer par1InventoryPlayer, TileEntityCoalGenerator tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
|
||||
{
|
||||
ItemStack var2 = null;
|
||||
Slot var3 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (var3 != null && var3.getHasStack())
|
||||
{
|
||||
ItemStack var4 = var3.getStack();
|
||||
var2 = var4.copy();
|
||||
|
||||
if (par1 != 0)
|
||||
{
|
||||
if (var4.itemID == Item.coal.itemID)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 30 && par1 < 37 && !this.mergeItemStack(var4, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var4, 3, 37, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var4.stackSize == 0)
|
||||
{
|
||||
var3.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var3.onSlotChanged();
|
||||
}
|
||||
|
||||
if (var4.stackSize == var2.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onPickupFromSlot(par1EntityPlayer, var4);
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
}
|
130
src/dark/core/common/machines/ContainerElectricFurnace.java
Normal file
130
src/dark/core/common/machines/ContainerElectricFurnace.java
Normal file
|
@ -0,0 +1,130 @@
|
|||
package dark.core.common.machines;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.inventory.SlotFurnace;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import universalelectricity.core.item.IItemElectric;
|
||||
import universalelectricity.prefab.SlotSpecific;
|
||||
|
||||
public class ContainerElectricFurnace extends Container
|
||||
{
|
||||
private TileEntityElectricFurnace tileEntity;
|
||||
|
||||
public ContainerElectricFurnace(InventoryPlayer par1InventoryPlayer, TileEntityElectricFurnace tileEntity)
|
||||
{
|
||||
this.tileEntity = tileEntity;
|
||||
|
||||
// Electric Input Slot
|
||||
this.addSlotToContainer(new SlotSpecific(tileEntity, 0, 55, 49, IItemElectric.class));
|
||||
|
||||
// To be smelted
|
||||
this.addSlotToContainer(new Slot(tileEntity, 1, 55, 25));
|
||||
|
||||
// Smelting result
|
||||
this.addSlotToContainer(new SlotFurnace(par1InventoryPlayer.player, tileEntity, 2, 108, 25));
|
||||
int var3;
|
||||
|
||||
for (var3 = 0; var3 < 3; ++var3)
|
||||
{
|
||||
for (int var4 = 0; var4 < 9; ++var4)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (var3 = 0; var3 < 9; ++var3)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer entityplayer)
|
||||
{
|
||||
super.onContainerClosed(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
|
||||
{
|
||||
return this.tileEntity.isUseableByPlayer(par1EntityPlayer);
|
||||
}
|
||||
|
||||
/** Called to transfer a stack from one inventory to the other eg. when shift clicking. */
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par1)
|
||||
{
|
||||
ItemStack var2 = null;
|
||||
Slot var3 = (Slot) this.inventorySlots.get(par1);
|
||||
|
||||
if (var3 != null && var3.getHasStack())
|
||||
{
|
||||
ItemStack var4 = var3.getStack();
|
||||
var2 = var4.copy();
|
||||
|
||||
if (par1 == 2)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 3, 39, true))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onSlotChange(var4, var2);
|
||||
}
|
||||
else if (par1 != 1 && par1 != 0)
|
||||
{
|
||||
if (var4.getItem() instanceof IItemElectric)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 0, 1, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (FurnaceRecipes.smelting().getSmeltingResult(var4) != null)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 1, 2, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 3 && par1 < 30)
|
||||
{
|
||||
if (!this.mergeItemStack(var4, 30, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (par1 >= 30 && par1 < 39 && !this.mergeItemStack(var4, 3, 30, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else if (!this.mergeItemStack(var4, 3, 39, false))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (var4.stackSize == 0)
|
||||
{
|
||||
var3.putStack((ItemStack) null);
|
||||
}
|
||||
else
|
||||
{
|
||||
var3.onSlotChanged();
|
||||
}
|
||||
|
||||
if (var4.stackSize == var2.stackSize)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var3.onPickupFromSlot(par1EntityPlayer, var4);
|
||||
}
|
||||
|
||||
return var2;
|
||||
}
|
||||
}
|
|
@ -37,16 +37,16 @@ import dark.api.energy.IPowerLess;
|
|||
import dark.core.common.ExternalModHandler;
|
||||
|
||||
/** Basic energy tile that can consume power
|
||||
*
|
||||
*
|
||||
* Based off both UE universal electrical tile, and electrical tile prefabs
|
||||
*
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public class TileEntityEnergyMachine extends TileEntityMachine implements IElectrical, IElectricalStorage, IEnergySink, IEnergySource, IPowerReceptor, IPowerLess
|
||||
{
|
||||
/** Forge Ore Directory name of the item to toggle infinite power mode */
|
||||
public static String powerToggleItemID = "battery";
|
||||
|
||||
protected float WATTS_PER_TICK, MAX_WATTS, maxInputEnergy = 100, energyStored = 0;
|
||||
public float WATTS_PER_TICK, MAX_WATTS, maxInputEnergy = 100, energyStored = 0;
|
||||
protected boolean isAddedToEnergyNet, consumeEnergy = true;
|
||||
public PowerHandler bcPowerHandler;
|
||||
public Type bcBlockType = Type.MACHINE;
|
||||
|
@ -413,7 +413,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
|||
}
|
||||
|
||||
/** Produces UE power towards a specific direction.
|
||||
*
|
||||
*
|
||||
* @param outputDirection - The output direction. */
|
||||
public void produceUE(ForgeDirection outputDirection)
|
||||
{
|
||||
|
@ -442,7 +442,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
|||
}
|
||||
|
||||
/** The electrical input direction.
|
||||
*
|
||||
*
|
||||
* @return The direction that electricity is entered into the tile. Return null for no input. By
|
||||
* default you can accept power from all sides. */
|
||||
public EnumSet<ForgeDirection> getInputDirections()
|
||||
|
@ -451,7 +451,7 @@ public class TileEntityEnergyMachine extends TileEntityMachine implements IElect
|
|||
}
|
||||
|
||||
/** The electrical output direction.
|
||||
*
|
||||
*
|
||||
* @return The direction that electricity is output from the tile. Return null for no output. By
|
||||
* default it will return an empty EnumSet. */
|
||||
public EnumSet<ForgeDirection> getOutputDirections()
|
||||
|
|
Loading…
Reference in a new issue