Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] WorldEdit ignores command when inserted with ITextComponent
The update for 1.13 is being worked on - please be patient. (Updated 02/19/19)
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 0
Stenbergcsgo

[1.12.2] WorldEdit ignores command when inserted with ITextComponent

Started by Stenbergcsgo, April 18, 2018

5 posts in this topic

Stenbergcsgo    0

Stenbergcsgo

Stenbergcsgo    0

  • Stone Miner
  • Stenbergcsgo
  • Members
  • 0
  • 62 posts
  • Report post
Posted April 18, 2018 (edited)

I'm trying to create a mod where the player can load, paste, and undo schematics using custom items, compared to manually typing the text. I got the first part working, but for some reason MCEdit ignores messages posted directly using the ITextComponent, opposed to actually typing the text and hitting enter.

 

An example of my Paste.class:

package com.mta.utzonmod.items;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import com.mta.utzonmod.client.gui.signInputGui;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ActionResult;
import net.minecraft.util.EnumHand;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraft.world.World;

public class Paste extends ItemBase{ 
	public Paste(String name) {
		
		super(name);
	}
	
	static boolean canPlace = false;
	
	@Override
	public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer player, EnumHand handIn) {
		if(!worldIn.isRemote) {
			if(canPlace == true) {
				ITextComponent message = new TextComponentString("//paste");
				player.sendMessage(message);
				canPlace = false;
				Undo.setCanUndo(true);
			}
		}
		return super.onItemRightClick(worldIn, player, handIn);	
	}
	
	public static void setCanPlace(boolean cPlace) {
		canPlace = cPlace;
	}
}

 

Is there another component I can use for sending text, or is it a whole other size of problem?

Edited April 18, 2018 by Stenbergcsgo

Share this post


Link to post
Share on other sites

diesieben07    6110

diesieben07

diesieben07    6110

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6110
  • 40227 posts
  • Report post
Posted April 18, 2018

Calling sendMessage on the server sends a message to the player via chat.

If you want to execute a command on behalf of a player, call ICommandManager::executeCommand.

Share this post


Link to post
Share on other sites

Stenbergcsgo    0

Stenbergcsgo

Stenbergcsgo    0

  • Stone Miner
  • Stenbergcsgo
  • Members
  • 0
  • 62 posts
  • Report post
Posted April 18, 2018
6 minutes ago, diesieben07 said:

Calling sendMessage on the server sends a message to the player via chat.

If you want to execute a command on behalf of a player, call ICommandManager::executeCommand.

I assume this can't be done client-side? All the examples I see use:

MinecraftServer minecraftserver = MinecraftServer.getServer();

Where I get told MinecraftServer's getServer() isn't static so I can't even call it if I wanted to. How would I implement this in the code from my original post?

Share this post


Link to post
Share on other sites

diesieben07    6110

diesieben07

diesieben07    6110

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6110
  • 40227 posts
  • Report post
Posted April 18, 2018

To obtain the server instance you can use ICommandSender::getServer (every entity is a command sender).

 

On the client you can use EntityPlayerSP::sendChatMessage to send a command to the server.

  • Thanks 1

Share this post


Link to post
Share on other sites

Stenbergcsgo    0

Stenbergcsgo

Stenbergcsgo    0

  • Stone Miner
  • Stenbergcsgo
  • Members
  • 0
  • 62 posts
  • Report post
Posted April 19, 2018
18 hours ago, diesieben07 said:

To obtain the server instance you can use ICommandSender::getServer (every entity is a command sender).

 

On the client you can use EntityPlayerSP::sendChatMessage to send a command to the server.

Worked like a charm, thank you very much =)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0
Go To Topic Listing Modder Support

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • Drachenbauer
      how do i save animations of an entity-model in blockbench

      By Drachenbauer · Posted 18 minutes ago

      Hello i created my entities in Blockbench. It has a tab to create custom animations. But how can i save souch animations? If i just click save, and close the game, the animations will be deleted... What must i do to get them save?   it´s because i create a coustm player model and want to add custom animations for using items and rising and lowering a shield
    • DoctorLOGiQ
      [1.13.2] Example mod fails to launch

      By DoctorLOGiQ · Posted 27 minutes ago

      Mkay so... you're going to hate me, but trust me, none of this is my fault. After rinse-and-repeat clearing all files, re-extracting the mdk zip, doing the gradle command, importing the project and testing... a programmer's worst nightmare occurred: it just started working. I did not change anything, I don't know why it now works and why it didn't before, but... well, it's working now.   The Forge examplemod included in the ZIP has an incorrect version number, causing it to error during initialization, but that was an easy enough fix.   This would not have changed anything, the tasks were generated first time each time, that wasn't part of the problem.    The exact process I followed over and over and over (and over!) again is: Extract MDK ZIP Rename the folder (non important) Open Cmder, 'cd' to the folder Run 'gradlew eclipse' Wait Wait some more, until the task completes Close Cmder, open IDEA Open project, browse to and select the folder When prompted, 'import gradle project' Wait for indexing and project sync to complete Run Gradle task 'genIntellijRuns' Rename tasks because "runClient" and "runServer" are not very eyecandy-friendly (non important) Select the module under 'use classpath of module' for both server and client run tasks Alter mods.toml file to support version 1.13.2 instead of 1.13 Run This task has been the same each time. "Magical fix is magical" *DING!* I'm sorry I can't say what happened here, if only I knew. But there you go, I suppose something was missing and now isn't. I am still getting floods of errors about sound files being missing, however.   Mods: I don't know if this should be classed as resolved, on the one hand my development environment is (minimally) working, but on the other hand I do not know how or why the issue fixed itself.
    • Drachenbauer
      Error with block registration

      By Drachenbauer · Posted 1 hour ago

      Here is the whole new error log   I added the registry name thing to all my blocks. what also goes wrong here?
    • gunnerwolf
      Thank you Forge Developers

      By gunnerwolf · Posted 1 hour ago

      Agreed. Forge is the vehicle that the modding community has driven to get as far as it has. There were solutions before, such as Risugami's Mod Loader, but they were just ways of applying multiple mods at once without conflicts, not actual APIs.

      Not only that, but it's my understanding that Forge makes some significant improvements and optimizations to Minecraft's code, and from status updates given in the past by Forge devs, I've seen several instances of devs not only taking their own free time to work on forge, but take time away from friends and family, and even time off work to help push Forge forwards.

      Thank you forge devs, for your hard work and dedication. I'm sure you guys have received a ton of hate from impatient people who don't understand how much work something like Forge is, so thank you for sticking with it.
    • wilechaote
      Local ForgeGradle build dependency caching

      By wilechaote · Posted 2 hours ago

      Quickly FTR, my working approach for this is to use the possibility to globally override the gradle properties: In build.gradle: In gradle.properties: These are then changed to a "file://" location in a local GIT repository containing the downloaded files. However, this might not yet be enough, as further resources appear to be loaded. More introspection needed here ;). [is there a way to move this thread to the ForgeGradle sub forum? I accidentally posted this here]?
  • Topics

    • Drachenbauer
      0
      how do i save animations of an entity-model in blockbench

      By Drachenbauer
      Started 18 minutes ago

    • DoctorLOGiQ
      5
      [1.13.2] Example mod fails to launch

      By DoctorLOGiQ
      Started Monday at 01:23 PM

    • Drachenbauer
      10
      Error with block registration

      By Drachenbauer
      Started 22 hours ago

    • PoofyKittens
      1
      Thank you Forge Developers

      By PoofyKittens
      Started 19 hours ago

    • wilechaote
      1
      Local ForgeGradle build dependency caching

      By wilechaote
      Started Friday at 02:01 PM

  • Who's Online (See full list)

    • MX_wb
    • That_Martin_Guy
    • V0idWa1k3r
    • Toma™
    • sliceofmeat1
    • ZigTheHedge
    • Cadiboo
    • Drachenbauer
    • crackedEgg
    • unassigned
    • Builderboy426
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.12.2] WorldEdit ignores command when inserted with ITextComponent
  • Theme
  • Contact Us

Copyright © 2017 ForgeDevelopment LLC Powered by Invision Community