@Override protected void handleModePacket(PacketBase payload) { super.handleModePacket(payload); lockPrimary = payload.getBool(); callNeighborTileChange(); }
public static void initialize() { SIDE_CONFIGS[TYPE] = new SideConfig(); SIDE_CONFIGS[TYPE].numConfig = 7; SIDE_CONFIGS[TYPE].slotGroups = new int[][] { {}, { 0, 1 }, { 2 }, { 0 }, { 1 }, { 0, 1, 2 }, { 0, 1, 2 } }; SIDE_CONFIGS[TYPE].sideTypes = new int[] { NONE, INPUT_ALL, OUTPUT_ALL, INPUT_PRIMARY, INPUT_SECONDARY, OPEN, OMNI }; SIDE_CONFIGS[TYPE].defaultSides = new byte[] { 1, 1, 2, 2, 2, 2 }; ALT_SIDE_CONFIGS[TYPE] = new SideConfig(); ALT_SIDE_CONFIGS[TYPE].numConfig = 2; ALT_SIDE_CONFIGS[TYPE].slotGroups = new int[][] { {}, { 0, 1 }, { 2 }, { 0 }, { 1 }, { 0, 1, 2 }, { 0, 1, 2 } }; ALT_SIDE_CONFIGS[TYPE].sideTypes = new int[] { NONE, OPEN }; ALT_SIDE_CONFIGS[TYPE].defaultSides = new byte[] { 1, 1, 1, 1, 1, 1 }; SLOT_CONFIGS[TYPE] = new SlotConfig(); SLOT_CONFIGS[TYPE].allowInsertionSlot = new boolean[] { true, true, false, false }; SLOT_CONFIGS[TYPE].allowExtractionSlot = new boolean[] { false, false, true, false }; VALID_AUGMENTS[TYPE] = new HashSet<>(); VALID_AUGMENTS[TYPE].add(TEProps.MACHINE_ENCHANTER_EMPOWERED); LIGHT_VALUES[TYPE] = 12; GameRegistry.registerTileEntity(TileEnchanter.class, "thermalexpansion:machine_enchanter"); config(); }
public TileEnchanter() { super(); inventory = new ItemStack[2 + 1 + 1]; Arrays.fill(inventory, ItemStack.EMPTY); createAllSlots(inventory.length); tank.setLock(TFFluids.fluidExperience); }
@Override protected void transferInput() { if (!getTransferIn()) { return; } int side; for (int i = inputTrackerPrimary + 1; i <= inputTrackerPrimary + 6; i++) { side = i % 6; if (isPrimaryInput(sideConfig.sideTypes[sideCache[side]])) { if (extractItem(0, ITEM_TRANSFER[level], EnumFacing.VALUES[side])) { inputTrackerPrimary = side; break; } } } for (int i = inputTrackerSecondary + 1; i <= inputTrackerSecondary + 6; i++) { side = i % 6; if (isSecondaryInput(sideConfig.sideTypes[sideCache[side]])) { if (extractItem(1, ITEM_TRANSFER[level], EnumFacing.VALUES[side])) { inputTrackerSecondary = side; break; } } } }
@Override public void initGui() { super.initGui(); slotPrimaryInput[0] = (ElementSlotOverlay) addElement(new ElementSlotOverlay(this, 32, 26).setSlotInfo(SlotColor.BLUE, SlotType.STANDARD, SlotRender.FULL)); slotPrimaryInput[1] = (ElementSlotOverlay) addElement(new ElementSlotOverlay(this, 32, 26).setSlotInfo(SlotColor.GREEN, SlotType.STANDARD, SlotRender.BOTTOM)); slotSecondaryInput[0] = (ElementSlotOverlay) addElement(new ElementSlotOverlay(this, 56, 26).setSlotInfo(SlotColor.BLUE, SlotType.STANDARD, SlotRender.FULL)); slotSecondaryInput[1] = (ElementSlotOverlay) addElement(new ElementSlotOverlay(this, 56, 26).setSlotInfo(SlotColor.PURPLE, SlotType.STANDARD, SlotRender.BOTTOM)); slotOutput = addElement(new ElementSlotOverlay(this, 112, 31).setSlotInfo(SlotColor.ORANGE, SlotType.OUTPUT, SlotRender.FULL)); if (!myTile.smallStorage()) { addElement(new ElementEnergyStored(this, 8, 8, myTile.getEnergyStorage())); } addElement(new ElementFluidTank(this, 152, 9, myTile.getTank()).setGauge(1).setAlwaysShow(true)); progressFluid = (ElementFluid) addElement(new ElementFluid(this, 79, 34).setFluid(myTile.getTankFluid()).setSize(24, 16)); progressOverlay = (ElementDualScaled) addElement(new ElementDualScaled(this, 79, 34).setBackground(false).setMode(1).setSize(24, 16).setTexture(TEX_ARROW_FLUID_RIGHT, 64, 16)); speed = (ElementDualScaled) addElement(new ElementDualScaled(this, 44, 44).setSize(16, 16).setTexture(TEX_BOOK, 32, 16)); mode = (ElementButton) addElement(new ElementButton(this, 80, 53, "Mode", 176, 0, 176, 16, 176, 32, 16, 16, TEX_PATH)); modeOverlay = (ElementSimple) addElement(new ElementSimple(this, 32, 26).setTextureOffsets(176, 48).setSize(16, 16).setTexture(TEX_PATH, 256, 256)); }
@Override protected void updateElementInformation() { super.updateElementInformation(); slotPrimaryInput[0].setVisible(myTile.hasSideType(INPUT_ALL) || baseTile.hasSideType(OMNI)); slotPrimaryInput[1].setVisible(myTile.hasSideType(INPUT_PRIMARY)); slotSecondaryInput[0].setVisible(myTile.hasSideType(INPUT_ALL) || baseTile.hasSideType(OMNI)); slotSecondaryInput[1].setVisible(myTile.hasSideType(INPUT_SECONDARY)); slotOutput.setVisible(baseTile.hasSideType(OUTPUT_ALL) || baseTile.hasSideType(OMNI)); if (!baseTile.hasSideType(INPUT_ALL) && !baseTile.hasSideType(OMNI)) { slotPrimaryInput[1].setSlotRender(SlotRender.FULL); slotSecondaryInput[1].setSlotRender(SlotRender.FULL); } else { slotPrimaryInput[1].setSlotRender(SlotRender.BOTTOM); slotSecondaryInput[1].setSlotRender(SlotRender.BOTTOM); } progressFluid.setSize(baseTile.getScaledProgress(PROGRESS), 16); progressOverlay.setQuantity(baseTile.getScaledProgress(PROGRESS)); speed.setQuantity(myTile.getScaledSpeed(SPEED)); if (myTile.lockPrimary) { mode.setToolTip("gui.thermalexpansion.machine.enchanter.modeLocked"); mode.setSheetX(176); mode.setHoverX(176); modeOverlay.setVisible(true); } else { mode.setToolTip("gui.thermalexpansion.machine.enchanter.modeUnlocked"); mode.setSheetX(192); mode.setHoverX(192); modeOverlay.setVisible(false); } }
@Override protected void processFinish() { if (curRecipe == null) { getRecipe(); } if (curRecipe == null) { processOff(); return; } tank.drain(curRecipe.getExperience(), true); ItemStack primaryItem = curRecipe.getOutput(); if (inventory[2].isEmpty()) { inventory[2] = ItemHelper.cloneStack(primaryItem); } else { inventory[2].grow(primaryItem.getCount()); } if (EnchanterManager.isRecipeReversed(inventory[0], inventory[1])) { inventory[1].shrink(curRecipe.getPrimaryInput().getCount()); inventory[0].shrink(curRecipe.getSecondaryInput().getCount()); } else { inventory[0].shrink(curRecipe.getPrimaryInput().getCount()); inventory[1].shrink(curRecipe.getSecondaryInput().getCount()); } if (inventory[0].getCount() <= 0) { inventory[0] = ItemStack.EMPTY; } if (inventory[1].getCount() <= 0) { inventory[1] = ItemStack.EMPTY; } }
@Override protected boolean hasValidInput() { if (curRecipe == null) { getRecipe(); } if (curRecipe == null) { return false; } if (EnchanterManager.isRecipeReversed(inventory[0], inventory[1])) { return curRecipe.getPrimaryInput().getCount() <= inventory[1].getCount() && curRecipe.getSecondaryInput().getCount() <= inventory[0].getCount(); } else { return curRecipe.getPrimaryInput().getCount() <= inventory[0].getCount() && curRecipe.getSecondaryInput().getCount() <= inventory[1].getCount(); } }
public ContainerEnchanter(InventoryPlayer inventory, TileEntity tile) { super(inventory, tile); myTile = (TileEnchanter) tile; addSlotToContainer(new SlotValidated(lockSlot, myTile, 0, 32, 26)); addSlotToContainer(new SlotValidated(otherSlot, myTile, 1, 56, 26)); addSlotToContainer(new SlotRemoveOnly(myTile, 2, 116, 35)); addSlotToContainer(new SlotEnergy(myTile, myTile.getChargeSlot(), 8, 53)); }
return new TileBrewer(); case ENCHANTER: return new TileEnchanter(); case PRECIPITATOR: return new TilePrecipitator();
@Override protected boolean canStart() { if (inventory[0].isEmpty() || inventory[1].isEmpty() || energyStorage.getEnergyStored() <= 0) { return false; } getRecipe(); if (curRecipe == null) { return false; } if (tank.getFluidAmount() < curRecipe.getExperience()) { return false; } if (curRecipe.getType() == EnchanterManager.Type.EMPOWERED && !augmentEmpowered) { return false; } if (EnchanterManager.isRecipeReversed(inventory[0], inventory[1])) { if (curRecipe.getPrimaryInput().getCount() > inventory[1].getCount() || curRecipe.getSecondaryInput().getCount() > inventory[0].getCount()) { return false; } } else { if (curRecipe.getPrimaryInput().getCount() > inventory[0].getCount() || curRecipe.getSecondaryInput().getCount() > inventory[1].getCount()) { return false; } } ItemStack output = curRecipe.getOutput(); return inventory[2].isEmpty() || inventory[2].isItemEqual(output) && inventory[2].getCount() + output.getCount() <= output.getMaxStackSize(); }