More major updating

Migrates the rest of the recipe system to Ingredient inputs, Migrates
the compost to an IBakedModel instead of a TESR
This commit is contained in:
Shadows_of_Fire 2018-06-23 20:44:47 -04:00
parent 5bbca0ee30
commit 5c149648da
40 changed files with 980 additions and 467 deletions

View file

@ -34,6 +34,7 @@ import de.ellpeck.actuallyadditions.api.recipe.OilGenRecipe;
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
@ -200,10 +201,23 @@ public final class ActuallyAdditionsAPI{
* @param output The itemstack to be output from the compost once conversion finishes
* @param outputDisplay The block to display when there is output in the compost
*/
@Deprecated
public static void addCompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay){
COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay));
}
/**
* Adds a new conversion recipe to the compost.
*
* @param input The ingredient to be input into the compost
* @param inputDisplay The state to display when there is input in the compost
* @param output The itemstack to be output from the compost once conversion finishes
* @param outputDisplay The state to display when there is output in the compost
*/
public static void addCompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){
COMPOST_RECIPES.add(new CompostRecipe(input, inputDisplay, output, outputDisplay));
}
/**
* Adds an item to the list of possible items to be returned when right-clicking a Ball Of Fur
*
@ -226,10 +240,15 @@ public final class ActuallyAdditionsAPI{
TREASURE_CHEST_LOOT.add(new TreasureChestLoot(stack, chance, minAmount, maxAmount));
}
@Deprecated
public static void addEmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor){
EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor));
}
public static void addEmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor){
EMPOWERER_RECIPES.add(new EmpowererRecipe(input, output, modifier1, modifier2, modifier3, modifier4, energyPerStand, time, particleColor));
}
/**
* Adds a recipe to the Atomic Reconstructor conversion lenses
* StackSizes can only be 1 and greater ones will be ignored
@ -240,14 +259,34 @@ public final class ActuallyAdditionsAPI{
* @param type The type of lens used for the conversion. To use the default type, use method below.
* Note how this always has to be the same instance of the lens type that the item also has for it to work!
*/
@Deprecated
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
@Deprecated
public static void addReconstructorLensConversionRecipe(ItemStack input, ItemStack output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**
* Adds a recipe to the Atomic Reconstructor conversion lenses
* StackSizes can only be 1 and greater ones will be ignored
*
* @param input The input as an ItemStack
* @param output The output as an ItemStack
* @param energyUse The amount of RF used per conversion
* @param type The type of lens used for the conversion. To use the default type, use method below.
* 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){
RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(new LensConversionRecipe(input, output, energyUse, type));
}
public static void addReconstructorLensConversionRecipe(Ingredient input, ItemStack output, int energyUse){
addReconstructorLensConversionRecipe(input, output, energyUse, lensDefaultConversion);
}
/**
* Adds an item and the way it is modified to the Atomic Reconstructor's color lens.
* This also works for blocks, but they have to be in their item form.

View file

@ -12,20 +12,34 @@ package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.potion.PotionEffect;
public class CoffeeIngredient {
public final ItemStack ingredient;
public final int maxAmplifier;
protected final Ingredient input;
protected final int maxAmplifier;
protected PotionEffect[] effects;
public CoffeeIngredient(ItemStack ingredient, PotionEffect[] effects, int maxAmplifier){
this.ingredient = ingredient.copy();
@Deprecated
public CoffeeIngredient(ItemStack input, PotionEffect[] effects, int maxAmplifier) {
this(Ingredient.fromStacks(input), maxAmplifier, effects);
}
public CoffeeIngredient(Ingredient input, int maxAmplifier, PotionEffect... effects) {
this.input = input;
this.effects = effects;
this.maxAmplifier = maxAmplifier;
}
public boolean matches(ItemStack stack) {
return input.apply(stack);
}
public Ingredient getInput() {
return input;
}
public PotionEffect[] getEffects() {
return this.effects;
}
@ -37,4 +51,8 @@ public class CoffeeIngredient{
public String getExtraText() {
return "";
}
public int getMaxAmplifier() {
return maxAmplifier;
}
}

View file

@ -11,20 +11,47 @@
package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public class CompostRecipe{
public final ItemStack input;
public final ItemStack output;
public final Block inputDisplay;
public final Block outputDisplay;
protected final Ingredient input;
protected final ItemStack output;
protected final IBlockState inputDisplay;
protected final IBlockState outputDisplay;
@Deprecated
public CompostRecipe(ItemStack input, Block inputDisplay, ItemStack output, Block outputDisplay) {
this(Ingredient.fromStacks(input), inputDisplay.getDefaultState(), output, outputDisplay.getDefaultState());
}
public CompostRecipe(Ingredient input, IBlockState inputDisplay, ItemStack output, IBlockState outputDisplay){
this.input = input;
this.output = output;
this.inputDisplay = inputDisplay;
this.outputDisplay = outputDisplay;
}
public boolean matches(ItemStack stack) {
return input.apply(stack);
}
public Ingredient getInput() {
return input;
}
public ItemStack getOutput() {
return output;
}
public IBlockState getInputDisplay() {
return inputDisplay;
}
public IBlockState getOutputDisplay() {
return outputDisplay;
}
}

View file

@ -15,15 +15,12 @@ import net.minecraft.item.crafting.Ingredient;
public class CrusherRecipe {
@Deprecated //ModTweaker compat, will be removed soon.
public ItemStack outputOneStack;
protected Ingredient input;
protected ItemStack outputOne;
protected ItemStack outputTwo;
protected int outputChance;
private Ingredient input;
private ItemStack outputOne;
private ItemStack outputTwo;
private int outputChance;
@Deprecated //ModTweaker compat, will be removed soon.
@Deprecated
public CrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputChance) {
this(Ingredient.fromStacks(input), outputOne, outputTwo, outputChance);
}
@ -33,7 +30,6 @@ public class CrusherRecipe {
this.outputOne = outputOne;
this.outputTwo = outputTwo;
this.outputChance = outputChance;
outputOneStack = outputOne;
}
public boolean matches(ItemStack stack) {

View file

@ -11,22 +11,28 @@
package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public class EmpowererRecipe {
public ItemStack input;
public ItemStack output;
protected final Ingredient input;
protected final ItemStack output;
public ItemStack modifier1;
public ItemStack modifier2;
public ItemStack modifier3;
public ItemStack modifier4;
protected final Ingredient modifier1;
protected final Ingredient modifier2;
protected final Ingredient modifier3;
protected final Ingredient modifier4;
public int energyPerStand;
public float[] particleColor;
public int time;
protected final int energyPerStand;
protected final float[] particleColor;
protected final int time;
@Deprecated
public EmpowererRecipe(ItemStack input, ItemStack output, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3, ItemStack modifier4, int energyPerStand, int time, float[] particleColor) {
this(Ingredient.fromStacks(input), output, Ingredient.fromStacks(modifier1), Ingredient.fromStacks(modifier2), Ingredient.fromStacks(modifier3), Ingredient.fromStacks(modifier4), energyPerStand, time, particleColor);
}
public EmpowererRecipe(Ingredient input, ItemStack output, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3, Ingredient modifier4, int energyPerStand, int time, float[] particleColor) {
this.input = input;
this.output = output;
this.modifier1 = modifier1;
@ -37,4 +43,44 @@ public class EmpowererRecipe{
this.particleColor = particleColor;
this.time = time;
}
public boolean matches(ItemStack base, ItemStack stand1, ItemStack stand2, ItemStack stand3, ItemStack stand4) {
return input.apply(base) && modifier1.apply(stand1) && modifier2.apply(stand2) && modifier3.apply(stand3) && modifier4.apply(stand4);
}
public Ingredient getInput() {
return input;
}
public ItemStack getOutput() {
return output;
}
public Ingredient getStandOne() {
return modifier1;
}
public Ingredient getStandTwo() {
return modifier2;
}
public Ingredient getStandThree() {
return modifier3;
}
public Ingredient getStandFour() {
return modifier4;
}
public int getTime() {
return time;
}
public int getEnergyPerStand() {
return energyPerStand;
}
public float[] getParticleColors() {
return particleColor;
}
}

View file

@ -11,24 +11,51 @@
package de.ellpeck.actuallyadditions.api.recipe;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.math.BlockPos;
public class LensConversionRecipe {
public final int energyUse;
public final LensConversion type;
public ItemStack inputStack;
public ItemStack outputStack;
protected final Ingredient input;
protected final ItemStack output;
protected final int energy;
protected final Lens type;
public LensConversionRecipe(ItemStack input, ItemStack output, int energyUse, LensConversion type){
this.inputStack = input;
this.outputStack = output;
this.energyUse = energyUse;
@Deprecated
public LensConversionRecipe(ItemStack input, ItemStack output, int energy, Lens type) {
this(Ingredient.fromStacks(input), output, energy, type);
}
public LensConversionRecipe(Ingredient input, ItemStack output, int energy, Lens type) {
this.input = input;
this.output = output;
this.energy = energy;
this.type = type;
}
public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) {}
public boolean matches(ItemStack input, Lens lens) {
return this.input.apply(input) && this.type == lens;
}
public Ingredient getInput() {
return input;
}
public ItemStack getOutput() {
return output;
}
public int getEnergyUsed() {
return energy;
}
public Lens getType() {
return type;
}
public void transformHook(ItemStack stack, IBlockState state, BlockPos pos, IAtomicReconstructor tile) {
}
}

View file

@ -1,5 +1,7 @@
package de.ellpeck.actuallyadditions.mod;
import de.ellpeck.actuallyadditions.mod.blocks.render.ActualCompostModel;
import de.ellpeck.actuallyadditions.mod.blocks.render.CompostModel;
import de.ellpeck.actuallyadditions.mod.blocks.render.IHasModel;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.util.FluidStateMapper;
@ -7,6 +9,8 @@ import net.minecraft.block.Block;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.event.ModelRegistryEvent;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.Fluid;
@ -48,4 +52,11 @@ public class ClientRegistryHandler{
registerCustomFluidBlockRenderer(InitFluids.fluidCrystalOil);
registerCustomFluidBlockRenderer(InitFluids.fluidEmpoweredOil);
}
@SubscribeEvent
public void onModelBake(ModelBakeEvent e) {
ModelResourceLocation mrl = new ModelResourceLocation(new ResourceLocation(ActuallyAdditions.MODID, "block_compost"), "normal");
CompostModel.compostBase = e.getModelRegistry().getObject(mrl);
e.getModelRegistry().putObject(mrl, new ActualCompostModel());
}
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.List;
import org.apache.commons.lang3.tuple.Pair;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
@ -19,6 +23,8 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.ScaledResolution;
@ -27,6 +33,7 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
@ -35,11 +42,12 @@ import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.property.ExtendedBlockState;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.common.property.IUnlistedProperty;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class BlockCompost extends BlockContainerBase implements IHudDisplay {
protected static final AxisAlignedBB AABB_LEGS = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.3125D, 1.0D);
@ -102,11 +110,10 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
compost.inv.setStackInSlot(0, stackToAdd);
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
return true;
}
else{
} else {
ItemStack stackIn = slot.copy();
if(stackIn.getCount() < recipeHand.input.getMaxStackSize()){
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-stackIn.getCount());
if (stackIn.getCount() < slot.getMaxStackSize()) {
int sizeAdded = Math.min(maxAdd, slot.getMaxStackSize() - stackIn.getCount());
stackIn.grow(sizeAdded);
compost.inv.setStackInSlot(0, stackIn);
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
@ -115,14 +122,12 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
}
}
}
}
else{
} else {
if (!StackUtil.isValid(stackPlayer)) {
player.setHeldItem(hand, slot.copy());
compost.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
}
else if(ItemUtil.canBeStacked(stackPlayer, slot)){
} else if (ItemUtil.canBeStacked(stackPlayer, slot)) {
int addedStackSize = Math.min(slot.getCount(), stackPlayer.getMaxStackSize() - stackPlayer.getCount());
ItemStack stackToAdd = stackPlayer.copy();
stackToAdd.grow(addedStackSize);
@ -132,15 +137,15 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
}
}
tile.markDirty();
world.notifyBlockUpdate(pos, getDefaultState(), getDefaultState(), 3);
}
}
else{
} else {
return true;
}
return false;
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new TileEntityCompost();
@ -160,8 +165,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
String strg;
if (!StackUtil.isValid(slot)) {
strg = "Empty";
}
else{
} else {
strg = slot.getDisplayName();
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth() / 2 + 15, resolution.getScaledHeight() / 2 - 29, 1F);
@ -169,4 +173,50 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
minecraft.fontRenderer.drawStringWithShadow(TextFormatting.YELLOW + "" + TextFormatting.ITALIC + strg, resolution.getScaledWidth() / 2 + 35, resolution.getScaledHeight() / 2 - 25, StringUtil.DECIMAL_COLOR_WHITE);
}
}
@Override
protected BlockStateContainer createBlockState() {
return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[] { COMPOST_PROP });
}
@Override
public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityCompost && state instanceof IExtendedBlockState) {
TileEntityCompost compost = (TileEntityCompost) te;
return ((IExtendedBlockState) state).withProperty(COMPOST_PROP, Pair.of(compost.getCurrentDisplay(), compost.getHeight()));
}
return state;
}
public BlockRenderLayer getBlockLayer() {
return BlockRenderLayer.CUTOUT;
}
public static CompostProperty COMPOST_PROP = new CompostProperty();
@SuppressWarnings("rawtypes")
private static class CompostProperty implements IUnlistedProperty<Pair> {
@Override
public String getName() {
return "compost";
}
@Override
public boolean isValid(Pair value) {
return true;
}
@Override
public Class<Pair> getType() {
return Pair.class;
}
@Override
public String valueToString(Pair value) {
return "";
}
}
}

View file

@ -57,7 +57,7 @@ public class BlockEmpowerer extends BlockContainerBase{
if(empowerer != null){
ItemStack stackThere = empowerer.inv.getStackInSlot(0);
if(StackUtil.isValid(heldItem)){
if(!StackUtil.isValid(stackThere) && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
if(!StackUtil.isValid(stackThere) && TileEntityEmpowerer.isPossibleInput(heldItem)){
ItemStack toPut = heldItem.copy();
toPut.grow(1);
empowerer.inv.setStackInSlot(0, toPut);

View file

@ -0,0 +1,63 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.tuple.Pair;
import de.ellpeck.actuallyadditions.mod.blocks.BlockCompost;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.property.IExtendedBlockState;
public class ActualCompostModel implements IBakedModel {
public static final Map<Pair<IBlockState, Float>, IBakedModel> MODELS = new HashMap<>();
@SuppressWarnings("unchecked")
@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
if (state instanceof IExtendedBlockState) {
Pair<IBlockState, Float> data = ((IExtendedBlockState) state).getValue(BlockCompost.COMPOST_PROP);
if (data == null || data.getRight() <= 0) return CompostModel.compostBase.getQuads(state, side, rand);
IBakedModel model = MODELS.get(data);
if (model == null) {
model = new CompostModel(data.getLeft(), data.getRight());
MODELS.put(data, model);
}
return model.getQuads(state, side, rand);
}
return CompostModel.compostBase.getQuads(state, side, rand);
}
@Override
public boolean isAmbientOcclusion() {
return CompostModel.compostBase.isAmbientOcclusion();
}
@Override
public boolean isGui3d() {
return false;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
public TextureAtlasSprite getParticleTexture() {
return CompostModel.compostBase.getParticleTexture();
}
@Override
public ItemOverrideList getOverrides() {
return ItemOverrideList.NONE;
}
}

View file

@ -0,0 +1,94 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import java.util.EnumMap;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Vector3f;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.model.TRSRTransformation;
public class CompostModel implements IBakedModel {
public static IBakedModel compostBase;
private final IBakedModel display;
private final ImmutableList<BakedQuad> general;
private final ImmutableMap<EnumFacing, ImmutableList<BakedQuad>> faces;
public CompostModel(IBlockState flowerState, float height) {
this.display = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(flowerState);
TRSRTransformation transform = TRSRTransformation.blockCenterToCorner(new TRSRTransformation(new Vector3f(0, -.218F, 0), null, new Vector3f(0.75F, height / 1.81F, 0.75F), null));
ImmutableList.Builder<BakedQuad> builder;
EnumMap<EnumFacing, ImmutableList<BakedQuad>> faces = new EnumMap<>(EnumFacing.class);
for (EnumFacing face : EnumFacing.values()) {
builder = ImmutableList.builder();
if (!display.isBuiltInRenderer()) {
for (BakedQuad quad : display.getQuads(flowerState, face, 0)) {
Transformer transformer = new Transformer(transform, quad.getFormat());
quad.pipe(transformer);
builder.add(transformer.build());
}
builder.addAll(compostBase.getQuads(null, face, 0));
}
faces.put(face, builder.build());
}
if (!display.isBuiltInRenderer()) {
builder = ImmutableList.builder();
for (BakedQuad quad : display.getQuads(flowerState, null, 0)) {
Transformer transformer = new Transformer(transform, quad.getFormat());
quad.pipe(transformer);
builder.add(transformer.build());
}
builder.addAll(compostBase.getQuads(null, null, 0));
this.general = builder.build();
} else general = ImmutableList.of();
this.faces = Maps.immutableEnumMap(faces);
}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (side == null) return general;
return faces.get(side);
}
@Override
public boolean isAmbientOcclusion() {
return compostBase.isAmbientOcclusion() && display.isAmbientOcclusion();
}
@Override
public boolean isGui3d() {
return false;
}
@Override
public boolean isBuiltInRenderer() {
return false;
}
@Override
public TextureAtlasSprite getParticleTexture() {
return compostBase.getParticleTexture();
}
@Override
public ItemOverrideList getOverrides() {
return ItemOverrideList.NONE;
}
}

View file

@ -1,65 +0,0 @@
/*
* This file ("RenderCompost.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2017 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class RenderCompost extends TileEntitySpecialRenderer<TileEntityCompost>{
@Override
public void render(TileEntityCompost compost, double x, double y, double z, float partialTicks, int destroyStage, float f){
if(compost instanceof TileEntityCompost){
ItemStack slot = compost.inv.getStackInSlot(0);
if(StackUtil.isValid(slot)){
Block display = null;
int maxAmount = 0;
for(CompostRecipe aRecipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
if(slot.isItemEqual(aRecipe.input)){
display = aRecipe.inputDisplay;
maxAmount = aRecipe.input.getMaxStackSize();
break;
}
else if(slot.isItemEqual(aRecipe.output)){
display = aRecipe.outputDisplay;
maxAmount = aRecipe.output.getMaxStackSize();
break;
}
}
if(display != null){
float i = (float)slot.getCount()/(float)maxAmount;
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
//Hehe
if("ShadowfactsDev".equals(Minecraft.getMinecraft().player.getName())){
GlStateManager.translate(0F, 1F, 0F);
}
GlStateManager.scale(1.5F, i, 1.5F);
AssetUtil.renderBlockInWorld(display, 0);
GlStateManager.popMatrix();
}
}
}
}
}

View file

@ -64,7 +64,7 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpower
EnumFacing facing = EnumFacing.HORIZONTALS[i];
BlockPos offset = tile.getPos().offset(facing, 3);
AssetUtil.renderLaser(tile.getPos().getX()+0.5, tile.getPos().getY()+0.5, tile.getPos().getZ()+0.5, offset.getX()+0.5, offset.getY()+0.95, offset.getZ()+0.5, 80, 1F, 0.1F, recipe.particleColor);
AssetUtil.renderLaser(tile.getPos().getX()+0.5, tile.getPos().getY()+0.5, tile.getPos().getZ()+0.5, offset.getX()+0.5, offset.getY()+0.95, offset.getZ()+0.5, 80, 1F, 0.1F, recipe.getParticleColors());
}
}
}

View file

@ -0,0 +1,54 @@
package de.ellpeck.actuallyadditions.mod.blocks.render;
import javax.vecmath.Matrix3f;
import javax.vecmath.Matrix4f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.client.renderer.vertex.VertexFormatElement;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.client.model.pipeline.VertexTransformer;
import net.minecraftforge.common.model.TRSRTransformation;
public class Transformer extends VertexTransformer {
protected final Matrix4f transformation;
protected final Matrix3f normalTransformation;
public Transformer(TRSRTransformation transformation, VertexFormat format) {
super(new UnpackedBakedQuad.Builder(format));
// position transform
this.transformation = transformation.getMatrix();
// normal transform
this.normalTransformation = new Matrix3f();
this.transformation.getRotationScale(this.normalTransformation);
this.normalTransformation.invert();
this.normalTransformation.transpose();
}
@Override
public void put(int element, float... data) {
VertexFormatElement.EnumUsage usage = parent.getVertexFormat().getElement(element).getUsage();
// transform normals and position
if (usage == VertexFormatElement.EnumUsage.POSITION && data.length >= 3) {
Vector4f vec = new Vector4f(data);
vec.setW(1.0f);
transformation.transform(vec);
data = new float[4];
vec.get(data);
} else if (usage == VertexFormatElement.EnumUsage.NORMAL && data.length >= 3) {
Vector3f vec = new Vector3f(data);
normalTransformation.transform(vec);
vec.normalize();
data = new float[4];
vec.get(data);
}
super.put(element, data);
}
public UnpackedBakedQuad build() {
return ((UnpackedBakedQuad.Builder) parent).build();
}
}

View file

@ -47,6 +47,7 @@ import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidUtil;
@ -185,7 +186,7 @@ public final class InitBooklet{
//Reconstruction
chaptersIntroduction[7] = new BookletChapter("reconstructorLenses", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new PageTextOnly(1)).setImportant();
new BookletChapter("additionalRecipes", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.LEATHER), new PageReconstructor(1, LensRecipeHandler.recipeSoulSand).setNoText(), new PageReconstructor(2, LensRecipeHandler.recipeLeather).setNoText(), new PageReconstructor(3, LensRecipeHandler.recipeNetherWart).setNoText(), new PageReconstructor(4, LensRecipeHandler.recipePrismarine).setNoText()).setSpecial();
new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(new ItemStack(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText());
new BookletChapter("bookSplitting", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(Items.ENCHANTED_BOOK), new PageTextOnly(1), new PageReconstructor(2, new LensConversionRecipe(Ingredient.fromItem(Items.ENCHANTED_BOOK), new ItemStack(Items.ENCHANTED_BOOK), 0, ActuallyAdditionsAPI.lensDefaultConversion)).setNoText());
new BookletChapter("lensColor", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemColorLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeColorLens).setNoText());
new BookletChapter("lensDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemDamageLens), new PageTextOnly(1), new PageReconstructor(2, LensRecipeHandler.recipeDamageLens).setNoText());
new BookletChapter("lensMoreDeath", ActuallyAdditionsAPI.entryReconstruction, new ItemStack(InitItems.itemMoreDamageLens), new PageTextOnly(1), new PageCrafting(2, ItemCrafting.recipeLensMoreDeath).setNoText());

View file

@ -27,10 +27,14 @@ public class PageCoffeeMachine extends BookletPage{
private final CoffeeIngredient ingredient;
private final ItemStack outcome;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
public PageCoffeeMachine(int localizationKey, CoffeeIngredient ingredient){
super(localizationKey);
this.ingredient = ingredient;
this.stacks = ingredient.getInput().getMatchingStacks();
this.outcome = new ItemStack(InitItems.itemCoffee);
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.outcome, this.ingredient);
@ -48,6 +52,8 @@ public class PageCoffeeMachine extends BookletPage{
gui.renderSplitScaledAsciiString("Hover over this to see the effect!", startX+5, startY+51, 0, false, gui.getSmallFontSize(), 35);
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+90);
if(counter++ % 50 == 0) gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+5+82, startY+10+1, 1F, true);
}
@Override
@ -55,7 +61,7 @@ public class PageCoffeeMachine extends BookletPage{
public void initGui(GuiBookletBase gui, int startX, int startY){
super.initGui(gui, startX, startY);
gui.addOrModifyItemRenderer(this.ingredient.ingredient, startX+5+82, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(stacks[0], startX+5+82, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(this.outcome, startX+5+36, startY+10+42, 1F, false);
gui.addOrModifyItemRenderer(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal()), startX+5+37, startY+10+1, 1F, true);

View file

@ -25,10 +25,24 @@ import java.util.List;
public class PageEmpowerer extends BookletPage{
private final EmpowererRecipe recipe;
private int counter = 0;
private int rotate = 0;
ItemStack[] inputs;
ItemStack[] stand1;
ItemStack[] stand2;
ItemStack[] stand3;
ItemStack[] stand4;
public PageEmpowerer(int localizationKey, EmpowererRecipe recipe){
super(localizationKey);
this.recipe = recipe;
if(recipe != null) {
this.inputs = recipe.getInput().getMatchingStacks();
this.stand1 = recipe.getStandOne().getMatchingStacks();
this.stand2 = recipe.getStandTwo().getMatchingStacks();
this.stand3 = recipe.getStandThree().getMatchingStacks();
this.stand4 = recipe.getStandFour().getMatchingStacks();
}
}
@Override
@ -42,6 +56,7 @@ public class PageEmpowerer extends BookletPage{
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".empowererRecipe")+")", startX+6, startY+85, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
if(recipe != null) updateInputs(gui, startX, startY);
}
@Override
@ -50,13 +65,25 @@ public class PageEmpowerer extends BookletPage{
super.initGui(gui, startX, startY);
if(this.recipe != null){
gui.addOrModifyItemRenderer(this.recipe.modifier1, startX+5+26, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.modifier2, startX+5+1, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.modifier3, startX+5+51, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.modifier4, startX+5+26, startY+10+51, 1F, true);
gui.addOrModifyItemRenderer(stand1[0], startX+5+26, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(stand2[0], startX+5+1, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand3[0], startX+5+51, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand4[0], startX+5+26, startY+10+51, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.input, startX+5+26, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.output, startX+5+96, startY+10+26, 1F, false);
gui.addOrModifyItemRenderer(inputs[0], startX+5+26, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX+5+96, startY+10+26, 1F, false);
}
}
private void updateInputs(GuiBookletBase gui, int startX, int startY) {
if(counter++ % 50 == 0) {
rotate++;
gui.addOrModifyItemRenderer(stand1[rotate % stand1.length], startX+5+26, startY+10+1, 1F, true);
gui.addOrModifyItemRenderer(stand2[rotate % stand2.length], startX+5+1, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand3[rotate % stand3.length], startX+5+51, startY+10+26, 1F, true);
gui.addOrModifyItemRenderer(stand4[rotate % stand4.length], startX+5+26, startY+10+51, 1F, true);
gui.addOrModifyItemRenderer(inputs[rotate % inputs.length], startX+5+26, startY+10+26, 1F, true);
}
}
@ -65,7 +92,7 @@ public class PageEmpowerer extends BookletPage{
super.getItemStacksForPage(list);
if(this.recipe != null){
list.add(this.recipe.output);
list.add(this.recipe.getOutput());
}
}

View file

@ -27,10 +27,15 @@ public class PageReconstructor extends BookletPage{
private final LensConversionRecipe recipe;
private boolean isWildcard;
private int counter = 0;
private int rotate = 0;
private ItemStack[] stacks;
public PageReconstructor(int localizationKey, LensConversionRecipe recipe){
super(localizationKey);
this.recipe = recipe;
if(recipe != null) this.stacks = recipe.getInput().getMatchingStacks();
}
@Override
@ -44,6 +49,9 @@ public class PageReconstructor extends BookletPage{
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".reconstructorRecipe")+")", startX+6, startY+63, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+88);
if(this.recipe != null){
if(counter++ % 50 == 0) gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+30+1, startY+10+13, 1F, true);
}
}
@Override
@ -52,8 +60,8 @@ public class PageReconstructor extends BookletPage{
super.initGui(gui, startX, startY);
if(this.recipe != null){
gui.addOrModifyItemRenderer(this.recipe.inputStack, startX+30+1, startY+10+13, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.outputStack, startX+30+47, startY+10+13, 1F, false);
gui.addOrModifyItemRenderer(stacks[0], startX+30+1, startY+10+13, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutput(), startX+30+47, startY+10+13, 1F, false);
}
}
@ -62,7 +70,7 @@ public class PageReconstructor extends BookletPage{
super.getItemStacksForPage(list);
if(this.recipe != null){
ItemStack copy = this.recipe.outputStack.copy();
ItemStack copy = this.recipe.getOutput().copy();
if(this.isWildcard){
copy.setItemDamage(Util.WILDCARD);
}

View file

@ -16,11 +16,16 @@ import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntListValues;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.*;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.CactusFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.DefaultFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.MelonPumpkinFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.NetherWartFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.ReedFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.EnderlillyFarmerBehavior;
import de.ellpeck.actuallyadditions.mod.misc.apiimpl.farmer.exu.RedOrchidFarmerBehavior;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.ResourceLocation;
public final class InitCrafting{
@ -34,8 +39,8 @@ public final class InitCrafting{
FoodCrafting.init();
ToolCrafting.init();
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal()), Blocks.LEAVES, new ItemStack(InitItems.itemFertilizer), Blocks.DIRT);
ActuallyAdditionsAPI.addCompostRecipe(new ItemStack(InitItems.itemCanolaSeed), Blocks.DIRT, new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND);
ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.MASHED_FOOD.ordinal())), Blocks.LEAVES.getDefaultState(), new ItemStack(InitItems.itemFertilizer), Blocks.DIRT.getDefaultState());
ActuallyAdditionsAPI.addCompostRecipe(Ingredient.fromItem(InitItems.itemCanolaSeed), Blocks.DIRT.getDefaultState(), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.BIOMASS.ordinal()), Blocks.SOUL_SAND.getDefaultState());
int[] power = ConfigIntListValues.OIL_POWER.getValue();
int[] time = ConfigIntListValues.OIL_TIME.getValue();

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.event;
import java.util.Locale;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.IHudDisplay;
import de.ellpeck.actuallyadditions.mod.config.ConfigValues;
@ -46,8 +48,6 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.oredict.OreDictionary;
import java.util.Locale;
@SideOnly(Side.CLIENT)
public class ClientEvents{

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.inventory.gui;
import java.io.IOException;
import org.lwjgl.input.Keyboard;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerInputter;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
@ -20,18 +24,14 @@ import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.input.Keyboard;
import java.io.IOException;
@SideOnly(Side.CLIENT)
public class GuiInputter extends GuiContainer{
public class GuiInputter extends GuiWtfMojang{
public static final int OFFSET_ADVANCED = 12+36;
public static final String[] SIDES = new String[]{

View file

@ -10,6 +10,11 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
@ -25,16 +30,13 @@ import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.StringUtils;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.Loader;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
public class ItemCoffee extends ItemFoodBase{
public ItemCoffee(String name){
@ -46,29 +48,28 @@ public class ItemCoffee extends ItemFoodBase{
}
public static void initIngredients(){
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(new ItemStack(Items.MILK_BUCKET)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.fromItem(Items.MILK_BUCKET)));
//Pam's Soy Milk (For Jemx because he's lactose intolerant. YER HAPPY NAO!?)
if(Loader.isModLoaded("harvestcraft")){
Item item = ItemUtil.getItemFromName("harvestcraft:soymilkItem");
if(item != null){
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(new ItemStack(item)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new MilkIngredient(Ingredient.fromItem(item)));
}
}
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.SUGAR), new PotionEffect[]{new PotionEffect(MobEffects.SPEED, 30, 0)}, 4));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.MAGMA_CREAM), new PotionEffect[]{new PotionEffect(MobEffects.FIRE_RESISTANCE, 20, 0)}, 2));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.FISH, 1, 3), new PotionEffect[]{new PotionEffect(MobEffects.WATER_BREATHING, 10, 0)}, 2));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.GOLDEN_CARROT), new PotionEffect[]{new PotionEffect(MobEffects.NIGHT_VISION, 30, 0)}, 2));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.GHAST_TEAR), new PotionEffect[]{new PotionEffect(MobEffects.REGENERATION, 5, 0)}, 3));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.BLAZE_POWDER), new PotionEffect[]{new PotionEffect(MobEffects.STRENGTH, 15, 0)}, 4));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(new ItemStack(Items.FERMENTED_SPIDER_EYE), new PotionEffect[]{new PotionEffect(MobEffects.INVISIBILITY, 25, 0)}, 2));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.SUGAR), 4, new PotionEffect(MobEffects.SPEED, 30, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.MAGMA_CREAM), 2, new PotionEffect(MobEffects.FIRE_RESISTANCE, 20, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromStacks(new ItemStack(Items.FISH, 1, 3)), 2, new PotionEffect(MobEffects.WATER_BREATHING, 10, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.GOLDEN_CARROT), 2, new PotionEffect(MobEffects.NIGHT_VISION, 30, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.GHAST_TEAR), 3, new PotionEffect(MobEffects.REGENERATION, 5, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.BLAZE_POWDER), 4, new PotionEffect(MobEffects.STRENGTH, 15, 0)));
ActuallyAdditionsAPI.addCoffeeMachineIngredient(new CoffeeIngredient(Ingredient.fromItems(Items.FERMENTED_SPIDER_EYE), 2, new PotionEffect(MobEffects.INVISIBILITY, 25, 0)));
}
@Nullable
public static CoffeeIngredient getIngredientFromStack(ItemStack stack){
for(CoffeeIngredient ingredient : ActuallyAdditionsAPI.COFFEE_MACHINE_INGREDIENTS){
if(ingredient.ingredient.copy().isItemEqual(stack)){
return ingredient;
}
if(ingredient.getInput().apply(stack)) return ingredient;
}
return null;
}
@ -132,8 +133,8 @@ public class ItemCoffee extends ItemFoodBase{
public static class MilkIngredient extends CoffeeIngredient{
public MilkIngredient(ItemStack ingredient){
super(ingredient, null, 0);
public MilkIngredient(Ingredient ingredient){
super(ingredient, 0);
}
@Override

View file

@ -11,8 +11,12 @@
package de.ellpeck.actuallyadditions.mod.items.lens;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.ColorLensChangerByDyeMeta;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
@ -21,12 +25,13 @@ import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.recipe.EnchBookConversion;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public final class LensRecipeHandler{
@ -47,65 +52,65 @@ public final class LensRecipeHandler{
public static void init(){
//Crystal Blocks
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.REDSTONE_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.REDSTONE.ordinal()), 400);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.LAPIS_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.LAPIS.ordinal()), 400);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.DIAMOND_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.DIAMOND.ordinal()), 600);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.EMERALD_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.EMERALD.ordinal()), 1000);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.COAL_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.COAL.ordinal()), 600);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.IRON_BLOCK), new ItemStack(InitBlocks.blockCrystal, 1, TheCrystals.IRON.ordinal()), 800);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
//Crystal Items
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.REDSTONE), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.REDSTONE.ordinal()), 40);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.DYE, 1, 4), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Items.DYE, 1, 4)), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.LAPIS.ordinal()), 40);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.DIAMOND), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.DIAMOND.ordinal()), 60);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.EMERALD), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.EMERALD.ordinal()), 100);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.COAL), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.COAL.ordinal()), 60);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.IRON_INGOT), new ItemStack(InitItems.itemCrystal, 1, TheCrystals.IRON.ordinal()), 80);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastReconstructorRecipe());
//Lenses
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), new ItemStack(InitItems.itemColorLens), 5000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal())), new ItemStack(InitItems.itemColorLens), 5000);
recipeColorLens = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(InitItems.itemColorLens), new ItemStack(InitItems.itemExplosionLens), 5000);
recipeExplosionLens = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(InitItems.itemExplosionLens), new ItemStack(InitItems.itemDamageLens), 5000);
recipeDamageLens = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(InitItems.itemDamageLens), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.LENS.ordinal()), 5000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitBlocks.blockLaserRelay), new ItemStack(InitBlocks.blockLaserRelayFluids), 2000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelay), new ItemStack(InitBlocks.blockLaserRelayFluids), 2000);
recipeFluidLaser = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitBlocks.blockLaserRelayFluids), new ItemStack(InitBlocks.blockLaserRelayItem), 2000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayFluids), new ItemStack(InitBlocks.blockLaserRelayItem), 2000);
recipeItemLaser = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitBlocks.blockLaserRelayItem), new ItemStack(InitBlocks.blockLaserRelay), 2000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(InitBlocks.blockLaserRelayItem), new ItemStack(InitBlocks.blockLaserRelay), 2000);
//Misc
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.SAND), new ItemStack(Blocks.SOUL_SAND), 20000);
recipeSoulSand = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.ROTTEN_FLESH), new ItemStack(Items.LEATHER), 8000);
recipeLeather = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.RED_MUSHROOM), new ItemStack(Items.NETHER_WART), 150000);
recipeNetherWart = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Items.QUARTZ), new ItemStack(Items.PRISMARINE_SHARD), 30000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(Items.QUARTZ), new ItemStack(Items.PRISMARINE_SHARD), 30000);
recipePrismarine = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), 2000);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromItem(InitItems.itemCanolaSeed), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), 2000);
recipeCrystallizedCanolaSeed = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(fromBlock(Blocks.QUARTZ_BLOCK), new ItemStack(InitBlocks.blockTestifiBucksWhiteWall), 10);
recipeWhiteWall = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
ActuallyAdditionsAPI.addReconstructorLensConversionRecipe(Ingredient.fromStacks(new ItemStack(Blocks.QUARTZ_BLOCK, 1, 1)), new ItemStack(InitBlocks.blockTestifiBucksGreenWall), 10);
recipeGreenWall = RecipeUtil.lastReconstructorRecipe();
ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES.add(recipeEnchBook = new EnchBookConversion());
@ -121,13 +126,22 @@ public final class LensRecipeHandler{
ActuallyAdditionsAPI.addReconstructorLensColorChangeItem(Item.getItemFromBlock(InitBlocks.blockColoredLampOn), changer);
}
public static ArrayList<LensConversionRecipe> getRecipesFor(ItemStack input){
ArrayList<LensConversionRecipe> possibleRecipes = new ArrayList<LensConversionRecipe>();
for(LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES){
if(ItemUtil.areItemsEqual(recipe.inputStack, input, true)){
possibleRecipes.add(recipe);
}
}
@Deprecated //Use lens-checking method below.
public static List<LensConversionRecipe> getRecipesFor(ItemStack input){
List<LensConversionRecipe> possibleRecipes = new ArrayList<>();
for(LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES)
if(recipe.getInput().apply(input)) possibleRecipes.add(recipe);
return possibleRecipes;
}
@Nullable
public static LensConversionRecipe findMatchingRecipe(ItemStack input, Lens lens){
for(LensConversionRecipe recipe : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_CONVERSION_RECIPES)
if(recipe.matches(input, lens)) return recipe;
return null;
}
private static Ingredient fromBlock(Block b) {
return Ingredient.fromItem(Item.getItemFromBlock(b));
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.jei.coffee;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -52,7 +54,7 @@ public class CoffeeMachineRecipeCategory implements IRecipeCategory<CoffeeMachin
@Override
public void setRecipe(IRecipeLayout recipeLayout, CoffeeMachineRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 89, 20);
recipeLayout.getItemStacks().set(0, wrapper.theIngredient.ingredient);
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.ingredient.getInput().getMatchingStacks()));
recipeLayout.getItemStacks().init(1, true, 44, 38);
recipeLayout.getItemStacks().set(1, wrapper.cup);

View file

@ -10,6 +10,11 @@
package de.ellpeck.actuallyadditions.mod.jei.coffee;
import java.util.ArrayList;
import java.util.List;
import com.google.common.base.Strings;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
@ -24,27 +29,25 @@ import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.List;
public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton {
public final CoffeeIngredient theIngredient;
public final CoffeeIngredient ingredient;
public final ItemStack theOutput;
public final ItemStack cup = new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CUP.ordinal());
public final ItemStack coffeeBeans = new ItemStack(InitItems.itemCoffeeBean);
public CoffeeMachineRecipeWrapper(CoffeeIngredient ingredient) {
this.theIngredient = ingredient;
this.ingredient = ingredient;
this.theOutput = new ItemStack(InitItems.itemCoffee);
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.theIngredient);
ActuallyAdditionsAPI.methodHandler.addEffectToStack(this.theOutput, this.ingredient);
}
@Override
public void getIngredients(IIngredients ingredients) {
List<ItemStack> list = new ArrayList<ItemStack>();
list.add(this.theIngredient.ingredient);
List<ItemStack> list = new ArrayList<>();
for(ItemStack s : ingredient.getInput().getMatchingStacks())
list.add(s);
list.add(this.cup);
list.add(this.coffeeBeans);
ingredients.setInputs(ItemStack.class, list);
@ -54,13 +57,13 @@ public class CoffeeMachineRecipeWrapper extends RecipeWrapperWithButton{
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
if(this.theIngredient.getExtraText() != null){
if (!Strings.isNullOrEmpty(this.ingredient.getExtraText())) {
minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.special") + ":", 2, 4, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
minecraft.fontRenderer.drawString(this.theIngredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
minecraft.fontRenderer.drawString(this.ingredient.getExtraText(), 2, 16, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
if(this.theIngredient.maxAmplifier > 0){
minecraft.fontRenderer.drawString(StringUtil.localize("container.nei."+ActuallyAdditions.MODID+".coffee.maxAmount")+": "+this.theIngredient.maxAmplifier, 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
if (this.ingredient.getMaxAmplifier() > 0) {
minecraft.fontRenderer.drawString(StringUtil.localize("container.nei." + ActuallyAdditions.MODID + ".coffee.maxAmount") + ": " + this.ingredient.getMaxAmplifier(), 2, 28, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.jei.compost;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -52,9 +54,9 @@ public class CompostRecipeCategory implements IRecipeCategory<CompostRecipeWrapp
@Override
public void setRecipe(IRecipeLayout recipeLayout, CompostRecipeWrapper wrapper, IIngredients ingredients) {
recipeLayout.getItemStacks().init(0, true, 4, 18);
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.input);
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.recipe.getInput().getMatchingStacks()));
recipeLayout.getItemStacks().init(1, false, 66, 18);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.output);
recipeLayout.getItemStacks().set(1, wrapper.recipe.getOutput());
}
}

View file

@ -10,28 +10,30 @@
package de.ellpeck.actuallyadditions.mod.jei.compost;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityCompost;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
public class CompostRecipeWrapper extends RecipeWrapperWithButton {
public final CompostRecipe theRecipe;
public final CompostRecipe recipe;
public CompostRecipeWrapper(CompostRecipe recipe) {
this.theRecipe = recipe;
this.recipe = recipe;
}
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(ItemStack.class, this.theRecipe.input);
ingredients.setOutput(ItemStack.class, this.theRecipe.output);
ingredients.setInputs(ItemStack.class, Arrays.asList(recipe.getInput().getMatchingStacks()));
ingredients.setOutput(ItemStack.class, recipe.getOutput());
}
@Override

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.jei.empowerer;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
@ -52,21 +54,21 @@ public class EmpowererRecipeCategory implements IRecipeCategory<EmpowererRecipeW
@Override
public void setRecipe(IRecipeLayout recipeLayout, EmpowererRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 31, 31);
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.input);
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
recipeLayout.getItemStacks().init(1, true, 1, 31);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.modifier1);
recipeLayout.getItemStacks().set(1, Arrays.asList(wrapper.theRecipe.getStandOne().getMatchingStacks()));
recipeLayout.getItemStacks().init(2, true, 31, 1);
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.modifier2);
recipeLayout.getItemStacks().set(2, Arrays.asList(wrapper.theRecipe.getStandTwo().getMatchingStacks()));
recipeLayout.getItemStacks().init(3, true, 61, 31);
recipeLayout.getItemStacks().set(3, wrapper.theRecipe.modifier3);
recipeLayout.getItemStacks().set(3, Arrays.asList(wrapper.theRecipe.getStandThree().getMatchingStacks()));
recipeLayout.getItemStacks().init(4, true, 31, 61);
recipeLayout.getItemStacks().set(4, wrapper.theRecipe.modifier4);
recipeLayout.getItemStacks().set(4, Arrays.asList(wrapper.theRecipe.getStandFour().getMatchingStacks()));
recipeLayout.getItemStacks().init(5, false, 112, 31);
recipeLayout.getItemStacks().set(5, wrapper.theRecipe.output);
recipeLayout.getItemStacks().set(5, wrapper.theRecipe.getOutput());
}
}

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.jei.empowerer;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
@ -18,8 +21,6 @@ import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.item.ItemStack;
import java.util.Arrays;
public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{
public final EmpowererRecipe theRecipe;
@ -30,8 +31,20 @@ public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{
@Override
public void getIngredients(IIngredients ingredients){
ingredients.setInputs(ItemStack.class, Arrays.asList(this.theRecipe.input, this.theRecipe.modifier1, this.theRecipe.modifier2, this.theRecipe.modifier3, this.theRecipe.modifier4));
ingredients.setOutput(ItemStack.class, this.theRecipe.output);
List<ItemStack> inputs = new ArrayList<>();
for(ItemStack s : theRecipe.getInput().getMatchingStacks())
inputs.add(s);
for(ItemStack s : theRecipe.getStandOne().getMatchingStacks())
inputs.add(s);
for(ItemStack s : theRecipe.getStandTwo().getMatchingStacks())
inputs.add(s);
for(ItemStack s : theRecipe.getStandThree().getMatchingStacks())
inputs.add(s);
for(ItemStack s : theRecipe.getStandFour().getMatchingStacks())
inputs.add(s);
ingredients.setInputs(ItemStack.class, inputs);
ingredients.setOutput(ItemStack.class, this.theRecipe.getOutput());
}
@Override

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.jei.reconstructor;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
@ -40,13 +42,13 @@ public class ReconstructorRecipeWrapper extends RecipeWrapperWithButton{
@Override
public void getIngredients(IIngredients ingredients) {
ingredients.setInput(ItemStack.class, this.theRecipe.inputStack);
ingredients.setOutput(ItemStack.class, this.theRecipe.outputStack);
ingredients.setInputs(ItemStack.class, Arrays.asList(this.theRecipe.getInput().getMatchingStacks()));
ingredients.setOutput(ItemStack.class, this.theRecipe.getOutput());
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY) {
minecraft.fontRenderer.drawString(this.theRecipe.energyUse+" CF", 55, 0, 0xFFFFFF, true);
minecraft.fontRenderer.drawString(this.theRecipe.getEnergyUsed() + " CF", 55, 0, 0xFFFFFF, true);
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
}

View file

@ -61,7 +61,7 @@ public class MethodHandler implements IMethodHandler{
for(PotionEffect effect : effects){
PotionEffect effectHas = this.getSameEffectFromStack(stack, effect);
if(effectHas != null){
if(effectHas.getAmplifier() < ingredient.maxAmplifier-1){
if(effectHas.getAmplifier() < ingredient.getMaxAmplifier()-1){
this.addEffectProperties(stack, effect, false, true);
worked = true;
}
@ -168,10 +168,9 @@ public class MethodHandler implements IMethodHandler{
BlockPos pos = new BlockPos(hitBlock.getX()+reachX, hitBlock.getY()+reachY, hitBlock.getZ()+reachZ);
if(!tile.getWorldObject().isAirBlock(pos)){
IBlockState state = tile.getWorldObject().getBlockState(pos);
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)));
for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){
ItemStack output = recipe.outputStack;
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(new ItemStack(state.getBlock(), 1, state.getBlock().getMetaFromState(state)), tile.getLens());
if(recipe != null && tile.getEnergy() >= recipe.getEnergyUsed()){
ItemStack output = recipe.getOutput();
if(StackUtil.isValid(output)){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(state));
recipe.transformHook(ItemStack.EMPTY, state, pos, tile);
@ -186,7 +185,7 @@ public class MethodHandler implements IMethodHandler{
tile.getWorldObject().setBlockToAir(pos);
}
tile.extractEnergy(recipe.energyUse);
tile.extractEnergy(recipe.getEnergyUsed());
break;
}
}
@ -194,17 +193,15 @@ public class MethodHandler implements IMethodHandler{
}
}
}
}
//Converting the Items
List<EntityItem> items = tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX()-rangeX, hitBlock.getY()-rangeY, hitBlock.getZ()-rangeZ, hitBlock.getX()+1+rangeX, hitBlock.getY()+1+rangeY, hitBlock.getZ()+1+rangeZ));
for(EntityItem item : items){
ItemStack stack = item.getItem();
if(!item.isDead && StackUtil.isValid(stack)){
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens()){
int itemsPossible = Math.min(tile.getEnergy()/recipe.energyUse, stack.getCount());
LensConversionRecipe recipe = LensRecipeHandler.findMatchingRecipe(stack, tile.getLens());
if(recipe != null){
int itemsPossible = Math.min(tile.getEnergy()/recipe.getEnergyUsed(), stack.getCount());
if(itemsPossible > 0){
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
@ -218,19 +215,18 @@ public class MethodHandler implements IMethodHandler{
tile.getWorldObject().spawnEntity(inputLeft);
}
ItemStack outputCopy = recipe.outputStack.copy();
ItemStack outputCopy = recipe.getOutput().copy();
outputCopy.setCount(itemsPossible);
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
tile.getWorldObject().spawnEntity(newItem);
tile.extractEnergy(recipe.energyUse*itemsPossible);
tile.extractEnergy(recipe.getEnergyUsed()*itemsPossible);
break;
}
}
}
}
}
return !hitState.getBlock().isAir(hitState, tile.getWorldObject(), hitBlock);
}
return false;

View file

@ -16,8 +16,8 @@ import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.ClientRegistryHandler;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderBatteryBox;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderCompost;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderDisplayStand;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderEmpowerer;
import de.ellpeck.actuallyadditions.mod.blocks.render.RenderLaserRelay;
@ -43,14 +43,17 @@ import de.ellpeck.actuallyadditions.mod.tile.TileEntitySmileyCloud;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingBlock;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.network.NetHandlerPlayClient;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.color.IBlockColor;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.client.CPacketPlayerDigging;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.common.MinecraftForge;
@ -81,7 +84,7 @@ public class ClientProxy implements IProxy{
new ClientEvents();
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCompost.class, new RenderCompost());
//ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCompost.class, new RenderCompost());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityAtomicReconstructor.class, new RenderReconstructorLens());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySmileyCloud.class, new RenderSmileyCloud());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityDisplayStand.class, new RenderDisplayStand());
@ -110,6 +113,18 @@ public class ClientProxy implements IProxy{
Minecraft.getMinecraft().getItemColors().registerItemColorHandler(((IColorProvidingItem)block).getItemColor(), block);
}
}
IBlockColor color = (state, world, pos, tint) -> {
if (world != null && pos != null) {
TileEntity tileentity = world.getTileEntity(pos);
if (tileentity instanceof TileEntityCompost && ((TileEntityCompost) tileentity).getCurrentDisplay().getBlock() != state.getBlock()) {
IBlockState iblockstate = ((TileEntityCompost) tileentity).getCurrentDisplay();
return Minecraft.getMinecraft().getBlockColors().colorMultiplier(iblockstate, world, pos, tint);
}
}
return -1;
};
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(color, InitBlocks.blockCompost);
}
@Override

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.recipe;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
@ -17,13 +20,14 @@ import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheCrystals;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.oredict.OreIngredient;
public final class EmpowererHandler {
@ -31,32 +35,37 @@ public final class EmpowererHandler{
public static EmpowererRecipe recipeEmpoweredCanolaSeed;
public static void init() {
addCrystalEmpowering(TheCrystals.REDSTONE, "dyeRed", new ItemStack(Items.NETHERBRICK), new ItemStack(Items.REDSTONE), new ItemStack(Items.BRICK));
addCrystalEmpowering(TheCrystals.LAPIS, "dyeCyan", new ItemStack(Items.PRISMARINE_SHARD), new ItemStack(Items.PRISMARINE_SHARD), new ItemStack(Items.PRISMARINE_SHARD));
addCrystalEmpowering(TheCrystals.DIAMOND, "dyeLightBlue", new ItemStack(Items.CLAY_BALL), new ItemStack(Items.CLAY_BALL), new ItemStack(Blocks.CLAY));
addCrystalEmpowering(TheCrystals.IRON, "dyeGray", new ItemStack(Items.SNOWBALL), new ItemStack(Blocks.STONE_BUTTON), new ItemStack(Blocks.COBBLESTONE));
addCrystalEmpowering(TheCrystals.REDSTONE, "dyeRed", Ingredient.fromItem(Items.NETHERBRICK), Ingredient.fromItem(Items.REDSTONE), Ingredient.fromItem(Items.BRICK));
addCrystalEmpowering(TheCrystals.LAPIS, "dyeCyan", Ingredient.fromItem(Items.PRISMARINE_SHARD), Ingredient.fromItem(Items.PRISMARINE_SHARD), Ingredient.fromItem(Items.PRISMARINE_SHARD));
addCrystalEmpowering(TheCrystals.DIAMOND, "dyeLightBlue", Ingredient.fromItem(Items.CLAY_BALL), Ingredient.fromItem(Items.CLAY_BALL), fromBlock(Blocks.CLAY));
addCrystalEmpowering(TheCrystals.IRON, "dyeGray", Ingredient.fromItem(Items.SNOWBALL), fromBlock(Blocks.STONE_BUTTON), fromBlock(Blocks.COBBLESTONE));
addCrystalEmpowering(TheCrystals.COAL, "dyeBlack", new ItemStack(Items.COAL, 1, 1), new ItemStack(Items.FLINT), new ItemStack(Blocks.STONE));
addCrystalEmpowering(TheCrystals.COAL, "dyeBlack", igd(new ItemStack(Items.COAL, 1, 1)), Ingredient.fromItem(Items.FLINT), fromBlock(Blocks.STONE));
List<ItemStack> balls = OreDictionary.getOres("slimeball");
for (ItemStack ball : balls) {
addCrystalEmpowering(TheCrystals.EMERALD, "dyeLime", new ItemStack(Blocks.TALLGRASS, 1, 1), new ItemStack(Blocks.SAPLING), ball.copy());
addCrystalEmpowering(TheCrystals.EMERALD, "dyeLime", igd(new ItemStack(Blocks.TALLGRASS, 1, 1)), igd(new ItemStack(Blocks.SAPLING)), igd(ball.copy()));
}
ItemStack seed = new ItemStack(InitItems.itemCanolaSeed);
ActuallyAdditionsAPI.addEmpowererRecipe(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal()), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal()), seed, seed, seed, seed, 1000, 30, new float[]{1F, 91F/255F, 76F/255F});
Ingredient seed = Ingredient.fromItem(InitItems.itemCanolaSeed);
ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemMisc, 1, TheMiscItems.CRYSTALLIZED_CANOLA_SEED.ordinal())), new ItemStack(InitItems.itemMisc, 1, TheMiscItems.EMPOWERED_CANOLA_SEED.ordinal()), seed, seed, seed, seed, 1000, 30, new float[] { 1F, 91F / 255F, 76F / 255F });
recipeEmpoweredCanolaSeed = RecipeUtil.lastEmpowererRecipe();
}
private static void addCrystalEmpowering(TheCrystals type, String dye, ItemStack modifier1, ItemStack modifier2, ItemStack modifier3){
private static void addCrystalEmpowering(TheCrystals type, String dye, Ingredient modifier1, Ingredient modifier2, Ingredient modifier3) {
float[] color = type.conversionColorParticles;
List<ItemStack> dyes = OreDictionary.getOres(dye);
for(ItemStack dyeStack : dyes){
ActuallyAdditionsAPI.addEmpowererRecipe(new ItemStack(InitItems.itemCrystal, 1, type.ordinal()), new ItemStack(InitItems.itemCrystalEmpowered, 1, type.ordinal()), dyeStack, modifier1, modifier2, modifier3, 5000, 50, color);
ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitItems.itemCrystal, 1, type.ordinal())), new ItemStack(InitItems.itemCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 5000, 50, color);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe());
ActuallyAdditionsAPI.addEmpowererRecipe(new ItemStack(InitBlocks.blockCrystal, 1, type.ordinal()), new ItemStack(InitBlocks.blockCrystalEmpowered, 1, type.ordinal()), dyeStack, modifier1, modifier2, modifier3, 50000, 500, color);
ActuallyAdditionsAPI.addEmpowererRecipe(Ingredient.fromStacks(new ItemStack(InitBlocks.blockCrystal, 1, type.ordinal())), new ItemStack(InitBlocks.blockCrystalEmpowered, 1, type.ordinal()), new OreIngredient(dye), modifier1, modifier2, modifier3, 50000, 500, color);
MAIN_PAGE_RECIPES.add(RecipeUtil.lastEmpowererRecipe());
}
private static Ingredient igd(ItemStack s) {
return Ingredient.fromStacks(s);
}
private static Ingredient fromBlock(Block b) {
return Ingredient.fromItem(Item.getItemFromBlock(b));
}
}

View file

@ -13,12 +13,13 @@ import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.util.math.BlockPos;
public class EnchBookConversion extends LensConversionRecipe {
public EnchBookConversion() {
super(new ItemStack(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
super(Ingredient.fromItem(Items.ENCHANTED_BOOK), ItemStack.EMPTY, 155000, ActuallyAdditionsAPI.lensDefaultConversion);
}
@Override

View file

@ -12,7 +12,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -20,7 +23,8 @@ public class TileEntityCompost extends TileEntityInventoryBase{
public static final int COMPOST_TIME_TICKS = 3000;
public int conversionTime;
protected int conversionTime;
protected CompostRecipe recipe;
public TileEntityCompost() {
super(1, "compost");
@ -29,9 +33,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
public static CompostRecipe getRecipeForInput(ItemStack input) {
if (StackUtil.isValid(input)) {
for (CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES) {
if(input.isItemEqual(recipe.input)){
return recipe;
}
if (recipe.matches(input)) return recipe;
}
}
return null;
@ -56,6 +58,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
if (type != NBTType.SAVE_BLOCK) {
this.conversionTime = compound.getInteger("ConversionTime");
}
if (type == NBTType.SYNC) this.world.markBlockRangeForRenderUpdate(this.pos, this.pos.up());
}
@Override
@ -65,18 +68,17 @@ public class TileEntityCompost extends TileEntityInventoryBase{
boolean theFlag = this.conversionTime > 0;
ItemStack input = inv.getStackInSlot(0);
if (StackUtil.isValid(input)) {
CompostRecipe recipe = getRecipeForInput(input);
if (recipe == null || !recipe.matches(input)) recipe = getRecipeForInput(input);
if (recipe != null) {
this.conversionTime++;
if (this.conversionTime >= COMPOST_TIME_TICKS) {
ItemStack output = recipe.output.copy();
ItemStack output = recipe.getOutput().copy();
output.setCount(input.getCount());
this.inv.setStackInSlot(0, output);
this.conversionTime = 0;
this.markDirty();
}
}
else{
} else {
this.conversionTime = 0;
}
}
@ -96,4 +98,24 @@ public class TileEntityCompost extends TileEntityInventoryBase{
public boolean canExtract(int slot, ItemStack stack, boolean automation) {
return getRecipeForInput(stack) == null;
}
public IBlockState getCurrentDisplay() {
ItemStack input = inv.getStackInSlot(0);
CompostRecipe displayRecipe = recipe;
if (displayRecipe == null || !displayRecipe.matches(input)) displayRecipe = getRecipeForInput(input);
if (displayRecipe == null) for (CompostRecipe r : ActuallyAdditionsAPI.COMPOST_RECIPES) {
if (ItemUtil.areItemsEqual(input, r.getOutput(), true)) return r.getOutputDisplay();
else if (r.getInput().apply(input)) return r.getInputDisplay();
}
if(displayRecipe != null) return displayRecipe.getInputDisplay();
return Blocks.AIR.getDefaultState();
}
public float getHeight() {
ItemStack input = inv.getStackInSlot(0);
if (input.isEmpty()) return 0;
return (float) input.getCount() / input.getMaxStackSize();
}
}

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.IEnergyStorage;
@ -100,4 +101,8 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
public IEnergyStorage getEnergyStorage(EnumFacing facing){
return this.storage;
}
public ItemStack getStack() {
return this.inv.getStackInSlot(0);
}
}

View file

@ -10,9 +10,13 @@
package de.ellpeck.actuallyadditions.mod.tile;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@ -22,10 +26,6 @@ import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class TileEntityEmpowerer extends TileEntityInventoryBase {
public int processTime;
@ -36,11 +36,12 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
super(1, "empowerer");
}
@Deprecated //Use findMatchingRecipe
public static List<EmpowererRecipe> getRecipesForInput(ItemStack input) {
List<EmpowererRecipe> recipesThatWork = new ArrayList<EmpowererRecipe>();
if (StackUtil.isValid(input)) {
for (EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES) {
if(StackUtil.isValid(recipe.input) && recipe.input.isItemEqual(input)){
if (recipe.getInput().apply(input)) {
recipesThatWork.add(recipe);
}
}
@ -48,23 +49,35 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
return recipesThatWork;
}
public static boolean isPossibleInput(ItemStack stack) {
for(EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) if(r.getInput().apply(stack)) return true;
return false;
}
@Nullable
public static EmpowererRecipe findMatchingRecipe(ItemStack base, ItemStack stand1, ItemStack stand2, ItemStack stand3, ItemStack stand4) {
for (EmpowererRecipe r : ActuallyAdditionsAPI.EMPOWERER_RECIPES) {
if (r.matches(base, stand1, stand2, stand3, stand4)) return r;
}
return null;
}
@Override
public void updateEntity() {
super.updateEntity();
if (!this.world.isRemote) {
List<EmpowererRecipe> recipes = getRecipesForInput(this.inv.getStackInSlot(0));
if(!recipes.isEmpty()){
for(EmpowererRecipe recipe : recipes){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
if(modifierStands != null){ //Meaning the display stands around match all the criteria
TileEntityDisplayStand[] stands = this.getNearbyStands();
if (stands != null) {
EmpowererRecipe recipe = findMatchingRecipe(this.inv.getStackInSlot(0), stands[0].getStack(), stands[1].getStack(), stands[2].getStack(), stands[3].getStack());
if (recipe != null) {
this.recipeForRenderIndex = ActuallyAdditionsAPI.EMPOWERER_RECIPES.indexOf(recipe);
this.processTime++;
boolean done = this.processTime >= recipe.time;
boolean done = this.processTime >= recipe.getTime();
for(TileEntityDisplayStand stand : modifierStands){
stand.storage.extractEnergyInternal(recipe.energyPerStand/recipe.time, false);
for (TileEntityDisplayStand stand : stands) {
stand.storage.extractEnergyInternal(recipe.getEnergyPerStand() / recipe.getTime(), false);
if (done) {
stand.inv.getStackInSlot(0).shrink(1);
@ -78,18 +91,13 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
if (done) {
((WorldServer) this.world).spawnParticle(EnumParticleTypes.END_ROD, false, this.pos.getX() + 0.5, this.pos.getY() + 1.1, this.pos.getZ() + 0.5, 100, 0, 0, 0, 0.25D);
this.inv.setStackInSlot(0, recipe.output.copy());
this.inv.setStackInSlot(0, recipe.getOutput().copy());
this.markDirty();
this.processTime = 0;
this.recipeForRenderIndex = -1;
}
break;
}
}
}
else{
} else {
this.processTime = 0;
this.recipeForRenderIndex = -1;
}
@ -100,34 +108,20 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
}
}
}
}
private TileEntityDisplayStand[] getFittingModifiers(EmpowererRecipe recipe, int powerDivider){
TileEntityDisplayStand[] modifierStands = new TileEntityDisplayStand[4];
List<ItemStack> itemsStillNeeded = new ArrayList<ItemStack>(Arrays.asList(recipe.modifier1, recipe.modifier2, recipe.modifier3, recipe.modifier4));
private TileEntityDisplayStand[] getNearbyStands() {
TileEntityDisplayStand[] stands = new TileEntityDisplayStand[4];
for (int i = 0; i < EnumFacing.HORIZONTALS.length; i++) {
EnumFacing facing = EnumFacing.HORIZONTALS[i];
BlockPos offset = this.pos.offset(facing, 3);
TileEntity tile = this.world.getTileEntity(offset);
if(tile instanceof TileEntityDisplayStand){
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
ItemStack standItem = stand.inv.getStackInSlot(0);
int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true);
if(stand.storage.getEnergyStored() >= recipe.energyPerStand/powerDivider && containPlace != -1){
modifierStands[i] = stand;
itemsStillNeeded.remove(containPlace);
}
else{
return null;
}
}
else{
return null;
}
if (tile instanceof TileEntityDisplayStand) stands[i] = (TileEntityDisplayStand) tile;
else return null;
}
return modifierStands;
return stands;
}
@Override

View file

@ -144,6 +144,7 @@ public class TileEntityPhantomPlacer extends TileEntityInventoryBase implements
}
else{
int theSlot = StackUtil.findFirstFilled(this.inv);
if(theSlot == -1) return;
inv.setStackInSlot(theSlot, WorldUtil.useItemAtSide(WorldUtil.getDirectionBySidesInOrder(this.side), this.world, this.boundPosition, inv.getStackInSlot(theSlot)));
}
}

View file

@ -10,18 +10,25 @@
package de.ellpeck.actuallyadditions.mod.util;
import org.lwjgl.opengl.GL11;
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.tile.TileEntityBase;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.GlStateManager.DestFactor;
import net.minecraft.client.renderer.GlStateManager.SourceFactor;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.RenderItem;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms.TransformType;
import net.minecraft.client.renderer.texture.TextureManager;
@ -31,13 +38,14 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.client.ForgeHooksClient;
import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
public final class AssetUtil{
@ -84,6 +92,20 @@ public final class AssetUtil{
}
}
@SideOnly(Side.CLIENT)
public static void renderStateInWorld(IBlockState state, IBlockAccess world, BlockPos pos, float brightness){
Minecraft.getMinecraft().getTextureManager().bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
GlStateManager.rotate(90.0F, 0.0F, 1.0F, 0.0F);
int i = Minecraft.getMinecraft().getBlockColors().colorMultiplier(state, world, pos, 0);
float r = (float) (i >> 16 & 255) / 255F;
float g = (float) (i >> 8 & 255) / 255F;
float b = (float) (i & 255) / 255F;
Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelRenderer().renderModelBrightnessColor(state, model, brightness, r, g, b);
}
@SideOnly(Side.CLIENT)
public static void renderItemWithoutScrewingWithColors(ItemStack stack){
if(StackUtil.isValid(stack)){