Compare commits

..

No commits in common. "86a89a96a8b2300dde43b47ce459c316bea0783b" and "e8fee61c9174544e82832aac5b5f666517497147" have entirely different histories.

14 changed files with 57 additions and 104 deletions

View file

@ -480,8 +480,8 @@ f3df22f203e8c00ee7ee004bb9b4edfd522f069a data/actuallyadditions/loot_tables/bloc
bf7743c27757cf5b0dbab9b3e15d1d5ca1ece818 data/actuallyadditions/loot_tables/blocks/coal_generator.json
66ee33930c8392b29710ce2bc117f99907e336df data/actuallyadditions/loot_tables/blocks/coffee.json
3285202e3f840d091b8d85dc2c721199fcc96240 data/actuallyadditions/loot_tables/blocks/coffee_machine.json
317d0377327250f2fe15ff549a1ffa1b7bdade14 data/actuallyadditions/loot_tables/blocks/crusher.json
b087c6f44cf0236f52471ec54c026ee30ba0d273 data/actuallyadditions/loot_tables/blocks/crusher_double.json
98c2198bf7df995a8c43f08101eb2021a62e1dec data/actuallyadditions/loot_tables/blocks/crusher.json
93c16ed7d46e44ceafdc32c2a440f98b8c805723 data/actuallyadditions/loot_tables/blocks/crusher_double.json
6336ca572b8d81f6e06b43bb925b48bb915b6574 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_block.json
b9ed4007fec7a382a02b08b231f072df6aa40049 data/actuallyadditions/loot_tables/blocks/diamatine_crystal_cluster.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
13f0d4587dac4822a26fd063a22f6f46c83e9af6 data/actuallyadditions/loot_tables/blocks/placer.json
6d9a73f94513ed92c1697d25c5d89145b016ab5d data/actuallyadditions/loot_tables/blocks/player_interface.json
bb5b9781aa9c64a1330eff6d7bb3e6c2c7f3a645 data/actuallyadditions/loot_tables/blocks/powered_furnace.json
25a194a62fcad1b0b86540efbe6ca81757a3408a data/actuallyadditions/loot_tables/blocks/powered_furnace.json
a92f9584164335ecbcf769bc668289d76cea5d6c data/actuallyadditions/loot_tables/blocks/ranged_collector.json
d497fdb4936e1f3fdaa556da79e39f6fcbb405ed data/actuallyadditions/loot_tables/blocks/restonia_crystal_block.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
ca4f8d37d115eac5889542b04d1c01cd2e0cde43 data/actuallyadditions/recipes/colorchange/yellow_wool.json
160466dfd10fafc2ae4b4130ca35220d4c2d2342 data/actuallyadditions/recipes/crate_keeper.json
341c5816febc417a36e516986f6d1461cf38cfed data/actuallyadditions/recipes/crushing/bone_crusher.json
b76b843a60a1c456a11d3bb932a93ab3753d6f58 data/actuallyadditions/recipes/crushing/bone_crusher.json
293cecfa94d22e62bd817a3964e82dca4479d44d data/actuallyadditions/recipes/diamond_aiot.json
abb220fb19dea7cf9afcd30fbe533d21b7c4e9c0 data/actuallyadditions/recipes/display_stand.json
f3465f5a05a931f4e5933508c2bc56de9c9eafe5 data/actuallyadditions/recipes/double_battery.json

View file

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

View file

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

View file

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

View file

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

View file

@ -57,9 +57,6 @@ public class LootTableGenerator extends LootTableProvider {
dropKeepEnergy(ActuallyBlocks.DISPLAY_STAND);
dropKeepEnergy(ActuallyBlocks.COAL_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.ITEM_INTERFACE_HOPPING.get());
@ -84,6 +81,9 @@ public class LootTableGenerator extends LootTableProvider {
this.dropSelf(ActuallyBlocks.PHANTOM_BREAKER.get());
this.dropSelf(ActuallyBlocks.FERMENTING_BARREL.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.GREENHOUSE_GLASS.get());
this.dropSelf(ActuallyBlocks.BREAKER.get());

View file

@ -46,9 +46,9 @@ public final class ActuallyBlocks {
// 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<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER = new AABlockReg<>("crusher", () -> new BlockCrusher(false),
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCrusher::new);
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCrusher::new);
public static final AABlockReg<BlockCrusher, AABlockItem, TileEntityCrusher> CRUSHER_DOUBLE = new AABlockReg<>("crusher_double", () -> new BlockCrusher(false),
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityCrusherDouble::new);
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCrusherDouble::new);
public static final AABlockReg<BlockEnergizer, AABlockItem, TileEntityEnergizer> ENERGIZER = new AABlockReg<>("energizer", () -> new BlockEnergizer(true),
(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,
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityCoffeeMachine::new);
public static final AABlockReg<BlockPoweredFurnace, AABlockItem, TileEntityPoweredFurnace> POWERED_FURNACE = new AABlockReg<>("powered_furnace", BlockPoweredFurnace::new,
(b) -> new AABlockItem.BlockEntityEnergyItem(b, defaultBlockItemProperties), TileEntityPoweredFurnace::new);
(b) -> new AABlockItem(b, defaultBlockItemProperties), TileEntityPoweredFurnace::new);
// Crystal Blocks

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -44,8 +44,5 @@ public class ResourceReloader implements IResourceManagerReloadListener {
ActuallyAdditionsAPI.MINING_LENS_RECIPES.clear();
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_large": "Large Storage Crate",
"block.actuallyadditions.crusher": "Crusher",
"block.actuallyadditions.crusher_double": "Double Crusher",
"block.actuallyadditions.double_crusher": "Double Crusher",
"block.actuallyadditions.powered_furnace": "Powered Furnace",
"block.actuallyadditions.fishing_net": "Fishing Net",
"block.actuallyadditions.furnace_solar": "Solar Panel",
@ -591,7 +591,7 @@
"container.actuallyadditions.inputter": "ESD",
"container.actuallyadditions.inputterAdvanced": "Advanced ESD",
"container.actuallyadditions.crusher": "Crusher",
"container.actuallyadditions.crusher_double": "Double Crusher",
"container.actuallyadditions.double_crusher": "Double Crusher",
"container.actuallyadditions.powered_furnace": "Powered Furnace",
"container.actuallyadditions.feeder": "Feeder",
"container.actuallyadditions.giantChest": "Small Storage Crate",