Compare commits

...

3 commits

Author SHA1 Message Date
Flanks255
86a89a96a8 first pass at functional crusher. 2022-10-19 13:04:42 -05:00
Flanks255
04714de062 fixed furnace for now. 2022-10-19 12:15:46 -05:00
Flanks255
120721564e Crushers and furnaces keep energy.
Fixed crusher crash.
2022-10-19 09:57:56 -05:00
14 changed files with 104 additions and 57 deletions

View file

@ -480,8 +480,8 @@ f3df22f203e8c00ee7ee004bb9b4edfd522f069a data/actuallyadditions/loot_tables/bloc
bf7743c27757cf5b0dbab9b3e15d1d5ca1ece818 data/actuallyadditions/loot_tables/blocks/coal_generator.json bf7743c27757cf5b0dbab9b3e15d1d5ca1ece818 data/actuallyadditions/loot_tables/blocks/coal_generator.json
66ee33930c8392b29710ce2bc117f99907e336df data/actuallyadditions/loot_tables/blocks/coffee.json 66ee33930c8392b29710ce2bc117f99907e336df data/actuallyadditions/loot_tables/blocks/coffee.json
3285202e3f840d091b8d85dc2c721199fcc96240 data/actuallyadditions/loot_tables/blocks/coffee_machine.json 3285202e3f840d091b8d85dc2c721199fcc96240 data/actuallyadditions/loot_tables/blocks/coffee_machine.json
98c2198bf7df995a8c43f08101eb2021a62e1dec data/actuallyadditions/loot_tables/blocks/crusher.json 317d0377327250f2fe15ff549a1ffa1b7bdade14 data/actuallyadditions/loot_tables/blocks/crusher.json
93c16ed7d46e44ceafdc32c2a440f98b8c805723 data/actuallyadditions/loot_tables/blocks/crusher_double.json b087c6f44cf0236f52471ec54c026ee30ba0d273 data/actuallyadditions/loot_tables/blocks/crusher_double.json
6336ca572b8d81f6e06b43bb925b48bb915b6574 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_block.json 6336ca572b8d81f6e06b43bb925b48bb915b6574 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_block.json
b9ed4007fec7a382a02b08b231f072df6aa40049 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_cluster.json b9ed4007fec7a382a02b08b231f072df6aa40049 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_cluster.json
7476dbc0cbb3c1a8ce5a3c1562f73fcfb4adcd10 data/actuallyadditions/loot_tables/blocks/display_stand.json 7476dbc0cbb3c1a8ce5a3c1562f73fcfb4adcd10 data/actuallyadditions/loot_tables/blocks/display_stand.json
@ -559,7 +559,7 @@ d6c0f113ea7c3cc0e8c3a11860792966d516211b data/actuallyadditions/loot_tables/bloc
a365f2f0d80e070d281a7b839c961d36f115abeb data/actuallyadditions/loot_tables/blocks/phantom_redstoneface.json a365f2f0d80e070d281a7b839c961d36f115abeb data/actuallyadditions/loot_tables/blocks/phantom_redstoneface.json
13f0d4587dac4822a26fd063a22f6f46c83e9af6 data/actuallyadditions/loot_tables/blocks/placer.json 13f0d4587dac4822a26fd063a22f6f46c83e9af6 data/actuallyadditions/loot_tables/blocks/placer.json
6d9a73f94513ed92c1697d25c5d89145b016ab5d data/actuallyadditions/loot_tables/blocks/player_interface.json 6d9a73f94513ed92c1697d25c5d89145b016ab5d data/actuallyadditions/loot_tables/blocks/player_interface.json
25a194a62fcad1b0b86540efbe6ca81757a3408a data/actuallyadditions/loot_tables/blocks/powered_furnace.json bb5b9781aa9c64a1330eff6d7bb3e6c2c7f3a645 data/actuallyadditions/loot_tables/blocks/powered_furnace.json
a92f9584164335ecbcf769bc668289d76cea5d6c data/actuallyadditions/loot_tables/blocks/ranged_collector.json a92f9584164335ecbcf769bc668289d76cea5d6c data/actuallyadditions/loot_tables/blocks/ranged_collector.json
d497fdb4936e1f3fdaa556da79e39f6fcbb405ed data/actuallyadditions/loot_tables/blocks/restonia_crystal_block.json d497fdb4936e1f3fdaa556da79e39f6fcbb405ed data/actuallyadditions/loot_tables/blocks/restonia_crystal_block.json
7d025b370ad83e847619627002ca835901faf235 data/actuallyadditions/loot_tables/blocks/restonia_crystal_cluster.json 7d025b370ad83e847619627002ca835901faf235 data/actuallyadditions/loot_tables/blocks/restonia_crystal_cluster.json
@ -718,7 +718,7 @@ e088aee52db067c15c72bfe743ac106b98ca4be2 data/actuallyadditions/recipes/colorcha
a4fb51f83c38bfebceeadde885d59632e355bf6d data/actuallyadditions/recipes/colorchange/yellow_terracotta.json a4fb51f83c38bfebceeadde885d59632e355bf6d data/actuallyadditions/recipes/colorchange/yellow_terracotta.json
ca4f8d37d115eac5889542b04d1c01cd2e0cde43 data/actuallyadditions/recipes/colorchange/yellow_wool.json ca4f8d37d115eac5889542b04d1c01cd2e0cde43 data/actuallyadditions/recipes/colorchange/yellow_wool.json
160466dfd10fafc2ae4b4130ca35220d4c2d2342 data/actuallyadditions/recipes/crate_keeper.json 160466dfd10fafc2ae4b4130ca35220d4c2d2342 data/actuallyadditions/recipes/crate_keeper.json
b76b843a60a1c456a11d3bb932a93ab3753d6f58 data/actuallyadditions/recipes/crushing/bone_crusher.json 341c5816febc417a36e516986f6d1461cf38cfed data/actuallyadditions/recipes/crushing/bone_crusher.json
293cecfa94d22e62bd817a3964e82dca4479d44d data/actuallyadditions/recipes/diamond_aiot.json 293cecfa94d22e62bd817a3964e82dca4479d44d data/actuallyadditions/recipes/diamond_aiot.json
abb220fb19dea7cf9afcd30fbe533d21b7c4e9c0 data/actuallyadditions/recipes/display_stand.json abb220fb19dea7cf9afcd30fbe533d21b7c4e9c0 data/actuallyadditions/recipes/display_stand.json
f3465f5a05a931f4e5933508c2bc56de9c9eafe5 data/actuallyadditions/recipes/double_battery.json f3465f5a05a931f4e5933508c2bc56de9c9eafe5 data/actuallyadditions/recipes/double_battery.json

View file

@ -13,6 +13,19 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
],
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "Energy",
"target": "BlockEntityTag.Energy",
"op": "replace"
}
]
}
] ]
} }
] ]

View file

@ -13,6 +13,19 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
],
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "Energy",
"target": "BlockEntityTag.Energy",
"op": "replace"
}
]
}
] ]
} }
] ]

View file

@ -13,6 +13,19 @@
{ {
"condition": "minecraft:survives_explosion" "condition": "minecraft:survives_explosion"
} }
],
"functions": [
{
"function": "minecraft:copy_nbt",
"source": "block_entity",
"ops": [
{
"source": "Energy",
"target": "BlockEntityTag.Energy",
"op": "replace"
}
]
}
] ]
} }
] ]

View file

@ -6,10 +6,12 @@
"result": [ "result": [
{ {
"item": "minecraft:bone_meal", "item": "minecraft:bone_meal",
"count": 6,
"chance": 1.0 "chance": 1.0
}, },
{ {
"item": "minecraft:air", "item": "minecraft:air",
"count": 0,
"chance": 0.0 "chance": 0.0
} }
] ]

View file

@ -57,6 +57,9 @@ public class LootTableGenerator extends LootTableProvider {
dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND); dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND);
dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR); dropKeepEnergy(ActuallyBlocks.COAL_GENERATOR);
dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR); dropKeepEnergy(ActuallyBlocks.OIL_GENERATOR);
dropKeepEnergy(ActuallyBlocks.CRUSHER);
dropKeepEnergy(ActuallyBlocks.CRUSHER_DOUBLE);
dropKeepEnergy(ActuallyBlocks.POWERED_FURNACE);
this.dropSelf(ActuallyBlocks.BATTERY_BOX.get()); this.dropSelf(ActuallyBlocks.BATTERY_BOX.get());
this.dropSelf(ActuallyBlocks.ITEM_INTERFACE_HOPPING.get()); this.dropSelf(ActuallyBlocks.ITEM_INTERFACE_HOPPING.get());
@ -81,9 +84,6 @@ public class LootTableGenerator extends LootTableProvider {
this.dropSelf(ActuallyBlocks.PHANTOM_BREAKER.get()); this.dropSelf(ActuallyBlocks.PHANTOM_BREAKER.get());
this.dropSelf(ActuallyBlocks.FERMENTING_BARREL.get()); this.dropSelf(ActuallyBlocks.FERMENTING_BARREL.get());
this.dropSelf(ActuallyBlocks.FEEDER.get()); this.dropSelf(ActuallyBlocks.FEEDER.get());
this.dropSelf(ActuallyBlocks.CRUSHER.get());
this.dropSelf(ActuallyBlocks.CRUSHER_DOUBLE.get());
this.dropSelf(ActuallyBlocks.POWERED_FURNACE.get());
this.dropSelf(ActuallyBlocks.HEAT_COLLECTOR.get()); this.dropSelf(ActuallyBlocks.HEAT_COLLECTOR.get());
this.dropSelf(ActuallyBlocks.GREENHOUSE_GLASS.get()); this.dropSelf(ActuallyBlocks.GREENHOUSE_GLASS.get());
this.dropSelf(ActuallyBlocks.BREAKER.get()); this.dropSelf(ActuallyBlocks.BREAKER.get());

View file

@ -46,9 +46,9 @@ public final class ActuallyBlocks {
// Machines // Machines
public static final AABlockReg<BlockFeeder, AABlockItem, TileEntityFeeder> FEEDER = new AABlockReg<>("feeder", BlockFeeder::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityFeeder::new); public static final AABlockReg<BlockFeeder, AABlockItem, TileEntityFeeder> FEEDER = new AABlockReg<>("feeder", BlockFeeder::new, (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityFeeder::new);
public static final AABlockReg<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER = new AABlockReg<>("crusher", () -> new BlockCrusher(false), public static final AABlockReg<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER = new AABlockReg<>("crusher", () -> new BlockCrusher(false),
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCrusher::new); (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCrusher::new);
public static final AABlockReg<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER_DOUBLE = new AABlockReg<>("crusher_double", () -> new BlockCrusher(false), public static final AABlockReg<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER_DOUBLE = new AABlockReg<>("crusher_double", () -> new BlockCrusher(false),
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCrusherDouble::new); (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCrusherDouble::new);
public static final AABlockReg<BlockEnergizer, AABlockItem, TileEntityEnergizer> ENERGIZER = new AABlockReg<>("energizer", () -> new BlockEnergizer(true), public static final AABlockReg<BlockEnergizer, AABlockItem, TileEntityEnergizer> ENERGIZER = new AABlockReg<>("energizer", () -> new BlockEnergizer(true),
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEnergizer::new); (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityEnergizer::new);
@ -108,7 +108,7 @@ public final class ActuallyBlocks {
public static final AABlockReg<BlockCoffeeMachine, AABlockItem, TileEntityCoffeeMachine> COFFEE_MACHINE = new AABlockReg<>("coffee_machine", BlockCoffeeMachine::new, public static final AABlockReg<BlockCoffeeMachine, AABlockItem, TileEntityCoffeeMachine> COFFEE_MACHINE = new AABlockReg<>("coffee_machine", BlockCoffeeMachine::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCoffeeMachine::new); (b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCoffeeMachine::new);
public static final AABlockReg<BlockPoweredFurnace, AABlockItem, TileEntityPoweredFurnace> POWERED_FURNACE = new AABlockReg<>("powered_furnace", BlockPoweredFurnace::new, public static final AABlockReg<BlockPoweredFurnace, AABlockItem, TileEntityPoweredFurnace> POWERED_FURNACE = new AABlockReg<>("powered_furnace", BlockPoweredFurnace::new,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityPoweredFurnace::new); (b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityPoweredFurnace::new);
// Crystal Blocks // Crystal Blocks

View file

@ -83,7 +83,7 @@ public class BlockCrusher extends BlockContainerBase {
@Override @Override
public BlockState getStateForPlacement(BlockItemUseContext context) { public BlockState getStateForPlacement(BlockItemUseContext context) {
return defaultBlockState().setValue(HORIZONTAL_FACING, context.getNearestLookingDirection().getOpposite()).setValue(LIT, false); return defaultBlockState().setValue(HORIZONTAL_FACING, context.getHorizontalDirection().getOpposite()).setValue(LIT, false);
} }
@Override @Override

View file

@ -121,14 +121,18 @@ public class CrushingRecipe implements IRecipe<IInventory> {
if (resultList.size() < 1) if (resultList.size() < 1)
throw new IllegalStateException(pRecipeId.toString() + ": Recipe must contain at least 1 result item"); throw new IllegalStateException(pRecipeId.toString() + ": Recipe must contain at least 1 result item");
ItemStack output1 = new ItemStack(JSONUtils.getAsItem(resultList.get(0).getAsJsonObject(), "item")); JsonObject result1 = resultList.get(0).getAsJsonObject();
float chance1 = JSONUtils.getAsFloat(resultList.get(0).getAsJsonObject(), "chance"); int count1 = JSONUtils.getAsInt(result1, "count", 0);
ItemStack output1 = new ItemStack(JSONUtils.getAsItem(result1, "item"), count1);
float chance1 = JSONUtils.getAsFloat(result1, "chance");
ItemStack output2 = ItemStack.EMPTY; ItemStack output2 = ItemStack.EMPTY;
float chance2 = 1.0f; float chance2 = 1.0f;
if (resultList.size() > 1) { if (resultList.size() > 1) {
output2 = new ItemStack(JSONUtils.getAsItem(resultList.get(1).getAsJsonObject(), "item")); JsonObject result2 = resultList.get(1).getAsJsonObject();
chance2 = JSONUtils.getAsFloat(resultList.get(1).getAsJsonObject(), "chance"); int count2 = JSONUtils.getAsInt(result2, "count", 0);
output2 = new ItemStack(JSONUtils.getAsItem(result2, "item"), count2);
chance2 = JSONUtils.getAsFloat(result2, "chance");
} }
return new CrushingRecipe(pRecipeId, ingredient, output1, chance1, output2, chance2); return new CrushingRecipe(pRecipeId, ingredient, output1, chance1, output2, chance2);
@ -182,10 +186,12 @@ public class CrushingRecipe implements IRecipe<IInventory> {
JsonObject result1 = new JsonObject(); JsonObject result1 = new JsonObject();
result1.addProperty("item", outputOne.asItem().getRegistryName().toString()); result1.addProperty("item", outputOne.asItem().getRegistryName().toString());
result1.addProperty("count", countOne);
result1.addProperty("chance", outputChance1); result1.addProperty("chance", outputChance1);
JsonObject result2 = new JsonObject(); JsonObject result2 = new JsonObject();
result2.addProperty("item", outputTwo.asItem().getRegistryName().toString()); result2.addProperty("item", outputTwo.asItem().getRegistryName().toString());
result2.addProperty("count", countTwo);
result2.addProperty("chance", outputChance2); result2.addProperty("chance", outputChance2);
JsonArray resultList = new JsonArray(); JsonArray resultList = new JsonArray();

View file

@ -8,7 +8,8 @@ public class SingleItem implements IInventory {
private final ItemStack itemStack; private final ItemStack itemStack;
public SingleItem(ItemStack itemStack) { public SingleItem(ItemStack itemStack) {
this.itemStack = itemStack; this.itemStack = itemStack.copy();
this.itemStack.setCount(1);
} }
@Override @Override

View file

@ -10,7 +10,9 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.AASounds; import de.ellpeck.actuallyadditions.mod.AASounds;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe; import de.ellpeck.actuallyadditions.mod.crafting.CrushingRecipe;
import de.ellpeck.actuallyadditions.mod.inventory.CrusherContainer; import de.ellpeck.actuallyadditions.mod.inventory.CrusherContainer;
@ -37,6 +39,7 @@ import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.Optional;
public class TileEntityCrusher extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider { public class TileEntityCrusher extends TileEntityInventoryBase implements IButtonReactor, INamedContainerProvider {
@ -186,26 +189,21 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
return (slot, automation) -> !automation || slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2; return (slot, automation) -> !automation || slot == SLOT_OUTPUT_1_1 || slot == SLOT_OUTPUT_1_2 || slot == SLOT_OUTPUT_2_1 || slot == SLOT_OUTPUT_2_2;
} }
public static Optional<CrushingRecipe> getRecipeForInput(ItemStack itemStack) {
return ActuallyAdditionsAPI.CRUSHER_RECIPES.stream().filter($ -> $.matches(itemStack)).findFirst();
}
public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) { public boolean canCrushOn(int theInput, int theFirstOutput, int theSecondOutput) {
if (StackUtil.isValid(this.inv.getStackInSlot(theInput))) { ItemStack inputStack = this.inv.getStackInSlot(theInput);
CrushingRecipe recipe = null;//CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput)); //TODO if (!inputStack.isEmpty()) {
if (recipe == null) { Optional<CrushingRecipe> recipeOpt = getRecipeForInput(inputStack);
if (!recipeOpt.isPresent()) {
return false; return false;
} }
CrushingRecipe recipe = recipeOpt.get();
ItemStack outputOne = recipe.getOutputOne(); ItemStack outputOne = recipe.getOutputOne();
ItemStack outputTwo = recipe.getOutputTwo(); ItemStack outputTwo = recipe.getOutputTwo();
if (StackUtil.isValid(outputOne)) { if (!outputOne.isEmpty()) {
/* //TODO return (this.inv.getStackInSlot(theFirstOutput).isEmpty() || this.inv.getStackInSlot(theFirstOutput).sameItem(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (outputTwo.isEmpty() || this.inv.getStackInSlot(theSecondOutput).isEmpty() || this.inv.getStackInSlot(theSecondOutput).sameItem(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount());
if (outputOne.getDamage() == Util.WILDCARD) {
outputOne.setDamage(0);
}
if (StackUtil.isValid(outputTwo) && outputTwo.getDamage() == Util.WILDCARD) {
outputTwo.setDamage(0);
}
*/
if ((!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput)) || this.inv.getStackInSlot(theFirstOutput).sameItem(outputOne) && this.inv.getStackInSlot(theFirstOutput).getCount() <= this.inv.getStackInSlot(theFirstOutput).getMaxStackSize() - outputOne.getCount()) && (!StackUtil.isValid(outputTwo) || !StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput)) || this.inv.getStackInSlot(theSecondOutput).sameItem(outputTwo) && this.inv.getStackInSlot(theSecondOutput).getCount() <= this.inv.getStackInSlot(theSecondOutput).getMaxStackSize() - outputTwo.getCount())) {
return true;
}
} }
} }
return false; return false;
@ -218,18 +216,15 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
} }
public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput) { public void finishCrushing(int theInput, int theFirstOutput, int theSecondOutput) {
CrushingRecipe recipe = CrusherRecipeRegistry.getRecipeFromInput(this.inv.getStackInSlot(theInput));//TODO Optional<CrushingRecipe> recipeOpt = getRecipeForInput(this.inv.getStackInSlot(theInput));
if (recipe == null) { if (!recipeOpt.isPresent()) {
return; return;
} }
CrushingRecipe recipe = recipeOpt.get();
ItemStack outputOne = recipe.getOutputOne(); ItemStack outputOne = recipe.getOutputOne();
if (StackUtil.isValid(outputOne)) { if (!outputOne.isEmpty()) {
/* //TODO if (this.inv.getStackInSlot(theFirstOutput).isEmpty()) {
if (outputOne.getDamage() == Util.WILDCARD) {
outputOne.setDamage(0);
}
*/
if (!StackUtil.isValid(this.inv.getStackInSlot(theFirstOutput))) {
this.inv.setStackInSlot(theFirstOutput, outputOne.copy()); this.inv.setStackInSlot(theFirstOutput, outputOne.copy());
} else if (this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()) { } else if (this.inv.getStackInSlot(theFirstOutput).getItem() == outputOne.getItem()) {
this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount())); this.inv.setStackInSlot(theFirstOutput, StackUtil.grow(this.inv.getStackInSlot(theFirstOutput), outputOne.getCount()));
@ -237,15 +232,10 @@ public class TileEntityCrusher extends TileEntityInventoryBase implements IButto
} }
ItemStack outputTwo = recipe.getOutputTwo(); ItemStack outputTwo = recipe.getOutputTwo();
if (StackUtil.isValid(outputTwo)) { if (!outputTwo.isEmpty()) {
/* //TODO
if (outputTwo.getDamage() == Util.WILDCARD) {
outputTwo.setDamage(0);
}
*/
float rand = this.level.random.nextFloat(); float rand = this.level.random.nextFloat();
if (rand <= recipe.getSecondChance()) { if (rand <= recipe.getSecondChance()) {
if (!StackUtil.isValid(this.inv.getStackInSlot(theSecondOutput))) { if (this.inv.getStackInSlot(theSecondOutput).isEmpty()) {
this.inv.setStackInSlot(theSecondOutput, outputTwo.copy()); this.inv.setStackInSlot(theSecondOutput, outputTwo.copy());
} else if (this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()) { } else if (this.inv.getStackInSlot(theSecondOutput).getItem() == outputTwo.getItem()) {
this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount())); this.inv.setStackInSlot(theSecondOutput, StackUtil.grow(this.inv.getStackInSlot(theSecondOutput), outputTwo.getCount()));

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks; import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
import de.ellpeck.actuallyadditions.mod.crafting.SingleItem; import de.ellpeck.actuallyadditions.mod.crafting.SingleItem;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble; import de.ellpeck.actuallyadditions.mod.inventory.ContainerFurnaceDouble;
@ -24,8 +25,10 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.container.Container; import net.minecraft.inventory.container.Container;
import net.minecraft.inventory.container.INamedContainerProvider; import net.minecraft.inventory.container.INamedContainerProvider;
import net.minecraft.inventory.container.Slot;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.AbstractCookingRecipe; import net.minecraft.item.crafting.AbstractCookingRecipe;
import net.minecraft.item.crafting.FurnaceRecipe;
import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.IRecipeType;
import net.minecraft.nbt.CompoundNBT; import net.minecraft.nbt.CompoundNBT;
import net.minecraft.state.properties.BlockStateProperties; import net.minecraft.state.properties.BlockStateProperties;
@ -67,11 +70,11 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
ItemStack first = inv.getStackInSlot(slot1); ItemStack first = inv.getStackInSlot(slot1);
ItemStack second = inv.getStackInSlot(slot2); ItemStack second = inv.getStackInSlot(slot2);
if (StackUtil.isValid(first) || StackUtil.isValid(second)) { if (!first.isEmpty() || !second.isEmpty()) {
ItemStack toSplit = ItemStack.EMPTY; ItemStack toSplit = ItemStack.EMPTY;
if (!StackUtil.isValid(first) && StackUtil.isValid(second) && second.getCount() > 1) { if (first.isEmpty() && !second.isEmpty() && second.getCount() > 1) {
toSplit = second; toSplit = second;
} else if (!StackUtil.isValid(second) && StackUtil.isValid(first) && first.getCount() > 1) { } else if (second.isEmpty() && !first.isEmpty() && first.getCount() > 1) {
toSplit = first; toSplit = first;
} else if (ItemUtil.canBeStacked(first, second)) { } else if (ItemUtil.canBeStacked(first, second)) {
if (first.getCount() < first.getMaxStackSize() || second.getCount() < second.getMaxStackSize()) { if (first.getCount() < first.getMaxStackSize() || second.getCount() < second.getMaxStackSize()) {
@ -82,7 +85,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
} }
} }
if (StackUtil.isValid(toSplit)) { if (!toSplit.isEmpty()) {
ItemStack splitFirst = toSplit.copy(); ItemStack splitFirst = toSplit.copy();
ItemStack secondSplit = splitFirst.split(splitFirst.getCount() / 2); ItemStack secondSplit = splitFirst.split(splitFirst.getCount() / 2);
inv.setStackInSlot(slot1, splitFirst); inv.setStackInSlot(slot1, splitFirst);
@ -120,6 +123,7 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
if (this.isAutoSplit) { if (this.isAutoSplit) {
autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2); autoSplit(this.inv, SLOT_INPUT_1, SLOT_INPUT_2);
} }
//TODO all this logic needs redone someday
boolean smelted = false; boolean smelted = false;
@ -190,6 +194,10 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
return level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new SingleItem(stack), level).map(AbstractCookingRecipe::getResultItem); return level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new SingleItem(stack), level).map(AbstractCookingRecipe::getResultItem);
} }
public Optional<FurnaceRecipe> getRecipeForInput(ItemStack stack) {
return level.getServer().getRecipeManager().getRecipeFor(IRecipeType.SMELTING, new SingleItem(stack), level);
}
@Override @Override
public IAcceptor getAcceptor() { public IAcceptor getAcceptor() {
return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && validInput(stack); return (slot, stack, automation) -> !automation || (slot == SLOT_INPUT_1 || slot == SLOT_INPUT_2) && validInput(stack);
@ -204,10 +212,8 @@ public class TileEntityPoweredFurnace extends TileEntityInventoryBase implements
ItemStack input = this.inv.getStackInSlot(theInput); ItemStack input = this.inv.getStackInSlot(theInput);
ItemStack output = this.inv.getStackInSlot(theOutput); ItemStack output = this.inv.getStackInSlot(theOutput);
if (!input.isEmpty()) { if (!input.isEmpty()) {
ItemStack outputStack = getOutputForInput(input).orElse(ItemStack.EMPTY); Optional<FurnaceRecipe> recipe = getRecipeForInput(input);
if (!output.isEmpty()) { return recipe.map($ -> output.isEmpty() || output.sameItem($.getResultItem()) && output.getCount() <= output.getMaxStackSize() - $.getResultItem().getCount()).orElse(false);
return output.isEmpty() || output.sameItem(outputStack) && output.getCount() <= output.getMaxStackSize() - outputStack.getCount();
}
} }
return false; return false;
} }

View file

@ -44,5 +44,8 @@ public class ResourceReloader implements IResourceManagerReloadListener {
ActuallyAdditionsAPI.MINING_LENS_RECIPES.clear(); ActuallyAdditionsAPI.MINING_LENS_RECIPES.clear();
ActuallyAdditionsAPI.MINING_LENS_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.MINING_LENS)); ActuallyAdditionsAPI.MINING_LENS_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.MINING_LENS));
ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.CRUSHING));
} }
} }

View file

@ -105,7 +105,7 @@
"block.actuallyadditions.giant_chest_medium": "Medium Storage Crate", "block.actuallyadditions.giant_chest_medium": "Medium Storage Crate",
"block.actuallyadditions.giant_chest_large": "Large Storage Crate", "block.actuallyadditions.giant_chest_large": "Large Storage Crate",
"block.actuallyadditions.crusher": "Crusher", "block.actuallyadditions.crusher": "Crusher",
"block.actuallyadditions.double_crusher": "Double Crusher", "block.actuallyadditions.crusher_double": "Double Crusher",
"block.actuallyadditions.powered_furnace": "Powered Furnace", "block.actuallyadditions.powered_furnace": "Powered Furnace",
"block.actuallyadditions.fishing_net": "Fishing Net", "block.actuallyadditions.fishing_net": "Fishing Net",
"block.actuallyadditions.furnace_solar": "Solar Panel", "block.actuallyadditions.furnace_solar": "Solar Panel",
@ -591,7 +591,7 @@
"container.actuallyadditions.inputter": "ESD", "container.actuallyadditions.inputter": "ESD",
"container.actuallyadditions.inputterAdvanced": "Advanced ESD", "container.actuallyadditions.inputterAdvanced": "Advanced ESD",
"container.actuallyadditions.crusher": "Crusher", "container.actuallyadditions.crusher": "Crusher",
"container.actuallyadditions.double_crusher": "Double Crusher", "container.actuallyadditions.crusher_double": "Double Crusher",
"container.actuallyadditions.powered_furnace": "Powered Furnace", "container.actuallyadditions.powered_furnace": "Powered Furnace",
"container.actuallyadditions.feeder": "Feeder", "container.actuallyadditions.feeder": "Feeder",
"container.actuallyadditions.giantChest": "Small Storage Crate", "container.actuallyadditions.giantChest": "Small Storage Crate",