Cleanup and some more validation checks ~

This commit is contained in:
Ellpeck 2016-11-16 20:31:16 +01:00
parent 2ab8288282
commit 36c176dd2e
95 changed files with 308 additions and 355 deletions

View file

@ -116,7 +116,7 @@ public class BlockAtomicReconstructor extends BlockContainerBase implements IHud
if(tile instanceof TileEntityAtomicReconstructor){ if(tile instanceof TileEntityAtomicReconstructor){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0); ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
String strg; String strg;
if(slot == null){ if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noLens"); strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noLens");
} }
else{ else{

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase; import de.ellpeck.actuallyadditions.mod.blocks.base.ItemBlockBase;
import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors; import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -72,7 +73,7 @@ public class BlockColoredLamp extends BlockBase{
return true; return true;
} }
if(stack != null){ if(StackUtil.isValid(stack)){
//Changing Colors //Changing Colors
int[] oreIDs = OreDictionary.getOreIDs(stack); int[] oreIDs = OreDictionary.getOreIDs(stack);
if(oreIDs.length > 0){ if(oreIDs.length > 0){

View file

@ -89,13 +89,13 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
TileEntityCompost compost = (TileEntityCompost)tile; TileEntityCompost compost = (TileEntityCompost)tile;
ItemStack slot = compost.getStackInSlot(0); ItemStack slot = compost.getStackInSlot(0);
CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot); CompostRecipe recipeIn = TileEntityCompost.getRecipeForInput(slot);
if(slot == null || recipeIn != null){ if(!StackUtil.isValid(slot) || recipeIn != null){
if(stackPlayer != null){ 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 = Math.min(StackUtil.getStackSize(recipeHand.input), StackUtil.getStackSize(stackPlayer)); int maxAdd = Math.min(StackUtil.getStackSize(recipeHand.input), StackUtil.getStackSize(stackPlayer));
if(slot == null){ if(!StackUtil.isValid(slot)){
ItemStack stackToAdd = stackPlayer.copy(); ItemStack stackToAdd = stackPlayer.copy();
stackToAdd = StackUtil.setStackSize(stackToAdd, maxAdd); stackToAdd = StackUtil.setStackSize(stackToAdd, maxAdd);
compost.setInventorySlotContents(0, stackToAdd); compost.setInventorySlotContents(0, stackToAdd);
@ -116,7 +116,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
} }
} }
else{ else{
if(stackPlayer == null){ if(!StackUtil.isValid(stackPlayer)){
player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy()); player.inventory.setInventorySlotContents(player.inventory.currentItem, slot.copy());
compost.setInventorySlotContents(0, null); compost.setInventorySlotContents(0, null);
return true; return true;
@ -163,7 +163,7 @@ public class BlockCompost extends BlockContainerBase implements IHudDisplay{
if(tile instanceof TileEntityCompost){ if(tile instanceof TileEntityCompost){
ItemStack slot = ((TileEntityCompost)tile).getStackInSlot(0); ItemStack slot = ((TileEntityCompost)tile).getStackInSlot(0);
String strg; String strg;
if(slot == null){ if(!StackUtil.isValid(slot)){
strg = "Empty"; strg = "Empty";
} }
else{ else{

View file

@ -33,7 +33,7 @@ public class BlockCrystal extends BlockBase{
public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values(); public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values();
private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_CRYSTALS.length-1); private static final PropertyInteger META = PropertyInteger.create("meta", 0, ALL_CRYSTALS.length-1);
private boolean isEmpowered; private final boolean isEmpowered;
public BlockCrystal(String name, boolean isEmpowered){ public BlockCrystal(String name, boolean isEmpowered){
super(Material.ROCK, name); super(Material.ROCK, name);

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.base.BlockContainerBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDistributorItem; import de.ellpeck.actuallyadditions.mod.tile.TileEntityDistributorItem;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType; import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
@ -59,7 +60,7 @@ public class BlockDistributorItem extends BlockContainerBase implements IHudDisp
ItemStack slot = distributor.getStackInSlot(0); ItemStack slot = distributor.getStackInSlot(0);
String strg; String strg;
if(slot == null){ if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noItem"); strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noItem");
} }
else{ else{

View file

@ -19,6 +19,7 @@ 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.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
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;
@ -129,7 +130,7 @@ public class BlockGiantChest extends BlockContainerBase{
//Destroy the keeper //Destroy the keeper
if(i != place){ if(i != place){
NBTTagCompound compound = new NBTTagCompound(); NBTTagCompound compound = new NBTTagCompound();
if(slots[i] != null){ if(StackUtil.isValid(slots[i])){
slots[i].writeToNBT(compound); slots[i].writeToNBT(compound);
} }
list.appendTag(compound); list.appendTag(compound);
@ -138,7 +139,7 @@ public class BlockGiantChest extends BlockContainerBase{
if(list.tagCount() > 0){ if(list.tagCount() > 0){
ItemStack stackInQuestion = drops.get(0); ItemStack stackInQuestion = drops.get(0);
if(stackInQuestion != null){ if(StackUtil.isValid(stackInQuestion)){
if(stackInQuestion.getTagCompound() == null){ if(stackInQuestion.getTagCompound() == null){
stackInQuestion.setTagCompound(new NBTTagCompound()); stackInQuestion.setTagCompound(new NBTTagCompound());
} }

View file

@ -195,7 +195,7 @@ public class BlockLaserRelay extends BlockContainerBase implements IHudDisplay{
minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(strg, resolution.getScaledWidth()/2+5, resolution.getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
String expl; String expl;
if(stack != null && stack.getItem() instanceof ItemCompass){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemCompass){
expl = TextFormatting.GREEN+"Right-Click to increase! \nSneak-Right-Click to decrease!"; expl = TextFormatting.GREEN+"Right-Click to increase! \nSneak-Right-Click to decrease!";
} }
else{ else{

View file

@ -53,7 +53,7 @@ public class BlockPlayerInterface extends BlockContainerBase implements IHudDisp
@Override @Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){ public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase player, ItemStack stack){
TileEntity tile = world.getTileEntity(pos); TileEntity tile = world.getTileEntity(pos);
if(tile != null && tile instanceof TileEntityPlayerInterface){ if(tile instanceof TileEntityPlayerInterface){
TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile; TileEntityPlayerInterface face = (TileEntityPlayerInterface)tile;
if(face.connectedPlayer == null){ if(face.connectedPlayer == null){
face.connectedPlayer = player.getUniqueID(); face.connectedPlayer = player.getUniqueID();

View file

@ -182,8 +182,8 @@ public class BlockTinyTorch extends BlockBase{
if(enumfacing.getAxis().isHorizontal()){ if(enumfacing.getAxis().isHorizontal()){
EnumFacing enumfacing1 = enumfacing.getOpposite(); EnumFacing enumfacing1 = enumfacing.getOpposite();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]); worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D);
} }
else{ else{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D); worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D);

View file

@ -201,7 +201,7 @@ public abstract class BlockContainerBase extends BlockContainer implements ItemB
} }
protected boolean checkFailUseItemOnTank(EntityPlayer player, ItemStack heldItem, FluidTank tank){ protected boolean checkFailUseItemOnTank(EntityPlayer player, ItemStack heldItem, FluidTank tank){
return heldItem == null || !FluidUtil.interactWithFluidHandler(heldItem, tank, player); return !StackUtil.isValid(heldItem) || !FluidUtil.interactWithFluidHandler(heldItem, tank, player);
} }
@Override @Override

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand; import de.ellpeck.actuallyadditions.mod.tile.TileEntityDisplayStand;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderDisplayStand extends TileEntitySpecialRenderer{
} }
ItemStack stack = ((TileEntityDisplayStand)tile).getStackInSlot(0); ItemStack stack = ((TileEntityDisplayStand)tile).getStackInSlot(0);
if(stack != null){ 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);

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer; import de.ellpeck.actuallyadditions.mod.tile.TileEntityEmpowerer;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer{
} }
ItemStack stack = ((TileEntityEmpowerer)tile).getStackInSlot(0); ItemStack stack = ((TileEntityEmpowerer)tile).getStackInSlot(0);
if(stack != null){ 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);

View file

@ -14,6 +14,7 @@ package de.ellpeck.actuallyadditions.mod.blocks.render;
import de.ellpeck.actuallyadditions.api.lens.ILensItem; import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor; import de.ellpeck.actuallyadditions.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
} }
ItemStack stack = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0); ItemStack stack = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
if(stack != null && stack.getItem() instanceof ILensItem){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F); GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F); GlStateManager.rotate(180F, 0.0F, 0.0F, 1.0F);

View file

@ -16,6 +16,7 @@ import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiBooklet;
import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage; import de.ellpeck.actuallyadditions.mod.booklet.gui.GuiPage;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
@ -77,7 +78,7 @@ public class BookmarkButton extends GuiButton{
if(this.assignedPage != null){ if(this.assignedPage != null){
ItemStack display = this.assignedPage.getChapter().getDisplayItemStack(); ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
if(display != null){ if(StackUtil.isValid(display)){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
AssetUtil.renderStackToGui(display, this.xPosition+2, this.yPosition+1, 0.725F); AssetUtil.renderStackToGui(display, this.xPosition+2, this.yPosition+1, 0.725F);
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.booklet.button; package de.ellpeck.actuallyadditions.mod.booklet.button;
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.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
@ -40,7 +41,7 @@ public class EntryButton extends GuiButton{
this.mouseDragged(minecraft, mouseX, mouseY); this.mouseDragged(minecraft, mouseX, mouseY);
int textOffsetX = 0; int textOffsetX = 0;
if(this.stackToRender != null){ if(StackUtil.isValid(this.stackToRender)){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
AssetUtil.renderStackToGui(this.stackToRender, this.xPosition-4, this.yPosition, 0.725F); AssetUtil.renderStackToGui(this.stackToRender, this.xPosition-4, this.yPosition, 0.725F);
GlStateManager.popMatrix(); GlStateManager.popMatrix();

View file

@ -10,7 +10,6 @@
package de.ellpeck.actuallyadditions.mod.booklet.chapter; package de.ellpeck.actuallyadditions.mod.booklet.chapter;
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;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.booklet.chapter;
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;
import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe; import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.booklet.page.BookletPage;
import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe; import de.ellpeck.actuallyadditions.mod.booklet.page.PageCrusherRecipe;
import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting; import de.ellpeck.actuallyadditions.mod.crafting.CrusherCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;

View file

@ -14,8 +14,8 @@ 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;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage; import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -41,6 +41,41 @@ public class BookletEntry implements IBookletEntry{
this.color = TextFormatting.RESET; this.color = TextFormatting.RESET;
} }
@SideOnly(Side.CLIENT)
private static boolean fitsFilter(IBookletPage page, String searchBarText){
Minecraft mc = Minecraft.getMinecraft();
List<ItemStack> items = new ArrayList<ItemStack>();
page.getItemStacksForPage(items);
if(!items.isEmpty()){
for(ItemStack stack : items){
if(StackUtil.isValid(stack)){
List<String> tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
for(String strg : tooltip){
if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){
return true;
}
}
}
}
}
List<FluidStack> fluids = new ArrayList<FluidStack>();
page.getFluidStacksForPage(fluids);
if(!fluids.isEmpty()){
for(FluidStack stack : fluids){
if(stack != null){
String strg = stack.getLocalizedName();
if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){
return true;
}
}
}
}
return false;
}
@Override @Override
public List<IBookletChapter> getAllChapters(){ public List<IBookletChapter> getAllChapters(){
return this.chapters; return this.chapters;
@ -94,41 +129,6 @@ public class BookletEntry implements IBookletEntry{
} }
} }
@SideOnly(Side.CLIENT)
private static boolean fitsFilter(IBookletPage page, String searchBarText){
Minecraft mc = Minecraft.getMinecraft();
List<ItemStack> items = new ArrayList<ItemStack>();
page.getItemStacksForPage(items);
if(!items.isEmpty()){
for(ItemStack stack : items){
if(stack != null){
List<String> tooltip = stack.getTooltip(mc.thePlayer, mc.gameSettings.advancedItemTooltips);
for(String strg : tooltip){
if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){
return true;
}
}
}
}
}
List<FluidStack> fluids = new ArrayList<FluidStack>();
page.getFluidStacksForPage(fluids);
if(!fluids.isEmpty()){
for(FluidStack stack : fluids){
if(stack != null){
String strg = stack.getLocalizedName();
if(strg != null && strg.toLowerCase(Locale.ROOT).contains(searchBarText)){
return true;
}
}
}
}
return false;
}
public BookletEntry setImportant(){ public BookletEntry setImportant(){
this.color = TextFormatting.DARK_GREEN; this.color = TextFormatting.DARK_GREEN;
return this; return this;

View file

@ -41,21 +41,17 @@ public abstract class GuiBooklet extends GuiBookletBase{
public static final int BUTTONS_PER_PAGE = 12; public static final int BUTTONS_PER_PAGE = 12;
public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("guiBooklet"); public static final ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("guiBooklet");
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets"); public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
public GuiScreen previousScreen; public GuiScreen previousScreen;
public GuiBookletBase parentPage; public GuiBookletBase parentPage;
private GuiButton buttonLeft;
private GuiButton buttonRight;
private GuiButton buttonBack;
protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
public GuiTextField searchField; public GuiTextField searchField;
protected int xSize; protected int xSize;
protected int ySize; protected int ySize;
protected int guiLeft; protected int guiLeft;
protected int guiTop; protected int guiTop;
private GuiButton buttonLeft;
private GuiButton buttonRight;
private GuiButton buttonBack;
public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){ public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){
this.previousScreen = previousScreen; this.previousScreen = previousScreen;

View file

@ -29,9 +29,9 @@ import java.util.List;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class GuiPage extends GuiBooklet{ public class GuiPage extends GuiBooklet{
private int pageTimer;
private final List<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>();
public final IBookletPage[] pages = new IBookletPage[2]; public final IBookletPage[] pages = new IBookletPage[2];
private final List<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>();
private int pageTimer;
public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2){ public GuiPage(GuiScreen previousScreen, GuiBookletBase parentPage, IBookletPage page1, IBookletPage page2){
super(previousScreen, parentPage); super(previousScreen, parentPage);

View file

@ -30,14 +30,12 @@ import java.util.Map;
public class BookletPage implements IBookletPage{ public class BookletPage implements IBookletPage{
protected IBookletChapter chapter;
private final List<ItemStack> itemsForPage = new ArrayList<ItemStack>();
private final List<FluidStack> fluidsForPage = new ArrayList<FluidStack>();
protected boolean hasNoText;
protected final HashMap<String, String> textReplacements = new HashMap<String, String>(); protected final HashMap<String, String> textReplacements = new HashMap<String, String>();
protected final int localizationKey; protected final int localizationKey;
private final List<ItemStack> itemsForPage = new ArrayList<ItemStack>();
private final List<FluidStack> fluidsForPage = new ArrayList<FluidStack>();
protected IBookletChapter chapter;
protected boolean hasNoText;
public BookletPage(int localizationKey){ public BookletPage(int localizationKey){
this.localizationKey = localizationKey; this.localizationKey = localizationKey;

View file

@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.init.SoundEvents; import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting; import net.minecraft.util.text.TextFormatting;
@ -31,13 +30,12 @@ import java.util.List;
public class ItemDisplay{ public class ItemDisplay{
private final GuiPage gui;
public final int x; public final int x;
public final int y; public final int y;
public final float scale; public final float scale;
private final GuiPage gui;
public ItemStack stack;
private final IBookletPage page; private final IBookletPage page;
public ItemStack stack;
public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){ public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){
this.gui = gui; this.gui = gui;

View file

@ -16,7 +16,6 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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 de.ellpeck.actuallyadditions.mod.util.Util; import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes; import net.minecraft.item.crafting.ShapedRecipes;
@ -33,10 +32,10 @@ import java.util.List;
public class PageCrafting extends BookletPage{ public class PageCrafting extends BookletPage{
private final List<IRecipe> recipes;
private int recipeAt; private int recipeAt;
private String recipeTypeLocKey; private String recipeTypeLocKey;
private boolean isWildcard; private boolean isWildcard;
private final List<IRecipe> recipes;
public PageCrafting(int localizationKey, List<IRecipe> recipes){ public PageCrafting(int localizationKey, List<IRecipe> recipes){
super(localizationKey); super(localizationKey);
@ -103,7 +102,7 @@ public class PageCrafting extends BookletPage{
for(IRecipe recipe : this.recipes){ for(IRecipe recipe : this.recipes){
if(recipe != null){ if(recipe != null){
ItemStack output = recipe.getRecipeOutput(); ItemStack output = recipe.getRecipeOutput();
if(output != null){ if(StackUtil.isValid(output)){
ItemStack copy = output.copy(); ItemStack copy = output.copy();
if(this.isWildcard){ if(this.isWildcard){
copy.setItemDamage(Util.WILDCARD); copy.setItemDamage(Util.WILDCARD);
@ -146,7 +145,7 @@ public class PageCrafting extends BookletPage{
for(int i = 0; i < shaped.getInput().length; i++){ for(int i = 0; i < shaped.getInput().length; i++){
Object input = shaped.getInput()[i]; Object input = shaped.getInput()[i];
if(input != null){ if(input != null){
stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0)); stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? StackUtil.getNull() : ((List<ItemStack>)input).get(0));
} }
} }
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapedOreRecipe"; this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapedOreRecipe";
@ -155,7 +154,7 @@ public class PageCrafting extends BookletPage{
ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe; ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe;
for(int i = 0; i < shapeless.getInput().size(); i++){ for(int i = 0; i < shapeless.getInput().size(); i++){
Object input = shapeless.getInput().get(i); Object input = shapeless.getInput().get(i);
stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? null : ((List<ItemStack>)input).get(0)); stacks[i] = input instanceof ItemStack ? (ItemStack)input : (((List<ItemStack>)input).isEmpty() ? StackUtil.getNull() : ((List<ItemStack>)input).get(0));
} }
this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapelessOreRecipe"; this.recipeTypeLocKey = "booklet."+ModUtil.MOD_ID+".shapelessOreRecipe";
} }

View file

@ -30,6 +30,15 @@ public class PageFurnace extends BookletPage{
this.input = getInputForOutput(output); this.input = getInputForOutput(output);
} }
private static ItemStack getInputForOutput(ItemStack output){
for(Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet()){
if(entry.getValue().isItemEqual(output)){
return entry.getKey();
}
}
return null;
}
@Override @Override
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){ public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks); super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
@ -50,15 +59,6 @@ public class PageFurnace extends BookletPage{
gui.addOrModifyItemRenderer(this.output, startX+23+59, startY+10+5, 1F, false); gui.addOrModifyItemRenderer(this.output, startX+23+59, startY+10+5, 1F, false);
} }
private static ItemStack getInputForOutput(ItemStack output){
for(Map.Entry<ItemStack, ItemStack> entry : FurnaceRecipes.instance().getSmeltingList().entrySet()){
if(entry.getValue().isItemEqual(output)){
return entry.getKey();
}
}
return null;
}
@Override @Override
public void getItemStacksForPage(List<ItemStack> list){ public void getItemStacksForPage(List<ItemStack> list){
super.getItemStacksForPage(list); super.getItemStacksForPage(list);

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.booklet.page; package de.ellpeck.actuallyadditions.mod.booklet.page;
import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase; import de.ellpeck.actuallyadditions.api.booklet.internal.GuiBookletBase;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -21,13 +20,6 @@ public class PageTextOnly extends BookletPage{
super(localizationKey); super(localizationKey);
} }
@Override
@SideOnly(Side.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
renderTextToPage(gui, this, startX+6, startY+5);
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){ public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){
String text = page.getInfoText(); String text = page.getInfoText();
@ -35,4 +27,11 @@ public class PageTextOnly extends BookletPage{
gui.renderSplitScaledAsciiString(text, x, y, 0, false, 0.75F, 120); gui.renderSplitScaledAsciiString(text, x, y, 0, false, 0.75F, 120);
} }
} }
@Override
@SideOnly(Side.CLIENT)
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float partialTicks){
super.drawScreenPre(gui, startX, startY, mouseX, mouseY, partialTicks);
renderTextToPage(gui, this, startX+6, startY+5);
}
} }

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.crafting; package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe; import net.minecraftforge.oredict.ShapedOreRecipe;
@ -27,7 +28,7 @@ public class RecipeKeepDataShaped extends ShapedOreRecipe{
@Override @Override
public ItemStack getCraftingResult(InventoryCrafting inventory){ public ItemStack getCraftingResult(InventoryCrafting inventory){
ItemStack stack = super.getCraftingResult(inventory); ItemStack stack = super.getCraftingResult(inventory);
if(stack != null){ if(StackUtil.isValid(stack)){
for(int i = 0; i < inventory.getSizeInventory(); i++){ for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack input = inventory.getStackInSlot(i); ItemStack input = inventory.getStackInSlot(i);
if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){ if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.crafting; package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapelessOreRecipe; import net.minecraftforge.oredict.ShapelessOreRecipe;
@ -27,7 +28,7 @@ public class RecipeKeepDataShapeless extends ShapelessOreRecipe{
@Override @Override
public ItemStack getCraftingResult(InventoryCrafting inventory){ public ItemStack getCraftingResult(InventoryCrafting inventory){
ItemStack stack = super.getCraftingResult(inventory); ItemStack stack = super.getCraftingResult(inventory);
if(stack != null){ if(StackUtil.isValid(stack)){
for(int i = 0; i < inventory.getSizeInventory(); i++){ for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack input = inventory.getStackInSlot(i); ItemStack input = inventory.getStackInSlot(i);
if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){ if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){

View file

@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.EnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay; import de.ellpeck.actuallyadditions.mod.tile.IEnergyDisplay;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase; import de.ellpeck.actuallyadditions.mod.tile.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneTorch; import net.minecraft.block.BlockRedstoneTorch;
@ -54,7 +55,7 @@ public class ClientEvents{
@SubscribeEvent @SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event){ public void onTooltipEvent(ItemTooltipEvent event){
//Advanced Item Info //Advanced Item Info
if(event.getItemStack() != null && event.getItemStack().getItem() != null){ if(StackUtil.isValid(event.getItemStack())){
if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){ if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){
if(GuiScreen.isCtrlKeyDown()){ if(GuiScreen.isCtrlKeyDown()){
event.getToolTip().add(TextFormatting.DARK_GRAY+""+TextFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".extraInfo.desc")+":"); event.getToolTip().add(TextFormatting.DARK_GRAY+""+TextFormatting.ITALIC+StringUtil.localize("tooltip."+ModUtil.MOD_ID+".extraInfo.desc")+":");
@ -140,7 +141,7 @@ public class ClientEvents{
FontRenderer font = minecraft.fontRendererObj; FontRenderer font = minecraft.fontRendererObj;
ItemStack stack = player.getHeldItemMainhand(); ItemStack stack = player.getHeldItemMainhand();
if(stack != null){ if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof IHudDisplay){ if(stack.getItem() instanceof IHudDisplay){
((IHudDisplay)stack.getItem()).displayHud(minecraft, player, stack, posHit, event.getResolution()); ((IHudDisplay)stack.getItem()).displayHud(minecraft, player, stack, posHit, event.getResolution());
} }
@ -161,7 +162,7 @@ public class ClientEvents{
font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE); font.drawStringWithShadow(strg, event.getResolution().getScaledWidth()/2+5, event.getResolution().getScaledHeight()/2+5, StringUtil.DECIMAL_COLOR_WHITE);
String expl; String expl;
if(stack != null && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){ if(StackUtil.isValid(stack) && Block.getBlockFromItem(stack.getItem()) instanceof BlockRedstoneTorch){
expl = TextFormatting.GREEN+"Right-Click to toggle!"; expl = TextFormatting.GREEN+"Right-Click to toggle!";
} }
else{ else{

View file

@ -20,6 +20,7 @@ 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.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -79,7 +80,7 @@ public class CommonEvents{
checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING); checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
if(ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()){ if(ConfigBoolValues.GIVE_BOOKLET_ON_FIRST_CRAFT.isEnabled()){
if(!event.player.worldObj.isRemote && event.crafting != null && event.crafting.getItem() != null && event.crafting.getItem() != InitItems.itemBooklet){ if(!event.player.worldObj.isRemote && StackUtil.isValid(event.crafting) && event.crafting.getItem() != InitItems.itemBooklet){
String name = event.crafting.getItem().getRegistryName().toString(); String name = event.crafting.getItem().getRegistryName().toString();
if(name != null && name.toLowerCase(Locale.ROOT).contains(ModUtil.MOD_ID)){ if(name != null && name.toLowerCase(Locale.ROOT).contains(ModUtil.MOD_ID)){

View file

@ -85,7 +85,7 @@ public class ContainerBag extends Container implements IButtonReactor{
} }
ItemStack stack = inventory.getCurrentItem(); ItemStack stack = inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemBag){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag){
ItemDrill.loadSlotsFromNBT(this.bagInventory.slots, inventory.getCurrentItem()); ItemDrill.loadSlotsFromNBT(this.bagInventory.slots, inventory.getCurrentItem());
if(stack.hasTagCompound()){ if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound(); NBTTagCompound compound = stack.getTagCompound();
@ -203,7 +203,7 @@ public class ContainerBag extends Container implements IButtonReactor{
@Override @Override
public void onContainerClosed(EntityPlayer player){ public void onContainerClosed(EntityPlayer player){
ItemStack stack = this.inventory.getCurrentItem(); ItemStack stack = this.inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemBag){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag){
ItemDrill.writeSlotsToNBT(this.bagInventory.slots, this.inventory.getCurrentItem()); ItemDrill.writeSlotsToNBT(this.bagInventory.slots, this.inventory.getCurrentItem());
NBTTagCompound compound = stack.getTagCompound(); NBTTagCompound compound = stack.getTagCompound();
this.filter.writeToNBT(compound, "Filter"); this.filter.writeToNBT(compound, "Filter");

View file

@ -109,7 +109,7 @@ public class ContainerCrafter extends Container{
if(!this.world.isRemote){ if(!this.world.isRemote){
for(int i = 0; i < 9; ++i){ for(int i = 0; i < 9; ++i){
ItemStack stack = this.craftMatrix.removeStackFromSlot(i); ItemStack stack = this.craftMatrix.removeStackFromSlot(i);
if(stack != null){ if(StackUtil.isValid(stack)){
player.dropItem(stack, false); player.dropItem(stack, false);
} }
} }

View file

@ -64,7 +64,7 @@ public class ContainerDrill extends Container{
} }
ItemStack stack = inventory.getCurrentItem(); ItemStack stack = inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemDrill){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){
ItemDrill.loadSlotsFromNBT(this.drillInventory.slots, inventory.getCurrentItem()); ItemDrill.loadSlotsFromNBT(this.drillInventory.slots, inventory.getCurrentItem());
} }
} }
@ -135,7 +135,7 @@ public class ContainerDrill extends Container{
@Override @Override
public void onContainerClosed(EntityPlayer player){ public void onContainerClosed(EntityPlayer player){
ItemStack stack = this.inventory.getCurrentItem(); ItemStack stack = this.inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemDrill){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemDrill){
ItemDrill.writeSlotsToNBT(this.drillInventory.slots, this.inventory.getCurrentItem()); ItemDrill.writeSlotsToNBT(this.drillInventory.slots, this.inventory.getCurrentItem());
} }
super.onContainerClosed(player); super.onContainerClosed(player);

View file

@ -59,7 +59,7 @@ public class ContainerEnergizer extends Container{
@Override @Override
public boolean isItemValid(ItemStack stack){ public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, slot, player); return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
} }
@Override @Override

View file

@ -58,7 +58,7 @@ public class ContainerEnervator extends Container{
@Override @Override
public boolean isItemValid(ItemStack stack){ public boolean isItemValid(ItemStack stack){
return stack != null && stack.getItem().isValidArmor(stack, slot, player); return StackUtil.isValid(stack) && stack.getItem().isValidArmor(stack, slot, player);
} }
@Override @Override

View file

@ -59,7 +59,7 @@ public class ContainerFilter extends Container{
} }
ItemStack stack = inventory.getCurrentItem(); ItemStack stack = inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemFilter){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter){
ItemDrill.loadSlotsFromNBT(this.filterInventory.slots, inventory.getCurrentItem()); ItemDrill.loadSlotsFromNBT(this.filterInventory.slots, inventory.getCurrentItem());
} }
} }
@ -128,7 +128,7 @@ public class ContainerFilter extends Container{
@Override @Override
public void onContainerClosed(EntityPlayer player){ public void onContainerClosed(EntityPlayer player){
ItemStack stack = this.inventory.getCurrentItem(); ItemStack stack = this.inventory.getCurrentItem();
if(stack != null && stack.getItem() instanceof ItemFilter){ if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemFilter){
ItemDrill.writeSlotsToNBT(this.filterInventory.slots, this.inventory.getCurrentItem()); ItemDrill.writeSlotsToNBT(this.filterInventory.slots, this.inventory.getCurrentItem());
} }
super.onContainerClosed(player); super.onContainerClosed(player);

View file

@ -67,7 +67,7 @@ public class ContainerFurnaceDouble extends Container{
//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(FurnaceRecipes.instance().getSmeltingResult(newStack) != null){ if(StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(newStack))){
if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false)){ if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_1, TileEntityFurnaceDouble.SLOT_INPUT_1+1, false)){
if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+1, false)){ if(!this.mergeItemStack(newStack, TileEntityFurnaceDouble.SLOT_INPUT_2, TileEntityFurnaceDouble.SLOT_INPUT_2+1, false)){
return StackUtil.getNull(); return StackUtil.getNull();

View file

@ -158,7 +158,7 @@ public class GuiHandler implements IGuiHandler{
case FLUID_COLLECTOR: case FLUID_COLLECTOR:
return new GuiFluidCollector(player.inventory, tile); return new GuiFluidCollector(player.inventory, tile);
case COFFEE_MACHINE: case COFFEE_MACHINE:
return new GuiCoffeeMachine(player.inventory, tile, x, y, z, world); return new GuiCoffeeMachine(player.inventory, tile);
case DRILL: case DRILL:
return new GuiDrill(player.inventory); return new GuiDrill(player.inventory);
case FILTER: case FILTER:
@ -168,7 +168,7 @@ public class GuiHandler implements IGuiHandler{
case ENERVATOR: case ENERVATOR:
return new GuiEnervator(player, tile); return new GuiEnervator(player, tile);
case XP_SOLIDIFIER: case XP_SOLIDIFIER:
return new GuiXPSolidifier(player.inventory, tile, x, y, z, world); return new GuiXPSolidifier(player.inventory, tile);
case CLOUD: case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world); return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK: case BOOK:
@ -189,7 +189,7 @@ public class GuiHandler implements IGuiHandler{
case DIRECTIONAL_BREAKER: case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(player.inventory, tile); return new GuiDirectionalBreaker(player.inventory, tile);
case RANGED_COLLECTOR: case RANGED_COLLECTOR:
return new GuiRangedCollector(player.inventory, tile, x, y, z, world); return new GuiRangedCollector(player.inventory, tile);
case MINER: case MINER:
return new GuiMiner(player.inventory, tile); return new GuiMiner(player.inventory, tile);
case LASER_RELAY_ITEM_WHITELIST: case LASER_RELAY_ITEM_WHITELIST:

View file

@ -22,7 +22,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
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;
@ -34,23 +33,15 @@ public class GuiCoffeeMachine extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiCoffeeMachine"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiCoffeeMachine");
private final TileEntityCoffeeMachine machine; private final TileEntityCoffeeMachine machine;
private final int x;
private final int y;
private final int z;
private final World world;
private EnergyDisplay energy; private EnergyDisplay energy;
private FluidDisplay fluid; private FluidDisplay fluid;
public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){ public GuiCoffeeMachine(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerCoffeeMachine(inventory, tile)); super(new ContainerCoffeeMachine(inventory, tile));
this.machine = (TileEntityCoffeeMachine)tile; this.machine = (TileEntityCoffeeMachine)tile;
this.xSize = 176; this.xSize = 176;
this.ySize = 93+86; this.ySize = 93+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
} }
@Override @Override
@ -79,10 +70,6 @@ public class GuiCoffeeMachine extends GuiContainer{
if(x >= this.guiLeft+16 && y >= this.guiTop+5 && x <= this.guiLeft+23 && y <= this.guiTop+89){ if(x >= this.guiLeft+16 && y >= this.guiTop+5 && x <= this.guiLeft+23 && y <= this.guiTop+89){
this.drawHoveringText(Collections.singletonList(text1), x, y); this.drawHoveringText(Collections.singletonList(text1), x, y);
} }
String text3 = StringUtil.getFluidInfo(this.machine.tank);
if(x >= this.guiLeft+27 && y >= this.guiTop+5 && x <= this.guiLeft+33 && y <= this.guiTop+70){
this.drawHoveringText(Collections.singletonList(text3), x, y);
}
String text2 = this.machine.coffeeCacheAmount+"/"+TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT+" "+StringUtil.localize("info."+ModUtil.MOD_ID+".gui.coffee"); String text2 = this.machine.coffeeCacheAmount+"/"+TileEntityCoffeeMachine.COFFEE_CACHE_MAX_AMOUNT+" "+StringUtil.localize("info."+ModUtil.MOD_ID+".gui.coffee");
if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){ if(x >= this.guiLeft+40 && y >= this.guiTop+25 && x <= this.guiLeft+49 && y <= this.guiTop+56){

View file

@ -20,7 +20,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
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;
@ -29,22 +28,14 @@ public class GuiRangedCollector extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiRangedCollector"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiRangedCollector");
private final TileEntityRangedCollector collector; private final TileEntityRangedCollector collector;
private final int x;
private final int y;
private final int z;
private final World world;
private FilterSettingsGui filter; private FilterSettingsGui filter;
public GuiRangedCollector(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){ public GuiRangedCollector(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerRangedCollector(inventory, tile)); super(new ContainerRangedCollector(inventory, tile));
this.collector = (TileEntityRangedCollector)tile; this.collector = (TileEntityRangedCollector)tile;
this.xSize = 176; this.xSize = 176;
this.ySize = 86+86; this.ySize = 86+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
} }
@Override @Override

View file

@ -22,7 +22,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
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;
@ -31,20 +30,12 @@ public class GuiXPSolidifier extends GuiContainer{
private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiXPSolidifier"); private static final ResourceLocation RES_LOC = AssetUtil.getGuiLocation("guiXPSolidifier");
private final TileEntityXPSolidifier solidifier; private final TileEntityXPSolidifier solidifier;
private final int x;
private final int y;
private final int z;
private final World world;
public GuiXPSolidifier(InventoryPlayer inventory, TileEntityBase tile, int x, int y, int z, World world){ public GuiXPSolidifier(InventoryPlayer inventory, TileEntityBase tile){
super(new ContainerXPSolidifier(inventory, tile)); super(new ContainerXPSolidifier(inventory, tile));
this.solidifier = (TileEntityXPSolidifier)tile; this.solidifier = (TileEntityXPSolidifier)tile;
this.xSize = 176; this.xSize = 176;
this.ySize = 93+86; this.ySize = 93+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
} }
@Override @Override

View file

@ -24,8 +24,8 @@ import java.util.List;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class TexturedButton extends GuiButton{ public class TexturedButton extends GuiButton{
private final ResourceLocation resLoc;
public final List textList = new ArrayList(); public final List textList = new ArrayList();
private final ResourceLocation resLoc;
public int texturePosX; public int texturePosX;
public int texturePosY; public int texturePosY;

View file

@ -33,12 +33,12 @@ public class SlotFilter extends Slot{
ItemStack heldStack = player.inventory.getItemStack(); ItemStack heldStack = player.inventory.getItemStack();
//Delete the stack in the inventory //Delete the stack in the inventory
if(this.getStack() != null && heldStack == null){ if(StackUtil.isValid(this.getStack()) && !StackUtil.isValid(heldStack)){
this.putStack(null); this.putStack(StackUtil.getNull());
} }
//Put the current Item as a filter //Put the current Item as a filter
else{ else{
if(heldStack != null){ if(StackUtil.isValid(heldStack)){
ItemStack stack = heldStack.copy(); ItemStack stack = heldStack.copy();
stack = StackUtil.setStackSize(stack, 1); stack = StackUtil.setStackSize(stack, 1);
this.putStack(stack); this.putStack(stack);
@ -55,8 +55,7 @@ public class SlotFilter extends Slot{
@Override @Override
public void putStack(ItemStack stack){ public void putStack(ItemStack stack){
ItemStack theStack = (stack != null ? stack.copy() : null); super.putStack(StackUtil.validateCopy(stack));
super.putStack(theStack);
} }
@Override @Override

View file

@ -65,12 +65,12 @@ public class ItemBag extends ItemBase{
EntityItem item = event.getItem(); EntityItem item = event.getItem();
if(item != null && !item.isDead){ if(item != null && !item.isDead){
ItemStack stack = item.getEntityItem(); ItemStack stack = item.getEntityItem();
if(stack != null && stack.getItem() != null){ if(StackUtil.isValid(stack)){
for(int i = 0; i < player.inventory.getSizeInventory(); i++){ for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(i != player.inventory.currentItem){ if(i != player.inventory.currentItem){
ItemStack invStack = player.inventory.getStackInSlot(i); ItemStack invStack = player.inventory.getStackInSlot(i);
if(invStack != null && invStack.getItem() instanceof ItemBag && invStack.hasTagCompound()){ if(StackUtil.isValid(invStack) && invStack.getItem() instanceof ItemBag && invStack.hasTagCompound()){
if(invStack.getTagCompound().getBoolean("AutoInsert")){ if(invStack.getTagCompound().getBoolean("AutoInsert")){
boolean changed = false; boolean changed = false;
@ -88,7 +88,7 @@ public class ItemBag extends ItemBase{
else{ else{
for(int j = 4; j < inventory.length; j++){ for(int j = 4; j < inventory.length; j++){
ItemStack bagStack = inventory[j]; ItemStack bagStack = inventory[j];
if(bagStack != null){ 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(StackUtil.getStackSize(stack), stack.getMaxStackSize()-StackUtil.getStackSize(bagStack));
if(maxTransfer > 0){ if(maxTransfer > 0){
@ -145,14 +145,14 @@ public class ItemBag extends ItemBase{
for(int j = 4; j < inventory.length; j++){ for(int j = 4; j < inventory.length; j++){
ItemStack invStack = inventory[j]; ItemStack invStack = inventory[j];
if(invStack != null){ if(StackUtil.isValid(invStack)){
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)){
inventory[j] = remain == null ? null : remain.copy(); inventory[j] = StackUtil.validateCopy(remain);
changed = true; changed = true;
if(remain == null){ if(!StackUtil.isValid(remain)){
break; break;
} }
} }

View file

@ -14,6 +14,7 @@ import cofh.api.energy.IEnergyContainerItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer; import net.darkhax.tesla.api.ITeslaConsumer;
@ -53,7 +54,7 @@ public class ItemBattery extends ItemEnergy{
EntityPlayer player = (EntityPlayer)entity; EntityPlayer player = (EntityPlayer)entity;
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(slot != null){ if(StackUtil.isValid(slot)){
int received = 0; int received = 0;
Item item = slot.getItem(); Item item = slot.getItem();

View file

@ -19,6 +19,7 @@ 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.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
@ -113,7 +114,7 @@ public class ItemBooklet extends ItemBase implements IHudDisplay{
String strg2 = "Page "+(page.getChapter().getPageIndex(page)+1); String strg2 = "Page "+(page.getChapter().getPageIndex(page)+1);
String strg3 = "Right-Click to open..."; String strg3 = "Right-Click to open...";
AssetUtil.renderStackToGui(page.getChapter().getDisplayItemStack() != null ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F); AssetUtil.renderStackToGui(StackUtil.isValid(page.getChapter().getDisplayItemStack()) ? page.getChapter().getDisplayItemStack() : new ItemStack(InitItems.itemBooklet), resolution.getScaledWidth()/2-10, height+41, 1F);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg1, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg1)/2, height+20, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg1, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg1)/2, height+20, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg2, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg2)/2, height+30, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.YELLOW+""+TextFormatting.ITALIC+strg2, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg2)/2, height+30, StringUtil.DECIMAL_COLOR_WHITE);
minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.GOLD+strg3, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg3)/2, height+60, StringUtil.DECIMAL_COLOR_WHITE); minecraft.fontRendererObj.drawStringWithShadow(TextFormatting.GOLD+strg3, resolution.getScaledWidth()/2-minecraft.fontRendererObj.getStringWidth(strg3)/2, height+60, StringUtil.DECIMAL_COLOR_WHITE);

View file

@ -48,9 +48,9 @@ public class ItemChestToCrateUpgrade extends ItemBase{
ItemStack[] stacks = new ItemStack[chest.getSizeInventory()]; ItemStack[] stacks = new ItemStack[chest.getSizeInventory()];
for(int i = 0; i < stacks.length; i++){ for(int i = 0; i < stacks.length; i++){
ItemStack aStack = chest.getStackInSlot(i); ItemStack aStack = chest.getStackInSlot(i);
if(aStack != null){ if(StackUtil.isValid(aStack)){
stacks[i] = aStack.copy(); stacks[i] = aStack.copy();
chest.setInventorySlotContents(i, null); chest.setInventorySlotContents(i, StackUtil.getNull());
} }
} }
@ -63,7 +63,7 @@ public class ItemChestToCrateUpgrade extends ItemBase{
if(newTileHit instanceof IInventory){ if(newTileHit instanceof IInventory){
IInventory newChest = (IInventory)newTileHit; IInventory newChest = (IInventory)newTileHit;
for(int i = 0; i < stacks.length; i++){ for(int i = 0; i < stacks.length; i++){
if(stacks[i] != null){ if(StackUtil.isValid(stacks[i])){
if(newChest.getSizeInventory() > i){ if(newChest.getSizeInventory() > i){
newChest.setInventorySlotContents(i, stacks[i].copy()); newChest.setInventorySlotContents(i, stacks[i].copy());
} }

View file

@ -26,7 +26,7 @@ import java.util.List;
public class ItemCrystal extends ItemBase{ public class ItemCrystal extends ItemBase{
private boolean isEmpowered; private final boolean isEmpowered;
public ItemCrystal(String name, boolean isEmpowered){ public ItemCrystal(String name, boolean isEmpowered){
super(name); super(name);

View file

@ -38,6 +38,52 @@ public class ItemFillingWand extends ItemEnergy{
super(800000, 2000, name); super(800000, 2000, name);
} }
private static boolean removeFittingItem(IBlockState state, EntityPlayer player){
Block block = state.getBlock();
ItemStack stack = new ItemStack(block, 1, block.damageDropped(state));
if(StackUtil.isValid(stack)){
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
ItemStack slot = player.inventory.getStackInSlot(i);
if(StackUtil.isValid(slot) && slot.isItemEqual(stack)){
slot = StackUtil.addStackSize(slot, -1);
if(!StackUtil.isValid(slot)){
player.inventory.setInventorySlotContents(i, StackUtil.getNull());
}
return true;
}
}
}
return false;
}
private static void saveBlock(IBlockState state, ItemStack stack){
if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
Block block = state.getBlock();
compound.setString("Block", block.getRegistryName().toString());
compound.setInteger("Meta", block.getMetaFromState(state));
}
private static IBlockState loadBlock(ItemStack stack){
if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound();
String blockName = compound.getString("Block");
int meta = compound.getInteger("Meta");
Block block = Block.getBlockFromName(blockName);
if(block != null){
return block.getStateFromMeta(meta);
}
}
return null;
}
@Override @Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){ public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ){
if(!world.isRemote && player.getItemInUseCount() <= 0){ if(!world.isRemote && player.getItemInUseCount() <= 0){
@ -200,52 +246,6 @@ public class ItemFillingWand extends ItemEnergy{
list.add("Selected Block: "+display); list.add("Selected Block: "+display);
} }
private static boolean removeFittingItem(IBlockState state, EntityPlayer player){
Block block = state.getBlock();
ItemStack stack = new ItemStack(block, 1, block.damageDropped(state));
if(StackUtil.isValid(stack)){
for(int i = 0; i < player.inventory.getSizeInventory(); i++){
ItemStack slot = player.inventory.getStackInSlot(i);
if(StackUtil.isValid(slot) && slot.isItemEqual(stack)){
slot = StackUtil.addStackSize(slot, -1);
if(!StackUtil.isValid(slot)){
player.inventory.setInventorySlotContents(i, StackUtil.getNull());
}
return true;
}
}
}
return false;
}
private static void saveBlock(IBlockState state, ItemStack stack){
if(!stack.hasTagCompound()){
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound compound = stack.getTagCompound();
Block block = state.getBlock();
compound.setString("Block", block.getRegistryName().toString());
compound.setInteger("Meta", block.getMetaFromState(state));
}
private static IBlockState loadBlock(ItemStack stack){
if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound();
String blockName = compound.getString("Block");
int meta = compound.getInteger("Meta");
Block block = Block.getBlockFromName(blockName);
if(block != null){
return block.getStateFromMeta(meta);
}
}
return null;
}
@Override @Override
public int getMaxItemUseDuration(ItemStack stack){ public int getMaxItemUseDuration(ItemStack stack){
return Integer.MAX_VALUE; return Integer.MAX_VALUE;

View file

@ -14,6 +14,7 @@ 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.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;
@ -50,7 +51,7 @@ public class ItemFilter extends ItemBase{
ItemDrill.loadSlotsFromNBT(slots, stack); ItemDrill.loadSlotsFromNBT(slots, stack);
if(slots != null && slots.length > 0){ if(slots != null && slots.length > 0){
for(ItemStack slot : slots){ for(ItemStack slot : slots){
if(slot != null && slot.getItem() != null){ if(StackUtil.isValid(slot)){
tooltip.add(slot.getItem().getItemStackDisplayName(slot)); tooltip.add(slot.getItem().getItemStackDisplayName(slot));
} }
} }

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods; import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
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.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -44,7 +45,7 @@ public class ItemFoods extends ItemFoodBase{
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){ public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){
ItemStack stackToReturn = super.onItemUseFinish(stack, world, player); ItemStack stackToReturn = super.onItemUseFinish(stack, world, player);
ItemStack returnItem = stack.getItemDamage() >= ALL_FOODS.length ? null : ALL_FOODS[stack.getItemDamage()].returnItem; ItemStack returnItem = stack.getItemDamage() >= ALL_FOODS.length ? null : ALL_FOODS[stack.getItemDamage()].returnItem;
if(returnItem != null && player instanceof EntityPlayer){ if(StackUtil.isValid(returnItem) && player instanceof EntityPlayer){
if(!((EntityPlayer)player).inventory.addItemStackToInventory(returnItem.copy())){ if(!((EntityPlayer)player).inventory.addItemStackToInventory(returnItem.copy())){
if(!world.isRemote){ if(!world.isRemote){
EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy()); EntityItem entityItem = new EntityItem(player.worldObj, player.posX, player.posY, player.posZ, returnItem.copy());

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items; package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockGrass; import net.minecraft.block.BlockGrass;
import net.minecraft.block.IGrowable; import net.minecraft.block.IGrowable;
@ -43,7 +44,7 @@ public class ItemGrowthRing extends ItemEnergy{
ItemStack equipped = player.getHeldItemMainhand(); ItemStack equipped = player.getHeldItemMainhand();
int energyUse = 300; int energyUse = 300;
if(equipped != null && equipped == stack && this.getEnergyStored(stack) >= energyUse){ if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){
List<BlockPos> blocks = new ArrayList<BlockPos>(); List<BlockPos> blocks = new ArrayList<BlockPos>();
//Adding all possible Blocks //Adding all possible Blocks

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.mod.achievement.TheAchievements;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface; import de.ellpeck.actuallyadditions.mod.tile.TileEntityPlayerInterface;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
@ -92,7 +93,7 @@ public class ItemPlayerProbe extends ItemBase{
public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){ public boolean itemInteractionForEntity(ItemStack aStack, EntityPlayer player, EntityLivingBase entity, EnumHand hand){
if(!player.worldObj.isRemote){ if(!player.worldObj.isRemote){
ItemStack stack = player.getHeldItemMainhand(); ItemStack stack = player.getHeldItemMainhand();
if(stack != null && stack.getItem() == this){ if(StackUtil.isValid(stack) && stack.getItem() == this){
if(entity instanceof EntityPlayer){ if(entity instanceof EntityPlayer){
EntityPlayer playerHit = (EntityPlayer)entity; EntityPlayer playerHit = (EntityPlayer)entity;

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase; import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.ThePotionRings; import de.ellpeck.actuallyadditions.mod.items.metalists.ThePotionRings;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem; import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
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.renderer.color.IItemColor; import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -67,7 +68,7 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
if(player instanceof EntityPlayer){ if(player instanceof EntityPlayer){
EntityPlayer thePlayer = (EntityPlayer)player; EntityPlayer thePlayer = (EntityPlayer)player;
ItemStack equippedStack = thePlayer.getHeldItemMainhand(); ItemStack equippedStack = thePlayer.getHeldItemMainhand();
this.effectEntity(thePlayer, stack, equippedStack != null && stack == equippedStack); this.effectEntity(thePlayer, stack, StackUtil.isValid(equippedStack) && stack == equippedStack);
} }
} }
} }

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -38,7 +39,7 @@ public class ItemWaterRemovalRing extends ItemEnergy{
ItemStack equipped = player.getHeldItemMainhand(); ItemStack equipped = player.getHeldItemMainhand();
int energyUse = 350; int energyUse = 350;
if(equipped != null && equipped == stack && this.getEnergyStored(stack) >= energyUse){ if(StackUtil.isValid(equipped) && equipped == stack && this.getEnergyStored(stack) >= energyUse){
//Setting everything to air //Setting everything to air
int range = 3; int range = 3;

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items;
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.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.passive.EntityBat; import net.minecraft.entity.passive.EntityBat;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
@ -90,11 +91,11 @@ public class ItemWingsOfTheBats extends ItemBase{
*/ */
public static ItemStack getWingItem(EntityPlayer player){ public static ItemStack getWingItem(EntityPlayer player){
for(int i = 0; i < player.inventory.getSizeInventory(); i++){ for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(player.inventory.getStackInSlot(i) != null && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats){ if(StackUtil.isValid(player.inventory.getStackInSlot(i)) && player.inventory.getStackInSlot(i).getItem() instanceof ItemWingsOfTheBats){
return player.inventory.getStackInSlot(i); return player.inventory.getStackInSlot(i);
} }
} }
return null; return StackUtil.getNull();
} }
@SubscribeEvent @SubscribeEvent
@ -120,7 +121,7 @@ public class ItemWingsOfTheBats extends ItemBase{
public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event){ public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event){
if(event.getEntityLiving() instanceof EntityPlayer){ if(event.getEntityLiving() instanceof EntityPlayer){
EntityPlayer player = (EntityPlayer)event.getEntityLiving(); EntityPlayer player = (EntityPlayer)event.getEntityLiving();
boolean wingsEquipped = ItemWingsOfTheBats.getWingItem(player) != null; boolean wingsEquipped = StackUtil.isValid(ItemWingsOfTheBats.getWingItem(player));
//If Player isn't (really) winged //If Player isn't (really) winged
if(!ItemWingsOfTheBats.isPlayerWinged(player)){ if(!ItemWingsOfTheBats.isPlayerWinged(player)){

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.items.base;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -68,7 +69,7 @@ public class ItemToolAA extends ItemTool{
@Override @Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){ public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
if(this.repairItem != null){ if(StackUtil.isValid(this.repairItem)){
return ItemUtil.areItemsEqual(this.repairItem, stack, false); return ItemUtil.areItemsEqual(this.repairItem, stack, false);
} }
else if(this.repairOredict != null){ else if(this.repairOredict != null){

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
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.api.recipe.IColorLensChanger; import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
@ -66,9 +67,9 @@ public class LensColor extends Lens{
ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1)); ArrayList<EntityItem> items = (ArrayList<EntityItem>)tile.getWorldObject().getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(hitBlock.getX(), hitBlock.getY(), hitBlock.getZ(), hitBlock.getX()+1, hitBlock.getY()+1, hitBlock.getZ()+1));
for(EntityItem item : items){ for(EntityItem item : items){
if(!item.isDead && item.getEntityItem() != null && tile.getEnergy() >= ENERGY_USE){ if(!item.isDead && StackUtil.isValid(item.getEntityItem()) && tile.getEnergy() >= ENERGY_USE){
ItemStack newStack = this.tryConvert(item.getEntityItem(), hitState, hitBlock, tile); ItemStack newStack = this.tryConvert(item.getEntityItem(), hitState, hitBlock, tile);
if(newStack != null){ if(StackUtil.isValid(newStack)){
item.setDead(); item.setDead();
EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack); EntityItem newItem = new EntityItem(tile.getWorldObject(), item.posX, item.posY, item.posZ, newStack);
@ -83,7 +84,7 @@ public class LensColor extends Lens{
} }
private ItemStack tryConvert(ItemStack stack, IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){ private ItemStack tryConvert(ItemStack stack, IBlockState hitState, BlockPos hitBlock, IAtomicReconstructor tile){
if(stack != null){ if(StackUtil.isValid(stack)){
Item item = stack.getItem(); Item item = stack.getItem();
if(item != null){ if(item != null){
for(Map.Entry<Item, IColorLensChanger> changer : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_COLOR_CHANGERS.entrySet()){ for(Map.Entry<Item, IColorLensChanger> changer : ActuallyAdditionsAPI.RECONSTRUCTOR_LENS_COLOR_CHANGERS.entrySet()){

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.items.lens;
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.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData; import net.minecraft.enchantment.EnchantmentData;
@ -42,7 +43,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.getEntityItem(); ItemStack stack = item.getEntityItem();
if(stack != null){ if(StackUtil.isValid(stack)){
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){

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
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.api.recipe.WeightedOre; import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherrack; import net.minecraft.block.BlockNetherrack;
import net.minecraft.block.BlockStone; import net.minecraft.block.BlockStone;
@ -119,7 +120,7 @@ public class LensMining extends Lens{
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false); List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
if(stacks != null && !stacks.isEmpty()){ if(stacks != null && !stacks.isEmpty()){
for(ItemStack aStack : stacks){ for(ItemStack aStack : stacks){
if(aStack != null && aStack.getItem() instanceof ItemBlock){ if(StackUtil.isValid(aStack) && aStack.getItem() instanceof ItemBlock){
adaptedUse += (totalWeight-ore.itemWeight)%40000; adaptedUse += (totalWeight-ore.itemWeight)%40000;
stack = aStack; stack = aStack;

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items.metalists; package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.init.Items; import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity; import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -45,7 +46,7 @@ public enum TheFoods{
public final boolean getsDrunken; public final boolean getsDrunken;
public final int useDuration; public final int useDuration;
public final EnumRarity rarity; public final EnumRarity rarity;
public ItemStack returnItem; public ItemStack returnItem = StackUtil.getNull();
TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity){ TheFoods(String name, int healAmount, float saturation, boolean getsDrunken, int useDuration, EnumRarity rarity){
this.name = name; this.name = name;

View file

@ -19,7 +19,6 @@ import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.List; import java.util.List;
public class BookletRecipeCategory extends BlankRecipeCategory<BookletRecipeWrapper>{ public class BookletRecipeCategory extends BlankRecipeCategory<BookletRecipeWrapper>{

View file

@ -17,8 +17,6 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
public class CoffeeMachineRecipeCategory extends BlankRecipeCategory<CoffeeMachineRecipeWrapper>{ public class CoffeeMachineRecipeCategory extends BlankRecipeCategory<CoffeeMachineRecipeWrapper>{

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.jei.crusher; package de.ellpeck.actuallyadditions.mod.jei.crusher;
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.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import mezz.jei.api.IGuiHelper; import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IDrawable; import mezz.jei.api.gui.IDrawable;
@ -51,7 +52,7 @@ public class CrusherRecipeCategory extends BlankRecipeCategory<CrusherRecipeWrap
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.outputOneStack);
if(wrapper.theRecipe.outputTwoStack != null){ if(StackUtil.isValid(wrapper.theRecipe.outputTwoStack)){
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.outputTwoStack);
} }

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks; import de.ellpeck.actuallyadditions.mod.blocks.InitBlocks;
import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils; import de.ellpeck.actuallyadditions.mod.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton; import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil; import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
@ -37,7 +38,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
List list = new ArrayList(); List list = new ArrayList();
list.add(this.theRecipe.outputOneStack); list.add(this.theRecipe.outputOneStack);
if(this.theRecipe.outputTwoStack != null){ if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
list.add(this.theRecipe.outputTwoStack); list.add(this.theRecipe.outputTwoStack);
} }
ingredients.setOutputs(ItemStack.class, list); ingredients.setOutputs(ItemStack.class, list);
@ -45,7 +46,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
@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(this.theRecipe.outputTwoStack != null){ if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
minecraft.fontRendererObj.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false); minecraft.fontRendererObj.drawString(this.theRecipe.outputTwoChance+"%", 60, 60, StringUtil.DECIMAL_COLOR_GRAY_TEXT, false);
} }

View file

@ -17,8 +17,6 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout; import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients; import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory; import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
public class EmpowererRecipeCategory extends BlankRecipeCategory<EmpowererRecipeWrapper>{ public class EmpowererRecipeCategory extends BlankRecipeCategory<EmpowererRecipeWrapper>{

View file

@ -18,6 +18,7 @@ import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import mezz.jei.api.ingredients.IIngredients; 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.Arrays; import java.util.Arrays;
public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{ public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{

View file

@ -65,6 +65,7 @@ public class ConnectionPair implements IConnectionPair{
return this.type; return this.type;
} }
@Override
public boolean contains(BlockPos relay){ public boolean contains(BlockPos relay){
for(BlockPos position : this.positions){ for(BlockPos position : this.positions){
if(position != null && position.equals(relay)){ if(position != null && position.equals(relay)){

View file

@ -147,7 +147,7 @@ public class MethodHandler implements IMethodHandler{
for(LensConversionRecipe recipe : recipes){ for(LensConversionRecipe recipe : recipes){
if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){ if(recipe != null && recipe.type == tile.getLens() && tile.getEnergy() >= recipe.energyUse){
ItemStack output = recipe.outputStack; ItemStack output = recipe.outputStack;
if(output != null){ if(StackUtil.isValid(output)){
tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos))); tile.getWorldObject().playEvent(2001, pos, Block.getStateId(tile.getWorldObject().getBlockState(pos)));
if(output.getItem() instanceof ItemBlock){ if(output.getItem() instanceof ItemBlock){

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.misc.special; package de.ellpeck.actuallyadditions.mod.misc.special;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -28,6 +29,7 @@ public class RenderSpecial{
} }
public void render(EntityPlayer player, float partialTicks){ public void render(EntityPlayer player, float partialTicks){
if(StackUtil.isValid(this.theThingToRender)){
if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){ if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){
return; return;
} }
@ -52,18 +54,19 @@ public class RenderSpecial{
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0); GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
GlStateManager.disableLighting(); GlStateManager.disableLighting();
if(this.theThingToRender != null){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
if(!isBlock){ if(!isBlock){
GlStateManager.translate(0D, 0.5D, 0D); GlStateManager.translate(0D, 0.5D, 0D);
} }
GlStateManager.rotate(180F, 1F, 0F, 0F); GlStateManager.rotate(180F, 1F, 0F, 0F);
AssetUtil.renderItemInWorld(this.theThingToRender); AssetUtil.renderItemInWorld(this.theThingToRender);
GlStateManager.popMatrix(); GlStateManager.popMatrix();
}
GlStateManager.enableLighting(); GlStateManager.enableLighting();
GlStateManager.popMatrix(); GlStateManager.popMatrix();
} }
}
} }

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.misc.special; package de.ellpeck.actuallyadditions.mod.misc.special;
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.ItemStack; import net.minecraft.item.ItemStack;
@ -46,7 +47,7 @@ public class SpecialRenderInit{
meta = 0; meta = 0;
} }
ItemStack stack = null; ItemStack stack = StackUtil.getNull();
//Get the Item from the String //Get the Item from the String
ResourceLocation resLoc = new ResourceLocation(itemName); ResourceLocation resLoc = new ResourceLocation(itemName);
if(Item.REGISTRY.containsKey(resLoc)){ if(Item.REGISTRY.containsKey(resLoc)){
@ -59,7 +60,7 @@ public class SpecialRenderInit{
} }
//Add a new Special Renderer to the list //Add a new Special Renderer to the list
if(stack != null){ if(StackUtil.isValid(stack)){
SPECIAL_LIST.put(key, new RenderSpecial(stack)); SPECIAL_LIST.put(key, new RenderSpecial(stack));
} }
} }

View file

@ -20,7 +20,6 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
@ -38,10 +37,7 @@ import java.util.UUID;
public final class PacketHandler{ public final class PacketHandler{
public static SimpleNetworkWrapper theNetwork;
public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>(); public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>();
public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){ public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){
@Override @Override
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@ -56,7 +52,7 @@ public final class PacketHandler{
World world = Minecraft.getMinecraft().theWorld; World world = Minecraft.getMinecraft().theWorld;
if(world != null){ if(world != null){
TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z"))); TileEntity tile = world.getTileEntity(new BlockPos(compound.getInteger("X"), compound.getInteger("Y"), compound.getInteger("Z")));
if(tile != null && tile instanceof TileEntityBase){ if(tile instanceof TileEntityBase){
((TileEntityBase)tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC); ((TileEntityBase)tile).readSyncableNBT(compound.getCompoundTag("Data"), TileEntityBase.NBTType.SYNC);
} }
} }
@ -71,7 +67,7 @@ public final class PacketHandler{
if(tile instanceof IButtonReactor){ if(tile instanceof IButtonReactor){
IButtonReactor reactor = (IButtonReactor)tile; IButtonReactor reactor = (IButtonReactor)tile;
Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
if(entity != null && entity instanceof EntityPlayer){ if(entity instanceof EntityPlayer){
reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity); reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
} }
} }
@ -82,9 +78,9 @@ public final class PacketHandler{
public void handleData(NBTTagCompound compound){ public void handleData(NBTTagCompound compound){
World world = DimensionManager.getWorld(compound.getInteger("WorldID")); World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
Entity entity = world.getEntityByID(compound.getInteger("PlayerID")); Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
if(entity != null && entity instanceof EntityPlayer){ if(entity instanceof EntityPlayer){
Container container = ((EntityPlayer)entity).openContainer; Container container = ((EntityPlayer)entity).openContainer;
if(container != null && container instanceof IButtonReactor){ if(container instanceof IButtonReactor){
((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity); ((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
} }
} }
@ -125,6 +121,7 @@ public final class PacketHandler{
} }
} }
}; };
public static SimpleNetworkWrapper theNetwork;
public static void init(){ public static void init(){
theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID); theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);

View file

@ -11,13 +11,7 @@
package de.ellpeck.actuallyadditions.mod.proxy; package de.ellpeck.actuallyadditions.mod.proxy;
import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.booklet.IBookletChapter;
import de.ellpeck.actuallyadditions.api.booklet.IBookletEntry;
import de.ellpeck.actuallyadditions.api.booklet.IBookletPage;
import de.ellpeck.actuallyadditions.mod.blocks.render.*; import de.ellpeck.actuallyadditions.mod.blocks.render.*;
import de.ellpeck.actuallyadditions.mod.booklet.entry.BookletEntryAllItems;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities; import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.ClientEvents; import de.ellpeck.actuallyadditions.mod.event.ClientEvents;
import de.ellpeck.actuallyadditions.mod.fluids.InitFluids; import de.ellpeck.actuallyadditions.mod.fluids.InitFluids;
@ -30,19 +24,16 @@ import net.minecraft.block.Block;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.client.resources.IResourceManagerReloadListener;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.model.ModelLoader; import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.api.recipe.CrusherRecipe;
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.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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;
@ -53,12 +54,12 @@ public final class CrusherRecipeRegistry{
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i); CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
addedRecipes.add(recipe.inputStack+" -> "+recipe.outputOneStack); addedRecipes.add(recipe.inputStack+" -> "+recipe.outputOneStack);
} }
ModUtil.LOGGER.info("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes.toString()); ModUtil.LOGGER.info("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes);
ModUtil.LOGGER.warn("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult.toString()); ModUtil.LOGGER.warn("Couldn't add "+oresNoResult.size()+" Crusher Recipes automatically, either because the inputs were missing outputs, or because they exist already: "+oresNoResult);
} }
public static boolean hasBlacklistedOutput(ItemStack output){ public static boolean hasBlacklistedOutput(ItemStack output){
if(output != null){ if(StackUtil.isValid(output)){
Item item = output.getItem(); Item item = output.getItem();
if(item != null){ if(item != null){
String reg = item.getRegistryName().toString(); String reg = item.getRegistryName().toString();

View file

@ -15,6 +15,7 @@ import de.ellpeck.actuallyadditions.mod.blocks.metalists.TheMiscBlocks;
import de.ellpeck.actuallyadditions.mod.items.InitItems; import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems; import de.ellpeck.actuallyadditions.mod.items.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil; import de.ellpeck.actuallyadditions.mod.util.ModUtil;
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.ItemStack; import net.minecraft.item.ItemStack;
@ -49,7 +50,7 @@ public class FuelHandler implements IFuelHandler{
@Override @Override
public int getBurnTime(ItemStack stack){ public int getBurnTime(ItemStack stack){
if(stack != null){ if(StackUtil.isValid(stack)){
for(Fuel fuel : FUEL_LIST){ for(Fuel fuel : FUEL_LIST){
if(stack.isItemEqual(fuel.fuel)){ if(stack.isItemEqual(fuel.fuel)){
return fuel.burnTime; return fuel.burnTime;

View file

@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.api.lens.ILensItem;
import de.ellpeck.actuallyadditions.api.lens.Lens; import de.ellpeck.actuallyadditions.api.lens.Lens;
import de.ellpeck.actuallyadditions.mod.misc.SoundHandler; import de.ellpeck.actuallyadditions.mod.misc.SoundHandler;
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.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.state.IBlockState; import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -116,7 +117,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
@Override @Override
public Lens getLens(){ public Lens getLens(){
if(this.slots[0] != null){ if(StackUtil.isValid(this.slots[0])){
if(this.slots[0].getItem() instanceof ILensItem){ if(this.slots[0].getItem() instanceof ILensItem){
return ((ILensItem)this.slots[0].getItem()).getLens(); return ((ILensItem)this.slots[0].getItem()).getLens();
} }
@ -151,7 +152,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return stack != null && stack.getItem() instanceof ILensItem; return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
} }
@Override @Override

View file

@ -130,7 +130,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
} }
public void storeCoffee(){ public void storeCoffee(){
if(this.slots[SLOT_COFFEE_BEANS] != null && this.slots[SLOT_COFFEE_BEANS].getItem() == InitItems.itemCoffeeBean){ if(StackUtil.isValid(this.slots[SLOT_COFFEE_BEANS]) && this.slots[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[SLOT_COFFEE_BEANS] = StackUtil.addStackSize(this.slots[SLOT_COFFEE_BEANS], -1); this.slots[SLOT_COFFEE_BEANS] = StackUtil.addStackSize(this.slots[SLOT_COFFEE_BEANS], -1);

View file

@ -26,7 +26,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
} }
public static CompostRecipe getRecipeForInput(ItemStack input){ public static CompostRecipe getRecipeForInput(ItemStack input){
if(input != null){ if(StackUtil.isValid(input)){
for(CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES){ for(CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
if(input.isItemEqual(recipe.input)){ if(input.isItemEqual(recipe.input)){
return recipe; return recipe;
@ -97,7 +97,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
@Override @Override
public int getInventoryStackLimit(){ public int getInventoryStackLimit(){
if(this.slots[0] != null){ if(StackUtil.isValid(this.slots[0])){
CompostRecipe recipe = getRecipeForInput(this.slots[0]); CompostRecipe recipe = getRecipeForInput(this.slots[0]);
if(recipe != null && StackUtil.isValid(recipe.input)){ if(recipe != null && StackUtil.isValid(recipe.input)){
return StackUtil.getStackSize(recipe.input); return StackUtil.getStackSize(recipe.input);

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem; import de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
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;
@ -33,7 +34,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
super.updateEntity(); super.updateEntity();
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
if(this.slots[0] != null && !this.isRedstonePowered){ if(StackUtil.isValid(this.slots[0]) && !this.isRedstonePowered){
IDisplayStandItem item = this.convertToDisplayStandItem(this.slots[0].getItem()); IDisplayStandItem item = this.convertToDisplayStandItem(this.slots[0].getItem());
if(item != null){ if(item != null){
int energy = item.getUsePerTick(this.slots[0], this, this.ticksElapsed); int energy = item.getUsePerTick(this.slots[0], this, this.ticksElapsed);

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.tile;
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.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.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.CapabilityItemHandler;
@ -131,16 +130,6 @@ public class TileEntityDistributorItem extends TileEntityInventoryBase{
} }
} }
@Override
public void writeSyncableNBT(NBTTagCompound compound, NBTType type){
super.writeSyncableNBT(compound, type);
}
@Override
public void readSyncableNBT(NBTTagCompound compound, NBTType type){
super.readSyncableNBT(compound, type);
}
@Override @Override
public boolean shouldSyncSlots(){ public boolean shouldSyncSlots(){
return true; return true;

View file

@ -14,6 +14,7 @@ import de.ellpeck.actuallyadditions.api.ActuallyAdditionsAPI;
import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe; import de.ellpeck.actuallyadditions.api.recipe.EmpowererRecipe;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil; import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil; import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
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;
@ -36,9 +37,9 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
public static List<EmpowererRecipe> getRecipesForInput(ItemStack input){ public static List<EmpowererRecipe> getRecipesForInput(ItemStack input){
List<EmpowererRecipe> recipesThatWork = new ArrayList<EmpowererRecipe>(); List<EmpowererRecipe> recipesThatWork = new ArrayList<EmpowererRecipe>();
if(input != null){ if(StackUtil.isValid(input)){
for(EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES){ for(EmpowererRecipe recipe : ActuallyAdditionsAPI.EMPOWERER_RECIPES){
if(recipe.input != null && recipe.input.isItemEqual(input)){ if(StackUtil.isValid(recipe.input) && recipe.input.isItemEqual(input)){
recipesThatWork.add(recipe); recipesThatWork.add(recipe);
} }
} }
@ -100,7 +101,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
BlockPos offset = this.pos.offset(facing, 3); BlockPos offset = this.pos.offset(facing, 3);
TileEntity tile = this.worldObj.getTileEntity(offset); TileEntity tile = this.worldObj.getTileEntity(offset);
if(tile != null && tile instanceof TileEntityDisplayStand){ if(tile instanceof TileEntityDisplayStand){
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile; TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
ItemStack standItem = stand.getStackInSlot(0); ItemStack standItem = stand.getStackInSlot(0);
int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true); int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true);

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
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.BlockCrops; import net.minecraft.block.BlockCrops;
@ -150,7 +151,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
private IBlockState getFirstPlantablePlantFromSlots(BlockPos pos){ private IBlockState getFirstPlantablePlantFromSlots(BlockPos pos){
for(int i = 0; i < 6; i++){ for(int i = 0; i < 6; i++){
ItemStack stack = this.slots[i]; ItemStack stack = this.slots[i];
if(stack != null){ if(StackUtil.isValid(stack)){
IPlantable plantable = null; IPlantable plantable = null;
Item item = stack.getItem(); Item item = stack.getItem();
@ -178,7 +179,7 @@ public class TileEntityFarmer extends TileEntityInventoryBase implements ICustom
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return i < 6 && stack != null && stack.getItem() instanceof IPlantable; return i < 6 && StackUtil.isValid(stack) && stack.getItem() instanceof IPlantable;
} }
@Override @Override

View file

@ -62,7 +62,7 @@ public class TileEntityFishingNet extends TileEntityBase{
List<ItemStack> fishables = this.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.worldObj.rand, builder.build()); List<ItemStack> fishables = this.worldObj.getLootTableManager().getLootTableFromLocation(LootTableList.GAMEPLAY_FISHING).generateLootForPools(this.worldObj.rand, builder.build());
for(ItemStack fishable : fishables){ for(ItemStack fishable : fishables){
ItemStack leftover = this.storeInContainer(fishable); ItemStack leftover = this.storeInContainer(fishable);
if(leftover != null){ if(StackUtil.isValid(leftover)){
EntityItem item = new EntityItem(this.worldObj, this.pos.getX()+0.5, this.pos.getY()+0.5, this.pos.getZ()+0.5, leftover.copy()); EntityItem item = new EntityItem(this.worldObj, this.pos.getX()+0.5, this.pos.getY()+0.5, this.pos.getZ()+0.5, leftover.copy());
item.lifespan = 2000; item.lifespan = 2000;
this.worldObj.spawnEntityInWorld(item); this.worldObj.spawnEntityInWorld(item);

View file

@ -164,7 +164,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
@Override @Override
public boolean isItemValidForSlot(int i, ItemStack stack){ public boolean isItemValidForSlot(int i, ItemStack stack){
return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && FurnaceRecipes.instance().getSmeltingResult(stack) != null; return (i == SLOT_INPUT_1 || i == SLOT_INPUT_2) && StackUtil.isValid(FurnaceRecipes.instance().getSmeltingResult(stack));
} }
public boolean canSmeltOn(int theInput, int theOutput){ public boolean canSmeltOn(int theInput, int theOutput){

View file

@ -13,12 +13,10 @@ package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor; import de.ellpeck.actuallyadditions.mod.network.gui.INumberReactor;
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;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
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;

View file

@ -12,6 +12,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues; import de.ellpeck.actuallyadditions.mod.config.values.ConfigStringListValues;
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;
@ -33,7 +34,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
} }
public static boolean canBeRepaired(ItemStack stack){ public static boolean canBeRepaired(ItemStack stack){
if(stack != null){ if(StackUtil.isValid(stack)){
Item item = stack.getItem(); Item item = stack.getItem();
if(item != null){ if(item != null){
if(item.isRepairable()){ if(item.isRepairable()){
@ -77,10 +78,10 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
super.updateEntity(); super.updateEntity();
if(!this.worldObj.isRemote){ if(!this.worldObj.isRemote){
ItemStack input = this.slots[SLOT_INPUT]; ItemStack input = this.slots[SLOT_INPUT];
if(this.slots[SLOT_OUTPUT] == null && canBeRepaired(input)){ if(!StackUtil.isValid(this.slots[SLOT_OUTPUT]) && canBeRepaired(input)){
if(input.getItemDamage() <= 0){ if(input.getItemDamage() <= 0){
this.slots[SLOT_OUTPUT] = input.copy(); this.slots[SLOT_OUTPUT] = input.copy();
this.slots[SLOT_INPUT] = null; this.slots[SLOT_INPUT] = StackUtil.getNull();
this.nextRepairTick = 0; this.nextRepairTick = 0;
} }
else{ else{
@ -124,7 +125,7 @@ public class TileEntityItemRepairer extends TileEntityInventoryBase implements I
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public int getItemDamageToScale(int i){ public int getItemDamageToScale(int i){
if(this.slots[SLOT_INPUT] != null){ if(StackUtil.isValid(this.slots[SLOT_INPUT])){
return (this.slots[SLOT_INPUT].getMaxDamage()-this.slots[SLOT_INPUT].getItemDamage())*i/this.slots[SLOT_INPUT].getMaxDamage(); return (this.slots[SLOT_INPUT].getMaxDamage()-this.slots[SLOT_INPUT].getItemDamage())*i/this.slots[SLOT_INPUT].getMaxDamage();
} }
return 0; return 0;

View file

@ -36,11 +36,6 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
super(0, "itemViewer"); super(0, "itemViewer");
} }
@Override
public void updateEntity(){
super.updateEntity();
}
@Override @Override
protected void getInvWrappers(SidedInvWrapper[] wrappers){ protected void getInvWrappers(SidedInvWrapper[] wrappers){
for(int i = 0; i < wrappers.length; i++){ for(int i = 0; i < wrappers.length; i++){
@ -191,7 +186,7 @@ public class TileEntityItemViewer extends TileEntityInventoryBase{
@Override @Override
public void setInventorySlotContents(int i, ItemStack stack){ public void setInventorySlotContents(int i, ItemStack stack){
if(stack != null){ if(StackUtil.isValid(stack)){
SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(i); SpecificItemHandlerInfo handler = this.getSwitchedIndexHandler(i);
if(handler != null){ if(handler != null){
ItemStack toInsert = stack.copy(); ItemStack toInsert = stack.copy();

View file

@ -89,7 +89,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
WrenchMode mode = WrenchMode.values()[data.theCompound.getInteger("LaserWrenchMode")]; WrenchMode mode = WrenchMode.values()[data.theCompound.getInteger("LaserWrenchMode")];
if(mode != WrenchMode.NO_PARTICLES){ if(mode != WrenchMode.NO_PARTICLES){
ItemStack stack = player.getHeldItemMainhand(); ItemStack stack = player.getHeldItemMainhand();
if(mode == WrenchMode.ALWAYS_PARTICLES || (stack != null && stack.getItem() instanceof ItemLaserWrench)){ if(mode == WrenchMode.ALWAYS_PARTICLES || (StackUtil.isValid(stack) && stack.getItem() instanceof ItemLaserWrench)){
Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj); Network network = ActuallyAdditionsAPI.connectionHandler.getNetworkFor(this.pos, this.worldObj);
if(network != null){ if(network != null){
for(IConnectionPair aPair : network.connections){ for(IConnectionPair aPair : network.connections){

View file

@ -32,8 +32,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{ public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public int priority;
public final Map<BlockPos, IItemHandler> handlersAround = new ConcurrentHashMap<BlockPos, IItemHandler>(); public final Map<BlockPos, IItemHandler> handlersAround = new ConcurrentHashMap<BlockPos, IItemHandler>();
public int priority;
public TileEntityLaserRelayItem(String name){ public TileEntityLaserRelayItem(String name){
super(name, LaserType.ITEM); super(name, LaserType.ITEM);

View file

@ -13,6 +13,7 @@ package de.ellpeck.actuallyadditions.mod.tile;
import cofh.api.energy.EnergyStorage; import cofh.api.energy.EnergyStorage;
import cofh.api.energy.IEnergyContainerItem; import cofh.api.energy.IEnergyContainerItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions; import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil; import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer; import net.darkhax.tesla.api.ITeslaConsumer;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -61,7 +62,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
for(int i = 0; i < player.inventory.getSizeInventory(); i++){ for(int i = 0; i < player.inventory.getSizeInventory(); i++){
if(this.storage.getEnergyStored() > 0){ if(this.storage.getEnergyStored() > 0){
ItemStack slot = player.inventory.getStackInSlot(i); ItemStack slot = player.inventory.getStackInSlot(i);
if(slot != null){ if(StackUtil.isValid(slot)){
Item item = slot.getItem(); Item item = slot.getItem();
int received = 0; int received = 0;
@ -199,10 +200,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
public ItemStack decrStackSize(int i, int j){ public ItemStack decrStackSize(int i, int j){
EntityPlayer player = this.getPlayer(); EntityPlayer player = this.getPlayer();
if(player != null){ if(player != null){
ItemStack stack = player.inventory.decrStackSize(i, j); return player.inventory.decrStackSize(i, j);
if(stack != null){
return stack;
}
} }
return null; return null;
} }
@ -211,10 +209,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
public ItemStack removeStackFromSlot(int index){ public ItemStack removeStackFromSlot(int index){
EntityPlayer player = this.getPlayer(); EntityPlayer player = this.getPlayer();
if(player != null){ if(player != null){
ItemStack stack = player.inventory.removeStackFromSlot(index); return player.inventory.removeStackFromSlot(index);
if(stack != null){
return stack;
}
} }
return null; return null;
} }

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile; package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor; import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil; import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -57,7 +58,7 @@ public class TileEntityRangedCollector extends TileEntityInventoryBase implement
ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX()-RANGE, this.pos.getY()-RANGE, this.pos.getZ()-RANGE, this.pos.getX()+RANGE, this.pos.getY()+RANGE, this.pos.getZ()+RANGE)); ArrayList<EntityItem> items = (ArrayList<EntityItem>)this.worldObj.getEntitiesWithinAABB(EntityItem.class, new AxisAlignedBB(this.pos.getX()-RANGE, this.pos.getY()-RANGE, this.pos.getZ()-RANGE, this.pos.getX()+RANGE, this.pos.getY()+RANGE, this.pos.getZ()+RANGE));
if(!items.isEmpty()){ if(!items.isEmpty()){
for(EntityItem item : items){ for(EntityItem item : items){
if(!item.isDead && !item.cannotPickup() && item.getEntityItem() != null){ if(!item.isDead && !item.cannotPickup() && StackUtil.isValid(item.getEntityItem())){
ItemStack toAdd = item.getEntityItem().copy(); ItemStack toAdd = item.getEntityItem().copy();
if(this.filter.check(toAdd, this.slots)){ if(this.filter.check(toAdd, this.slots)){
ArrayList<ItemStack> checkList = new ArrayList<ItemStack>(); ArrayList<ItemStack> checkList = new ArrayList<ItemStack>();

View file

@ -156,7 +156,7 @@ public class TileEntityXPSolidifier extends TileEntityInventoryBase implements I
if(StackUtil.isValid(this.slots[1]) && this.slots[1].getItem() instanceof ItemSolidifiedExperience){ if(StackUtil.isValid(this.slots[1]) && this.slots[1].getItem() instanceof ItemSolidifiedExperience){
this.amount += StackUtil.getStackSize(this.slots[1]); this.amount += StackUtil.getStackSize(this.slots[1]);
this.slots[1] = null; this.slots[1] = StackUtil.getNull();
} }
if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){ if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){

View file

@ -63,7 +63,7 @@ public final class AssetUtil{
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderItemInWorld(ItemStack stack){ public static void renderItemInWorld(ItemStack stack){
if(stack != null && stack.getItem() != null){ if(StackUtil.isValid(stack)){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();
GlStateManager.disableLighting(); GlStateManager.disableLighting();
GlStateManager.pushAttrib(); GlStateManager.pushAttrib();

View file

@ -77,7 +77,7 @@ public final class ItemUtil{
public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard){ public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard){
if(list != null && list.size() > 0){ if(list != null && list.size() > 0){
for(int i = 0; i < list.size(); i++){ for(int i = 0; i < list.size(); i++){
if((stack == null && list.get(i) == null) || areItemsEqual(stack, list.get(i), checkWildcard)){ if((!StackUtil.isValid(stack) && !StackUtil.isValid(list.get(i))) || areItemsEqual(stack, list.get(i), checkWildcard)){
return i; return i;
} }
} }
@ -86,7 +86,7 @@ public final class ItemUtil{
} }
public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){ public static boolean areItemsEqual(ItemStack stack1, ItemStack stack2, boolean checkWildcard){
return stack1 != null && stack2 != null && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD))); return StackUtil.isValid(stack1) && StackUtil.isValid(stack2) && (stack1.isItemEqual(stack2) || (checkWildcard && stack1.getItem() == stack2.getItem() && (stack1.getItemDamage() == Util.WILDCARD || stack2.getItemDamage() == Util.WILDCARD)));
} }
/** /**

View file

@ -13,7 +13,6 @@ package de.ellpeck.actuallyadditions.mod.util;
import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.util.text.translation.I18n; import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
@ -49,10 +48,6 @@ public final class StringUtil{
} }
} }
public static String getFluidInfo(FluidTank tank){
return "";
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public static void renderScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale){ public static void renderScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale){
GlStateManager.pushMatrix(); GlStateManager.pushMatrix();

View file

@ -60,10 +60,10 @@ public final class WorldUtil{
IItemHandler insertCap = insert.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, insertSide); IItemHandler insertCap = insert.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, insertSide);
ItemStack theoreticalExtract = extractCap.extractItem(slotExtract, Integer.MAX_VALUE, true); ItemStack theoreticalExtract = extractCap.extractItem(slotExtract, Integer.MAX_VALUE, true);
if(theoreticalExtract != null){ if(StackUtil.isValid(theoreticalExtract)){
ItemStack remaining = insertCap.insertItem(slotInsert, theoreticalExtract, false); ItemStack remaining = insertCap.insertItem(slotInsert, theoreticalExtract, false);
if(!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)){ if(!ItemStack.areItemStacksEqual(remaining, theoreticalExtract)){
int toExtract = remaining == null ? StackUtil.getStackSize(theoreticalExtract) : StackUtil.getStackSize(theoreticalExtract)-StackUtil.getStackSize(remaining); int toExtract = !StackUtil.isValid(remaining) ? StackUtil.getStackSize(theoreticalExtract) : StackUtil.getStackSize(theoreticalExtract)-StackUtil.getStackSize(remaining);
extractCap.extractItem(slotExtract, toExtract, false); extractCap.extractItem(slotExtract, toExtract, false);
return true; return true;
} }
@ -265,7 +265,7 @@ public final class WorldUtil{
backupSlots = new ItemStack[inventory.getSizeInventory()]; backupSlots = new ItemStack[inventory.getSizeInventory()];
for(int i = 0; i < backupSlots.length; i++){ for(int i = 0; i < backupSlots.length; i++){
ItemStack stack = inventory.getStackInSlot(i); ItemStack stack = inventory.getStackInSlot(i);
if(stack != null){ if(StackUtil.isValid(stack)){
backupSlots[i] = stack.copy(); backupSlots[i] = stack.copy();
} }
} }
@ -303,7 +303,7 @@ public final class WorldUtil{
public static int findFirstFilledSlot(ItemStack[] slots){ public static int findFirstFilledSlot(ItemStack[] slots){
for(int i = 0; i < slots.length; i++){ for(int i = 0; i < slots.length; i++){
if(slots[i] != null){ if(StackUtil.isValid(slots[i])){
return i; return i;
} }
} }