Jump to content

[Paused] [1.8.9] How to detect if item is in inventory, then remove it?


FireController1847

Recommended Posts

Any specific slot? Players hand? And input would be using a KeyHandler and possibly the KeyInputEvent

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Do you have access to a EntityPlayer variable? If so there is a thing called inventory in there.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

I have access to the EntityPlayerSP variable. What for inventory would I use to search for an item?

First EntityPlayerSP is not a variable you can use, you will need to send packets. This is a link to Diesieben07's tutorial on Packets.

http://www.minecraftforge.net/forum/index.php?topic=20135.0

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

is there a reason why I'd have to do this? I am very easily able to get the itemstack on the inventory using this...

 

Minecraft.getMinecraft().thePlayer.inventory.mainInventory

 

That is an item stack list

 

EDIT:

When I do print System.out.println(player.inventory.mainInventory[5]); to console, it outputs ...

 

1xtile.lightgem@0

 

When I print out ItemStack testItem = new ItemStack(Blocks.glowstone);, it outputs ...

 

1xtile.lightgem@0

 

Yet the if-statment I have given it doesn't work?

 

	final EntityPlayerSP player = Minecraft.getMinecraft().thePlayer;

	ItemStack testItem = new ItemStack(Blocks.glowstone);

	System.out.println(player.inventory.mainInventory[5]);
	System.out.println(testItem);

	if (player.inventory.mainInventory[5] == testItem) {
		System.out.println("HE HAS IT");
	} else {
		System.out.println("It ain't glowstone");
	}

 

Full Output:

[19:25:30] [Client thread/INFO] [sTDOUT]: [com.fire.cdmbloxread.apps.ApplicationBloxRead:init:36]: 1xtile.lightgem@0
[19:25:30] [Client thread/INFO] [sTDOUT]: [com.fire.cdmbloxread.apps.ApplicationBloxRead:init:37]: 1xtile.lightgem@0
[19:25:30] [Client thread/INFO] [sTDOUT]: [com.fire.cdmbloxread.apps.ApplicationBloxRead:init:42]: It ain't glowstone

I am on my journey of making a remake of matmos, as explained here.

Link to comment
Share on other sites

is there a reason why I'd have to do this? I am very easily able to get the itemstack on the inventory using this...

 

Minecraft.getMinecraft().thePlayer.inventory.mainInventory

That is client side you can grab what there is client side and modify it, but since all data is saved and should be modified on the server. It will just be overriden by the server. Thus a packet is required.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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