diff --git a/src/main/java/supersymmetry/api/util/SuSyUtility.java b/src/main/java/supersymmetry/api/util/SuSyUtility.java index 84cd0040b..40f646003 100644 --- a/src/main/java/supersymmetry/api/util/SuSyUtility.java +++ b/src/main/java/supersymmetry/api/util/SuSyUtility.java @@ -56,4 +56,5 @@ public class SuSyUtility { public static ResourceLocation susyId(String path) { return new ResourceLocation(Supersymmetry.MODID, path); } + } diff --git a/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java b/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java index e920caa0a..b6f9d12e5 100644 --- a/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java +++ b/src/main/java/supersymmetry/client/renderer/textures/SusyTextures.java @@ -46,6 +46,7 @@ public SusyTextures(){ public static final OrientedOverlayRenderer PHASE_SEPARATOR_OVERLAY = new OrientedOverlayRenderer("machines/phase_separator"); public static final OrientedOverlayRenderer BATH_CONDENSER_OVERLAY = new OrientedOverlayRenderer("machines/bath_condenser"); public static final OrientedOverlayRenderer CATALYTIC_REFORMER_OVERLAY = new OrientedOverlayRenderer("multiblock/catalytic_reformer"); + public static final OrientedOverlayRenderer INCINERATOR_OVERLAY = new OrientedOverlayRenderer("machines/incinerator"); public static final OrientedOverlayRenderer FLUID_COMPRESSOR_OVERLAY = new OrientedOverlayRenderer("machines/fluid_compressor"); public static final OrientedOverlayRenderer FLUID_DECOMPRESSOR_OVERLAY = new OrientedOverlayRenderer("machines/fluid_decompressor"); diff --git a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java index 8d33f82ce..c881a992c 100644 --- a/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java +++ b/src/main/java/supersymmetry/common/metatileentities/SuSyMetaTileEntities.java @@ -40,6 +40,7 @@ import supersymmetry.common.metatileentities.multiblockpart.SusyMetaTileEntityDumpingHatch; import supersymmetry.common.metatileentities.multiblockpart.SusyMetaTileEntityEnergyHatch; import supersymmetry.common.metatileentities.single.electric.MetaTileEntityBathCondenser; +import supersymmetry.common.metatileentities.single.electric.MetaTileEntityIncinerator; import supersymmetry.common.metatileentities.single.electric.MetaTileEntityLatexCollector; import supersymmetry.common.metatileentities.single.electric.MetaTileEntityPhaseSeparator; import supersymmetry.common.metatileentities.single.steam.MetaTileEntitySteamLatexCollector; @@ -187,6 +188,8 @@ public class SuSyMetaTileEntities { public static final MetaTileEntityMultiFluidHatch[] SUSY_QUADRUPLE_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[3]; // LV-HV public static final MetaTileEntityMultiFluidHatch[] SUSY_NONUPLE_EXPORT_HATCH = new MetaTileEntityMultiFluidHatch[3]; // LV-HV + public static MetaTileEntityIncinerator[] INCINERATOR = new MetaTileEntityIncinerator[4]; + public static void init() { MAGNETIC_REFRIGERATOR = registerMetaTileEntity(14500, new MetaTileEntityMagneticRefrigerator(susyId("magnetic_refrigerator"))); COAGULATION_TANK = registerMetaTileEntity(14501, new MetaTileEntityCoagulationTank(susyId("coagulation_tank"))); @@ -310,6 +313,12 @@ public static void init() { NEW_ENERGY_OUTPUT_HATCH_16A[2] = registerMetaTileEntity(16005, new SusyMetaTileEntityEnergyHatch(susyId("energy_hatch.output_16a.hv"), 3, 16, true)); NEW_ENERGY_OUTPUT_HATCH_16A[3] = registerMetaTileEntity(16006, new SusyMetaTileEntityEnergyHatch(susyId("energy_hatch.output_16a.ev"), 4, 16, true)); + INCINERATOR[0] = registerMetaTileEntity(16500, new MetaTileEntityIncinerator(susyId("incinerator.lv"), 1, 20, 10)); + INCINERATOR[1] = registerMetaTileEntity(16501, new MetaTileEntityIncinerator(susyId("incinerator.mv"), 2, 20, 20)); + INCINERATOR[2] = registerMetaTileEntity(16502, new MetaTileEntityIncinerator(susyId("incinerator.hv"), 3, 20, 40)); + INCINERATOR[3] = registerMetaTileEntity(16503, new MetaTileEntityIncinerator(susyId("incinerator.ev"), 4, 10, 40)); + + BASIC_STEAM_TURBINE = registerMetaTileEntity(17000, new MetaTileEntitySUSYLargeTurbine(susyId("basic_steam_turbine"), SuSyRecipeMaps.LARGE_STEAM_TURBINE, 1, MetaBlocks.TURBINE_CASING.getState(BlockTurbineCasing.TurbineCasingType.STEEL_TURBINE_CASING), Textures.SOLID_STEEL_CASING, SusyTextures.LARGE_STEAM_TURBINE_OVERLAY)); BASIC_GAS_TURBINE = registerMetaTileEntity(17001, new MetaTileEntitySUSYLargeTurbine(susyId("basic_gas_turbine"), RecipeMaps.GAS_TURBINE_FUELS, 2, MetaBlocks.TURBINE_CASING.getState(BlockTurbineCasing.TurbineCasingType.STEEL_TURBINE_CASING), Textures.SOLID_STEEL_CASING, SusyTextures.LARGE_GAS_TURBINE_OVERLAY)); @@ -351,6 +360,7 @@ public static void init() { registerSimpleMTE(ELECTROSTATIC_SEPARATOR, 12, 17035, "electrostatic_separator", SuSyRecipeMaps.ELECTROSTATIC_SEPARATOR, SusyTextures.ELECTROSTATIC_SEPARATOR_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(POLISHING_MACHINE, 12, 17048, "polishing_machine", SuSyRecipeMaps.POLISHING_MACHINE, SusyTextures.POLISHING_MACHINE_OVERLAY, true, GTUtility.defaultTankSizeFunction); registerSimpleMTE(TEXTILE_SPINNER, 12, 17061, "textile_spinner", SuSyRecipeMaps.SPINNING_RECIPES, SusyTextures.TEXTILE_SPINNER_OVERLAY, true); + } private static void registerSimpleSteamMTE(SuSySimpleSteamMetaTileEntity[] machines, int startId, String name, RecipeMap recipeMap, SuSySteamProgressIndicator progressIndicator, ICubeRenderer texture, boolean isBricked) { diff --git a/src/main/java/supersymmetry/common/metatileentities/single/electric/MetaTileEntityIncinerator.java b/src/main/java/supersymmetry/common/metatileentities/single/electric/MetaTileEntityIncinerator.java new file mode 100644 index 000000000..5cdfb9a99 --- /dev/null +++ b/src/main/java/supersymmetry/common/metatileentities/single/electric/MetaTileEntityIncinerator.java @@ -0,0 +1,281 @@ +package supersymmetry.common.metatileentities.single.electric; + +import codechicken.lib.render.CCRenderState; +import codechicken.lib.render.pipeline.IVertexOperation; +import codechicken.lib.vec.Matrix4; +import gregtech.api.GTValues; +import gregtech.api.capability.GregtechTileCapabilities; +import gregtech.api.capability.IControllable; +import gregtech.api.capability.impl.NotifiableItemStackHandler; +import gregtech.api.gui.GuiTextures; +import gregtech.api.gui.ModularUI; +import gregtech.api.gui.widgets.AdvancedTextWidget; +import gregtech.api.gui.widgets.SlotWidget; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.TieredMetaTileEntity; +import gregtech.api.metatileentity.interfaces.IGregTechTileEntity; +import gregtechfoodoption.utils.GTFOUtils; +import net.minecraft.block.state.IBlockState; +import net.minecraft.client.resources.I18n; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.SoundEvents; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.network.PacketBuffer; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumParticleTypes; +import net.minecraft.util.ResourceLocation; +import net.minecraft.util.SoundCategory; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.TextComponentTranslation; +import net.minecraft.world.World; +import net.minecraftforge.common.capabilities.Capability; +import net.minecraftforge.fml.relauncher.Side; +import net.minecraftforge.fml.relauncher.SideOnly; +import net.minecraftforge.items.IItemHandlerModifiable; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import supersymmetry.client.renderer.textures.SusyTextures; + +import java.util.List; + +import static gregtech.api.GTValues.V; +import static gregtech.api.capability.GregtechDataCodes.UPDATE_ACTIVE; +import static gregtech.api.capability.GregtechDataCodes.WORKING_ENABLED; + +public class MetaTileEntityIncinerator extends TieredMetaTileEntity implements IControllable { + + private boolean isWorkingEnabled = true; + private boolean canProgress; + private boolean hasItems = false; + private int progress = 0; + private boolean isClogged = false; + public final int maxProgress; + public final int itemsPerRun; + public static final int UPDATE_CLOGGED = 3488; + + public MetaTileEntityIncinerator(ResourceLocation metaTileEntityId, int tier, int maxProgress, int itemsPerRun) { + super(metaTileEntityId, tier); + initializeInventory(); + this.maxProgress = maxProgress; + this.itemsPerRun = itemsPerRun; + } + + @Override + public void renderMetaTileEntity(CCRenderState renderState, Matrix4 translation, IVertexOperation[] pipeline) { + super.renderMetaTileEntity(renderState, translation, pipeline); + SusyTextures.INCINERATOR_OVERLAY.renderOrientedState(renderState, translation, pipeline, getFrontFacing(), this.isActive(), true); + } + + @Override + public MetaTileEntity createMetaTileEntity(IGregTechTileEntity iGregTechTileEntity) { + return new MetaTileEntityIncinerator(metaTileEntityId, this.getTier(), maxProgress, itemsPerRun); + } + + @Override + protected ModularUI createUI(EntityPlayer entityPlayer) { + int rowSize = (int) Math.sqrt(getInventorySize()); + return createUITemplate(entityPlayer, rowSize) + .build(getHolder(), entityPlayer); + } + + @Override + public void update() { + super.update(); + if (isActive() && this.getOffsetTimer() % 5 == 0) { + if (this.getWorld().isRemote) { + this.incineratingParticles(); + } else { + getWorld().playSound(null, getPos(), SoundEvents.ENTITY_GENERIC_BURN, SoundCategory.BLOCKS, 1.0F, 1.0F); + } + } + if (!this.getWorld().isRemote && this.getOffsetTimer() % 40 == 0) { + checkClogged(); + } + if (!isClogged && isWorkingEnabled && !this.getWorld().isRemote && (hasItems || this.notifiedItemInputList != null)) { + this.hasItems = true; + int startSlot = GTFOUtils.getFirstUnemptyItemSlot(this.importItems, 0); + if (startSlot == -1) { + this.hasItems = false; + progress = 0; + if (this.canProgress) + setCanProgress(false); + } else if (this.energyContainer.removeEnergy(V[getTier()] / 2) == -V[getTier()] / 2) { + if (!this.canProgress) + setCanProgress(true); + progress++; + if (progress >= maxProgress) { + this.importItems.extractItem(startSlot, itemsPerRun, false); + progress = 0; + } + } else { + if (this.canProgress) + setCanProgress(false); + } + } + } + + public void checkClogged() { + for (BlockPos pos : BlockPos.getAllInBox(getPos().up(1), getPos().up(8))) { + IBlockState state = getWorld().getBlockState(pos); + if (!state.getBlock().isAir(state, getWorld(), pos)) { + setClogged(true); + progress = 0; + return; + } + } + setClogged(false); + } + + @Override + public boolean isActive() { + return canProgress && isWorkingEnabled && !isClogged; + } + + public void setCanProgress(boolean canProgress) { + this.canProgress = canProgress; + this.writeCustomData(UPDATE_ACTIVE, buf -> buf.writeBoolean(canProgress)); + } + + @SideOnly(Side.CLIENT) + private void incineratingParticles() { + BlockPos pos = this.getPos(); + double xPos = pos.getX() + Math.random() / 2; + double yPos = pos.getY() + 0.5D; + double zPos = pos.getZ() + Math.random() / 2; + + double ySpd = 0.1D + Math.random() / 3; + double xSpd = (Math.random() - 0.5D) / 3; + double zSpd = (Math.random() - 0.5D) / 3; + + getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, xPos, yPos, zPos, xSpd, ySpd, zSpd); + getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, xPos, yPos, zPos, xSpd, ySpd, zSpd); + } + + private ModularUI.Builder createUITemplate(EntityPlayer player, int gridSize) { + int backgroundWidth = gridSize > 6 ? 176 + (gridSize - 6) * 18 : 176; + int center = backgroundWidth / 2; + + int gridStartX = center - (gridSize * 9); + + int inventoryStartX = center - 9 - 4 * 18; + int inventoryStartY = 30 + 18 * gridSize + 12; + + ModularUI.Builder builder = ModularUI.builder(GuiTextures.BACKGROUND, backgroundWidth, 30 + 18 * gridSize + 94) + .label(10, 5, getMetaFullName()); + + builder.widget(new AdvancedTextWidget(10, 18, this::getDisplayText, 0)); + + for (int y = 0; y < gridSize; y++) { + for (int x = 0; x < gridSize; x++) { + int index = y * gridSize + x; + + builder.widget(new SlotWidget(importItems, index, + gridStartX + x * 18, 30 + y * 18, true, true) + .setBackgroundTexture(GuiTextures.SLOT)); + } + } + + return builder.bindPlayerInventory(player.inventory, GuiTextures.SLOT, inventoryStartX, inventoryStartY); + } + + private int getInventorySize() { + int sizeRoot = 1 + Math.min(9, getTier()); + return sizeRoot * sizeRoot; + } + + @Override + protected IItemHandlerModifiable createImportItemHandler() { + return new NotifiableItemStackHandler(this, getInventorySize(), this, false); + } + + @Override + public boolean isWorkingEnabled() { + return isWorkingEnabled; + } + + @Override + public void setWorkingEnabled(boolean b) { + this.isWorkingEnabled = b; + this.writeCustomData(WORKING_ENABLED, buf -> buf.writeBoolean(b)); + } + + public void setClogged(boolean b) { + this.isClogged = b; + this.writeCustomData(UPDATE_CLOGGED, buf -> buf.writeBoolean(b)); + } + + public void getDisplayText(List list) { + list.add(new TextComponentTranslation(isClogged ? "gregtech.multiblock.incinerator.clogged" : "gregtech.multiblock.incinerator.working")); + } + + @Override + public void receiveCustomData(int dataId, @NotNull PacketBuffer buf) { + super.receiveCustomData(dataId, buf); + if (dataId == WORKING_ENABLED) { + this.isWorkingEnabled = buf.readBoolean(); + scheduleRenderUpdate(); + } else if (dataId == UPDATE_CLOGGED) { + this.isClogged = buf.readBoolean(); + scheduleRenderUpdate(); + } else if (dataId == UPDATE_ACTIVE) { + this.canProgress = buf.readBoolean(); + scheduleRenderUpdate(); + } + } + + @Override + public NBTTagCompound writeToNBT(NBTTagCompound data) { + data.setBoolean("workingEnabled", this.isWorkingEnabled); + data.setInteger("progress", this.progress); + data.setBoolean("isClogged", this.isClogged); + data.setBoolean("canProgress", this.canProgress); + return super.writeToNBT(data); + } + + + @Override + public void readFromNBT(NBTTagCompound data) { + super.readFromNBT(data); + this.isWorkingEnabled = data.getBoolean("workingEnabled"); + this.progress = data.getInteger("progress"); + this.isClogged = data.getBoolean("isClogged"); + this.canProgress = data.getBoolean("canProgress"); + } + + @Override + public void writeInitialSyncData(@NotNull PacketBuffer buf) { + super.writeInitialSyncData(buf); + buf.writeBoolean(this.isWorkingEnabled); + buf.writeInt(this.progress); + buf.writeBoolean(this.isClogged); + buf.writeBoolean(this.canProgress); + } + + @Override + public void receiveInitialSyncData(@NotNull PacketBuffer buf) { + super.receiveInitialSyncData(buf); + this.isWorkingEnabled = buf.readBoolean(); + this.progress = buf.readInt(); + this.isClogged = buf.readBoolean(); + this.canProgress = buf.readBoolean(); + } + + @Override + public T getCapability(Capability capability, EnumFacing side) { + if (capability == GregtechTileCapabilities.CAPABILITY_CONTROLLABLE) + return GregtechTileCapabilities.CAPABILITY_CONTROLLABLE.cast(this); + return super.getCapability(capability, side); + } + + @Override + public void addInformation(ItemStack stack, @Nullable World player, @NotNull List tooltip, boolean advanced) { + tooltip.add(I18n.format("gregtech.universal.tooltip.max_voltage_in", energyContainer.getInputVoltage(), GTValues.VNF[getTier()])); + tooltip.add(I18n.format("gregtech.universal.tooltip.energy_storage_capacity", energyContainer.getEnergyCapacity())); + tooltip.add(I18n.format("gregtech.universal.tooltip.item_storage_capacity", getInventorySize())); + tooltip.add(I18n.format("gregtech.machine.incinerator.tooltip.1", itemsPerRun, maxProgress)); + tooltip.add(I18n.format("gregtech.machine.incinerator.tooltip.2")); + tooltip.add(I18n.format("gregtech.machine.incinerator.tooltip.3")); + } +} diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front.png new file mode 100644 index 000000000..3fcac9642 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/roaster/roaster_bottom_active.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front_active.png similarity index 100% rename from src/main/resources/assets/gregtech/textures/blocks/machines/roaster/roaster_bottom_active.png rename to src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front_active.png diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front_active_emissive.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front_active_emissive.png new file mode 100644 index 000000000..abad930ae Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_front_active_emissive.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top.png new file mode 100644 index 000000000..e9b20bd48 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active.png new file mode 100644 index 000000000..df70d190c Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active_emissive.png b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active_emissive.png new file mode 100644 index 000000000..6d8fef6b4 Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/incinerator/overlay_top_active_emissive.png differ diff --git a/src/main/resources/assets/gregtech/textures/blocks/machines/roaster/overlay_bottom_active_emissive.png b/src/main/resources/assets/gregtech/textures/blocks/machines/roaster/overlay_bottom_active_emissive.png new file mode 100644 index 000000000..abad930ae Binary files /dev/null and b/src/main/resources/assets/gregtech/textures/blocks/machines/roaster/overlay_bottom_active_emissive.png differ diff --git a/src/main/resources/assets/susy/lang/en_us.lang b/src/main/resources/assets/susy/lang/en_us.lang index b3844da09..db0ce29ec 100644 --- a/src/main/resources/assets/susy/lang/en_us.lang +++ b/src/main/resources/assets/susy/lang/en_us.lang @@ -668,6 +668,16 @@ gregtech.machine.polishing_machine.opv.name=Legendary Polishing Machine gregtech.machine.bath_condenser.name=Bath Condenser gregtech.machine.bath_condenser.tooltip=Only works inside a Cryogenic Distillation Tower +gregtech.machine.incinerator.lv.name=Basic Incinerator +gregtech.machine.incinerator.mv.name=Advanced Incinerator +gregtech.machine.incinerator.hv.name=Advanced Incinerator II +gregtech.machine.incinerator.ev.name=Advanced Incinerator III +gregtech.machine.incinerator.tooltip.1=§6Incinerates§r %s item(s) per %s tick(s) +gregtech.machine.incinerator.tooltip.2=§cNeeds eight blocks of air to release gasses into +gregtech.machine.incinerator.tooltip.3=§8Don't worry about where the heavy metals are going. +gregtech.multiblock.incinerator.clogged=§4Clogged! (Is the top blocked?) +gregtech.multiblock.incinerator.working=§2Clog-free + # Recipemaps recipemap.coagulation_tank.name=Coagulation recipemap.latex_collector.name=Arboreal Collector