Add MFE GUI and made batterys charge and decharge?
This commit is contained in:
parent
dd6af0d09b
commit
1993fa92bd
8 changed files with 237 additions and 11 deletions
|
@ -13,6 +13,7 @@ import techreborn.tiles.generator.*;
|
|||
import techreborn.tiles.idsu.TileIDSU;
|
||||
import techreborn.tiles.lesu.TileLesu;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
import techreborn.tiles.teir1.*;
|
||||
|
||||
|
@ -186,6 +187,8 @@ public class GuiHandler implements IGuiHandler
|
|||
return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
}else if (ID == mfsuID){
|
||||
return new ContainerMFSU((TileMFSU) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
}else if (ID == mfeID){
|
||||
return new ContainerMFE((TileMFE) world.getTileEntity(new BlockPos(x, y, z)), player);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -313,6 +316,10 @@ public class GuiHandler implements IGuiHandler
|
|||
{
|
||||
return new GuiMFSU(player, (TileMFSU) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
else if (ID == mfeID)
|
||||
{
|
||||
return new GuiMFE(player, (TileMFE) world.getTileEntity(new BlockPos(x, y, z)));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,22 +1,19 @@
|
|||
package techreborn.client;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.event.entity.player.ItemTooltipEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.Color;
|
||||
import techreborn.Core;
|
||||
|
||||
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||
|
||||
public class StackToolTipEvent
|
||||
{
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import net.minecraft.inventory.ICrafting;
|
|||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileBatBox;
|
||||
|
||||
|
@ -39,8 +40,8 @@ public class ContainerBatbox extends RebornContainer
|
|||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
// this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
// this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
115
src/main/java/techreborn/client/container/ContainerMFE.java
Normal file
115
src/main/java/techreborn/client/container/ContainerMFE.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
package techreborn.client.container;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||
import net.minecraft.inventory.ICrafting;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
|
||||
|
||||
public class ContainerMFE extends RebornContainer
|
||||
{
|
||||
|
||||
public int burnTime = 0;
|
||||
public int totalBurnTime = 0;
|
||||
public int energy;
|
||||
public int tickTime;
|
||||
EntityPlayer player;
|
||||
TileMFE tile;
|
||||
private static final EntityEquipmentSlot[] equipmentSlots = new EntityEquipmentSlot[] {EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
|
||||
public ContainerMFE(TileMFE tile, EntityPlayer player)
|
||||
{
|
||||
super();
|
||||
this.tile = tile;
|
||||
this.player = player;
|
||||
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < 9; ++i)
|
||||
{
|
||||
this.addSlotToContainer(new Slot(player.inventory, i, 8 + i * 18, 142));
|
||||
}
|
||||
for (int k = 0; k < 4; k++)
|
||||
{
|
||||
final EntityEquipmentSlot slot = equipmentSlots[k];
|
||||
addSlotToContainer(new Slot(player.inventory, player.inventory.getSizeInventory() - 2 - k, 44, 6 + k * 19)
|
||||
{
|
||||
@Override
|
||||
public int getSlotStackLimit() { return 1; }
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack)
|
||||
{
|
||||
return stack != null && stack.getItem().isValidArmor(stack, slot, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void detectAndSendChanges()
|
||||
{
|
||||
super.detectAndSendChanges();
|
||||
for (int i = 0; i < this.crafters.size(); i++)
|
||||
{
|
||||
ICrafting icrafting = (ICrafting) this.crafters.get(i);
|
||||
if (this.energy != (int) tile.getEnergy())
|
||||
{
|
||||
icrafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCraftGuiOpened(ICrafting crafting)
|
||||
{
|
||||
super.onCraftGuiOpened(crafting);
|
||||
crafting.sendProgressBarUpdate(this, 2, (int) tile.getEnergy());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void updateProgressBar(int id, int value)
|
||||
{
|
||||
if (id == 0)
|
||||
{
|
||||
this.burnTime = value;
|
||||
} else if (id == 1)
|
||||
{
|
||||
this.totalBurnTime = value;
|
||||
} else if (id == 2)
|
||||
{
|
||||
this.energy = value;
|
||||
}
|
||||
this.tile.setEnergy(energy);
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int i)
|
||||
{
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * i);
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import net.minecraft.inventory.Slot;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.client.gui.SlotCharge;
|
||||
import reborncore.common.container.RebornContainer;
|
||||
import techreborn.tiles.storage.TileMFSU;
|
||||
|
||||
|
@ -54,8 +55,8 @@ public class ContainerMFSU extends RebornContainer
|
|||
}
|
||||
});
|
||||
}
|
||||
// this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
// this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 0, 80, 17));
|
||||
this.addSlotToContainer(new SlotCharge(tile.inventory, 1, 80, 53));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
77
src/main/java/techreborn/client/gui/GUIMFE.java
Normal file
77
src/main/java/techreborn/client/gui/GUIMFE.java
Normal file
|
@ -0,0 +1,77 @@
|
|||
package techreborn.client.gui;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.translation.I18n;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.client.container.ContainerMFE;
|
||||
import techreborn.tiles.storage.TileMFE;
|
||||
|
||||
/**
|
||||
* Created by Rushmead
|
||||
*/
|
||||
public class GuiMFE extends GuiContainer
|
||||
{
|
||||
|
||||
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/mfe.png");
|
||||
|
||||
TileMFE generator;
|
||||
|
||||
ContainerMFE containerGenerator;
|
||||
|
||||
public GuiMFE(EntityPlayer player, TileMFE generator)
|
||||
{
|
||||
super(new ContainerMFE(generator, player));
|
||||
this.xSize = 176;
|
||||
this.ySize = 167;
|
||||
this.generator = generator;
|
||||
this.containerGenerator = (ContainerMFE) this.inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_)
|
||||
{
|
||||
this.mc.getTextureManager().bindTexture(texture);
|
||||
int k = (this.width - this.xSize) / 2;
|
||||
int l = (this.height - this.ySize) / 2;
|
||||
this.drawTexturedModalRect(k, l, 0, 0, this.xSize, this.ySize);
|
||||
|
||||
int j = 0;
|
||||
|
||||
j = generator.getEnergyScaled(24);
|
||||
if (j > 0)
|
||||
{
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
}
|
||||
//
|
||||
// if (containerGenerator.burnTime != 0)
|
||||
// {
|
||||
// j = containerGenerator.getScaledBurnTime(13);
|
||||
// this.drawTexturedModalRect(k + 80, l + 38 + 12 - j, 176, 30 - j, 14,
|
||||
// j + 1);
|
||||
// }
|
||||
}
|
||||
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_)
|
||||
{
|
||||
String name = I18n.translateToLocal("tile.techreborn.mfe.name");
|
||||
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6,
|
||||
4210752);
|
||||
|
||||
this.fontRendererObj.drawString(I18n.translateToLocalFormatted("container.inventory", new Object[0]), this.xSize - 60,
|
||||
this.ySize - 96 + 2, 4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(generator.getMaxPower()), 110, this.ySize - 150,
|
||||
4210752);
|
||||
this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 110, this.ySize - 160,
|
||||
4210752);
|
||||
}
|
||||
}
|
|
@ -44,7 +44,7 @@ public class GuiBatbox extends GuiContainer
|
|||
|
||||
int j = 0;
|
||||
|
||||
j = generator.getEnergyScaled(12);
|
||||
j = generator.getEnergyScaled(24);
|
||||
if (j > 0)
|
||||
{
|
||||
this.drawTexturedModalRect(k + 109, l + 21 + 12, 176, 0, j + 1, 16);
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
package techreborn.tiles.storage;
|
||||
|
||||
import ic2.api.tile.IWrenchable;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.common.powerSystem.PoweredItem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.init.ModBlocks;
|
||||
import ic2.api.tile.IWrenchable;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 14/03/2016.
|
||||
*/
|
||||
public class TileBatBox extends TilePowerAcceptor implements IWrenchable
|
||||
public class TileBatBox extends TilePowerAcceptor implements IWrenchable, ITickable
|
||||
{
|
||||
|
||||
public Inventory inventory = new Inventory(2, "TileBatBox", 64, this);
|
||||
|
@ -44,6 +47,31 @@ public class TileBatBox extends TilePowerAcceptor implements IWrenchable
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override public void updateEntity()
|
||||
{
|
||||
if(inventory.getStackInSlot(0) != null){
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) inventory.getStackInSlot(0).getItem();
|
||||
if(PoweredItem.getEnergy(stack) != PoweredItem.getMaxPower(stack)){
|
||||
if(canUseEnergy(item.getMaxTransfer(stack)))
|
||||
{
|
||||
useEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) + item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
}
|
||||
}if(inventory.getStackInSlot(1) != null){
|
||||
ItemStack stack = inventory.getStackInSlot(1);
|
||||
IEnergyItemInfo item = (IEnergyItemInfo) stack.getItem();
|
||||
if(item.canProvideEnergy(stack)){
|
||||
if(getEnergy() != getMaxPower())
|
||||
{
|
||||
addEnergy(item.getMaxTransfer(stack));
|
||||
PoweredItem.setEnergy(PoweredItem.getEnergy(stack) - item.getMaxTransfer(stack), stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getWrenchDropRate()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue