2020-09-09 16:49:01 +02:00
|
|
|
package de.ellpeck.actuallyadditions.common.misc.apiimpl;
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2018-06-23 01:39:30 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2016-10-30 17:13:46 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
2016-11-12 15:13:20 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
|
|
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
2016-05-14 14:14:06 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
2016-05-14 13:51:18 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
|
2017-02-20 13:19:19 +01:00
|
|
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
2016-05-14 13:51:18 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
|
2016-05-14 14:14:06 +02:00
|
|
|
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
|
2020-09-09 16:49:01 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.blocks.BlockLaserRelay;
|
2020-09-09 16:48:43 +02:00
|
|
|
import de.ellpeck.actuallyadditions.booklet.chapter.BookletChapter;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.chapter.BookletChapterTrials;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.page.PageCrafting;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.page.PageFurnace;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.page.PagePicture;
|
|
|
|
import de.ellpeck.actuallyadditions.booklet.page.PageTextOnly;
|
2020-09-09 16:49:01 +02:00
|
|
|
import de.ellpeck.actuallyadditions.common.config.values.ConfigStringListValues;
|
|
|
|
import de.ellpeck.actuallyadditions.common.items.lens.LensRecipeHandler;
|
|
|
|
import de.ellpeck.actuallyadditions.common.recipe.CrusherRecipeRegistry;
|
|
|
|
import de.ellpeck.actuallyadditions.common.tile.TileEntityAtomicReconstructor;
|
|
|
|
import de.ellpeck.actuallyadditions.common.util.StackUtil;
|
2016-05-14 14:14:06 +02:00
|
|
|
import net.minecraft.block.Block;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.entity.item.EntityItem;
|
|
|
|
import net.minecraft.item.ItemBlock;
|
2016-01-05 04:47:35 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-07-31 17:20:49 +02:00
|
|
|
import net.minecraft.item.crafting.IRecipe;
|
2016-01-05 04:47:35 +01:00
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2016-03-18 23:47:22 +01:00
|
|
|
import net.minecraft.potion.Potion;
|
2016-01-05 04:47:35 +01:00
|
|
|
import net.minecraft.potion.PotionEffect;
|
2016-12-03 13:29:20 +01:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2017-08-17 07:06:09 +02:00
|
|
|
import net.minecraft.util.EnumHand;
|
2016-07-31 17:20:49 +02:00
|
|
|
import net.minecraft.util.ResourceLocation;
|
2016-05-14 14:14:06 +02:00
|
|
|
import net.minecraft.util.math.AxisAlignedBB;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
2019-05-18 20:16:27 +02:00
|
|
|
import net.minecraft.util.math.Vec3i;
|
2017-08-17 07:06:09 +02:00
|
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
public class MethodHandler implements IMethodHandler {
|
2016-01-05 04:47:35 +01:00
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean addEffectToStack(ItemStack stack, CoffeeIngredient ingredient) {
|
2016-01-05 04:47:35 +01:00
|
|
|
boolean worked = false;
|
2019-05-02 09:10:29 +02:00
|
|
|
if (ingredient != null) {
|
2016-01-05 04:47:35 +01:00
|
|
|
PotionEffect[] effects = ingredient.getEffects();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (effects != null && effects.length > 0) {
|
|
|
|
for (PotionEffect effect : effects) {
|
2016-05-14 13:51:18 +02:00
|
|
|
PotionEffect effectHas = this.getSameEffectFromStack(stack, effect);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (effectHas != null) {
|
|
|
|
if (effectHas.getAmplifier() < ingredient.getMaxAmplifier() - 1) {
|
2016-05-14 13:51:18 +02:00
|
|
|
this.addEffectProperties(stack, effect, false, true);
|
2016-01-05 04:47:35 +01:00
|
|
|
worked = true;
|
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2016-05-14 13:51:18 +02:00
|
|
|
this.addEffectToStack(stack, effect);
|
2016-01-05 04:47:35 +01:00
|
|
|
worked = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return worked;
|
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public PotionEffect getSameEffectFromStack(ItemStack stack, PotionEffect effect) {
|
2016-05-14 13:51:18 +02:00
|
|
|
PotionEffect[] effectsStack = this.getEffectsFromStack(stack);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (effectsStack != null && effectsStack.length > 0) {
|
|
|
|
for (PotionEffect effectStack : effectsStack) {
|
|
|
|
if (effect.getPotion() == effectStack.getPotion()) { return effectStack; }
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void addEffectProperties(ItemStack stack, PotionEffect effect, boolean addDur, boolean addAmp) {
|
2016-05-14 13:51:18 +02:00
|
|
|
PotionEffect[] effects = this.getEffectsFromStack(stack);
|
2016-01-05 04:47:35 +01:00
|
|
|
stack.setTagCompound(new NBTTagCompound());
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int i = 0; i < effects.length; i++) {
|
|
|
|
if (effects[i].getPotion() == effect.getPotion()) {
|
|
|
|
effects[i] = new PotionEffect(effects[i].getPotion(), effects[i].getDuration() + (addDur ? effect.getDuration() : 0), effects[i].getAmplifier() + (addAmp ? effect.getAmplifier() > 0 ? effect.getAmplifier() : 1 : 0));
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|
2016-05-14 13:51:18 +02:00
|
|
|
this.addEffectToStack(stack, effects[i]);
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public void addEffectToStack(ItemStack stack, PotionEffect effect) {
|
2016-01-05 04:47:35 +01:00
|
|
|
NBTTagCompound tag = stack.getTagCompound();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (tag == null) {
|
2016-01-05 04:47:35 +01:00
|
|
|
tag = new NBTTagCompound();
|
|
|
|
}
|
|
|
|
|
|
|
|
int prevCounter = tag.getInteger("Counter");
|
|
|
|
NBTTagCompound compound = new NBTTagCompound();
|
2016-03-18 23:47:22 +01:00
|
|
|
compound.setInteger("ID", Potion.getIdFromPotion(effect.getPotion()));
|
2016-01-05 04:47:35 +01:00
|
|
|
compound.setInteger("Duration", effect.getDuration());
|
|
|
|
compound.setInteger("Amplifier", effect.getAmplifier());
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
int counter = prevCounter + 1;
|
|
|
|
tag.setTag(counter + "", compound);
|
2016-01-05 04:47:35 +01:00
|
|
|
tag.setInteger("Counter", counter);
|
|
|
|
|
|
|
|
stack.setTagCompound(tag);
|
|
|
|
}
|
|
|
|
|
2016-05-14 13:51:18 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public PotionEffect[] getEffectsFromStack(ItemStack stack) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ArrayList<PotionEffect> effects = new ArrayList<>();
|
2016-01-05 04:47:35 +01:00
|
|
|
NBTTagCompound tag = stack.getTagCompound();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (tag != null) {
|
2016-01-05 04:47:35 +01:00
|
|
|
int counter = tag.getInteger("Counter");
|
2019-05-02 09:10:29 +02:00
|
|
|
while (counter > 0) {
|
|
|
|
NBTTagCompound compound = (NBTTagCompound) tag.getTag(counter + "");
|
2016-03-18 23:47:22 +01:00
|
|
|
PotionEffect effect = new PotionEffect(Potion.getPotionById(compound.getInteger("ID")), compound.getInteger("Duration"), compound.getByte("Amplifier"));
|
|
|
|
effects.add(effect);
|
2016-01-05 04:47:35 +01:00
|
|
|
counter--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return effects.size() > 0 ? effects.toArray(new PotionEffect[effects.size()]) : null;
|
|
|
|
}
|
2016-05-14 14:14:06 +02:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile) {
|
|
|
|
if (hitBlock != null) {
|
2016-12-03 13:29:20 +01:00
|
|
|
int range = 1;
|
|
|
|
int rangeX = 0;
|
|
|
|
int rangeY = 0;
|
|
|
|
int rangeZ = 0;
|
|
|
|
|
|
|
|
EnumFacing facing = tile.getOrientation();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (facing != EnumFacing.UP && facing != EnumFacing.DOWN) {
|
2016-12-03 13:29:20 +01:00
|
|
|
rangeY = range;
|
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (facing == EnumFacing.NORTH || facing == EnumFacing.SOUTH) {
|
2016-12-03 13:29:20 +01:00
|
|
|
rangeX = range;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2016-12-03 13:29:20 +01:00
|
|
|
rangeZ = range;
|
|
|
|
}
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
2016-12-03 13:29:20 +01:00
|
|
|
rangeX = range;
|
|
|
|
rangeZ = range;
|
|
|
|
}
|
2016-05-14 14:14:06 +02:00
|
|
|
|
|
|
|
//Converting the Blocks
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int reachX = -rangeX; reachX <= rangeX; reachX++) {
|
|
|
|
for (int reachZ = -rangeZ; reachZ <= rangeZ; reachZ++) {
|
|
|
|
for (int reachY = -rangeY; reachY <= rangeY; reachY++) {
|
|
|
|
BlockPos pos = new BlockPos(hitBlock.getX() + reachX, hitBlock.getY() + reachY, hitBlock.getZ() + reachZ);
|
|
|
|
if (!tile.getWorldObject().isAirBlock(pos)) {
|
2016-10-19 18:38:57 +02:00
|
|
|
IBlockState state = tile.getWorldObject().getBlockState(pos);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (state.getBlock() instanceof BlockLaserRelay) continue;
|
2018-06-24 02:44:47 +02:00
|
|
|
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), tile.getLens());
|
2019-05-02 09:10:29 +02:00
|
|
|
if (recipe != null && tile.getEnergy() >= recipe.getEnergyUsed()) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack output = recipe.getOutput();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (StackUtil.isValid(output)) {
|
2019-02-27 19:53:05 +01:00
|
|
|
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(state));
|
|
|
|
recipe.transformHook(ItemStack.EMPTY, state, pos, tile);
|
2019-05-02 09:10:29 +02:00
|
|
|
if (output.getItem() instanceof ItemBlock) {
|
2019-02-27 19:53:05 +01:00
|
|
|
Block toPlace = Block.getBlockFromItem(output.getItem());
|
|
|
|
IBlockState state2Place = toPlace.getStateForPlacement(tile.getWorldObject(), pos, facing, 0, 0, 0, output.getMetadata(), FakePlayerFactory.getMinecraft((WorldServer) tile.getWorldObject()), EnumHand.MAIN_HAND);
|
|
|
|
tile.getWorldObject().setBlockState(pos, state2Place, 2);
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
|
|
|
EntityItem item = new EntityItem(tile.getWorldObject(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, output.copy());
|
2019-02-27 19:53:05 +01:00
|
|
|
tile.getWorldObject().spawnEntity(item);
|
|
|
|
tile.getWorldObject().setBlockToAir(pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
tile.extractEnergy(recipe.getEnergyUsed());
|
|
|
|
break;
|
2016-05-14 14:14:06 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
}
|
2016-05-14 14:14:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//Converting the Items
|
2019-05-02 10:17:02 +02:00
|
|
|
AxisAlignedBB aabb = new AxisAlignedBB(tile.getPosition().getX(), tile.getPosition().getY(), tile.getPosition().getZ(), hitBlock.getX() + 1, hitBlock.getY() + 1, hitBlock.getZ() + 1);
|
2019-05-18 20:16:27 +02:00
|
|
|
Vec3i dir = tile.getOrientation().getDirectionVec();
|
|
|
|
aabb = aabb.grow(0.02, 0.02, 0.02).expand(dir.getX(), dir.getY(), dir.getZ());
|
2019-05-02 10:17:02 +02:00
|
|
|
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, aabb);
|
2019-05-02 09:10:29 +02:00
|
|
|
for (EntityItem item : items) {
|
2017-06-29 18:30:02 +02:00
|
|
|
ItemStack stack = item.getItem();
|
2019-07-09 07:38:24 +02:00
|
|
|
if (!item.isDead && StackUtil.isValid(stack) && !item.getEntityData().getBoolean("aa_cnv")) {
|
2018-06-24 02:44:47 +02:00
|
|
|
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens());
|
2019-05-02 09:10:29 +02:00
|
|
|
if (recipe != null) {
|
|
|
|
int itemsPossible = Math.min(tile.getEnergy() / recipe.getEnergyUsed(), stack.getCount());
|
2016-05-14 14:14:06 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (itemsPossible > 0) {
|
2019-02-27 19:53:05 +01:00
|
|
|
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
|
|
|
|
item.setDead();
|
2016-05-14 14:14:06 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (stack.getCount() - itemsPossible > 0) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack stackCopy = stack.copy();
|
|
|
|
stackCopy.shrink(itemsPossible);
|
2016-05-14 14:14:06 +02:00
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
|
|
|
|
tile.getWorldObject().spawnEntity(inputLeft);
|
|
|
|
}
|
2016-11-02 21:15:28 +01:00
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack outputCopy = recipe.getOutput().copy();
|
|
|
|
outputCopy.setCount(itemsPossible);
|
2016-11-02 21:15:28 +01:00
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
|
2019-07-09 07:38:24 +02:00
|
|
|
newItem.getEntityData().setBoolean("aa_cnv", true);
|
2019-02-27 19:53:05 +01:00
|
|
|
tile.getWorldObject().spawnEntity(newItem);
|
2016-11-02 21:15:28 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
tile.extractEnergy(recipe.getEnergyUsed() * itemsPossible);
|
2019-02-27 19:53:05 +01:00
|
|
|
break;
|
2016-05-14 14:14:06 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
}
|
2016-05-14 14:14:06 +02:00
|
|
|
}
|
2016-12-03 13:29:20 +01:00
|
|
|
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
|
2016-05-14 14:14:06 +02:00
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2016-07-31 17:20:49 +02:00
|
|
|
|
2017-02-20 13:19:19 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean invokeReconstructor(IAtomicReconstructor tile) {
|
|
|
|
if (tile.getEnergy() >= TileEntityAtomicReconstructor.ENERGY_USE) {
|
2017-02-20 13:24:57 +01:00
|
|
|
EnumFacing sideToManipulate = tile.getOrientation();
|
2017-02-20 13:19:19 +01:00
|
|
|
Lens currentLens = tile.getLens();
|
2019-05-02 09:10:29 +02:00
|
|
|
if (currentLens.canInvoke(tile, sideToManipulate, TileEntityAtomicReconstructor.ENERGY_USE)) {
|
2017-02-20 13:19:19 +01:00
|
|
|
tile.extractEnergy(TileEntityAtomicReconstructor.ENERGY_USE);
|
|
|
|
|
|
|
|
int distance = currentLens.getDistance();
|
2019-05-02 09:10:29 +02:00
|
|
|
for (int i = 0; i < distance; i++) {
|
|
|
|
BlockPos hitBlock = tile.getPosition().offset(sideToManipulate, i + 1);
|
2017-02-20 13:19:19 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (currentLens.invoke(tile.getWorldObject().getBlockState(hitBlock), hitBlock, tile) || i >= distance - 1) {
|
2017-02-20 13:19:19 +01:00
|
|
|
TileEntityAtomicReconstructor.shootLaser(tile.getWorldObject(), tile.getX(), tile.getY(), tile.getZ(), hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), currentLens);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-10-30 17:13:46 +01:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance) {
|
2016-10-30 17:13:46 +01:00
|
|
|
boolean hasWorkedOnce = false;
|
2019-05-02 09:10:29 +02:00
|
|
|
for (ItemStack input : inputs) {
|
|
|
|
if (StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null) {
|
|
|
|
for (ItemStack outputOne : outputOnes) {
|
|
|
|
if (StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) {
|
2016-10-30 17:13:46 +01:00
|
|
|
ItemStack outputOneCopy = outputOne.copy();
|
2018-06-23 01:39:30 +02:00
|
|
|
outputOneCopy.setCount(outputOneAmounts);
|
2016-10-30 17:13:46 +01:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (outputTwos.isEmpty()) {
|
2017-11-02 22:49:53 +01:00
|
|
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
|
2016-10-30 17:13:46 +01:00
|
|
|
hasWorkedOnce = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else {
|
|
|
|
for (ItemStack outputTwo : outputTwos) {
|
|
|
|
if (StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) {
|
2016-10-30 17:13:46 +01:00
|
|
|
ItemStack outputTwoCopy = outputTwo.copy();
|
2018-06-23 01:39:30 +02:00
|
|
|
outputTwoCopy.setCount(outputTwoAmounts);
|
2016-10-30 17:13:46 +01:00
|
|
|
|
|
|
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
|
|
|
hasWorkedOnce = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return hasWorkedOnce;
|
2017-08-08 17:05:44 +02:00
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
|
2017-08-08 17:05:44 +02:00
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance) {
|
2017-08-08 17:05:44 +02:00
|
|
|
boolean hasWorkedOnce = false;
|
2019-05-02 09:10:29 +02:00
|
|
|
for (ItemStack input : inputs) {
|
|
|
|
if (StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null) {
|
|
|
|
if (StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack outputOneCopy = outputOne.copy();
|
|
|
|
outputOneCopy.setCount(outputOneAmount);
|
2017-08-08 17:05:44 +02:00
|
|
|
|
2019-05-02 09:10:29 +02:00
|
|
|
if (!StackUtil.isValid(outputTwo)) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
|
|
|
|
hasWorkedOnce = true;
|
2019-05-02 09:10:29 +02:00
|
|
|
} else if (StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())) {
|
2019-02-27 19:53:05 +01:00
|
|
|
ItemStack outputTwoCopy = outputTwo.copy();
|
|
|
|
outputTwoCopy.setCount(outputTwoAmount);
|
2017-08-08 17:05:44 +02:00
|
|
|
|
2019-02-27 19:53:05 +01:00
|
|
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
|
|
|
hasWorkedOnce = true;
|
2017-08-08 17:05:44 +02:00
|
|
|
}
|
|
|
|
}
|
2019-02-27 19:53:05 +01:00
|
|
|
}
|
|
|
|
}
|
2017-08-08 17:05:44 +02:00
|
|
|
return hasWorkedOnce;
|
2016-10-30 17:13:46 +01:00
|
|
|
}
|
2016-11-12 15:13:20 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateTextPage(int id) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return this.generateTextPage(id, 0);
|
2016-11-12 15:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return this.generatePicturePage(id, resLoc, textStartY, 0);
|
2016-11-12 15:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateCraftingPage(int id, IRecipe... recipes) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return this.generateCraftingPage(id, 0, recipes);
|
2016-11-12 15:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return this.generateFurnacePage(id, input, result, 0);
|
2016-11-12 15:13:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, IBookletPage... pages) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return this.generateBookletChapter(identifier, entry, displayStack, 0, pages);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateTextPage(int id, int priority) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return new PageTextOnly(id, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generatePicturePage(int id, ResourceLocation resLoc, int textStartY, int priority) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return new PagePicture(id, resLoc, textStartY, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateCraftingPage(int id, int priority, IRecipe... recipes) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return new PageCrafting(id, priority, recipes);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletPage generateFurnacePage(int id, ItemStack input, ItemStack result, int priority) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return new PageFurnace(id, result, priority);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletChapter generateBookletChapter(String identifier, IBookletEntry entry, ItemStack displayStack, int priority, IBookletPage... pages) {
|
2016-11-22 22:54:35 +01:00
|
|
|
return new BookletChapter(identifier, entry, displayStack, priority, pages);
|
2016-11-12 15:13:20 +01:00
|
|
|
}
|
2017-02-18 00:54:58 +01:00
|
|
|
|
|
|
|
@Override
|
2019-05-02 09:10:29 +02:00
|
|
|
public IBookletChapter createTrial(String identifier, ItemStack displayStack, boolean textOnSecondPage) {
|
2017-02-18 00:54:58 +01:00
|
|
|
return new BookletChapterTrials(identifier, displayStack, textOnSecondPage);
|
|
|
|
}
|
2016-01-05 04:47:35 +01:00
|
|
|
}
|