Skip to content

Commit

Permalink
Merge remote-tracking branch 'IF/1.16' into 1.16
Browse files Browse the repository at this point in the history
  • Loading branch information
Buuz135 committed Apr 3, 2021
2 parents 87f0906 + 883c8ae commit 7a5fedc
Show file tree
Hide file tree
Showing 11 changed files with 337 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "industrialforegoing:block/wither_builder"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "industrialforegoing:wither_builder"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
]
}
Original file line number Diff line number Diff line change
@@ -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<WitherBuilderTile> {

public WitherBuilderBlock() {
super("wither_builder", Properties.from(Blocks.IRON_BLOCK), WitherBuilderTile.class, ModuleAgricultureHusbandry.TAB_AG_HUS);
}

@Override
public IFactory<WitherBuilderTile> getTileEntityFactory() {
return WitherBuilderTile::new;
}

@Nonnull
@Override
public RotationType getRotationType() {
return RotationType.FOUR_WAY;
}

@Override
public void registerRecipe(Consumer<IFinishedRecipe> 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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public MobDuplicatorTile() {
.setValidator(fluidStack -> fluidStack.getFluid().isIn(IndustrialTags.Fluids.EXPERIENCE))
);

this.addInventory(input = (SidedInventoryComponent<MobDuplicatorTile>) new SidedInventoryComponent<MobDuplicatorTile>("Mob imprisonment Tool", 64, 22, 1, 1)
this.addInventory(input = (SidedInventoryComponent<MobDuplicatorTile>) new SidedInventoryComponent<MobDuplicatorTile>("mob_imprisonment_tool", 64, 22, 1, 1)
.setColor(DyeColor.ORANGE)
.setInputFilter((itemStack, integer) -> itemStack.getItem().equals(ModuleTool.MOB_IMPRISONMENT_TOOL))
.setComponentHarness(this)
Expand Down
Original file line number Diff line number Diff line change
@@ -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<WitherBuilderTile> {

@Save
private SidedInventoryComponent<WitherBuilderTile> top;

@Save
private SidedInventoryComponent<WitherBuilderTile> middle;

@Save
private SidedInventoryComponent<WitherBuilderTile> bottom;

public WitherBuilderTile() {
super(ModuleAgricultureHusbandry.WITHER_BUILDER, RangeManager.RangeType.TOP_UP, true, WitherBuilderConfig.powerPerOperation);


this.addInventory(top = (SidedInventoryComponent<WitherBuilderTile>) new SidedInventoryComponent<WitherBuilderTile>("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<WitherBuilderTile>) new SidedInventoryComponent<WitherBuilderTile>("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<WitherBuilderTile>) new SidedInventoryComponent<WitherBuilderTile>("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<WitherBuilderTile> 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;
}
}
Original file line number Diff line number Diff line change
@@ -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;

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Feature.Builder> generateFeatures() {
Expand Down Expand Up @@ -81,6 +82,7 @@ public List<Feature.Builder> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,4 @@
"item.industrialforegoing.addon": "Addon: ",
"item.industrialforegoing.efficiency": "Efficiency ",
"item.industrialforegoing.speed": "Speed "
}
}
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 7a5fedc

Please sign in to comment.