Jump to content

[1.14.2] How to open Enderchest from item


Recommended Posts

Hi All,


I'm looking for some guidance here.   I'm converting my mod from 1.12.2 --> 1.14.3 and have a question.


I have an item that allows a player to open their EnderChest by right-clicking an item.   The .openGUIChest doesn't exist in PlayerEntity in 1.14.3, and throws an error.   Reading through PlayerEntity.java yields no insight, so I'm stuck.   Suggestions?


Here is my code:

package com.kwpugh.gobber2.items.rings;

import java.util.List;

import com.kwpugh.gobber2.util.RayTraceUtil;

import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.ServerPlayerEntity;
import net.minecraft.inventory.EnderChestInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.EffectInstance;
import net.minecraft.potion.Effects;
import net.minecraft.util.ActionResult;
import net.minecraft.util.ActionResultType;
import net.minecraft.util.Hand;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.SoundEvents;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.world.World;

public class ItemCustomRingEnderman extends Item

	public ItemCustomRingEnderman(Properties properties)

	public ActionResult<ItemStack> onItemRightClick(World world, PlayerEntity player, Hand hand)
		EnderChestInventory enderChest = player.getInventoryEnderChest();
		if (enderChest != null)
			if (!world.isRemote)
		return new ActionResult<ItemStack>(ActionResultType.PASS, player.getHeldItem(hand));
	public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flag)
		super.addInformation(stack, world, list, flag);				
		list.add(new StringTextComponent("Provides player with a boost of speed"));
		list.add(new StringTextComponent("Right-click to use"));



Link to comment
Share on other sites

Thanks for the pointer.   I adapted some code there and added a static methods for field_220115_d.   Thanks for the help.


 player.openContainer(new SimpleNamedContainerProvider((p_220114_1_, p_220114_2_, p_220114_3_) -> {
		               return ChestContainer.createGeneric9X3(p_220114_1_, p_220114_2_, enderChest);
		            }, field_220115_d));


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.