From 2cd8183c126748ea5d642038a82788dcbee0c61c Mon Sep 17 00:00:00 2001 From: drcrazy Date: Sat, 24 Aug 2019 01:41:40 +0300 Subject: [PATCH] Facelift for chunkloader. Closes #1806 --- .../machine/tier3/ChunkLoaderBlockEntity.java | 49 ++- .../java/techreborn/client/gui/GuiAESU.java | 6 - .../techreborn/client/gui/GuiChunkLoader.java | 93 ++--- .../techreborn/config/TechRebornConfig.java | 379 +++++++++--------- .../packets/ServerboundPackets.java | 43 +- 5 files changed, 310 insertions(+), 260 deletions(-) diff --git a/src/main/java/techreborn/blockentity/machine/tier3/ChunkLoaderBlockEntity.java b/src/main/java/techreborn/blockentity/machine/tier3/ChunkLoaderBlockEntity.java index 99570d7e7..aaac171d1 100644 --- a/src/main/java/techreborn/blockentity/machine/tier3/ChunkLoaderBlockEntity.java +++ b/src/main/java/techreborn/blockentity/machine/tier3/ChunkLoaderBlockEntity.java @@ -26,6 +26,7 @@ package techreborn.blockentity.machine.tier3; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; +import net.minecraft.nbt.CompoundTag; import net.minecraft.util.math.Direction; import reborncore.api.IToolDrop; import reborncore.api.blockentity.InventoryProvider; @@ -41,16 +42,50 @@ import techreborn.init.TRContent; public class ChunkLoaderBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider, IContainerProvider { public RebornInventory inventory = new RebornInventory<>(1, "ChunkLoaderBlockEntity", 64, this); + private int radius; public ChunkLoaderBlockEntity() { super(TRBlockEntities.CHUNK_LOADER ); + this.radius = 1; + } + + public void handleGuiInputFromClient(int buttonID) { + radius += buttonID; + + if (radius > TechRebornConfig.chunkLoaderMaxRadius) { + radius = TechRebornConfig.chunkLoaderMaxRadius; + } + if (radius <= 1) { + radius = 1; + } } @Override public ItemStack getToolDrop(final PlayerEntity entityPlayer) { return TRContent.Machine.CHUNK_LOADER.getStack(); } + + @Override + public void tick() { + super.tick(); + // TODO: chunkload + } + @Override + public CompoundTag toTag(CompoundTag tagCompound) { + super.toTag(tagCompound); + tagCompound.putInt("radius", radius); + inventory.write(tagCompound); + return tagCompound; + } + + @Override + public void fromTag(CompoundTag nbttagcompound) { + super.fromTag(nbttagcompound); + this.radius = nbttagcompound.getInt("radius"); + inventory.read(nbttagcompound); + } + @Override public double getBaseMaxPower() { return TechRebornConfig.chunkLoaderMaxEnergy; @@ -80,10 +115,18 @@ public class ChunkLoaderBlockEntity extends PowerAcceptorBlockEntity implements public RebornInventory getInventory() { return this.inventory; } + + public int getRadius() { + return radius; + } + + public void setRadius(int radius) { + this.radius = radius; + } @Override - public BuiltContainer createContainer(int syncID, final PlayerEntity player) { - return new ContainerBuilder("chunkloader").player(player.inventory).inventory(8,84).hotbar(8,142).addInventory() - .create(this, syncID); + public BuiltContainer createContainer(int syncID, PlayerEntity player) { + return new ContainerBuilder("chunkloader").player(player.inventory).inventory().hotbar().addInventory() + .blockEntity(this).energySlot(0, 8, 72).syncEnergyValue().syncIntegerValue(this::getRadius, this::setRadius).addInventory().create(this, syncID); } } diff --git a/src/main/java/techreborn/client/gui/GuiAESU.java b/src/main/java/techreborn/client/gui/GuiAESU.java index b006eac76..d57c858df 100644 --- a/src/main/java/techreborn/client/gui/GuiAESU.java +++ b/src/main/java/techreborn/client/gui/GuiAESU.java @@ -44,12 +44,6 @@ public class GuiAESU extends GuiBase { this.blockEntity = aesu; } - @Override - public void init() { - super.init(); - - } - @Override protected void drawBackground(final float f, final int mouseX, final int mouseY) { super.drawBackground(f, mouseX, mouseY); diff --git a/src/main/java/techreborn/client/gui/GuiChunkLoader.java b/src/main/java/techreborn/client/gui/GuiChunkLoader.java index 660a3d18e..8c968dffd 100644 --- a/src/main/java/techreborn/client/gui/GuiChunkLoader.java +++ b/src/main/java/techreborn/client/gui/GuiChunkLoader.java @@ -24,74 +24,51 @@ package techreborn.client.gui; -import com.mojang.blaze3d.platform.GlStateManager; -import net.minecraft.client.gui.screen.ingame.AbstractContainerScreen; -import net.minecraft.client.gui.widget.ButtonWidget; -import reborncore.common.util.StringUtils; import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.text.LiteralText; -import net.minecraft.util.Identifier; import reborncore.client.containerBuilder.builder.BuiltContainer; -import reborncore.client.gui.builder.widget.GuiButtonSimple; +import reborncore.client.gui.builder.GuiBase; +import reborncore.client.gui.builder.widget.GuiButtonUpDown; +import reborncore.common.network.NetworkManager; import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; +import techreborn.packets.ServerboundPackets; -public class GuiChunkLoader extends AbstractContainerScreen { +public class GuiChunkLoader extends GuiBase { - private static final Identifier texture = new Identifier("techreborn", - "textures/gui/industrial_chunkloader.png"); - ChunkLoaderBlockEntity chunkloader; - private ButtonWidget plusOneButton; - private ButtonWidget plusTenButton; - private ButtonWidget minusOneButton; - private ButtonWidget minusTenButton; + ChunkLoaderBlockEntity blockEntity; - public GuiChunkLoader(int syncID, final PlayerEntity player, final ChunkLoaderBlockEntity chunkLoader) { - super(chunkLoader.createContainer(syncID, player), player.inventory, new LiteralText("techreborn.chunkloader")); - this.containerWidth = 176; - this.containerHeight = 167; - this.chunkloader = chunkLoader; + public GuiChunkLoader(int syncID, PlayerEntity player, ChunkLoaderBlockEntity blockEntity) { + super(player, blockEntity, blockEntity.createContainer(syncID, player)); + this.blockEntity = blockEntity; } - + @Override - public void init() { - super.init(); - this.left = this.width / 2 - this.containerWidth / 2; - this.top = this.height / 2 - this.containerHeight / 2; - this.plusOneButton = new GuiButtonSimple(this.left + 5, this.top + 37, 40, 20, "+1", buttonWidget -> {}); - this.plusTenButton = new GuiButtonSimple(this.left + 45, this.top + 37, 40, 20, "+10", buttonWidget -> {}); - - this.minusOneButton = new GuiButtonSimple(this.left + 90, this.top + 37, 40, 20, "-1", buttonWidget -> {}); - this.minusTenButton = new GuiButtonSimple(this.left + 130, this.top + 37, 40, 20, "-10", buttonWidget -> {}); - - this.buttons.add(this.plusOneButton); - this.buttons.add(this.plusTenButton); - this.buttons.add(this.minusOneButton); - this.buttons.add(this.minusTenButton); + protected void drawBackground(float partialTicks, int mouseX, int mouseY) { + super.drawBackground(partialTicks, mouseX, mouseY); + final Layer layer = Layer.BACKGROUND; + + // Battery slot + drawSlot(8, 72, layer); + builder.drawUpDownButtons(this, 64, 40, layer); + if (GuiBase.slotConfigType != GuiBase.SlotConfigType.NONE) { + return; + } + String text = "Raidus: " + String.valueOf(blockEntity.getRadius()); + drawCentredString(text, 25, 4210752, layer); } - + @Override - protected void drawBackground(final float p_146976_1_, final int p_146976_2_, final int p_146976_3_) { - this.renderBackground(); - GlStateManager.color4f(1.0F, 1.0F, 1.0F, 1.0F); - minecraft.getTextureManager().bindTexture(GuiChunkLoader.texture); - final int k = (this.width - this.containerWidth) / 2; - final int l = (this.height - this.containerHeight) / 2; - this.blit(k, l, 0, 0, this.containerWidth, this.containerHeight); - } + protected void drawForeground(final int mouseX, final int mouseY) { + super.drawForeground(mouseX, mouseY); + final GuiBase.Layer layer = GuiBase.Layer.FOREGROUND; - @Override - protected void drawForeground(final int p_146979_1_, final int p_146979_2_) { - final String name = StringUtils.t("block.techreborn.chunk_loader"); - this.font.draw(name, this.containerWidth / 2 - this.font.getStringWidth(name) / 2, 6, - 4210752); - this.font.draw(StringUtils.t("container.inventory", new Object[0]), 8, - this.containerHeight - 96 + 2, 4210752); + builder.drawMultiEnergyBar(this, 9, 19, (int) blockEntity.getEnergy(), (int) blockEntity.getMaxPower(), mouseX, mouseY, 0, layer); + addButton(new GuiButtonUpDown(left + 64, top + 40, this, b -> onClick(5))); + addButton(new GuiButtonUpDown(left + 64 + 12, top + 40, this, b -> onClick(1))); + addButton(new GuiButtonUpDown(left + 64 + 24, top + 40, this, b -> onClick(-1))); + addButton(new GuiButtonUpDown(left + 64 + 36, top + 40, this, b -> onClick(-5))); } - - @Override - public void render(int mouseX, int mouseY, float partialTicks) { - super.render(mouseX, mouseY, partialTicks); - this.drawMouseoverTooltip(mouseX, mouseY); - } - + + public void onClick(int amount){ + NetworkManager.sendToServer(ServerboundPackets.createPacketChunkloader(amount, blockEntity)); + } } diff --git a/src/main/java/techreborn/config/TechRebornConfig.java b/src/main/java/techreborn/config/TechRebornConfig.java index 3be810c7e..286c60e8a 100644 --- a/src/main/java/techreborn/config/TechRebornConfig.java +++ b/src/main/java/techreborn/config/TechRebornConfig.java @@ -28,7 +28,150 @@ import reborncore.common.config.Config; //All moved into one class as its a lot easier to find the annotations when you know where they all are public class TechRebornConfig { + + // Generators + @Config(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in FE)") + public static int basicGenerationRateD = 1; + + @Config(config = "generators", category = "solarPanelBasic", key = "basicNightRate", comment = "Generation rate during night for Basic Solar Panel (Value in FE)") + public static int basicGenerationRateN = 0; + + @Config(config = "generators", category = "solarPanelAdvanced", key = "advancedDayRate", comment = "Generation rate during day for Advanced Solar Panel (Value in FE)") + public static int advancedGenerationRateD = 16; + + @Config(config = "generators", category = "solarPanelAdvanced", key = "advancedNightRate", comment = "Generation rate during night for Advanced Solar Panel (Value in FE)") + public static int advancedGenerationRateN = 0; + + @Config(config = "generators", category = "solarPanelIndustrial", key = "industrialDayRate", comment = "Generation rate during day for Industrial Solar Panel (Value in FE)") + public static int industrialGenerationRateD = 64; + + @Config(config = "generators", category = "solarPanelIndustrial", key = "industrialNightRate", comment = "Generation rate during night for Industrial Solar Panel (Value in FE)") + public static int industrialGenerationRateN = 2; + + @Config(config = "generators", category = "solarPanelUltimate", key = "ultimateDayRate", comment = "Generation rate during day for Ultimate Solar Panel (Value in FE)") + public static int ultimateGenerationRateD = 256; + + @Config(config = "generators", category = "solarPanelUltimate", key = "ultimateNightRate", comment = "Generation rate during night for Ultimate Solar Panel (Value in FE)") + public static int ultimateGenerationRateN = 16; + + @Config(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in FE)") + public static int quantumGenerationRateD = 1024; + + @Config(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in FE)") + public static int quantumGenerationRateN = 64; + + @Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxOutput", comment = "Lightning Rod Max Output (Value in EU)") + public static int lightningRodMaxOutput = 2048; + @Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxEnergy", comment = "Lightning Rod Max Energy (Value in EU)") + public static int lightningRodMaxEnergy = 100_000_000; + + @Config(config = "generators", category = "lightning_rod", key = "LightningRodChanceOfStrike", comment = "Chance of lightning striking a rod (Range: 0-70)") + public static int lightningRodChanceOfStrike = 24; + + @Config(config = "generators", category = "lightning_rod", key = "LightningRodBaseStrikeEnergy", comment = "Base amount of energy per strike (Value in EU)") + public static int lightningRodBaseEnergyStrike = 262_144; + + @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxOutput", comment = "Thermal Generator Max Output (Value in EU)") + public static int thermalGeneratorMaxOutput = 128; + + @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)") + public static int thermalGeneratorMaxEnergy = 1_000_000; + + @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorTankCapacity", comment = "Thermal Generator Tank Capacity") + public static int thermalGeneratorTankCapacity = 10_000; + + @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)") + public static int thermalGeneratorEnergyPerTick = 16; + + @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxOutput", comment = "Plasma Generator Max Output (Value in EU)") + public static int plasmaGeneratorMaxOutput = 2048; + + @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy (Value in EU)") + public static double plasmaGeneratorMaxEnergy = 500_000_000; + + @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorTankCapacity", comment = "Plasma Generator Tank Capacity") + public static int plasmaGeneratorTankCapacity = 10_000; + + @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick (Value in EU)") + public static int plasmaGeneratorEnergyPerTick = 400; + + @Config(config = "generators", category = "wind_mill", key = "WindMillMaxOutput", comment = "Wind Mill Max Output (Value in EU)") + public static int windMillMaxOutput = 128; + + @Config(config = "generators", category = "wind_mill", key = "WindMillMaxEnergy", comment = "Wind Mill Max Energy (Value in EU)") + public static int windMillMaxEnergy = 10_000; + + @Config(config = "generators", category = "wind_mill", key = "WindMillEnergyPerTick", comment = "Wind Mill Energy Per Tick (Value in EU)") + public static int windMillBaseEnergy = 2; + + @Config(config = "generators", category = "wind_mill", key = "WindMillThunderMultiplier", comment = "Wind Mill Thunder Multiplier") + public static double windMillThunderMultiplier = 1.25; + + @Config(config = "generators", category = "water_mill", key = "WaterMillMaxOutput", comment = "Water Mill Max Output (Value in EU)") + public static int waterMillMaxOutput = 32; + + @Config(config = "generators", category = "water_mill", key = "WaterMillMaxEnergy", comment = "Water Mill Max Energy (Value in EU)") + public static int waterMillMaxEnergy = 1000; + + @Config(config = "generators", category = "water_mill", key = "WaterMillEnergyPerTick", comment = "Water Mill Energy Multiplier") + public static double waterMillEnergyMultiplier = 0.1; + + @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxOutput", comment = "Semifluid Generator Max Output (Value in EU)") + public static int semiFluidGeneratorMaxOutput = 128; + + @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxEnergy", comment = "Semifluid Generator Max Energy (Value in EU)") + public static int semiFluidGeneratorMaxEnergy = 1000000; + + @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorTankCapacity", comment = "Semifluid Generator Tank Capacity") + public static int semiFluidGeneratorTankCapacity = 10000; + + @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)") + public static int semiFluidGeneratorEnergyPerTick = 8; + + @Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxOutput", comment = "Gas Generator Max Output (Value in EU)") + public static int gasTurbineMaxOutput = 128; + + @Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxEnergy", comment = "Gas Generator Max Energy (Value in EU)") + public static int gasTurbineMaxEnergy = 1000000; + + @Config(config = "generators", category = "gas_generator", key = "GasGeneratorTankCapacity", comment = "Gas Generator Tank Capacity") + public static int gasTurbineTankCapacity = 10000; + + @Config(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)") + public static int gasTurbineEnergyPerTick = 16; + + @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxOutput", comment = "Diesel Generator Max Output (Value in EU)") + public static int dieselGeneratorMaxOutput = 32; + + @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)") + public static int dieselGeneratorMaxEnergy = 10_000; + + @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorTankCapacity", comment = "Diesel Generator Tank Capacity") + public static int dieselGeneratorTankCapacity = 10_000; + + @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)") + public static int dieselGeneratorEnergyPerTick = 20; + + @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)") + public static int dragonEggSyphonMaxOutput = 128; + + @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxEnergy", comment = "Dragon Egg Siphoner Max Energy (Value in EU)") + public static int dragonEggSyphonMaxEnergy = 1000; + + @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerEnergyPerTick", comment = "Dragon Egg Siphoner Energy Per Tick (Value in EU)") + public static int dragonEggSyphonEnergyPerTick = 4; + + @Config(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)") + public static int solidFuelGeneratorMaxOutput = 32; + + @Config(config = "generators", category = "generator", key = "GeneratorMaxEnergy", comment = "Solid Fuel Generator Max Energy (Value in EU)") + public static int solidFuelGeneratorMaxEnergy = 10_000; + + @Config(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)") + public static int solidFuelGeneratorOutputAmount = 10; + + // Items @Config(config = "items", category = "general", key = "enableGemTools", comment = "Enable Gem armor and tools") public static boolean enableGemArmorAndTools = true; @@ -88,76 +231,27 @@ public class TechRebornConfig { @Config(config = "items", category = "power", key = "clockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (FE)") public static int cloackingDeviceUsage = 10; + + @Config(config = "items", category = "upgrades", key = "overclcoker_speed", comment = "Overclocker behavior speed multipiler") + public static double overclockerSpeed = 0.25; - @Config(config = "generators", category = "solarPanelBasic", key = "basicDayRate", comment = "Generation rate during day for Basic Solar Panel (Value in FE)") - public static int basicGenerationRateD = 1; - - @Config(config = "generators", category = "solarPanelBasic", key = "basicNightRate", comment = "Generation rate during night for Basic Solar Panel (Value in FE)") - public static int basicGenerationRateN = 0; - - @Config(config = "generators", category = "solarPanelAdvanced", key = "advancedDayRate", comment = "Generation rate during day for Advanced Solar Panel (Value in FE)") - public static int advancedGenerationRateD = 16; - - @Config(config = "generators", category = "solarPanelAdvanced", key = "advancedNightRate", comment = "Generation rate during night for Advanced Solar Panel (Value in FE)") - public static int advancedGenerationRateN = 0; - - @Config(config = "generators", category = "solarPanelIndustrial", key = "industrialDayRate", comment = "Generation rate during day for Industrial Solar Panel (Value in FE)") - public static int industrialGenerationRateD = 64; - - @Config(config = "generators", category = "solarPanelIndustrial", key = "industrialNightRate", comment = "Generation rate during night for Industrial Solar Panel (Value in FE)") - public static int industrialGenerationRateN = 2; - - @Config(config = "generators", category = "solarPanelUltimate", key = "ultimateDayRate", comment = "Generation rate during day for Ultimate Solar Panel (Value in FE)") - public static int ultimateGenerationRateD = 256; - - @Config(config = "generators", category = "solarPanelUltimate", key = "ultimateNightRate", comment = "Generation rate during night for Ultimate Solar Panel (Value in FE)") - public static int ultimateGenerationRateN = 16; - - @Config(config = "generators", category = "solarPanelQuantum", key = "quantumDayRate", comment = "Generation rate during day for Quantum Solar Panel (Value in FE)") - public static int quantumGenerationRateD = 1024; - - @Config(config = "generators", category = "solarPanelQuantum", key = "quantumNightRate", comment = "Generation rate during night for Quantum Solar Panel (Value in FE)") - public static int quantumGenerationRateN = 64; + @Config(config = "items", category = "upgrades", key = "overclcoker_power", comment = "Overclocker behavior power multipiler") + public static double overclockerPower = 0.75; - @Config(config = "world", category = "loot", key = "enableOverworldLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to OverWorld loot chests.") - public static boolean enableOverworldLoot = true; + @Config(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage behavior extra power") + public static double energyStoragePower = 40_000; - @Config(config = "world", category = "loot", key = "enableNetherLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to Nether loot chests.") - public static boolean enableNetherLoot = true; - - @Config(config = "world", category = "loot", key = "enableEndLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to The End loot chests.") - public static boolean enableEndLoot = true; - @Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxOutput", comment = "Lightning Rod Max Output (Value in EU)") - public static int lightningRodMaxOutput = 2048; - @Config(config = "generators", category = "lightning_rod", key = "LightningRodMaxEnergy", comment = "Lightning Rod Max Energy (Value in EU)") - public static int lightningRodMaxEnergy = 100_000_000; - @Config(config = "generators", category = "lightning_rod", key = "LightningRodChanceOfStrike", comment = "Chance of lightning striking a rod (Range: 0-70)") - public static int lightningRodChanceOfStrike = 24; - - @Config(config = "generators", category = "lightning_rod", key = "LightningRodBaseStrikeEnergy", comment = "Base amount of energy per strike (Value in EU)") - public static int lightningRodBaseEnergyStrike = 262_144; + // Machines @Config(config = "machines", category = "grinder", key = "GrinderInput", comment = "Grinder Max Input (Value in EU)") public static int grinderMaxInput = 32; @Config(config = "machines", category = "grinder", key = "GrinderMaxEnergy", comment = "Grinder Max Energy (Value in EU)") public static int grinderMaxEnergy = 1_000; - @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxOutput", comment = "Thermal Generator Max Output (Value in EU)") - public static int thermalGeneratorMaxOutput = 128; - - @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorMaxEnergy", comment = "Thermal Generator Max Energy (Value in EU)") - public static int thermalGeneratorMaxEnergy = 1_000_000; - - @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorTankCapacity", comment = "Thermal Generator Tank Capacity") - public static int thermalGeneratorTankCapacity = 10_000; - - @Config(config = "generators", category = "thermal_generator", key = "ThermalGeneratorEnergyPerTick", comment = "Thermal Generator Energy Per Tick (Value in EU)") - public static int thermalGeneratorEnergyPerTick = 16; - @Config(config = "machines", category = "lesu", key = "LesuMaxOutput", comment = "LESU Base Output (Value in EU)") public static int lesuBaseOutput = 16; @@ -167,9 +261,6 @@ public class TechRebornConfig { @Config(config = "machines", category = "lesu", key = "LesuExtraIO", comment = "LESU Extra I/O Multiplier") public static int lesuExtraIOPerBlock = 8; - @Config(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.") - public static boolean IC2TransformersStyle = true; - @Config(config = "machines", category = "aesu", key = "AesuMaxInput", comment = "AESU Max Input (Value in EU)") public static int aesuMaxInput = 16192; @@ -203,18 +294,6 @@ public class TechRebornConfig { @Config(config = "machines", category = "extractor", key = "ExtractorMaxEnergy", comment = "Extractor Max Energy (Value in EU)") public static int extractorMaxEnergy = 1_000; - @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxOutput", comment = "Semifluid Generator Max Output (Value in EU)") - public static int semiFluidGeneratorMaxOutput = 128; - - @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorMaxEnergy", comment = "Semifluid Generator Max Energy (Value in EU)") - public static int semiFluidGeneratorMaxEnergy = 1000000; - - @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorTankCapacity", comment = "Semifluid Generator Tank Capacity") - public static int semiFluidGeneratorTankCapacity = 10000; - - @Config(config = "generators", category = "semifluid_generator", key = "SemifluidGeneratorEnergyPerTick", comment = "Semifluid Generator Energy Per Tick (Value in EU)") - public static int semiFluidGeneratorEnergyPerTick = 8; - @Config(config = "machines", category = "compressor", key = "CompressorInput", comment = "Compressor Max Input (Value in EU)") public static int compressorMaxInput = 32; @@ -239,36 +318,21 @@ public class TechRebornConfig { @Config(config = "machines", category = "rolling_machine", key = "RollingMachineMaxEnergy", comment = "Rolling Machine Max Energy (Value in EU)") public static int rollingMachineMaxEnergy = 10000; - @Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input (Value in EU)") + @Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxInput", comment = "Chunk Loader Max Input") public static int chunkLoaderMaxInput = 32; - @Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxEnergy", comment = "Chunk Loader Max Energy (Value in EU)") + @Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxEnergy", comment = "Chunk Loader Max Energy") public static int chunkLoaderMaxEnergy = 10_000; - - @Config(config = "generators", category = "water_mill", key = "WaterMillMaxOutput", comment = "Water Mill Max Output (Value in EU)") - public static int waterMillMaxOutput = 32; - - @Config(config = "generators", category = "water_mill", key = "WaterMillMaxEnergy", comment = "Water Mill Max Energy (Value in EU)") - public static int waterMillMaxEnergy = 1000; - - @Config(config = "generators", category = "water_mill", key = "WaterMillEnergyPerTick", comment = "Water Mill Energy Multiplier") - public static double waterMillEnergyMultiplier = 0.1; - + + @Config(config = "machines", category = "chunk_loader", key = "ChunkLoaderMaxRadius", comment = "Chunk Loader Max Radius") + public static int chunkLoaderMaxRadius = 10; + @Config(config = "machines", category = "assembling_machine", key = "AssemblingMachineMaxInput", comment = "Assembling Machine Max Input (Value in EU)") public static int assemblingMachineMaxInput = 128; @Config(config = "machines", category = "assembling_machine", key = "AssemblingMachineMaxEnergy", comment = "Assembling Machine Max Energy (Value in EU)") public static int assemblingMachineMaxEnergy = 10_000; - @Config(config = "misc", category = "nuke", key = "fusetime", comment = "Nuke fuse time (ticks)") - public static int nukeFuseTime = 400; - - @Config(config = "misc", category = "nuke", key = "radius", comment = "Nuke explision radius") - public static int nukeRadius = 40; - - @Config(config = "misc", category = "nuke", key = "enabled", comment = "Should the nuke explode, set to false to prevent block damage") - public static boolean nukeEnabled = true; - @Config(config = "machines", category = "matter_fabricator", key = "MatterFabricatorMaxInput", comment = "Matter Fabricator Max Input (Value in EU)") public static int matterFabricatorMaxInput = 8192; @@ -305,33 +369,12 @@ public class TechRebornConfig { @Config(config = "machines", category = "industrial_furnace", key = "IndustrialFurnaceMaxEnergy", comment = "Industrial Blast Furnace Max Energy (Value in EU)") public static int industrialBlastFurnaceMaxEnergy = 40_000; - @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxOutput", comment = "Diesel Generator Max Output (Value in EU)") - public static int dieselGeneratorMaxOutput = 32; - - @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorMaxEnergy", comment = "Diesel Generator Max Energy (Value in EU)") - public static int dieselGeneratorMaxEnergy = 10_000; - - @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorTankCapacity", comment = "Diesel Generator Tank Capacity") - public static int dieselGeneratorTankCapacity = 10_000; - - @Config(config = "generators", category = "diesel_generator", key = "DieselGeneratorEnergyPerTick", comment = "Diesel Generator Energy Per Tick (Value in EU)") - public static int dieselGeneratorEnergyPerTick = 20; - @Config(config = "machines", category = "industrial_sawmill", key = "IndustrialSawmillMaxInput", comment = "Industrial Sawmill Max Input (Value in EU)") public static int industrialSawmillMaxInput = 128; @Config(config = "machines", category = "industrial_sawmill", key = "IndustrialSawmillMaxEnergy", comment = "Industrial Sawmill Max Energy (Value in EU)") public static int industrialSawmillMaxEnergy = 10_000; - @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxOutput", comment = "Dragon Egg Siphoner Max Output (Value in EU)") - public static int dragonEggSyphonMaxOutput = 128; - - @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerMaxEnergy", comment = "Dragon Egg Siphoner Max Energy (Value in EU)") - public static int dragonEggSyphonMaxEnergy = 1000; - - @Config(config = "generators", category = "dragon_egg_siphoner", key = "DragonEggSiphonerEnergyPerTick", comment = "Dragon Egg Siphoner Energy Per Tick (Value in EU)") - public static int dragonEggSyphonEnergyPerTick = 4; - @Config(config = "machines", category = "autocrafter", key = "AutoCrafterInput", comment = "AutoCrafting Table Max Input (Value in EU)") public static int autoCraftingTableMaxInput = 32; @@ -344,24 +387,12 @@ public class TechRebornConfig { @Config(config = "machines", category = "fluidreplicator", key = "FluidReplicatorMaxEnergy", comment = "Fluid Replicator Max Energy (Value in EU)") public static int fluidReplicatorMaxEnergy = 400_000; - @Config(config = "misc", category = "general", key = "DispenserScrapbox", comment = "Dispensers will open scrapboxes") - public static boolean dispenseScrapboxes = true; - @Config(config = "machines", category = "electric_furnace", key = "ElectricFurnaceInput", comment = "Electric Furnace Max Input (Value in EU)") public static int electricFurnaceMaxInput = 32; @Config(config = "machines", category = "electric_furnace", key = "ElectricFurnaceMaxEnergy", comment = "Electric Furnace Max Energy (Value in EU)") public static int electricFurnaceMaxEnergy = 1000; - @Config(config = "generators", category = "generator", key = "GeneratorMaxOutput", comment = "Solid Fuel Generator Max Output (Value in EU)") - public static int solidFuelGeneratorMaxOutput = 32; - - @Config(config = "generators", category = "generator", key = "GeneratorMaxEnergy", comment = "Solid Fuel Generator Max Energy (Value in EU)") - public static int solidFuelGeneratorMaxEnergy = 10_000; - - @Config(config = "generators", category = "generator", key = "GeneratorEnergyOutput", comment = "Solid Fuel Generator Energy Output Amount (Value in EU)") - public static int solidFuelGeneratorOutputAmount = 10; - @Config(config = "machines", category = "quantum_tank", key = "QuantumTankMaxStorage", comment = "Maximum amount of millibuckets a Quantum Tank can store") public static int quantumTankMaxStorage = Integer.MAX_VALUE; @@ -383,33 +414,12 @@ public class TechRebornConfig { @Config(config = "machines", category = "industrial_electrolyzer", key = "IndustrialElectrolyzerMaxEnergy", comment = "Industrial Electrolyzer Max Energy (Value in EU)") public static int industrialElectrolyzerMaxEnergy = 10_000; - @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionDamage", comment = "When true an uninsulated cable will cause damage to entities") - public static boolean uninsulatedElectrocutionDamage = true; - - @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionSound", comment = "When true an uninsulated cable will create a spark sound when an entity touches it") - public static boolean uninsulatedElectrocutionSound = true; - - @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionParticles", comment = "When true an uninsulated cable will create a spark when an entity touches it") - public static boolean uninsulatedElectrocutionParticles = true; - @Config(config = "machines", category = "centrifuge", key = "CentrifugeMaxInput", comment = "Centrifuge Max Input (Value in EU)") public static int industrialCentrifugeMaxInput = 32; @Config(config = "machines", category = "centrifuge", key = "CentrifugeMaxEnergy", comment = "Centrifuge Max Energy (Value in EU)") public static int industrialCentrifugeMaxEnergy = 10_000; - @Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxOutput", comment = "Gas Generator Max Output (Value in EU)") - public static int gasTurbineMaxOutput = 128; - - @Config(config = "generators", category = "gas_generator", key = "GasGeneratorMaxEnergy", comment = "Gas Generator Max Energy (Value in EU)") - public static int gasTurbineMaxEnergy = 1000000; - - @Config(config = "generators", category = "gas_generator", key = "GasGeneratorTankCapacity", comment = "Gas Generator Tank Capacity") - public static int gasTurbineTankCapacity = 10000; - - @Config(config = "generators", category = "gas_generator", key = "GasGeneratorEnergyPerTick", comment = "Gas Generator Energy Per Tick (Value in EU)") - public static int gasTurbineEnergyPerTick = 16; - @Config(config = "machines", category = "chemical_reactor", key = "ChemicalReactorMaxInput", comment = "Chemical Reactor Max Input (Value in EU)") public static int chemicalReactorMaxInput = 128; @@ -437,30 +447,6 @@ public class TechRebornConfig { @Config(config = "machines", category = "fusion_reactor", key = "FusionReactorMaxCoilSize", comment = "Fusion Reactor Max Coil size (Radius)") public static int fusionControlComputerMaxCoilSize = 50; - @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxOutput", comment = "Plasma Generator Max Output (Value in EU)") - public static int plasmaGeneratorMaxOutput = 2048; - - @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorMaxEnergy", comment = "Plasma Generator Max Energy (Value in EU)") - public static double plasmaGeneratorMaxEnergy = 500_000_000; - - @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorTankCapacity", comment = "Plasma Generator Tank Capacity") - public static int plasmaGeneratorTankCapacity = 10_000; - - @Config(config = "generators", category = "plasma_generator", key = "PlasmaGeneratorEnergyPerTick", comment = "Plasma Generator Energy Per Tick (Value in EU)") - public static int plasmaGeneratorEnergyPerTick = 400; - - @Config(config = "generators", category = "wind_mill", key = "WindMillMaxOutput", comment = "Wind Mill Max Output (Value in EU)") - public static int windMillMaxOutput = 128; - - @Config(config = "generators", category = "wind_mill", key = "WindMillMaxEnergy", comment = "Wind Mill Max Energy (Value in EU)") - public static int windMillMaxEnergy = 10_000; - - @Config(config = "generators", category = "wind_mill", key = "WindMillEnergyPerTick", comment = "Wind Mill Energy Per Tick (Value in EU)") - public static int windMillBaseEnergy = 2; - - @Config(config = "generators", category = "wind_mill", key = "WindMillThunderMultiplier", comment = "Wind Mill Thunder Multiplier") - public static double windMillThunderMultiplier = 1.25; - @Config(config = "machines", category = "recycler", key = "RecyclerInput", comment = "Recycler Max Input (Value in EU)") public static int recyclerMaxInput = 32; @@ -473,21 +459,48 @@ public class TechRebornConfig { @Config(config = "machines", category = "scrapboxinator", key = "ScrapboxinatorMaxEnergy", comment = "Scrapboxinator Max Energy (Value in EU)") public static int scrapboxinatorMaxEnergy = 1_000; - @Config(config = "items", category = "upgrades", key = "overclcoker_speed", comment = "Overclocker behavior speed multipiler") - public static double overclockerSpeed = 0.25; - - @Config(config = "items", category = "upgrades", key = "overclcoker_power", comment = "Overclocker behavior power multipiler") - public static double overclockerPower = 0.75; - - @Config(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage behavior extra power") - public static double energyStoragePower = 40_000; - - @Config(config = "misc", category = "general", key = "manualRefund", comment = "Allow refunding items used to craft the manual") - public static boolean allowManualRefund = true; - @Config(config = "machines", category = "solid_canning_machine", key = "solidCanningMachineMaxInput", comment = "Solid Canning Machine Max Input (Value in EU)") public static int solidCanningMachineMaxInput = 32; @Config(config = "machines", category = "solid_canning_machine", key = "solidCanningMachineMaxInput", comment = "Solid Canning Machine Max Energy (Value in EU)") public static int solidCanningMachineMaxEnergy = 1_000; + + + // Misc + @Config(config = "misc", category = "general", key = "IC2TransformersStyle", comment = "Input from dots side, output from other sides, like in IC2.") + public static boolean IC2TransformersStyle = true; + + @Config(config = "misc", category = "general", key = "manualRefund", comment = "Allow refunding items used to craft the manual") + public static boolean allowManualRefund = true; + + @Config(config = "misc", category = "nuke", key = "fusetime", comment = "Nuke fuse time (ticks)") + public static int nukeFuseTime = 400; + + @Config(config = "misc", category = "nuke", key = "radius", comment = "Nuke explision radius") + public static int nukeRadius = 40; + + @Config(config = "misc", category = "nuke", key = "enabled", comment = "Should the nuke explode, set to false to prevent block damage") + public static boolean nukeEnabled = true; + + @Config(config = "misc", category = "general", key = "DispenserScrapbox", comment = "Dispensers will open scrapboxes") + public static boolean dispenseScrapboxes = true; + + @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionDamage", comment = "When true an uninsulated cable will cause damage to entities") + public static boolean uninsulatedElectrocutionDamage = true; + + @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionSound", comment = "When true an uninsulated cable will create a spark sound when an entity touches it") + public static boolean uninsulatedElectrocutionSound = true; + + @Config(config = "misc", category = "cable", key = "uninsulatedElectrocutionParticles", comment = "When true an uninsulated cable will create a spark when an entity touches it") + public static boolean uninsulatedElectrocutionParticles = true; + + // World + @Config(config = "world", category = "loot", key = "enableOverworldLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to OverWorld loot chests.") + public static boolean enableOverworldLoot = true; + + @Config(config = "world", category = "loot", key = "enableNetherLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to Nether loot chests.") + public static boolean enableNetherLoot = true; + + @Config(config = "world", category = "loot", key = "enableEndLoot", comment = "When true TechReborn will add ingots, machine frames and circuits to The End loot chests.") + public static boolean enableEndLoot = true; } diff --git a/src/main/java/techreborn/packets/ServerboundPackets.java b/src/main/java/techreborn/packets/ServerboundPackets.java index bd166d1a9..347dfc1a8 100644 --- a/src/main/java/techreborn/packets/ServerboundPackets.java +++ b/src/main/java/techreborn/packets/ServerboundPackets.java @@ -31,13 +31,16 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.network.Packet; +import net.minecraft.network.listener.ServerPlayPacketListener; import net.minecraft.util.Identifier; import net.minecraft.util.math.BlockPos; import reborncore.common.network.ExtendedPacketBuffer; import reborncore.common.network.NetworkManager; +import techreborn.TechReborn; import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity; import techreborn.blockentity.machine.tier1.AutoCraftingTableBlockEntity; import techreborn.blockentity.machine.tier1.RollingMachineBlockEntity; +import techreborn.blockentity.machine.tier3.ChunkLoaderBlockEntity; import techreborn.blockentity.storage.AdjustableSUBlockEntity; import techreborn.config.TechRebornConfig; import techreborn.init.TRContent; @@ -46,11 +49,12 @@ import java.util.function.BiConsumer; public class ServerboundPackets { - public static final Identifier AESU = new Identifier("techreborn", "aesu"); - public static final Identifier AUTO_CRAFTING_LOCK = new Identifier("techreborn", "auto_crafting_lock"); - public static final Identifier ROLLING_MACHINE_LOCK = new Identifier("techreborn", "rolling_machine_lock"); - public static final Identifier FUSION_CONTROL_SIZE = new Identifier("techreborn", "fusion_control_size"); - public static final Identifier REFUND = new Identifier("techreborn", "refund"); + public static final Identifier AESU = new Identifier(TechReborn.MOD_ID, "aesu"); + public static final Identifier AUTO_CRAFTING_LOCK = new Identifier(TechReborn.MOD_ID, "auto_crafting_lock"); + public static final Identifier ROLLING_MACHINE_LOCK = new Identifier(TechReborn.MOD_ID, "rolling_machine_lock"); + public static final Identifier FUSION_CONTROL_SIZE = new Identifier(TechReborn.MOD_ID, "fusion_control_size"); + public static final Identifier REFUND = new Identifier(TechReborn.MOD_ID, "refund"); + public static final Identifier CHUNKLOADER = new Identifier(TechReborn.MOD_ID, "chunkloader"); public static void init() { registerPacketHandler(AESU, (extendedPacketBuffer, context) -> { @@ -121,13 +125,25 @@ public class ServerboundPackets { }); }); + + registerPacketHandler(CHUNKLOADER, (extendedPacketBuffer, context) -> { + BlockPos pos = extendedPacketBuffer.readBlockPos(); + int buttonID = extendedPacketBuffer.readInt(); + + context.getTaskQueue().execute(() -> { + BlockEntity blockEntity = context.getPlayer().world.getBlockEntity(pos); + if (blockEntity instanceof ChunkLoaderBlockEntity) { + ((ChunkLoaderBlockEntity) blockEntity).handleGuiInputFromClient(buttonID); + } + }); + }); } private static void registerPacketHandler(Identifier identifier, BiConsumer consumer){ ServerSidePacketRegistry.INSTANCE.register(identifier, (packetContext, packetByteBuf) -> consumer.accept(new ExtendedPacketBuffer(packetByteBuf), packetContext)); } - public static Packet createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) { + public static Packet createPacketAesu(int buttonID, boolean shift, boolean ctrl, AdjustableSUBlockEntity blockEntity) { return NetworkManager.createServerBoundPacket(AESU, extendedPacketBuffer -> { extendedPacketBuffer.writeBlockPos(blockEntity.getPos()); extendedPacketBuffer.writeInt(buttonID); @@ -136,14 +152,14 @@ public class ServerboundPackets { }); } - public static Packet createPacketAutoCraftingTableLock(AutoCraftingTableBlockEntity machine, boolean locked) { + public static Packet createPacketAutoCraftingTableLock(AutoCraftingTableBlockEntity machine, boolean locked) { return NetworkManager.createServerBoundPacket(AUTO_CRAFTING_LOCK, extendedPacketBuffer -> { extendedPacketBuffer.writeBlockPos(machine.getPos()); extendedPacketBuffer.writeBoolean(locked); }); } - public static Packet createPacketFusionControlSize(int sizeDelta, BlockPos pos) { + public static Packet createPacketFusionControlSize(int sizeDelta, BlockPos pos) { return NetworkManager.createServerBoundPacket(FUSION_CONTROL_SIZE, extendedPacketBuffer -> { extendedPacketBuffer.writeInt(sizeDelta); extendedPacketBuffer.writeBlockPos(pos); @@ -151,17 +167,24 @@ public class ServerboundPackets { } - public static Packet createPacketRollingMachineLock(RollingMachineBlockEntity machine, boolean locked) { + public static Packet createPacketRollingMachineLock(RollingMachineBlockEntity machine, boolean locked) { return NetworkManager.createServerBoundPacket(ROLLING_MACHINE_LOCK, extendedPacketBuffer -> { extendedPacketBuffer.writeBlockPos(machine.getPos()); extendedPacketBuffer.writeBoolean(locked); }); } - public static Packet createRefundPacket(){ + public static Packet createRefundPacket(){ return NetworkManager.createServerBoundPacket(REFUND, extendedPacketBuffer -> { }); } + + public static Packet createPacketChunkloader(int buttonID, ChunkLoaderBlockEntity blockEntity) { + return NetworkManager.createServerBoundPacket(CHUNKLOADER, extendedPacketBuffer -> { + extendedPacketBuffer.writeBlockPos(blockEntity.getPos()); + extendedPacketBuffer.writeInt(buttonID); + }); + } }