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){
ItemStack slot = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
String strg;
if(slot == null){
if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noLens");
}
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.metalists.TheColoredLampColors;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
@ -72,7 +73,7 @@ public class BlockColoredLamp extends BlockBase{
return true;
}
if(stack != null){
if(StackUtil.isValid(stack)){
//Changing Colors
int[] oreIDs = OreDictionary.getOreIDs(stack);
if(oreIDs.length > 0){

View file

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

View file

@ -33,7 +33,7 @@ public class BlockCrystal extends BlockBase{
public static final TheCrystals[] ALL_CRYSTALS = TheCrystals.values();
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){
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.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@ -59,7 +60,7 @@ public class BlockDistributorItem extends BlockContainerBase implements IHudDisp
ItemStack slot = distributor.getStackInSlot(0);
String strg;
if(slot == null){
if(!StackUtil.isValid(slot)){
strg = StringUtil.localize("info."+ModUtil.MOD_ID+".noItem");
}
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.TileEntityGiantChestMedium;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
@ -129,7 +130,7 @@ public class BlockGiantChest extends BlockContainerBase{
//Destroy the keeper
if(i != place){
NBTTagCompound compound = new NBTTagCompound();
if(slots[i] != null){
if(StackUtil.isValid(slots[i])){
slots[i].writeToNBT(compound);
}
list.appendTag(compound);
@ -138,7 +139,7 @@ public class BlockGiantChest extends BlockContainerBase{
if(list.tagCount() > 0){
ItemStack stackInQuestion = drops.get(0);
if(stackInQuestion != null){
if(StackUtil.isValid(stackInQuestion)){
if(stackInQuestion.getTagCompound() == null){
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);
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!";
}
else{

View file

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

View file

@ -182,8 +182,8 @@ public class BlockTinyTorch extends BlockBase{
if(enumfacing.getAxis().isHorizontal()){
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.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.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);
}
else{
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){
return heldItem == null || !FluidUtil.interactWithFluidHandler(heldItem, tank, player);
return !StackUtil.isValid(heldItem) || !FluidUtil.interactWithFluidHandler(heldItem, tank, player);
}
@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.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderDisplayStand extends TileEntitySpecialRenderer{
}
ItemStack stack = ((TileEntityDisplayStand)tile).getStackInSlot(0);
if(stack != null){
if(StackUtil.isValid(stack)){
GlStateManager.pushMatrix();
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.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderEmpowerer extends TileEntitySpecialRenderer{
}
ItemStack stack = ((TileEntityEmpowerer)tile).getStackInSlot(0);
if(stack != null){
if(StackUtil.isValid(stack)){
GlStateManager.pushMatrix();
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.mod.tile.TileEntityAtomicReconstructor;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
@ -29,7 +30,7 @@ public class RenderReconstructorLens extends TileEntitySpecialRenderer{
}
ItemStack stack = ((TileEntityAtomicReconstructor)tile).getStackInSlot(0);
if(stack != null && stack.getItem() instanceof ILensItem){
if(StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem){
GlStateManager.pushMatrix();
GlStateManager.translate((float)x+0.5F, (float)y-0.5F, (float)z+0.5F);
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.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
@ -77,7 +78,7 @@ public class BookmarkButton extends GuiButton{
if(this.assignedPage != null){
ItemStack display = this.assignedPage.getChapter().getDisplayItemStack();
if(display != null){
if(StackUtil.isValid(display)){
GlStateManager.pushMatrix();
AssetUtil.renderStackToGui(display, this.xPosition+2, this.yPosition+1, 0.725F);
GlStateManager.popMatrix();

View file

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

View file

@ -10,7 +10,6 @@
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.IBookletEntry;
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.IBookletPage;
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.crafting.CrusherCrafting;
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.IBookletEntry;
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.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
@ -41,6 +41,41 @@ public class BookletEntry implements IBookletEntry{
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
public List<IBookletChapter> getAllChapters(){
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(){
this.color = TextFormatting.DARK_GREEN;
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 ResourceLocation RES_LOC_GUI = AssetUtil.getBookletGuiLocation("guiBooklet");
public static final ResourceLocation RES_LOC_GADGETS = AssetUtil.getBookletGuiLocation("guiBookletGadgets");
protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
public GuiScreen previousScreen;
public GuiBookletBase parentPage;
private GuiButton buttonLeft;
private GuiButton buttonRight;
private GuiButton buttonBack;
protected final BookmarkButton[] bookmarkButtons = new BookmarkButton[12];
public GuiTextField searchField;
protected int xSize;
protected int ySize;
protected int guiLeft;
protected int guiTop;
private GuiButton buttonLeft;
private GuiButton buttonRight;
private GuiButton buttonBack;
public GuiBooklet(GuiScreen previousScreen, GuiBookletBase parentPage){
this.previousScreen = previousScreen;

View file

@ -29,9 +29,9 @@ import java.util.List;
@SideOnly(Side.CLIENT)
public class GuiPage extends GuiBooklet{
private int pageTimer;
private final List<ItemDisplay> itemDisplays = new ArrayList<ItemDisplay>();
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){
super(previousScreen, parentPage);

View file

@ -30,14 +30,12 @@ import java.util.Map;
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 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){
this.localizationKey = localizationKey;

View file

@ -19,7 +19,6 @@ import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextFormatting;
@ -31,13 +30,12 @@ import java.util.List;
public class ItemDisplay{
private final GuiPage gui;
public final int x;
public final int y;
public final float scale;
public ItemStack stack;
private final GuiPage gui;
private final IBookletPage page;
public ItemStack stack;
public ItemDisplay(GuiPage gui, int x, int y, float scale, ItemStack stack, boolean shouldTryTransfer){
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.StringUtil;
import de.ellpeck.actuallyadditions.mod.util.Util;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
@ -33,10 +32,10 @@ import java.util.List;
public class PageCrafting extends BookletPage{
private final List<IRecipe> recipes;
private int recipeAt;
private String recipeTypeLocKey;
private boolean isWildcard;
private final List<IRecipe> recipes;
public PageCrafting(int localizationKey, List<IRecipe> recipes){
super(localizationKey);
@ -103,7 +102,7 @@ public class PageCrafting extends BookletPage{
for(IRecipe recipe : this.recipes){
if(recipe != null){
ItemStack output = recipe.getRecipeOutput();
if(output != null){
if(StackUtil.isValid(output)){
ItemStack copy = output.copy();
if(this.isWildcard){
copy.setItemDamage(Util.WILDCARD);
@ -146,7 +145,7 @@ public class PageCrafting extends BookletPage{
for(int i = 0; i < shaped.getInput().length; i++){
Object input = shaped.getInput()[i];
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";
@ -155,7 +154,7 @@ public class PageCrafting extends BookletPage{
ShapelessOreRecipe shapeless = (ShapelessOreRecipe)recipe;
for(int i = 0; i < shapeless.getInput().size(); 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";
}

View file

@ -30,6 +30,15 @@ public class PageFurnace extends BookletPage{
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
public void drawScreenPre(GuiBookletBase gui, int startX, int startY, int mouseX, int mouseY, float 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);
}
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
public void getItemStacksForPage(List<ItemStack> list){
super.getItemStacksForPage(list);

View file

@ -11,7 +11,6 @@
package de.ellpeck.actuallyadditions.mod.booklet.page;
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.SideOnly;
@ -21,13 +20,6 @@ public class PageTextOnly extends BookletPage{
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)
public static void renderTextToPage(GuiBookletBase gui, BookletPage page, int x, int y){
String text = page.getInfoText();
@ -35,4 +27,11 @@ public class PageTextOnly extends BookletPage{
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;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapedOreRecipe;
@ -27,7 +28,7 @@ public class RecipeKeepDataShaped extends ShapedOreRecipe{
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory){
ItemStack stack = super.getCraftingResult(inventory);
if(stack != null){
if(StackUtil.isValid(stack)){
for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack input = inventory.getStackInSlot(i);
if(ItemUtil.areItemsEqual(this.nbtCopyStack, input, true)){

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.crafting;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapelessOreRecipe;
@ -27,7 +28,7 @@ public class RecipeKeepDataShapeless extends ShapelessOreRecipe{
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory){
ItemStack stack = super.getCraftingResult(inventory);
if(stack != null){
if(StackUtil.isValid(stack)){
for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack input = inventory.getStackInSlot(i);
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.TileEntityBase;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneTorch;
@ -54,7 +55,7 @@ public class ClientEvents{
@SubscribeEvent
public void onTooltipEvent(ItemTooltipEvent event){
//Advanced Item Info
if(event.getItemStack() != null && event.getItemStack().getItem() != null){
if(StackUtil.isValid(event.getItemStack())){
if(ConfigBoolValues.CTRL_EXTRA_INFO.isEnabled()){
if(GuiScreen.isCtrlKeyDown()){
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;
ItemStack stack = player.getHeldItemMainhand();
if(stack != null){
if(StackUtil.isValid(stack)){
if(stack.getItem() instanceof IHudDisplay){
((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);
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!";
}
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.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntitySpider;
import net.minecraft.entity.player.EntityPlayer;
@ -79,7 +80,7 @@ public class CommonEvents{
checkAchievements(event.crafting, event.player, InitAchievements.Type.CRAFTING);
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();
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();
if(stack != null && stack.getItem() instanceof ItemBag){
if(StackUtil.isValid(stack) && stack.getItem() instanceof ItemBag){
ItemDrill.loadSlotsFromNBT(this.bagInventory.slots, inventory.getCurrentItem());
if(stack.hasTagCompound()){
NBTTagCompound compound = stack.getTagCompound();
@ -203,7 +203,7 @@ public class ContainerBag extends Container implements IButtonReactor{
@Override
public void onContainerClosed(EntityPlayer player){
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());
NBTTagCompound compound = stack.getTagCompound();
this.filter.writeToNBT(compound, "Filter");

View file

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

View file

@ -64,7 +64,7 @@ public class ContainerDrill extends Container{
}
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());
}
}
@ -135,7 +135,7 @@ public class ContainerDrill extends Container{
@Override
public void onContainerClosed(EntityPlayer player){
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());
}
super.onContainerClosed(player);

View file

@ -59,7 +59,7 @@ public class ContainerEnergizer extends Container{
@Override
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

View file

@ -58,7 +58,7 @@ public class ContainerEnervator extends Container{
@Override
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

View file

@ -59,7 +59,7 @@ public class ContainerFilter extends Container{
}
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());
}
}
@ -128,7 +128,7 @@ public class ContainerFilter extends Container{
@Override
public void onContainerClosed(EntityPlayer player){
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());
}
super.onContainerClosed(player);

View file

@ -67,7 +67,7 @@ public class ContainerFurnaceDouble extends Container{
//Other Slots in Inventory excluded
else if(slot >= inventoryStart){
//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_2, TileEntityFurnaceDouble.SLOT_INPUT_2+1, false)){
return StackUtil.getNull();

View file

@ -158,7 +158,7 @@ public class GuiHandler implements IGuiHandler{
case FLUID_COLLECTOR:
return new GuiFluidCollector(player.inventory, tile);
case COFFEE_MACHINE:
return new GuiCoffeeMachine(player.inventory, tile, x, y, z, world);
return new GuiCoffeeMachine(player.inventory, tile);
case DRILL:
return new GuiDrill(player.inventory);
case FILTER:
@ -168,7 +168,7 @@ public class GuiHandler implements IGuiHandler{
case ENERVATOR:
return new GuiEnervator(player, tile);
case XP_SOLIDIFIER:
return new GuiXPSolidifier(player.inventory, tile, x, y, z, world);
return new GuiXPSolidifier(player.inventory, tile);
case CLOUD:
return new GuiSmileyCloud(tile, x, y, z, world);
case BOOK:
@ -189,7 +189,7 @@ public class GuiHandler implements IGuiHandler{
case DIRECTIONAL_BREAKER:
return new GuiDirectionalBreaker(player.inventory, tile);
case RANGED_COLLECTOR:
return new GuiRangedCollector(player.inventory, tile, x, y, z, world);
return new GuiRangedCollector(player.inventory, tile);
case MINER:
return new GuiMiner(player.inventory, tile);
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.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
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 final TileEntityCoffeeMachine machine;
private final int x;
private final int y;
private final int z;
private final World world;
private EnergyDisplay energy;
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));
this.machine = (TileEntityCoffeeMachine)tile;
this.xSize = 176;
this.ySize = 93+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
}
@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){
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");
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.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
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 final TileEntityRangedCollector collector;
private final int x;
private final int y;
private final int z;
private final World world;
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));
this.collector = (TileEntityRangedCollector)tile;
this.xSize = 176;
this.ySize = 86+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
}
@Override

View file

@ -22,7 +22,6 @@ import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
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 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));
this.solidifier = (TileEntityXPSolidifier)tile;
this.xSize = 176;
this.ySize = 93+86;
this.x = x;
this.y = y;
this.z = z;
this.world = world;
}
@Override

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,6 +38,52 @@ public class ItemFillingWand extends ItemEnergy{
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
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){
@ -200,52 +246,6 @@ public class ItemFillingWand extends ItemEnergy{
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
public int getMaxItemUseDuration(ItemStack stack){
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.GuiHandler;
import de.ellpeck.actuallyadditions.mod.items.base.ItemBase;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -50,7 +51,7 @@ public class ItemFilter extends ItemBase{
ItemDrill.loadSlotsFromNBT(slots, stack);
if(slots != null && slots.length > 0){
for(ItemStack slot : slots){
if(slot != null && slot.getItem() != null){
if(StackUtil.isValid(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.items.base.ItemFoodBase;
import de.ellpeck.actuallyadditions.mod.items.metalists.TheFoods;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.creativetab.CreativeTabs;
@ -44,7 +45,7 @@ public class ItemFoods extends ItemFoodBase{
public ItemStack onItemUseFinish(ItemStack stack, World world, EntityLivingBase player){
ItemStack stackToReturn = super.onItemUseFinish(stack, world, player);
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(!world.isRemote){
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;
import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.IGrowable;
@ -43,7 +44,7 @@ public class ItemGrowthRing extends ItemEnergy{
ItemStack equipped = player.getHeldItemMainhand();
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>();
//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.tile.TileEntityPlayerInterface;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.entity.Entity;
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){
if(!player.worldObj.isRemote){
ItemStack stack = player.getHeldItemMainhand();
if(stack != null && stack.getItem() == this){
if(StackUtil.isValid(stack) && stack.getItem() == this){
if(entity instanceof EntityPlayer){
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.metalists.ThePotionRings;
import de.ellpeck.actuallyadditions.mod.util.IColorProvidingItem;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import net.minecraft.client.renderer.color.IItemColor;
import net.minecraft.creativetab.CreativeTabs;
@ -67,7 +68,7 @@ public class ItemPotionRing extends ItemBase implements IColorProvidingItem, IDi
if(player instanceof EntityPlayer){
EntityPlayer thePlayer = (EntityPlayer)player;
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.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
@ -38,7 +39,7 @@ public class ItemWaterRemovalRing extends ItemEnergy{
ItemStack equipped = player.getHeldItemMainhand();
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
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.items.base.ItemBase;
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.player.EntityPlayer;
import net.minecraft.item.EnumRarity;
@ -90,11 +91,11 @@ public class ItemWingsOfTheBats extends ItemBase{
*/
public static ItemStack getWingItem(EntityPlayer player){
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 null;
return StackUtil.getNull();
}
@SubscribeEvent
@ -120,7 +121,7 @@ public class ItemWingsOfTheBats extends ItemBase{
public void livingUpdateEvent(LivingEvent.LivingUpdateEvent event){
if(event.getEntityLiving() instanceof EntityPlayer){
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(!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.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -68,7 +69,7 @@ public class ItemToolAA extends ItemTool{
@Override
public boolean getIsRepairable(ItemStack itemToRepair, ItemStack stack){
if(this.repairItem != null){
if(StackUtil.isValid(this.repairItem)){
return ItemUtil.areItemsEqual(this.repairItem, stack, false);
}
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.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.IColorLensChanger;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
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));
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);
if(newStack != null){
if(StackUtil.isValid(newStack)){
item.setDead();
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){
if(stack != null){
if(StackUtil.isValid(stack)){
Item item = stack.getItem();
if(item != null){
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.lens.Lens;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentData;
@ -42,7 +43,7 @@ public class LensDisenchanting extends Lens{
for(EntityItem item : items){
if(item != null && !item.isDead){
ItemStack stack = item.getEntityItem();
if(stack != null){
if(StackUtil.isValid(stack)){
Item stackItem = stack.getItem();
if(stackItem == Items.BOOK || stackItem == Items.ENCHANTED_BOOK){
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.lens.Lens;
import de.ellpeck.actuallyadditions.api.recipe.WeightedOre;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockNetherrack;
import net.minecraft.block.BlockStone;
@ -119,7 +120,7 @@ public class LensMining extends Lens{
List<ItemStack> stacks = OreDictionary.getOres(ore.name, false);
if(stacks != null && !stacks.isEmpty()){
for(ItemStack aStack : stacks){
if(aStack != null && aStack.getItem() instanceof ItemBlock){
if(StackUtil.isValid(aStack) && aStack.getItem() instanceof ItemBlock){
adaptedUse += (totalWeight-ore.itemWeight)%40000;
stack = aStack;

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.items.metalists;
import de.ellpeck.actuallyadditions.mod.items.InitItems;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.init.Items;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.ItemStack;
@ -45,7 +46,7 @@ public enum TheFoods{
public final boolean getsDrunken;
public final int useDuration;
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){
this.name = name;

View file

@ -19,7 +19,6 @@ import mezz.jei.api.recipe.BlankRecipeCategory;
import net.minecraft.item.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
public class CoffeeMachineRecipeCategory extends BlankRecipeCategory<CoffeeMachineRecipeWrapper>{

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.jei.crusher;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import mezz.jei.api.IGuiHelper;
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().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().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.booklet.misc.BookletUtils;
import de.ellpeck.actuallyadditions.mod.jei.RecipeWrapperWithButton;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.StringUtil;
import mezz.jei.api.ingredients.IIngredients;
import net.minecraft.client.Minecraft;
@ -37,7 +38,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
List list = new ArrayList();
list.add(this.theRecipe.outputOneStack);
if(this.theRecipe.outputTwoStack != null){
if(StackUtil.isValid(this.theRecipe.outputTwoStack)){
list.add(this.theRecipe.outputTwoStack);
}
ingredients.setOutputs(ItemStack.class, list);
@ -45,7 +46,7 @@ public class CrusherRecipeWrapper extends RecipeWrapperWithButton{
@Override
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);
}

View file

@ -17,8 +17,6 @@ import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
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 net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
import java.util.Arrays;
public class EmpowererRecipeWrapper extends RecipeWrapperWithButton{

View file

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

View file

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

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.misc.special;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
@ -28,42 +29,44 @@ public class RenderSpecial{
}
public void render(EntityPlayer player, float partialTicks){
if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){
return;
}
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
if(StackUtil.isValid(this.theThingToRender)){
if(player.isInvisible() || !player.isWearing(EnumPlayerModelParts.CAPE) || player.isElytraFlying()){
return;
}
boolean isBlock = this.theThingToRender.getItem() instanceof ItemBlock;
GlStateManager.pushMatrix();
Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks);
Vec3d playerPos = player.getPositionEyes(partialTicks);
GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord, playerPos.zCoord-currentPos.zCoord);
GlStateManager.translate(0D, 2.375D-(player.isSneaking() ? 0.125D : 0D)+(isBlock ? 0D : 0.1875D), 0D);
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
float size = isBlock ? 0.5F : 0.4F;
GlStateManager.scale(size, size, size);
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
//Peck edit: What do you mean by "nice" you jackass? >_>
double boop = Minecraft.getSystemTime()/1000D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.25, 0D);
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
GlStateManager.disableLighting();
if(this.theThingToRender != null){
GlStateManager.pushMatrix();
Vec3d currentPos = Minecraft.getMinecraft().thePlayer.getPositionEyes(partialTicks);
Vec3d playerPos = player.getPositionEyes(partialTicks);
GlStateManager.translate(playerPos.xCoord-currentPos.xCoord, playerPos.yCoord-currentPos.yCoord, playerPos.zCoord-currentPos.zCoord);
GlStateManager.translate(0D, 2.375D-(player.isSneaking() ? 0.125D : 0D)+(isBlock ? 0D : 0.1875D), 0D);
GlStateManager.rotate(180F, 1.0F, 0.0F, 1.0F);
float size = isBlock ? 0.5F : 0.4F;
GlStateManager.scale(size, size, size);
//Make the floaty stuff look nice using sine waves \o/ -xdjackiexd
//Peck edit: What do you mean by "nice" you jackass? >_>
double boop = Minecraft.getSystemTime()/1000D;
GlStateManager.translate(0D, Math.sin(boop%(2*Math.PI))*0.25, 0D);
GlStateManager.rotate((float)(((boop*40D)%360)), 0, 1, 0);
GlStateManager.disableLighting();
GlStateManager.pushMatrix();
if(!isBlock){
GlStateManager.translate(0D, 0.5D, 0D);
}
GlStateManager.rotate(180F, 1F, 0F, 0F);
AssetUtil.renderItemInWorld(this.theThingToRender);
GlStateManager.popMatrix();
}
GlStateManager.enableLighting();
GlStateManager.popMatrix();
GlStateManager.enableLighting();
GlStateManager.popMatrix();
}
}
}

View file

@ -10,6 +10,7 @@
package de.ellpeck.actuallyadditions.mod.misc.special;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -46,7 +47,7 @@ public class SpecialRenderInit{
meta = 0;
}
ItemStack stack = null;
ItemStack stack = StackUtil.getNull();
//Get the Item from the String
ResourceLocation resLoc = new ResourceLocation(itemName);
if(Item.REGISTRY.containsKey(resLoc)){
@ -59,7 +60,7 @@ public class SpecialRenderInit{
}
//Add a new Special Renderer to the list
if(stack != null){
if(StackUtil.isValid(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.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.inventory.Container;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -38,10 +37,7 @@ import java.util.UUID;
public final class PacketHandler{
public static SimpleNetworkWrapper theNetwork;
public static final List<IDataHandler> DATA_HANDLERS = new ArrayList<IDataHandler>();
public static final IDataHandler PARTICLE_HANDLER = new IDataHandler(){
@Override
@SideOnly(Side.CLIENT)
@ -56,7 +52,7 @@ public final class PacketHandler{
World world = Minecraft.getMinecraft().theWorld;
if(world != null){
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);
}
}
@ -71,7 +67,7 @@ public final class PacketHandler{
if(tile instanceof IButtonReactor){
IButtonReactor reactor = (IButtonReactor)tile;
Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
if(entity != null && entity instanceof EntityPlayer){
if(entity instanceof EntityPlayer){
reactor.onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
}
}
@ -82,9 +78,9 @@ public final class PacketHandler{
public void handleData(NBTTagCompound compound){
World world = DimensionManager.getWorld(compound.getInteger("WorldID"));
Entity entity = world.getEntityByID(compound.getInteger("PlayerID"));
if(entity != null && entity instanceof EntityPlayer){
if(entity instanceof EntityPlayer){
Container container = ((EntityPlayer)entity).openContainer;
if(container != null && container instanceof IButtonReactor){
if(container instanceof IButtonReactor){
((IButtonReactor)container).onButtonPressed(compound.getInteger("ButtonID"), (EntityPlayer)entity);
}
}
@ -125,6 +121,7 @@ public final class PacketHandler{
}
}
};
public static SimpleNetworkWrapper theNetwork;
public static void init(){
theNetwork = NetworkRegistry.INSTANCE.newSimpleChannel(ModUtil.MOD_ID);

View file

@ -11,13 +11,7 @@
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.booklet.entry.BookletEntryAllItems;
import de.ellpeck.actuallyadditions.mod.config.values.ConfigBoolValues;
import de.ellpeck.actuallyadditions.mod.entity.InitEntities;
import de.ellpeck.actuallyadditions.mod.event.ClientEvents;
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.renderer.block.model.ModelResourceLocation;
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.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import java.util.ArrayList;
import java.util.HashMap;
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.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;
@ -53,12 +54,12 @@ public final class CrusherRecipeRegistry{
CrusherRecipe recipe = ActuallyAdditionsAPI.CRUSHER_RECIPES.get(i);
addedRecipes.add(recipe.inputStack+" -> "+recipe.outputOneStack);
}
ModUtil.LOGGER.info("Added "+addedRecipes.size()+" Crusher Recipes automatically: "+addedRecipes.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.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);
}
public static boolean hasBlacklistedOutput(ItemStack output){
if(output != null){
if(StackUtil.isValid(output)){
Item item = output.getItem();
if(item != null){
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.metalists.TheMiscItems;
import de.ellpeck.actuallyadditions.mod.util.ModUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@ -49,7 +50,7 @@ public class FuelHandler implements IFuelHandler{
@Override
public int getBurnTime(ItemStack stack){
if(stack != null){
if(StackUtil.isValid(stack)){
for(Fuel fuel : FUEL_LIST){
if(stack.isItemEqual(fuel.fuel)){
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.mod.misc.SoundHandler;
import de.ellpeck.actuallyadditions.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.block.state.IBlockState;
import net.minecraft.item.ItemStack;
@ -116,7 +117,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
@Override
public Lens getLens(){
if(this.slots[0] != null){
if(StackUtil.isValid(this.slots[0])){
if(this.slots[0].getItem() instanceof ILensItem){
return ((ILensItem)this.slots[0].getItem()).getLens();
}
@ -151,7 +152,7 @@ public class TileEntityAtomicReconstructor extends TileEntityInventoryBase imple
@Override
public boolean isItemValidForSlot(int i, ItemStack stack){
return stack != null && stack.getItem() instanceof ILensItem;
return StackUtil.isValid(stack) && stack.getItem() instanceof ILensItem;
}
@Override

View file

@ -130,7 +130,7 @@ public class TileEntityCoffeeMachine extends TileEntityInventoryBase implements
}
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;
if(toAdd <= COFFEE_CACHE_MAX_AMOUNT-this.coffeeCacheAmount){
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){
if(input != null){
if(StackUtil.isValid(input)){
for(CompostRecipe recipe : ActuallyAdditionsAPI.COMPOST_RECIPES){
if(input.isItemEqual(recipe.input)){
return recipe;
@ -97,7 +97,7 @@ public class TileEntityCompost extends TileEntityInventoryBase{
@Override
public int getInventoryStackLimit(){
if(this.slots[0] != null){
if(StackUtil.isValid(this.slots[0])){
CompostRecipe recipe = getRecipeForInput(this.slots[0]);
if(recipe != null && StackUtil.isValid(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 de.ellpeck.actuallyadditions.api.misc.IDisplayStandItem;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemBlock;
@ -33,7 +34,7 @@ public class TileEntityDisplayStand extends TileEntityInventoryBase implements I
super.updateEntity();
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());
if(item != null){
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.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
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
public boolean shouldSyncSlots(){
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.mod.util.AssetUtil;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
@ -36,9 +37,9 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
public static List<EmpowererRecipe> getRecipesForInput(ItemStack input){
List<EmpowererRecipe> recipesThatWork = new ArrayList<EmpowererRecipe>();
if(input != null){
if(StackUtil.isValid(input)){
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);
}
}
@ -100,7 +101,7 @@ public class TileEntityEmpowerer extends TileEntityInventoryBase{
BlockPos offset = this.pos.offset(facing, 3);
TileEntity tile = this.worldObj.getTileEntity(offset);
if(tile != null && tile instanceof TileEntityDisplayStand){
if(tile instanceof TileEntityDisplayStand){
TileEntityDisplayStand stand = (TileEntityDisplayStand)tile;
ItemStack standItem = stand.getStackInSlot(0);
int containPlace = ItemUtil.getPlaceAt(itemsStillNeeded, standItem, true);

View file

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

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());
for(ItemStack fishable : fishables){
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());
item.lifespan = 2000;
this.worldObj.spawnEntityInWorld(item);

View file

@ -164,7 +164,7 @@ public class TileEntityFurnaceDouble extends TileEntityInventoryBase implements
@Override
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){

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.INumberReactor;
import de.ellpeck.actuallyadditions.mod.util.ItemUtil;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;

View file

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

View file

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

View file

@ -89,7 +89,7 @@ public abstract class TileEntityLaserRelay extends TileEntityBase{
WrenchMode mode = WrenchMode.values()[data.theCompound.getInteger("LaserWrenchMode")];
if(mode != WrenchMode.NO_PARTICLES){
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);
if(network != null){
for(IConnectionPair aPair : network.connections){

View file

@ -32,8 +32,8 @@ import java.util.concurrent.ConcurrentHashMap;
public class TileEntityLaserRelayItem extends TileEntityLaserRelay{
public int priority;
public final Map<BlockPos, IItemHandler> handlersAround = new ConcurrentHashMap<BlockPos, IItemHandler>();
public int priority;
public TileEntityLaserRelayItem(String name){
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.IEnergyContainerItem;
import de.ellpeck.actuallyadditions.mod.ActuallyAdditions;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.compat.TeslaUtil;
import net.darkhax.tesla.api.ITeslaConsumer;
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++){
if(this.storage.getEnergyStored() > 0){
ItemStack slot = player.inventory.getStackInSlot(i);
if(slot != null){
if(StackUtil.isValid(slot)){
Item item = slot.getItem();
int received = 0;
@ -199,10 +200,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
public ItemStack decrStackSize(int i, int j){
EntityPlayer player = this.getPlayer();
if(player != null){
ItemStack stack = player.inventory.decrStackSize(i, j);
if(stack != null){
return stack;
}
return player.inventory.decrStackSize(i, j);
}
return null;
}
@ -211,10 +209,7 @@ public class TileEntityPlayerInterface extends TileEntityInventoryBase implement
public ItemStack removeStackFromSlot(int index){
EntityPlayer player = this.getPlayer();
if(player != null){
ItemStack stack = player.inventory.removeStackFromSlot(index);
if(stack != null){
return stack;
}
return player.inventory.removeStackFromSlot(index);
}
return null;
}

View file

@ -11,6 +11,7 @@
package de.ellpeck.actuallyadditions.mod.tile;
import de.ellpeck.actuallyadditions.mod.network.gui.IButtonReactor;
import de.ellpeck.actuallyadditions.mod.util.StackUtil;
import de.ellpeck.actuallyadditions.mod.util.WorldUtil;
import net.minecraft.entity.item.EntityItem;
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));
if(!items.isEmpty()){
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();
if(this.filter.check(toAdd, this.slots)){
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){
this.amount += StackUtil.getStackSize(this.slots[1]);
this.slots[1] = null;
this.slots[1] = StackUtil.getNull();
}
if(this.lastAmount != this.amount && this.sendUpdateWithInterval()){

View file

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

View file

@ -77,7 +77,7 @@ public final class ItemUtil{
public static int getPlaceAt(List<ItemStack> list, ItemStack stack, boolean checkWildcard){
if(list != null && list.size() > 0){
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;
}
}
@ -86,7 +86,7 @@ public final class ItemUtil{
}
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.renderer.GlStateManager;
import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
@ -49,10 +48,6 @@ public final class StringUtil{
}
}
public static String getFluidInfo(FluidTank tank){
return "";
}
@SideOnly(Side.CLIENT)
public static void renderScaledAsciiString(FontRenderer font, String text, int x, int y, int color, boolean shadow, float scale){
GlStateManager.pushMatrix();

View file

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