Started implementing a GUI for creating control panels
fixed the default value for euPerIf, closes #6
This commit is contained in:
parent
4bda8d458c
commit
ee827b46ef
|
@ -70,7 +70,7 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
deobfCompile "net.industrial-craft:industrialcraft-2:2.6.+"
|
||||
//deobfCompile "blusunrize:ImmersiveEngineering:0.10-+:deobf"
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.10-+:deobf"
|
||||
}
|
||||
|
||||
jar {
|
||||
|
|
|
@ -19,7 +19,9 @@ package malte0811.industrialWires;
|
|||
|
||||
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||
import malte0811.industrialWires.containers.ContainerRSPanelConn;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -39,6 +41,9 @@ public class CommonProxy implements IGuiHandler {
|
|||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new ContainerPanelCreator(player.inventory, (TileEntityPanelCreator)te);
|
||||
}
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new ContainerRSPanelConn((TileEntityRSPanelConn)te);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ public class IWConfig {
|
|||
|
||||
public static MechConversion mc = new MechConversion();
|
||||
public static class MechConversion {
|
||||
@Comment({"The amount of EU that would be produced by an ideal converter from 1 IF (default: 4)"})
|
||||
public static double euPerIf = 4;
|
||||
@Comment({"The amount of EU that would be produced by an ideal converter from 1 IF (default: 0.25)"})
|
||||
public static double euPerIf = .25;
|
||||
@Comment({"The amount of IC2 kinetic energy that an ideal converter produces from 1 EU"})
|
||||
public static double kinPerEu = 4;
|
||||
|
||||
|
|
|
@ -90,9 +90,13 @@ public class IndicatorLight extends PanelComponent {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
return null;
|
||||
if (aabb==null) {
|
||||
aabb = new AxisAlignedBB(x, 0, y, x+size, 0, y+size);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -73,9 +73,16 @@ public class Label extends PanelComponent {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
return null;
|
||||
if (aabb == null) {
|
||||
RawModelFontRenderer fr = fontRenderer();
|
||||
float width = fr.getStringWidth(text) * fr.scale;
|
||||
float height = fr.FONT_HEIGHT * fr.scale;
|
||||
aabb = new AxisAlignedBB(getX(), 0, getY(), getX() + width, 0, getY() + height);
|
||||
}
|
||||
return aabb;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -38,7 +38,6 @@ public class LightedButton extends PanelComponent {
|
|||
public boolean latching;
|
||||
public int rsOutputId;
|
||||
public int rsOutputChannel;
|
||||
private AxisAlignedBB aabb;
|
||||
private int ticksTillOff;
|
||||
private Set<BiConsumer<Integer, Byte>> rsOut = new HashSet<>();
|
||||
public LightedButton() {
|
||||
|
@ -97,6 +96,7 @@ public class LightedButton extends PanelComponent {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
|
|
|
@ -20,6 +20,8 @@ package malte0811.industrialWires.blocks.controlpanel;
|
|||
|
||||
import blusunrize.immersiveengineering.common.util.IELogger;
|
||||
import malte0811.industrialWires.client.RawQuad;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import net.minecraft.client.gui.Gui;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderGlobal;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
|
@ -38,6 +40,7 @@ import java.util.function.Supplier;
|
|||
|
||||
public abstract class PanelComponent {
|
||||
protected float panelHeight;
|
||||
protected AxisAlignedBB aabb = null;
|
||||
protected float x, y;
|
||||
private final String type;
|
||||
protected final static float[] gray = {.8F, .8F, .8F};
|
||||
|
@ -59,6 +62,7 @@ public abstract class PanelComponent {
|
|||
public abstract PanelComponent copyOf();
|
||||
|
||||
//well, only relative in the x/z directions
|
||||
@Nonnull
|
||||
public abstract AxisAlignedBB getBlockRelativeAABB();
|
||||
|
||||
public abstract boolean interactWith(Vec3d hitRelative, TileEntityPanel tile);
|
||||
|
@ -86,10 +90,12 @@ public abstract class PanelComponent {
|
|||
|
||||
public void setX(float x) {
|
||||
this.x = x;
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
public void setY(float y) {
|
||||
this.y = y;
|
||||
aabb = null;
|
||||
}
|
||||
|
||||
public void setPanelHeight(float panelHeight) {
|
||||
|
@ -132,6 +138,30 @@ public abstract class PanelComponent {
|
|||
GlStateManager.disableBlend();
|
||||
}
|
||||
|
||||
public void renderInGUI(GuiPanelCreator gui) {
|
||||
//TODO override in special components
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB();
|
||||
int left = (int) (gui.getX0()+aabb.minX*gui.panelSize);
|
||||
int top = (int) (gui.getY0()+aabb.minZ*gui.panelSize);
|
||||
int right = (int) (gui.getX0()+aabb.maxX*gui.panelSize);
|
||||
int bottom = (int) (gui.getY0()+aabb.maxZ*gui.panelSize);
|
||||
Gui.drawRect(left, top, right, bottom, 0xffffffff);
|
||||
}
|
||||
|
||||
public boolean isValidPos() {
|
||||
AxisAlignedBB aabb = getBlockRelativeAABB().offset(0, panelHeight, 0);
|
||||
if (aabb.minX<0||aabb.maxX>1) {
|
||||
return false;
|
||||
}
|
||||
if (aabb.minY<0||aabb.maxY>1) {
|
||||
return false;
|
||||
}
|
||||
if (aabb.minZ<0||aabb.maxZ>1) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
@ -110,7 +110,7 @@ public class Slider extends PanelComponent {
|
|||
return ret;
|
||||
}
|
||||
|
||||
private AxisAlignedBB aabb;
|
||||
@Nonnull
|
||||
@Override
|
||||
public AxisAlignedBB getBlockRelativeAABB() {
|
||||
if (aabb==null) {
|
||||
|
|
|
@ -235,7 +235,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
|
|||
Vec3d playerPos = Minecraft.getMinecraft().thePlayer.getPositionVector().addVector(-pos.getX(), player.getEyeHeight() - pos.getY(), -pos.getZ());
|
||||
for (PanelComponent pc : components) {
|
||||
AxisAlignedBB box = pc.getBlockRelativeAABB();
|
||||
if (box != null) {
|
||||
if (box.maxY>box.minY) {
|
||||
box = apply(mat, box.expandXyz(.002));
|
||||
Vec3d hitVec = hitAbs ? hit.addVector(-pos.getX(), -pos.getY(), -pos.getZ()) : hit;
|
||||
hitVec = hitVec.scale(2).subtract(playerPos);
|
||||
|
|
|
@ -22,16 +22,42 @@ import blusunrize.immersiveengineering.common.util.inventory.IIEInventory;
|
|||
import malte0811.industrialWires.blocks.TileEntityIWBase;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TileEntityPanelCreator extends TileEntityIWBase implements IIEInventory {
|
||||
@Override
|
||||
public void writeNBT(NBTTagCompound out, boolean updatePacket) {
|
||||
public List<PanelComponent> components = new ArrayList<>();
|
||||
public float height = 0.5F;
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
NBTTagList l = nbt.getTagList("components", 10);
|
||||
components.clear();
|
||||
for (int i = 0; i < l.tagCount(); i++) {
|
||||
PanelComponent pc = PanelComponent.read(l.getCompoundTagAt(i));
|
||||
if (pc != null) {
|
||||
components.add(pc);
|
||||
}
|
||||
}
|
||||
height = nbt.getFloat("height");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readNBT(NBTTagCompound in, boolean updatePacket) {
|
||||
public void writeNBT(NBTTagCompound nbt, boolean updatePacket) {
|
||||
writeToItemNBT(nbt, false);
|
||||
}
|
||||
|
||||
public void writeToItemNBT(NBTTagCompound nbt, boolean toItem) {
|
||||
NBTTagList comps = new NBTTagList();
|
||||
for (PanelComponent p : components) {
|
||||
NBTTagCompound nbtInner = new NBTTagCompound();
|
||||
p.writeToNBT(nbtInner, toItem);
|
||||
comps.appendTag(nbtInner);
|
||||
}
|
||||
nbt.setTag("components", comps);
|
||||
nbt.setFloat("height", height);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -53,4 +79,4 @@ public class TileEntityPanelCreator extends TileEntityIWBase implements IIEInven
|
|||
public void doGraphicalUpdates(int slot) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,6 +34,7 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -247,6 +248,11 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getConnectorWorld() {
|
||||
return worldObj;
|
||||
}
|
||||
|
||||
public int getRsId() {
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
|
|||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.GuiPanelCreator;
|
||||
import malte0811.industrialWires.client.gui.RSPanelConn;
|
||||
import malte0811.industrialWires.client.gui.GuiRSPanelConn;
|
||||
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
|
||||
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
|
@ -225,7 +225,7 @@ public class ClientProxy extends CommonProxy {
|
|||
public Gui getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
|
||||
TileEntity te = world.getTileEntity(new BlockPos(x, y, z));
|
||||
if (te instanceof TileEntityRSPanelConn) {
|
||||
return new RSPanelConn((TileEntityRSPanelConn)te);
|
||||
return new GuiRSPanelConn((TileEntityRSPanelConn)te);
|
||||
}
|
||||
if (te instanceof TileEntityPanelCreator) {
|
||||
return new GuiPanelCreator(player.inventory, (TileEntityPanelCreator) te);
|
||||
|
|
|
@ -18,29 +18,124 @@
|
|||
|
||||
package malte0811.industrialWires.client.gui;
|
||||
|
||||
import blusunrize.immersiveengineering.common.util.IELogger;
|
||||
import malte0811.industrialWires.blocks.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import malte0811.industrialWires.containers.ComponentFakeSlot;
|
||||
import malte0811.industrialWires.containers.ContainerPanelCreator;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.VertexBuffer;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiPanelCreator extends GuiContainer {
|
||||
private int heightWithoutInv = 130;
|
||||
public int panelSize = 128;
|
||||
private ContainerPanelCreator container;
|
||||
|
||||
public GuiPanelCreator(InventoryPlayer ip, TileEntityPanelCreator te) {
|
||||
super(new ContainerPanelCreator(ip, te));
|
||||
ySize=207;
|
||||
container = (ContainerPanelCreator) inventorySlots;
|
||||
ySize = 207;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
|
||||
int x0 = getX0();
|
||||
int y0 = getY0();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
mc.getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
TextureAtlasSprite sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite("minecraft:blocks/iron_block");
|
||||
drawTexturedRect(x0, x0 + panelSize, y0, y0 + panelSize, sprite.getMinU(), sprite.getMaxU(), sprite.getMinV(), sprite.getMaxV());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
|
||||
super.drawScreen(mouseX, mouseY, partialTicks);
|
||||
int x0 = getX0();
|
||||
int y0 = getY0();
|
||||
int xRel = mouseX - x0;
|
||||
int yRel = mouseY - y0;
|
||||
if (container.toPlace != null && 0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
|
||||
drawPanelComponent(container.toPlace, xRel, yRel);
|
||||
}
|
||||
for (PanelComponent pc:container.tile.components) {
|
||||
drawPanelComponent(pc, -1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
private void drawPanelComponent(PanelComponent pc, int x, int y) {
|
||||
if (x>=0&&y>=0) {
|
||||
pc.setX(x / (float) panelSize);
|
||||
pc.setY(y / (float) panelSize);
|
||||
}
|
||||
if (container.toPlace.isValidPos()) {
|
||||
GlStateManager.color(1, 1, 1);
|
||||
} else {
|
||||
GlStateManager.color(1, 0, 0);
|
||||
}
|
||||
pc.renderInGUI(this);
|
||||
GlStateManager.color(1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
private void drawTexturedRect(float xMin, float xMax, float yMin, float yMax, float uMin, float uMax, float vMin, float vMax) {
|
||||
Tessellator tes = Tessellator.getInstance();
|
||||
VertexBuffer buf = tes.getBuffer();
|
||||
buf.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
buf.pos(xMin, yMax, zLevel).tex(uMin, vMax).endVertex();
|
||||
buf.pos(xMax, yMax, zLevel).tex(uMax, vMax).endVertex();
|
||||
buf.pos(xMax, yMin, zLevel).tex(uMax, vMin).endVertex();
|
||||
buf.pos(xMin, yMin, zLevel).tex(uMin, vMin).endVertex();
|
||||
tes.draw();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawSlot(Slot slot) {
|
||||
if (slot instanceof ComponentFakeSlot && ((ComponentFakeSlot) slot).isSelected()) {
|
||||
drawRect(slot.xDisplayPosition, slot.yDisplayPosition, slot.xDisplayPosition + 16, slot.yDisplayPosition + 16, 0x8000ff00);
|
||||
}
|
||||
super.drawSlot(slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
int x0 = getX0();
|
||||
int y0 = getY0();
|
||||
int xRel = mouseX - x0;
|
||||
int yRel = mouseY - y0;
|
||||
if (container.toPlace != null && 0 <= xRel && xRel <= panelSize && 0 <= yRel && yRel <= panelSize) {
|
||||
IELogger.info("Place?");
|
||||
container.tile.components.add(container.toPlace.copyOf());//TODO tell the server
|
||||
}
|
||||
}
|
||||
|
||||
public int getX0() {
|
||||
return width / 2 - panelSize / 2;
|
||||
}
|
||||
|
||||
public int getY0() {
|
||||
return heightWithoutInv - panelSize;
|
||||
}
|
||||
|
||||
public int getGuiLeft() {
|
||||
return guiLeft;
|
||||
}
|
||||
|
||||
public int getGuiTop() {
|
||||
return guiTop;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,10 +28,10 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
public class RSPanelConn extends GuiScreen {
|
||||
public class GuiRSPanelConn extends GuiScreen {
|
||||
private TileEntityRSPanelConn te;
|
||||
private int curr = 0;
|
||||
public RSPanelConn(TileEntityRSPanelConn tile) {
|
||||
public GuiRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
te = tile;
|
||||
}
|
||||
@Override
|
|
@ -35,7 +35,7 @@ public class RawModelFontRenderer extends FontRenderer {
|
|||
float[] colorA = new float[4];
|
||||
private ImmutableList.Builder<RawQuad> builder = ImmutableList.builder();
|
||||
private final Vector3f normal = new Vector3f(0, 1, 0);
|
||||
private final float scale;
|
||||
public final float scale;
|
||||
|
||||
private TextureAtlasSprite sprite;
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2017 malte0811
|
||||
*
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialWires.blocks.controlpanel.PanelComponent;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ComponentFakeSlot extends Slot {
|
||||
private PanelComponent base;
|
||||
private boolean selected = false;
|
||||
public ComponentFakeSlot(IInventory inventoryIn, int index, int xPosition, int yPosition, PanelComponent pc) {
|
||||
super(inventoryIn, index, xPosition, yPosition);
|
||||
base = pc;
|
||||
putStack(new ItemStack(Blocks.DIAMOND_BLOCK));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer playerIn) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(@Nullable ItemStack stack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer playerIn, ItemStack stack) {
|
||||
super.onPickupFromSlot(playerIn, stack);
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the PanelComponent associated with this slot
|
||||
* @return the basic selected component (this instacne may be modified)
|
||||
*/
|
||||
public PanelComponent select() {
|
||||
selected = true;
|
||||
return base.copyOf();
|
||||
}
|
||||
|
||||
public void unselect() {
|
||||
selected = false;
|
||||
}
|
||||
|
||||
public boolean isSelected() {
|
||||
return selected;
|
||||
}
|
||||
}
|
|
@ -19,19 +19,52 @@
|
|||
package malte0811.industrialWires.containers;
|
||||
|
||||
import blusunrize.immersiveengineering.common.gui.ContainerIEBase;
|
||||
import malte0811.industrialWires.blocks.controlpanel.Label;
|
||||
import malte0811.industrialWires.blocks.controlpanel.LightedButton;
|
||||
import malte0811.industrialWires.blocks.controlpanel.PanelComponent;
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.ClickType;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
//TODO remove dependency on core IE
|
||||
public class ContainerPanelCreator extends ContainerIEBase<TileEntityPanelCreator> {
|
||||
public PanelComponent toPlace = null;
|
||||
public ContainerPanelCreator(InventoryPlayer inventoryPlayer, TileEntityPanelCreator tile) {
|
||||
super(inventoryPlayer, tile);
|
||||
slotCount = 4*9;
|
||||
int slotH = 130;
|
||||
slotCount = 38;
|
||||
addSlotToContainer(new ComponentFakeSlot(inventoryPlayer, 36, 0, 0, new LightedButton(0xff00, false, false, 0, 0)));
|
||||
addSlotToContainer(new ComponentFakeSlot(inventoryPlayer, 37, 0, 18, new Label("TEST", 0xff00)));
|
||||
for (int i = 0; i < 3; i++)
|
||||
for (int j = 0; j < 9; j++)
|
||||
addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, 126+i*18));
|
||||
addSlotToContainer(new Slot(inventoryPlayer, j+i*9+9, 8+j*18, slotH+i*18));
|
||||
for (int i = 0; i < 9; i++)
|
||||
addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, 184));
|
||||
addSlotToContainer(new Slot(inventoryPlayer, i, 8+i*18, slotH+58));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack slotClick(int id, int button, ClickType clickType, EntityPlayer player) {
|
||||
if (id >= 0) {
|
||||
Slot s = getSlot(id);
|
||||
if (s instanceof ComponentFakeSlot) {
|
||||
if (!((ComponentFakeSlot) s).isSelected()) {
|
||||
toPlace = ((ComponentFakeSlot) s).select();
|
||||
for (int i = 0; i < slotCount; i++) {
|
||||
Slot slot = getSlot(i);
|
||||
if (slot != s && slot instanceof ComponentFakeSlot) {
|
||||
((ComponentFakeSlot) slot).unselect();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
toPlace = null;
|
||||
((ComponentFakeSlot) s).unselect();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return super.slotClick(id, button, clickType, player);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,12 +18,17 @@
|
|||
|
||||
package malte0811.industrialWires.containers;
|
||||
|
||||
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class ContainerRSPanelConn extends Container {
|
||||
final TileEntityRSPanelConn te;
|
||||
public ContainerRSPanelConn(TileEntityRSPanelConn tile) {
|
||||
te = tile;
|
||||
}
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer playerIn) {
|
||||
return false;
|
||||
return playerIn.getDistanceSq(te.getPos())<64;
|
||||
}
|
||||
}
|
||||
|
|
1
src/main/resources/META-INF/IndustrialWires_at.cfg
Normal file
1
src/main/resources/META-INF/IndustrialWires_at.cfg
Normal file
|
@ -0,0 +1 @@
|
|||
protected net.minecraft.client.gui.inventory.GuiContainer func_146977_a(Lnet/minecraft/inventory/Slot;)V #drawSlot
|
Loading…
Reference in a new issue