mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-22 15:18:34 +01:00
1st pass at fixing reconstructor...
This commit is contained in:
parent
a8ba206b27
commit
92b0fed4d5
11 changed files with 84 additions and 42 deletions
|
@ -41,13 +41,15 @@ public final class ActuallyAdditionsAPI {
|
||||||
public static final List<CrushingRecipe> CRUSHER_RECIPES = new ArrayList<>();
|
public static final List<CrushingRecipe> CRUSHER_RECIPES = new ArrayList<>();
|
||||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>();
|
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>();
|
||||||
// public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<>();
|
// public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<>();
|
||||||
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>();
|
//public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>();
|
||||||
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<>();
|
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<>();
|
||||||
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>();
|
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>();
|
||||||
|
|
||||||
public static final List<SolidFuelRecipe> SOLID_FUEL_RECIPES = new ArrayList<>();
|
public static final List<SolidFuelRecipe> SOLID_FUEL_RECIPES = new ArrayList<>();
|
||||||
public static final List<PressingRecipe> PRESSING_RECIPES = new ArrayList<>();
|
public static final List<PressingRecipe> PRESSING_RECIPES = new ArrayList<>();
|
||||||
public static final List<FermentingRecipe> FERMENTING_RECIPES = new ArrayList<>();
|
public static final List<FermentingRecipe> FERMENTING_RECIPES = new ArrayList<>();
|
||||||
|
public static final List<LaserRecipe> CONVERSION_LASER_RECIPES = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime.
|
* Farmer behaviors are sorted when first accessed, this will not be done until after loading, but do not add behaviors at runtime.
|
||||||
*/
|
*/
|
||||||
|
@ -260,12 +262,12 @@ public final class ActuallyAdditionsAPI {
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type) {
|
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type) {
|
||||||
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
|
//RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse) {
|
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse) {
|
||||||
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
|
//addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -279,11 +281,11 @@ public final class ActuallyAdditionsAPI {
|
||||||
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
|
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
|
||||||
*/
|
*/
|
||||||
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type) {
|
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse, LensConversion type) {
|
||||||
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
|
//RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse) {
|
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse) {
|
||||||
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
|
//addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.FullyDirectionalBlock;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityFermentingBarrel;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.Lang;
|
import de.ellpeck.actuallyadditions.mod.util.Lang;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
@ -89,11 +90,17 @@ public class BlockAtomicReconstructor extends FullyDirectionalBlock.Container im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
//@Override
|
@Override
|
||||||
public TileEntity newBlockEntity(IBlockReader worldIn) {
|
public TileEntity createTileEntity(BlockState state, IBlockReader world) {
|
||||||
return new TileEntityAtomicReconstructor();
|
return new TileEntityAtomicReconstructor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasTileEntity(BlockState state) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// public BlockState getBaseConstructorState() {
|
// public BlockState getBaseConstructorState() {
|
||||||
// return this.stateContainer.getBaseState().with(FACING, Direction.NORTH);
|
// return this.stateContainer.getBaseState().with(FACING, Direction.NORTH);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -17,11 +17,13 @@ public class CommonConfig {
|
||||||
|
|
||||||
public static class MACHINES {
|
public static class MACHINES {
|
||||||
public static ForgeConfigSpec.IntValue FARMER_AREA;
|
public static ForgeConfigSpec.IntValue FARMER_AREA;
|
||||||
|
public static ForgeConfigSpec.IntValue RECONSTRUCTOR_POWER;
|
||||||
|
|
||||||
public static void build() {
|
public static void build() {
|
||||||
BUILDER.comment("Machine Settings").push("machineSettings");
|
BUILDER.comment("Machine Settings").push("machineSettings");
|
||||||
|
|
||||||
FARMER_AREA = BUILDER.comment("The size of the farmer's farming area. Default is 9x9, must be an odd number.").defineInRange("farmerArea", 9, 1, Integer.MAX_VALUE);
|
FARMER_AREA = BUILDER.comment("The size of the farmer's farming area. Default is 9x9, must be an odd number.").defineInRange("farmerArea", 9, 1, Integer.MAX_VALUE);
|
||||||
|
RECONSTRUCTOR_POWER = BUILDER.comment("The amount of power the atomic reconstructor can store.").defineInRange("reconstructorPower", 300000, 300000, Integer.MAX_VALUE);
|
||||||
|
|
||||||
BUILDER.pop();
|
BUILDER.pop();
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,13 +70,6 @@ public enum ConfigIntValues {
|
||||||
500,
|
500,
|
||||||
"The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."),
|
"The size of the booklet's large font in percent. Set to 0 to use defaults from the lang file."),
|
||||||
|
|
||||||
RECONSTRUCTOR_POWER(
|
|
||||||
"Atomic Reconstructor Power",
|
|
||||||
ConfigCategories.MACHINE_VALUES,
|
|
||||||
300000,
|
|
||||||
300000,
|
|
||||||
Integer.MAX_VALUE,
|
|
||||||
"The amount of power the atomic reconstructor can store."),
|
|
||||||
MINING_LENS_USE(
|
MINING_LENS_USE(
|
||||||
"Mining Lens Energy",
|
"Mining Lens Energy",
|
||||||
ConfigCategories.MACHINE_VALUES,
|
ConfigCategories.MACHINE_VALUES,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||||
|
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import net.minecraft.data.IFinishedRecipe;
|
import net.minecraft.data.IFinishedRecipe;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -16,6 +17,7 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.registries.ForgeRegistryEntry;
|
import net.minecraftforge.registries.ForgeRegistryEntry;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
|
||||||
public class LaserRecipe implements IRecipe<IInventory> {
|
public class LaserRecipe implements IRecipe<IInventory> {
|
||||||
|
@ -37,10 +39,13 @@ public class LaserRecipe implements IRecipe<IInventory> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matches(ItemStack itemStack, int energyIn) {
|
public boolean matches(ItemStack itemStack, int energyIn) {
|
||||||
|
|
||||||
return itemIngredient.test(itemStack) && (energyIn >= energy);
|
return itemIngredient.test(itemStack) && (energyIn >= energy);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean matches(ItemStack itemStack) {
|
||||||
|
return itemIngredient.test(itemStack);
|
||||||
|
}
|
||||||
|
|
||||||
//nah
|
//nah
|
||||||
@Override
|
@Override
|
||||||
public boolean matches(IInventory pInv, World pLevel) {
|
public boolean matches(IInventory pInv, World pLevel) {
|
||||||
|
@ -77,6 +82,14 @@ public class LaserRecipe implements IRecipe<IInventory> {
|
||||||
return ActuallyRecipes.Types.LASER;
|
return ActuallyRecipes.Types.LASER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Optional<LaserRecipe> getRecipeForStack(ItemStack stack) {
|
||||||
|
return ActuallyAdditionsAPI.CONVERSION_LASER_RECIPES.stream().filter(recipe -> recipe.matches(stack)).findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean validInput(ItemStack stack) {
|
||||||
|
return getRecipeForStack(stack).isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<LaserRecipe> {
|
public static class Serializer extends ForgeRegistryEntry<IRecipeSerializer<?>> implements IRecipeSerializer<LaserRecipe> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -58,7 +58,8 @@ public class LensColor extends Lens {
|
||||||
ItemStack returnStack = this.tryConvert(new ItemStack(block), hitState, hitBlock, tile);
|
ItemStack returnStack = this.tryConvert(new ItemStack(block), hitState, hitBlock, tile);
|
||||||
if (returnStack != null && returnStack.getItem() instanceof BlockItem) {
|
if (returnStack != null && returnStack.getItem() instanceof BlockItem) {
|
||||||
Block toPlace = Block.byItem(returnStack.getItem());
|
Block toPlace = Block.byItem(returnStack.getItem());
|
||||||
BlockState state2Place = toPlace.defaultBlockState(); //getStateForPlacement(tile.getWorldObject(), hitBlock, Direction.UP, 0, 0, 0, FakePlayerFactory.getMinecraft((ServerWorld) tile.getWorldObject()), Hand.MAIN_HAND); //TODO
|
BlockState state2Place = toPlace.defaultBlockState();
|
||||||
|
//getStateForPlacement(tile.getWorldObject(), hitBlock, Direction.UP, 0, 0, 0, FakePlayerFactory.getMinecraft((ServerWorld) tile.getWorldObject()), Hand.MAIN_HAND); //TODO
|
||||||
tile.getWorldObject().setBlock(hitBlock, state2Place, 2);
|
tile.getWorldObject().setBlock(hitBlock, state2Place, 2);
|
||||||
tile.extractEnergy(ENERGY_USE);
|
tile.extractEnergy(ENERGY_USE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.List;
|
||||||
|
|
||||||
public class LensMining extends Lens {
|
public class LensMining extends Lens {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() { //TODO ohhh boy
|
||||||
ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000);
|
ActuallyAdditionsAPI.addMiningLensStoneOre("oreCoal", 5000);
|
||||||
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000);
|
ActuallyAdditionsAPI.addMiningLensNetherOre("oreNetherCoal", 5000);
|
||||||
ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000);
|
ActuallyAdditionsAPI.addMiningLensStoneOre("oreIron", 3000);
|
||||||
|
|
|
@ -14,17 +14,29 @@ import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
||||||
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.blocks.BlockLaserRelay;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.crafting.LaserRecipe;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.items.lens.LensRecipeHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.entity.item.ItemEntity;
|
||||||
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.CompoundNBT;
|
import net.minecraft.nbt.CompoundNBT;
|
||||||
import net.minecraft.potion.Effect;
|
import net.minecraft.potion.Effect;
|
||||||
import net.minecraft.potion.EffectInstance;
|
import net.minecraft.potion.EffectInstance;
|
||||||
import net.minecraft.util.Direction;
|
import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.vector.Vector3i;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
public class MethodHandler implements IMethodHandler {
|
public class MethodHandler implements IMethodHandler {
|
||||||
|
|
||||||
|
@ -71,12 +83,12 @@ public class MethodHandler implements IMethodHandler {
|
||||||
for (int i = 0; i < effects.length; i++) {
|
for (int i = 0; i < effects.length; i++) {
|
||||||
if (effects[i].getEffect() == effect.getEffect()) {
|
if (effects[i].getEffect() == effect.getEffect()) {
|
||||||
effects[i] = new EffectInstance(effects[i].getEffect(), effects[i].getDuration() + (addDur
|
effects[i] = new EffectInstance(effects[i].getEffect(), effects[i].getDuration() + (addDur
|
||||||
? effect.getDuration()
|
? effect.getDuration()
|
||||||
: 0), effects[i].getAmplifier() + (addAmp
|
: 0), effects[i].getAmplifier() + (addAmp
|
||||||
? effect.getAmplifier() > 0
|
? effect.getAmplifier() > 0
|
||||||
? effect.getAmplifier()
|
? effect.getAmplifier()
|
||||||
: 1
|
: 1
|
||||||
: 0));
|
: 0));
|
||||||
}
|
}
|
||||||
this.addEffectToStack(stack, effects[i]);
|
this.addEffectToStack(stack, effects[i]);
|
||||||
}
|
}
|
||||||
|
@ -111,13 +123,13 @@ public class MethodHandler implements IMethodHandler {
|
||||||
counter--;
|
counter--;
|
||||||
}
|
}
|
||||||
return effects.size() > 0
|
return effects.size() > 0
|
||||||
? effects.toArray(new EffectInstance[effects.size()])
|
? effects.toArray(new EffectInstance[effects.size()])
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean invokeConversionLens(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
public boolean invokeConversionLens(BlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
||||||
/* if (hitBlock != null) {
|
if (hitBlock != null) {
|
||||||
int range = 1;
|
int range = 1;
|
||||||
int rangeX = 0;
|
int rangeX = 0;
|
||||||
int rangeY = 0;
|
int rangeY = 0;
|
||||||
|
@ -147,12 +159,12 @@ public class MethodHandler implements IMethodHandler {
|
||||||
if (state.getBlock() instanceof BlockLaserRelay) {
|
if (state.getBlock() instanceof BlockLaserRelay) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), tile.getLens());
|
Optional<LaserRecipe> recipe = LaserRecipe.getRecipeForStack(new ItemStack(state.getBlock()));
|
||||||
if (recipe != null && tile.getEnergy() >= recipe.getEnergyUsed()) {
|
if (recipe.isPresent() && tile.getEnergy() >= recipe.get().getEnergy()) {
|
||||||
ItemStack output = recipe.getOutput();
|
ItemStack output = recipe.get().getResultItem().copy();
|
||||||
if (StackUtil.isValid(output)) {
|
if (!output.isEmpty()) {
|
||||||
tile.getWorldObject().levelEvent(2001, pos, Block.getId(state));
|
tile.getWorldObject().levelEvent(2001, pos, Block.getId(state));
|
||||||
recipe.transformHook(ItemStack.EMPTY, state, pos, tile);
|
//recipe.transformHook(ItemStack.EMPTY, state, pos, tile); //TODO empty method
|
||||||
if (output.getItem() instanceof BlockItem) {
|
if (output.getItem() instanceof BlockItem) {
|
||||||
Block toPlace = Block.byItem(output.getItem());
|
Block toPlace = Block.byItem(output.getItem());
|
||||||
BlockState state2Place = toPlace.defaultBlockState(); //.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND); //TODO
|
BlockState state2Place = toPlace.defaultBlockState(); //.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), Hand.MAIN_HAND); //TODO
|
||||||
|
@ -163,7 +175,7 @@ public class MethodHandler implements IMethodHandler {
|
||||||
tile.getWorldObject().setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
tile.getWorldObject().setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
|
||||||
}
|
}
|
||||||
|
|
||||||
tile.extractEnergy(recipe.getEnergyUsed());
|
tile.extractEnergy(recipe.get().getEnergy());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,12 +192,12 @@ public class MethodHandler implements IMethodHandler {
|
||||||
for (ItemEntity item : items) {
|
for (ItemEntity item : items) {
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if (item.isAlive() && StackUtil.isValid(stack) && !item.getPersistentData().getBoolean("aa_cnv")) {
|
if (item.isAlive() && StackUtil.isValid(stack) && !item.getPersistentData().getBoolean("aa_cnv")) {
|
||||||
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens());
|
Optional<LaserRecipe> recipe = LaserRecipe.getRecipeForStack(stack);
|
||||||
if (recipe != null) {
|
if (recipe.isPresent()) {
|
||||||
int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount());
|
int itemsPossible = Math.min(tile.getEnergy() / recipe.get().getEnergy(), stack.getCount());
|
||||||
|
|
||||||
if (itemsPossible > 0) {
|
if (itemsPossible > 0) {
|
||||||
recipe.transformHook(item.getItem(), null, item.blockPosition(), tile);
|
//recipe.transformHook(item.getItem(), null, item.blockPosition(), tile); //TODO empty method
|
||||||
item.remove();
|
item.remove();
|
||||||
|
|
||||||
if (stack.getCount() - itemsPossible > 0) {
|
if (stack.getCount() - itemsPossible > 0) {
|
||||||
|
@ -196,21 +208,21 @@ public class MethodHandler implements IMethodHandler {
|
||||||
tile.getWorldObject().addFreshEntity(inputLeft);
|
tile.getWorldObject().addFreshEntity(inputLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack outputCopy = recipe.getOutput().copy();
|
ItemStack outputCopy = recipe.get().getResultItem().copy();
|
||||||
outputCopy.setCount(itemsPossible);
|
outputCopy.setCount(itemsPossible);
|
||||||
|
|
||||||
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getX(), item.getY(), item.getZ(), outputCopy);
|
ItemEntity newItem = new ItemEntity(tile.getWorldObject(), item.getX(), item.getY(), item.getZ(), outputCopy);
|
||||||
newItem.getPersistentData().putBoolean("aa_cnv", true);
|
newItem.getPersistentData().putBoolean("aa_cnv", true);
|
||||||
tile.getWorldObject().addFreshEntity(newItem);
|
tile.getWorldObject().addFreshEntity(newItem);
|
||||||
|
|
||||||
tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible);
|
tile.extractEnergy(recipe.get().getEnergy() * itemsPossible);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
|
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
|
||||||
}*/
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
import de.ellpeck.actuallyadditions.api.lens.ILensItem;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
import de.ellpeck.actuallyadditions.mod.blocks.ActuallyBlocks;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.config.CommonConfig;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
|
@ -45,7 +46,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
|
|
||||||
public TileEntityAtomicReconstructor() {
|
public TileEntityAtomicReconstructor() {
|
||||||
super(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getTileEntityType(), 1);
|
super(ActuallyBlocks.ATOMIC_RECONSTRUCTOR.getTileEntityType(), 1);
|
||||||
int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue();
|
int power = CommonConfig.MACHINES.RECONSTRUCTOR_POWER.get();
|
||||||
int recieve = MathHelper.ceil(power * 0.016666F);
|
int recieve = MathHelper.ceil(power * 0.016666F);
|
||||||
this.storage = new CustomEnergyStorage(power, recieve, 0);
|
this.storage = new CustomEnergyStorage(power, recieve, 0);
|
||||||
this.lazyEnergy = LazyOptional.of(() -> this.storage);
|
this.lazyEnergy = LazyOptional.of(() -> this.storage);
|
||||||
|
@ -153,7 +154,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IAcceptor getAcceptor() {
|
public IAcceptor getAcceptor() {
|
||||||
return (slot, stack, automation) -> StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
|
return (slot, stack, automation) -> !stack.isEmpty() && stack.getItem() instanceof ILensItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,6 +13,8 @@ package de.ellpeck.actuallyadditions.mod.util;
|
||||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||||
import com.mojang.blaze3d.platform.GlStateManager;
|
import com.mojang.blaze3d.platform.GlStateManager;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandler;
|
||||||
|
import de.ellpeck.actuallyadditions.mod.network.PacketServerToClient;
|
||||||
import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam;
|
import de.ellpeck.actuallyadditions.mod.particle.ParticleBeam;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
@ -30,6 +32,9 @@ import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
|
import net.minecraftforge.fml.network.NetworkRegistry;
|
||||||
|
import net.minecraftforge.fml.network.PacketDispatcher;
|
||||||
|
import net.minecraftforge.fml.network.PacketDistributor;
|
||||||
|
|
||||||
public final class AssetUtil {
|
public final class AssetUtil {
|
||||||
|
|
||||||
|
@ -214,7 +219,7 @@ public final class AssetUtil {
|
||||||
data.putFloat("Size", size);
|
data.putFloat("Size", size);
|
||||||
data.putInt("MaxAge", maxAge);
|
data.putInt("MaxAge", maxAge);
|
||||||
data.putFloat("Alpha", alpha);
|
data.putFloat("Alpha", alpha);
|
||||||
//PacketHandler.THE_NETWORK.sendToAllAround(new PacketServerToClient(data, PacketHandler.LASER_HANDLER), new NetworkRegistry.TargetPoint(world.provider.getDimension(), startX, startY, startZ, 96)); //TODO
|
PacketHandler.THE_NETWORK.send(PacketDistributor.NEAR.with(() -> new PacketDistributor.TargetPoint(startX, startY, startZ, 96, world.dimension())), new PacketServerToClient(data, PacketHandler.LASER_HANDLER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,11 +3,14 @@ package de.ellpeck.actuallyadditions.mod.util;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
import de.ellpeck.actuallyadditions.mod.crafting.ActuallyRecipes;
|
||||||
|
import net.minecraft.item.crafting.IRecipeType;
|
||||||
import net.minecraft.item.crafting.RecipeManager;
|
import net.minecraft.item.crafting.RecipeManager;
|
||||||
import net.minecraft.resources.DataPackRegistries;
|
import net.minecraft.resources.DataPackRegistries;
|
||||||
import net.minecraft.resources.IResourceManager;
|
import net.minecraft.resources.IResourceManager;
|
||||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public class ResourceReloader implements IResourceManagerReloadListener {
|
public class ResourceReloader implements IResourceManagerReloadListener {
|
||||||
private final DataPackRegistries data;
|
private final DataPackRegistries data;
|
||||||
|
@ -29,5 +32,8 @@ public class ResourceReloader implements IResourceManagerReloadListener {
|
||||||
|
|
||||||
ActuallyAdditionsAPI.FERMENTING_RECIPES.clear();
|
ActuallyAdditionsAPI.FERMENTING_RECIPES.clear();
|
||||||
ActuallyAdditionsAPI.FERMENTING_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.FERMENTING));
|
ActuallyAdditionsAPI.FERMENTING_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.FERMENTING));
|
||||||
|
|
||||||
|
ActuallyAdditionsAPI.CONVERSION_LASER_RECIPES.clear();
|
||||||
|
ActuallyAdditionsAPI.CONVERSION_LASER_RECIPES.addAll(recipeManager.getAllRecipesFor(ActuallyRecipes.Types.LASER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue