From 883c8ae42048e7ee7e431718aba7f0f32960417d Mon Sep 17 00:00:00 2001 From: Hexeption Date: Sat, 3 Apr 2021 19:03:29 +0100 Subject: [PATCH] Added the Wither Builder (#1065) * Added Wither Builder * Fixed Tooltip lang with the Mob Duplicator * Fixed Power of the Wither Builder it was using the wrong config * Readded removed files --- .../blockstates/wither_builder.json | 19 ++ .../models/item/wither_builder.json | 3 + .../loot_tables/blocks/wither_builder.json | 19 ++ .../recipes/wither_builder.json | 46 +++++ .../WitherBuilderBlock.java | 46 +++++ .../tile/MobDuplicatorTile.java | 2 +- .../tile/WitherBuilderTile.java | 165 ++++++++++++++++++ .../WitherBuilderConfig.java | 19 ++ .../module/ModuleAgricultureHusbandry.java | 2 + .../industrialforegoing/lang/en_us.json | 2 +- .../en_us/entries/agr_hus/wither_builder.json | 16 ++ 11 files changed, 337 insertions(+), 2 deletions(-) create mode 100644 src/generated/resources/assets/industrialforegoing/blockstates/wither_builder.json create mode 100644 src/generated/resources/assets/industrialforegoing/models/item/wither_builder.json create mode 100644 src/generated/resources/data/industrialforegoing/loot_tables/blocks/wither_builder.json create mode 100644 src/generated/resources/data/industrialforegoing/recipes/wither_builder.json create mode 100644 src/main/java/com/buuz135/industrial/block/agriculturehusbandry/WitherBuilderBlock.java create mode 100644 src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/WitherBuilderTile.java create mode 100644 src/main/java/com/buuz135/industrial/config/machine/agriculturehusbandry/WitherBuilderConfig.java create mode 100644 src/main/resources/data/industrialforegoing/patchouli_books/industrial_foregoing/en_us/entries/agr_hus/wither_builder.json diff --git a/src/generated/resources/assets/industrialforegoing/blockstates/wither_builder.json b/src/generated/resources/assets/industrialforegoing/blockstates/wither_builder.json new file mode 100644 index 000000000..3cf9a612e --- /dev/null +++ b/src/generated/resources/assets/industrialforegoing/blockstates/wither_builder.json @@ -0,0 +1,19 @@ +{ + "variants": { + "subfacing=north": { + "model": "industrialforegoing:block/wither_builder" + }, + "subfacing=south": { + "model": "industrialforegoing:block/wither_builder", + "y": 180 + }, + "subfacing=west": { + "model": "industrialforegoing:block/wither_builder", + "y": 270 + }, + "subfacing=east": { + "model": "industrialforegoing:block/wither_builder", + "y": 90 + } + } +} \ No newline at end of file diff --git a/src/generated/resources/assets/industrialforegoing/models/item/wither_builder.json b/src/generated/resources/assets/industrialforegoing/models/item/wither_builder.json new file mode 100644 index 000000000..12d413f03 --- /dev/null +++ b/src/generated/resources/assets/industrialforegoing/models/item/wither_builder.json @@ -0,0 +1,3 @@ +{ + "parent": "industrialforegoing:block/wither_builder" +} \ No newline at end of file diff --git a/src/generated/resources/data/industrialforegoing/loot_tables/blocks/wither_builder.json b/src/generated/resources/data/industrialforegoing/loot_tables/blocks/wither_builder.json new file mode 100644 index 000000000..520487751 --- /dev/null +++ b/src/generated/resources/data/industrialforegoing/loot_tables/blocks/wither_builder.json @@ -0,0 +1,19 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "industrialforegoing:wither_builder" + } + ], + "conditions": [ + { + "condition": "minecraft:survives_explosion" + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/industrialforegoing/recipes/wither_builder.json b/src/generated/resources/data/industrialforegoing/recipes/wither_builder.json new file mode 100644 index 000000000..13b76376b --- /dev/null +++ b/src/generated/resources/data/industrialforegoing/recipes/wither_builder.json @@ -0,0 +1,46 @@ +{ + "type": "forge:conditional", + "recipes": [ + { + "conditions": [ + { + "values": [ + { + "item": "industrialforegoing:wither_builder", + "type": "forge:item_exists" + } + ], + "type": "forge:and" + } + ], + "recipe": { + "type": "minecraft:crafting_shaped", + "pattern": [ + "PNP", + "WCW", + "SSS" + ], + "key": { + "P": { + "tag": "forge:plastic" + }, + "N": { + "item": "minecraft:nether_star" + }, + "W": { + "item": "minecraft:wither_skeleton_skull" + }, + "C": { + "tag": "industrialforegoing:machine_frame/supreme" + }, + "S": { + "item": "minecraft:soul_sand" + } + }, + "result": { + "item": "industrialforegoing:wither_builder" + } + } + } + ] +} \ No newline at end of file diff --git a/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/WitherBuilderBlock.java b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/WitherBuilderBlock.java new file mode 100644 index 000000000..64070061c --- /dev/null +++ b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/WitherBuilderBlock.java @@ -0,0 +1,46 @@ +package com.buuz135.industrial.block.agriculturehusbandry; + +import java.util.function.Consumer; + +import javax.annotation.Nonnull; + +import com.buuz135.industrial.block.IndustrialBlock; +import com.buuz135.industrial.block.agriculturehusbandry.tile.WitherBuilderTile; +import com.buuz135.industrial.module.ModuleAgricultureHusbandry; +import com.buuz135.industrial.utils.IndustrialTags; +import com.hrznstudio.titanium.api.IFactory; +import com.hrznstudio.titanium.recipe.generator.TitaniumShapedRecipeBuilder; + +import net.minecraft.block.Blocks; +import net.minecraft.data.IFinishedRecipe; +import net.minecraft.item.Items; + +public class WitherBuilderBlock extends IndustrialBlock { + + public WitherBuilderBlock() { + super("wither_builder", Properties.from(Blocks.IRON_BLOCK), WitherBuilderTile.class, ModuleAgricultureHusbandry.TAB_AG_HUS); + } + + @Override + public IFactory getTileEntityFactory() { + return WitherBuilderTile::new; + } + + @Nonnull + @Override + public RotationType getRotationType() { + return RotationType.FOUR_WAY; + } + + @Override + public void registerRecipe(Consumer consumer) { + TitaniumShapedRecipeBuilder.shapedRecipe(this) + .patternLine("PNP").patternLine("WCW").patternLine("SSS") + .key('P', IndustrialTags.Items.PLASTIC) + .key('N', Items.NETHER_STAR) + .key('W', Items.WITHER_SKELETON_SKULL) + .key('C', IndustrialTags.Items.MACHINE_FRAME_SUPREME) + .key('S', Blocks.SOUL_SAND) + .build(consumer); + } +} diff --git a/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/MobDuplicatorTile.java b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/MobDuplicatorTile.java index b3a66a828..da1cf130e 100644 --- a/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/MobDuplicatorTile.java +++ b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/MobDuplicatorTile.java @@ -52,7 +52,7 @@ public MobDuplicatorTile() { .setValidator(fluidStack -> fluidStack.getFluid().isIn(IndustrialTags.Fluids.EXPERIENCE)) ); - this.addInventory(input = (SidedInventoryComponent) new SidedInventoryComponent("Mob imprisonment Tool", 64, 22, 1, 1) + this.addInventory(input = (SidedInventoryComponent) new SidedInventoryComponent("mob_imprisonment_tool", 64, 22, 1, 1) .setColor(DyeColor.ORANGE) .setInputFilter((itemStack, integer) -> itemStack.getItem().equals(ModuleTool.MOB_IMPRISONMENT_TOOL)) .setComponentHarness(this) diff --git a/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/WitherBuilderTile.java b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/WitherBuilderTile.java new file mode 100644 index 000000000..29c15a0d8 --- /dev/null +++ b/src/main/java/com/buuz135/industrial/block/agriculturehusbandry/tile/WitherBuilderTile.java @@ -0,0 +1,165 @@ +package com.buuz135.industrial.block.agriculturehusbandry.tile; + +import javax.annotation.Nonnull; + +import com.buuz135.industrial.IndustrialForegoing; +import com.buuz135.industrial.block.tile.IndustrialAreaWorkingTile; +import com.buuz135.industrial.block.tile.RangeManager; +import com.buuz135.industrial.config.machine.agriculturehusbandry.MobDuplicatorConfig; +import com.buuz135.industrial.config.machine.agriculturehusbandry.WitherBuilderConfig; +import com.buuz135.industrial.module.ModuleAgricultureHusbandry; +import com.buuz135.industrial.utils.IFFakePlayer; +import com.hrznstudio.titanium.annotation.Save; +import com.hrznstudio.titanium.component.energy.EnergyStorageComponent; +import com.hrznstudio.titanium.component.inventory.SidedInventoryComponent; +import net.minecraftforge.items.ItemStackHandler; + +import net.minecraft.block.Blocks; +import net.minecraft.item.DyeColor; +import net.minecraft.item.ItemStack; +import net.minecraft.item.Items; +import net.minecraft.util.Direction; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.shapes.VoxelShape; + +public class WitherBuilderTile extends IndustrialAreaWorkingTile { + + @Save + private SidedInventoryComponent top; + + @Save + private SidedInventoryComponent middle; + + @Save + private SidedInventoryComponent bottom; + + public WitherBuilderTile() { + super(ModuleAgricultureHusbandry.WITHER_BUILDER, RangeManager.RangeType.TOP_UP, true, WitherBuilderConfig.powerPerOperation); + + + this.addInventory(top = (SidedInventoryComponent) new SidedInventoryComponent("wither_skulls", 64, 25, 3, 0) + .setColor(DyeColor.BLACK) + .setInputFilter((itemStack, integer) -> itemStack.getItem().equals(Items.WITHER_SKELETON_SKULL)) + .setSlotLimit(1) + .setComponentHarness(this) + ); + this.addInventory(middle = (SidedInventoryComponent) new SidedInventoryComponent("soulsand", 64, 25 + 18, 3, 1) + .setColor(DyeColor.ORANGE) + .setInputFilter((itemStack, integer) -> itemStack.getItem().equals(Blocks.SOUL_SAND.asItem())) + .setSlotLimit(1) + .setComponentHarness(this) + ); + this.addInventory(bottom = (SidedInventoryComponent) new SidedInventoryComponent("soulsand", 64 + 18, 25 + 18 * 2, 1, 2) + .setColor(DyeColor.ORANGE) + .setInputFilter((itemStack, integer) -> itemStack.getItem().equals(Blocks.SOUL_SAND.asItem())) + .setSlotLimit(1) + .setComponentHarness(this) + ); + } + + @Override + public WorkAction work() { + if (!hasEnergy(WitherBuilderConfig.powerPerOperation)) return new WorkAction(1, 0); + BlockPos pos = this.pos.add(0, 2, 0); + float power = 0; + if (this.world.getBlockState(pos).getBlock().equals(Blocks.AIR) && !getDefaultOrFind(0, bottom, new ItemStack(Blocks.SOUL_SAND)).isEmpty()) { + this.world.setBlockState(pos, Blocks.SOUL_SAND.getDefaultState()); + getDefaultOrFind(0, bottom, new ItemStack(Blocks.SOUL_SAND)).shrink(1); + power += 1 / 7f; + } + if (this.world.getBlockState(pos).getBlock().equals(Blocks.SOUL_SAND)) { + for (int i = 0; i < 3; ++i) { + BlockPos temp; + if (getFacingDirection() == Direction.EAST || getFacingDirection() == Direction.WEST) { + temp = pos.add(0, 1, i - 1); + } else { + temp = pos.add(i - 1, 1, 0); + } + if (this.world.getBlockState(temp).getBlock().equals(Blocks.AIR) && !getDefaultOrFind(i, middle, new ItemStack(Blocks.SOUL_SAND)).isEmpty()) { + this.world.setBlockState(temp, Blocks.SOUL_SAND.getDefaultState()); + getDefaultOrFind(i, middle, new ItemStack(Blocks.SOUL_SAND)).shrink(1); + power += 1 / 7f; + } + } + } + if (this.world.getBlockState(pos).getBlock().equals(Blocks.SOUL_SAND)) { + boolean secondRow = true; + for (int i = 0; i < 3; ++i) { + BlockPos temp; + if (getFacingDirection() == Direction.EAST || getFacingDirection() == Direction.WEST) { + temp = pos.add(0, 1, i - 1); + } else { + temp = pos.add(i - 1, 1, 0); + } + if (!this.world.getBlockState(temp).getBlock().equals(Blocks.SOUL_SAND)) { + secondRow = false; + break; + } + } + if (secondRow) { + for (int i = 0; i < 3; ++i) { + BlockPos temp; + if (getFacingDirection() == Direction.EAST || getFacingDirection() == Direction.WEST) { + temp = pos.add(0, 2, i - 1); + } else { + temp = pos.add(i - 1, 2, 0); + } + if (this.world.getBlockState(temp).getBlock().equals(Blocks.AIR) && !getDefaultOrFind(i, top, new ItemStack(Items.WITHER_SKELETON_SKULL)).isEmpty() && this.world.getBlockState(temp.add(0, -1, 0)).getBlock().equals(Blocks.SOUL_SAND)) { + + IFFakePlayer fakePlayer = (IFFakePlayer) IndustrialForegoing.getFakePlayer(world, temp); + ItemStack stack = getDefaultOrFind(i, top, new ItemStack(Items.WITHER_SKELETON_SKULL)); + if (fakePlayer.placeBlock(this.world, temp, stack)) { + power += 1 / 7f; + } + } + } + } + } + return new WorkAction(1, power > 0 ? WitherBuilderConfig.powerPerOperation : 0); + } + + @Override + public VoxelShape getWorkingArea() { + + return new RangeManager(this.pos, this.getFacingDirection(), RangeManager.RangeType.TOP_UP) { + @Override + public AxisAlignedBB getBox() { + if (getFacingDirection() == Direction.EAST || getFacingDirection() == Direction.WEST) { + return super.getBox().offset(new BlockPos(0, 1, 0)).grow(0, 1, 1); + } else { + return super.getBox().offset(new BlockPos(0, 1, 0)).grow(1, 1, 0); + } + } + }.get(0); + + } + + @Nonnull + @Override + public WitherBuilderTile getSelf() { + return this; + } + + @Nonnull + @Override + protected EnergyStorageComponent createEnergyStorage() { + return new EnergyStorageComponent<>(WitherBuilderConfig.maxStoredPower, 10, 20); + } + + @Override + public int getMaxProgress() { + return WitherBuilderConfig.maxProgress; + } + + + public ItemStack getDefaultOrFind(int i, ItemStackHandler handler, ItemStack filter) { + if (handler.getStackInSlot(i).isItemEqual(filter)) return handler.getStackInSlot(i); + for (ItemStackHandler h : new ItemStackHandler[] {top, middle, bottom}) { + for (int s = 0; s < h.getSlots(); ++s) { + if (h.getStackInSlot(s).isItemEqual(filter)) return h.getStackInSlot(s); + } + } + return ItemStack.EMPTY; + } +} diff --git a/src/main/java/com/buuz135/industrial/config/machine/agriculturehusbandry/WitherBuilderConfig.java b/src/main/java/com/buuz135/industrial/config/machine/agriculturehusbandry/WitherBuilderConfig.java new file mode 100644 index 000000000..dee39f93b --- /dev/null +++ b/src/main/java/com/buuz135/industrial/config/machine/agriculturehusbandry/WitherBuilderConfig.java @@ -0,0 +1,19 @@ +package com.buuz135.industrial.config.machine.agriculturehusbandry; + +import com.buuz135.industrial.config.MachineAgricultureHusbandryConfig; +import com.hrznstudio.titanium.annotation.config.ConfigFile; +import com.hrznstudio.titanium.annotation.config.ConfigVal; + +@ConfigFile.Child(MachineAgricultureHusbandryConfig.class) +public class WitherBuilderConfig { + + @ConfigVal(comment = "Cooldown Time in Ticks [20 Ticks per Second] - Default: [40 (5s)]") + public static int maxProgress = 40; + + @ConfigVal(comment = "Amount of Power Consumed per Operation - Default: [500FE]") + public static int powerPerOperation = 20000; + + @ConfigVal(comment = "Max Stored Power [FE] - Default: [70000 FE]") + public static int maxStoredPower = 70000; + +} diff --git a/src/main/java/com/buuz135/industrial/module/ModuleAgricultureHusbandry.java b/src/main/java/com/buuz135/industrial/module/ModuleAgricultureHusbandry.java index ff658bf82..bb29b3017 100644 --- a/src/main/java/com/buuz135/industrial/module/ModuleAgricultureHusbandry.java +++ b/src/main/java/com/buuz135/industrial/module/ModuleAgricultureHusbandry.java @@ -52,6 +52,7 @@ public class ModuleAgricultureHusbandry implements IModule { public static MobCrusherBlock MOB_CRUSHER = new MobCrusherBlock(); public static HydroponicBedBlock HYDROPONIC_BED = new HydroponicBedBlock(); public static MobDuplicatorBlock MOB_DUPLICATOR = new MobDuplicatorBlock(); + public static WitherBuilderBlock WITHER_BUILDER = new WitherBuilderBlock(); @Override public List generateFeatures() { @@ -81,6 +82,7 @@ public List generateFeatures() { builders.add(createFeature(MOB_CRUSHER)); builders.add(createFeature(HYDROPONIC_BED)); builders.add(createFeature(MOB_DUPLICATOR)); + builders.add(createFeature(WITHER_BUILDER)); TAB_AG_HUS.addIconStack(new ItemStack(PLANT_SOWER)); return builders; } diff --git a/src/main/resources/assets/industrialforegoing/lang/en_us.json b/src/main/resources/assets/industrialforegoing/lang/en_us.json index 23f024f44..1eace6ffa 100644 --- a/src/main/resources/assets/industrialforegoing/lang/en_us.json +++ b/src/main/resources/assets/industrialforegoing/lang/en_us.json @@ -544,4 +544,4 @@ "item.industrialforegoing.addon": "Addon: ", "item.industrialforegoing.efficiency": "Efficiency ", "item.industrialforegoing.speed": "Speed " -} \ No newline at end of file +} diff --git a/src/main/resources/data/industrialforegoing/patchouli_books/industrial_foregoing/en_us/entries/agr_hus/wither_builder.json b/src/main/resources/data/industrialforegoing/patchouli_books/industrial_foregoing/en_us/entries/agr_hus/wither_builder.json new file mode 100644 index 000000000..58a867cf7 --- /dev/null +++ b/src/main/resources/data/industrialforegoing/patchouli_books/industrial_foregoing/en_us/entries/agr_hus/wither_builder.json @@ -0,0 +1,16 @@ +{ + "name": "Wither Builder", + "icon": "industrialforegoing:wither_builder", + "category": "agriculture_husbandry", + "read_by_default": true, + "pages": [ + { + "type": "text", + "text": "A machine used to spawn withers. When provided with power, $(6)3 Wither Skulls$() and $(6)4 soulsand$(), it will completely build the wither spawning structure in the working area." + }, + { + "type": "crafting", + "recipe": "industrialforegoing:wither_builder" + } + ] +}