mirror of
https://github.com/Ellpeck/ActuallyAdditions.git
synced 2024-11-26 08:48:34 +01:00
We're just gonna hope nothing is on fire.
This commit is contained in:
parent
a571c70457
commit
ac2bc0124a
121 changed files with 1582 additions and 1627 deletions
|
@ -10,6 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.api;
|
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.IBookletChapter;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
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.laser.ILaserRelayConnectionHandler;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.LensConversion;
|
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.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.item.crafting.Ingredient;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public final class ActuallyAdditionsAPI{
|
public final class ActuallyAdditionsAPI{
|
||||||
|
|
||||||
public static final String MOD_ID = "actuallyadditions";
|
public static final String MOD_ID = "actuallyadditions";
|
||||||
public static final String API_ID = MOD_ID+"api";
|
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<CrusherRecipe> CRUSHER_RECIPES = new ArrayList<>();
|
||||||
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<BallOfFurReturn>();
|
public static final List<BallOfFurReturn> BALL_OF_FUR_RETURN_ITEMS = new ArrayList<>();
|
||||||
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<TreasureChestLoot>();
|
public static final List<TreasureChestLoot> TREASURE_CHEST_LOOT = new ArrayList<>();
|
||||||
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<LensConversionRecipe>();
|
public static final List<LensConversionRecipe> RECONSTRUCTOR_LENS_CONVERSION_RECIPES = new ArrayList<>();
|
||||||
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<EmpowererRecipe>();
|
public static final List<EmpowererRecipe> EMPOWERER_RECIPES = new ArrayList<>();
|
||||||
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<Item, IColorLensChanger>();
|
public static final Map<Item, IColorLensChanger> RECONSTRUCTOR_LENS_COLOR_CHANGERS = new HashMap<>();
|
||||||
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<IFarmerBehavior>();
|
public static final List<IFarmerBehavior> FARMER_BEHAVIORS = new ArrayList<>();
|
||||||
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<CoffeeIngredient>();
|
public static final List<CoffeeIngredient> COFFEE_MACHINE_INGREDIENTS = new ArrayList<>();
|
||||||
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<CompostRecipe>();
|
public static final List<CompostRecipe> COMPOST_RECIPES = new ArrayList<>();
|
||||||
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<OilGenRecipe>();
|
public static final List<OilGenRecipe> OIL_GENERATOR_RECIPES = new ArrayList<>();
|
||||||
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<IBookletEntry>();
|
public static final List<IBookletEntry> BOOKLET_ENTRIES = new ArrayList<>();
|
||||||
//This is added to automatically, you don't need to add anything to this list
|
//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
|
//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<IBookletPage> BOOKLET_PAGES_WITH_ITEM_OR_FLUID_DATA = new ArrayList<>();
|
||||||
public static final List<WeightedOre> STONE_ORES = new ArrayList<WeightedOre>();
|
public static final List<WeightedOre> STONE_ORES = new ArrayList<>();
|
||||||
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<WeightedOre>();
|
public static final List<WeightedOre> NETHERRACK_ORES = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use this to handle things that aren't based in the API itself
|
* 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)
|
* @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){
|
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));
|
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.
|
//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){
|
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);
|
return methodHandler.addCrusherRecipes(inputs, outputOne, outputOneAmount, outputTwo, outputTwoAmount, outputTwoChance);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,11 @@ public interface IFarmer extends IEnergyTile{
|
||||||
|
|
||||||
EnumFacing getOrientation();
|
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.api.internal;
|
package de.ellpeck.actuallyadditions.api.internal;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
|
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.ResourceLocation;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the internal method handler.
|
* This is the internal method handler.
|
||||||
* Use ActuallyAdditionsAPI.methodHandler for calling
|
* Use ActuallyAdditionsAPI.methodHandler for calling
|
||||||
|
@ -43,9 +43,9 @@ public interface IMethodHandler{
|
||||||
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
|
boolean invokeConversionLens(IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile);
|
||||||
|
|
||||||
boolean invokeReconstructor(IAtomicReconstructor tile);
|
boolean invokeReconstructor(IAtomicReconstructor tile);
|
||||||
|
|
||||||
boolean addCrusherRecipes(List<ItemStack> inputs, List<ItemStack> outputOnes, int outputOneAmounts, List<ItemStack> outputTwos, int outputTwoAmounts, int outputTwoChance);
|
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);
|
boolean addCrusherRecipes(List<ItemStack> inputs, ItemStack outputOne, int outputOneAmount, ItemStack outputTwo, int outputTwoAmount, int outputTwoChance);
|
||||||
|
|
||||||
IBookletPage generateTextPage(int id);
|
IBookletPage generateTextPage(int id);
|
||||||
|
|
|
@ -11,20 +11,49 @@
|
||||||
package de.ellpeck.actuallyadditions.api.recipe;
|
package de.ellpeck.actuallyadditions.api.recipe;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
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 outputOneStack;
|
||||||
public ItemStack outputTwoStack;
|
|
||||||
public int outputTwoChance;
|
|
||||||
|
|
||||||
public CrusherRecipe(ItemStack inputStack, ItemStack outputOneStack, ItemStack outputTwoStack, int outputTwoChance){
|
private Ingredient input;
|
||||||
this.inputStack = inputStack;
|
private ItemStack outputOne;
|
||||||
this.outputOneStack = outputOneStack;
|
private ItemStack outputTwo;
|
||||||
this.outputTwoStack = outputTwoStack;
|
private int outputChance;
|
||||||
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ import de.ellpeck.actuallyadditions.mod.recipe.TreasureChestHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
import de.ellpeck.actuallyadditions.mod.update.UpdateChecker;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
|
import de.ellpeck.actuallyadditions.mod.util.compat.CompatUtil;
|
||||||
|
import net.minecraft.launchwrapper.Launch;
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
@ -64,6 +65,7 @@ public class ActuallyAdditions {
|
||||||
public static final String VERSION = "@VERSION@";
|
public static final String VERSION = "@VERSION@";
|
||||||
public static final String GUIFACTORY = "de.ellpeck.actuallyadditions.mod.config.GuiFactory";
|
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 String DEPS = "before:craftingtweaks;after:fastbench@[1.3.2,)";
|
||||||
|
public static final boolean DEOBF = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||||
|
|
||||||
@Instance
|
@Instance
|
||||||
public static ActuallyAdditions INSTANCE;
|
public static ActuallyAdditions INSTANCE;
|
||||||
|
|
|
@ -78,10 +78,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
|
||||||
if(reconstructor != null){
|
if(reconstructor != null){
|
||||||
if(StackUtil.isValid(heldItem)){
|
if(StackUtil.isValid(heldItem)){
|
||||||
Item item = heldItem.getItem();
|
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();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut = StackUtil.setStackSize(toPut, 1);
|
toPut.setCount(1);
|
||||||
reconstructor.slots.setStackInSlot(0, toPut);
|
reconstructor.inv.setStackInSlot(0, toPut);
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
player.inventory.decrStackSize(player.inventory.currentItem, 1);
|
||||||
}
|
}
|
||||||
//Shush, don't tell anyone!
|
//Shush, don't tell anyone!
|
||||||
|
@ -91,10 +91,10 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ItemStack slot = reconstructor.slots.getStackInSlot(0);
|
ItemStack slot = reconstructor.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(slot)){
|
if(StackUtil.isValid(slot)){
|
||||||
player.setHeldItem(hand, slot.copy());
|
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){
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
||||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||||
if(tile instanceof TileEntityAtomicReconstructor){
|
if(tile instanceof TileEntityAtomicReconstructor){
|
||||||
ItemStack slot = ((TileEntityAtomicReconstructor)tile).slots.getStackInSlot(0);
|
ItemStack slot = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0);
|
||||||
String strg;
|
String strg;
|
||||||
if(!StackUtil.isValid(slot)){
|
if(!StackUtil.isValid(slot)){
|
||||||
strg = StringUtil.localize("info."+ActuallyAdditions.MODID+".noLens");
|
strg = StringUtil.localize("info."+ActuallyAdditions.MODID+".noLens");
|
||||||
|
|
|
@ -56,17 +56,17 @@ public class BlockBatteryBox extends BlockContainerBase{
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
|
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.slots.getStackInSlot(0))){
|
if(stack.getItem() instanceof ItemBattery && !StackUtil.isValid(box.inv.getStackInSlot(0))){
|
||||||
box.slots.setStackInSlot(0, stack.copy());
|
box.inv.setStackInSlot(0, stack.copy());
|
||||||
player.setHeldItem(hand, StackUtil.getEmpty());
|
player.setHeldItem(hand, StackUtil.getEmpty());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ItemStack inSlot = box.slots.getStackInSlot(0);
|
ItemStack inSlot = box.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(inSlot)){
|
if(StackUtil.isValid(inSlot)){
|
||||||
player.setHeldItem(hand, inSlot.copy());
|
player.setHeldItem(hand, inSlot.copy());
|
||||||
box.slots.setStackInSlot(0, StackUtil.getEmpty());
|
box.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,27 +88,27 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityCompost){
|
if(tile instanceof TileEntityCompost){
|
||||||
TileEntityCompost compost = (TileEntityCompost)tile;
|
TileEntityCompost compost = (TileEntityCompost)tile;
|
||||||
ItemStack slot = compost.slots.getStackInSlot(0);
|
ItemStack slot = compost.inv.getStackInSlot(0);
|
||||||
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
|
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
|
||||||
if(!StackUtil.isValid(slot) || recipeIn != null){
|
if(!StackUtil.isValid(slot) || recipeIn != null){
|
||||||
if(StackUtil.isValid(stackPlayer)){
|
if(StackUtil.isValid(stackPlayer)){
|
||||||
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
|
CompostRecipe recipeHand = TileEntityCompost.getRecipeForInput(stackPlayer);
|
||||||
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
|
if(recipeHand != null && (recipeIn == null || recipeIn == recipeHand)){
|
||||||
int maxAdd = StackUtil.getStackSize(stackPlayer);
|
int maxAdd = stackPlayer.getCount();
|
||||||
|
|
||||||
if(!StackUtil.isValid(slot)){
|
if(!StackUtil.isValid(slot)){
|
||||||
ItemStack stackToAdd = stackPlayer.copy();
|
ItemStack stackToAdd = stackPlayer.copy();
|
||||||
stackToAdd = StackUtil.setStackSize(stackToAdd, maxAdd);
|
stackToAdd.setCount(maxAdd);
|
||||||
compost.slots.setStackInSlot(0, stackToAdd);
|
compost.inv.setStackInSlot(0, stackToAdd);
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
|
player.inventory.decrStackSize(player.inventory.currentItem, maxAdd);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
ItemStack stackIn = slot.copy();
|
ItemStack stackIn = slot.copy();
|
||||||
if(StackUtil.getStackSize(stackIn) < recipeHand.input.getMaxStackSize()){
|
if(stackIn.getCount() < recipeHand.input.getMaxStackSize()){
|
||||||
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-StackUtil.getStackSize(stackIn));
|
int sizeAdded = Math.min(maxAdd, recipeHand.input.getMaxStackSize()-stackIn.getCount());
|
||||||
stackIn = StackUtil.addStackSize(stackIn, sizeAdded);
|
stackIn.grow(sizeAdded);
|
||||||
compost.slots.setStackInSlot(0, stackIn);
|
compost.inv.setStackInSlot(0, stackIn);
|
||||||
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
|
player.inventory.decrStackSize(player.inventory.currentItem, sizeAdded);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -119,15 +119,15 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
|
||||||
else{
|
else{
|
||||||
if(!StackUtil.isValid(stackPlayer)){
|
if(!StackUtil.isValid(stackPlayer)){
|
||||||
player.setHeldItem(hand, slot.copy());
|
player.setHeldItem(hand, slot.copy());
|
||||||
compost.slots.setStackInSlot(0, StackUtil.getEmpty());
|
compost.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(ItemUtil.canBeStacked(stackPlayer, slot)){
|
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();
|
ItemStack stackToAdd = stackPlayer.copy();
|
||||||
stackToAdd = StackUtil.addStackSize(stackToAdd, addedStackSize);
|
stackToAdd.grow(addedStackSize);
|
||||||
player.setHeldItem(hand, stackToAdd);
|
player.setHeldItem(hand, stackToAdd);
|
||||||
compost.slots.decrStackSize(0, addedStackSize);
|
compost.inv.getStackInSlot(0).shrink(addedStackSize);
|
||||||
return true;
|
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){
|
public void displayHud(Minecraft minecraft, EntityPlayer player, ItemStack stack, RayTraceResult posHit, ScaledResolution resolution){
|
||||||
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
TileEntity tile = minecraft.world.getTileEntity(posHit.getBlockPos());
|
||||||
if(tile instanceof TileEntityCompost){
|
if(tile instanceof TileEntityCompost){
|
||||||
ItemStack slot = ((TileEntityCompost)tile).slots.getStackInSlot(0);
|
ItemStack slot = ((TileEntityCompost)tile).inv.getStackInSlot(0);
|
||||||
String strg;
|
String strg;
|
||||||
if(!StackUtil.isValid(slot)){
|
if(!StackUtil.isValid(slot)){
|
||||||
strg = "Empty";
|
strg = "Empty";
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
strg = slot.getItem().getItemStackDisplayName(slot);
|
strg = slot.getDisplayName();
|
||||||
|
|
||||||
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
|
AssetUtil.renderStackToGui(slot, resolution.getScaledWidth()/2+15, resolution.getScaledHeight()/2-29, 1F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,9 +29,9 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
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);
|
super(Material.ROCK, name);
|
||||||
|
|
||||||
this.setHarvestLevel("pickaxe", 0);
|
this.setHarvestLevel("pickaxe", 0);
|
||||||
|
@ -41,74 +41,71 @@ public class BlockDisplayStand extends BlockContainerBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World worldIn, int meta){
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||||
return new TileEntityDisplayStand();
|
return new TileEntityDisplayStand();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
|
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||||
return BlockSlabs.AABB_BOTTOM_HALF;
|
return BlockSlabs.AABB_BOTTOM_HALF;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
ItemStack heldItem = player.getHeldItem(hand);
|
||||||
if(!world.isRemote){
|
if (!world.isRemote) {
|
||||||
TileEntityDisplayStand stand = (TileEntityDisplayStand)world.getTileEntity(pos);
|
TileEntityDisplayStand stand = (TileEntityDisplayStand) world.getTileEntity(pos);
|
||||||
if(stand != null){
|
if (stand != null) {
|
||||||
ItemStack display = stand.slots.getStackInSlot(0);
|
ItemStack display = stand.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(heldItem)){
|
if (StackUtil.isValid(heldItem)) {
|
||||||
if(!StackUtil.isValid(display)){
|
if (!StackUtil.isValid(display)) {
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut = StackUtil.setStackSize(toPut, 1);
|
toPut.setCount(1);
|
||||||
stand.slots.setStackInSlot(0, toPut);
|
stand.inv.setStackInSlot(0, toPut);
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, -1));
|
if(!player.capabilities.isCreativeMode) heldItem.shrink(1);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else if (ItemUtil.canBeStacked(heldItem, display)) {
|
||||||
else if(ItemUtil.canBeStacked(heldItem, display)){
|
int maxTransfer = Math.min(display.getCount(), heldItem.getMaxStackSize() - heldItem.getCount());
|
||||||
int maxTransfer = Math.min(StackUtil.getStackSize(display), heldItem.getMaxStackSize()-StackUtil.getStackSize(heldItem));
|
if (maxTransfer > 0) {
|
||||||
if(maxTransfer > 0){
|
heldItem.grow(maxTransfer);
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, maxTransfer));
|
|
||||||
ItemStack newDisplay = display.copy();
|
ItemStack newDisplay = display.copy();
|
||||||
newDisplay = StackUtil.addStackSize(newDisplay, -maxTransfer);
|
newDisplay.shrink(maxTransfer);
|
||||||
stand.slots.setStackInSlot(0, StackUtil.validateCheck(newDisplay));
|
stand.inv.setStackInSlot(0, newDisplay);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
if (StackUtil.isValid(display)) {
|
||||||
if(StackUtil.isValid(display)){
|
|
||||||
player.setHeldItem(hand, display.copy());
|
player.setHeldItem(hand, display.copy());
|
||||||
stand.slots.setStackInSlot(0, StackUtil.getEmpty());
|
stand.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOpaqueCube(IBlockState state){
|
public boolean isOpaqueCube(IBlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isFullCube(IBlockState state){
|
public boolean isFullCube(IBlockState state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face) {
|
||||||
if(face == EnumFacing.DOWN) return BlockFaceShape.SOLID;
|
if (face == EnumFacing.DOWN) return BlockFaceShape.SOLID;
|
||||||
return BlockFaceShape.UNDEFINED;
|
return BlockFaceShape.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack){
|
public EnumRarity getRarity(ItemStack stack) {
|
||||||
return EnumRarity.RARE;
|
return EnumRarity.RARE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,22 +55,22 @@ public class BlockEmpowerer extends BlockContainerBase{
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
TileEntityEmpowerer empowerer = (TileEntityEmpowerer)world.getTileEntity(pos);
|
TileEntityEmpowerer empowerer = (TileEntityEmpowerer)world.getTileEntity(pos);
|
||||||
if(empowerer != null){
|
if(empowerer != null){
|
||||||
ItemStack stackThere = empowerer.slots.getStackInSlot(0);
|
ItemStack stackThere = empowerer.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(heldItem)){
|
if(StackUtil.isValid(heldItem)){
|
||||||
if(!StackUtil.isValid(stackThere) && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
|
if(!StackUtil.isValid(stackThere) && !TileEntityEmpowerer.getRecipesForInput(heldItem).isEmpty()){
|
||||||
ItemStack toPut = heldItem.copy();
|
ItemStack toPut = heldItem.copy();
|
||||||
toPut = StackUtil.setStackSize(toPut, 1);
|
toPut.grow(1);
|
||||||
empowerer.slots.setStackInSlot(0, toPut);
|
empowerer.inv.setStackInSlot(0, toPut);
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, -1));
|
player.setHeldItem(hand, StackUtil.shrink(heldItem, 1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(ItemUtil.canBeStacked(heldItem, stackThere)){
|
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){
|
if(maxTransfer > 0){
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(heldItem, maxTransfer));
|
player.setHeldItem(hand, StackUtil.grow(heldItem, maxTransfer));
|
||||||
ItemStack newStackThere = stackThere.copy();
|
ItemStack newStackThere = stackThere.copy();
|
||||||
newStackThere = StackUtil.addStackSize(newStackThere, -maxTransfer);
|
newStackThere = StackUtil.shrink(newStackThere, maxTransfer);
|
||||||
empowerer.slots.setStackInSlot(0, StackUtil.validateCheck(newStackThere));
|
empowerer.inv.setStackInSlot(0, newStackThere);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class BlockEmpowerer extends BlockContainerBase{
|
||||||
else{
|
else{
|
||||||
if(StackUtil.isValid(stackThere)){
|
if(StackUtil.isValid(stackThere)){
|
||||||
player.setHeldItem(hand, stackThere.copy());
|
player.setHeldItem(hand, stackThere.copy());
|
||||||
empowerer.slots.setStackInSlot(0, StackUtil.getEmpty());
|
empowerer.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
|
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.TileEntityGiantChest;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestLarge;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityGiantChestMedium;
|
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.Block;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
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.util.text.TextFormatting;
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class BlockGiantChest extends BlockContainerBase{
|
public class BlockGiantChest extends BlockContainerBase{
|
||||||
|
|
||||||
|
@ -102,12 +106,12 @@ public class BlockGiantChest extends BlockContainerBase{
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityGiantChest){
|
if(tile instanceof TileEntityGiantChest){
|
||||||
NBTTagList list = stack.getTagCompound().getTagList("Items", 10);
|
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++){
|
for(int i = 0; i < list.tagCount(); i++){
|
||||||
NBTTagCompound compound = list.getCompoundTagAt(i);
|
NBTTagCompound compound = list.getCompoundTagAt(i);
|
||||||
if(compound != null && compound.hasKey("id")){
|
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);
|
super.getDrops(drops, world, pos, state, fortune);
|
||||||
TileEntity tile = world.getTileEntity(pos);
|
TileEntity tile = world.getTileEntity(pos);
|
||||||
if(tile instanceof TileEntityGiantChest){
|
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);
|
int place = ItemUtil.getPlaceAt(slots.getItems(), new ItemStack(InitItems.itemCrateKeeper), false);
|
||||||
if(place >= 0){
|
if(place >= 0){
|
||||||
NBTTagList list = new NBTTagList();
|
NBTTagList list = new NBTTagList();
|
||||||
|
@ -153,7 +157,7 @@ public class BlockGiantChest extends BlockContainerBase{
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldDropInventory(World world, BlockPos pos) {
|
public boolean shouldDropInventory(World world, BlockPos pos) {
|
||||||
TileEntity tile = world.getTileEntity(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
|
@Override
|
||||||
|
|
|
@ -186,15 +186,16 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if(stack.getItem() instanceof ItemLaserRelayUpgrade){
|
else if(stack.getItem() instanceof ItemLaserRelayUpgrade){
|
||||||
ItemStack inRelay = relay.slots.getStackInSlot(0);
|
ItemStack inRelay = relay.inv.getStackInSlot(0);
|
||||||
if(!StackUtil.isValid(inRelay)){
|
if(!StackUtil.isValid(inRelay)){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
if(!player.isCreative()){
|
if(!player.isCreative()){
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack set = StackUtil.validateCopy(stack);
|
ItemStack set = stack.copy();
|
||||||
relay.slots.setStackInSlot(0, StackUtil.setStackSize(set, 1));
|
set.setCount(1);
|
||||||
|
relay.inv.setStackInSlot(0, set);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -203,10 +204,10 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.isSneaking()){
|
if(player.isSneaking()){
|
||||||
ItemStack inRelay = StackUtil.validateCopy(relay.slots.getStackInSlot(0));
|
ItemStack inRelay = relay.inv.getStackInSlot(0).copy();
|
||||||
if(StackUtil.isValid(inRelay)){
|
if(StackUtil.isValid(inRelay)){
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
relay.slots.setStackInSlot(0, StackUtil.getEmpty());
|
relay.inv.setStackInSlot(0, StackUtil.getEmpty());
|
||||||
|
|
||||||
if(!player.inventory.addItemStackToInventory(inRelay)){
|
if(!player.inventory.addItemStackToInventory(inRelay)){
|
||||||
player.entityDropItem(inRelay, 0);
|
player.entityDropItem(inRelay, 0);
|
||||||
|
|
|
@ -51,25 +51,6 @@ public class BlockSlabs extends BlockBase{
|
||||||
this.fullBlockState = fullBlockState;
|
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
|
@Override
|
||||||
public boolean isOpaqueCube(IBlockState state){
|
public boolean isOpaqueCube(IBlockState state){
|
||||||
return false;
|
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)){
|
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);
|
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);
|
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;
|
return EnumActionResult.SUCCESS;
|
||||||
|
@ -184,7 +165,7 @@ public class BlockSlabs extends BlockBase{
|
||||||
SoundType soundtype = theBlock.fullBlockState.getBlock().getSoundType(theBlock.fullBlockState, world, pos, player);
|
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);
|
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;
|
return true;
|
||||||
|
|
|
@ -10,10 +10,11 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.blocks;
|
package de.ellpeck.actuallyadditions.mod.blocks;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
import de.ellpeck.actuallyadditions.api.recipe.TreasureChestLoot;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.block.BlockHorizontal;
|
import net.minecraft.block.BlockHorizontal;
|
||||||
import net.minecraft.block.SoundType;
|
import net.minecraft.block.SoundType;
|
||||||
import net.minecraft.block.material.Material;
|
import net.minecraft.block.material.Material;
|
||||||
|
@ -27,15 +28,19 @@ import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
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.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BlockTreasureChest extends BlockBase{
|
public class BlockTreasureChest extends BlockBase{
|
||||||
|
|
||||||
public BlockTreasureChest(String name){
|
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++){
|
for(int i = 0; i < MathHelper.getInt(world.rand, 3, 6); i++){
|
||||||
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
|
TreasureChestLoot theReturn = WeightedRandom.getRandomItem(world.rand, ActuallyAdditionsAPI.TREASURE_CHEST_LOOT);
|
||||||
ItemStack itemStack = theReturn.returnItem.copy();
|
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 dX = world.rand.nextFloat()*0.8F+0.1F;
|
||||||
float dY = world.rand.nextFloat()*0.8F+0.1F;
|
float dY = world.rand.nextFloat()*0.8F+0.1F;
|
||||||
|
|
|
@ -88,8 +88,8 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
|
||||||
TileEntity aTile = world.getTileEntity(position);
|
TileEntity aTile = world.getTileEntity(position);
|
||||||
if(aTile instanceof TileEntityInventoryBase){
|
if(aTile instanceof TileEntityInventoryBase){
|
||||||
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
TileEntityInventoryBase tile = (TileEntityInventoryBase)aTile;
|
||||||
if(tile.slots.getSlots() > 0){
|
if(tile.inv.getSlots() > 0){
|
||||||
for(int i = 0; i < tile.slots.getSlots(); i++){
|
for(int i = 0; i < tile.inv.getSlots(); i++){
|
||||||
this.dropSlotFromInventory(i, tile, world, position);
|
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){
|
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)){
|
if(StackUtil.isValid(stack)){
|
||||||
float dX = world.rand.nextFloat()*0.8F+0.1F;
|
float dX = world.rand.nextFloat()*0.8F+0.1F;
|
||||||
float dY = world.rand.nextFloat()*0.8F+0.1F;
|
float dY = world.rand.nextFloat()*0.8F+0.1F;
|
||||||
|
|
|
@ -99,7 +99,7 @@ public class BlockPlant extends BlockCrops implements ItemBlockBase.ICustomRarit
|
||||||
for(ItemStack drop : drops){
|
for(ItemStack drop : drops){
|
||||||
if(StackUtil.isValid(drop)){
|
if(StackUtil.isValid(drop)){
|
||||||
if(drop.getItem() == this.seedItem && !deductedSeedSize){
|
if(drop.getItem() == this.seedItem && !deductedSeedSize){
|
||||||
StackUtil.addStackSize(drop, -1);
|
drop.shrink(1);
|
||||||
deductedSeedSize = true;
|
deductedSeedSize = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class RenderBatteryBox extends TileEntitySpecialRenderer<TileEntityBatter
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ((TileEntityBatteryBox)tile).slots.getStackInSlot(0);
|
ItemStack stack = ((TileEntityBatteryBox)tile).inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
|
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class RenderCompost extends TileEntitySpecialRenderer<TileEntityCompost>{
|
||||||
@Override
|
@Override
|
||||||
public void render(TileEntityCompost compost, double x, double y, double z, float partialTicks, int destroyStage, float f){
|
public void render(TileEntityCompost compost, double x, double y, double z, float partialTicks, int destroyStage, float f){
|
||||||
if(compost instanceof TileEntityCompost){
|
if(compost instanceof TileEntityCompost){
|
||||||
ItemStack slot = compost.slots.getStackInSlot(0);
|
ItemStack slot = compost.inv.getStackInSlot(0);
|
||||||
|
|
||||||
if(StackUtil.isValid(slot)){
|
if(StackUtil.isValid(slot)){
|
||||||
Block display = null;
|
Block display = null;
|
||||||
|
@ -47,7 +47,7 @@ public class RenderCompost extends TileEntitySpecialRenderer<TileEntityCompost>{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(display != null){
|
if(display != null){
|
||||||
float i = (float)StackUtil.getStackSize(slot)/(float)maxAmount;
|
float i = (float)slot.getCount()/(float)maxAmount;
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
|
GlStateManager.translate((float)x+0.5F, (float)y+(i/3F)+0.01F, (float)z+0.5F);
|
||||||
//Hehe
|
//Hehe
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class RenderDisplayStand extends TileEntitySpecialRenderer<TileEntityDisp
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ((TileEntityDisplayStand)tile).slots.getStackInSlot(0);
|
ItemStack stack = ((TileEntityDisplayStand)tile).inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer<TileEntityEmpower
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack stack = ((TileEntityEmpowerer)tile).slots.getStackInSlot(0);
|
ItemStack stack = ((TileEntityEmpowerer)tile).inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
GlStateManager.translate((float)x+0.5F, (float)y+1F, (float)z+0.5F);
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
|
||||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||||
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
boolean hasGoggles = ItemEngineerGoggles.isWearing(player);
|
||||||
|
|
||||||
ItemStack upgrade = relay.slots.getStackInSlot(0);
|
ItemStack upgrade = relay.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(upgrade)){
|
if(StackUtil.isValid(upgrade)){
|
||||||
if(upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility){
|
if(upgrade.getItem() == InitItems.itemLaserUpgradeInvisibility){
|
||||||
hasInvis = true;
|
hasInvis = true;
|
||||||
|
@ -81,7 +81,7 @@ public class RenderLaserRelay extends TileEntitySpecialRenderer<TileEntityLaserR
|
||||||
|
|
||||||
TileEntity secondTile = tile.getWorld().getTileEntity(second);
|
TileEntity secondTile = tile.getWorld().getTileEntity(second);
|
||||||
if(secondTile instanceof TileEntityLaserRelay){
|
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;
|
boolean otherInvis = StackUtil.isValid(secondUpgrade) && secondUpgrade.getItem() == InitItems.itemLaserUpgradeInvisibility;
|
||||||
|
|
||||||
if(hasGoggles || !hasInvis || !otherInvis){
|
if(hasGoggles || !hasInvis || !otherInvis){
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer<TileEntit
|
||||||
if(!(tile instanceof TileEntityAtomicReconstructor)){
|
if(!(tile instanceof TileEntityAtomicReconstructor)){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = ((TileEntityAtomicReconstructor)tile).slots.getStackInSlot(0);
|
ItemStack stack = ((TileEntityAtomicReconstructor)tile).inv.getStackInSlot(0);
|
||||||
|
|
||||||
if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
|
if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
|
||||||
GlStateManager.pushMatrix();
|
GlStateManager.pushMatrix();
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class PageCrafting extends BookletPage{
|
||||||
ItemStack stack = stacks[0];
|
ItemStack stack = stacks[0];
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
ItemStack copy = stack.copy();
|
ItemStack copy = stack.copy();
|
||||||
copy = StackUtil.setStackSize(copy, 1);
|
copy.setCount(1);
|
||||||
if(copy.getItemDamage() == Util.WILDCARD){
|
if(copy.getItemDamage() == Util.WILDCARD){
|
||||||
copy.setItemDamage(0);
|
copy.setItemDamage(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
package de.ellpeck.actuallyadditions.mod.booklet.page;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PageCrusherRecipe extends BookletPage{
|
public class PageCrusherRecipe extends BookletPage{
|
||||||
|
|
||||||
private final CrusherRecipe recipe;
|
private final CrusherRecipe recipe;
|
||||||
|
private int counter = 0;
|
||||||
|
private int rotate = 0;
|
||||||
|
private final ItemStack[] stacks;
|
||||||
|
|
||||||
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe){
|
public PageCrusherRecipe(int localizationKey, CrusherRecipe recipe){
|
||||||
super(localizationKey);
|
super(localizationKey);
|
||||||
this.recipe = recipe;
|
this.recipe = recipe;
|
||||||
|
stacks = recipe.getInput().getMatchingStacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
gui.renderScaledAsciiString("("+StringUtil.localize("booklet."+ActuallyAdditions.MODID+".crusherRecipe")+")", startX+36, startY+85, 0, false, gui.getMediumFontSize());
|
||||||
|
|
||||||
PageTextOnly.renderTextToPage(gui, this, startX+6, startY+100);
|
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
|
@Override
|
||||||
|
@ -51,11 +57,11 @@ public class PageCrusherRecipe extends BookletPage{
|
||||||
super.initGui(gui, startX, startY);
|
super.initGui(gui, startX, startY);
|
||||||
|
|
||||||
if(this.recipe != null){
|
if(this.recipe != null){
|
||||||
gui.addOrModifyItemRenderer(this.recipe.inputStack, startX+38+18, startY+6+2, 1F, true);
|
gui.addOrModifyItemRenderer(stacks[rotate++ % stacks.length], startX+38+18, startY+6+1, 1F, true);
|
||||||
gui.addOrModifyItemRenderer(this.recipe.outputOneStack, startX+38+4, startY+6+53, 1F, false);
|
gui.addOrModifyItemRenderer(this.recipe.getOutputOne(), startX+38+4, startY+6+53, 1F, false);
|
||||||
|
|
||||||
if(StackUtil.isValid(this.recipe.outputTwoStack)){
|
if(StackUtil.isValid(this.recipe.getOutputTwo())){
|
||||||
gui.addOrModifyItemRenderer(this.recipe.outputTwoStack, startX+38+30, startY+6+53, 1F, false);
|
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);
|
super.getItemStacksForPage(list);
|
||||||
|
|
||||||
if(this.recipe != null){
|
if(this.recipe != null){
|
||||||
list.add(this.recipe.outputOneStack);
|
list.add(this.recipe.getOutputOne());
|
||||||
|
|
||||||
if(StackUtil.isValid(this.recipe.outputTwoStack)){
|
if(StackUtil.isValid(this.recipe.getOutputTwo())){
|
||||||
list.add(this.recipe.outputTwoStack);
|
list.add(this.recipe.getOutputTwo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.crafting;
|
package de.ellpeck.actuallyadditions.mod.crafting;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.InitItems;
|
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.items.metalists.TheFoods;
|
||||||
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
import de.ellpeck.actuallyadditions.mod.recipe.CrusherRecipeRegistry;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
import de.ellpeck.actuallyadditions.mod.util.RecipeUtil;
|
||||||
|
@ -23,13 +26,11 @@ import net.minecraft.init.Items;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
import net.minecraftforge.oredict.OreIngredient;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
public final class CrusherCrafting{
|
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 recipeIronHorseArmor;
|
||||||
public static CrusherRecipe recipeGoldHorseArmor;
|
public static CrusherRecipe recipeGoldHorseArmor;
|
||||||
public static CrusherRecipe recipeDiamondHorseArmor;
|
public static CrusherRecipe recipeDiamondHorseArmor;
|
||||||
|
@ -37,8 +38,6 @@ public final class CrusherCrafting{
|
||||||
public static void init(){
|
public static void init(){
|
||||||
ActuallyAdditions.LOGGER.info("Initializing Crusher Recipes...");
|
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);
|
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.BONE), new ItemStack(Items.DYE, 6, 15), StackUtil.getEmpty(), 0);
|
||||||
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
|
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3), StackUtil.getEmpty(), 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Items.REEDS), new ItemStack(Items.SUGAR, 3), StackUtil.getEmpty(), 0);
|
||||||
|
@ -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);
|
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(Blocks.DOUBLE_PLANT, 1, 5), new ItemStack(Items.DYE, 4, 9), StackUtil.getEmpty(), 0);
|
||||||
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
|
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
|
||||||
|
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreRedstone", false), new ItemStack(Items.REDSTONE), 10, StackUtil.getEmpty(), 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreRedstone"), new ItemStack(Items.REDSTONE, 10), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreLapis", false), new ItemStack(Items.DYE, 1, 4), 12, StackUtil.getEmpty(), 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreLapis"), new ItemStack(Items.DYE, 12, 4), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("coal", false), OreDictionary.getOres("dustCoal", false), 1, LIST, 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("coal"), new ItemStack(InitItems.itemDust, 1, TheDusts.COAL.ordinal()), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreCoal", false), new ItemStack(Items.COAL), 3, StackUtil.getEmpty(), 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreCoal"), new ItemStack(Items.COAL,3), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("blockCoal", false), new ItemStack(Items.COAL), 9, StackUtil.getEmpty(), 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("blockCoal"), new ItemStack(Items.COAL,9), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("oreQuartz", false), new ItemStack(Items.QUARTZ), 3, StackUtil.getEmpty(), 0, 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient("oreQuartz"), new ItemStack(Items.QUARTZ,3), StackUtil.getEmpty(), 0);
|
||||||
ActuallyAdditionsAPI.addCrusherRecipes(OreDictionary.getOres("cobblestone", false), new ItemStack(Blocks.SAND), 1, StackUtil.getEmpty(), 0, 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.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);
|
ActuallyAdditionsAPI.addCrusherRecipe(new ItemStack(InitItems.itemFoods, 1, TheFoods.RICE.ordinal()), new ItemStack(Items.SUGAR, 2), StackUtil.getEmpty(), 0);
|
||||||
MISC_RECIPES.add(RecipeUtil.lastCrusherRecipe());
|
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("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(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();
|
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();
|
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();
|
recipeDiamondHorseArmor = RecipeUtil.lastCrusherRecipe();
|
||||||
|
|
||||||
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("oreNether", 6));
|
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("denseore", 8));
|
||||||
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("gem", 1));
|
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("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));
|
||||||
CrusherRecipeRegistry.SEARCH_CASES.add(new CrusherRecipeRegistry.SearchCase("ore", 2, "gem")); //If no dust is found for certain ores, make gems directly
|
|
||||||
|
|
||||||
CrusherRecipeRegistry.registerFinally();
|
CrusherRecipeRegistry.registerFinally();
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,13 +52,7 @@ public final class InitCrafting{
|
||||||
ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior());
|
ActuallyAdditionsAPI.addFarmerBehavior(new EnderlillyFarmerBehavior());
|
||||||
ActuallyAdditionsAPI.addFarmerBehavior(new RedOrchidFarmerBehavior());
|
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"));
|
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"));
|
new RecipeBioMash(new ResourceLocation(ActuallyAdditions.MODID, "bio_mash"));
|
||||||
//RecipeSorter.register(ModUtil.MOD_ID+":recipeBioMash", RecipeBioMash.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.event;
|
package de.ellpeck.actuallyadditions.mod.event;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.data.PlayerData;
|
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.misc.DungeonLoot;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
import de.ellpeck.actuallyadditions.mod.network.PacketHandlerHelper;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
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.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
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.eventhandler.SubscribeEvent;
|
||||||
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
import net.minecraftforge.fml.common.gameevent.PlayerEvent;
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class CommonEvents{
|
public class CommonEvents{
|
||||||
|
|
||||||
public CommonEvents(){
|
public CommonEvents(){
|
||||||
|
@ -78,14 +78,14 @@ public class CommonEvents{
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
boolean isVoid = ((ItemBag)invStack.getItem()).isVoid;
|
boolean isVoid = ((ItemBag)invStack.getItem()).isVoid;
|
||||||
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerBag.getSlotAmount(isVoid));
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(isVoid));
|
||||||
ItemDrill.loadSlotsFromNBT(inv, invStack);
|
ItemDrill.loadSlotsFromNBT(inv, invStack);
|
||||||
|
|
||||||
FilterSettings filter = new FilterSettings(4, false, false, false, false, 0, 0);
|
FilterSettings filter = new FilterSettings(4, false, false, false, false, 0, 0);
|
||||||
filter.readFromNBT(invStack.getTagCompound(), "Filter");
|
filter.readFromNBT(invStack.getTagCompound(), "Filter");
|
||||||
if(filter.check(stack)){
|
if(filter.check(stack)){
|
||||||
if(isVoid){
|
if(isVoid){
|
||||||
stack = StackUtil.setStackSize(stack, 0);
|
stack.setCount(0);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -93,17 +93,17 @@ public class CommonEvents{
|
||||||
ItemStack bagStack = inv.getStackInSlot(j);
|
ItemStack bagStack = inv.getStackInSlot(j);
|
||||||
if(StackUtil.isValid(bagStack)){
|
if(StackUtil.isValid(bagStack)){
|
||||||
if(ItemUtil.canBeStacked(bagStack, stack)){
|
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){
|
if(maxTransfer > 0){
|
||||||
inv.setStackInSlot(j, StackUtil.addStackSize(bagStack, maxTransfer));
|
inv.setStackInSlot(j, StackUtil.grow(bagStack, maxTransfer));
|
||||||
stack = StackUtil.addStackSize(stack, -maxTransfer);
|
stack.shrink(maxTransfer);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
inv.setStackInSlot(j, stack.copy());
|
inv.setStackInSlot(j, stack.copy());
|
||||||
stack = StackUtil.setStackSize(stack, 0);
|
stack.setCount(0);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.gen.village;
|
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.IMerchant;
|
||||||
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
import net.minecraft.entity.passive.EntityVillager.ITradeList;
|
||||||
import net.minecraft.entity.passive.EntityVillager.PriceInfo;
|
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.MerchantRecipe;
|
||||||
import net.minecraft.village.MerchantRecipeList;
|
import net.minecraft.village.MerchantRecipeList;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BasicTradeList implements ITradeList{
|
public class BasicTradeList implements ITradeList{
|
||||||
|
|
||||||
private final ItemStack input;
|
private final ItemStack input;
|
||||||
|
@ -46,9 +45,9 @@ public class BasicTradeList implements ITradeList{
|
||||||
@Override
|
@Override
|
||||||
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random){
|
public void addMerchantRecipe(IMerchant merchant, MerchantRecipeList recipeList, Random random){
|
||||||
ItemStack in = this.input.copy();
|
ItemStack in = this.input.copy();
|
||||||
in = StackUtil.setStackSize(in, this.inputAmount.getPrice(random));
|
in.setCount(this.inputAmount.getPrice(random));
|
||||||
ItemStack out = this.output.copy();
|
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));
|
recipeList.add(new MerchantRecipe(in, out));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
||||||
if(compost instanceof TileEntityCompost){
|
if(compost instanceof TileEntityCompost){
|
||||||
TileEntityCompost tile = (TileEntityCompost)compost;
|
TileEntityCompost tile = (TileEntityCompost)compost;
|
||||||
tile.stopFromDropping = true;
|
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;
|
TileEntityCanolaPress tile = (TileEntityCanolaPress)press;
|
||||||
tile.stopFromDropping = true;
|
tile.stopFromDropping = true;
|
||||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/3));
|
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);
|
TileEntity crusher = this.getTileAtPos(world, 2, 1, 6, sbb);
|
||||||
|
@ -144,7 +144,7 @@ public class VillageComponentEngineerHouse extends StructureVillagePieces.House1
|
||||||
tile.stopFromDropping = true;
|
tile.stopFromDropping = true;
|
||||||
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
|
tile.storage.setEnergyStored(world.rand.nextInt(tile.storage.getMaxEnergyStored()/2));
|
||||||
if(world.rand.nextFloat() >= 0.25F){
|
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){
|
if(coal instanceof TileEntityCoalGenerator){
|
||||||
TileEntityCoalGenerator tile = (TileEntityCoalGenerator)coal;
|
TileEntityCoalGenerator tile = (TileEntityCoalGenerator)coal;
|
||||||
tile.stopFromDropping = true;
|
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);
|
TileEntity reconstructor = this.getTileAtPos(world, 8, 4, 3, sbb);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import de.ellpeck.actuallyadditions.mod.items.ItemBag;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
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 de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -44,7 +44,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
public class ContainerBag extends Container implements IButtonReactor{
|
public class ContainerBag extends Container implements IButtonReactor{
|
||||||
|
|
||||||
public final FilterSettings filter = new FilterSettings(4, false, true, false, false, 0, -1000);
|
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 InventoryPlayer inventory;
|
||||||
private final boolean isVoid;
|
private final boolean isVoid;
|
||||||
public boolean autoInsert;
|
public boolean autoInsert;
|
||||||
|
@ -53,7 +53,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
|
|
||||||
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){
|
public ContainerBag(ItemStack sack, InventoryPlayer inventory, boolean isVoid){
|
||||||
this.inventory = inventory;
|
this.inventory = inventory;
|
||||||
this.bagInventory = new ItemStackHandlerCustom(getSlotAmount(isVoid)) {
|
this.bagInventory = new ItemStackHandlerAA(getSlotAmount(isVoid)) {
|
||||||
@Override
|
@Override
|
||||||
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
public ItemStack insertItem(int slot, ItemStack stack, boolean simulate) {
|
||||||
if(isBlacklisted(stack)) return stack;
|
if(isBlacklisted(stack)) return stack;
|
||||||
|
@ -198,7 +198,7 @@ public class ContainerBag extends Container implements IButtonReactor{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ContainerBioReactor extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
for(int j = 0; j < 2; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerBreaker extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerCanolaPress extends Container{
|
||||||
public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerCanolaPress(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.press = (TileEntityCanolaPress)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 i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -85,7 +85,7 @@ public class ContainerCanolaPress extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ContainerCoalGenerator extends Container{
|
||||||
public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerCoalGenerator(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.generator = (TileEntityCoalGenerator)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 i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -84,7 +84,7 @@ public class ContainerCoalGenerator extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class ContainerCoffeeMachine extends Container{
|
||||||
public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.machine = (TileEntityCoffeeMachine)tile;
|
this.machine = (TileEntityCoffeeMachine)tile;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.slots, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_COFFEE_BEANS, 37, 6));
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.slots, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.machine.inv, TileEntityCoffeeMachine.SLOT_INPUT, 80, 42));
|
||||||
this.addSlotToContainer(new SlotOutput(this.machine.slots, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73));
|
this.addSlotToContainer(new SlotOutput(this.machine.inv, TileEntityCoffeeMachine.SLOT_OUTPUT, 80, 73));
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
for(int j = 0; j < 2; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerDirectionalBreaker extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -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.inventory.slot.SlotItemHandlerUnconditioned;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrillUpgrade;
|
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 de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -28,7 +28,7 @@ public class ContainerDrill extends Container{
|
||||||
|
|
||||||
public static final int SLOT_AMOUNT = 5;
|
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;
|
private final InventoryPlayer inventory;
|
||||||
|
|
||||||
public ContainerDrill(InventoryPlayer inventory){
|
public ContainerDrill(InventoryPlayer inventory){
|
||||||
|
@ -106,7 +106,7 @@ public class ContainerDrill extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class ContainerDropper extends Container{
|
||||||
InventoryPlayer inventory = player.inventory;
|
InventoryPlayer inventory = player.inventory;
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -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.TileEntityBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEnergizer;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
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;
|
private final TileEntityEnergizer energizer;
|
||||||
|
|
||||||
public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile){
|
public ContainerEnergizer(final EntityPlayer player, TileEntityBase tile) {
|
||||||
this.energizer = (TileEntityEnergizer)tile;
|
this.energizer = (TileEntityEnergizer) tile;
|
||||||
InventoryPlayer inventory = player.inventory;
|
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
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack) {
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return super.isItemValid(stack) && stack.hasCapability(CapabilityEnergy.ENERGY, null);
|
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 i = 0; i < 3; i++) {
|
||||||
for(int j = 0; j < 9; j++){
|
for (int j = 0; j < 9; j++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, j+i*9+9, 8+j*18, 97+i*18));
|
this.addSlotToContainer(new Slot(inventory, j + i * 9 + 9, 8 + j * 18, 97 + i * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i = 0; i < 9; i++){
|
for (int i = 0; i < 9; i++) {
|
||||||
this.addSlotToContainer(new Slot(inventory, i, 8+i*18, 155));
|
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];
|
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
|
@Override
|
||||||
public int getSlotStackLimit(){
|
public int getSlotStackLimit() {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack){
|
public boolean isItemValid(ItemStack stack) {
|
||||||
return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
|
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
|
@Override
|
||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public String getSlotTexture(){
|
public String getSlotTexture() {
|
||||||
return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
return ItemArmor.EMPTY_SLOT_NAMES[slot.getIndex()];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -76,58 +82,43 @@ public class ContainerEnergizer extends Container{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack transferStackInSlot(EntityPlayer player, int slot){
|
public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
|
||||||
int inventoryStart = 2;
|
int inventoryStart = 2;
|
||||||
int inventoryEnd = inventoryStart+26;
|
int inventoryEnd = inventoryStart + 26;
|
||||||
int hotbarStart = inventoryEnd+1;
|
int hotbarStart = inventoryEnd + 1;
|
||||||
int hotbarEnd = hotbarStart+8;
|
int hotbarEnd = hotbarStart + 8;
|
||||||
|
|
||||||
Slot theSlot = this.inventorySlots.get(slot);
|
Slot theSlot = this.inventorySlots.get(slot);
|
||||||
|
|
||||||
if(theSlot != null && theSlot.getHasStack()){
|
if (theSlot != null && theSlot.getHasStack()) {
|
||||||
ItemStack newStack = theSlot.getStack();
|
ItemStack newStack = theSlot.getStack();
|
||||||
ItemStack currentStack = newStack.copy();
|
ItemStack currentStack = newStack.copy();
|
||||||
|
|
||||||
//Slots in Inventory to shift from
|
//Slots in Inventory to shift from
|
||||||
if(slot == 1){
|
if (slot == 1) {
|
||||||
if(!this.mergeItemStack(newStack, inventoryStart, hotbarEnd+1, true)){
|
if (!this.mergeItemStack(newStack, inventoryStart, hotbarEnd + 1, true)) { return StackUtil.getEmpty(); }
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
theSlot.onSlotChange(newStack, currentStack);
|
theSlot.onSlotChange(newStack, currentStack);
|
||||||
}
|
}
|
||||||
//Other Slots in Inventory excluded
|
//Other Slots in Inventory excluded
|
||||||
else if(slot >= inventoryStart){
|
else if (slot >= inventoryStart) {
|
||||||
//Shift from Inventory
|
//Shift from Inventory
|
||||||
if(newStack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
if (newStack.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||||
if(!this.mergeItemStack(newStack, 0, 1, false)){
|
if (!this.mergeItemStack(newStack, 0, 1, false)) { return StackUtil.getEmpty(); }
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
|
||||||
else if(slot >= inventoryStart && slot <= inventoryEnd){
|
else if (slot >= inventoryStart && slot <= inventoryEnd) {
|
||||||
if(!this.mergeItemStack(newStack, hotbarStart, hotbarEnd+1, false)){
|
if (!this.mergeItemStack(newStack, hotbarStart, hotbarEnd + 1, false)) { return StackUtil.getEmpty(); }
|
||||||
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 >= 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());
|
theSlot.putStack(StackUtil.getEmpty());
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if (newStack.getCount() == currentStack.getCount()) { return StackUtil.getEmpty(); }
|
||||||
return StackUtil.getEmpty();
|
|
||||||
}
|
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
||||||
return currentStack;
|
return currentStack;
|
||||||
|
@ -136,7 +127,7 @@ public class ContainerEnergizer extends Container{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canInteractWith(EntityPlayer player){
|
public boolean canInteractWith(EntityPlayer player) {
|
||||||
return this.energizer.canPlayerUse(player);
|
return this.energizer.canPlayerUse(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -35,8 +35,8 @@ public class ContainerEnervator extends Container{
|
||||||
this.enervator = (TileEntityEnervator)tile;
|
this.enervator = (TileEntityEnervator)tile;
|
||||||
InventoryPlayer inventory = player.inventory;
|
InventoryPlayer inventory = player.inventory;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.slots, 0, 76, 73));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.enervator.inv, 0, 76, 73));
|
||||||
this.addSlotToContainer(new SlotOutput(this.enervator.slots, 1, 76, 42));
|
this.addSlotToContainer(new SlotOutput(this.enervator.inv, 1, 76, 42));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -119,7 +119,7 @@ public class ContainerEnervator extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,12 +30,12 @@ public class ContainerFarmer extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 2; j++){
|
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 i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 2; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class ContainerFeeder extends Container{
|
||||||
|
|
||||||
public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerFeeder(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.tileFeeder = (TileEntityFeeder)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 i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -78,7 +78,7 @@ public class ContainerFeeder extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -72,7 +72,7 @@ public class ContainerFermentingBarrel extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -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.SlotFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotImmovable;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
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 de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.entity.player.InventoryPlayer;
|
import net.minecraft.entity.player.InventoryPlayer;
|
||||||
|
@ -27,7 +27,7 @@ public class ContainerFilter extends Container{
|
||||||
|
|
||||||
public static final int SLOT_AMOUNT = 24;
|
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;
|
private final InventoryPlayer inventory;
|
||||||
|
|
||||||
public ContainerFilter(InventoryPlayer inventory){
|
public ContainerFilter(InventoryPlayer inventory){
|
||||||
|
@ -96,7 +96,7 @@ public class ContainerFilter extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -79,7 +79,7 @@ public class ContainerFluidCollector extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,10 +30,10 @@ public class ContainerFurnaceDouble extends Container{
|
||||||
public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerFurnaceDouble(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.tileFurnace = (TileEntityFurnaceDouble)tile;
|
this.tileFurnace = (TileEntityFurnaceDouble)tile;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_1, 51, 21));
|
||||||
this.addSlotToContainer(new SlotOutput(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69));
|
this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_1, 51, 69));
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_INPUT_2, 109, 21));
|
||||||
this.addSlotToContainer(new SlotOutput(this.tileFurnace.slots, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69));
|
this.addSlotToContainer(new SlotOutput(this.tileFurnace.inv, TileEntityFurnaceDouble.SLOT_OUTPUT_2, 108, 69));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -97,7 +97,7 @@ public class ContainerFurnaceDouble extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -31,7 +31,7 @@ public class ContainerGiantChest extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 9; i++){
|
for(int i = 0; i < 9; i++){
|
||||||
for(int j = 0; j < 13; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class ContainerGrinder extends Container{
|
||||||
this.tileGrinder = (TileEntityGrinder)tile;
|
this.tileGrinder = (TileEntityGrinder)tile;
|
||||||
this.isDouble = isDouble;
|
this.isDouble = isDouble;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.slots, TileEntityGrinder.SLOT_INPUT_1, this.isDouble ? 51 : 80, 21));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, 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.inv, 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 SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_1_2, this.isDouble ? 64 : 92, 69));
|
||||||
if(this.isDouble){
|
if(this.isDouble){
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.slots, TileEntityGrinder.SLOT_INPUT_2, 109, 21));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileGrinder.inv, 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.inv, TileEntityGrinder.SLOT_OUTPUT_2_1, 96, 69));
|
||||||
this.addSlotToContainer(new SlotOutput(this.tileGrinder.slots, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69));
|
this.addSlotToContainer(new SlotOutput(this.tileGrinder.inv, TileEntityGrinder.SLOT_OUTPUT_2_2, 121, 69));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
|
@ -108,7 +108,7 @@ public class ContainerGrinder extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class ContainerInputter extends Container{
|
||||||
this.tileInputter = (TileEntityInputter)tile;
|
this.tileInputter = (TileEntityInputter)tile;
|
||||||
this.isAdvanced = isAdvanced;
|
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){
|
if(isAdvanced){
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
|
@ -95,7 +95,7 @@ public class ContainerInputter extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class ContainerLaserRelayItemWhitelist extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerMiner extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ContainerOilGenerator extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public class ContainerPhantomPlacer extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ContainerRangedCollector extends Container{
|
||||||
|
|
||||||
for(int i = 0; i < 2; i++){
|
for(int i = 0; i < 2; i++){
|
||||||
for(int j = 0; j < 3; j++){
|
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++){
|
for(int i = 0; i < 4; i++){
|
||||||
|
@ -90,7 +90,7 @@ public class ContainerRangedCollector extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -29,8 +29,8 @@ public class ContainerRepairer extends Container{
|
||||||
public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerRepairer(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.tileRepairer = (TileEntityItemRepairer)tile;
|
this.tileRepairer = (TileEntityItemRepairer)tile;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileRepairer.slots, TileEntityItemRepairer.SLOT_INPUT, 47, 53));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_INPUT, 47, 53));
|
||||||
this.addSlotToContainer(new SlotOutput(this.tileRepairer.slots, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53));
|
this.addSlotToContainer(new SlotOutput(this.tileRepairer.inv, TileEntityItemRepairer.SLOT_OUTPUT, 109, 53));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -85,7 +85,7 @@ public class ContainerRepairer extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -30,8 +30,8 @@ public class ContainerXPSolidifier extends Container{
|
||||||
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
|
public ContainerXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
|
||||||
this.solidifier = (TileEntityXPSolidifier)tile;
|
this.solidifier = (TileEntityXPSolidifier)tile;
|
||||||
|
|
||||||
this.addSlotToContainer(new SlotOutput(this.solidifier.slots, 0, 95, 8));
|
this.addSlotToContainer(new SlotOutput(this.solidifier.inv, 0, 95, 8));
|
||||||
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.solidifier.slots, 1, 65, 8));
|
this.addSlotToContainer(new SlotItemHandlerUnconditioned(this.solidifier.inv, 1, 65, 8));
|
||||||
|
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(int j = 0; j < 9; j++){
|
for(int j = 0; j < 9; j++){
|
||||||
|
@ -83,7 +83,7 @@ public class ContainerXPSolidifier extends Container{
|
||||||
theSlot.onSlotChanged();
|
theSlot.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StackUtil.getStackSize(newStack) == StackUtil.getStackSize(currentStack)){
|
if(newStack.getCount() == currentStack.getCount()){
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
theSlot.onTake(player, newStack);
|
theSlot.onTake(player, newStack);
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class GuiRepairer extends GuiWtfMojang{
|
||||||
this.mc.getTextureManager().bindTexture(RES_LOC);
|
this.mc.getTextureManager().bindTexture(RES_LOC);
|
||||||
this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, 176, 93);
|
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);
|
int i = this.tileRepairer.getItemDamageToScale(22);
|
||||||
this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16);
|
this.drawTexturedModalRect(this.guiLeft+73, this.guiTop+52, 176, 28, i, 16);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory.slot;
|
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;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SlotDeletion extends SlotItemHandlerUnconditioned{
|
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);
|
super(inv, slot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ package de.ellpeck.actuallyadditions.mod.inventory.slot;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemFilter;
|
import de.ellpeck.actuallyadditions.mod.items.ItemFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.FilterSettings;
|
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 de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.inventory.Container;
|
import net.minecraft.inventory.Container;
|
||||||
|
@ -21,7 +21,7 @@ import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SlotFilter extends SlotItemHandlerUnconditioned{
|
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);
|
super(inv, slot, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,10 +57,10 @@ public class SlotFilter extends SlotItemHandlerUnconditioned{
|
||||||
}
|
}
|
||||||
else if(StackUtil.isValid(heldStack)){
|
else if(StackUtil.isValid(heldStack)){
|
||||||
if(!isFilter(stackInSlot)){
|
if(!isFilter(stackInSlot)){
|
||||||
this.putStack(StackUtil.setStackSize(heldStack.copy(), 1));
|
this.putStack(StackUtil.grow(heldStack.copy(), 1));
|
||||||
|
|
||||||
if(isFilter(heldStack)){
|
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
|
@Override
|
||||||
public void putStack(ItemStack stack){
|
public void putStack(ItemStack stack){
|
||||||
super.putStack(StackUtil.validateCopy(stack));
|
super.putStack(stack.copy());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,68 +10,66 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory.slot;
|
package de.ellpeck.actuallyadditions.mod.inventory.slot;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerCustom;
|
import javax.annotation.Nonnull;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.ItemStackHandlerAA;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.items.SlotItemHandler;
|
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(ItemStackHandlerAA inv, int index, int xPosition, int yPosition) {
|
||||||
|
super(inv, index, xPosition, yPosition);
|
||||||
public SlotItemHandlerUnconditioned(ItemStackHandlerCustom handler, int index, int xPosition, int yPosition){
|
this.inv = inv;
|
||||||
super(handler, index, xPosition, yPosition);
|
|
||||||
this.handler = handler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValid(ItemStack stack){
|
public boolean isItemValid(ItemStack stack) {
|
||||||
if(StackUtil.isValid(stack)){
|
if (stack.isEmpty() || !inv.canAccept(getSlotIndex(), stack, false)) return false;
|
||||||
ItemStack currentStack = this.handler.getStackInSlot(this.getSlotIndex());
|
|
||||||
this.handler.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
|
ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex());
|
||||||
ItemStack remainder = this.handler.insertItemInternal(this.getSlotIndex(), stack, true);
|
this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
|
||||||
this.handler.setStackInSlot(this.getSlotIndex(), currentStack);
|
ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), stack, true, false);
|
||||||
|
this.inv.setStackInSlot(this.getSlotIndex(), currentStack);
|
||||||
return remainder.isEmpty() || remainder.getCount() < stack.getCount();
|
return remainder.isEmpty() || remainder.getCount() < stack.getCount();
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper fnct to get the stack in the slot.
|
* Helper fnct to get the stack in the slot.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ItemStack getStack(){
|
public ItemStack getStack() {
|
||||||
return this.handler.getStackInSlot(this.getSlotIndex());
|
return this.inv.getStackInSlot(this.getSlotIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void putStack(ItemStack stack){
|
public void putStack(ItemStack stack) {
|
||||||
this.handler.setStackInSlot(this.getSlotIndex(), stack);
|
this.inv.setStackInSlot(this.getSlotIndex(), stack);
|
||||||
this.onSlotChanged();
|
this.onSlotChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getItemStackLimit(ItemStack stack){
|
public int getItemStackLimit(ItemStack stack) {
|
||||||
ItemStack maxAdd = stack.copy();
|
ItemStack maxAdd = stack.copy();
|
||||||
maxAdd.setCount(stack.getMaxStackSize());
|
maxAdd.setCount(stack.getMaxStackSize());
|
||||||
ItemStack currentStack = this.handler.getStackInSlot(this.getSlotIndex());
|
ItemStack currentStack = this.inv.getStackInSlot(this.getSlotIndex());
|
||||||
this.handler.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
|
this.inv.setStackInSlot(this.getSlotIndex(), ItemStack.EMPTY);
|
||||||
ItemStack remainder = this.handler.insertItemInternal(this.getSlotIndex(), maxAdd, true);
|
ItemStack remainder = this.inv.insertItem(this.getSlotIndex(), maxAdd, true, false);
|
||||||
this.handler.setStackInSlot(this.getSlotIndex(), currentStack);
|
this.inv.setStackInSlot(this.getSlotIndex(), currentStack);
|
||||||
return stack.getMaxStackSize()-remainder.getCount();
|
return stack.getMaxStackSize() - remainder.getCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canTakeStack(EntityPlayer playerIn){
|
public boolean canTakeStack(EntityPlayer playerIn) {
|
||||||
return !this.handler.extractItemInternal(this.getSlotIndex(), 1, true).isEmpty();
|
return !this.inv.extractItem(this.getSlotIndex(), 1, true, false).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack decrStackSize(int amount){
|
public ItemStack decrStackSize(int amount) {
|
||||||
return this.handler.extractItemInternal(this.getSlotIndex(), amount, false);
|
return this.inv.extractItem(this.getSlotIndex(), amount, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.inventory.slot;
|
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;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
public class SlotOutput extends SlotItemHandlerUnconditioned{
|
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);
|
super(inventory, id, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,17 +10,22 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
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.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag;
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerBag;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler.GuiTypes;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler.GuiTypes;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
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.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
|
@ -32,9 +37,6 @@ import net.minecraft.world.World;
|
||||||
import net.minecraftforge.items.CapabilityItemHandler;
|
import net.minecraftforge.items.CapabilityItemHandler;
|
||||||
import net.minecraftforge.items.IItemHandler;
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemBag extends ItemBase{
|
public class ItemBag extends ItemBase{
|
||||||
|
|
||||||
public final boolean isVoid;
|
public final boolean isVoid;
|
||||||
|
@ -47,7 +49,7 @@ public class ItemBag extends ItemBase{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addInformation(ItemStack stack, @Nullable World playerIn, List<String> tooltip, ITooltipFlag advanced){
|
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);
|
ItemDrill.loadSlotsFromNBT(inv, stack);
|
||||||
|
|
||||||
int slotsTotal = inv.getSlots();
|
int slotsTotal = inv.getSlots();
|
||||||
|
@ -72,7 +74,7 @@ public class ItemBag extends ItemBase{
|
||||||
if(handler != null){
|
if(handler != null){
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerBag.getSlotAmount(this.isVoid));
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerBag.getSlotAmount(this.isVoid));
|
||||||
ItemDrill.loadSlotsFromNBT(inv, stack);
|
ItemDrill.loadSlotsFromNBT(inv, stack);
|
||||||
|
|
||||||
for(int j = 0; j < inv.getSlots(); j++){
|
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++){
|
for(int i = 0; i < handler.getSlots(); i++){
|
||||||
ItemStack remain = handler.insertItem(i, invStack, false);
|
ItemStack remain = handler.insertItem(i, invStack, false);
|
||||||
if(!ItemStack.areItemStacksEqual(remain, invStack)){
|
if(!ItemStack.areItemStacksEqual(remain, invStack)){
|
||||||
inv.setStackInSlot(j, StackUtil.validateCopy(remain));
|
inv.setStackInSlot(j, remain.copy());
|
||||||
changed = true;
|
changed = true;
|
||||||
|
|
||||||
if(!StackUtil.isValid(remain)){
|
if(!StackUtil.isValid(remain)){
|
||||||
|
@ -108,11 +110,16 @@ public class ItemBag extends ItemBase{
|
||||||
if(!world.isRemote && hand == EnumHand.MAIN_HAND){
|
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);
|
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
|
@Override
|
||||||
public EnumRarity getRarity(ItemStack stack){
|
public EnumRarity getRarity(ItemStack stack){
|
||||||
return this.isVoid ? EnumRarity.RARE : EnumRarity.UNCOMMON;
|
return this.isVoid ? EnumRarity.RARE : EnumRarity.UNCOMMON;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public NBTTagCompound getNBTShareTag(ItemStack stack){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
|
||||||
chest = new InvWrapper((IInventory)tileHit);
|
chest = new InvWrapper((IInventory)tileHit);
|
||||||
}
|
}
|
||||||
else if(tileHit instanceof TileEntityInventoryBase){
|
else if(tileHit instanceof TileEntityInventoryBase){
|
||||||
chest = ((TileEntityInventoryBase)tileHit).slots;
|
chest = ((TileEntityInventoryBase)tileHit).inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chest != null){
|
if(chest != null){
|
||||||
|
@ -74,7 +74,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
|
||||||
//Copy Items into new Chest
|
//Copy Items into new Chest
|
||||||
TileEntity newTileHit = world.getTileEntity(pos);
|
TileEntity newTileHit = world.getTileEntity(pos);
|
||||||
if(newTileHit instanceof TileEntityInventoryBase){
|
if(newTileHit instanceof TileEntityInventoryBase){
|
||||||
IItemHandlerModifiable newChest = ((TileEntityInventoryBase)newTileHit).slots;
|
IItemHandlerModifiable newChest = ((TileEntityInventoryBase)newTileHit).inv;
|
||||||
|
|
||||||
for(int i = 0; i < stacks.length; i++){
|
for(int i = 0; i < stacks.length; i++){
|
||||||
if(StackUtil.isValid(stacks[i])){
|
if(StackUtil.isValid(stacks[i])){
|
||||||
|
|
|
@ -23,7 +23,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.ContainerDrill;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.tile.TileEntityInventoryBase;
|
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.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
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.ActionResult;
|
||||||
import net.minecraft.util.EnumActionResult;
|
import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.EnumFacing.Axis;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.util.EnumFacing.Axis;
|
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.RayTraceResult;
|
import net.minecraft.util.math.RayTraceResult;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import net.minecraftforge.common.ForgeHooks;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
import net.minecraftforge.fml.relauncher.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraftforge.items.IItemHandler;
|
||||||
|
import net.minecraftforge.items.IItemHandlerModifiable;
|
||||||
|
|
||||||
public class ItemDrill extends ItemEnergy{
|
public class ItemDrill extends ItemEnergy{
|
||||||
|
|
||||||
|
@ -74,7 +76,7 @@ public class ItemDrill extends ItemEnergy{
|
||||||
*
|
*
|
||||||
* @param stack The Drill
|
* @param stack The Drill
|
||||||
*/
|
*/
|
||||||
public static void loadSlotsFromNBT(ItemStackHandlerCustom slots, ItemStack stack){
|
public static void loadSlotsFromNBT(IItemHandlerModifiable slots, ItemStack stack){
|
||||||
NBTTagCompound compound = stack.getTagCompound();
|
NBTTagCompound compound = stack.getTagCompound();
|
||||||
if(compound != null){
|
if(compound != null){
|
||||||
TileEntityInventoryBase.loadSlots(slots, compound);
|
TileEntityInventoryBase.loadSlots(slots, compound);
|
||||||
|
@ -87,7 +89,7 @@ public class ItemDrill extends ItemEnergy{
|
||||||
* @param slots The Slots
|
* @param slots The Slots
|
||||||
* @param stack The Drill
|
* @param stack The Drill
|
||||||
*/
|
*/
|
||||||
public static void writeSlotsToNBT(ItemStackHandlerCustom slots, ItemStack stack){
|
public static void writeSlotsToNBT(IItemHandler slots, ItemStack stack){
|
||||||
NBTTagCompound compound = stack.getTagCompound();
|
NBTTagCompound compound = stack.getTagCompound();
|
||||||
if(compound == null){
|
if(compound == null){
|
||||||
compound = new NBTTagCompound();
|
compound = new NBTTagCompound();
|
||||||
|
@ -115,7 +117,7 @@ public class ItemDrill extends ItemEnergy{
|
||||||
//Places the Block into the World
|
//Places the Block into the World
|
||||||
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
if(toPlaceStack.onItemUse(player, world, pos, hand, side, hitX, hitY, hitZ) != EnumActionResult.FAIL){
|
||||||
if(!player.capabilities.isCreativeMode){
|
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();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerDrill.SLOT_AMOUNT);
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerDrill.SLOT_AMOUNT);
|
||||||
loadSlotsFromNBT(inv, stack);
|
loadSlotsFromNBT(inv, stack);
|
||||||
for(int i = 0; i < inv.getSlots(); i++){
|
for(int i = 0; i < inv.getSlots(); i++){
|
||||||
ItemStack slotStack = inv.getStackInSlot(i);
|
ItemStack slotStack = inv.getStackInSlot(i);
|
||||||
|
|
|
@ -52,7 +52,7 @@ public class ItemFillingWand extends ItemEnergy {
|
||||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||||
ItemStack slot = player.inventory.getStackInSlot(i);
|
ItemStack slot = player.inventory.getStackInSlot(i);
|
||||||
if (StackUtil.isValid(slot) && slot.isItemEqual(stack)) {
|
if (StackUtil.isValid(slot) && slot.isItemEqual(stack)) {
|
||||||
slot = StackUtil.addStackSize(slot, -1);
|
slot.shrink(1);
|
||||||
if (!StackUtil.isValid(slot)) {
|
if (!StackUtil.isValid(slot)) {
|
||||||
player.inventory.setInventorySlotContents(i, StackUtil.getEmpty());
|
player.inventory.setInventorySlotContents(i, StackUtil.getEmpty());
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,11 +10,13 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
|
import de.ellpeck.actuallyadditions.mod.inventory.ContainerFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
import de.ellpeck.actuallyadditions.mod.inventory.GuiHandler;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
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.StackUtil;
|
||||||
import net.minecraft.client.util.ITooltipFlag;
|
import net.minecraft.client.util.ITooltipFlag;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -25,8 +27,6 @@ import net.minecraft.util.EnumActionResult;
|
||||||
import net.minecraft.util.EnumHand;
|
import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemFilter extends ItemBase{
|
public class ItemFilter extends ItemBase{
|
||||||
|
|
||||||
public ItemFilter(String name){
|
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){
|
public void addInformation(ItemStack stack, World playerIn, List<String> tooltip, ITooltipFlag advanced){
|
||||||
super.addInformation(stack, playerIn, tooltip, 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);
|
ItemDrill.loadSlotsFromNBT(inv, stack);
|
||||||
for(int i = 0; i < inv.getSlots(); i++){
|
for(int i = 0; i < inv.getSlots(); i++){
|
||||||
ItemStack slot = inv.getStackInSlot(i);
|
ItemStack slot = inv.getStackInSlot(i);
|
||||||
|
|
|
@ -10,26 +10,29 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigIntValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
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.item.EntityItem;
|
||||||
import net.minecraft.entity.passive.EntityOcelot;
|
import net.minecraft.entity.passive.EntityOcelot;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.SoundEvents;
|
import net.minecraft.init.SoundEvents;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
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.minecraft.world.World;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.event.entity.living.LivingEvent;
|
import net.minecraftforge.event.entity.living.LivingEvent;
|
||||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class ItemHairyBall extends ItemBase{
|
public class ItemHairyBall extends ItemBase{
|
||||||
|
|
||||||
public ItemHairyBall(String name){
|
public ItemHairyBall(String name){
|
||||||
|
@ -61,7 +64,7 @@ public class ItemHairyBall extends ItemBase{
|
||||||
entityItem.setPickupDelay(0);
|
entityItem.setPickupDelay(0);
|
||||||
player.world.spawnEntity(entityItem);
|
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);
|
world.playSound(null, player.posX, player.posY, player.posZ, SoundEvents.ENTITY_ITEM_PICKUP, SoundCategory.PLAYERS, 0.2F, world.rand.nextFloat()*0.1F+0.9F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,8 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.entity.SharedMonsterAttributes;
|
import net.minecraft.entity.SharedMonsterAttributes;
|
||||||
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
import net.minecraft.entity.ai.attributes.AttributeModifier;
|
||||||
import net.minecraft.inventory.EntityEquipmentSlot;
|
import net.minecraft.inventory.EntityEquipmentSlot;
|
||||||
|
@ -55,6 +55,6 @@ public class ItemKnife extends ItemBase{
|
||||||
public ItemStack getContainerItem(ItemStack stack){
|
public ItemStack getContainerItem(ItemStack stack){
|
||||||
ItemStack theStack = stack.copy();
|
ItemStack theStack = stack.copy();
|
||||||
theStack.setItemDamage(theStack.getItemDamage()+1);
|
theStack.setItemDamage(theStack.getItemDamage()+1);
|
||||||
return StackUtil.setStackSize(theStack, 1);
|
return theStack;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,9 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
@ -24,8 +25,6 @@ import net.minecraft.util.EnumHand;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemMagnetRing extends ItemEnergy{
|
public class ItemMagnetRing extends ItemEnergy{
|
||||||
|
|
||||||
public ItemMagnetRing(String name){
|
public ItemMagnetRing(String name){
|
||||||
|
@ -50,10 +49,10 @@ public class ItemMagnetRing extends ItemEnergy{
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
if(item.getEntityData().getBoolean("PreventRemoteMovement")) continue;
|
if(item.getEntityData().getBoolean("PreventRemoteMovement")) continue;
|
||||||
if(!item.isDead && !item.cannotPickup()){
|
if(!item.isDead && !item.cannotPickup()){
|
||||||
int energyForItem = 50*StackUtil.getStackSize(item.getItem());
|
int energyForItem = 50*item.getItem().getCount();
|
||||||
|
|
||||||
if(this.getEnergyStored(stack) >= energyForItem){
|
if(this.getEnergyStored(stack) >= energyForItem){
|
||||||
ItemStack oldItem = StackUtil.validateCopy(item.getItem());
|
ItemStack oldItem = item.getItem().copy();
|
||||||
|
|
||||||
item.onCollideWithPlayer(player);
|
item.onCollideWithPlayer(player);
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.EnumRarity;
|
import net.minecraft.item.EnumRarity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -31,7 +30,7 @@ public class ItemResonantRice extends ItemBase{
|
||||||
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
|
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand){
|
||||||
ItemStack stack = player.getHeldItem(hand);
|
ItemStack stack = player.getHeldItem(hand);
|
||||||
if(!world.isRemote){
|
if(!world.isRemote){
|
||||||
stack = StackUtil.addStackSize(stack, -1);
|
stack.shrink(1);
|
||||||
world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true);
|
world.createExplosion(null, player.posX, player.posY, player.posZ, 0.5F, true);
|
||||||
}
|
}
|
||||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
||||||
|
|
|
@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.items;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.entity.EntityCreature;
|
import net.minecraft.entity.EntityCreature;
|
||||||
import net.minecraft.entity.item.EntityItem;
|
import net.minecraft.entity.item.EntityItem;
|
||||||
import net.minecraft.entity.item.EntityXPOrb;
|
import net.minecraft.entity.item.EntityXPOrb;
|
||||||
|
@ -60,13 +59,13 @@ public class ItemSolidifiedExperience extends ItemBase{
|
||||||
if(!player.isSneaking()){
|
if(!player.isSneaking()){
|
||||||
amount = SOLID_XP_AMOUNT;
|
amount = SOLID_XP_AMOUNT;
|
||||||
if(!player.capabilities.isCreativeMode){
|
if(!player.capabilities.isCreativeMode){
|
||||||
stack = StackUtil.addStackSize(stack, -1);
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
amount = SOLID_XP_AMOUNT*StackUtil.getStackSize(stack);
|
amount = SOLID_XP_AMOUNT*stack.getCount();
|
||||||
if(!player.capabilities.isCreativeMode){
|
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);
|
orb.getEntityData().setBoolean(ActuallyAdditions.MODID+"FromSolidified", true);
|
||||||
world.spawnEntity(orb);
|
world.spawnEntity(orb);
|
||||||
}
|
}
|
||||||
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
|
return new ActionResult<>(EnumActionResult.SUCCESS, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class ItemSpawnerChanger extends ItemBase{
|
||||||
ItemPhantomConnector.clearStorage(stack, "Entity");
|
ItemPhantomConnector.clearStorage(stack, "Entity");
|
||||||
|
|
||||||
if(!player.capabilities.isCreativeMode){
|
if(!player.capabilities.isCreativeMode){
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
player.setHeldItem(hand, StackUtil.shrink(stack, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class ItemWaterBowl extends ItemBase{
|
||||||
|
|
||||||
if(!event.getWorld().isRemote){
|
if(!event.getWorld().isRemote){
|
||||||
event.getWorld().setBlockState(trace.getBlockPos(), Blocks.AIR.getDefaultState(), 11);
|
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);
|
ItemStack bowl = new ItemStack(InitItems.itemWaterBowl);
|
||||||
if(!StackUtil.isValid(reduced)){
|
if(!StackUtil.isValid(reduced)){
|
||||||
|
|
|
@ -10,11 +10,12 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items;
|
package de.ellpeck.actuallyadditions.mod.items;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
import de.ellpeck.actuallyadditions.mod.entity.EntityWorm;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.block.BlockGrass;
|
import net.minecraft.block.BlockGrass;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
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.Side;
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ItemWorm extends ItemBase{
|
public class ItemWorm extends ItemBase{
|
||||||
|
|
||||||
public ItemWorm(String name){
|
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.setPosition(pos.getX()+0.5, pos.getY()+0.5, pos.getZ()+0.5);
|
||||||
worm.setCustomNameTag(stack.getDisplayName());
|
worm.setCustomNameTag(stack.getDisplayName());
|
||||||
world.spawnEntity(worm);
|
world.spawnEntity(worm);
|
||||||
|
if(!player.capabilities.isCreativeMode) stack.shrink(1);
|
||||||
if(!player.capabilities.isCreativeMode){
|
|
||||||
player.setHeldItem(hand, StackUtil.addStackSize(stack, -1));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return EnumActionResult.SUCCESS;
|
return EnumActionResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ public class LensDisenchanting extends Lens{
|
||||||
for(EntityItem item : items){
|
for(EntityItem item : items){
|
||||||
if(item != null && !item.isDead){
|
if(item != null && !item.isDead){
|
||||||
ItemStack stack = item.getItem();
|
ItemStack stack = item.getItem();
|
||||||
if(StackUtil.isValid(stack) && StackUtil.getStackSize(stack) == 1){
|
if(StackUtil.isValid(stack) && stack.getCount() == 1){
|
||||||
Item stackItem = stack.getItem();
|
Item stackItem = stack.getItem();
|
||||||
if(stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK){
|
if(stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK){
|
||||||
if(book == null){
|
if(book == null){
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.items.lens;
|
package de.ellpeck.actuallyadditions.mod.items.lens;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
import de.ellpeck.actuallyadditions.api.internal.IAtomicReconstructor;
|
||||||
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
import de.ellpeck.actuallyadditions.api.lens.Lens;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
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.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
public class LensDisruption extends Lens{
|
public class LensDisruption extends Lens{
|
||||||
|
|
||||||
private static final int ENERGY_USE = 150000;
|
private static final int ENERGY_USE = 150000;
|
||||||
|
@ -52,7 +52,7 @@ public class LensDisruption extends Lens{
|
||||||
}
|
}
|
||||||
while(!StackUtil.isValid(newStack));
|
while(!StackUtil.isValid(newStack));
|
||||||
|
|
||||||
newStack = StackUtil.setStackSize(newStack, StackUtil.getStackSize(stack));
|
newStack.setCount(stack.getCount());
|
||||||
|
|
||||||
if(!newStack.hasTagCompound()){
|
if(!newStack.hasTagCompound()){
|
||||||
newStack.setTagCompound(new NBTTagCompound());
|
newStack.setTagCompound(new NBTTagCompound());
|
||||||
|
|
|
@ -10,6 +10,8 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
@ -53,14 +55,14 @@ public class CrusherRecipeCategory implements IRecipeCategory<CrusherRecipeWrapp
|
||||||
@Override
|
@Override
|
||||||
public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients){
|
public void setRecipe(IRecipeLayout recipeLayout, CrusherRecipeWrapper wrapper, IIngredients ingredients){
|
||||||
recipeLayout.getItemStacks().init(0, true, 19, 7);
|
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().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().init(2, false, 31, 55);
|
||||||
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.outputTwoStack);
|
recipeLayout.getItemStacks().set(2, wrapper.theRecipe.getOutputTwo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,10 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.jei.crusher;
|
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.booklet.IBookletPage;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
|
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.client.Minecraft;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
|
public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
|
||||||
|
|
||||||
public final CrusherRecipe theRecipe;
|
public final CrusherRecipe theRecipe;
|
||||||
|
@ -34,20 +35,20 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getIngredients(IIngredients ingredients){
|
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<ItemStack> list = new ArrayList<>();
|
||||||
list.add(this.theRecipe.outputOneStack);
|
list.add(this.theRecipe.getOutputOne());
|
||||||
if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
|
if(StackUtil.isValid(this.theRecipe.getOutputTwo())){
|
||||||
list.add(this.theRecipe.outputTwoStack);
|
list.add(this.theRecipe.getOutputTwo());
|
||||||
}
|
}
|
||||||
ingredients.setOutputs(ItemStack.class, list);
|
ingredients.setOutputs(ItemStack.class, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
public void drawInfo(Minecraft minecraft, int recipeWidth, int recipeHeight, int mouseX, int mouseY){
|
||||||
if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
|
if(StackUtil.isValid(this.theRecipe.getOutputTwo())){
|
||||||
minecraft.fontRenderer.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
minecraft.fontRenderer.drawString(this.theRecipe.getSecondChance()+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
super.drawInfo(minecraft, recipeWidth, recipeHeight, mouseX, mouseY);
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.misc.apiimpl;
|
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.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
|
||||||
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
|
||||||
|
@ -47,9 +50,6 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class MethodHandler implements IMethodHandler{
|
public class MethodHandler implements IMethodHandler{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -204,22 +204,22 @@ public class MethodHandler implements IMethodHandler{
|
||||||
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
|
List<LensConversionRecipe> recipes = LensRecipeHandler.getRecipesFor(stack);
|
||||||
for(LensConversionRecipe recipe : recipes){
|
for(LensConversionRecipe recipe : recipes){
|
||||||
if(recipe != null && recipe.type == tile.getLens()){
|
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){
|
if(itemsPossible > 0){
|
||||||
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
|
recipe.transformHook(item.getItem(), null, item.getPosition(), tile);
|
||||||
item.setDead();
|
item.setDead();
|
||||||
|
|
||||||
if(StackUtil.getStackSize(stack)-itemsPossible > 0){
|
if(stack.getCount()-itemsPossible > 0){
|
||||||
ItemStack stackCopy = stack.copy();
|
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);
|
EntityItem inputLeft = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, stackCopy);
|
||||||
tile.getWorldObject().spawnEntity(inputLeft);
|
tile.getWorldObject().spawnEntity(inputLeft);
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack outputCopy = recipe.outputStack.copy();
|
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);
|
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, outputCopy);
|
||||||
tile.getWorldObject().spawnEntity(newItem);
|
tile.getWorldObject().spawnEntity(newItem);
|
||||||
|
@ -268,7 +268,7 @@ public class MethodHandler implements IMethodHandler{
|
||||||
for(ItemStack outputOne : outputOnes){
|
for(ItemStack outputOne : outputOnes){
|
||||||
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
||||||
ItemStack outputOneCopy = outputOne.copy();
|
ItemStack outputOneCopy = outputOne.copy();
|
||||||
outputOneCopy = StackUtil.setStackSize(outputOneCopy, outputOneAmounts);
|
outputOneCopy.setCount(outputOneAmounts);
|
||||||
|
|
||||||
if(outputTwos.isEmpty()){
|
if(outputTwos.isEmpty()){
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
|
||||||
|
@ -278,7 +278,7 @@ public class MethodHandler implements IMethodHandler{
|
||||||
for(ItemStack outputTwo : outputTwos){
|
for(ItemStack outputTwo : outputTwos){
|
||||||
if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
||||||
ItemStack outputTwoCopy = outputTwo.copy();
|
ItemStack outputTwoCopy = outputTwo.copy();
|
||||||
outputTwoCopy = StackUtil.setStackSize(outputTwoCopy, outputTwoAmounts);
|
outputTwoCopy.setCount(outputTwoAmounts);
|
||||||
|
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
||||||
hasWorkedOnce = true;
|
hasWorkedOnce = true;
|
||||||
|
@ -299,7 +299,7 @@ public class MethodHandler implements IMethodHandler{
|
||||||
if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){
|
if(StackUtil.isValid(input) && CrusherRecipeRegistry.getRecipeFromInput(input) == null){
|
||||||
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
if(StackUtil.isValid(outputOne) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputOne, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
||||||
ItemStack outputOneCopy = outputOne.copy();
|
ItemStack outputOneCopy = outputOne.copy();
|
||||||
outputOneCopy = StackUtil.setStackSize(outputOneCopy, outputOneAmount);
|
outputOneCopy.setCount(outputOneAmount);
|
||||||
|
|
||||||
if(!StackUtil.isValid(outputTwo)){
|
if(!StackUtil.isValid(outputTwo)){
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, StackUtil.getEmpty(), 0);
|
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())){
|
else if(StackUtil.isValid(outputTwo) && !CrusherRecipeRegistry.hasBlacklistedOutput(outputTwo, ConfigStringListValues.CRUSHER_OUTPUT_BLACKLIST.getValue())){
|
||||||
ItemStack outputTwoCopy = outputTwo.copy();
|
ItemStack outputTwoCopy = outputTwo.copy();
|
||||||
outputTwoCopy = StackUtil.setStackSize(outputTwoCopy, outputTwoAmount);
|
outputTwoCopy.setCount(outputTwoAmount);
|
||||||
|
|
||||||
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
ActuallyAdditionsAPI.addCrusherRecipe(input, outputOneCopy, outputTwoCopy, outputTwoChance);
|
||||||
hasWorkedOnce = true;
|
hasWorkedOnce = true;
|
||||||
|
|
|
@ -65,12 +65,12 @@ public class CactusFarmerBehavior implements IFarmerBehavior{
|
||||||
upState.getBlock().getDrops(drops, world, up, upState, 0);
|
upState.getBlock().getDrops(drops, world, up, upState, 0);
|
||||||
|
|
||||||
if(!drops.isEmpty()){
|
if(!drops.isEmpty()){
|
||||||
if(farmer.addToOutputInventory(drops, false)){
|
if(farmer.canAddToOutput(drops)){
|
||||||
world.playEvent(2001, up, Block.getStateId(upState));
|
world.playEvent(2001, up, Block.getStateId(upState));
|
||||||
world.setBlockToAir(up);
|
world.setBlockToAir(up);
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
farmer.addToOutputInventory(drops, true);
|
farmer.addToOutput(drops);
|
||||||
|
|
||||||
result = FarmerResult.SUCCESS;
|
result = FarmerResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,16 +120,16 @@ public class DefaultFarmerBehavior implements IFarmerBehavior{
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean putSeeds = true;
|
boolean putSeeds = true;
|
||||||
if(!farmer.addToSeedInventory(seeds, false)){
|
if(!farmer.canAddToSeeds(seeds)){
|
||||||
other.addAll(seeds);
|
other.addAll(seeds);
|
||||||
putSeeds = false;
|
putSeeds = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(farmer.addToOutputInventory(other, false)){
|
if(farmer.canAddToOutput(other)){
|
||||||
farmer.addToOutputInventory(other, true);
|
farmer.addToOutput(other);
|
||||||
|
|
||||||
if(putSeeds){
|
if(putSeeds){
|
||||||
farmer.addToSeedInventory(seeds, true);
|
farmer.addToSeeds(seeds);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
|
|
|
@ -58,12 +58,12 @@ public class MelonPumpkinFarmerBehavior implements IFarmerBehavior{
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
block.getDrops(drops, world, pos, state, 0);
|
block.getDrops(drops, world, pos, state, 0);
|
||||||
if(!drops.isEmpty()){
|
if(!drops.isEmpty()){
|
||||||
if(farmer.addToOutputInventory(drops, false)){
|
if(farmer.canAddToOutput(drops)){
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
farmer.addToOutputInventory(drops, true);
|
farmer.addToOutput(drops);
|
||||||
|
|
||||||
return FarmerResult.SUCCESS;
|
return FarmerResult.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,16 +53,16 @@ public class NetherWartFarmerBehavior implements IFarmerBehavior{
|
||||||
NonNullList<ItemStack> drops = NonNullList.create();
|
NonNullList<ItemStack> drops = NonNullList.create();
|
||||||
state.getBlock().getDrops(drops, world, pos, state, 0);
|
state.getBlock().getDrops(drops, world, pos, state, 0);
|
||||||
if(!drops.isEmpty()){
|
if(!drops.isEmpty()){
|
||||||
boolean toInput = farmer.addToSeedInventory(drops, false);
|
boolean toInput = farmer.canAddToSeeds(drops);
|
||||||
if(toInput || farmer.addToOutputInventory(drops, false)){
|
if(toInput || farmer.canAddToOutput(drops)){
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
world.setBlockToAir(pos);
|
world.setBlockToAir(pos);
|
||||||
|
|
||||||
if(toInput){
|
if(toInput){
|
||||||
farmer.addToSeedInventory(drops, true);
|
farmer.addToSeeds(drops);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
farmer.addToOutputInventory(drops, true);
|
farmer.addToOutput(drops);
|
||||||
}
|
}
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
farmer.extractEnergy(use);
|
||||||
|
|
|
@ -58,12 +58,12 @@ public class ReedFarmerBehavior implements IFarmerBehavior{
|
||||||
upState.getBlock().getDrops(drops, world, pos, state, 0);
|
upState.getBlock().getDrops(drops, world, pos, state, 0);
|
||||||
|
|
||||||
if(!drops.isEmpty()){
|
if(!drops.isEmpty()){
|
||||||
if(farmer.addToOutputInventory(drops, false)){
|
if(farmer.canAddToOutput(drops)){
|
||||||
world.playEvent(2001, up, Block.getStateId(upState));
|
world.playEvent(2001, up, Block.getStateId(upState));
|
||||||
world.setBlockToAir(up);
|
world.setBlockToAir(up);
|
||||||
|
|
||||||
farmer.extractEnergy(use);
|
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.
|
result = FarmerResult.STOP_PROCESSING; //Success no longer makes it not replant, and the plant logic seems sketchy right after harvesting. This works tho.
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,19 +79,19 @@ public abstract class ExUPlantFarmerBehavior implements IFarmerBehavior{
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
ResourceLocation itemReg = stack.getItem().getRegistryName();
|
ResourceLocation itemReg = stack.getItem().getRegistryName();
|
||||||
if(itemReg != null && this.getPlantName().equals(itemReg.toString())){
|
if(itemReg != null && this.getPlantName().equals(itemReg.toString())){
|
||||||
if(StackUtil.getStackSize(stack) <= 1){
|
if(stack.getCount() <= 1){
|
||||||
drops.remove(stack);
|
drops.remove(stack);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
StackUtil.addStackSize(stack, -1);
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(farmer.addToOutputInventory(drops, false)){
|
if(farmer.canAddToOutput(drops)){
|
||||||
farmer.addToOutputInventory(drops, true);
|
farmer.addToOutput(drops);
|
||||||
|
|
||||||
world.playEvent(2001, pos, Block.getStateId(state));
|
world.playEvent(2001, pos, Block.getStateId(state));
|
||||||
world.setBlockState(pos, block.getDefaultState(), 2);
|
world.setBlockState(pos, block.getDefaultState(), 2);
|
||||||
|
|
|
@ -10,23 +10,23 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.recipe;
|
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.ActuallyAdditionsAPI;
|
||||||
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
|
||||||
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
|
||||||
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
|
import net.minecraftforge.oredict.OreIngredient;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
|
|
||||||
public final class CrusherRecipeRegistry{
|
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(){
|
public static void registerFinally(){
|
||||||
ArrayList<String> oresNoResult = new ArrayList<String>();
|
ArrayList<String> oresNoResult = new ArrayList<String>();
|
||||||
|
@ -37,13 +37,15 @@ public final class CrusherRecipeRegistry{
|
||||||
for(SearchCase theCase : SEARCH_CASES){
|
for(SearchCase theCase : SEARCH_CASES){
|
||||||
if(ore.length() > theCase.theCase.length()){
|
if(ore.length() > theCase.theCase.length()){
|
||||||
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
|
if(ore.substring(0, theCase.theCase.length()).equals(theCase.theCase)){
|
||||||
String output = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
String outputOre = theCase.resultPreString+ore.substring(theCase.theCase.length());
|
||||||
List<ItemStack> outputs = OreDictionary.getOres(output, false);
|
List<ItemStack> outputs = OreDictionary.getOres(outputOre, false);
|
||||||
if(!ActuallyAdditionsAPI.methodHandler.addCrusherRecipes(OreDictionary.getOres(ore, false), outputs.isEmpty() ? StackUtil.getEmpty() : outputs.get(0), theCase.resultAmount, StackUtil.getEmpty(), 0, 0)){
|
ItemStack output = outputs.isEmpty() ? ItemStack.EMPTY : outputs.get(0).copy();
|
||||||
|
output.setCount(theCase.resultAmount);
|
||||||
|
if(output.isEmpty()){
|
||||||
if(!oresNoResult.contains(ore)){
|
if(!oresNoResult.contains(ore)){
|
||||||
oresNoResult.add(ore);
|
oresNoResult.add(ore);
|
||||||
}
|
}
|
||||||
}
|
} else ActuallyAdditionsAPI.addCrusherRecipe(new OreIngredient(ore), output, StackUtil.getEmpty(), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,10 +55,29 @@ public final class CrusherRecipeRegistry{
|
||||||
ArrayList<String> addedRecipes = new ArrayList<String>();
|
ArrayList<String> addedRecipes = new ArrayList<String>();
|
||||||
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
|
for(int i = recipeStartedAt; i < ActuallyAdditionsAPI.CRUSHER_RECIPES.size(); i++){
|
||||||
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(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("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);
|
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){
|
public static boolean hasBlacklistedOutput(ItemStack output, String[] config){
|
||||||
|
@ -100,30 +121,12 @@ public final class CrusherRecipeRegistry{
|
||||||
return false;
|
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){
|
public static CrusherRecipe getRecipeFromInput(ItemStack input){
|
||||||
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES){
|
for(CrusherRecipe recipe : ActuallyAdditionsAPI.CRUSHER_RECIPES)
|
||||||
if(ItemUtil.areItemsEqual(recipe.inputStack, input, true)){
|
if(recipe.matches(input)) return recipe;
|
||||||
return recipe;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
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{
|
public static class SearchCase{
|
||||||
|
|
||||||
final String theCase;
|
final String theCase;
|
||||||
|
|
|
@ -10,17 +10,18 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
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.ContainerFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
import de.ellpeck.actuallyadditions.mod.inventory.slot.SlotFilter;
|
||||||
import de.ellpeck.actuallyadditions.mod.items.ItemDrill;
|
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 de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.ResourceLocation;
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
|
|
||||||
public class FilterSettings{
|
public class FilterSettings{
|
||||||
|
|
||||||
|
@ -29,7 +30,7 @@ public class FilterSettings{
|
||||||
public final int nbtButtonId;
|
public final int nbtButtonId;
|
||||||
public final int oredictButtonId;
|
public final int oredictButtonId;
|
||||||
public final int modButtonId;
|
public final int modButtonId;
|
||||||
public final ItemStackHandlerCustom filterInventory;
|
public final ItemStackHandlerAA filterInventory;
|
||||||
public boolean isWhitelist;
|
public boolean isWhitelist;
|
||||||
public boolean respectMeta;
|
public boolean respectMeta;
|
||||||
public boolean respectNBT;
|
public boolean respectNBT;
|
||||||
|
@ -42,7 +43,7 @@ public class FilterSettings{
|
||||||
private int lastRecpectOredict;
|
private int lastRecpectOredict;
|
||||||
|
|
||||||
public FilterSettings(int slots, boolean defaultWhitelist, boolean defaultRespectMeta, boolean defaultRespectNBT, boolean defaultRespectMod, int defaultRespectOredict, int buttonIdStart){
|
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.isWhitelist = defaultWhitelist;
|
||||||
this.respectMeta = defaultRespectMeta;
|
this.respectMeta = defaultRespectMeta;
|
||||||
|
@ -57,14 +58,14 @@ public class FilterSettings{
|
||||||
this.modButtonId = buttonIdStart+4;
|
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)){
|
if(StackUtil.isValid(stack)){
|
||||||
for(int i = 0; i < filter.getSlots(); i++){
|
for(int i = 0; i < filter.getSlots(); i++){
|
||||||
ItemStack slot = filter.getStackInSlot(i);
|
ItemStack slot = filter.getStackInSlot(i);
|
||||||
|
|
||||||
if(StackUtil.isValid(slot)){
|
if(StackUtil.isValid(slot)){
|
||||||
if(SlotFilter.isFilter(slot)){
|
if(SlotFilter.isFilter(slot)){
|
||||||
ItemStackHandlerCustom inv = new ItemStackHandlerCustom(ContainerFilter.SLOT_AMOUNT);
|
ItemStackHandlerAA inv = new ItemStackHandlerAA(ContainerFilter.SLOT_AMOUNT);
|
||||||
ItemDrill.loadSlotsFromNBT(inv, slot);
|
ItemDrill.loadSlotsFromNBT(inv, slot);
|
||||||
for(int k = 0; k < inv.getSlots(); k++){
|
for(int k = 0; k < inv.getSlots(); k++){
|
||||||
ItemStack filterSlot = inv.getStackInSlot(k);
|
ItemStack filterSlot = inv.getStackInSlot(k);
|
||||||
|
|
|
@ -21,6 +21,7 @@ import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
@ -30,7 +31,7 @@ import net.minecraft.util.math.MathHelper;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
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 static final int ENERGY_USE = 1000;
|
||||||
public final CustomEnergyStorage storage;
|
public final CustomEnergyStorage storage;
|
||||||
|
@ -38,22 +39,22 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
private int currentTime;
|
private int currentTime;
|
||||||
private int oldEnergy;
|
private int oldEnergy;
|
||||||
|
|
||||||
public TileEntityAtomicReconstructor(){
|
public TileEntityAtomicReconstructor() {
|
||||||
super(1, "reconstructor");
|
super(1, "reconstructor");
|
||||||
int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue();
|
int power = ConfigIntValues.RECONSTRUCTOR_POWER.getValue();
|
||||||
int recieve = MathHelper.ceil(power * 0.016666F);
|
int recieve = MathHelper.ceil(power * 0.016666F);
|
||||||
storage = new CustomEnergyStorage(power, recieve, 0);
|
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);
|
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);
|
AssetUtil.spawnLaserWithTimeServer(world, startX, startY, startZ, endX, endY, endZ, currentLens.getColor(), 25, 0, 0.2F, 0.8F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void writeSyncableNBT(NBTTagCompound compound, NBTType type) {
|
||||||
super.writeSyncableNBT(compound, type);
|
super.writeSyncableNBT(compound, type);
|
||||||
if(type != NBTType.SAVE_BLOCK){
|
if (type != NBTType.SAVE_BLOCK) {
|
||||||
compound.setInteger("CurrentTime", this.currentTime);
|
compound.setInteger("CurrentTime", this.currentTime);
|
||||||
compound.setInteger("Counter", this.counter);
|
compound.setInteger("Counter", this.counter);
|
||||||
}
|
}
|
||||||
|
@ -61,14 +62,14 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldSyncSlots(){
|
public boolean shouldSyncSlots() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void readSyncableNBT(NBTTagCompound compound, NBTType type) {
|
||||||
super.readSyncableNBT(compound, type);
|
super.readSyncableNBT(compound, type);
|
||||||
if(type != NBTType.SAVE_BLOCK){
|
if (type != NBTType.SAVE_BLOCK) {
|
||||||
this.currentTime = compound.getInteger("CurrentTime");
|
this.currentTime = compound.getInteger("CurrentTime");
|
||||||
this.counter = compound.getInteger("Counter");
|
this.counter = compound.getInteger("Counter");
|
||||||
}
|
}
|
||||||
|
@ -76,22 +77,21 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity(){
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!this.world.isRemote){
|
if (!this.world.isRemote) {
|
||||||
if(!this.isRedstonePowered && !this.isPulseMode){
|
if (!this.isRedstonePowered && !this.isPulseMode) {
|
||||||
if(this.currentTime > 0){
|
if (this.currentTime > 0) {
|
||||||
this.currentTime--;
|
this.currentTime--;
|
||||||
if(this.currentTime <= 0){
|
if (this.currentTime <= 0) {
|
||||||
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
|
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
this.currentTime = 100;
|
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.oldEnergy = this.storage.getEnergyStored();
|
||||||
this.world.updateComparatorOutputLevel(pos, InitBlocks.blockAtomicReconstructor);
|
this.world.updateComparatorOutputLevel(pos, InitBlocks.blockAtomicReconstructor);
|
||||||
}
|
}
|
||||||
|
@ -100,88 +100,85 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Lens getLens(){
|
public Lens getLens() {
|
||||||
if(StackUtil.isValid(this.slots.getStackInSlot(0))){
|
Item item = inv.getStackInSlot(0).getItem();
|
||||||
if(this.slots.getStackInSlot(0).getItem() instanceof ILensItem){
|
if (item instanceof ILensItem) return ((ILensItem) item).getLens();
|
||||||
return ((ILensItem)this.slots.getStackInSlot(0).getItem()).getLens();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.counter >= 500 ? ActuallyAdditionsAPI.lensDisruption : ActuallyAdditionsAPI.lensDefaultConversion;
|
return this.counter >= 500 ? ActuallyAdditionsAPI.lensDisruption : ActuallyAdditionsAPI.lensDefaultConversion;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EnumFacing getOrientation(){
|
public EnumFacing getOrientation() {
|
||||||
IBlockState state = this.world.getBlockState(this.pos);
|
IBlockState state = this.world.getBlockState(this.pos);
|
||||||
return WorldUtil.getDirectionByPistonRotation(state);
|
return WorldUtil.getDirectionByPistonRotation(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockPos getPosition(){
|
public BlockPos getPosition() {
|
||||||
return this.pos;
|
return this.pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getX(){
|
public int getX() {
|
||||||
return this.getPos().getX();
|
return this.getPos().getX();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getY(){
|
public int getY() {
|
||||||
return this.getPos().getY();
|
return this.getPos().getY();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getZ(){
|
public int getZ() {
|
||||||
return this.getPos().getZ();
|
return this.getPos().getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorldObject(){
|
public World getWorldObject() {
|
||||||
return this.getWorld();
|
return this.getWorld();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void extractEnergy(int amount){
|
public void extractEnergy(int amount) {
|
||||||
this.storage.extractEnergyInternal(amount, false);
|
this.storage.extractEnergyInternal(amount, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getEnergy(){
|
public int getEnergy() {
|
||||||
return this.storage.getEnergyStored();
|
return this.storage.getEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomEnergyStorage getEnergyStorage(){
|
public CustomEnergyStorage getEnergyStorage() {
|
||||||
return this.storage;
|
return this.storage;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean needsHoldShift(){
|
public boolean needsHoldShift() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRedstoneToggle(){
|
public boolean isRedstoneToggle() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activateOnPulse(){
|
public void activateOnPulse() {
|
||||||
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
|
ActuallyAdditionsAPI.methodHandler.invokeReconstructor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
public IEnergyStorage getEnergyStorage(EnumFacing facing) {
|
||||||
return this.storage;
|
return this.storage;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
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.items.ItemBattery;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
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.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISharingEnergyProvider{
|
||||||
|
|
||||||
private int lastEnergyStored;
|
private int lastEnergyStored;
|
||||||
|
@ -33,7 +33,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IEnergyStorage getEnergyStorage(EnumFacing facing){
|
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(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery){
|
||||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||||
return stack.getCapability(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);
|
IEnergyStorage storage = this.getEnergyStorage(null);
|
||||||
if(storage != null){
|
if(storage != null){
|
||||||
ItemStack stack = this.slots.getStackInSlot(0);
|
ItemStack stack = this.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)){
|
if(StackUtil.isValid(stack) && ItemUtil.isEnabled(stack)){
|
||||||
if(storage.getEnergyStored() > 0){
|
if(storage.getEnergyStored() > 0){
|
||||||
List<TileEntityBatteryBox> tiles = new ArrayList<TileEntityBatteryBox>();
|
List<TileEntityBatteryBox> tiles = new ArrayList<TileEntityBatteryBox>();
|
||||||
|
@ -67,7 +67,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
|
||||||
int maxPer = storage.extractEnergy(energyPer, true);
|
int maxPer = storage.extractEnergy(energyPer, true);
|
||||||
|
|
||||||
for(TileEntityBatteryBox tile : tiles){
|
for(TileEntityBatteryBox tile : tiles){
|
||||||
ItemStack battery = tile.slots.getStackInSlot(0);
|
ItemStack battery = tile.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)){
|
if(StackUtil.isValid(battery) && !ItemUtil.isEnabled(battery)){
|
||||||
if(tile.hasCapability(CapabilityEnergy.ENERGY, null)){
|
if(tile.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||||
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null);
|
IEnergyStorage cap = tile.getCapability(CapabilityEnergy.ENERGY, null);
|
||||||
|
@ -119,7 +119,7 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void activateOnPulse(){
|
public void activateOnPulse(){
|
||||||
ItemStack stack = this.slots.getStackInSlot(0);
|
ItemStack stack = this.inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
ItemUtil.changeEnabled(stack);
|
ItemUtil.changeEnabled(stack);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
|
@ -144,13 +144,13 @@ public class TileEntityBatteryBox extends TileEntityInventoryBase implements ISh
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int slot, ItemStack stack){
|
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
|
||||||
return StackUtil.isValid(stack) && stack.getItem() instanceof ItemBattery;
|
return stack.getItem() instanceof ItemBattery;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -66,8 +66,8 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
List<Item> types = null;
|
List<Item> types = null;
|
||||||
|
|
||||||
if(this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
|
if(this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
|
||||||
for(int i = 0; i < this.slots.getSlots(); i++){
|
for(int i = 0; i < this.inv.getSlots(); i++){
|
||||||
ItemStack stack = this.slots.getStackInSlot(i);
|
ItemStack stack = this.inv.getStackInSlot(i);
|
||||||
if(StackUtil.isValid(stack)){
|
if(StackUtil.isValid(stack)){
|
||||||
Item item = stack.getItem();
|
Item item = stack.getItem();
|
||||||
if(isValidItem(stack) && (types == null || !types.contains(item))){
|
if(isValidItem(stack) && (types == null || !types.contains(item))){
|
||||||
|
@ -76,7 +76,7 @@ public class TileEntityBioReactor extends TileEntityInventoryBase implements ISh
|
||||||
}
|
}
|
||||||
types.add(item);
|
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
|
@Override
|
||||||
public boolean canExtractItem(int index, ItemStack stack){
|
public boolean canExtract(int index, ItemStack stack, boolean byAutomation){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
public boolean canInsert(int index, ItemStack stack, boolean fromAutomation){
|
||||||
return isValidItem(stack);
|
return isValidItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,9 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack) {
|
public boolean canInsert(int slot, ItemStack stack, boolean automation) {
|
||||||
return true;
|
if(isPlacer) return true;
|
||||||
|
else return !automation;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void doWork() {
|
private void doWork() {
|
||||||
|
@ -87,25 +88,18 @@ public class TileEntityBreaker extends TileEntityInventoryBase {
|
||||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, world, breakCoords);
|
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, world, breakCoords);
|
||||||
|
|
||||||
if (chance > 0 && world.rand.nextFloat() <= chance) {
|
if (chance > 0 && world.rand.nextFloat() <= chance) {
|
||||||
if (StackUtil.canAddAll(slots, drops)) {
|
if (StackUtil.canAddAll(inv, drops, false)) {
|
||||||
world.destroyBlock(breakCoords, false);
|
world.destroyBlock(breakCoords, false);
|
||||||
StackUtil.addAll(slots, drops);
|
StackUtil.addAll(inv, drops, false);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (this.isPlacer) {
|
} else if (this.isPlacer) {
|
||||||
int theSlot = WorldUtil.findFirstFilledSlot(slots);
|
int slot = StackUtil.findFirstFilled(inv);
|
||||||
this.slots.setStackInSlot(theSlot, WorldUtil.useItemAtSide(side, world, pos, slots.getStackInSlot(theSlot)));
|
if(slot == -1) return;
|
||||||
if (!StackUtil.isValid(slots.getStackInSlot(theSlot))) {
|
this.inv.setStackInSlot(slot, WorldUtil.useItemAtSide(side, world, pos, inv.getStackInSlot(slot)));
|
||||||
this.slots.setStackInSlot(theSlot, StackUtil.getEmpty());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int slot, ItemStack stack) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRedstoneToggle() {
|
public boolean isRedstoneToggle() {
|
||||||
|
|
|
@ -84,14 +84,14 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!this.world.isRemote){
|
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){
|
if(this.storage.getEnergyStored() >= ENERGY_USE){
|
||||||
this.currentProcessTime++;
|
this.currentProcessTime++;
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
if(this.currentProcessTime >= TIME){
|
if(this.currentProcessTime >= TIME){
|
||||||
this.currentProcessTime = 0;
|
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.tank.fillInternal(new FluidStack(InitFluids.fluidCanolaOil, PRODUCE), true);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
|
@ -111,17 +111,17 @@ public class TileEntityCanolaPress extends TileEntityInventoryBase implements IS
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean canInsert(int slot, ItemStack stack, boolean fromAutomation){
|
||||||
return (i == 0 && stack.getItem() == InitItems.itemMisc && stack.getItemDamage() == TheMiscItems.CANOLA.ordinal());
|
return (slot == 0 && isCanola(stack));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCanola(int slot){
|
public static boolean isCanola(ItemStack stack){
|
||||||
return StackUtil.isValid(this.slots.getStackInSlot(slot)) && this.slots.getStackInSlot(slot).getItem() == InitItems.itemMisc && this.slots.getStackInSlot(slot).getItemDamage() == TheMiscItems.CANOLA.ordinal();
|
return stack.getItem() == InitItems.itemMisc && stack.getMetadata() == TheMiscItems.CANOLA.ordinal();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
||||||
return false;
|
return !byAutomation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -76,17 +75,16 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
||||||
this.storage.receiveEnergyInternal(PRODUCE, false);
|
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()){
|
ItemStack stack = inv.getStackInSlot(0);
|
||||||
int burnTime = TileEntityFurnace.getItemBurnTime(this.slots.getStackInSlot(0));
|
int burn = TileEntityFurnace.getItemBurnTime(stack);
|
||||||
this.maxBurnTime = burnTime;
|
if(!this.isRedstonePowered && this.currentBurnTime <= 0 && burn > 0 && this.storage.getEnergyStored() < this.storage.getMaxEnergyStored()){
|
||||||
this.currentBurnTime = burnTime;
|
this.maxBurnTime = burn;
|
||||||
|
this.currentBurnTime = burn;
|
||||||
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -1, true));
|
stack.shrink(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){
|
if(flag != this.currentBurnTime > 0 || this.lastCompare != this.getComparatorStrength()){
|
||||||
this.lastCompare = this.getComparatorStrength();
|
this.lastCompare = this.getComparatorStrength();
|
||||||
|
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,13 +103,14 @@ public class TileEntityCoalGenerator extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean canInsert(int i, ItemStack stack, boolean fromAutomation){
|
||||||
return TileEntityFurnace.getItemBurnTime(stack) > 0;
|
return TileEntityFurnace.getItemBurnTime(stack) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean byAutomation){
|
||||||
return TileEntityFurnace.getItemBurnTime(this.slots.getStackInSlot(0)) <= 0;
|
if(!byAutomation) return true;
|
||||||
|
return TileEntityFurnace.getItemBurnTime(this.inv.getStackInSlot(0)) <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -125,15 +125,15 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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());
|
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(){
|
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;
|
int toAdd = 2;
|
||||||
if(toAdd <= COFFEE_CACHE_MAX_AMOUNT-this.coffeeCacheAmount){
|
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;
|
this.coffeeCacheAmount += toAdd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
|
|
||||||
public void brew(){
|
public void brew(){
|
||||||
if(!this.world.isRemote){
|
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.storage.getEnergyStored() >= ENERGY_USED){
|
||||||
if(this.brewTime%30 == 0){
|
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);
|
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){
|
if(this.brewTime >= TIME_USED){
|
||||||
this.brewTime = 0;
|
this.brewTime = 0;
|
||||||
ItemStack output = new ItemStack(InitItems.itemCoffee);
|
ItemStack output = new ItemStack(InitItems.itemCoffee);
|
||||||
for(int i = 3; i < this.slots.getSlots(); i++){
|
for(int i = 3; i < this.inv.getSlots(); i++){
|
||||||
if(StackUtil.isValid(this.slots.getStackInSlot(i))){
|
if(StackUtil.isValid(this.inv.getStackInSlot(i))){
|
||||||
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.slots.getStackInSlot(i));
|
CoffeeIngredient ingredient = ItemCoffee.getIngredientFromStack(this.inv.getStackInSlot(i));
|
||||||
if(ingredient != null){
|
if(ingredient != null){
|
||||||
if(ingredient.effect(output)){
|
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.inv.setStackInSlot(SLOT_OUTPUT, output.copy());
|
||||||
this.slots.setStackInSlot(SLOT_INPUT, StackUtil.addStackSize(this.slots.getStackInSlot(SLOT_INPUT), -1));
|
this.inv.getStackInSlot(SLOT_INPUT).shrink(1);
|
||||||
this.coffeeCacheAmount -= CACHE_USE;
|
this.coffeeCacheAmount -= CACHE_USE;
|
||||||
this.tank.drainInternal(WATER_USE, true);
|
this.tank.drainInternal(WATER_USE, true);
|
||||||
}
|
}
|
||||||
|
@ -176,8 +177,8 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
||||||
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.slots.getSlots() && ItemCoffee.getIngredientFromStack(stack) == null);
|
return slot == SLOT_OUTPUT || (slot >= 3 && slot < this.inv.getSlots() && ItemCoffee.getIngredientFromStack(stack) == null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -63,14 +63,15 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!this.world.isRemote){
|
if(!this.world.isRemote){
|
||||||
boolean theFlag = this.conversionTime > 0;
|
boolean theFlag = this.conversionTime > 0;
|
||||||
|
ItemStack input = inv.getStackInSlot(0);
|
||||||
if(StackUtil.isValid(this.slots.getStackInSlot(0))){
|
if(StackUtil.isValid(input)){
|
||||||
CompostRecipe recipe = getRecipeForInput(this.slots.getStackInSlot(0));
|
CompostRecipe recipe = getRecipeForInput(input);
|
||||||
if(recipe != null){
|
if(recipe != null){
|
||||||
this.conversionTime++;
|
this.conversionTime++;
|
||||||
if(this.conversionTime >= COMPOST_TIME_TICKS){
|
if(this.conversionTime >= COMPOST_TIME_TICKS){
|
||||||
ItemStack output = recipe.output.copy();
|
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.conversionTime = 0;
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
@ -87,12 +88,12 @@ public class TileEntityCompost extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
||||||
return getRecipeForInput(stack) != null;
|
return getRecipeForInput(stack) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
||||||
return getRecipeForInput(stack) == null;
|
return getRecipeForInput(stack) == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
@ -19,8 +20,6 @@ import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.NonNullList;
|
import net.minecraft.util.NonNullList;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||||
|
|
||||||
|
@ -89,10 +88,10 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||||
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, coordsBlock);
|
float chance = WorldUtil.fireFakeHarvestEventsForDropChance(drops, this.world, coordsBlock);
|
||||||
|
|
||||||
if(chance > 0 && this.world.rand.nextFloat() <= chance){
|
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.playEvent(2001, coordsBlock, Block.getStateId(this.world.getBlockState(coordsBlock)));
|
||||||
this.world.setBlockToAir(coordsBlock);
|
this.world.setBlockToAir(coordsBlock);
|
||||||
WorldUtil.addToInventory(this.slots, drops, true);
|
StackUtil.addAll(this.inv, drops, false);
|
||||||
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
this.storage.extractEnergyInternal(ENERGY_USE, false);
|
||||||
this.markDirty();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
@ -103,17 +102,16 @@ public class TileEntityDirectionalBreaker extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean canInsert(int slot, ItemStack stack, boolean automation){
|
||||||
return false;
|
return !automation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getEnergyScaled(int i){
|
public int getEnergyScaled(int i){
|
||||||
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@ import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemBlock;
|
import net.minecraft.item.ItemBlock;
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
|
@ -34,12 +33,12 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!this.world.isRemote){
|
if(!this.world.isRemote){
|
||||||
if(StackUtil.isValid(this.slots.getStackInSlot(0)) && !this.isRedstonePowered){
|
if(StackUtil.isValid(this.inv.getStackInSlot(0)) && !this.isRedstonePowered){
|
||||||
IDisplayStandItem item = this.convertToDisplayStandItem(this.slots.getStackInSlot(0).getItem());
|
IDisplayStandItem item = this.convertToDisplayStandItem(this.inv.getStackInSlot(0).getItem());
|
||||||
if(item != null){
|
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(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);
|
this.storage.extractEnergyInternal(energy, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,11 +56,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
|
||||||
super.writeSyncableNBT(compound, type);
|
super.writeSyncableNBT(compound, type);
|
||||||
|
@ -87,11 +81,6 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int index, ItemStack stack){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CustomEnergyStorage getEnergyStorage(){
|
public CustomEnergyStorage getEnergyStorage(){
|
||||||
return this.storage;
|
return this.storage;
|
||||||
|
@ -103,7 +92,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxStackSizePerSlot(int slot){
|
public int getMaxStackSize(int slot){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,26 +58,24 @@ public class TileEntityDropper extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doWork(){
|
private void doWork(){
|
||||||
ItemStack theoreticalRemove = this.removeFromInventory(false);
|
ItemStack theoreticalRemove = this.removeFromInventory(false);
|
||||||
if(StackUtil.isValid(theoreticalRemove)){
|
if(StackUtil.isValid(theoreticalRemove)){
|
||||||
IBlockState state = this.world.getBlockState(this.pos);
|
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);
|
this.removeFromInventory(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack removeFromInventory(boolean actuallyDo){
|
public ItemStack removeFromInventory(boolean actuallyDo){
|
||||||
for(int i = 0; i < this.slots.getSlots(); i++){
|
for(int i = 0; i < this.inv.getSlots(); i++){
|
||||||
if(StackUtil.isValid(this.slots.getStackInSlot(i))){
|
if(StackUtil.isValid(this.inv.getStackInSlot(i))){
|
||||||
ItemStack slot = this.slots.getStackInSlot(i).copy();
|
ItemStack slot = this.inv.getStackInSlot(i).copy();
|
||||||
if(actuallyDo){
|
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();
|
this.markDirty();
|
||||||
}
|
}
|
||||||
return slot;
|
return slot;
|
||||||
|
@ -86,11 +84,6 @@ public class TileEntityDropper extends TileEntityInventoryBase{
|
||||||
return StackUtil.getEmpty();
|
return StackUtil.getEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isRedstoneToggle(){
|
public boolean isRedstoneToggle(){
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
|
|
||||||
if(!this.world.isRemote){
|
if(!this.world.isRemote){
|
||||||
List<EmpowererRecipe> recipes = getRecipesForInput(this.slots.getStackInSlot(0));
|
List<EmpowererRecipe> recipes = getRecipesForInput(this.inv.getStackInSlot(0));
|
||||||
if(!recipes.isEmpty()){
|
if(!recipes.isEmpty()){
|
||||||
for(EmpowererRecipe recipe : recipes){
|
for(EmpowererRecipe recipe : recipes){
|
||||||
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
|
TileEntityDisplayStand[] modifierStands = this.getFittingModifiers(recipe, recipe.time);
|
||||||
|
@ -67,7 +67,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
||||||
stand.storage.extractEnergyInternal(recipe.energyPerStand/recipe.time, false);
|
stand.storage.extractEnergyInternal(recipe.energyPerStand/recipe.time, false);
|
||||||
|
|
||||||
if(done){
|
if(done){
|
||||||
stand.slots.decrStackSize(0, 1);
|
stand.inv.getStackInSlot(0).shrink(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
||||||
if(done){
|
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);
|
((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.markDirty();
|
||||||
|
|
||||||
this.processTime = 0;
|
this.processTime = 0;
|
||||||
|
@ -112,7 +112,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
||||||
|
|
||||||
if(tile instanceof TileEntityDisplayStand){
|
if(tile instanceof TileEntityDisplayStand){
|
||||||
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
|
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
|
||||||
ItemStack standItem = stand.slots.getStackInSlot(0);
|
ItemStack standItem = stand.inv.getStackInSlot(0);
|
||||||
int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true);
|
int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true);
|
||||||
if(stand.storage.getEnergyStored() >= recipe.energyPerStand/powerDivider && containPlace != -1){
|
if(stand.storage.getEnergyStored() >= recipe.energyPerStand/powerDivider && containPlace != -1){
|
||||||
modifierStands[i] = stand;
|
modifierStands[i] = stand;
|
||||||
|
@ -158,17 +158,17 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int index, ItemStack stack){
|
public boolean canInsert(int index, ItemStack stack, boolean automation){
|
||||||
return !getRecipesForInput(stack).isEmpty();
|
return !automation || !getRecipesForInput(stack).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int index, ItemStack stack){
|
public boolean canExtract(int index, ItemStack stack, boolean automation){
|
||||||
return getRecipesForInput(stack).isEmpty();
|
return !automation || getRecipesForInput(stack).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxStackSizePerSlot(int slot){
|
public int getMaxStackSize(int slot){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,12 @@
|
||||||
package de.ellpeck.actuallyadditions.mod.tile;
|
package de.ellpeck.actuallyadditions.mod.tile;
|
||||||
|
|
||||||
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
|
||||||
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraftforge.energy.CapabilityEnergy;
|
import net.minecraftforge.energy.CapabilityEnergy;
|
||||||
import net.minecraftforge.energy.IEnergyStorage;
|
import net.minecraftforge.energy.IEnergyStorage;
|
||||||
import net.minecraftforge.fml.relauncher.Side;
|
|
||||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class TileEntityEnergizer extends TileEntityInventoryBase{
|
public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||||
|
|
||||||
|
@ -44,13 +43,13 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||||
public void updateEntity(){
|
public void updateEntity(){
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
if(!this.world.isRemote){
|
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){
|
if(this.storage.getEnergyStored() > 0){
|
||||||
int received = 0;
|
int received = 0;
|
||||||
boolean canTakeUp = false;
|
boolean canTakeUp = false;
|
||||||
|
|
||||||
if(this.slots.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
if(this.inv.getStackInSlot(0).hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||||
IEnergyStorage cap = this.slots.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null);
|
IEnergyStorage cap = this.inv.getStackInSlot(0).getCapability(CapabilityEnergy.ENERGY, null);
|
||||||
if(cap != null){
|
if(cap != null){
|
||||||
received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
|
received = cap.receiveEnergy(this.storage.getEnergyStored(), false);
|
||||||
canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored();
|
canTakeUp = cap.getEnergyStored() >= cap.getMaxEnergyStored();
|
||||||
|
@ -61,8 +60,8 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
if(canTakeUp){
|
if(canTakeUp){
|
||||||
this.slots.setStackInSlot(1, this.slots.getStackInSlot(0).copy());
|
this.inv.setStackInSlot(1, this.inv.getStackInSlot(0).copy());
|
||||||
this.slots.setStackInSlot(0, StackUtil.addStackSize(this.slots.getStackInSlot(0), -1));
|
this.inv.setStackInSlot(0, StackUtil.shrink(this.inv.getStackInSlot(0), 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,16 +73,15 @@ public class TileEntityEnergizer extends TileEntityInventoryBase{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isItemValidForSlot(int i, ItemStack stack){
|
public boolean canInsert(int i, ItemStack stack, boolean automation){
|
||||||
return i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null));
|
return !automation || (i == 0 && (stack.hasCapability(CapabilityEnergy.ENERGY, null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canExtractItem(int slot, ItemStack stack){
|
public boolean canExtract(int slot, ItemStack stack, boolean automation){
|
||||||
return slot == 1;
|
return !EnchantmentHelper.hasBindingCurse(stack) && !automation || (slot == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public int getEnergyScaled(int i){
|
public int getEnergyScaled(int i){
|
||||||
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
return this.storage.getEnergyStored()*i/this.storage.getMaxEnergyStored();
|
||||||
}
|
}
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue