Jump to content

[1.12.2] how to execute command without the result beeing output in chat


Recommended Posts

Posted (edited)

when i right click an item it replaces the head slot with that item, i did this with 

Minecraft.getMinecraft().player.sendChatMessage("/replaceitem entity @p slot.armor.head mm:headset")

but that posts the result in the chat. is there a way i can make it not do that?

Edited by madmagic
Posted
  On 7/27/2019 at 1:23 PM, madmagic said:

when i right click an item it replaces the head slot with that item, i did this with 

Minecraft.getMinecraft().player.sendChatMessage("/replaceitem entity @p slot.armor.head mm:headset")

but that posts the result in the chat. is there a way i can make it not do that?

Expand  

Why are you running the command anyways?

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.

Posted
  On 7/27/2019 at 8:15 PM, Animefan8888 said:

Why are you running the command anyways?

Expand  

because i have a 3D model of a headset that fits just perfecly around the players head when the item is put there using that command and i want to be able to equip it by right clicking wich then exdcutes that command, i tried by doing 

Minecraft.getMinecraft().player.inventory.setInventorySlotContents(103, new ItemStack(ModItems.HEADSET))

but that wouldnt work, if i changed 103 to 1 then it would work.

Posted
  On 7/27/2019 at 8:20 PM, madmagic said:

because i have a 3D model of a headset that fits just perfecly around the players head when the item is put there using that command and i want to be able to equip it by right clicking wich then exdcutes that command, i tried by doing 

Minecraft.getMinecraft().player.inventory.setInventorySlotContents(103, new ItemStack(ModItems.HEADSET))

but that wouldnt work, if i changed 103 to 1 then it would work.

Expand  

Post the whole method please.

 

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.

Posted

Because that does it on the client, you need to get the server instance of the player

This is my Forum Signature, I am currently attempting to transform it into a small guide for fixing easier issues using spoiler blocks to keep things tidy.

 

As the most common issue I feel I should put this outside the main bulk:

The only official source for Forge is https://files.minecraftforge.net, and the only site I trust for getting mods is CurseForge.

If you use any site other than these, please take a look at the StopModReposts project and install their browser extension, I would also advise running a virus scan.

 

For players asking for assistance with Forge please expand the spoiler below and read the appropriate section(s) in its/their entirety.

  Reveal hidden contents

 

Posted
  On 7/27/2019 at 8:21 PM, Animefan8888 said:

Post the whole method please.

 

Expand  
@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, EnumHand handIn) {
		Minecraft.getMinecraft().player.inventory.setInventorySlotContents(103, new ItemStack(ModItems.HEADSET));
		return super.onItemRightClick(worldIn, playerIn, handIn);
	}

this is what i tried, i got it to be wearable by using isValidArmor but i also have some other rightclickevents set such as playSound but by using the isValidArmor you cant rightclick the item to equip it

 

Posted
  On 7/27/2019 at 8:37 PM, madmagic said:

Minecraft.getMinecraft().player

Expand  
  On 7/27/2019 at 8:37 PM, madmagic said:

EntityPlayer playerIn,

Expand  

Why though?

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.

Posted
  On 7/27/2019 at 8:41 PM, madmagic said:

im new to java

Expand  

Modding is not a good way to learn Java. The problem is that you used Minecraft.getMinecraft().player instead of using the EntityPlayer parameter you are given.

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.

Posted
  On 7/28/2019 at 7:32 PM, madmagic said:

you cant use the EntityPlayer parameter, it has to be playerimage.png.0199a2ba301fb80d8c8d158e228316ae.png

Expand  

What.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

That is going to crash on a dedicated server.

Do not access client-only code from the server side.

Some tips:

  Reveal hidden contents

 

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.

Guest
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.

Announcements



×
×
  • Create New...

Important Information

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