stuff and things

This commit is contained in:
gigabit101 2016-03-21 15:30:32 +00:00
parent dfbc4045e6
commit 8f382f2239
5 changed files with 180 additions and 3 deletions

View file

@ -1,9 +1,12 @@
package techreborn.blocks.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.blocks.IRotationTexture;
import techreborn.Core;
import techreborn.client.GuiHandler;
import techreborn.client.TechRebornCreativeTab;
import techreborn.tiles.storage.TileBatBox;
@ -17,6 +20,13 @@ public class BlockBatBox extends BlockMachineBase implements IRotationTexture {
setUnlocalizedName("techreborn.batBox");
setCreativeTab(TechRebornCreativeTab.instance);
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
if (!player.isSneaking())
player.openGui(Core.INSTANCE, GuiHandler.batboxID, world, x, y, z);
return true;
}
@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {

View file

@ -12,6 +12,7 @@ import techreborn.tiles.fusionReactor.TileEntityFusionController;
import techreborn.tiles.generator.*;
import techreborn.tiles.idsu.TileIDSU;
import techreborn.tiles.lesu.TileLesu;
import techreborn.tiles.storage.TileBatBox;
import techreborn.tiles.teir1.*;
public class GuiHandler implements IGuiHandler {
@ -52,6 +53,8 @@ public class GuiHandler implements IGuiHandler {
public static final int ironFurnace = 36;
public static final int recyclerID = 37;
public static final int scrapboxinatorID = 38;
public static final int batboxID = 39;
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
@ -148,6 +151,8 @@ public class GuiHandler implements IGuiHandler {
return new ContainerRecycler((TileRecycler) world.getTileEntity(new BlockPos(x, y, z)), player);
}else if (ID == scrapboxinatorID) {
return new ContainerScrapboxinator((TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)), player);
}else if (ID == batboxID) {
return new ContainerBatbox((TileBatBox) world.getTileEntity(new BlockPos(x, y, z)), player);
}
return null;
}
@ -246,8 +251,10 @@ public class GuiHandler implements IGuiHandler {
return new GuiIronFurnace(player, (TileIronFurnace) world.getTileEntity(new BlockPos(x, y, z)));
}else if (ID == recyclerID) {
return new GuiRecycler(player, (TileRecycler) world.getTileEntity(new BlockPos(x, y, z)));
} else if (ID == scrapboxinatorID) {
}else if (ID == scrapboxinatorID) {
return new GuiScrapboxinator(player, (TileScrapboxinator) world.getTileEntity(new BlockPos(x, y, z)));
}else if (ID == batboxID) {
return new GuiBatbox(player, (TileBatBox) world.getTileEntity(new BlockPos(x, y, z)));
}
return null;
}

View file

@ -0,0 +1,98 @@
package techreborn.client.container;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnaceFuel;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.common.container.RebornContainer;
import techreborn.tiles.generator.TileGenerator;
import techreborn.tiles.storage.TileBatBox;
public class ContainerBatbox extends RebornContainer {
EntityPlayer player;
TileBatBox tile;
public int burnTime = 0;
public int totalBurnTime = 0;
public int energy;
@Override
public boolean canInteractWith(EntityPlayer player) {
return true;
}
public int tickTime;
public ContainerBatbox(TileBatBox tile, EntityPlayer player) {
super();
this.tile = tile;
this.player = player;
// fuel
// this.addSlotToContainer(new Slot(tile.inventory, 0, 80, 53));
// // charge
// this.addSlotToContainer(new SlotFurnaceFuel(tile.inventory, 1, 80, 17));
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));
}
}
// @Override
// public void detectAndSendChanges() {
// super.detectAndSendChanges();
// for (int i = 0; i < this.crafters.size(); i++) {
// ICrafting icrafting = (ICrafting) this.crafters.get(i);
// if (this.burnTime != tile.burnTime) {
// icrafting.sendProgressBarUpdate(this, 0, tile.burnTime);
// }
// if (this.totalBurnTime != tile.totalBurnTime) {
// icrafting.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
// }
// 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, 0, tile.burnTime);
// crafting.sendProgressBarUpdate(this, 1, tile.totalBurnTime);
// 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);
}
}

View file

@ -0,0 +1,63 @@
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.ContainerBatbox;
import techreborn.client.container.ContainerGenerator;
import techreborn.tiles.generator.TileGenerator;
import techreborn.tiles.storage.TileBatBox;
public class GuiBatbox extends GuiContainer {
public static final ResourceLocation texture = new ResourceLocation("techreborn", "textures/gui/batbox.png");
TileBatBox generator;
ContainerBatbox containerGenerator;
public GuiBatbox(EntityPlayer player, TileBatBox generator) {
super(new ContainerBatbox(generator, player));
this.xSize = 176;
this.ySize = 167;
this.generator = generator;
this.containerGenerator = (ContainerBatbox) 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.batbox.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]), 8, this.ySize - 96 + 2, 4210752);
// this.fontRendererObj.drawString(PowerSystem.getLocaliszedPower(containerGenerator.energy), 25, this.ySize- 150, 4210752);
}
}

View file

@ -2,7 +2,6 @@ package techreborn.parts;
import mcmultipart.MCMultiPartMod;
import mcmultipart.microblock.IMicroblock;
import mcmultipart.multipart.ICollidableMultipart;
import mcmultipart.multipart.IMultipartContainer;
import mcmultipart.multipart.INormallyOccludingPart;
import mcmultipart.multipart.ISlottedPart;
@ -54,7 +53,7 @@ import java.util.Map;
/**
* Created by modmuss50 on 02/03/2016.
*/
public abstract class CableMultipart extends Multipart implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType, ICollidableMultipart {
public abstract class CableMultipart extends Multipart implements INormallyOccludingPart, ISlottedPart, ITickable, ICableType {
public Vecs3dCube[] boundingBoxes = new Vecs3dCube[14];
public float center = 0.6F;