Added support for individual slot configuration
* start work on slot config * More slot work * More gui work for slot config * Remove old sided code * More slot work * More slot memes * Stuff seems to be working :) * Start work on auto input / output * Slot IO check boxes now work * Fix buttons at different screen resolutions * Improve close button * Gui polish * Fix multiblock hologram rendering * More fixes + changes * Cleanup + output fix
This commit is contained in:
parent
a59647a0b7
commit
cbcb465c97
61 changed files with 1396 additions and 641 deletions
|
@ -26,15 +26,19 @@ package techreborn.client.gui;
|
|||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import techreborn.client.gui.widget.GuiButtonPowerBar;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
|
@ -45,6 +49,7 @@ public class GuiBase extends GuiContainer {
|
|||
public TRBuilder builder = new TRBuilder();
|
||||
public TileEntity tile;
|
||||
public BuiltContainer container;
|
||||
public static boolean showSlotConfig = false;
|
||||
|
||||
public GuiBase(EntityPlayer player, TileEntity tile, BuiltContainer container) {
|
||||
super(container);
|
||||
|
@ -106,6 +111,7 @@ public class GuiBase extends GuiContainer {
|
|||
@Override
|
||||
public void initGui() {
|
||||
super.initGui();
|
||||
GuiSlotConfiguration.init(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,6 +127,8 @@ public class GuiBase extends GuiContainer {
|
|||
builder.drawUpgrades(this, upgradeable, guiLeft, guiTop);
|
||||
}
|
||||
}
|
||||
builder.drawSlotTab(this, guiLeft, guiTop, mouseX, mouseY);
|
||||
|
||||
}
|
||||
|
||||
public boolean drawPlayerSlots() {
|
||||
|
@ -135,6 +143,9 @@ public class GuiBase extends GuiContainer {
|
|||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) {
|
||||
drawTitle();
|
||||
if(showSlotConfig){
|
||||
GuiSlotConfiguration.draw(this, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -179,6 +190,54 @@ public class GuiBase extends GuiContainer {
|
|||
buttonList.add(new GuiButtonPowerBar(id, x + factorX, y + factorY, this, layer));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException {
|
||||
if(showSlotConfig){
|
||||
if(GuiSlotConfiguration.mouseClicked(mouseX, mouseY, mouseButton, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClickMove(int mouseX, int mouseY, int clickedMouseButton, long timeSinceLastClick) {
|
||||
if(showSlotConfig){
|
||||
GuiSlotConfiguration.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick, this);
|
||||
}
|
||||
super.mouseClickMove(mouseX, mouseY, clickedMouseButton, timeSinceLastClick);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseReleased(int mouseX, int mouseY, int state) {
|
||||
if(isPointInRegion(-26, 84, 30, 30, mouseX, mouseY)){
|
||||
showSlotConfig = !showSlotConfig;
|
||||
if(!showSlotConfig){
|
||||
GuiSlotConfiguration.reset();
|
||||
}
|
||||
}
|
||||
if(showSlotConfig){
|
||||
if(GuiSlotConfiguration.mouseReleased(mouseX, mouseY, state, this)){
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.mouseReleased(mouseX, mouseY, state);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed() {
|
||||
showSlotConfig = false;
|
||||
super.onGuiClosed();
|
||||
}
|
||||
|
||||
public boolean isPointInRect(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY) {
|
||||
return super.isPointInRegion(rectX, rectY, rectWidth, rectHeight, pointX, pointY);
|
||||
}
|
||||
|
||||
public TileLegacyMachineBase getMachine(){
|
||||
return (TileLegacyMachineBase) tile;
|
||||
}
|
||||
|
||||
//TODO
|
||||
public enum SlotRender {
|
||||
STANDARD, OUTPUT, NONE, SPRITE;
|
||||
|
|
|
@ -108,7 +108,7 @@ public class GuiBlastFurnace extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
|
@ -41,6 +39,8 @@ import techreborn.init.ModBlocks;
|
|||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileDistillationTower;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiDistillationTower extends GuiBase {
|
||||
|
||||
public TileDistillationTower tile;
|
||||
|
@ -105,7 +105,7 @@ public class GuiDistillationTower extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -107,7 +107,7 @@ public class GuiImplosionCompressor extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -111,7 +111,7 @@ public class GuiIndustrialGrinder extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -41,6 +39,8 @@ import techreborn.init.ModBlocks;
|
|||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileIndustrialSawmill;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiIndustrialSawmill extends GuiBase {
|
||||
|
||||
TileIndustrialSawmill tile;
|
||||
|
@ -110,7 +110,7 @@ public class GuiIndustrialSawmill extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
package techreborn.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -39,6 +37,8 @@ import techreborn.init.ModBlocks;
|
|||
import techreborn.proxies.ClientProxy;
|
||||
import techreborn.tiles.multiblock.TileVacuumFreezer;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class GuiVacuumFreezer extends GuiBase {
|
||||
|
||||
TileVacuumFreezer tile;
|
||||
|
@ -102,7 +102,7 @@ public class GuiVacuumFreezer extends GuiBase {
|
|||
@Override
|
||||
public void actionPerformed(final GuiButton button) throws IOException {
|
||||
super.actionPerformed(button);
|
||||
if (button.id == 212) {
|
||||
if (button.id == 212 && !GuiBase.showSlotConfig) {
|
||||
if (ClientProxy.multiblockRenderEvent.currentMultiblock == null) {
|
||||
{
|
||||
// This code here makes a basic multiblock and then sets to the selected one.
|
||||
|
|
|
@ -27,23 +27,30 @@ package techreborn.client.gui;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fml.client.config.GuiUtils;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import reborncore.api.tile.IUpgradeable;
|
||||
import reborncore.client.guibuilder.GuiBuilder;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.lib.ModInfo;
|
||||
import techreborn.proxies.ClientProxy;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.minecraft.item.ItemStack.EMPTY;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
*/
|
||||
|
@ -86,6 +93,9 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawProgressBar(GuiBase gui, int progress, int maxProgress, int x, int y, int mouseX, int mouseY, ProgressDirection direction, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
|
@ -189,6 +199,9 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawJEIButton(GuiBase gui, int x, int y, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
return;
|
||||
}
|
||||
if (Loader.isModLoaded("jei")) {
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
|
@ -200,6 +213,9 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawHologramButton(GuiBase gui, int x, int y, int mouseX, int mouseY, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
return;
|
||||
}
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
x += gui.getGuiLeft();
|
||||
y += gui.getGuiTop();
|
||||
|
@ -299,6 +315,9 @@ public class TRBuilder extends GuiBuilder {
|
|||
}
|
||||
|
||||
public void drawMultiblockMissingBar(GuiBase gui, GuiBase.Layer layer) {
|
||||
if(GuiBase.showSlotConfig){
|
||||
return;
|
||||
}
|
||||
int x = 0;
|
||||
int y = 4;
|
||||
if (layer == GuiBase.Layer.BACKGROUND) {
|
||||
|
@ -364,6 +383,32 @@ public class TRBuilder extends GuiBuilder {
|
|||
gui.drawTexturedModalRect(posX - 27, posY + 4, 126, 151, 30, 87);
|
||||
}
|
||||
|
||||
public void drawSlotTab(GuiScreen gui, int posX, int posY, int mouseX, int mouseY){
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX - 26, posY + 84, 157, 148, 30, 30);
|
||||
renderItemStack(new ItemStack(ModItems.WRENCH), posX - 19, posY + 92);
|
||||
if (isInRect(posX - 19, posY + 92, 12, 12, mouseX, mouseY)) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add("Configure slots");
|
||||
net.minecraftforge.fml.client.config.GuiUtils.drawHoveringText(list, mouseX, mouseY, gui.width, gui.height, -1, gui.mc.fontRenderer);
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public void renderItemStack(ItemStack stack, int x, int y) {
|
||||
if (stack != EMPTY) {
|
||||
GL11.glEnable(GL11.GL_BLEND);
|
||||
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(stack, x, y);
|
||||
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
|
||||
public void drawScrapSlot(GuiScreen gui, int posX, int posY) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GUI_SHEET);
|
||||
gui.drawTexturedModalRect(posX, posY, 150, 0, 18, 18);
|
||||
|
|
|
@ -0,0 +1,169 @@
|
|||
package techreborn.client.gui.slot;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraftforge.client.event.GuiScreenEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.elements.ConfigSlotElement;
|
||||
import techreborn.client.gui.slot.elements.ElementBase;
|
||||
import techreborn.client.gui.slot.elements.SlotType;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class GuiSlotConfiguration {
|
||||
|
||||
static HashMap<Integer, ConfigSlotElement> slotElementMap = new HashMap<>();
|
||||
|
||||
public static int slectedSlot = 0;
|
||||
|
||||
public static void reset() {
|
||||
slectedSlot = -1;
|
||||
}
|
||||
|
||||
public static void init(GuiBase guiBase) {
|
||||
reset();
|
||||
slotElementMap.clear();
|
||||
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
ConfigSlotElement slotElement = new ConfigSlotElement(guiBase.getMachine(), slot.getSlotIndex(), SlotType.NORMAL, slot.xPos - guiBase.guiLeft + 50, slot.yPos - guiBase.guiTop - 25, guiBase);
|
||||
slotElementMap.put(slot.getSlotIndex(), slotElement);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void draw(GuiBase guiBase, int mouseX, int mouseY) {
|
||||
BuiltContainer container = guiBase.container;
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
GlStateManager.color(255, 0, 0);
|
||||
Color color = new Color(255, 0, 0, 128);
|
||||
GuiUtil.drawGradientRect(slot.xPos - 1, slot.yPos - 1, 18, 18, color.getRGB(), color.getRGB());
|
||||
GlStateManager.color(255, 255, 255);
|
||||
}
|
||||
|
||||
if (slectedSlot != -1) {
|
||||
slotElementMap.get(slectedSlot).draw(guiBase);
|
||||
}
|
||||
}
|
||||
|
||||
public static List<ConfigSlotElement> getVisibleElements() {
|
||||
if(slectedSlot == -1){
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return slotElementMap.values().stream()
|
||||
.filter(configSlotElement -> configSlotElement.getId() == slectedSlot)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
//Allows closing of the widget with the escape key
|
||||
@SubscribeEvent
|
||||
public static void keyboardEvent(GuiScreenEvent.KeyboardInputEvent event){
|
||||
if(!getVisibleElements().isEmpty() && Keyboard.getEventKey() == Keyboard.KEY_ESCAPE){
|
||||
slectedSlot = -1;
|
||||
event.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean mouseClicked(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) throws IOException {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
for (ElementBase element : configSlotElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isPressing = true;
|
||||
boolean action = element.onStartPress(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isPressing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isPressing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BuiltContainer container = guiBase.container;
|
||||
|
||||
if(getVisibleElements().isEmpty()) {
|
||||
for (Slot slot : container.inventorySlots) {
|
||||
if (guiBase.tile != slot.inventory) {
|
||||
continue;
|
||||
}
|
||||
if (guiBase.isPointInRect(slot.xPos, slot.yPos, 18, 18, mouseX, mouseY)) {
|
||||
slectedSlot = slot.getSlotIndex();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return !getVisibleElements().isEmpty();
|
||||
}
|
||||
|
||||
public static void mouseClickMove(int mouseX, int mouseY, int mouseButton, long timeSinceLastClick, GuiBase guiBase) {
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
for (ElementBase element : configSlotElement.elements) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isDragging = true;
|
||||
boolean action = element.onDrag(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isDragging = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
break;
|
||||
} else {
|
||||
element.isDragging = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean mouseReleased(int mouseX, int mouseY, int mouseButton, GuiBase guiBase) {
|
||||
boolean clicked = false;
|
||||
if (mouseButton == 0) {
|
||||
for (ConfigSlotElement configSlotElement : getVisibleElements()) {
|
||||
if (configSlotElement.isInRect(guiBase, configSlotElement.x, configSlotElement.y, configSlotElement.getWidth(guiBase.getMachine()), configSlotElement.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
clicked = true;
|
||||
}
|
||||
for (ElementBase element : Lists.reverse(configSlotElement.elements)) {
|
||||
if (element.isInRect(guiBase, element.x, element.y, element.getWidth(guiBase.getMachine()), element.getHeight(guiBase.getMachine()), mouseX, mouseY)) {
|
||||
element.isReleasing = true;
|
||||
boolean action = element.onRelease(guiBase.getMachine(), guiBase, mouseX, mouseY);
|
||||
for (ElementBase e : getVisibleElements()) {
|
||||
if (e != element) {
|
||||
e.isReleasing = false;
|
||||
}
|
||||
}
|
||||
if (action)
|
||||
clicked = true;
|
||||
break;
|
||||
} else {
|
||||
element.isReleasing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return clicked;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
public class ButtonElement extends ElementBase {
|
||||
private Sprite.Button buttonSprite;
|
||||
|
||||
public ButtonElement(int x, int y, Sprite.Button buttonSprite) {
|
||||
super(x, y, buttonSprite.getNormal());
|
||||
this.buttonSprite = buttonSprite;
|
||||
this.addUpdateAction((gui, element) -> {
|
||||
if (isHovering) {
|
||||
element.container.setSprite(0, buttonSprite.getHovered());
|
||||
} else {
|
||||
element.container.setSprite(0, buttonSprite.getNormal());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
public class CheckBoxElement extends ElementBase {
|
||||
public String label, type;
|
||||
public int labelColor, slotID;
|
||||
TileLegacyMachineBase machineBase;
|
||||
|
||||
private Sprite.CheckBox checkBoxSprite;
|
||||
|
||||
public CheckBoxElement(String label, int labelColor, int x, int y, String type, int slotID, Sprite.CheckBox checkBoxSprite, TileLegacyMachineBase machineBase) {
|
||||
super(x, y, checkBoxSprite.getNormal());
|
||||
this.checkBoxSprite = checkBoxSprite;
|
||||
this.type = type;
|
||||
this.slotID = slotID;
|
||||
this.machineBase = machineBase;
|
||||
this.label = label;
|
||||
this.labelColor = labelColor;
|
||||
if (isTicked()) {
|
||||
container.setSprite(0, checkBoxSprite.getTicked());
|
||||
} else {
|
||||
container.setSprite(0, checkBoxSprite.getNormal());
|
||||
}
|
||||
this.addPressAction((element, gui, provider, mouseX, mouseY) -> {
|
||||
if (isTicked()) {
|
||||
element.container.setSprite(0, checkBoxSprite.getTicked());
|
||||
} else {
|
||||
element.container.setSprite(0, checkBoxSprite.getNormal());
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
// super.draw(gui);
|
||||
ISprite sprite = checkBoxSprite.getNormal();
|
||||
if(isTicked()){
|
||||
sprite = checkBoxSprite.getTicked();
|
||||
}
|
||||
drawSprite(gui, sprite, x, y );
|
||||
drawString(gui, label, x + checkBoxSprite.getNormal().width + 5, ((y + getHeight(gui.getMachine()) / 2) - (gui.mc.fontRenderer.FONT_HEIGHT / 2)), labelColor);
|
||||
}
|
||||
|
||||
public boolean isTicked() {
|
||||
if(type.equalsIgnoreCase("output")){
|
||||
return machineBase.slotConfiguration.getSlotDetails(slotID).autoOutput();
|
||||
}
|
||||
return machineBase.slotConfiguration.getSlotDetails(slotID).autoInput();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.RenderItem;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import reborncore.common.tile.SlotConfiguration;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConfigSlotElement extends ElementBase {
|
||||
SlotType type;
|
||||
IInventory inventory;
|
||||
int id;
|
||||
public List<ElementBase> elements = new ArrayList<>();
|
||||
|
||||
|
||||
public ConfigSlotElement(IInventory slotInventory, int slotId, SlotType type, int x, int y, GuiBase gui) {
|
||||
super(x, y, type.getButtonSprite());
|
||||
this.type = type;
|
||||
this.inventory = slotInventory;
|
||||
this.id = slotId;
|
||||
|
||||
SlotConfigPopupElement popupElement;
|
||||
|
||||
elements.add(popupElement = new SlotConfigPopupElement(this.id, x - 22, y - 22, this));
|
||||
elements.add(new ButtonElement(x + 37, y - 25, Sprite.EXIT_BUTTON).addReleaseAction((element, gui1, provider, mouseX, mouseY) -> {
|
||||
GuiSlotConfiguration.slectedSlot = -1;
|
||||
return true;
|
||||
}));
|
||||
|
||||
SlotConfiguration.SlotConfigHolder slotConfigHolder = gui.getMachine().slotConfiguration.getSlotDetails(id);
|
||||
|
||||
elements.add(new CheckBoxElement("Auto Input", 0xFFFFFFFF, x - 26, y + 42, "input", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine()).addPressAction((element, gui12, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "input", gui12);
|
||||
return true;
|
||||
}));
|
||||
elements.add(new CheckBoxElement("Auto Output", 0xFFFFFFFF, x - 26, y + 57,"output", slotId, Sprite.LIGHT_CHECK_BOX, gui.getMachine()).addPressAction((element, gui13, provider, mouseX, mouseY) -> {
|
||||
popupElement.updateCheckBox((CheckBoxElement) element, "output", gui13);
|
||||
return true;
|
||||
}));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
super.draw(gui);
|
||||
ItemStack stack = inventory.getStackInSlot(id);
|
||||
int xPos = x + 1 + gui.guiLeft;
|
||||
int yPos = y + 1 + gui.guiTop;
|
||||
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem renderItem = Minecraft.getMinecraft().getRenderItem();
|
||||
renderItem.renderItemAndEffectIntoGUI(gui.mc.player, stack, xPos, yPos);
|
||||
renderItem.renderItemOverlayIntoGUI(gui.mc.fontRenderer, stack, xPos, yPos, null);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
if (isHovering) {
|
||||
drawSprite(gui, type.getButtonHoverOverlay(), x, y);
|
||||
}
|
||||
elements.forEach(elementBase -> elementBase.draw(gui));
|
||||
}
|
||||
|
||||
public SlotType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,363 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraft.client.renderer.*;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import reborncore.client.guibuilder.GuiBuilder;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ElementBase {
|
||||
|
||||
public int x;
|
||||
public int y;
|
||||
public boolean isHovering = false;
|
||||
public boolean isDragging = false;
|
||||
public boolean isPressing = false;
|
||||
public boolean isReleasing = false;
|
||||
public boolean startPressLast = false;
|
||||
public boolean isHoveringLast = false;
|
||||
public boolean isDraggingLast = false;
|
||||
public boolean isPressingLast = false;
|
||||
public boolean isReleasingLast = false;
|
||||
public List<ElementBase.Action> hoverActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> dragActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> startPressActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> pressActions = new ArrayList<>();
|
||||
public List<ElementBase.Action> releaseActions = new ArrayList<>();
|
||||
public SpriteContainer container;
|
||||
public List<UpdateAction> updateActions = new ArrayList<>();
|
||||
public List<UpdateAction> buttonUpdate = new ArrayList<>();
|
||||
private int width;
|
||||
private int height;
|
||||
|
||||
public static final ResourceLocation MECH_ELEMENTS = new ResourceLocation(ModInfo.MOD_ID, "textures/gui/elements.png");
|
||||
|
||||
public ElementBase(int x, int y, SpriteContainer container) {
|
||||
this.container = container;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, ISprite... sprites) {
|
||||
this.container = new SpriteContainer();
|
||||
for (ISprite sprite : sprites) {
|
||||
container.addSprite(sprite);
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height) {
|
||||
this.container = new SpriteContainer();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height, SpriteContainer container) {
|
||||
this.container = container;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public ElementBase(int x, int y, int width, int height, ISprite... sprites) {
|
||||
this.container = new SpriteContainer();
|
||||
for (ISprite sprite : sprites) {
|
||||
container.addSprite(sprite);
|
||||
}
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
public SpriteContainer getSpriteContainer() {
|
||||
return container;
|
||||
}
|
||||
|
||||
public void adjustDimensions(TileLegacyMachineBase provider) {
|
||||
if (container.offsetSprites != null) {
|
||||
for (OffsetSprite offsetSprite : container.offsetSprites) {
|
||||
if (offsetSprite.getSprite().getSprite(provider).width + offsetSprite.getOffsetX(provider) > this.width) {
|
||||
this.width = offsetSprite.getSprite().getSprite(provider).width + offsetSprite.getOffsetX(provider);
|
||||
}
|
||||
if (offsetSprite.getSprite().getSprite(provider).height + offsetSprite.getOffsetY(provider) > this.height) {
|
||||
this.height = offsetSprite.getSprite().getSprite(provider).height + offsetSprite.getOffsetY(provider);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void draw(GuiBase gui) {
|
||||
for (OffsetSprite sprite : getSpriteContainer().offsetSprites) {
|
||||
drawSprite(gui, sprite.getSprite(), x + sprite.getOffsetX(gui.getMachine()), y + sprite.getOffsetY(gui.getMachine()));
|
||||
}
|
||||
}
|
||||
|
||||
public void renderUpdate(GuiBase gui) {
|
||||
isHoveringLast = isHovering;
|
||||
isPressingLast = isPressing;
|
||||
isDraggingLast = isDragging;
|
||||
isReleasingLast = isReleasing;
|
||||
}
|
||||
|
||||
public void update(GuiBase gui) {
|
||||
for (UpdateAction action : updateActions) {
|
||||
action.update(gui, this);
|
||||
}
|
||||
}
|
||||
|
||||
public ElementBase addUpdateAction(UpdateAction action) {
|
||||
updateActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase setWidth(int width) {
|
||||
this.width = width;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase setHeight(int height) {
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public ElementBase setX(int x) {
|
||||
this.x = x;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public ElementBase setY(int y) {
|
||||
this.y = y;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getWidth(TileLegacyMachineBase provider) {
|
||||
adjustDimensions(provider);
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight(TileLegacyMachineBase provider) {
|
||||
adjustDimensions(provider);
|
||||
return height;
|
||||
}
|
||||
|
||||
public ElementBase addHoverAction(ElementBase.Action action) {
|
||||
this.hoverActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addDragAction(ElementBase.Action action) {
|
||||
this.dragActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addStartPressAction(ElementBase.Action action) {
|
||||
this.startPressActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addPressAction(ElementBase.Action action) {
|
||||
this.pressActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ElementBase addReleaseAction(ElementBase.Action action) {
|
||||
this.releaseActions.add(action);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean onHover(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : hoverActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !hoverActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onDrag(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : dragActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !dragActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onStartPress(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : startPressActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
return !startPressActions.isEmpty();
|
||||
}
|
||||
|
||||
public boolean onRelease(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
for (ElementBase.Action action : releaseActions) {
|
||||
if(action.execute(this, gui, provider, mouseX, mouseY)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isPressing) {
|
||||
for (ElementBase.Action action : pressActions) {
|
||||
action.execute(this, gui, provider, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
return !releaseActions.isEmpty() || !pressActions.isEmpty();
|
||||
}
|
||||
|
||||
public interface Action {
|
||||
boolean execute(ElementBase element, GuiBase gui, TileLegacyMachineBase provider, int mouseX, int mouseY);
|
||||
}
|
||||
|
||||
public interface UpdateAction {
|
||||
void update(GuiBase gui, ElementBase element);
|
||||
}
|
||||
|
||||
public void drawRect(GuiBase gui, int x, int y, int width, int height, int colour) {
|
||||
drawGradientRect(gui, x, y, width, height, colour, colour);
|
||||
}
|
||||
|
||||
/*
|
||||
Taken from Gui
|
||||
*/
|
||||
public void drawGradientRect(GuiBase gui, int x, int y, int width, int height, int startColor, int endColor) {
|
||||
x = adjustX(gui, x);
|
||||
y = adjustY(gui, y);
|
||||
|
||||
int left = x;
|
||||
int top = y;
|
||||
int right = x + width;
|
||||
int bottom = y + height;
|
||||
float f = (float) (startColor >> 24 & 255) / 255.0F;
|
||||
float f1 = (float) (startColor >> 16 & 255) / 255.0F;
|
||||
float f2 = (float) (startColor >> 8 & 255) / 255.0F;
|
||||
float f3 = (float) (startColor & 255) / 255.0F;
|
||||
float f4 = (float) (endColor >> 24 & 255) / 255.0F;
|
||||
float f5 = (float) (endColor >> 16 & 255) / 255.0F;
|
||||
float f6 = (float) (endColor >> 8 & 255) / 255.0F;
|
||||
float f7 = (float) (endColor & 255) / 255.0F;
|
||||
GlStateManager.disableTexture2D();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.disableAlpha();
|
||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
||||
GlStateManager.shadeModel(7425);
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
BufferBuilder vertexbuffer = tessellator.getBuffer();
|
||||
vertexbuffer.begin(7, DefaultVertexFormats.POSITION_COLOR);
|
||||
vertexbuffer.pos((double) right, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
|
||||
vertexbuffer.pos((double) left, (double) top, (double) 0).color(f1, f2, f3, f).endVertex();
|
||||
vertexbuffer.pos((double) left, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
|
||||
vertexbuffer.pos((double) right, (double) bottom, (double) 0).color(f5, f6, f7, f4).endVertex();
|
||||
tessellator.draw();
|
||||
GlStateManager.shadeModel(7424);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableAlpha();
|
||||
GlStateManager.enableTexture2D();
|
||||
}
|
||||
|
||||
public int adjustX(GuiBase gui, int x) {
|
||||
return gui.guiLeft + x;
|
||||
}
|
||||
|
||||
public int adjustY(GuiBase gui, int y) {
|
||||
return gui.guiTop + y;
|
||||
}
|
||||
|
||||
public boolean isInRect(GuiBase gui, int x, int y, int xSize, int ySize, int mouseX, int mouseY) {
|
||||
return gui.isPointInRect(x + gui.guiLeft, y + gui.guiTop, xSize, ySize, mouseX, mouseY);
|
||||
}
|
||||
|
||||
public void drawString(GuiBase gui, String string, int x, int y, int color) {
|
||||
x = adjustX(gui, x);
|
||||
y = adjustY(gui, y);
|
||||
gui.mc.fontRenderer.drawString(string, x, y, color);
|
||||
}
|
||||
|
||||
public void drawString(GuiBase gui, String string, int x, int y) {
|
||||
drawString(gui, string, x, y, 16777215);
|
||||
}
|
||||
|
||||
public void setTextureSheet(ResourceLocation textureLocation) {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(textureLocation);
|
||||
}
|
||||
|
||||
public void drawCenteredString(GuiBase gui, String string, int y, int colour) {
|
||||
drawString(gui, string, (gui.getXSize() / 2 - gui.mc.fontRenderer.getStringWidth(string) / 2), y, colour);
|
||||
}
|
||||
|
||||
public void drawCenteredString(GuiBase gui, String string, int x, int y, int colour) {
|
||||
drawString(gui, string, (x - gui.mc.fontRenderer.getStringWidth(string) / 2), y, colour);
|
||||
}
|
||||
|
||||
public int getStringWidth(String string) {
|
||||
return Minecraft.getMinecraft().fontRenderer.getStringWidth(string);
|
||||
}
|
||||
|
||||
public void drawSprite(GuiBase gui, ISprite iSprite, int x, int y) {
|
||||
Sprite sprite = iSprite.getSprite(gui.getMachine());
|
||||
if (sprite != null) {
|
||||
if (sprite.hasTextureInfo()) {
|
||||
GlStateManager.color(1F, 1F, 1F);
|
||||
setTextureSheet(sprite.textureLocation);
|
||||
gui.drawTexturedModalRect(x + gui.guiLeft, y + gui.guiTop, sprite.x, sprite.y, sprite.width, sprite.height);
|
||||
}
|
||||
if (sprite.hasStack()) {
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
|
||||
RenderItem itemRenderer = Minecraft.getMinecraft().getRenderItem();
|
||||
itemRenderer.renderItemAndEffectIntoGUI(sprite.itemStack, x + gui.guiLeft, y + gui.guiTop);
|
||||
|
||||
GlStateManager.disableLighting();
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getScaledBurnTime(int scale, int burnTime, int totalBurnTime) {
|
||||
return (int) (((float) burnTime / (float) totalBurnTime) * scale);
|
||||
}
|
||||
|
||||
public TextFormatting getPercentageColour(int percentage) {
|
||||
if (percentage <= 10) {
|
||||
return TextFormatting.RED;
|
||||
} else if (percentage >= 75) {
|
||||
return TextFormatting.GREEN;
|
||||
} else {
|
||||
return TextFormatting.YELLOW;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPercentage(int MaxValue, int CurrentValue) {
|
||||
if (CurrentValue == 0)
|
||||
return 0;
|
||||
return (int) ((CurrentValue * 100.0f) / MaxValue);
|
||||
}
|
||||
|
||||
public void drawDefaultBackground(GuiScreen gui, int x, int y, int width, int height) {
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(GuiBuilder.defaultTextureSheet);
|
||||
gui.drawTexturedModalRect(x, y, 0, 0, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x + width / 2, y, 150 - width / 2, 0, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x, y + height / 2, 0, 150 - height / 2, width / 2, height / 2);
|
||||
gui.drawTexturedModalRect(x + width / 2, y + height / 2, 150 - width / 2, 150 - height / 2, width / 2, height / 2);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public interface ISprite {
|
||||
Sprite getSprite(TileLegacyMachineBase provider);
|
||||
}
|
21
src/main/java/techreborn/client/gui/slot/elements/LICENSE
Normal file
21
src/main/java/techreborn/client/gui/slot/elements/LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2017 Prospector
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -0,0 +1,45 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public class OffsetSprite {
|
||||
public ISprite sprite;
|
||||
public int offsetX = 0;
|
||||
public int offsetY = 0;
|
||||
|
||||
public OffsetSprite(ISprite sprite, int offsetX, int offsetY) {
|
||||
this.sprite = sprite;
|
||||
this.offsetX = offsetX;
|
||||
this.offsetY = offsetY;
|
||||
}
|
||||
|
||||
public OffsetSprite(ISprite sprite) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public OffsetSprite(Sprite sprite, TileLegacyMachineBase provider) {
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public ISprite getSprite() {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public int getOffsetX(TileLegacyMachineBase provider) {
|
||||
return offsetX + sprite.getSprite(provider).offsetX;
|
||||
}
|
||||
|
||||
public OffsetSprite setOffsetX(int offsetX) {
|
||||
this.offsetX = offsetX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getOffsetY(TileLegacyMachineBase provider) {
|
||||
return offsetY + sprite.getSprite(provider).offsetY;
|
||||
}
|
||||
|
||||
public OffsetSprite setOffsetY(int offsetY) {
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
All code in this class was taken with permssion from https://github.com/ProfessorProspector/Mechanical-Construct
|
||||
|
||||
A large ammount of modifications have taken place to allow it to work with techreborn.
|
|
@ -0,0 +1,194 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.BlockRendererDispatcher;
|
||||
import net.minecraft.client.renderer.GlStateManager;
|
||||
import net.minecraft.client.renderer.block.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.fml.client.FMLClientHandler;
|
||||
import reborncore.RebornCore;
|
||||
import reborncore.client.gui.GuiUtil;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.network.packet.PacketIOSave;
|
||||
import reborncore.common.network.packet.PacketSlotSave;
|
||||
import reborncore.common.tile.SlotConfiguration;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.MachineFacing;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class SlotConfigPopupElement extends ElementBase {
|
||||
int id;
|
||||
|
||||
ConfigSlotElement slotElement;
|
||||
|
||||
|
||||
public SlotConfigPopupElement(int slotId, int x, int y, ConfigSlotElement slotElement) {
|
||||
super(x, y, Sprite.SLOT_CONFIG_POPUP);
|
||||
this.id = slotId;
|
||||
this.slotElement = slotElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GuiBase gui) {
|
||||
drawDefaultBackground(gui, adjustX(gui, getX() -8), adjustY(gui, getY() - 7), 84, 105);
|
||||
super.draw(gui);
|
||||
|
||||
TileLegacyMachineBase machine = ((TileLegacyMachineBase) gui.tile);
|
||||
IBlockAccess blockAccess = machine.getWorld();
|
||||
BlockPos pos = machine.getPos();
|
||||
IBlockState state = blockAccess.getBlockState(pos);
|
||||
IBlockState actualState = Blocks.DIRT.getDefaultState().getActualState(blockAccess, pos);
|
||||
BlockRendererDispatcher dispatcher = FMLClientHandler.instance().getClient().getBlockRendererDispatcher();
|
||||
IBakedModel model = dispatcher.getBlockModelShapes().getModelForState(state.withProperty(BlockMachineBase.FACING, EnumFacing.NORTH));
|
||||
FMLClientHandler.instance().getClient().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 4, 23); //left
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, -12, -90F, 1F, 0F, 0F); //top
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 23, -90F, 0F, 1F, 0F); //centre
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 23, 42, 90F, 1F, 0F, 0F); //bottom
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 23, 180F, 0F, 1F, 0F); //right
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, 26, 42, 90F, 0F, 1F, 0F); //back
|
||||
|
||||
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.UP.getFacing(machine), id, 22, -1, gui);
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.FRONT.getFacing(machine), id, 22, 18, gui);
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.DOWN.getFacing(machine), id, 22, 37, gui);
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.RIGHT.getFacing(machine), id, 41, 18, gui);
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.BACK.getFacing(machine), id, 41, 37, gui);
|
||||
drawSlotSateColor(gui.getMachine(), MachineFacing.LEFT.getFacing(machine), id, 3, 18, gui);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onRelease(TileLegacyMachineBase provider, GuiBase gui, int mouseX, int mouseY) {
|
||||
if(isInBox(23 , 4, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.UP.getFacing(provider), gui);
|
||||
} else if(isInBox(23 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.FRONT.getFacing(provider), gui);
|
||||
} else if(isInBox(42 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.RIGHT.getFacing(provider), gui);
|
||||
} else if(isInBox(4 , 23, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.LEFT.getFacing(provider), gui);
|
||||
} else if(isInBox(23 , 42, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.DOWN.getFacing(provider), gui);
|
||||
} else if(isInBox(42 , 42, 16, 16, mouseX, mouseY, gui)){
|
||||
cyleSlotConfig(MachineFacing.BACK.getFacing(provider), gui);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void cyleSlotConfig(EnumFacing side, GuiBase guiBase){
|
||||
SlotConfiguration.SlotConfig currentSlot = guiBase.getMachine().slotConfiguration.getSlotDetails(id).getSideDetail(side);
|
||||
|
||||
SlotConfiguration.SlotIO slotIO = new SlotConfiguration.SlotIO(currentSlot.getSlotIO().getIoConfig().getNext());
|
||||
SlotConfiguration.SlotConfig newConfig = new SlotConfiguration.SlotConfig(side, slotIO, id);
|
||||
PacketSlotSave packetSlotSave = new PacketSlotSave(guiBase.tile.getPos(), newConfig);
|
||||
NetworkManager.sendToServer(packetSlotSave);
|
||||
}
|
||||
|
||||
public void updateCheckBox(CheckBoxElement checkBoxElement, String type, GuiBase guiBase){
|
||||
SlotConfiguration.SlotConfigHolder configHolder = guiBase.getMachine().slotConfiguration.getSlotDetails(id);
|
||||
boolean input = configHolder.autoInput();
|
||||
boolean output = configHolder.autoOutput();
|
||||
if(type.equalsIgnoreCase("input")){
|
||||
input = !configHolder.autoInput();
|
||||
}
|
||||
if(type.equalsIgnoreCase("output")){
|
||||
output = !configHolder.autoOutput();
|
||||
}
|
||||
|
||||
PacketIOSave packetSlotSave = new PacketIOSave(guiBase.tile.getPos(), id, input, output);
|
||||
NetworkManager.sendToServer(packetSlotSave);
|
||||
}
|
||||
|
||||
private void drawSlotSateColor(TileLegacyMachineBase machineBase, EnumFacing side, int slotID, int inx, int iny, GuiBase gui){
|
||||
iny += 4;
|
||||
int sx = inx + getX() + gui.guiLeft;
|
||||
int sy = iny + getY() + gui.guiTop;
|
||||
SlotConfiguration.SlotConfigHolder slotConfigHolder = machineBase.slotConfiguration.getSlotDetails(slotID);
|
||||
if(slotConfigHolder == null){
|
||||
RebornCore.logHelper.debug("Humm, this isnt suppoed to happen");
|
||||
return;
|
||||
}
|
||||
SlotConfiguration.SlotConfig slotConfig = slotConfigHolder.getSideDetail(side);
|
||||
Color color;
|
||||
switch (slotConfig.getSlotIO().getIoConfig()){
|
||||
case NONE:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
case INPUT:
|
||||
color = new Color(0, 0, 255, 128);
|
||||
break;
|
||||
case OUTPUT:
|
||||
color = new Color(255, 69, 0, 128);
|
||||
break;
|
||||
default:
|
||||
color = new Color(0, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
GlStateManager.color(255, 255, 255);
|
||||
GuiUtil.drawGradientRect(sx, sy, 18, 18, color.getRGB(), color.getRGB());
|
||||
GlStateManager.color(255, 255, 255);
|
||||
|
||||
}
|
||||
|
||||
private boolean isInBox(int rectX, int rectY, int rectWidth, int rectHeight, int pointX, int pointY, GuiBase guiBase){
|
||||
rectX += getX();
|
||||
rectY += getY();
|
||||
if(true){
|
||||
return isInRect(guiBase, rectX, rectY, rectWidth, rectHeight, pointX, pointY);
|
||||
}
|
||||
return (pointX - guiBase.getGuiLeft()) >= rectX - 1 && (pointX - guiBase.getGuiLeft()) < rectX + rectWidth + 1 && (pointY - guiBase.getGuiTop()) >= rectY - 1 && (pointY - guiBase.getGuiTop()) < rectY + rectHeight + 1;
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui,
|
||||
IBlockAccess blockAccess,
|
||||
IBakedModel model,
|
||||
IBlockState actualState,
|
||||
BlockPos pos,
|
||||
BlockRendererDispatcher dispatcher,
|
||||
int x,
|
||||
int y,
|
||||
float rotAngle,
|
||||
float rotX,
|
||||
float rotY,
|
||||
float rotZ) {
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
GlStateManager.translate(8 + gui.guiLeft + this.x + x, 8 + gui.guiTop + this.y + y, 512);
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(0.5F, 0.5F, 0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
dispatcher.getBlockModelRenderer().renderModelBrightness(model, actualState, 1F, false);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();
|
||||
|
||||
/* GlStateManager.pushMatrix();
|
||||
GlStateManager.enableDepth();
|
||||
// GlStateManager.translate(8 + gui.xFactor + this.x + x, 8 + gui.yFactor + this.y + y, 1000);
|
||||
GlStateManager.translate(gui.xFactor + this.x + x, gui.yFactor + this.y + y, 512);
|
||||
if (rotAngle != 0) {
|
||||
GlStateManager.rotate(rotAngle, rotX, rotY, rotZ);
|
||||
}
|
||||
GlStateManager.scale(16F, 16F, 16F);
|
||||
GlStateManager.translate(-0.5F, -0.5F, -0.5F);
|
||||
GlStateManager.scale(-1, -1, -1);
|
||||
GlStateManager.disableDepth();
|
||||
GlStateManager.popMatrix();*/
|
||||
}
|
||||
|
||||
public void drawState(GuiBase gui, IBlockAccess blockAccess, IBakedModel model, IBlockState actualState, BlockPos pos, BlockRendererDispatcher dispatcher, int x, int y) {
|
||||
drawState(gui, blockAccess, model, actualState, pos, dispatcher, x, y, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraftforge.items.ItemStackHandler;
|
||||
|
||||
public class SlotElement extends ElementBase {
|
||||
protected ItemStackHandler slotInventory;
|
||||
protected SlotType type;
|
||||
int slotId, slotX, slotY;
|
||||
|
||||
public SlotElement(ItemStackHandler slotInventory, int slotId, int slotX, int slotY, SlotType type, int x, int y) {
|
||||
super(x, y, type.getSprite());
|
||||
this.type = type;
|
||||
this.slotInventory = slotInventory;
|
||||
this.slotId = slotId;
|
||||
this.slotX = slotX;
|
||||
this.slotY = slotY;
|
||||
}
|
||||
|
||||
public SlotType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ItemStackHandler getSlotInventory() {
|
||||
return slotInventory;
|
||||
}
|
||||
|
||||
public int getSlotId() {
|
||||
return slotId;
|
||||
}
|
||||
|
||||
public int getSlotX() {
|
||||
return slotX;
|
||||
}
|
||||
|
||||
public int getSlotY() {
|
||||
return slotY;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
public enum SlotType {
|
||||
NORMAL(1, 1, Sprite.SLOT_NORMAL, Sprite.BUTTON_SLOT_NORMAL, Sprite.BUTTON_HOVER_OVERLAY_SLOT_NORMAL);
|
||||
|
||||
int slotOffsetX;
|
||||
int slotOffsetY;
|
||||
Sprite sprite;
|
||||
Sprite buttonSprite;
|
||||
Sprite buttonHoverOverlay;
|
||||
|
||||
SlotType(int slotOffsetX, int slotOffsetY, Sprite sprite, Sprite buttonSprite, Sprite buttonHoverOverlay) {
|
||||
this.slotOffsetX = slotOffsetX;
|
||||
this.slotOffsetY = slotOffsetY;
|
||||
this.sprite = sprite;
|
||||
this.buttonSprite = buttonSprite;
|
||||
this.buttonHoverOverlay = buttonHoverOverlay;
|
||||
}
|
||||
|
||||
SlotType(int slotOffset, Sprite sprite) {
|
||||
this.slotOffsetX = slotOffset;
|
||||
this.slotOffsetY = slotOffset;
|
||||
this.sprite = sprite;
|
||||
}
|
||||
|
||||
public int getSlotOffsetX() {
|
||||
return slotOffsetX;
|
||||
}
|
||||
|
||||
public int getSlotOffsetY() {
|
||||
return slotOffsetY;
|
||||
}
|
||||
|
||||
public Sprite getSprite() {
|
||||
return sprite;
|
||||
}
|
||||
|
||||
public Sprite getButtonSprite() {
|
||||
return buttonSprite;
|
||||
}
|
||||
|
||||
public Sprite getButtonHoverOverlay() {
|
||||
return buttonHoverOverlay;
|
||||
}
|
||||
}
|
145
src/main/java/techreborn/client/gui/slot/elements/Sprite.java
Normal file
145
src/main/java/techreborn/client/gui/slot/elements/Sprite.java
Normal file
|
@ -0,0 +1,145 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
||||
public class Sprite implements ISprite {
|
||||
public static final Sprite EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 0, 0);
|
||||
public static final Sprite SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 0, 0, 18, 18);
|
||||
public static final Sprite CHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 18, 0, 18, 18);
|
||||
public static final Sprite DISCHARGE_SLOT_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 36, 0, 18, 18);
|
||||
public static final Sprite ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 18, 12, 40);
|
||||
public static final Sprite ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 12, 18, 14, 42);
|
||||
public static final Sprite TOP_ENERGY_BAR = new Sprite(ElementBase.MECH_ELEMENTS, 0, 215, 167, 2);
|
||||
public static final Sprite TOP_ENERGY_BAR_BACKGROUND = new Sprite(ElementBase.MECH_ELEMENTS, 0, 217, 169, 3);
|
||||
public static final Sprite LEFT_TAB = new Sprite(ElementBase.MECH_ELEMENTS, 0, 86, 23, 26);
|
||||
public static final Sprite LEFT_TAB_SELECTED = new Sprite(ElementBase.MECH_ELEMENTS, 0, 60, 29, 26);
|
||||
public static final Sprite CONFIGURE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 18, 16, 16);
|
||||
public static final Sprite REDSTONE_DISABLED_ICON = new Sprite(new ItemStack(Items.GUNPOWDER));
|
||||
public static final Sprite REDSTONE_LOW_ICON = new Sprite(new ItemStack(Items.REDSTONE));
|
||||
public static final Sprite REDSTONE_HIGH_ICON = new Sprite(new ItemStack(Blocks.REDSTONE_TORCH));
|
||||
public static final Sprite UPGRADE_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 26, 34, 16, 16);
|
||||
public static final Sprite ENERGY_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 46, 19, 9, 13);
|
||||
public static final Sprite ENERGY_ICON_EMPTY = new Sprite(ElementBase.MECH_ELEMENTS, 62, 19, 9, 13);
|
||||
public static final Sprite JEI_ICON = new Sprite(ElementBase.MECH_ELEMENTS, 42, 34, 16, 16);
|
||||
public static final Sprite BUTTON_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 54, 0, 18, 18);
|
||||
public static final Sprite FAKE_SLOT = new Sprite(ElementBase.MECH_ELEMENTS, 72, 0, 18, 18);
|
||||
public static final Sprite BUTTON_HOVER_OVERLAY_SLOT_NORMAL = new Sprite(ElementBase.MECH_ELEMENTS, 90, 0, 18, 18);
|
||||
public static final Sprite SLOT_CONFIG_POPUP = new Sprite(ElementBase.MECH_ELEMENTS, 29, 60, 62, 62);
|
||||
public static final Sprite.Button EXIT_BUTTON = new Sprite.Button(new Sprite(ElementBase.MECH_ELEMENTS, 26, 122, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 39, 122, 13, 13));
|
||||
public static final Sprite.CheckBox DARK_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 18, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 18, 16, 13));
|
||||
public static final Sprite.CheckBox LIGHT_CHECK_BOX = new Sprite.CheckBox(new Sprite(ElementBase.MECH_ELEMENTS, 74, 31, 13, 13), new Sprite(ElementBase.MECH_ELEMENTS, 87, 31, 16, 13));
|
||||
|
||||
public final ResourceLocation textureLocation;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int width;
|
||||
public final int height;
|
||||
public int offsetX = 0;
|
||||
public int offsetY = 0;
|
||||
public ItemStack itemStack;
|
||||
|
||||
public Sprite(ResourceLocation textureLocation, int x, int y, int width, int height) {
|
||||
this.textureLocation = textureLocation;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.itemStack = null;
|
||||
}
|
||||
|
||||
public Sprite(ItemStack stack) {
|
||||
this.textureLocation = null;
|
||||
this.x = -1;
|
||||
this.y = -1;
|
||||
this.width = -1;
|
||||
this.height = -1;
|
||||
this.itemStack = stack;
|
||||
}
|
||||
|
||||
public boolean hasStack() {
|
||||
return itemStack != null;
|
||||
}
|
||||
|
||||
public boolean hasTextureInfo() {
|
||||
return x >= 0 && y >= 0 && width >= 0 && height >= 0;
|
||||
}
|
||||
|
||||
public Sprite setOffsetX(int offsetX) {
|
||||
this.offsetX = offsetX;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Sprite setOffsetY(int offsetY) {
|
||||
this.offsetY = offsetY;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sprite getSprite(TileLegacyMachineBase provider) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Button {
|
||||
private Sprite normal;
|
||||
private Sprite hovered;
|
||||
|
||||
public Button(Sprite normal, Sprite hovered) {
|
||||
this.normal = normal;
|
||||
this.hovered = hovered;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getHovered() {
|
||||
return hovered;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ToggleButton {
|
||||
private Sprite normal;
|
||||
private Sprite hovered;
|
||||
private Sprite pressed;
|
||||
|
||||
public ToggleButton(Sprite normal, Sprite hovered, Sprite pressed) {
|
||||
this.normal = normal;
|
||||
this.hovered = hovered;
|
||||
this.pressed = pressed;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getHovered() {
|
||||
return hovered;
|
||||
}
|
||||
|
||||
public Sprite getPressed() {
|
||||
return pressed;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CheckBox {
|
||||
private Sprite normal;
|
||||
private Sprite ticked;
|
||||
|
||||
public CheckBox(Sprite normal, Sprite ticked) {
|
||||
this.normal = normal;
|
||||
this.ticked = ticked;
|
||||
}
|
||||
|
||||
public Sprite getNormal() {
|
||||
return normal;
|
||||
}
|
||||
|
||||
public Sprite getTicked() {
|
||||
return ticked;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package techreborn.client.gui.slot.elements;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SpriteContainer {
|
||||
public List<OffsetSprite> offsetSprites = new ArrayList<>();
|
||||
|
||||
public SpriteContainer setSprite(int index, OffsetSprite sprite) {
|
||||
offsetSprites.set(index, sprite);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer setSprite(int index, ISprite sprite, int offsetX, int offsetY) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX + offsetX).setOffsetY(((Sprite) sprite).offsetY + offsetY));
|
||||
} else {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite, offsetX, offsetY));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer setSprite(int index, ISprite sprite) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.set(index, new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX).setOffsetY(((Sprite) sprite).offsetY));
|
||||
} else {
|
||||
offsetSprites.add(index, new OffsetSprite(sprite));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(OffsetSprite sprite) {
|
||||
offsetSprites.add(sprite);
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(ISprite sprite, int offsetX, int offsetY) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.add(new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX + offsetX).setOffsetY(((Sprite) sprite).offsetY + offsetY));
|
||||
} else {
|
||||
offsetSprites.add(new OffsetSprite(sprite, offsetX, offsetY));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public SpriteContainer addSprite(ISprite sprite) {
|
||||
if (sprite instanceof Sprite) {
|
||||
offsetSprites.add(new OffsetSprite(sprite).setOffsetX(((Sprite) sprite).offsetX).setOffsetY(((Sprite) sprite).offsetY));
|
||||
} else {
|
||||
offsetSprites.add(new OffsetSprite(sprite));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -32,7 +32,7 @@ import net.minecraft.util.ResourceLocation;
|
|||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import reborncore.RebornRegistry;
|
||||
import reborncore.common.tile.TileMachineBase;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.OreUtil;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.Core;
|
||||
|
@ -349,7 +349,7 @@ public class ModBlocks {
|
|||
registerBlock(WIND_MILL, "wind_mill");
|
||||
GameRegistry.registerTileEntity(TileWindMill.class, "TileWindMillTR");
|
||||
|
||||
GameRegistry.registerTileEntity(TileMachineBase.class, "TileMachineBaseTR");
|
||||
GameRegistry.registerTileEntity(TileLegacyMachineBase.class, "TileMachineBaseTR");
|
||||
|
||||
RUBBER_LOG = new BlockRubberLog();
|
||||
registerBlock(RUBBER_LOG, "rubber_log");
|
||||
|
|
|
@ -40,11 +40,7 @@ import techreborn.config.ConfigTechReborn;
|
|||
import techreborn.init.IC2Duplicates;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.init.ModItems;
|
||||
import techreborn.items.DynamicCell;
|
||||
import techreborn.items.ItemDustsSmall;
|
||||
import techreborn.items.ItemNuggets;
|
||||
import techreborn.items.ItemParts;
|
||||
import techreborn.items.ItemUpgrades;
|
||||
import techreborn.items.*;
|
||||
|
||||
/**
|
||||
* Created by Prospector
|
||||
|
@ -90,8 +86,6 @@ public class CraftingTableRecipes extends RecipeMethods {
|
|||
}
|
||||
|
||||
//Upgrades
|
||||
registerShaped(ItemUpgrades.getUpgradeByName("injection"), "CHC", "PSP", "PPP", 'S', "chestWood", 'C', "circuitBasic", 'P', "plateIron", 'H', getStack(Blocks.HOPPER));
|
||||
registerShaped(ItemUpgrades.getUpgradeByName("ejection"), "CSC", "PHP", "PPP", 'S', "chestWood", 'C', "circuitBasic", 'P', "plateIron", 'H', getStack(Blocks.HOPPER));
|
||||
registerShaped(ItemUpgrades.getUpgradeByName("energy_storage"), "PPP", "WBW", "PCP", 'P', "plankWood", 'W', getStack(IC2Duplicates.CABLE_ICOPPER), 'C', "circuitBasic", 'B', "reBattery");
|
||||
registerShaped(ItemUpgrades.getUpgradeByName("overclock"), "TTT", "WCW", 'T', getMaterial("coolant_simple", Type.PART), 'W', getStack(IC2Duplicates.CABLE_ICOPPER), 'C', "circuitBasic");
|
||||
registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', getMaterial("helium_coolant_triple", Type.PART), 'W', getStack(IC2Duplicates.CABLE_ICOPPER), 'C', "circuitBasic");
|
||||
|
|
|
@ -29,7 +29,6 @@ import net.minecraft.client.util.ITooltipFlag;
|
|||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -37,16 +36,10 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IUpgrade;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.IUpgradeHandler;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.tile.IMachineSlotProvider;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
import reborncore.common.util.InventoryHelper;
|
||||
import reborncore.common.util.ItemNBTHelper;
|
||||
import techreborn.Core;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
|
@ -62,7 +55,7 @@ import java.util.List;
|
|||
|
||||
public class ItemUpgrades extends ItemTR implements IUpgrade {
|
||||
|
||||
public static final String[] types = new String[] { "overclock", "transformer", "energy_storage", "range", "ejection", "injection" };
|
||||
public static final String[] types = new String[] { "overclock", "transformer", "energy_storage", "range" };
|
||||
|
||||
public ItemUpgrades() {
|
||||
setUnlocalizedName("techreborn.upgrade");
|
||||
|
@ -131,68 +124,6 @@ public class ItemUpgrades extends ItemTR implements IUpgrade {
|
|||
handler.addSpeedMulti(0.25);
|
||||
handler.addPowerMulti(0.5);
|
||||
|
||||
} else if (stack.getItemDamage() == 4) {
|
||||
EnumFacing dir = getFacing(stack);
|
||||
TileEntity tileEntity = machineBase.getWorld().getTileEntity(machineBase.getPos().offset(dir));
|
||||
if (tileEntity instanceof IInventory) {
|
||||
if (machineBase instanceof IRecipeCrafterProvider) {
|
||||
RecipeCrafter crafter = ((IRecipeCrafterProvider) machineBase).getRecipeCrafter();
|
||||
for (Integer outSlot : crafter.outputSlots) {
|
||||
ItemStack outputStack = crafter.inventory.getStackInSlot(outSlot);
|
||||
if (!outputStack.isEmpty()) {
|
||||
int amount = InventoryHelper.testInventoryInsertion((IInventory) tileEntity, outputStack, dir);
|
||||
if (amount > 0) {
|
||||
InventoryHelper.insertItemIntoInventory((IInventory) tileEntity, outputStack);
|
||||
crafter.inventory.decrStackSize(outSlot, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (machineBase instanceof IMachineSlotProvider) {
|
||||
IMachineSlotProvider slotProvider = (IMachineSlotProvider) machineBase;
|
||||
for (Integer outSlot : slotProvider.getOuputSlots()) {
|
||||
ItemStack outputStack = slotProvider.getMachineInv().getStackInSlot(outSlot);
|
||||
if (!outputStack.isEmpty()) {
|
||||
int amount = InventoryHelper.testInventoryInsertion((IInventory) tileEntity, outputStack, dir);
|
||||
if (amount > 0) {
|
||||
InventoryHelper.insertItemIntoInventory((IInventory) tileEntity, outputStack);
|
||||
slotProvider.getMachineInv().decrStackSize(outSlot, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
IInventory inventory = machineBase;
|
||||
for (int outSlot = 0; outSlot < inventory.getSizeInventory(); outSlot++) {
|
||||
ItemStack outputStack = inventory.getStackInSlot(outSlot);
|
||||
if (!outputStack.isEmpty()) {
|
||||
int amount = InventoryHelper.testInventoryInsertion((IInventory) tileEntity, outputStack, dir);
|
||||
if (amount > 0) {
|
||||
InventoryHelper.insertItemIntoInventory((IInventory) tileEntity, outputStack);
|
||||
inventory.decrStackSize(outSlot, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (stack.getItemDamage() == 5) {
|
||||
if (machineBase.getWorld().getTotalWorldTime() % 10 != 0) {
|
||||
return;
|
||||
}
|
||||
EnumFacing dir = getFacing(stack);
|
||||
TileEntity tileEntity = machineBase.getWorld().getTileEntity(machineBase.getPos().offset(dir));
|
||||
if (tileEntity != null && tileEntity.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite())) {
|
||||
IItemHandler itemHandler = tileEntity.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, dir.getOpposite());
|
||||
for (int i = 0; i < itemHandler.getSlots(); i++) {
|
||||
ItemStack extractedStack = itemHandler.extractItem(i, 1, true);
|
||||
int amount = InventoryHelper.testInventoryInsertion(machineBase, extractedStack, dir.getOpposite());
|
||||
if (amount > 0) {
|
||||
extractedStack = itemHandler.extractItem(i, 1, false);
|
||||
extractedStack.setCount(1);
|
||||
InventoryHelper.insertItemIntoInventory(machineBase, extractedStack);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
if (machineBase instanceof TilePowerAcceptor) {
|
||||
if (stack.getItemDamage() == 2) {
|
||||
|
|
|
@ -43,6 +43,7 @@ import reborncore.client.multiblock.MultiblockRenderEvent;
|
|||
import techreborn.blocks.BlockRubberLeaves;
|
||||
import techreborn.client.*;
|
||||
import techreborn.client.gui.GuiBase;
|
||||
import techreborn.client.gui.slot.GuiSlotConfiguration;
|
||||
import techreborn.client.keybindings.KeyBindings;
|
||||
import techreborn.client.render.ModelDynamicCell;
|
||||
import techreborn.client.render.entitys.RenderNukePrimed;
|
||||
|
@ -74,6 +75,7 @@ public class ClientProxy extends CommonProxy {
|
|||
super.init(event);
|
||||
MinecraftForge.EVENT_BUS.register(new StackToolTipEvent());
|
||||
multiblockRenderEvent = new MultiblockRenderEvent();
|
||||
MinecraftForge.EVENT_BUS.register(GuiSlotConfiguration.class);
|
||||
MinecraftForge.EVENT_BUS.register(multiblockRenderEvent);
|
||||
// TODO FIX ME
|
||||
ClientRegistry.registerKeyBinding(KeyBindings.config);
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -45,7 +44,7 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileAssemblingMachine extends TilePowerAcceptor
|
||||
implements IToolDrop, ISidedInventory, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "assembling_machine", key = "AssemblingMachineMaxInput", comment = "Assembling Machine Max Input (Value in EU)")
|
||||
public static int maxInput = 128;
|
||||
|
@ -136,20 +135,6 @@ public class TileAssemblingMachine extends TilePowerAcceptor
|
|||
return this.crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,6 @@ package techreborn.tiles;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.CraftingManager;
|
||||
|
@ -55,7 +54,7 @@ import java.util.List;
|
|||
/**
|
||||
* Created by modmuss50 on 20/06/2017.
|
||||
*/
|
||||
public class TileAutoCraftingTable extends TilePowerAcceptor implements IContainerProvider, IInventoryProvider, ISidedInventory {
|
||||
public class TileAutoCraftingTable extends TilePowerAcceptor implements IContainerProvider, IInventoryProvider {
|
||||
|
||||
ResourceLocation currentRecipe;
|
||||
|
||||
|
@ -440,26 +439,4 @@ public class TileAutoCraftingTable extends TilePowerAcceptor implements IContain
|
|||
}
|
||||
return super.isItemValidForSlot(index, stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
if (index == 9) {
|
||||
return false;
|
||||
}
|
||||
int bestSlot = findBestSlotForStack(getIRecipe(), itemStackIn);
|
||||
if (bestSlot != -1) {
|
||||
return index == bestSlot;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return index == 9 || index == 10;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,12 +25,11 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.IEnergyInterfaceItem;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -43,7 +42,7 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileChargeOMat extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, ISidedInventory, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "charge_bench", key = "ChargeBenchMaxInput", comment = "Charge Bench Max Input (Value in EU)")
|
||||
public static int maxInput = 512;
|
||||
|
@ -87,28 +86,6 @@ public class TileChargeOMat extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
// if (itemStack.getItem() instanceof IElectricItem) {
|
||||
// double CurrentCharge = ElectricItem.manager.getCharge(itemStack);
|
||||
// double MaxCharge = ((IElectricItem)
|
||||
// itemStack.getItem()).getMaxCharge(itemStack);
|
||||
// if (CurrentCharge == MaxCharge)
|
||||
// return true;
|
||||
// }
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -43,7 +42,7 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileChemicalReactor extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "chemical_reactor", key = "ChemicalReactorMaxInput", comment = "Chemical Reactor Max Input (Value in EU)")
|
||||
public static int maxInput = 128;
|
||||
|
@ -97,33 +96,6 @@ public class TileChemicalReactor extends TilePowerAcceptor
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void addWailaInfo(List<String> info)
|
||||
// {
|
||||
// super.addWailaInfo(info);
|
||||
// info.add("Power Stored " + energy.getEnergyStored() +" EU");
|
||||
// if(crafter.currentRecipe !=null){
|
||||
// info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
|
||||
// }
|
||||
// }
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0 && this.crafter.currentNeededTicks > 0) {
|
||||
|
|
|
@ -27,8 +27,8 @@ package techreborn.tiles;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -42,7 +42,6 @@ import techreborn.client.container.IContainerProvider;
|
|||
import techreborn.client.container.builder.BuiltContainer;
|
||||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
import techreborn.init.ModBlocks;
|
||||
import techreborn.items.DynamicCell;
|
||||
import techreborn.lib.ModInfo;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -105,23 +104,6 @@ public class TileIndustrialCentrifuge extends TilePowerAcceptor
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return itemStackIn.isItemEqual(DynamicCell.getEmptyCell(1).copy()) ? index == 1 : index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex >= 2 && slotIndex <= 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInfo(final List<String> info, final boolean isRealTile) {
|
||||
super.addInfo(info, isRealTile);
|
||||
|
|
|
@ -25,13 +25,12 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -48,7 +47,7 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileIndustrialElectrolyzer extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "industrial_electrolyzer", key = "IndustrialElectrolyzerMaxInput", comment = "Industrial Electrolyzer Max Input (Value in EU)")
|
||||
public static int maxInput = 128;
|
||||
|
@ -115,26 +114,6 @@ public class TileIndustrialElectrolyzer extends TilePowerAcceptor
|
|||
// }
|
||||
// }
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5 } : new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack stack, final EnumFacing side) {
|
||||
if (slotIndex > 1)
|
||||
return false;
|
||||
if (slotIndex == 1)
|
||||
return ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true);
|
||||
return !ItemUtils.isItemEqual(stack, DynamicCell.getEmptyCell(1), true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -312,20 +312,6 @@ public class TileIronAlloyFurnace extends TileLegacyMachineBase
|
|||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 2;
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.burnTime;
|
||||
|
|
|
@ -26,11 +26,9 @@ package techreborn.tiles;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
@ -41,7 +39,7 @@ import techreborn.client.container.builder.BuiltContainer;
|
|||
import techreborn.client.container.builder.ContainerBuilder;
|
||||
|
||||
public class TileIronFurnace extends TileLegacyMachineBase
|
||||
implements IInventoryProvider, ISidedInventory, IContainerProvider {
|
||||
implements IInventoryProvider, IContainerProvider {
|
||||
|
||||
private static final int[] SLOTS_TOP = new int[] { 0, 2 };
|
||||
private static final int[] SLOTS_BOTTOM = new int[] { 1 };
|
||||
|
@ -174,11 +172,6 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
|||
return this.inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? TileIronFurnace.SLOTS_BOTTOM : side == EnumFacing.UP ? TileIronFurnace.SLOTS_TOP : TileIronFurnace.SLOTS_SIDES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
boolean isFuel = TileEntityFurnace.isItemFuel(stack);
|
||||
|
@ -191,23 +184,6 @@ public class TileIronFurnace extends TileLegacyMachineBase
|
|||
return index != output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
boolean isFuel = TileEntityFurnace.isItemFuel(stack);
|
||||
if(isFuel){
|
||||
ItemStack fuelSlotStack = getStackInSlot(fuelslot);
|
||||
if(fuelSlotStack.isEmpty() || ItemUtils.isItemEqual(stack, fuelSlotStack, true, true) && fuelSlotStack.getMaxStackSize() != fuelSlotStack.getCount()){
|
||||
return index == fuelslot;
|
||||
}
|
||||
}
|
||||
return index != output;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.fuel;
|
||||
}
|
||||
|
|
|
@ -27,8 +27,8 @@ package techreborn.tiles;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -75,23 +75,6 @@ public class TileMatterFabricator extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3, 4, 5, 6 } : new int[] { 0, 1, 2, 3, 4, 5, 6 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
if (slotIndex >= 6)
|
||||
return false;
|
||||
return isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int slotIndex, ItemStack itemStack, EnumFacing side) {
|
||||
return slotIndex >= 6 && slotIndex <= 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (world.isRemote){ return; }
|
||||
|
|
|
@ -33,8 +33,8 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
import reborncore.common.tile.TileLegacyMachineBase;
|
||||
|
|
|
@ -30,8 +30,8 @@ import net.minecraft.inventory.InventoryCrafting;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -192,23 +192,6 @@ public class TileRollingMachine extends TilePowerAcceptor
|
|||
tagCompound.setInteger("tickTime", this.tickTime);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 0 };
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int Index, final ItemStack itemStack, final EnumFacing side) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int Index, final ItemStack itemStack, final EnumFacing side) {
|
||||
return Index == outputSlot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
super.invalidate();
|
||||
|
|
|
@ -26,11 +26,10 @@ package techreborn.tiles;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -46,7 +45,7 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileScrapboxinator extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, ISidedInventory, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "scrapboxinator", key = "ScrapboxinatorMaxInput", comment = "Scrapboxinator Max Input (Value in EU)")
|
||||
public static int maxInput = 32;
|
||||
|
@ -152,25 +151,6 @@ public class TileScrapboxinator extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction){
|
||||
if (index == 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
|
||||
return index == 1;
|
||||
}
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return maxEnergy;
|
||||
|
|
|
@ -24,9 +24,6 @@
|
|||
|
||||
package techreborn.tiles.cable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
||||
|
@ -45,6 +42,9 @@ import reborncore.common.util.StringUtils;
|
|||
import techreborn.blocks.cable.BlockCable;
|
||||
import techreborn.blocks.cable.EnumCableType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 19/05/2017.
|
||||
*/
|
||||
|
|
|
@ -311,31 +311,6 @@ public class TileFusionControlComputer extends TilePowerAcceptor implements IToo
|
|||
public ITextComponent getDisplayName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can insert the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction){
|
||||
if (index == 0 || index == 1) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if automation can extract the given item in the given slot from the given side.
|
||||
*/
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction){
|
||||
return index == 2;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Inventory getInventory() {
|
||||
|
|
|
@ -31,8 +31,8 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.FluidUtils;
|
||||
|
|
|
@ -28,8 +28,8 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import techreborn.init.ModBlocks;
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
|
|
@ -31,8 +31,8 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.tileentity.TileEntityFurnace;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraftforge.common.ForgeModContainer;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -182,16 +182,6 @@ public class TileSolidFuelGenerator extends TilePowerAcceptor implements IToolDr
|
|||
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime).addInventory().create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return TileSolidFuelGenerator.getItemBurnTime(itemStackIn) != 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { fuelSlot };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
|
|
|
@ -141,21 +141,6 @@ public class TileDistillationTower extends TilePowerAcceptor
|
|||
this.crafter.writeToNBT(tagCompound);
|
||||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 0, 1, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 2 || index == 3 || index == 4 || index == 5;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -104,21 +104,6 @@ public class TileImplosionCompressor extends TilePowerAcceptor
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 0, 1, 2, 3 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0 || index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 2 || index == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -34,9 +34,9 @@ import net.minecraft.network.play.server.SPacketUpdateTileEntity;
|
|||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.multiblock.IMultiblockPart;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
|
@ -171,24 +171,6 @@ public class TileIndustrialBlastFurnace extends TilePowerAcceptor implements ITo
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2, 3 } : new int[] { 0, 1, 2, 3 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -37,9 +37,9 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -159,19 +159,6 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
|
|||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 1, 0, 2, 3, 4, 5, 6 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == 1) {
|
||||
|
@ -185,11 +172,6 @@ public class TileIndustrialGrinder extends TilePowerAcceptor implements IToolDro
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5 || slotIndex == 6;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -37,9 +37,9 @@ import net.minecraftforge.common.capabilities.Capability;
|
|||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidBlock;
|
||||
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -191,18 +191,6 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IToolDro
|
|||
return maxInput;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 1, 0, 2, 3, 4, 5 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing direction) {
|
||||
if (slotIndex >= 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int slotIndex, ItemStack itemStack) {
|
||||
if (slotIndex == 1) {
|
||||
|
@ -215,11 +203,6 @@ public class TileIndustrialSawmill extends TilePowerAcceptor implements IToolDro
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2 || slotIndex == 3 || slotIndex == 4 || slotIndex == 5;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(final EntityPlayer entityPlayer) {
|
||||
|
|
|
@ -28,9 +28,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -133,21 +133,6 @@ public class TileVacuumFreezer extends TilePowerAcceptor
|
|||
return this.crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("vacuumfreezer").player(player.inventory).inventory().hotbar().addInventory()
|
||||
|
|
|
@ -29,10 +29,10 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PoweredItem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -154,21 +154,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
|
|||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(EnumFacing side) {
|
||||
return new int[] { 0, 1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(int index, ItemStack itemStackIn, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
|
|
|
@ -25,14 +25,13 @@
|
|||
package techreborn.tiles.teir1;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.recipe.RecipeHandler;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
|
@ -49,7 +48,7 @@ import techreborn.lib.ModInfo;
|
|||
|
||||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class TileAlloySmelter extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, ISidedInventory, IRecipeCrafterProvider, IContainerProvider {
|
||||
implements IToolDrop, IInventoryProvider, IRecipeCrafterProvider, IContainerProvider {
|
||||
|
||||
@ConfigRegistry(config = "machines", category = "alloy_smelter", key = "AlloySmelterMaxInput", comment = "Alloy Smelter Max Input (Value in EU)")
|
||||
public static int maxInput = 32;
|
||||
|
@ -102,24 +101,6 @@ public class TileAlloySmelter extends TilePowerAcceptor
|
|||
return tagCompound;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
return side == EnumFacing.DOWN ? new int[] { 0, 1, 2 } : new int[] { 0, 1, 2 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 2;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0 && this.crafter.currentNeededTicks != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -27,9 +27,9 @@ package techreborn.tiles.teir1;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -72,26 +72,6 @@ public class TileCompressor extends TilePowerAcceptor implements IToolDrop, IInv
|
|||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.UP))
|
||||
return new int[] { 0 };
|
||||
else if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 1 };
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int Index, final ItemStack itemStack, final EnumFacing side) {
|
||||
return Index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int Index, final ItemStack itemStack, final EnumFacing side) {
|
||||
return Index == 1;
|
||||
}
|
||||
|
||||
public int getProgressScaled(final int scale) {
|
||||
if (this.crafter.currentTickTime != 0) {
|
||||
return this.crafter.currentTickTime * scale / this.crafter.currentNeededTicks;
|
||||
|
|
|
@ -26,17 +26,13 @@ package techreborn.tiles.teir1;
|
|||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.FurnaceRecipes;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.tile.IMachineSlotProvider;
|
||||
import reborncore.common.util.Inventory;
|
||||
import techreborn.client.container.IContainerProvider;
|
||||
import techreborn.client.container.builder.BuiltContainer;
|
||||
|
@ -44,7 +40,7 @@ import techreborn.client.container.builder.ContainerBuilder;
|
|||
import techreborn.init.ModBlocks;
|
||||
|
||||
public class TileElectricFurnace extends TilePowerAcceptor
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider, IMachineSlotProvider, ISidedInventory {
|
||||
implements IToolDrop, IInventoryProvider, IContainerProvider {
|
||||
|
||||
public Inventory inventory = new Inventory(3, "TileElectricFurnace", 64, this);
|
||||
public int capacity = 1000;
|
||||
|
@ -167,31 +163,6 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.UP))
|
||||
return new int[] { 0 };
|
||||
else if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 1 };
|
||||
else if (ArrayUtils.contains(EnumFacing.HORIZONTALS, side)){
|
||||
return new int[]{0};
|
||||
}
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex == 2)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
|
@ -237,21 +208,6 @@ public class TileElectricFurnace extends TilePowerAcceptor
|
|||
.syncIntegerValue(this::getBurnTime, this::setBurnTime).addInventory().create(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInputSlots() {
|
||||
return new int[] { input1 };
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getOuputSlots() {
|
||||
return new int[] { output };
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getMachineInv() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return true;
|
||||
|
|
|
@ -28,9 +28,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -130,25 +130,6 @@ public class TileExtractor extends TilePowerAcceptor
|
|||
return this.crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.UP))
|
||||
return new int[] { 0 };
|
||||
else if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 1 };
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("extractor").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||
|
|
|
@ -28,9 +28,9 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.recipe.IRecipeCrafterProvider;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.Inventory;
|
||||
|
@ -131,25 +131,6 @@ public class TileGrinder extends TilePowerAcceptor
|
|||
return this.crafter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.UP))
|
||||
return new int[] { 0 };
|
||||
else if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 1 };
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int index, final ItemStack itemStackIn, final EnumFacing direction) {
|
||||
return index == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int index, final ItemStack stack, final EnumFacing direction) {
|
||||
return index == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(final EntityPlayer player) {
|
||||
return new ContainerBuilder("grinder").player(player.inventory).inventory().hotbar().addInventory().tile(this)
|
||||
|
|
|
@ -138,28 +138,6 @@ public class TileRecycler extends TilePowerAcceptor implements IToolDrop, IInven
|
|||
return false;
|
||||
}
|
||||
|
||||
// ISidedInventory
|
||||
@Override
|
||||
public int[] getSlotsForFace(final EnumFacing side) {
|
||||
if (side.equals(EnumFacing.UP))
|
||||
return new int[] { 0 };
|
||||
else if (side.equals(EnumFacing.DOWN))
|
||||
return new int[] { 1 };
|
||||
return new int[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
if (slotIndex == 1)
|
||||
return false;
|
||||
return this.isItemValidForSlot(slotIndex, itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem(final int slotIndex, final ItemStack itemStack, final EnumFacing side) {
|
||||
return slotIndex == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseMaxPower() {
|
||||
return this.capacity;
|
||||
|
|
|
@ -31,8 +31,8 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
|
BIN
src/main/resources/assets/techreborn/textures/gui/elements.png
Normal file
BIN
src/main/resources/assets/techreborn/textures/gui/elements.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 15 KiB |
Loading…
Add table
Reference in a new issue