• Recently Browsing

    No registered users viewing this page.

  • Posts

    • Don't Worry I just Removed Unnecessary Mods  
    • Hello, I use tile entity from the furnace for my tile entity and I wanted to make the renderer for this block, but my renderer does not see items that are in block inventory. I still have empty inventory and I don't know why.   Tile entity: package cz.grossik.farmcraft.block; import java.util.List; import java.util.Map; import java.util.Map.Entry; import javax.annotation.Nullable; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import cz.grossik.farmcraft.recipe.FarmCraftRecipeType; import cz.grossik.farmcraft.container.JuicerContainer; import cz.grossik.farmcraft.init.FarmCraftTileEntityTypes; import cz.grossik.farmcraft.init.ItemInit; import cz.grossik.farmcraft.recipe.AbstractJuicerRecipe; import net.minecraft.block.BlockState; import net.minecraft.block.BrewingStandBlock; import net.minecraft.entity.item.ExperienceOrbEntity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.IRecipeHelperPopulator; import net.minecraft.inventory.IRecipeHolder; import net.minecraft.inventory.ISidedInventory; import net.minecraft.inventory.ItemStackHelper; import net.minecraft.inventory.container.Container; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.item.crafting.IRecipe; import net.minecraft.item.crafting.IRecipeType; import net.minecraft.item.crafting.RecipeItemHelper; import net.minecraft.nbt.CompoundNBT; import net.minecraft.tileentity.ITickableTileEntity; import net.minecraft.tileentity.LockableTileEntity; import net.minecraft.util.Direction; import net.minecraft.util.IIntArray; import net.minecraft.util.IItemProvider; import net.minecraft.util.NonNullList; import net.minecraft.util.ResourceLocation; import net.minecraft.util.math.MathHelper; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; import net.minecraftforge.common.capabilities.Capability; import net.minecraftforge.common.util.LazyOptional; import net.minecraftforge.items.CapabilityItemHandler; import net.minecraftforge.items.ItemStackHandler; public class JuicerTileEntity extends LockableTileEntity implements ISidedInventory, IRecipeHolder, IRecipeHelperPopulator, ITickableTileEntity { private static final int[] SLOTS_UP = new int[]{0}; private static final int[] SLOTS_DOWN = new int[]{2, 1}; private static final int[] SLOTS_HORIZONTAL = new int[]{1}; protected NonNullList<ItemStack> items = NonNullList.withSize(3, ItemStack.EMPTY); private int burnTime; private int recipesUsed; private int cookTime; private int cookTimeTotal; protected final IIntArray furnaceData = new IIntArray() { public int get(int index) { switch(index) { case 0: return JuicerTileEntity.this.burnTime; case 1: return JuicerTileEntity.this.recipesUsed; case 2: return JuicerTileEntity.this.cookTime; case 3: return JuicerTileEntity.this.cookTimeTotal; default: return 0; } } public void set(int index, int value) { switch(index) { case 0: JuicerTileEntity.this.burnTime = value; break; case 1: JuicerTileEntity.this.recipesUsed = value; break; case 2: JuicerTileEntity.this.cookTime = value; break; case 3: JuicerTileEntity.this.cookTimeTotal = value; } } public int size() { return 4; } }; private final Map<ResourceLocation, Integer> field_214022_n = Maps.newHashMap(); protected final IRecipeType<?> recipeType; public JuicerTileEntity() { super(FarmCraftTileEntityTypes.juicer.get()); this.recipeType = FarmCraftRecipeType.JUICER_RECIPE; } protected ITextComponent getDefaultName() { return new TranslationTextComponent("farmcraft.container.juicer"); } protected Container createMenu(int id, PlayerInventory player) { return new JuicerContainer(id, player, this, this.furnaceData); } @Deprecated //Forge - get burn times by calling ForgeHooks#getBurnTime(ItemStack) public static Map<Item, Integer> getBurnTimes() { Map<Item, Integer> map = Maps.newLinkedHashMap(); addItemBurnTime(map, ItemInit.juice_glass, 200); return map; } private static void addItemBurnTime(Map<Item, Integer> map, IItemProvider itemProvider, int burnTimeIn) { map.put(itemProvider.asItem(), burnTimeIn); } public boolean isBurning() { return this.burnTime > 0; } public void read(CompoundNBT compound) { super.read(compound); this.items = NonNullList.withSize(this.getSizeInventory(), ItemStack.EMPTY); ItemStackHelper.loadAllItems(compound, this.items); this.burnTime = compound.getInt("BurnTime"); this.cookTime = compound.getInt("CookTime"); this.cookTimeTotal = compound.getInt("CookTimeTotal"); this.recipesUsed = this.getBurnTime(this.items.get(1)); int i = compound.getShort("RecipesUsedSize"); for(int j = 0; j < i; ++j) { ResourceLocation resourcelocation = new ResourceLocation(compound.getString("RecipeLocation" + j)); int k = compound.getInt("RecipeAmount" + j); this.field_214022_n.put(resourcelocation, k); } } public CompoundNBT write(CompoundNBT compound) { super.write(compound); compound.putInt("BurnTime", this.burnTime); compound.putInt("CookTime", this.cookTime); compound.putInt("CookTimeTotal", this.cookTimeTotal); ItemStackHelper.saveAllItems(compound, this.items); compound.putShort("RecipesUsedSize", (short)this.field_214022_n.size()); int i = 0; for(Entry<ResourceLocation, Integer> entry : this.field_214022_n.entrySet()) { compound.putString("RecipeLocation" + i, entry.getKey().toString()); compound.putInt("RecipeAmount" + i, entry.getValue()); ++i; } return compound; } public void tick() { boolean flag = this.isBurning(); boolean flag1 = false; if (this.isBurning()) { --this.burnTime; } if (!this.world.isRemote) { ItemStack itemstack = this.items.get(1); if (this.isBurning() || !itemstack.isEmpty() && !this.items.get(0).isEmpty()) { IRecipe<?> irecipe = this.world.getRecipeManager().getRecipe((IRecipeType<AbstractJuicerRecipe>)this.recipeType, this, this.world).orElse(null); if (!this.isBurning() && this.canSmelt(irecipe)) { this.burnTime = this.getBurnTime(itemstack); this.recipesUsed = this.burnTime; if (this.isBurning()) { flag1 = true; if (itemstack.hasContainerItem()) this.items.set(1, itemstack.getContainerItem()); else if (!itemstack.isEmpty()) { Item item = itemstack.getItem(); //itemstack.shrink(1); if (itemstack.isEmpty()) { this.items.set(1, itemstack.getContainerItem()); } } } } if (this.isBurning() && this.canSmelt(irecipe)) { ++this.cookTime; if (this.cookTime == this.cookTimeTotal) { this.cookTime = 0; this.cookTimeTotal = this.func_214005_h(); this.func_214007_c(irecipe); flag1 = true; } } else { this.cookTime = 0; this.burnTime = 0; } } else if (!this.isBurning() && this.cookTime > 0) { this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal); } if (flag != this.isBurning()) { flag1 = true; this.world.setBlockState(this.pos, this.world.getBlockState(this.pos).with(JuicerBlock.VYPALUJE, Boolean.valueOf(this.isBurning())), 3); } BlockState blockstate = this.world.getBlockState(this.getPos()); if (!(blockstate.getBlock() instanceof JuicerBlock)) { return; } if(itemstack.getItem() != ItemInit.juice_glass) { blockstate = blockstate.with(JuicerBlock.HAS_BOTTLE, false); } else { blockstate = blockstate.with(JuicerBlock.HAS_BOTTLE, true); } this.world.setBlockState(this.pos, blockstate, 3); } if (flag1) { this.markDirty(); } } protected boolean canSmelt(@Nullable IRecipe<?> recipeIn) { if (!this.items.get(0).isEmpty() && !this.items.get(1).isEmpty() && recipeIn != null) { ItemStack itemstack = recipeIn.getRecipeOutput(); if (itemstack.isEmpty()) { return false; } else { ItemStack itemstack1 = this.items.get(2); if (itemstack1.isEmpty()) { return true; } else if (!itemstack1.isItemEqual(itemstack)) { return false; } else if (itemstack1.getCount() + itemstack.getCount() <= this.getInventoryStackLimit() && itemstack1.getCount() + itemstack.getCount() <= itemstack1.getMaxStackSize()) { // Forge fix: make furnace respect stack sizes in furnace recipes return true; } else { return itemstack1.getCount() + itemstack.getCount() <= itemstack.getMaxStackSize(); // Forge fix: make furnace respect stack sizes in furnace recipes } } } else { return false; } } private void func_214007_c(@Nullable IRecipe<?> p_214007_1_) { if (p_214007_1_ != null && this.canSmelt(p_214007_1_)) { ItemStack itemstack = this.items.get(0); ItemStack itemstack1 = p_214007_1_.getRecipeOutput(); ItemStack itemstack2 = this.items.get(2); ItemStack itemstack3 = this.items.get(1); if (itemstack2.isEmpty()) { this.items.set(2, itemstack1.copy()); } else if (itemstack2.getItem() == itemstack1.getItem()) { itemstack2.grow(itemstack1.getCount()); } if (!this.world.isRemote) { this.setRecipeUsed(p_214007_1_); } itemstack.shrink(1); itemstack3.shrink(1); } } protected int getBurnTime(ItemStack p_213997_1_) { Item item = p_213997_1_.getItem(); if (p_213997_1_.isEmpty()) { return 0; } else { if(getBurnTimes().containsKey(item)) { return getBurnTimes().get(item); } else { return 0; } } } /*protected int getBurnTime(ItemStack p_213997_1_) { if (p_213997_1_.isEmpty()) { return 0; } else { Item item = p_213997_1_.getItem(); if(item == ItemInit.juice_glass) { return 200; } else { return 0; } //return net.minecraftforge.common.ForgeHooks.getBurnTime(p_213997_1_); } }*/ protected int func_214005_h() { return this.world.getRecipeManager().getRecipe((IRecipeType<AbstractJuicerRecipe>)this.recipeType, this, this.world).map(AbstractJuicerRecipe::getCookTime).orElse(200); } public int[] getSlotsForFace(Direction side) { if (side == Direction.DOWN) { return SLOTS_DOWN; } else { return side == Direction.UP ? SLOTS_UP : SLOTS_HORIZONTAL; } } public boolean canInsertItem(int index, ItemStack itemStackIn, @Nullable Direction direction) { return this.isItemValidForSlot(index, itemStackIn); } public boolean canExtractItem(int index, ItemStack stack, Direction direction) { if (direction == Direction.DOWN && index == 1) { Item item = stack.getItem(); if (item != Items.WATER_BUCKET && item != Items.BUCKET) { return false; } } return true; } public int getSizeInventory() { return this.items.size(); } public boolean isEmpty() { for(ItemStack itemstack : this.items) { if (!itemstack.isEmpty()) { return false; } } return true; } public ItemStack getStackInSlot(int index) { return this.items.get(index); } public ItemStack decrStackSize(int index, int count) { return ItemStackHelper.getAndSplit(this.items, index, count); } public ItemStack removeStackFromSlot(int index) { return ItemStackHelper.getAndRemove(this.items, index); } public void setInventorySlotContents(int index, ItemStack stack) { ItemStack itemstack = this.items.get(index); boolean flag = !stack.isEmpty() && stack.isItemEqual(itemstack) && ItemStack.areItemStackTagsEqual(stack, itemstack); this.items.set(index, stack); if (stack.getCount() > this.getInventoryStackLimit()) { stack.setCount(this.getInventoryStackLimit()); } if (index == 0 && !flag) { this.cookTimeTotal = this.func_214005_h(); this.cookTime = 0; this.markDirty(); } } public boolean isUsableByPlayer(PlayerEntity player) { if (this.world.getTileEntity(this.pos) != this) { return false; } else { return player.getDistanceSq((double)this.pos.getX() + 0.5D, (double)this.pos.getY() + 0.5D, (double)this.pos.getZ() + 0.5D) <= 64.0D; } } public boolean isItemValidForSlot(int index, ItemStack stack) { if (index == 2) { return false; } else if (index != 1) { return true; } else { ItemStack itemstack = this.items.get(1); if(itemstack.getItem() == ItemInit.juice_glass) { return true; } else { return false; } } } public void clear() { this.items.clear(); } public void setRecipeUsed(@Nullable IRecipe<?> recipe) { if (recipe != null) { this.field_214022_n.compute(recipe.getId(), (p_214004_0_, p_214004_1_) -> { return 1 + (p_214004_1_ == null ? 0 : p_214004_1_); }); } } @Nullable public IRecipe<?> getRecipeUsed() { return null; } public void onCrafting(PlayerEntity player) { } public void func_213995_d(PlayerEntity p_213995_1_) { List<IRecipe<?>> list = Lists.newArrayList(); for(Entry<ResourceLocation, Integer> entry : this.field_214022_n.entrySet()) { p_213995_1_.world.getRecipeManager().getRecipe(entry.getKey()).ifPresent((p_213993_3_) -> { list.add(p_213993_3_); func_214003_a(p_213995_1_, entry.getValue(), ((AbstractJuicerRecipe)p_213993_3_).getExperience()); }); } p_213995_1_.unlockRecipes(list); this.field_214022_n.clear(); } private static void func_214003_a(PlayerEntity p_214003_0_, int p_214003_1_, float p_214003_2_) { if (p_214003_2_ == 0.0F) { p_214003_1_ = 0; } else if (p_214003_2_ < 1.0F) { int i = MathHelper.floor((float)p_214003_1_ * p_214003_2_); if (i < MathHelper.ceil((float)p_214003_1_ * p_214003_2_) && Math.random() < (double)((float)p_214003_1_ * p_214003_2_ - (float)i)) { ++i; } p_214003_1_ = i; } while(p_214003_1_ > 0) { int j = ExperienceOrbEntity.getXPSplit(p_214003_1_); p_214003_1_ -= j; p_214003_0_.world.addEntity(new ExperienceOrbEntity(p_214003_0_.world, p_214003_0_.func_226277_ct_(), p_214003_0_.func_226278_cu_() + 0.5D, p_214003_0_.func_226281_cx_() + 0.5D, j)); } } public void fillStackedContents(RecipeItemHelper helper) { for(ItemStack itemstack : this.items) { helper.accountStack(itemstack); } } net.minecraftforge.common.util.LazyOptional<? extends net.minecraftforge.items.IItemHandler>[] handlers = net.minecraftforge.items.wrapper.SidedInvWrapper.create(this, Direction.UP, Direction.DOWN, Direction.NORTH); @Override public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) { if (!this.removed && facing != null && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) { if (facing == Direction.UP) return handlers[0].cast(); else if (facing == Direction.DOWN) return handlers[1].cast(); else return handlers[2].cast(); } return super.getCapability(capability, facing); } /** * invalidates a tile entity */ @Override public void remove() { super.remove(); for (int x = 0; x < handlers.length; x++) handlers[x].invalidate(); } public NonNullList<ItemStack> getInventory() { return this.items; } }   Renderer: public class TileEntityJuicerRenderer extends TileEntityRenderer<JuicerTileEntity> { public TileEntityJuicerRenderer(TileEntityRendererDispatcher p_i226006_1_) { super(p_i226006_1_); } @Override public void func_225616_a_(JuicerTileEntity te, float p_225616_2_, MatrixStack p_225616_3_, IRenderTypeBuffer p_225616_4_, int p_225616_5_, int p_225616_6_) { BlockState blockstate = te.getBlockState(); if (!(blockstate.getBlock() instanceof JuicerBlock)) { return; } if(blockstate.get(JuicerBlock.VYPALUJE)) { System.err.println(te.getInventory()); } } }   Console still log: [1 air, 1 air, 1 air]   Anyone know what's wrong?
    • That's the same error you had before.   You need to figure out what version of java you have.
    • [19:37:19] [Client thread/ERROR] [LaunchWrapper]: Unable to launch java.lang.reflect.InvocationTargetException: null     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_241]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_241]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_241]     at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_241]     at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]     at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?] Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.minecraft.init.Items     at net.minecraft.potion.PotionHelper.func_185207_a(PotionHelper.java:154) ~[akh.class:?]     at net.minecraft.init.Bootstrap.func_151354_b(Bootstrap.java:504) ~[ni.class:?]     at net.minecraft.client.Minecraft.<init>(Minecraft.java:365) ~[bib.class:?]     at net.minecraft.client.main.Main.main(SourceFile:123) ~[Main.class:?]     ... 6 more Exception in thread "Client thread" [19:37:19] [Client thread/INFO] [STDERR]: [java.lang.ThreadGroup:uncaughtException:1052]: net.minecraftforge.fml.relauncher.FMLSecurityManager$ExitTrappedException   It came up with this?
  • Topics

  • Who's Online (See full list)