@Override public int getInfoEnergyPerTick() { if (!isActive) { return 0; } return calcEnergy(); }
processTick(); if (canFinish()) { processFinish(); transferOutput(); transferInput(); energyStorage.modifyEnergyStored(-processRem); if (!redstoneControlOrDisable() || !canStart()) { processOff(); } else { processStart(); processOff(); } else if (redstoneControlOrDisable()) { if (timeCheck()) { transferOutput(); transferInput(); if (timeCheckEighth() && canStart()) { processStart(); processTick(); isActive = true; updateIfChanged(curActive); chargeEnergy();
protected void processOff() { processRem = 0; isActive = false; wasActive = true; clearRecipe(); if (world != null) { tracker.markTime(world); } }
@Override public boolean onBlockActivatedDelegate(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) { TileMachineBase tile = (TileMachineBase) world.getTileEntity(pos); if (tile == null || !tile.canPlayerAccess(player)) { return false; } if (tile.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null)) { ItemStack heldItem = player.getHeldItem(hand); IFluidHandler handler = tile.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, null); if (FluidHelper.isFluidHandler(heldItem)) { FluidHelper.interactWithHandler(heldItem, handler, player, hand); return true; } } return false; }
@Override protected void preAugmentInstall() { energyConfig.setDefaultParams(getBasePower(this.level), smallStorage); energyMod = ENERGY_BASE; secondaryChance = SECONDARY_BASE; reuseChance = REUSE_BASE; hasModeAugment = false; augmentSecondaryNull = false; }
@Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = super.decrStackSize(slot, amount); if (ServerHelper.isServerWorld(world) && slot == 1) { if (isActive && (inventory[slot].isEmpty() || !hasValidInput())) { processOff(); hasFluidHandler = false; } } return stack; }
@Override protected void postAugmentInstall() { energyStorage.setCapacity(energyConfig.maxEnergy).setMaxTransfer(energyConfig.maxPower * 4); energyMod *= getBaseEnergy(this.level); secondaryChance = MathHelper.clamp(secondaryChance, SECONDARY_MIN, SECONDARY_BASE); reuseChance = MathHelper.clamp(reuseChance, REUSE_BASE, REUSE_MAX); }
@Override public boolean preInit() { this.setRegistryName("machine"); ForgeRegistries.BLOCKS.register(this); itemBlock = new ItemBlockMachine(this); itemBlock.setRegistryName(this.getRegistryName()); ForgeRegistries.ITEMS.register(itemBlock); TileMachineBase.config(); TileFurnace.initialize(); TilePulverizer.initialize(); TileSawmill.initialize(); TileSmelter.initialize(); TileInsolator.initialize(); TileCompactor.initialize(); TileCrucible.initialize(); TileRefinery.initialize(); TileTransposer.initialize(); TileCharger.initialize(); TileCentrifuge.initialize(); TileCrafter.initialize(); TileBrewer.initialize(); TileEnchanter.initialize(); TilePrecipitator.initialize(); TileExtruder.initialize(); ThermalExpansion.proxy.addIModelRegister(this); return true; }
@Override protected boolean installAugmentToSlot(int slot) { String id = AugmentHelper.getAugmentIdentifier(augments[slot]); if (TEProps.MACHINE_POWER.equals(id)) { energyConfig.setDefaultParams(energyConfig.maxPower + getBasePower(this.level), smallStorage); energyMod += 10; return true; } if (TEProps.MACHINE_SECONDARY.equals(id)) { secondaryChance -= 15; energyMod += 10; return true; } if (!augmentSecondaryNull && TEProps.MACHINE_SECONDARY_NULL.equals(id)) { augmentSecondaryNull = true; return true; } return super.installAugmentToSlot(slot); }
@Override public ItemStack decrStackSize(int slot, int amount) { ItemStack stack = super.decrStackSize(slot, amount); if (ServerHelper.isServerWorld(world) && slot == 1) { if (isActive && (inventory[slot].isEmpty() || !hasValidInput())) { processOff(); containerItem = null; hasContainerItem = false; handler = null; hasEnergyHandler = false; hasRepairItem = false; } } return stack; }
@Override protected int calcEnergy() { if (augmentLava) { return Math.min(super.calcEnergy() * LAVA_MULTIPLIER, energyStorage.getEnergyStored()); } return super.calcEnergy(); }
@Override protected boolean setLevel(int level) { if (super.setLevel(level)) { energyConfig.setDefaultParams(getBasePower(this.level), smallStorage); energyStorage.setCapacity(energyConfig.maxEnergy).setMaxTransfer(energyConfig.maxPower * 4); return true; } return false; }
@Override protected int calcEnergy() { if (augmentPyrolysis) { return Math.min(energyConfig.minPower, energyStorage.getEnergyStored()); } return super.calcEnergy(); }
protected int processTick() { if (processRem <= 0) { return 0; } int energy = calcEnergy(); energyStorage.modifyEnergyStored(-energy); processRem -= energy; return energy; }