We're just gonna hope nothing is on fire.

This commit is contained in:
Shadows_of_Fire 2018-06-22 19:39:30 -04:00
parent a571c70457
commit ac2bc0124a
121 changed files with 1582 additions and 1627 deletions

View file

@ -10,6 +10,11 @@
package de.ellpeck.actuallyadditions.api;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
@ -18,39 +23,44 @@ import de.ellpeck.actuallyadditions.api.internal.IMethodHandler;
import de.ellpeck.actuallyadditions.api.laser.ILaserRelayConnectionHandler;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
import de.ellpeck.actuallyadditions.api.recipe.*;
import de.ellpeck.actuallyadditions.api.recipe.BallOfFurReturn;
import de.ellpeck.actuallyadditions.api.recipe.CoffeeIngredient;
import de.ellpeck.actuallyadditions.api.recipe.CompostRecipe;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import de.ellpeck.actuallyadditions.api.recipe.LensConversionRecipe;
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.item.Item;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.item.crafting.Ingredient;
public final class ActuallyAdditionsAPI{
public static final String MOD_ID = "actuallyadditions";
public static final String API_ID = MOD_ID+"api";
public static final String API_VERSION = "33";
public static final String API_VERSION = "34";
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<CrusherRecipe>();
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<TreasureChestLoot>();
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<LensConversionRecipe>();
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<EmpowererRecipe>();
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<IFarmerBehavior>();
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<OilGenRecipe>();
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
public static final List<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<>();
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>();
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<>();
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>();
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<>();
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>();
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<>();
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<>();
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<>();
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<>();
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<>();
//This is added to automatically, you don't need to add anything to this list
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<IBookletChapter>();
public static final List<IBookletChapter> ALL_CHAPTERS = new ArrayList<>();
//This is added to automatically, you don't need to add anything to this list
public static final List<IBookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<IBookletPage>();
public static final List<WeightedOre> STONE_ORES = new ArrayList<WeightedOre>();
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<WeightedOre>();
public static final List<IBookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<>();
public static final List<WeightedOre> STONE_ORES = new ArrayList<>();
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<>();
/**
* Use this to handle things that aren't based in the API itself
@ -126,6 +136,18 @@ public final class ActuallyAdditionsAPI{
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
CRUSHER_RECIPES.add(new CrusherRecipe(Ingredient.fromStacks(input), outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance));
}
/**
* Adds a Recipe to the Crusher Recipe Registry
*
* @param input The input as an Ingredient
* @param outputOne The first output as an ItemStack
* @param outputTwo The second output as an ItemStack (can be ItemStack.EMPTY if there should be none)
* @param outputTwoChance The chance of the second output (0 won't occur at all, 100 will all the time)
*/
public static void addCrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputTwoChance){
CRUSHER_RECIPES.add(new CrusherRecipe(input, outputOne, outputTwo.isEmpty() ? ItemStack.EMPTY : outputTwo, outputTwoChance));
}
@ -145,6 +167,7 @@ public final class ActuallyAdditionsAPI{
}
//Same thing as above, but with ItemStack outputs.
@Deprecated //Use Ingredient
public static boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance){
return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance);
}

View file

@ -25,7 +25,11 @@ public interface IFarmer extends IEnergyTile{
EnumFacing getOrientation();
boolean addToSeedInventory(List<ItemStack> stacks, boolean actuallyDo);
boolean canAddToSeeds(List<ItemStack> stacks);
boolean addToOutputInventory(List<ItemStack> stacks, boolean actuallyDo);
boolean canAddToOutput(List<ItemStack> stacks);
void addToSeeds(List<ItemStack> stacks);
void addToOutput(List<ItemStack> stacks);
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.api.internal;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
@ -21,8 +23,6 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import java.util.List;
/**
* This is the internal method handler.
* Use ActuallyAdditionsAPI.methodHandler for calling
@ -43,9 +43,9 @@ public interface IMethodHandler{
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
boolean invokeReconstructor(IAtomicReconstructor tile);
boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance);
@Deprecated //Use Ingredient input on AA API class
boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance);
IBookletPage generateTextPage(int id);

View file

@ -11,20 +11,49 @@
package de.ellpeck.actuallyadditions.api.recipe;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
public class CrusherRecipe{
public class CrusherRecipe {
public ItemStack inputStack;
@Deprecated //ModTweaker compat, will be removed soon.
public ItemStack outputOneStack;
public ItemStack outputTwoStack;
public int outputTwoChance;
private Ingredient input;
private ItemStack outputOne;
private ItemStack outputTwo;
private int outputChance;
public CrusherRecipe(ItemStack inputStack, ItemStack outputOneStack, ItemStack outputTwoStack, int outputTwoChance){
this.inputStack = inputStack;
this.outputOneStack = outputOneStack;
this.outputTwoStack = outputTwoStack;
this.outputTwoChance = outputTwoChance;
@Deprecated //ModTweaker compat, will be removed soon.
public CrusherRecipe(ItemStack input, ItemStack outputOne, ItemStack outputTwo, int outputChance) {
this(Ingredient.fromStacks(input), outputOne, outputTwo, outputChance);
}
public CrusherRecipe(Ingredient input, ItemStack outputOne, ItemStack outputTwo, int outputChance) {
this.input = input;
this.outputOne = outputOne;
this.outputTwo = outputTwo;
this.outputChance = outputChance;
outputOneStack = outputOne;
}
public boolean matches(ItemStack stack) {
return input.apply(stack);
}
public ItemStack getOutputOne() {
return outputOne;
}
public ItemStack getOutputTwo() {
return outputTwo;
}
public int getSecondChance() {
return outputChance;
}
public Ingredient getInput() {
return input;
}
}

View file

@ -40,6 +40,7 @@ import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.server.MinecraftServer;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
@ -64,6 +65,7 @@ public class ActuallyAdditions {
public static final String VERSION = "@VERSION@";
public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.mod.config.GuiFactory";
public static final String DEPS = "before:craftingtweaks;after:fastbench@[1.3.2,)";
public static final boolean DEOBF = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
@Instance
public static ActuallyAdditions INSTANCE;

View file

@ -78,10 +78,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
if(reconstructor != null){
if(StackUtil.isValid(heldItem)){
Item item = heldItem.getItem();
if(item instanceof ILensItem && !StackUtil.isValid(reconstructor.slots.getStackInSlot(0))){
if(item instanceof ILensItem && !StackUtil.isValid(reconstructor.inv.getStackInSlot(0))){
ItemStack toPut = heldItem.copy();
toPut = StackUtil.setStackSize(toPut, 1);
reconstructor.slots.setStackInSlot(0, toPut);
toPut.setCount(1);
reconstructor.inv.setStackInSlot(0, toPut);
player.inventory.decrStackSize(player.inventory.currentItem, 1);
}
//Shush, don't tell anyone!
@ -91,10 +91,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
}
}
else{
ItemStack slot = reconstructor.slots.getStackInSlot(0);
ItemStack slot = reconstructor.inv.getStackInSlot(0);
if(StackUtil.isValid(slot)){
player.setHeldItem(hand, slot.copy());
reconstructor.slots.setStackInSlot(0, StackUtil.getEmpty());
reconstructor.inv.setStackInSlot(0, StackUtil.getEmpty());
}
}
}
@ -113,7 +113,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityAtomicReconstructor){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).slots.getStackInSlot(0);
ItemStack slot = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0);
String strg;
if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ActuallyAdditions.MODID+".noLens");

View file

@ -56,17 +56,17 @@ public class BlockBatteryBox extends BlockContainerBase{
ItemStack stack = player.getHeldItem(hand);
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.slots.getStackInSlot(0))){
box.slots.setStackInSlot(0, stack.copy());
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))){
box.inv.setStackInSlot(0, stack.copy());
player.setHeldItem(hand, StackUtil.getEmpty());
return true;
}
}
else{
ItemStack inSlot = box.slots.getStackInSlot(0);
ItemStack inSlot = box.inv.getStackInSlot(0);
if(StackUtil.isValid(inSlot)){
player.setHeldItem(hand, inSlot.copy());
box.slots.setStackInSlot(0, StackUtil.getEmpty());
box.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
}
}

View file

@ -88,27 +88,27 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityCompost){
TileEntityCompost compost = (TileEntityCompost)tile;
ItemStack slot = compost.slots.getStackInSlot(0);
ItemStack slot = compost.inv.getStackInSlot(0);
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
if(!StackUtil.isValid(slot) || recipeIn != null){
if(StackUtil.isValid(stackPlayer)){
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
int maxAdd = StackUtil.getStackSize(stackPlayer);
int maxAdd = stackPlayer.getCount();
if(!StackUtil.isValid(slot)){
ItemStack stackToAdd = stackPlayer.copy();
stackToAdd = StackUtil.setStackSize(stackToAdd, maxAdd);
compost.slots.setStackInSlot(0, stackToAdd);
stackToAdd.setCount(maxAdd);
compost.inv.setStackInSlot(0, stackToAdd);
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
return true;
}
else{
ItemStack stackIn = slot.copy();
if(StackUtil.getStackSize(stackIn) < recipeHand.input.getMaxStackSize()){
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-StackUtil.getStackSize(stackIn));
stackIn = StackUtil.addStackSize(stackIn, sizeAdded);
compost.slots.setStackInSlot(0, stackIn);
if(stackIn.getCount() < recipeHand.input.getMaxStackSize()){
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-stackIn.getCount());
stackIn.grow(sizeAdded);
compost.inv.setStackInSlot(0, stackIn);
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
return true;
}
@ -119,15 +119,15 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
else{
if(!StackUtil.isValid(stackPlayer)){
player.setHeldItem(hand, slot.copy());
compost.slots.setStackInSlot(0, StackUtil.getEmpty());
compost.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
}
else if(ItemUtil.canBeStacked(stackPlayer, slot)){
int addedStackSize = Math.min(StackUtil.getStackSize(slot), stackPlayer.getMaxStackSize()-StackUtil.getStackSize(stackPlayer));
int addedStackSize = Math.min(slot.getCount(), stackPlayer.getMaxStackSize()-stackPlayer.getCount());
ItemStack stackToAdd = stackPlayer.copy();
stackToAdd = StackUtil.addStackSize(stackToAdd, addedStackSize);
stackToAdd.grow(addedStackSize);
player.setHeldItem(hand, stackToAdd);
compost.slots.decrStackSize(0, addedStackSize);
compost.inv.getStackInSlot(0).shrink(addedStackSize);
return true;
}
@ -156,13 +156,13 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
if(tile instanceof TileEntityCompost){
ItemStack slot = ((TileEntityCompost)tile).slots.getStackInSlot(0);
ItemStack slot = ((TileEntityCompost)tile).inv.getStackInSlot(0);
String strg;
if(!StackUtil.isValid(slot)){
strg = "Empty";
}
else{
strg = slot.getItem().getItemStackDisplayName(slot);
strg = slot.getDisplayName();
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
}

View file

@ -29,9 +29,9 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockDisplayStand extends BlockContainerBase{
public class BlockDisplayStand extends BlockContainerBase {
public BlockDisplayStand(String name){
public BlockDisplayStand(String name) {
super(Material.ROCK, name);
this.setHarvestLevel("pickaxe", 0);
@ -41,74 +41,71 @@ public class BlockDisplayStand extends BlockContainerBase{
}
@Override
public TileEntity createNewTileEntity(World worldIn, int meta){
public TileEntity createNewTileEntity(World worldIn, int meta) {
return new TileEntityDisplayStand();
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
return BlockSlabs.AABB_BOTTOM_HALF;
}
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9){
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing par6, float par7, float par8, float par9) {
ItemStack heldItem = player.getHeldItem(hand);
if(!world.isRemote){
TileEntityDisplayStand stand = (TileEntityDisplayStand)world.getTileEntity(pos);
if(stand != null){
ItemStack display = stand.slots.getStackInSlot(0);
if(StackUtil.isValid(heldItem)){
if(!StackUtil.isValid(display)){
if (!world.isRemote) {
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getTileEntity(pos);
if (stand != null) {
ItemStack display = stand.inv.getStackInSlot(0);
if (StackUtil.isValid(heldItem)) {
if (!StackUtil.isValid(display)) {
ItemStack toPut = heldItem.copy();
toPut = StackUtil.setStackSize(toPut, 1);
stand.slots.setStackInSlot(0, toPut);
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, -1));
toPut.setCount(1);
stand.inv.setStackInSlot(0, toPut);
if(!player.capabilities.isCreativeMode) heldItem.shrink(1);
return true;
}
else if(ItemUtil.canBeStacked(heldItem, display)){
int maxTransfer = Math.min(StackUtil.getStackSize(display), heldItem.getMaxStackSize()-StackUtil.getStackSize(heldItem));
if(maxTransfer > 0){
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, maxTransfer));
} else if (ItemUtil.canBeStacked(heldItem, display)) {
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
if (maxTransfer > 0) {
heldItem.grow(maxTransfer);
ItemStack newDisplay = display.copy();
newDisplay = StackUtil.addStackSize(newDisplay, -maxTransfer);
stand.slots.setStackInSlot(0, StackUtil.validateCheck(newDisplay));
newDisplay.shrink(maxTransfer);
stand.inv.setStackInSlot(0, newDisplay);
return true;
}
}
}
else{
if(StackUtil.isValid(display)){
} else {
if (StackUtil.isValid(display)) {
player.setHeldItem(hand, display.copy());
stand.slots.setStackInSlot(0, StackUtil.getEmpty());
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
}
}
}
return false;
}
else{
} else {
return true;
}
}
@Override
public boolean isOpaqueCube(IBlockState state){
public boolean isOpaqueCube(IBlockState state) {
return false;
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
if(face == EnumFacing.DOWN) return BlockFaceShape.SOLID;
return BlockFaceShape.UNDEFINED;
}
@Override
public EnumRarity getRarity(ItemStack stack){
public boolean isFullCube(IBlockState state) {
return false;
}
@Override
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
if (face == EnumFacing.DOWN) return BlockFaceShape.SOLID;
return BlockFaceShape.UNDEFINED;
}
@Override
public EnumRarity getRarity(ItemStack stack) {
return EnumRarity.RARE;
}
}

View file

@ -55,22 +55,22 @@ public class BlockEmpowerer extends BlockContainerBase{
if(!world.isRemote){
TileEntityEmpowerer empowerer = (TileEntityEmpowerer)world.getTileEntity(pos);
if(empowerer != null){
ItemStack stackThere = empowerer.slots.getStackInSlot(0);
ItemStack stackThere = empowerer.inv.getStackInSlot(0);
if(StackUtil.isValid(heldItem)){
if(!StackUtil.isValid(stackThere) && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
ItemStack toPut = heldItem.copy();
toPut = StackUtil.setStackSize(toPut, 1);
empowerer.slots.setStackInSlot(0, toPut);
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, -1));
toPut.grow(1);
empowerer.inv.setStackInSlot(0, toPut);
player.setHeldItem(hand, StackUtil.shrink(heldItem, 1));
return true;
}
else if(ItemUtil.canBeStacked(heldItem, stackThere)){
int maxTransfer = Math.min(StackUtil.getStackSize(stackThere), heldItem.getMaxStackSize()-StackUtil.getStackSize(heldItem));
int maxTransfer = Math.min(stackThere.getCount(), heldItem.getMaxStackSize()-heldItem.getCount());
if(maxTransfer > 0){
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, maxTransfer));
player.setHeldItem(hand, StackUtil.grow(heldItem, maxTransfer));
ItemStack newStackThere = stackThere.copy();
newStackThere = StackUtil.addStackSize(newStackThere, -maxTransfer);
empowerer.slots.setStackInSlot(0, StackUtil.validateCheck(newStackThere));
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
empowerer.inv.setStackInSlot(0, newStackThere);
return true;
}
}
@ -78,7 +78,7 @@ public class BlockEmpowerer extends BlockContainerBase{
else{
if(StackUtil.isValid(stackThere)){
player.setHeldItem(hand, stackThere.copy());
empowerer.slots.setStackInSlot(0, StackUtil.getEmpty());
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
return true;
}
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
@ -18,7 +20,10 @@ import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChest;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
import de.ellpeck.actuallyadditions.mod.util.*;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@ -38,8 +43,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import java.util.List;
import net.minecraftforge.items.IItemHandlerModifiable;
public class BlockGiantChest extends BlockContainerBase{
@ -102,12 +106,12 @@ public class BlockGiantChest extends BlockContainerBase{
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityGiantChest){
NBTTagList list = stack.getTagCompound().getTagList("Items", 10);
ItemStackHandlerCustom slots = ((TileEntityGiantChest)tile).slots;
IItemHandlerModifiable inv = ((TileEntityGiantChest)tile).inv;
for(int i = 0; i < list.tagCount(); i++){
NBTTagCompound compound = list.getCompoundTagAt(i);
if(compound != null && compound.hasKey("id")){
slots.setStackInSlot(i, new ItemStack(list.getCompoundTagAt(i)));
inv.setStackInSlot(i, new ItemStack(list.getCompoundTagAt(i)));
}
}
}
@ -122,7 +126,7 @@ public class BlockGiantChest extends BlockContainerBase{
super.getDrops(drops, world, pos, state, fortune);
TileEntity tile = world.getTileEntity(pos);
if(tile instanceof TileEntityGiantChest){
ItemStackHandlerCustom slots = ((TileEntityGiantChest)tile).slots;
ItemStackHandlerAA slots = ((TileEntityGiantChest)tile).inv;
int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
if(place >= 0){
NBTTagList list = new NBTTagList();
@ -153,7 +157,7 @@ public class BlockGiantChest extends BlockContainerBase{
@Override
public boolean shouldDropInventory(World world, BlockPos pos) {
TileEntity tile = world.getTileEntity(pos);
return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
return !(tile instanceof TileEntityGiantChest) || !ItemUtil.contains(((TileEntityGiantChest) tile).inv.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
}
@Override

View file

@ -186,15 +186,16 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
return true;
}
else if(stack.getItem() instanceof ItemLaserRelayUpgrade){
ItemStack inRelay = relay.slots.getStackInSlot(0);
ItemStack inRelay = relay.inv.getStackInSlot(0);
if(!StackUtil.isValid(inRelay)){
if(!world.isRemote){
if(!player.isCreative()){
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
ItemStack set = StackUtil.validateCopy(stack);
relay.slots.setStackInSlot(0, StackUtil.setStackSize(set, 1));
ItemStack set = stack.copy();
set.setCount(1);
relay.inv.setStackInSlot(0, set);
}
return true;
}
@ -203,10 +204,10 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
}
if(player.isSneaking()){
ItemStack inRelay = StackUtil.validateCopy(relay.slots.getStackInSlot(0));
ItemStack inRelay = relay.inv.getStackInSlot(0).copy();
if(StackUtil.isValid(inRelay)){
if(!world.isRemote){
relay.slots.setStackInSlot(0, StackUtil.getEmpty());
relay.inv.setStackInSlot(0, StackUtil.getEmpty());
if(!player.inventory.addItemStackToInventory(inRelay)){
player.entityDropItem(inRelay, 0);

View file

@ -51,25 +51,6 @@ public class BlockSlabs extends BlockBase{
this.fullBlockState = fullBlockState;
}
/*@Override
public void addCollisionBoxesToList(World world, BlockPos pos, IBlockState state, AxisAlignedBB axis, List list, Entity entity){
this.setBlockBoundsBasedOnState(world, pos);
super.addCollisionBoxesToList(world, pos, state, axis, list, entity);
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, BlockPos pos){
int meta = PosUtil.getMetadata(pos, world);
float minY = meta == 1 ? 0.5F : 0.0F;
float maxY = meta == 1 ? 1.0F : 0.5F;
this.setBlockBounds(0.0F, minY, 0F, 1.0F, maxY, 1.0F);
}
@Override
public void setBlockBoundsForItemRender(){
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}*/
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
@ -144,7 +125,7 @@ public class BlockSlabs extends BlockBase{
if(bound != Block.NULL_AABB && world.checkNoEntityCollision(bound.offset(pos)) && world.setBlockState(pos, newState, 11)){
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
return EnumActionResult.SUCCESS;
@ -184,7 +165,7 @@ public class BlockSlabs extends BlockBase{
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
world.playSound(player, pos, soundtype.getPlaceSound(), SoundCategory.BLOCKS, (soundtype.getVolume()+1.0F)/2.0F, soundtype.getPitch()*0.8F);
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
return true;

View file

@ -10,10 +10,11 @@
package de.ellpeck.actuallyadditions.mod.blocks;
import java.util.Random;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockHorizontal;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@ -27,15 +28,19 @@ import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.Mirror;
import net.minecraft.util.Rotation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.Random;
public class BlockTreasureChest extends BlockBase{
public BlockTreasureChest(String name){
@ -92,7 +97,7 @@ public class BlockTreasureChest extends BlockBase{
for(int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++){
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
ItemStack itemStack = theReturn.returnItem.copy();
itemStack = StackUtil.setStackSize(itemStack, MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
itemStack.setCount(MathHelper.getInt(world.rand, theReturn.minAmount, theReturn.maxAmount));
float dX = world.rand.nextFloat()*0.8F+0.1F;
float dY = world.rand.nextFloat()*0.8F+0.1F;

View file

@ -88,8 +88,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
TileEntity aTile = world.getTileEntity(position);
if(aTile instanceof TileEntityInventoryBase){
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
if(tile.slots.getSlots() > 0){
for(int i = 0; i < tile.slots.getSlots(); i++){
if(tile.inv.getSlots() > 0){
for(int i = 0; i < tile.inv.getSlots(); i++){
this.dropSlotFromInventory(i, tile, world, position);
}
}
@ -98,7 +98,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
}
private void dropSlotFromInventory(int i, TileEntityInventoryBase tile, World world, BlockPos pos){
ItemStack stack = tile.slots.getStackInSlot(i);
ItemStack stack = tile.inv.getStackInSlot(i);
if(StackUtil.isValid(stack)){
float dX = world.rand.nextFloat()*0.8F+0.1F;
float dY = world.rand.nextFloat()*0.8F+0.1F;

View file

@ -99,7 +99,7 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit
for(ItemStack drop : drops){
if(StackUtil.isValid(drop)){
if(drop.getItem() == this.seedItem && !deductedSeedSize){
StackUtil.addStackSize(drop, -1);
drop.shrink(1);
deductedSeedSize = true;
}

View file

@ -37,7 +37,7 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatter
return;
}
ItemStack stack = ((TileEntityBatteryBox)tile).slots.getStackInSlot(0);
ItemStack stack = ((TileEntityBatteryBox)tile).inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);

View file

@ -29,7 +29,7 @@ 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.slots.getStackInSlot(0);
ItemStack slot = compost.inv.getStackInSlot(0);
if(StackUtil.isValid(slot)){
Block display = null;
@ -47,7 +47,7 @@ public class RenderCompost extends TileEntitySpecialRenderer<TileEntityCompost>{
}
}
if(display != null){
float i = (float)StackUtil.getStackSize(slot)/(float)maxAmount;
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

View file

@ -31,7 +31,7 @@ public class RenderDisplayStand extends TileEntitySpecialRenderer<TileEntityDisp
return;
}
ItemStack stack = ((TileEntityDisplayStand)tile).slots.getStackInSlot(0);
ItemStack stack = ((TileEntityDisplayStand)tile).inv.getStackInSlot(0);
if(StackUtil.isValid(stack)){
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);

View file

@ -35,7 +35,7 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpower
return;
}
ItemStack stack = ((TileEntityEmpowerer)tile).slots.getStackInSlot(0);
ItemStack stack = ((TileEntityEmpowerer)tile).inv.getStackInSlot(0);
if(StackUtil.isValid(stack)){
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);

View file

@ -49,7 +49,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
EntityPlayer player = Minecraft.getMinecraft().player;
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
ItemStack upgrade = relay.slots.getStackInSlot(0);
ItemStack upgrade = relay.inv.getStackInSlot(0);
if(StackUtil.isValid(upgrade)){
if(upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility){
hasInvis = true;
@ -81,7 +81,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
TileEntity secondTile = tile.getWorld().getTileEntity(second);
if(secondTile instanceof TileEntityLaserRelay){
ItemStack secondUpgrade = ((TileEntityLaserRelay)secondTile).slots.getStackInSlot(0);
ItemStack secondUpgrade = ((TileEntityLaserRelay)secondTile).inv.getStackInSlot(0);
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
if(hasGoggles || !hasInvis || !otherInvis){

View file

@ -30,7 +30,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntit
if(!(tile instanceof TileEntityAtomicReconstructor)){
return;
}
ItemStack stack = ((TileEntityAtomicReconstructor)tile).slots.getStackInSlot(0);
ItemStack stack = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
GlStateManager.pushMatrix();

View file

@ -180,7 +180,7 @@ public class PageCrafting extends BookletPage{
ItemStack stack = stacks[0];
if(StackUtil.isValid(stack)){
ItemStack copy = stack.copy();
copy = StackUtil.setStackSize(copy, 1);
copy.setCount(1);
if(copy.getItemDamage() == Util.WILDCARD){
copy.setItemDamage(0);
}

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.booklet.page;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
@ -21,15 +23,17 @@ import net.minecraftforge.fml.client.config.GuiUtils;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class PageCrusherRecipe extends BookletPage{
private final CrusherRecipe recipe;
private int counter = 0;
private int rotate = 0;
private final ItemStack[] stacks;
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe){
super(localizationKey);
this.recipe = recipe;
stacks = recipe.getInput().getMatchingStacks();
}
@Override
@ -43,6 +47,8 @@ public class PageCrusherRecipe extends BookletPage{
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".crusherRecipe")+")", startX+36, startY+85, 0, false, gui.getMediumFontSize());
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
if(counter++ % 50 == 0)gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+38+18, startY+6+1, 1F, true);
}
@Override
@ -51,11 +57,11 @@ public class PageCrusherRecipe extends BookletPage{
super.initGui(gui, startX, startY);
if(this.recipe != null){
gui.addOrModifyItemRenderer(this.recipe.inputStack, startX+38+18, startY+6+2, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.outputOneStack, startX+38+4, startY+6+53, 1F, false);
gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+38+18, startY+6+1, 1F, true);
gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX+38+4, startY+6+53, 1F, false);
if(StackUtil.isValid(this.recipe.outputTwoStack)){
gui.addOrModifyItemRenderer(this.recipe.outputTwoStack, startX+38+30, startY+6+53, 1F, false);
if(StackUtil.isValid(this.recipe.getOutputTwo())){
gui.addOrModifyItemRenderer(this.recipe.getOutputTwo(), startX+38+30, startY+6+53, 1F, false);
}
}
}
@ -65,10 +71,10 @@ public class PageCrusherRecipe extends BookletPage{
super.getItemStacksForPage(list);
if(this.recipe != null){
list.add(this.recipe.outputOneStack);
list.add(this.recipe.getOutputOne());
if(StackUtil.isValid(this.recipe.outputTwoStack)){
list.add(this.recipe.outputTwoStack);
if(StackUtil.isValid(this.recipe.getOutputTwo())){
list.add(this.recipe.getOutputTwo());
}
}
}

View file

@ -10,10 +10,13 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import java.util.ArrayList;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheDusts;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
@ -23,21 +26,17 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.Collections;
import net.minecraftforge.oredict.OreIngredient;
public final class CrusherCrafting{
public static final ArrayList<CrusherRecipe> MISC_RECIPES = new ArrayList<CrusherRecipe>();
public static final ArrayList<CrusherRecipe> MISC_RECIPES = new ArrayList<>();
public static CrusherRecipe recipeIronHorseArmor;
public static CrusherRecipe recipeGoldHorseArmor;
public static CrusherRecipe recipeDiamondHorseArmor;
public static void init(){
ActuallyAdditions.LOGGER.info("Initializing Crusher Recipes...");
final NonNullList<ItemStack> LIST = NonNullList.withSize(1, StackUtil.getEmpty());
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15), StackUtil.getEmpty(), 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
@ -75,15 +74,15 @@ public final class CrusherCrafting{
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 5), new ItemStack(Items.DYE, 4, 9), StackUtil.getEmpty(), 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreRedstone", false), new ItemStack(Items.REDSTONE), 10, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreLapis", false), new ItemStack(Items.DYE, 1, 4), 12, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("coal", false), OreDictionary.getOres("dustCoal", false), 1, LIST, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreCoal", false), new ItemStack(Items.COAL), 3, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("blockCoal", false), new ItemStack(Items.COAL), 9, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreQuartz", false), new ItemStack(Items.QUARTZ), 3, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("cobblestone", false), new ItemStack(Blocks.SAND), 1, StackUtil.getEmpty(), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreRedstone"), new ItemStack(Items.REDSTONE, 10), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreLapis"), new ItemStack(Items.DYE, 12, 4), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("coal"), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL,3), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL,9), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ,3), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("cobblestone"), new ItemStack(Blocks.SAND), StackUtil.getEmpty(), 0);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.GRAVEL), new ItemStack(Items.FLINT), new ItemStack(Items.FLINT), 50);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, LIST, 0, 0);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("stone", false), OreDictionary.getOres("cobblestone", false), 1, NonNullList.withSize(1, StackUtil.getEmpty()), 0, 0);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2), StackUtil.getEmpty(), 0);
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
@ -94,13 +93,19 @@ public final class CrusherCrafting{
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreNickel", false), OreDictionary.getOres("dustNickel", false), 2, OreDictionary.getOres("dustPlatinum", false), 1, 15);
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreIron", false), OreDictionary.getOres("dustIron", false), 2, OreDictionary.getOres("dustGold", false), 1, 20);
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.IRON_HORSE_ARMOR)), OreDictionary.getOres("dustIron", false), 6, LIST, 0, 0);
ItemStack temp = OreDictionary.getOres("dustIron").get(0).copy();
temp.setCount(6);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.IRON_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0);
recipeIronHorseArmor = RecipeUtil.lastCrusherRecipe();
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.GOLDEN_HORSE_ARMOR)), OreDictionary.getOres("dustGold"), 6, LIST, 0, 0);
temp = OreDictionary.getOres("dustGold").get(0).copy();
temp.setCount(6);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.GOLDEN_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0);
recipeGoldHorseArmor = RecipeUtil.lastCrusherRecipe();
ActuallyAdditionsAPI.addCrusherRecipes(Collections.singletonList(new ItemStack(Items.DIAMOND_HORSE_ARMOR)), OreDictionary.getOres("dustDiamond"), 6, LIST, 0, 0);
temp = OreDictionary.getOres("dustDiamond").get(0).copy();
temp.setCount(6);
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.DIAMOND_HORSE_ARMOR), temp, StackUtil.getEmpty(), 0);
recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe();
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6));
@ -108,8 +113,8 @@ public final class CrusherCrafting{
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("denseore", 8));
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("gem", 1));
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ingot", 1));
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2, "gem")); //Search for gems first so removeDuplicates doesn't clear gem recipes.
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2));
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2, "gem")); //If no dust is found for certain ores, make gems directly
CrusherRecipeRegistry.registerFinally();
}

View file

@ -52,13 +52,7 @@ public final class InitCrafting{
ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior());
ActuallyAdditionsAPI.addFarmerBehavior(new RedOrchidFarmerBehavior());
//RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShaped", RecipeKeepDataShaped.class, RecipeSorter.Category.SHAPED, "after:minecraft:shaped");
//RecipeSorter.register(ModUtil.MOD_ID+":recipeKeepDataShapeless", RecipeKeepDataShapeless.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
new RecipePotionRingCharging(new ResourceLocation(ActuallyAdditions.MODID, "potion_ring_charging"));
//RecipeSorter.register(ModUtil.MOD_ID+":recipePotionRingCharging", RecipePotionRingCharging.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
new RecipeBioMash(new ResourceLocation(ActuallyAdditions.MODID, "bio_mash"));
//RecipeSorter.register(ModUtil.MOD_ID+":recipeBioMash", RecipeBioMash.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
}
}

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.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
@ -22,7 +24,7 @@ import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.misc.DungeonLoot;
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState;
@ -41,8 +43,6 @@ import net.minecraftforge.fml.common.eventhandler.Event;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
import java.util.Locale;
public class CommonEvents{
public CommonEvents(){
@ -78,14 +78,14 @@ public class CommonEvents{
boolean changed = false;
boolean isVoid = ((ItemBag)invStack.getItem()).isVoid;
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerBag.getSlotAmount(isVoid));
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(isVoid));
ItemDrill.loadSlotsFromNBT(inv, invStack);
FilterSettings filter = new FilterSettings(4, false, false, false, false, 0, 0);
filter.readFromNBT(invStack.getTagCompound(), "Filter");
if(filter.check(stack)){
if(isVoid){
stack = StackUtil.setStackSize(stack, 0);
stack.setCount(0);
changed = true;
}
else{
@ -93,17 +93,17 @@ public class CommonEvents{
ItemStack bagStack = inv.getStackInSlot(j);
if(StackUtil.isValid(bagStack)){
if(ItemUtil.canBeStacked(bagStack, stack)){
int maxTransfer = Math.min(StackUtil.getStackSize(stack), stack.getMaxStackSize()-StackUtil.getStackSize(bagStack));
int maxTransfer = Math.min(stack.getCount(), stack.getMaxStackSize()-bagStack.getCount());
if(maxTransfer > 0){
inv.setStackInSlot(j, StackUtil.addStackSize(bagStack, maxTransfer));
stack = StackUtil.addStackSize(stack, -maxTransfer);
inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer));
stack.shrink(maxTransfer);
changed = true;
}
}
}
else{
inv.setStackInSlot(j, stack.copy());
stack = StackUtil.setStackSize(stack, 0);
stack.setCount(0);
changed = true;
}

View file

@ -10,7 +10,8 @@
package de.ellpeck.actuallyadditions.mod.gen.village;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import java.util.Random;
import net.minecraft.entity.IMerchant;
import net.minecraft.entity.passive.EntityVillager.ITradeList;
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
@ -19,8 +20,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.village.MerchantRecipe;
import net.minecraft.village.MerchantRecipeList;
import java.util.Random;
public class BasicTradeList implements ITradeList{
private final ItemStack input;
@ -46,9 +45,9 @@ public class BasicTradeList implements ITradeList{
@Override
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random){
ItemStack in = this.input.copy();
in = StackUtil.setStackSize(in, this.inputAmount.getPrice(random));
in.setCount(this.inputAmount.getPrice(random));
ItemStack out = this.output.copy();
out = StackUtil.setStackSize(out, this.outputAmount.getPrice(random));
out.setCount(this.outputAmount.getPrice(random));
recipeList.add(new MerchantRecipe(in, out));
}
}

View file

@ -110,7 +110,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
if(compost instanceof TileEntityCompost){
TileEntityCompost tile = (TileEntityCompost)compost;
tile.stopFromDropping = true;
tile.slots.setStackInSlot(0, new ItemStack(InitItems.itemFertilizer, 10));
tile.inv.setStackInSlot(0, new ItemStack(InitItems.itemFertilizer, 10));
}
}
@ -135,7 +135,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
TileEntityCanolaPress tile = (TileEntityCanolaPress)press;
tile.stopFromDropping = true;
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3));
tile.slots.setStackInSlot(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal()));
tile.inv.setStackInSlot(0, new ItemStack(InitItems.itemMisc, world.rand.nextInt(60)+1, TheMiscItems.CANOLA.ordinal()));
}
TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
@ -144,7 +144,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
tile.stopFromDropping = true;
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
if(world.rand.nextFloat() >= 0.25F){
tile.slots.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
tile.inv.setStackInSlot(TileEntityGrinder.SLOT_INPUT_1, new ItemStack(InitBlocks.blockMisc, world.rand.nextInt(10)+1, TheMiscBlocks.ORE_QUARTZ.ordinal()));
}
}
@ -152,7 +152,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
if(coal instanceof TileEntityCoalGenerator){
TileEntityCoalGenerator tile = (TileEntityCoalGenerator)coal;
tile.stopFromDropping = true;
tile.slots.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1));
tile.inv.setStackInSlot(0, new ItemStack(Items.COAL, world.rand.nextInt(25)+3, 1));
}
TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb);

View file

@ -25,7 +25,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemBag;
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -44,7 +44,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
public class ContainerBag extends Container implements IButtonReactor{
public final FilterSettings filter = new FilterSettings(4, false, true, false, false, 0, -1000);
private final ItemStackHandlerCustom bagInventory;
private final ItemStackHandlerAA bagInventory;
private final InventoryPlayer inventory;
private final boolean isVoid;
public boolean autoInsert;
@ -53,7 +53,7 @@ public class ContainerBag extends Container implements IButtonReactor{
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){
this.inventory = inventory;
this.bagInventory = new ItemStackHandlerCustom(getSlotAmount(isVoid)) {
this.bagInventory = new ItemStackHandlerAA(getSlotAmount(isVoid)) {
@Override
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
if(isBlacklisted(stack)) return stack;
@ -198,7 +198,7 @@ public class ContainerBag extends Container implements IButtonReactor{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -29,7 +29,7 @@ public class ContainerBioReactor extends Container{
for(int i = 0; i < 4; i++){
for(int j = 0; j < 2; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tile.slots, j+i*2, 50+j*18, 13+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tile.inv, j+i*2, 50+j*18, 13+i*18));
}
}
@ -86,7 +86,7 @@ public class ContainerBioReactor extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,7 +30,7 @@ public class ContainerBreaker extends Container{
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.slots, j+i*3, 62+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j+i*3, 62+j*18, 21+i*18));
}
}
@ -83,7 +83,7 @@ public class ContainerBreaker extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,7 +30,7 @@ public class ContainerCanolaPress extends Container{
public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){
this.press = (TileEntityCanolaPress)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.press.slots, 0, 81, 10));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.press.inv, 0, 81, 10));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -85,7 +85,7 @@ public class ContainerCanolaPress extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -29,7 +29,7 @@ public class ContainerCoalGenerator extends Container{
public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){
this.generator = (TileEntityCoalGenerator)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.generator.slots, 0, 87, 43));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.generator.inv, 0, 87, 43));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -84,7 +84,7 @@ public class ContainerCoalGenerator extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -32,13 +32,13 @@ public class ContainerCoffeeMachine extends Container{
public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){
this.machine = (TileEntityCoffeeMachine)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.slots, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.slots, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42));
this.addSlotToContainer(new SlotOutput(this.machine.slots, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42));
this.addSlotToContainer(new SlotOutput(this.machine.inv, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73));
for(int i = 0; i < 4; i++){
for(int j = 0; j < 2; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.slots, j+i*2+3, 125+j*18, 6+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, j+i*2+3, 125+j*18, 6+i*18));
}
}
@ -112,7 +112,7 @@ public class ContainerCoffeeMachine extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,7 +30,7 @@ public class ContainerDirectionalBreaker extends Container{
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.slots, j+i*3, 74+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.breaker.inv, j+i*3, 74+j*18, 21+i*18));
}
}
@ -83,7 +83,7 @@ public class ContainerDirectionalBreaker extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -14,7 +14,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotItemHandlerUnconditioned;
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -28,7 +28,7 @@ public class ContainerDrill extends Container{
public static final int SLOT_AMOUNT = 5;
private final ItemStackHandlerCustom drillInventory = new ItemStackHandlerCustom(SLOT_AMOUNT);
private final ItemStackHandlerAA drillInventory = new ItemStackHandlerAA(SLOT_AMOUNT);
private final InventoryPlayer inventory;
public ContainerDrill(InventoryPlayer inventory){
@ -106,7 +106,7 @@ public class ContainerDrill extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -33,7 +33,7 @@ public class ContainerDropper extends Container{
InventoryPlayer inventory = player.inventory;
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.dropper.slots, j+i*3, 62+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.dropper.inv, j+i*3, 62+j*18, 21+i*18));
}
}
@ -86,7 +86,7 @@ public class ContainerDropper extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotOutput;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
@ -26,49 +27,54 @@ import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class ContainerEnergizer extends Container {
public class ContainerEnergizer extends Container{
public static final EntityEquipmentSlot[] VALID_EQUIPMENT_SLOTS = new EntityEquipmentSlot[]{EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET};
public static final EntityEquipmentSlot[] VALID_EQUIPMENT_SLOTS = new EntityEquipmentSlot[] { EntityEquipmentSlot.HEAD, EntityEquipmentSlot.CHEST, EntityEquipmentSlot.LEGS, EntityEquipmentSlot.FEET };
private final TileEntityEnergizer energizer;
public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile){
this.energizer = (TileEntityEnergizer)tile;
public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile) {
this.energizer = (TileEntityEnergizer) tile;
InventoryPlayer inventory = player.inventory;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.energizer.slots, 0, 76, 73) {
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.energizer.inv, 0, 76, 73) {
@Override
public boolean isItemValid(ItemStack stack) {
return super.isItemValid(stack) && stack.hasCapability(CapabilityEnergy.ENERGY, null);
}
});
this.addSlotToContainer(new SlotOutput(this.energizer.slots, 1, 76, 42));
this.addSlotToContainer(new SlotOutput(this.energizer.inv, 1, 76, 42));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
}
}
for(int i = 0; i < 9; i++){
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
for (int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(inventory, i, 8 + i * 18, 155));
}
for(int k = 0; k < 4; ++k){
for (int k = 0; k < 4; ++k) {
final EntityEquipmentSlot slot = VALID_EQUIPMENT_SLOTS[k];
this.addSlotToContainer(new Slot(player.inventory, 36+(3-k), 102, 19+k*18){
this.addSlotToContainer(new Slot(player.inventory, 36 + (3 - k), 102, 19 + k * 18) {
@Override
public int getSlotStackLimit(){
public int getSlotStackLimit() {
return 1;
}
@Override
public boolean isItemValid(ItemStack stack){
public boolean isItemValid(ItemStack stack) {
return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
}
@Override
public boolean canTakeStack(EntityPlayer player) {
ItemStack itemstack = this.getStack();
return !itemstack.isEmpty() && !player.isCreative() && EnchantmentHelper.hasBindingCurse(itemstack) ? false : super.canTakeStack(player);
}
@Override
@SideOnly(Side.CLIENT)
public String getSlotTexture(){
public String getSlotTexture() {
return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
}
});
@ -76,58 +82,43 @@ public class ContainerEnergizer extends Container{
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
int inventoryStart = 2;
int inventoryEnd = inventoryStart+26;
int hotbarStart = inventoryEnd+1;
int hotbarEnd = hotbarStart+8;
int inventoryEnd = inventoryStart + 26;
int hotbarStart = inventoryEnd + 1;
int hotbarEnd = hotbarStart + 8;
Slot theSlot = this.inventorySlots.get(slot);
if(theSlot != null && theSlot.getHasStack()){
if (theSlot != null && theSlot.getHasStack()) {
ItemStack newStack = theSlot.getStack();
ItemStack currentStack = newStack.copy();
//Slots in Inventory to shift from
if(slot == 1){
if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){
return StackUtil.getEmpty();
}
if (slot == 1) {
if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); }
theSlot.onSlotChange(newStack, currentStack);
}
//Other Slots in Inventory excluded
else if(slot >= inventoryStart){
else if (slot >= inventoryStart) {
//Shift from Inventory
if(newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
if(!this.mergeItemStack(newStack, 0, 1, false)){
return StackUtil.getEmpty();
}
if (newStack.hasCapability(CapabilityEnergy.ENERGY, null)) {
if (!this.mergeItemStack(newStack, 0, 1, false)) { return StackUtil.getEmpty(); }
}
//
else if(slot >= inventoryStart && slot <= inventoryEnd){
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
return StackUtil.getEmpty();
}
}
else if(slot >= inventoryEnd+1 && slot < hotbarEnd+1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd+1, false)){
return StackUtil.getEmpty();
}
}
else if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, false)){
return StackUtil.getEmpty();
}
else if (slot >= inventoryStart && slot <= inventoryEnd) {
if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); }
} else if (slot >= inventoryEnd + 1 && slot < hotbarEnd + 1 && !this.mergeItemStack(newStack, inventoryStart, inventoryEnd + 1, false)) { return StackUtil.getEmpty(); }
} else if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); }
if(!StackUtil.isValid(newStack)){
if (!StackUtil.isValid(newStack)) {
theSlot.putStack(StackUtil.getEmpty());
}
else{
} else {
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
return StackUtil.getEmpty();
}
if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); }
theSlot.onTake(player, newStack);
return currentStack;
@ -136,7 +127,7 @@ public class ContainerEnergizer extends Container{
}
@Override
public boolean canInteractWith(EntityPlayer player){
public boolean canInteractWith(EntityPlayer player) {
return this.energizer.canPlayerUse(player);
}
}

View file

@ -35,8 +35,8 @@ public class ContainerEnervator extends Container{
this.enervator = (TileEntityEnervator)tile;
InventoryPlayer inventory = player.inventory;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.slots, 0, 76, 73));
this.addSlotToContainer(new SlotOutput(this.enervator.slots, 1, 76, 42));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.inv, 0, 76, 73));
this.addSlotToContainer(new SlotOutput(this.enervator.inv, 1, 76, 42));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -119,7 +119,7 @@ public class ContainerEnervator extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,12 +30,12 @@ public class ContainerFarmer extends Container{
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.slots, j+i*2, 67+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, j+i*2, 67+j*18, 21+i*18));
}
}
for(int i = 0; i < 3; i++){
for(int j = 0; j < 2; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.slots, 6+j+i*2, 105+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.farmer.inv, 6+j+i*2, 105+j*18, 21+i*18));
}
}
@ -88,7 +88,7 @@ public class ContainerFarmer extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -27,7 +27,7 @@ public class ContainerFeeder extends Container{
public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile){
this.tileFeeder = (TileEntityFeeder)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFeeder.slots, 0, 80, 45));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFeeder.inv, 0, 80, 45));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -78,7 +78,7 @@ public class ContainerFeeder extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -72,7 +72,7 @@ public class ContainerFermentingBarrel extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -13,7 +13,7 @@ package de.ellpeck.actuallyadditions.mod.inventory;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
@ -27,7 +27,7 @@ public class ContainerFilter extends Container{
public static final int SLOT_AMOUNT = 24;
private final ItemStackHandlerCustom filterInventory = new ItemStackHandlerCustom(SLOT_AMOUNT);
private final ItemStackHandlerAA filterInventory = new ItemStackHandlerAA(SLOT_AMOUNT);
private final InventoryPlayer inventory;
public ContainerFilter(InventoryPlayer inventory){
@ -96,7 +96,7 @@ public class ContainerFilter extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -79,7 +79,7 @@ public class ContainerFluidCollector extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,10 +30,10 @@ public class ContainerFurnaceDouble extends Container{
public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){
this.tileFurnace = (TileEntityFurnaceDouble)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21));
this.addSlotToContainer(new SlotOutput(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21));
this.addSlotToContainer(new SlotOutput(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21));
this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21));
this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -97,7 +97,7 @@ public class ContainerFurnaceDouble extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -31,7 +31,7 @@ public class ContainerGiantChest extends Container{
for(int i = 0; i < 9; i++){
for(int j = 0; j < 13; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileChest.slots, (9*13*page)+j+(i*13), 5+j*18, 5+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileChest.inv, (9*13*page)+j+(i*13), 5+j*18, 5+i*18));
}
}
@ -84,7 +84,7 @@ public class ContainerGiantChest extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -32,13 +32,13 @@ public class ContainerGrinder extends Container{
this.tileGrinder = (TileEntityGrinder)tile;
this.isDouble = isDouble;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.slots, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 : 80, 21));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.slots, TileEntityGrinder.SLOT_OUTPUT_1_1, this.isDouble ? 37 : 66, 69));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.slots, TileEntityGrinder.SLOT_OUTPUT_1_2, this.isDouble ? 64 : 92, 69));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 : 80, 21));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_1_1, this.isDouble ? 37 : 66, 69));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_1_2, this.isDouble ? 64 : 92, 69));
if(this.isDouble){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.slots, TileEntityGrinder.SLOT_INPUT_2, 109, 21));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.slots, TileEntityGrinder.SLOT_OUTPUT_2_1, 96, 69));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.slots, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, TileEntityGrinder.SLOT_INPUT_2, 109, 21));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_2_1, 96, 69));
this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69));
}
for(int i = 0; i < 3; i++){
@ -108,7 +108,7 @@ public class ContainerGrinder extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -34,7 +34,7 @@ public class ContainerInputter extends Container{
this.tileInputter = (TileEntityInputter)tile;
this.isAdvanced = isAdvanced;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileInputter.slots, 0, 80, 21+(isAdvanced ? 12 : 0)));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileInputter.inv, 0, 80, 21+(isAdvanced ? 12 : 0)));
if(isAdvanced){
for(int i = 0; i < 2; i++){
@ -95,7 +95,7 @@ public class ContainerInputter extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -82,7 +82,7 @@ public class ContainerLaserRelayItemWhitelist extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,7 +30,7 @@ public class ContainerMiner extends Container{
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.miner.slots, j+i*3, 62+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.miner.inv, j+i*3, 62+j*18, 21+i*18));
}
}
@ -83,7 +83,7 @@ public class ContainerMiner extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -71,7 +71,7 @@ public class ContainerOilGenerator extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,7 +30,7 @@ public class ContainerPhantomPlacer extends Container{
for(int i = 0; i < 3; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.placer.slots, j+i*3, 62+j*18, 21+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.placer.inv, j+i*3, 62+j*18, 21+i*18));
}
}
@ -83,7 +83,7 @@ public class ContainerPhantomPlacer extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -32,7 +32,7 @@ public class ContainerRangedCollector extends Container{
for(int i = 0; i < 2; i++){
for(int j = 0; j < 3; j++){
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.collector.slots, j+i*3, 96+j*18, 24+i*18));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.collector.inv, j+i*3, 96+j*18, 24+i*18));
}
}
for(int i = 0; i < 4; i++){
@ -90,7 +90,7 @@ public class ContainerRangedCollector extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -29,8 +29,8 @@ public class ContainerRepairer extends Container{
public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){
this.tileRepairer = (TileEntityItemRepairer)tile;
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileRepairer.slots, TileEntityItemRepairer.SLOT_INPUT, 47, 53));
this.addSlotToContainer(new SlotOutput(this.tileRepairer.slots, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_INPUT, 47, 53));
this.addSlotToContainer(new SlotOutput(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -85,7 +85,7 @@ public class ContainerRepairer extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -30,8 +30,8 @@ public class ContainerXPSolidifier extends Container{
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
this.solidifier = (TileEntityXPSolidifier)tile;
this.addSlotToContainer(new SlotOutput(this.solidifier.slots, 0, 95, 8));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.solidifier.slots, 1, 65, 8));
this.addSlotToContainer(new SlotOutput(this.solidifier.inv, 0, 95, 8));
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.solidifier.inv, 1, 65, 8));
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
@ -83,7 +83,7 @@ public class ContainerXPSolidifier extends Container{
theSlot.onSlotChanged();
}
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
if(newStack.getCount() == currentStack.getCount()){
return StackUtil.getEmpty();
}
theSlot.onTake(player, newStack);

View file

@ -61,7 +61,7 @@ public class GuiRepairer extends GuiWtfMojang{
this.mc.getTextureManager().bindTexture(RES_LOC);
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.slots.getStackInSlot(TileEntityItemRepairer.SLOT_INPUT))){
if(TileEntityItemRepairer.canBeRepaired(this.tileRepairer.inv.getStackInSlot(TileEntityItemRepairer.SLOT_INPUT))){
int i = this.tileRepairer.getItemDamageToScale(22);
this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16);
}

View file

@ -10,12 +10,12 @@
package de.ellpeck.actuallyadditions.mod.inventory.slot;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import net.minecraft.item.ItemStack;
public class SlotDeletion extends SlotItemHandlerUnconditioned{
public SlotDeletion(ItemStackHandlerCustom inv, int slot, int x, int y){
public SlotDeletion(ItemStackHandlerAA inv, int slot, int x, int y){
super(inv, slot, x, y);
}

View file

@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.slot;
import de.ellpeck.actuallyadditions.mod.items.ItemFilter;
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
@ -21,7 +21,7 @@ import net.minecraft.item.ItemStack;
public class SlotFilter extends SlotItemHandlerUnconditioned{
public SlotFilter(ItemStackHandlerCustom inv, int slot, int x, int y){
public SlotFilter(ItemStackHandlerAA inv, int slot, int x, int y){
super(inv, slot, x, y);
}
@ -57,10 +57,10 @@ public class SlotFilter extends SlotItemHandlerUnconditioned{
}
else if(StackUtil.isValid(heldStack)){
if(!isFilter(stackInSlot)){
this.putStack(StackUtil.setStackSize(heldStack.copy(), 1));
this.putStack(StackUtil.grow(heldStack.copy(), 1));
if(isFilter(heldStack)){
player.inventory.setItemStack(StackUtil.addStackSize(heldStack, -1));
player.inventory.setItemStack(StackUtil.shrink(heldStack, 1));
}
}
}
@ -73,7 +73,7 @@ public class SlotFilter extends SlotItemHandlerUnconditioned{
@Override
public void putStack(ItemStack stack){
super.putStack(StackUtil.validateCopy(stack));
super.putStack(stack.copy());
}
@Override

View file

@ -10,33 +10,31 @@
package de.ellpeck.actuallyadditions.mod.inventory.slot;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import javax.annotation.Nonnull;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.SlotItemHandler;
import javax.annotation.Nonnull;
public class SlotItemHandlerUnconditioned extends SlotItemHandler {
public class SlotItemHandlerUnconditioned extends SlotItemHandler{
private final ItemStackHandlerAA inv;
private final ItemStackHandlerCustom handler;
public SlotItemHandlerUnconditioned(ItemStackHandlerCustom handler, int index, int xPosition, int yPosition){
super(handler, index, xPosition, yPosition);
this.handler = handler;
public SlotItemHandlerUnconditioned(ItemStackHandlerAA inv, int index, int xPosition, int yPosition) {
super(inv, index, xPosition, yPosition);
this.inv = inv;
}
@Override
public boolean isItemValid(ItemStack stack){
if(StackUtil.isValid(stack)){
ItemStack currentStack = this.handler.getStackInSlot(this.getSlotIndex());
this.handler.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
ItemStack remainder = this.handler.insertItemInternal(this.getSlotIndex(), stack, true);
this.handler.setStackInSlot(this.getSlotIndex(), currentStack);
return remainder.isEmpty() || remainder.getCount() < stack.getCount();
}
return false;
public boolean isItemValid(ItemStack stack) {
if (stack.isEmpty() || !inv.canAccept(getSlotIndex(), stack, false)) return false;
ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex());
this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), stack, true, false);
this.inv.setStackInSlot(this.getSlotIndex(), currentStack);
return remainder.isEmpty() || remainder.getCount() < stack.getCount();
}
/**
@ -44,34 +42,34 @@ public class SlotItemHandlerUnconditioned extends SlotItemHandler{
*/
@Override
@Nonnull
public ItemStack getStack(){
return this.handler.getStackInSlot(this.getSlotIndex());
public ItemStack getStack() {
return this.inv.getStackInSlot(this.getSlotIndex());
}
@Override
public void putStack(ItemStack stack){
this.handler.setStackInSlot(this.getSlotIndex(), stack);
public void putStack(ItemStack stack) {
this.inv.setStackInSlot(this.getSlotIndex(), stack);
this.onSlotChanged();
}
@Override
public int getItemStackLimit(ItemStack stack){
public int getItemStackLimit(ItemStack stack) {
ItemStack maxAdd = stack.copy();
maxAdd.setCount(stack.getMaxStackSize());
ItemStack currentStack = this.handler.getStackInSlot(this.getSlotIndex());
this.handler.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
ItemStack remainder = this.handler.insertItemInternal(this.getSlotIndex(), maxAdd, true);
this.handler.setStackInSlot(this.getSlotIndex(), currentStack);
return stack.getMaxStackSize()-remainder.getCount();
ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex());
this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), maxAdd, true, false);
this.inv.setStackInSlot(this.getSlotIndex(), currentStack);
return stack.getMaxStackSize() - remainder.getCount();
}
@Override
public boolean canTakeStack(EntityPlayer playerIn){
return !this.handler.extractItemInternal(this.getSlotIndex(), 1, true).isEmpty();
public boolean canTakeStack(EntityPlayer playerIn) {
return !this.inv.extractItem(this.getSlotIndex(), 1, true, false).isEmpty();
}
@Override
public ItemStack decrStackSize(int amount){
return this.handler.extractItemInternal(this.getSlotIndex(), amount, false);
public ItemStack decrStackSize(int amount) {
return this.inv.extractItem(this.getSlotIndex(), amount, false, false);
}
}

View file

@ -10,12 +10,12 @@
package de.ellpeck.actuallyadditions.mod.inventory.slot;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import net.minecraft.item.ItemStack;
public class SlotOutput extends SlotItemHandlerUnconditioned{
public SlotOutput(ItemStackHandlerCustom inventory, int id, int x, int y){
public SlotOutput(ItemStackHandlerAA inventory, int id, int x, int y){
super(inventory, id, x, y);
}

View file

@ -10,17 +10,22 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.List;
import javax.annotation.Nullable;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler.GuiTypes;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
@ -32,9 +37,6 @@ import net.minecraft.world.World;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import javax.annotation.Nullable;
import java.util.List;
public class ItemBag extends ItemBase{
public final boolean isVoid;
@ -47,7 +49,7 @@ public class ItemBag extends ItemBase{
@Override
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced){
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerBag.getSlotAmount(this.isVoid));
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(this.isVoid));
ItemDrill.loadSlotsFromNBT(inv, stack);
int slotsTotal = inv.getSlots();
@ -72,7 +74,7 @@ public class ItemBag extends ItemBase{
if(handler != null){
boolean changed = false;
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerBag.getSlotAmount(this.isVoid));
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(this.isVoid));
ItemDrill.loadSlotsFromNBT(inv, stack);
for(int j = 0; j < inv.getSlots(); j++){
@ -81,7 +83,7 @@ public class ItemBag extends ItemBase{
for(int i = 0; i < handler.getSlots(); i++){
ItemStack remain = handler.insertItem(i, invStack, false);
if(!ItemStack.areItemStacksEqual(remain, invStack)){
inv.setStackInSlot(j, StackUtil.validateCopy(remain));
inv.setStackInSlot(j, remain.copy());
changed = true;
if(!StackUtil.isValid(remain)){
@ -108,11 +110,16 @@ public class ItemBag extends ItemBase{
if(!world.isRemote && hand == EnumHand.MAIN_HAND){
player.openGui(ActuallyAdditions.INSTANCE, (this.isVoid ? GuiTypes.VOID_BAG : GuiTypes.BAG).ordinal(), world, (int)player.posX, (int)player.posY, (int)player.posZ);
}
return new ActionResult<ItemStack>(EnumActionResult.PASS, player.getHeldItem(hand));
return new ActionResult<>(EnumActionResult.PASS, player.getHeldItem(hand));
}
@Override
public EnumRarity getRarity(ItemStack stack){
return this.isVoid ? EnumRarity.RARE : EnumRarity.UNCOMMON;
}
@Override
public NBTTagCompound getNBTShareTag(ItemStack stack){
return null;
}
}

View file

@ -53,7 +53,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
chest = new InvWrapper((IInventory)tileHit);
}
else if(tileHit instanceof TileEntityInventoryBase){
chest = ((TileEntityInventoryBase)tileHit).slots;
chest = ((TileEntityInventoryBase)tileHit).inv;
}
if(chest != null){
@ -74,7 +74,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
//Copy Items into new Chest
TileEntity newTileHit = world.getTileEntity(pos);
if(newTileHit instanceof TileEntityInventoryBase){
IItemHandlerModifiable newChest = ((TileEntityInventoryBase)newTileHit).slots;
IItemHandlerModifiable newChest = ((TileEntityInventoryBase)newTileHit).inv;
for(int i = 0; i < stacks.length; i++){
if(StackUtil.isValid(stacks[i])){

View file

@ -23,7 +23,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
@ -45,16 +45,18 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.EnumHand;
import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.EnumFacing.Axis;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.IItemHandlerModifiable;
public class ItemDrill extends ItemEnergy{
@ -74,7 +76,7 @@ public class ItemDrill extends ItemEnergy{
*
* @param stack The Drill
*/
public static void loadSlotsFromNBT(ItemStackHandlerCustom slots, ItemStack stack){
public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack){
NBTTagCompound compound = stack.getTagCompound();
if(compound != null){
TileEntityInventoryBase.loadSlots(slots, compound);
@ -87,7 +89,7 @@ public class ItemDrill extends ItemEnergy{
* @param slots The Slots
* @param stack The Drill
*/
public static void writeSlotsToNBT(ItemStackHandlerCustom slots, ItemStack stack){
public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack){
NBTTagCompound compound = stack.getTagCompound();
if(compound == null){
compound = new NBTTagCompound();
@ -115,7 +117,7 @@ public class ItemDrill extends ItemEnergy{
//Places the Block into the World
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
if(!player.capabilities.isCreativeMode){
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, StackUtil.validateCopy(toPlaceStack));
WorldUtil.setHandItemWithoutAnnoyingSound(player, hand, toPlaceStack.copy());
}
}
}
@ -147,7 +149,7 @@ public class ItemDrill extends ItemEnergy{
return StackUtil.getEmpty();
}
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerDrill.SLOT_AMOUNT);
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT);
loadSlotsFromNBT(inv, stack);
for(int i = 0; i < inv.getSlots(); i++){
ItemStack slotStack = inv.getStackInSlot(i);

View file

@ -52,7 +52,7 @@ public class ItemFillingWand extends ItemEnergy {
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
ItemStack slot = player.inventory.getStackInSlot(i);
if (StackUtil.isValid(slot) && slot.isItemEqual(stack)) {
slot = StackUtil.addStackSize(slot, -1);
slot.shrink(1);
if (!StackUtil.isValid(slot)) {
player.inventory.setInventorySlotContents(i, StackUtil.getEmpty());
}

View file

@ -10,11 +10,13 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.EntityPlayer;
@ -25,8 +27,6 @@ import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
import java.util.List;
public class ItemFilter extends ItemBase{
public ItemFilter(String name){
@ -51,7 +51,7 @@ public class ItemFilter extends ItemBase{
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced){
super.addInformation(stack, playerIn, tooltip, advanced);
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT);
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT);
ItemDrill.loadSlotsFromNBT(inv, stack);
for(int i = 0; i < inv.getSlots(); i++){
ItemStack slot = inv.getStackInSlot(i);

View file

@ -10,26 +10,29 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.Random;
import java.util.UUID;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.passive.EntityOcelot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.WeightedRandom;
import net.minecraft.world.World;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import java.util.Random;
import java.util.UUID;
public class ItemHairyBall extends ItemBase{
public ItemHairyBall(String name){
@ -61,7 +64,7 @@ public class ItemHairyBall extends ItemBase{
entityItem.setPickupDelay(0);
player.world.spawnEntity(entityItem);
}
stack = StackUtil.addStackSize(stack, -1);
stack.shrink(1);
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat()*0.1F+0.9F);
}

View file

@ -11,8 +11,8 @@
package de.ellpeck.actuallyadditions.mod.items;
import com.google.common.collect.Multimap;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.inventory.EntityEquipmentSlot;
@ -55,6 +55,6 @@ public class ItemKnife extends ItemBase{
public ItemStack getContainerItem(ItemStack stack){
ItemStack theStack = stack.copy();
theStack.setItemDamage(theStack.getItemDamage()+1);
return StackUtil.setStackSize(theStack, 1);
return theStack;
}
}

View file

@ -10,9 +10,10 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
@ -24,8 +25,6 @@ import net.minecraft.util.EnumHand;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.world.World;
import java.util.List;
public class ItemMagnetRing extends ItemEnergy{
public ItemMagnetRing(String name){
@ -50,10 +49,10 @@ public class ItemMagnetRing extends ItemEnergy{
for(EntityItem item : items){
if(item.getEntityData().getBoolean("PreventRemoteMovement")) continue;
if(!item.isDead && !item.cannotPickup()){
int energyForItem = 50*StackUtil.getStackSize(item.getItem());
int energyForItem = 50*item.getItem().getCount();
if(this.getEnergyStored(stack) >= energyForItem){
ItemStack oldItem = StackUtil.validateCopy(item.getItem());
ItemStack oldItem = item.getItem().copy();
item.onCollideWithPlayer(player);

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -31,7 +30,7 @@ public class ItemResonantRice extends ItemBase{
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
ItemStack stack = player.getHeldItem(hand);
if(!world.isRemote){
stack = StackUtil.addStackSize(stack, -1);
stack.shrink(1);
world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
@ -60,13 +59,13 @@ public class ItemSolidifiedExperience extends ItemBase{
if(!player.isSneaking()){
amount = SOLID_XP_AMOUNT;
if(!player.capabilities.isCreativeMode){
stack = StackUtil.addStackSize(stack, -1);
stack.shrink(1);
}
}
else{
amount = SOLID_XP_AMOUNT*StackUtil.getStackSize(stack);
amount = SOLID_XP_AMOUNT*stack.getCount();
if(!player.capabilities.isCreativeMode){
stack = StackUtil.setStackSize(stack, 0);
stack.setCount(0);
}
}
@ -74,7 +73,7 @@ public class ItemSolidifiedExperience extends ItemBase{
orb.getEntityData().setBoolean(ActuallyAdditions.MODID+"FromSolidified", true);
world.spawnEntity(orb);
}
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
}

View file

@ -71,7 +71,7 @@ public class ItemSpawnerChanger extends ItemBase{
ItemPhantomConnector.clearStorage(stack, "Entity");
if(!player.capabilities.isCreativeMode){
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
}
return EnumActionResult.SUCCESS;

View file

@ -61,7 +61,7 @@ public class ItemWaterBowl extends ItemBase{
if(!event.getWorld().isRemote){
event.getWorld().setBlockState(trace.getBlockPos(), Blocks.AIR.getDefaultState(), 11);
ItemStack reduced = StackUtil.addStackSize(event.getItemStack(), -1);
ItemStack reduced = StackUtil.shrink(event.getItemStack(), 1);
ItemStack bowl = new ItemStack(InitItems.itemWaterBowl);
if(!StackUtil.isValid(reduced)){

View file

@ -10,11 +10,12 @@
package de.ellpeck.actuallyadditions.mod.items;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
@ -38,8 +39,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import java.util.List;
public class ItemWorm extends ItemBase{
public ItemWorm(String name){
@ -68,10 +67,7 @@ public class ItemWorm extends ItemBase{
worm.setPosition(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5);
worm.setCustomNameTag(stack.getDisplayName());
world.spawnEntity(worm);
if(!player.capabilities.isCreativeMode){
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
}
if(!player.capabilities.isCreativeMode) stack.shrink(1);
}
return EnumActionResult.SUCCESS;
}

View file

@ -44,7 +44,7 @@ public class LensDisenchanting extends Lens{
for(EntityItem item : items){
if(item != null && !item.isDead){
ItemStack stack = item.getItem();
if(StackUtil.isValid(stack) && StackUtil.getStackSize(stack) == 1){
if(StackUtil.isValid(stack) && stack.getCount() == 1){
Item stackItem = stack.getItem();
if(stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK){
if(book == null){

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.items.lens;
import java.util.ArrayList;
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
@ -25,8 +27,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import java.util.ArrayList;
public class LensDisruption extends Lens{
private static final int ENERGY_USE = 150000;
@ -52,7 +52,7 @@ public class LensDisruption extends Lens{
}
while(!StackUtil.isValid(newStack));
newStack = StackUtil.setStackSize(newStack, StackUtil.getStackSize(stack));
newStack.setCount(stack.getCount());
if(!newStack.hasTagCompound()){
newStack.setTagCompound(new NBTTagCompound());

View file

@ -10,6 +10,8 @@
package de.ellpeck.actuallyadditions.mod.jei.crusher;
import java.util.Arrays;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -53,14 +55,14 @@ public class CrusherRecipeCategory implements IRecipeCategory<CrusherRecipeWrapp
@Override
public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients){
recipeLayout.getItemStacks().init(0, true, 19, 7);
recipeLayout.getItemStacks().set(0, wrapper.theRecipe.inputStack);
recipeLayout.getItemStacks().set(0, Arrays.asList(wrapper.theRecipe.getInput().getMatchingStacks()));
recipeLayout.getItemStacks().init(1, false, 7, 55);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.outputOneStack);
recipeLayout.getItemStacks().set(1, wrapper.theRecipe.getOutputOne());
if(StackUtil.isValid(wrapper.theRecipe.outputTwoStack)){
if(StackUtil.isValid(wrapper.theRecipe.getOutputTwo())){
recipeLayout.getItemStacks().init(2, false, 31, 55);
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.outputTwoStack);
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.getOutputTwo());
}
}
}

View file

@ -10,6 +10,10 @@
package de.ellpeck.actuallyadditions.mod.jei.crusher;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
@ -21,9 +25,6 @@ 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 CrusherRecipeWrapper extends RecipeWrapperWithButton{
public final CrusherRecipe theRecipe;
@ -34,20 +35,20 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
@Override
public void getIngredients(IIngredients ingredients){
ingredients.setInput(ItemStack.class, this.theRecipe.inputStack);
ingredients.setInputs(ItemStack.class, Arrays.asList(theRecipe.getInput().getMatchingStacks()));
List<ItemStack> list = new ArrayList<ItemStack>();
list.add(this.theRecipe.outputOneStack);
if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
list.add(this.theRecipe.outputTwoStack);
List<ItemStack> list = new ArrayList<>();
list.add(this.theRecipe.getOutputOne());
if(StackUtil.isValid(this.theRecipe.getOutputTwo())){
list.add(this.theRecipe.getOutputTwo());
}
ingredients.setOutputs(ItemStack.class, list);
}
@Override
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
minecraft.fontRenderer.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
if(StackUtil.isValid(this.theRecipe.getOutputTwo())){
minecraft.fontRenderer.drawString(this.theRecipe.getSecondChance()+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
}
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.misc.apiimpl;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
@ -47,9 +50,6 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.util.FakePlayerFactory;
import java.util.ArrayList;
import java.util.List;
public class MethodHandler implements IMethodHandler{
@Override
@ -204,22 +204,22 @@ public class MethodHandler implements IMethodHandler{
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, StackUtil.getStackSize(stack));
int itemsPossible = Math.min(tile.getEnergy()/recipe.energyUse, stack.getCount());
if(itemsPossible > 0){
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
item.setDead();
if(StackUtil.getStackSize(stack)-itemsPossible > 0){
if(stack.getCount()-itemsPossible > 0){
ItemStack stackCopy = stack.copy();
stackCopy = StackUtil.addStackSize(stackCopy, -itemsPossible);
stackCopy.shrink(itemsPossible);
EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
tile.getWorldObject().spawnEntity(inputLeft);
}
ItemStack outputCopy = recipe.outputStack.copy();
outputCopy = StackUtil.setStackSize(outputCopy, itemsPossible);
outputCopy.setCount(itemsPossible);
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
tile.getWorldObject().spawnEntity(newItem);
@ -268,7 +268,7 @@ public class MethodHandler implements IMethodHandler{
for(ItemStack outputOne : outputOnes){
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputOneCopy = outputOne.copy();
outputOneCopy = StackUtil.setStackSize(outputOneCopy, outputOneAmounts);
outputOneCopy.setCount(outputOneAmounts);
if(outputTwos.isEmpty()){
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
@ -278,7 +278,7 @@ public class MethodHandler implements IMethodHandler{
for(ItemStack outputTwo : outputTwos){
if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputTwoCopy = outputTwo.copy();
outputTwoCopy = StackUtil.setStackSize(outputTwoCopy, outputTwoAmounts);
outputTwoCopy.setCount(outputTwoAmounts);
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
hasWorkedOnce = true;
@ -299,7 +299,7 @@ public class MethodHandler implements IMethodHandler{
if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputOneCopy = outputOne.copy();
outputOneCopy = StackUtil.setStackSize(outputOneCopy, outputOneAmount);
outputOneCopy.setCount(outputOneAmount);
if(!StackUtil.isValid(outputTwo)){
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
@ -307,7 +307,7 @@ public class MethodHandler implements IMethodHandler{
}
else if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
ItemStack outputTwoCopy = outputTwo.copy();
outputTwoCopy = StackUtil.setStackSize(outputTwoCopy, outputTwoAmount);
outputTwoCopy.setCount(outputTwoAmount);
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
hasWorkedOnce = true;

View file

@ -65,12 +65,12 @@ public class CactusFarmerBehavior implements IFarmerBehavior{
upState.getBlock().getDrops(drops, world, up, upState, 0);
if(!drops.isEmpty()){
if(farmer.addToOutputInventory(drops, false)){
if(farmer.canAddToOutput(drops)){
world.playEvent(2001, up, Block.getStateId(upState));
world.setBlockToAir(up);
farmer.extractEnergy(use);
farmer.addToOutputInventory(drops, true);
farmer.addToOutput(drops);
result = FarmerResult.SUCCESS;
}

View file

@ -120,16 +120,16 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
}
boolean putSeeds = true;
if(!farmer.addToSeedInventory(seeds, false)){
if(!farmer.canAddToSeeds(seeds)){
other.addAll(seeds);
putSeeds = false;
}
if(farmer.addToOutputInventory(other, false)){
farmer.addToOutputInventory(other, true);
if(farmer.canAddToOutput(other)){
farmer.addToOutput(other);
if(putSeeds){
farmer.addToSeedInventory(seeds, true);
farmer.addToSeeds(seeds);
}
world.playEvent(2001, pos, Block.getStateId(state));

View file

@ -58,12 +58,12 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior{
NonNullList<ItemStack> drops = NonNullList.create();
block.getDrops(drops, world, pos, state, 0);
if(!drops.isEmpty()){
if(farmer.addToOutputInventory(drops, false)){
if(farmer.canAddToOutput(drops)){
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockToAir(pos);
farmer.extractEnergy(use);
farmer.addToOutputInventory(drops, true);
farmer.addToOutput(drops);
return FarmerResult.SUCCESS;
}

View file

@ -53,16 +53,16 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior{
NonNullList<ItemStack> drops = NonNullList.create();
state.getBlock().getDrops(drops, world, pos, state, 0);
if(!drops.isEmpty()){
boolean toInput = farmer.addToSeedInventory(drops, false);
if(toInput || farmer.addToOutputInventory(drops, false)){
boolean toInput = farmer.canAddToSeeds(drops);
if(toInput || farmer.canAddToOutput(drops)){
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockToAir(pos);
if(toInput){
farmer.addToSeedInventory(drops, true);
farmer.addToSeeds(drops);
}
else{
farmer.addToOutputInventory(drops, true);
farmer.addToOutput(drops);
}
farmer.extractEnergy(use);

View file

@ -58,12 +58,12 @@ public class ReedFarmerBehavior implements IFarmerBehavior{
upState.getBlock().getDrops(drops, world, pos, state, 0);
if(!drops.isEmpty()){
if(farmer.addToOutputInventory(drops, false)){
if(farmer.canAddToOutput(drops)){
world.playEvent(2001, up, Block.getStateId(upState));
world.setBlockToAir(up);
farmer.extractEnergy(use);
farmer.addToOutputInventory(drops, true);
farmer.addToOutput(drops);
result = FarmerResult.STOP_PROCESSING; //Success no longer makes it not replant, and the plant logic seems sketchy right after harvesting. This works tho.
}

View file

@ -79,19 +79,19 @@ public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{
if(StackUtil.isValid(stack)){
ResourceLocation itemReg = stack.getItem().getRegistryName();
if(itemReg != null && this.getPlantName().equals(itemReg.toString())){
if(StackUtil.getStackSize(stack) <= 1){
if(stack.getCount() <= 1){
drops.remove(stack);
break;
}
else{
StackUtil.addStackSize(stack, -1);
stack.shrink(1);
}
}
}
}
if(farmer.addToOutputInventory(drops, false)){
farmer.addToOutputInventory(drops, true);
if(farmer.canAddToOutput(drops)){
farmer.addToOutput(drops);
world.playEvent(2001, pos, Block.getStateId(state));
world.setBlockState(pos, block.getDefaultState(), 2);

View file

@ -10,23 +10,23 @@
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.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
import java.util.ArrayList;
import java.util.List;
import net.minecraftforge.oredict.OreIngredient;
public final class CrusherRecipeRegistry{
public static final ArrayList<SearchCase> SEARCH_CASES = new ArrayList<SearchCase>();
public static final ArrayList<SearchCase> SEARCH_CASES = new ArrayList<>();
public static void registerFinally(){
ArrayList<String> oresNoResult = new ArrayList<String>();
@ -37,13 +37,15 @@ public final class CrusherRecipeRegistry{
for(SearchCase theCase : SEARCH_CASES){
if(ore.length() > theCase.theCase.length()){
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
List<ItemStack> outputs = OreDictionary.getOres(output, false);
if(!ActuallyAdditionsAPI.methodHandler.addCrusherRecipes(OreDictionary.getOres(ore, false), outputs.isEmpty() ? StackUtil.getEmpty() : outputs.get(0), theCase.resultAmount, StackUtil.getEmpty(), 0, 0)){
String outputOre = theCase.resultPreString+ore.substring(theCase.theCase.length());
List<ItemStack> outputs = OreDictionary.getOres(outputOre, false);
ItemStack output = outputs.isEmpty() ? ItemStack.EMPTY : outputs.get(0).copy();
output.setCount(theCase.resultAmount);
if(output.isEmpty()){
if(!oresNoResult.contains(ore)){
oresNoResult.add(ore);
}
}
} else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0);
}
}
}
@ -53,11 +55,30 @@ public final class CrusherRecipeRegistry{
ArrayList<String> addedRecipes = new ArrayList<String>();
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
addedRecipes.add(recipe.inputStack+" -> "+recipe.outputOneStack);
addedRecipes.add(recipe.getInput().getMatchingStacks()+" -> "+recipe.getOutputOne());
}
ActuallyAdditions.LOGGER.debug("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes);
ActuallyAdditions.LOGGER.debug("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult);
removeDuplicateRecipes();
}
public static void removeDuplicateRecipes() {
ArrayList<CrusherRecipe> usable = new ArrayList<>();
ArrayList<CrusherRecipe> removed = new ArrayList<>();
for(CrusherRecipe r : ActuallyAdditionsAPI.CRUSHER_RECIPES) {
boolean canUse = true;
for(CrusherRecipe re : usable) {
if(re.getInput().apply(r.getInput().getMatchingStacks()[0])) canUse = false;
}
if(canUse) usable.add(r);
else removed.add(r);
}
ActuallyAdditionsAPI.CRUSHER_RECIPES.clear();
ActuallyAdditionsAPI.CRUSHER_RECIPES.addAll(usable);
ActuallyAdditions.LOGGER.debug(String.format("Removed %s crusher recipes that had dupliate inputs, %s remain.", removed.size(), usable.size()));
}
public static boolean hasBlacklistedOutput(ItemStack output, String[] config){
if(StackUtil.isValid(output)){
@ -100,30 +121,12 @@ public final class CrusherRecipeRegistry{
return false;
}
public static ItemStack getOutputOnes(ItemStack input){
CrusherRecipe recipe = getRecipeFromInput(input);
return recipe == null ? StackUtil.getEmpty() : recipe.outputOneStack;
}
public static CrusherRecipe getRecipeFromInput(ItemStack input){
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES){
if(ItemUtil.areItemsEqual(recipe.inputStack, input, true)){
return recipe;
}
}
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES)
if(recipe.matches(input)) return recipe;
return null;
}
public static ItemStack getOutputTwos(ItemStack input){
CrusherRecipe recipe = getRecipeFromInput(input);
return recipe == null ? StackUtil.getEmpty() : recipe.outputTwoStack;
}
public static int getOutputTwoChance(ItemStack input){
CrusherRecipe recipe = getRecipeFromInput(input);
return recipe == null ? -1 : recipe.outputTwoChance;
}
public static class SearchCase{
final String theCase;

View file

@ -10,17 +10,18 @@
package de.ellpeck.actuallyadditions.mod.tile;
import org.apache.commons.lang3.ArrayUtils;
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.oredict.OreDictionary;
import org.apache.commons.lang3.ArrayUtils;
public class FilterSettings{
@ -29,7 +30,7 @@ public class FilterSettings{
public final int nbtButtonId;
public final int oredictButtonId;
public final int modButtonId;
public final ItemStackHandlerCustom filterInventory;
public final ItemStackHandlerAA filterInventory;
public boolean isWhitelist;
public boolean respectMeta;
public boolean respectNBT;
@ -42,7 +43,7 @@ public class FilterSettings{
private int lastRecpectOredict;
public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, boolean defaultRespectMod, int defaultRespectOredict, int buttonIdStart){
this.filterInventory = new ItemStackHandlerCustom(slots);
this.filterInventory = new ItemStackHandlerAA(slots);
this.isWhitelist = defaultWhitelist;
this.respectMeta = defaultRespectMeta;
@ -57,14 +58,14 @@ public class FilterSettings{
this.modButtonId = buttonIdStart+4;
}
public static boolean check(ItemStack stack, ItemStackHandlerCustom filter, boolean whitelist, boolean meta, boolean nbt, boolean mod, int oredict){
public static boolean check(ItemStack stack, ItemStackHandlerAA filter, boolean whitelist, boolean meta, boolean nbt, boolean mod, int oredict){
if(StackUtil.isValid(stack)){
for(int i = 0; i < filter.getSlots(); i++){
ItemStack slot = filter.getStackInSlot(i);
if(StackUtil.isValid(slot)){
if(SlotFilter.isFilter(slot)){
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT);
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT);
ItemDrill.loadSlotsFromNBT(inv, slot);
for(int k = 0; k < inv.getSlots(); k++){
ItemStack filterSlot = inv.getStackInSlot(k);

View file

@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
@ -30,7 +31,7 @@ import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.energy.IEnergyStorage;
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor{
public class TileEntityAtomicReconstructor extends TileEntityInventoryBase implements IEnergyDisplay, IAtomicReconstructor {
public static final int ENERGY_USE = 1000;
public final CustomEnergyStorage storage;
@ -38,22 +39,22 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
private int currentTime;
private int oldEnergy;
public TileEntityAtomicReconstructor(){
public TileEntityAtomicReconstructor() {
super(1, "reconstructor");
int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue();
int recieve = MathHelper.ceil(power * 0.016666F);
storage = new CustomEnergyStorage(power, recieve, 0);
}
public static void shootLaser(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, Lens currentLens){
public static void shootLaser(World world, double startX, double startY, double startZ, double endX, double endY, double endZ, Lens currentLens) {
world.playSound(null, startX, startY, startZ, SoundHandler.reconstructor, SoundCategory.BLOCKS, 0.35F, 1.0F);
AssetUtil.spawnLaserWithTimeServer(world, startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), 25, 0, 0.2F, 0.8F);
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
public void writeSyncableNBT(NBTTagCompound compound, NBTType type) {
super.writeSyncableNBT(compound, type);
if(type != NBTType.SAVE_BLOCK){
if (type != NBTType.SAVE_BLOCK) {
compound.setInteger("CurrentTime", this.currentTime);
compound.setInteger("Counter", this.counter);
}
@ -61,14 +62,14 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
}
@Override
public boolean shouldSyncSlots(){
public boolean shouldSyncSlots() {
return true;
}
@Override
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
super.readSyncableNBT(compound, type);
if(type != NBTType.SAVE_BLOCK){
if (type != NBTType.SAVE_BLOCK) {
this.currentTime = compound.getInteger("CurrentTime");
this.counter = compound.getInteger("Counter");
}
@ -76,22 +77,21 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
}
@Override
public void updateEntity(){
public void updateEntity() {
super.updateEntity();
if(!this.world.isRemote){
if(!this.isRedstonePowered && !this.isPulseMode){
if(this.currentTime > 0){
if (!this.world.isRemote) {
if (!this.isRedstonePowered && !this.isPulseMode) {
if (this.currentTime > 0) {
this.currentTime--;
if(this.currentTime <= 0){
if (this.currentTime <= 0) {
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
}
}
else{
} else {
this.currentTime = 100;
}
}
if(this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()){
if (this.oldEnergy != this.storage.getEnergyStored() && this.sendUpdateWithInterval()) {
this.oldEnergy = this.storage.getEnergyStored();
this.world.updateComparatorOutputLevel(pos, InitBlocks.blockAtomicReconstructor);
}
@ -100,88 +100,85 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
}
@Override
public Lens getLens(){
if(StackUtil.isValid(this.slots.getStackInSlot(0))){
if(this.slots.getStackInSlot(0).getItem() instanceof ILensItem){
return ((ILensItem)this.slots.getStackInSlot(0).getItem()).getLens();
}
}
public Lens getLens() {
Item item = inv.getStackInSlot(0).getItem();
if (item instanceof ILensItem) return ((ILensItem) item).getLens();
return this.counter >= 500 ? ActuallyAdditionsAPI.lensDisruption : ActuallyAdditionsAPI.lensDefaultConversion;
}
@Override
public EnumFacing getOrientation(){
public EnumFacing getOrientation() {
IBlockState state = this.world.getBlockState(this.pos);
return WorldUtil.getDirectionByPistonRotation(state);
}
@Override
public BlockPos getPosition(){
public BlockPos getPosition() {
return this.pos;
}
@Override
public int getX(){
public int getX() {
return this.getPos().getX();
}
@Override
public int getY(){
public int getY() {
return this.getPos().getY();
}
@Override
public int getZ(){
public int getZ() {
return this.getPos().getZ();
}
@Override
public World getWorldObject(){
public World getWorldObject() {
return this.getWorld();
}
@Override
public void extractEnergy(int amount){
public void extractEnergy(int amount) {
this.storage.extractEnergyInternal(amount, false);
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation) {
return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
return true;
}
@Override
public int getEnergy(){
public int getEnergy() {
return this.storage.getEnergyStored();
}
@Override
public CustomEnergyStorage getEnergyStorage(){
public CustomEnergyStorage getEnergyStorage() {
return this.storage;
}
@Override
public boolean needsHoldShift(){
public boolean needsHoldShift() {
return false;
}
@Override
public boolean isRedstoneToggle(){
public boolean isRedstoneToggle() {
return true;
}
@Override
public void activateOnPulse(){
public void activateOnPulse() {
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
}
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
public IEnergyStorage getEnergyStorage(EnumFacing facing) {
return this.storage;
}
}

View file

@ -10,6 +10,9 @@
package de.ellpeck.actuallyadditions.mod.tile;
import java.util.ArrayList;
import java.util.List;
import de.ellpeck.actuallyadditions.mod.items.ItemBattery;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
@ -19,9 +22,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import java.util.ArrayList;
import java.util.List;
public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{
private int lastEnergyStored;
@ -33,7 +33,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
@Override
public IEnergyStorage getEnergyStorage(EnumFacing facing){
ItemStack stack = this.slots.getStackInSlot(0);
ItemStack stack = this.inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
return stack.getCapability(CapabilityEnergy.ENERGY, null);
@ -51,7 +51,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
IEnergyStorage storage = this.getEnergyStorage(null);
if(storage != null){
ItemStack stack = this.slots.getStackInSlot(0);
ItemStack stack = this.inv.getStackInSlot(0);
if(StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)){
if(storage.getEnergyStored() > 0){
List<TileEntityBatteryBox> tiles = new ArrayList<TileEntityBatteryBox>();
@ -67,7 +67,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
int maxPer = storage.extractEnergy(energyPer, true);
for(TileEntityBatteryBox tile : tiles){
ItemStack battery = tile.slots.getStackInSlot(0);
ItemStack battery = tile.inv.getStackInSlot(0);
if(StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)){
if(tile.hasCapability(CapabilityEnergy.ENERGY, null)){
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null);
@ -119,7 +119,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
@Override
public void activateOnPulse(){
ItemStack stack = this.slots.getStackInSlot(0);
ItemStack stack = this.inv.getStackInSlot(0);
if(StackUtil.isValid(stack)){
ItemUtil.changeEnabled(stack);
this.markDirty();
@ -144,13 +144,13 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
return true;
}
@Override
public boolean isItemValidForSlot(int slot, ItemStack stack){
return StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery;
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
return stack.getItem() instanceof ItemBattery;
}
@Override

View file

@ -66,8 +66,8 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
List<Item> types = null;
if(this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
for(int i = 0; i < this.slots.getSlots(); i++){
ItemStack stack = this.slots.getStackInSlot(i);
for(int i = 0; i < this.inv.getSlots(); i++){
ItemStack stack = this.inv.getStackInSlot(i);
if(StackUtil.isValid(stack)){
Item item = stack.getItem();
if(isValidItem(stack) && (types == null || !types.contains(item))){
@ -76,7 +76,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
}
types.add(item);
this.slots.setStackInSlot(i, StackUtil.addStackSize(stack, -1));
this.inv.setStackInSlot(i, StackUtil.shrink(stack, 1));
}
}
}
@ -129,12 +129,12 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
}
@Override
public boolean canExtractItem(int index, ItemStack stack){
public boolean canExtract(int index, ItemStack stack, boolean byAutomation){
return false;
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
public boolean canInsert(int index, ItemStack stack, boolean fromAutomation){
return isValidItem(stack);
}

View file

@ -69,10 +69,11 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
}
}
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
return true;
public boolean canInsert(int slot, ItemStack stack, boolean automation) {
if(isPlacer) return true;
else return !automation;
}
private void doWork() {
@ -87,26 +88,19 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, world, breakCoords);
if (chance > 0 && world.rand.nextFloat() <= chance) {
if (StackUtil.canAddAll(slots, drops)) {
if (StackUtil.canAddAll(inv, drops, false)) {
world.destroyBlock(breakCoords, false);
StackUtil.addAll(slots, drops);
StackUtil.addAll(inv, drops, false);
this.markDirty();
}
}
} else if (this.isPlacer) {
int theSlot = WorldUtil.findFirstFilledSlot(slots);
this.slots.setStackInSlot(theSlot, WorldUtil.useItemAtSide(side, world, pos, slots.getStackInSlot(theSlot)));
if (!StackUtil.isValid(slots.getStackInSlot(theSlot))) {
this.slots.setStackInSlot(theSlot, StackUtil.getEmpty());
}
int slot = StackUtil.findFirstFilled(inv);
if(slot == -1) return;
this.inv.setStackInSlot(slot, WorldUtil.useItemAtSide(side, world, pos, inv.getStackInSlot(slot)));
}
}
@Override
public boolean canExtractItem(int slot, ItemStack stack) {
return true;
}
@Override
public boolean isRedstoneToggle() {
return true;

View file

@ -84,14 +84,14 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
public void updateEntity(){
super.updateEntity();
if(!this.world.isRemote){
if(this.isCanola(0) && PRODUCE <= this.tank.getCapacity()-this.tank.getFluidAmount()){
if(isCanola(inv.getStackInSlot(0)) && PRODUCE <= this.tank.getCapacity()-this.tank.getFluidAmount()){
if(this.storage.getEnergyStored() >= ENERGY_USE){
this.currentProcessTime++;
this.storage.extractEnergyInternal(ENERGY_USE, false);
if(this.currentProcessTime >= TIME){
this.currentProcessTime = 0;
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -1));
this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1));
this.tank.fillInternal(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), true);
this.markDirty();
@ -111,17 +111,17 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal());
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
return (slot == 0 && isCanola(stack));
}
public boolean isCanola(int slot){
return StackUtil.isValid(this.slots.getStackInSlot(slot)) && this.slots.getStackInSlot(slot).getItem() == InitItems.itemMisc && this.slots.getStackInSlot(slot).getItemDamage() == TheMiscItems.CANOLA.ordinal();
public static boolean isCanola(ItemStack stack){
return stack.getItem() == InitItems.itemMisc && stack.getMetadata() == TheMiscItems.CANOLA.ordinal();
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
return false;
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
return !byAutomation;
}
@Override

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -76,17 +75,16 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
this.storage.receiveEnergyInternal(PRODUCE, false);
}
if(!this.isRedstonePowered && this.currentBurnTime <= 0 && StackUtil.isValid(this.slots.getStackInSlot(0)) && TileEntityFurnace.getItemBurnTime(this.slots.getStackInSlot(0)) > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
int burnTime = TileEntityFurnace.getItemBurnTime(this.slots.getStackInSlot(0));
this.maxBurnTime = burnTime;
this.currentBurnTime = burnTime;
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -1, true));
ItemStack stack = inv.getStackInSlot(0);
int burn = TileEntityFurnace.getItemBurnTime(stack);
if(!this.isRedstonePowered && this.currentBurnTime <= 0 && burn > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
this.maxBurnTime = burn;
this.currentBurnTime = burn;
stack.shrink(1);
}
if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){
this.lastCompare = this.getComparatorStrength();
this.markDirty();
}
@ -105,13 +103,14 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation){
return TileEntityFurnace.getItemBurnTime(stack) > 0;
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
return TileEntityFurnace.getItemBurnTime(this.slots.getStackInSlot(0)) <= 0;
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
if(!byAutomation) return true;
return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0;
}
@Override

View file

@ -125,15 +125,15 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
public boolean canInsert(int i, ItemStack stack, boolean automation){
return (i >= 3 && ItemCoffee.getIngredientFromStack(stack) != null) || (i == SLOT_COFFEE_BEANS && stack.getItem() == InitItems.itemCoffeeBean) || (i == SLOT_INPUT && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CUP.ordinal());
}
public void storeCoffee(){
if(StackUtil.isValid(this.slots.getStackInSlot(SLOT_COFFEE_BEANS)) && this.slots.getStackInSlot(SLOT_COFFEE_BEANS).getItem() == InitItems.itemCoffeeBean){
if(StackUtil.isValid(this.inv.getStackInSlot(SLOT_COFFEE_BEANS)) && this.inv.getStackInSlot(SLOT_COFFEE_BEANS).getItem() == InitItems.itemCoffeeBean){
int toAdd = 2;
if(toAdd <= COFFEE_CACHE_MAX_AMOUNT-this.coffeeCacheAmount){
this.slots.setStackInSlot(SLOT_COFFEE_BEANS, StackUtil.addStackSize(this.slots.getStackInSlot(SLOT_COFFEE_BEANS), -1));
this.inv.setStackInSlot(SLOT_COFFEE_BEANS, StackUtil.shrink(this.inv.getStackInSlot(SLOT_COFFEE_BEANS), 1));
this.coffeeCacheAmount += toAdd;
}
}
@ -141,7 +141,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
public void brew(){
if(!this.world.isRemote){
if(StackUtil.isValid(this.slots.getStackInSlot(SLOT_INPUT)) && this.slots.getStackInSlot(SLOT_INPUT).getItem() == InitItems.itemMisc && this.slots.getStackInSlot(SLOT_INPUT).getItemDamage() == TheMiscItems.CUP.ordinal() && !StackUtil.isValid(this.slots.getStackInSlot(SLOT_OUTPUT)) && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE){
ItemStack input = this.inv.getStackInSlot(SLOT_INPUT);
if (StackUtil.isValid(input) && input.getItem() == InitItems.itemMisc && input.getItemDamage() == TheMiscItems.CUP.ordinal() && !StackUtil.isValid(this.inv.getStackInSlot(SLOT_OUTPUT)) && this.coffeeCacheAmount >= CACHE_USE && this.tank.getFluid() != null && this.tank.getFluid().getFluid() == FluidRegistry.WATER && this.tank.getFluidAmount() >= WATER_USE){
if(this.storage.getEnergyStored() >= ENERGY_USED){
if(this.brewTime%30 == 0){
this.world.playSound(null, this.getPos().getX(), this.getPos().getY(), this.getPos().getZ(), SoundHandler.coffeeMachine, SoundCategory.BLOCKS, 0.35F, 1.0F);
@ -152,18 +153,18 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
if(this.brewTime >= TIME_USED){
this.brewTime = 0;
ItemStack output = new ItemStack(InitItems.itemCoffee);
for(int i = 3; i < this.slots.getSlots(); i++){
if(StackUtil.isValid(this.slots.getStackInSlot(i))){
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.slots.getStackInSlot(i));
for(int i = 3; i < this.inv.getSlots(); i++){
if(StackUtil.isValid(this.inv.getStackInSlot(i))){
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i));
if(ingredient != null){
if(ingredient.effect(output)){
this.slots.setStackInSlot(i, StackUtil.addStackSize(this.slots.getStackInSlot(i), -1, true));
this.inv.setStackInSlot(i, StackUtil.shrinkForContainer(this.inv.getStackInSlot(i), 1));
}
}
}
}
this.slots.setStackInSlot(SLOT_OUTPUT, output.copy());
this.slots.setStackInSlot(SLOT_INPUT, StackUtil.addStackSize(this.slots.getStackInSlot(SLOT_INPUT), -1));
this.inv.setStackInSlot(SLOT_OUTPUT, output.copy());
this.inv.getStackInSlot(SLOT_INPUT).shrink(1);
this.coffeeCacheAmount -= CACHE_USE;
this.tank.drainInternal(WATER_USE, true);
}
@ -176,8 +177,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.slots.getSlots() && ItemCoffee.getIngredientFromStack(stack) == null);
public boolean canExtract(int slot, ItemStack stack, boolean automation){
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(stack) == null);
}
@Override

View file

@ -63,14 +63,15 @@ public class TileEntityCompost extends TileEntityInventoryBase{
super.updateEntity();
if(!this.world.isRemote){
boolean theFlag = this.conversionTime > 0;
if(StackUtil.isValid(this.slots.getStackInSlot(0))){
CompostRecipe recipe = getRecipeForInput(this.slots.getStackInSlot(0));
ItemStack input = inv.getStackInSlot(0);
if(StackUtil.isValid(input)){
CompostRecipe recipe = getRecipeForInput(input);
if(recipe != null){
this.conversionTime++;
if(this.conversionTime >= COMPOST_TIME_TICKS){
ItemStack output = recipe.output.copy();
this.slots.setStackInSlot(0, StackUtil.setStackSize(output, StackUtil.getStackSize(this.slots.getStackInSlot(0))));
output.setCount(input.getCount());
this.inv.setStackInSlot(0, output);
this.conversionTime = 0;
this.markDirty();
}
@ -87,12 +88,12 @@ public class TileEntityCompost extends TileEntityInventoryBase{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
public boolean canInsert(int i, ItemStack stack, boolean automation){
return getRecipeForInput(stack) != null;
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
public boolean canExtract(int slot, ItemStack stack, boolean automation){
return getRecipeForInput(stack) == null;
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
@ -19,8 +20,6 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
@ -89,10 +88,10 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, coordsBlock);
if(chance > 0 && this.world.rand.nextFloat() <= chance){
if(WorldUtil.addToInventory(this.slots, drops, false)){
if(StackUtil.canAddAll(this.inv, drops, false)){
this.world.playEvent(2001, coordsBlock, Block.getStateId(this.world.getBlockState(coordsBlock)));
this.world.setBlockToAir(coordsBlock);
WorldUtil.addToInventory(this.slots, drops, true);
StackUtil.addAll(this.inv, drops, false);
this.storage.extractEnergyInternal(ENERGY_USE, false);
this.markDirty();
}
@ -103,17 +102,16 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return false;
public boolean canInsert(int slot, ItemStack stack, boolean automation){
return !automation;
}
@SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
public boolean canExtract(int slot, ItemStack stack, boolean automation){
return true;
}

View file

@ -15,7 +15,6 @@ 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;
@ -34,12 +33,12 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
super.updateEntity();
if(!this.world.isRemote){
if(StackUtil.isValid(this.slots.getStackInSlot(0)) && !this.isRedstonePowered){
IDisplayStandItem item = this.convertToDisplayStandItem(this.slots.getStackInSlot(0).getItem());
if(StackUtil.isValid(this.inv.getStackInSlot(0)) && !this.isRedstonePowered){
IDisplayStandItem item = this.convertToDisplayStandItem(this.inv.getStackInSlot(0).getItem());
if(item != null){
int energy = item.getUsePerTick(this.slots.getStackInSlot(0), this, this.ticksElapsed);
int energy = item.getUsePerTick(this.inv.getStackInSlot(0), this, this.ticksElapsed);
if(this.storage.getEnergyStored() >= energy){
if(item.update(this.slots.getStackInSlot(0), this, this.ticksElapsed)){
if(item.update(this.inv.getStackInSlot(0), this, this.ticksElapsed)){
this.storage.extractEnergyInternal(energy, false);
}
}
@ -57,11 +56,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
return true;
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return true;
}
@Override
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
super.writeSyncableNBT(compound, type);
@ -87,11 +81,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
return null;
}
@Override
public boolean canExtractItem(int index, ItemStack stack){
return true;
}
@Override
public CustomEnergyStorage getEnergyStorage(){
return this.storage;
@ -103,7 +92,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
}
@Override
public int getMaxStackSizePerSlot(int slot){
public int getMaxStackSize(int slot){
return 1;
}

View file

@ -58,26 +58,24 @@ public class TileEntityDropper extends TileEntityInventoryBase{
}
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return true;
}
private void doWork(){
ItemStack theoreticalRemove = this.removeFromInventory(false);
if(StackUtil.isValid(theoreticalRemove)){
IBlockState state = this.world.getBlockState(this.pos);
WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(state), this.world, this.pos, StackUtil.setStackSize(theoreticalRemove.copy(), 1));
ItemStack drop = theoreticalRemove.copy();
drop.setCount(1);
WorldUtil.dropItemAtSide(WorldUtil.getDirectionByPistonRotation(state), this.world, this.pos, drop);
this.removeFromInventory(true);
}
}
public ItemStack removeFromInventory(boolean actuallyDo){
for(int i = 0; i < this.slots.getSlots(); i++){
if(StackUtil.isValid(this.slots.getStackInSlot(i))){
ItemStack slot = this.slots.getStackInSlot(i).copy();
for(int i = 0; i < this.inv.getSlots(); i++){
if(StackUtil.isValid(this.inv.getStackInSlot(i))){
ItemStack slot = this.inv.getStackInSlot(i).copy();
if(actuallyDo){
this.slots.setStackInSlot(i, StackUtil.addStackSize(this.slots.getStackInSlot(i), -1));
this.inv.setStackInSlot(i, StackUtil.shrink(this.inv.getStackInSlot(i), 1));
this.markDirty();
}
return slot;
@ -86,11 +84,6 @@ public class TileEntityDropper extends TileEntityInventoryBase{
return StackUtil.getEmpty();
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
return true;
}
@Override
public boolean isRedstoneToggle(){
return true;

View file

@ -53,7 +53,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
super.updateEntity();
if(!this.world.isRemote){
List<EmpowererRecipe> recipes = getRecipesForInput(this.slots.getStackInSlot(0));
List<EmpowererRecipe> recipes = getRecipesForInput(this.inv.getStackInSlot(0));
if(!recipes.isEmpty()){
for(EmpowererRecipe recipe : recipes){
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
@ -67,7 +67,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
stand.storage.extractEnergyInternal(recipe.energyPerStand/recipe.time, false);
if(done){
stand.slots.decrStackSize(0, 1);
stand.inv.getStackInSlot(0).shrink(1);
}
}
@ -78,7 +78,7 @@ 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.slots.setStackInSlot(0, recipe.output.copy());
this.inv.setStackInSlot(0, recipe.output.copy());
this.markDirty();
this.processTime = 0;
@ -112,7 +112,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
if(tile instanceof TileEntityDisplayStand){
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
ItemStack standItem = stand.slots.getStackInSlot(0);
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;
@ -158,17 +158,17 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
}
@Override
public boolean isItemValidForSlot(int index, ItemStack stack){
return !getRecipesForInput(stack).isEmpty();
public boolean canInsert(int index, ItemStack stack, boolean automation){
return !automation || !getRecipesForInput(stack).isEmpty();
}
@Override
public boolean canExtractItem(int index, ItemStack stack){
return getRecipesForInput(stack).isEmpty();
public boolean canExtract(int index, ItemStack stack, boolean automation){
return !automation || getRecipesForInput(stack).isEmpty();
}
@Override
public int getMaxStackSizePerSlot(int slot){
public int getMaxStackSize(int slot){
return 1;
}
}

View file

@ -11,13 +11,12 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public class TileEntityEnergizer extends TileEntityInventoryBase{
@ -44,13 +43,13 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
public void updateEntity(){
super.updateEntity();
if(!this.world.isRemote){
if(StackUtil.isValid(this.slots.getStackInSlot(0)) && !StackUtil.isValid(this.slots.getStackInSlot(1))){
if(StackUtil.isValid(this.inv.getStackInSlot(0)) && !StackUtil.isValid(this.inv.getStackInSlot(1))){
if(this.storage.getEnergyStored() > 0){
int received = 0;
boolean canTakeUp = false;
if(this.slots.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)){
IEnergyStorage cap = this.slots.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null);
if(this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)){
IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null);
if(cap != null){
received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored();
@ -61,8 +60,8 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
}
if(canTakeUp){
this.slots.setStackInSlot(1, this.slots.getStackInSlot(0).copy());
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -1));
this.inv.setStackInSlot(1, this.inv.getStackInSlot(0).copy());
this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1));
}
}
}
@ -74,16 +73,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null));
public boolean canInsert(int i, ItemStack stack, boolean automation){
return !automation || (i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
}
@Override
public boolean canExtractItem(int slot, ItemStack stack){
return slot == 1;
public boolean canExtract(int slot, ItemStack stack, boolean automation){
return !EnchantmentHelper.hasBindingCurse(stack) && !automation || (slot == 1);
}
@SideOnly(Side.CLIENT)
public int getEnergyScaled(int i){
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
}

Some files were not shown because too many files have changed in this diff Show more