Jump to content

Solitary_Knight

Members
  • Posts

    8
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Solitary_Knight's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Yes, you are correct about what I am trying to do. Although I don't understand it completely yet, what you are suggesting sounds useful, and I'll try it. Thanks
  2. If a thread is going to break, do you have a recommendation for an alternative way to get/set player/entity position ~100 times per second? I need the object which I am moving to be an armor stand (so that I can put a block on its head). I assume there is no such thing as a particle armor stand?
  3. Maybe using a different thread is iffy, but it's working perfectly fine for me so far. I am spawning the entity client-side, so that statement isn't true. I can't interact with it, and that's fine, I just want to be able to control its visual movement, which I can do, just not smoothly. I did get it able to be a little smoother by using .setLocationAndAngles() every tick, and .move() 5 times per tick, but a better solution would be appreciated.
  4. I'm trying to add a feature to a mod (1.12.2 currently, and ideally 1.8.9 as well) which will allow me to spawn an entity (armor stand) and control its movement. For testing, I'm having the entity copy my movements, offset by x = 2. I need to do everything client-side because I want it to run on a server to which I don't have access. Here is a thread which I am running via a command. "player" is the command sender, "world" is Minecraft.getInstance().world, and "mil" is just the milliseconds between updates. class EntityThread extends Thread { Entity player; int mil; World world; EntityThread(EntityPlayer player, World world, int mil) { this.player = player; this.mil = mil; this.world = world; } public void run() { if (this.world.isRemote == true) { TKRS.message("Not server side."); } double x = player.posX + 2; double y = player.posY; double z = player.posZ; double vx = player.motionX; double vy = player.motionY; double vz = player.motionZ; float yaw = player.rotationYaw; float pitch = player.rotationPitch; Entity entity = new net.minecraft.entity.item.EntityArmorStand(world, x, y, z); world.spawnEntity(entity); for (int i = 0; i < (int)(10000/mil); i++) { try { Thread.sleep(this.mil); } catch (InterruptedException e) { e.printStackTrace(); } x = player.posX + 2; y = player.posY; z = player.posZ; vx = player.motionX; vy = player.motionY; vz = player.motionZ; yaw = player.rotationYaw; pitch = player.rotationPitch; entity.setLocationAndAngles(x, y, z, yaw, pitch); entity.setVelocity(vx, vy, vz); entity.velocityChanged = true; world.updateEntity(entity); } world.removeEntity(entity); } } This works OK both in single-player and on a server, except that it is very jittery because the position is only updating 20 times per second, and the velocity does not update at all. If I provide a server world to the EntityThread (only possible in singleplayer), it is smooth with velocity updates, but lags behind my movements for some reason (client-side world doesn't lag, just jittery). So my question is, how can I update the velocity for an entity spawned on client-side, without significant lag? I've tried looking up how to simulate clientbound packets from a non-existent server to update the velocity, but no luck so far.
  5. Here, here, here, etc. It definitely, at one point, was "supposed to" have it. I guess that must be for older versions, but I was having difficulty finding anything about a change occurring. I had been looking at the code myself, but I was searching for "chat" so "sendMessage()" was not showing up. That does appear to be what I am looking for, so thank you for the response and hopefully I can actually start this mod now
  6. The problem with "player" is that it does not have the "addChatMessage()" function like "thePlayer" is supposed to. It does have "sendChatMessage()", but my understanding is that that will send the message to all players on the server, which is not what I want.
  7. I'm sorry, I don't understand what I am supposed to do with this. getPlayer() does not seem to be an attribute of Minecraft or Minecraft.getMinecraft() or "event". Could you please elaborate?
  8. Hi, I am new to Forge. I am trying to make a mod that will (1) monitor the chat and (2) print messages (only to me) to the chat. I have #1 down, but I am having trouble with #2. My research shows that I should be using Minecraft.getMinecraft().thePlayer.addChatMessage("Hello World"); to do it. My issue is that "thePlayer" is underlined in red with "thePlayer cannot be resolved or is not a field". "Minecraft.getMinecraft()" is perfectly fine. Context: package com.solitary_knight.turbokartracersstatistics; import net.minecraft.client.Minecraft; import net.minecraft.util.text.TextComponentString; import net.minecraft.util.text.TextFormatting; import net.minecraftforge.client.event.ClientChatReceivedEvent; import net.minecraftforge.event.ServerChatEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; public class ChatEventHandler { @SubscribeEvent public void onServerChat(ClientChatReceivedEvent event) { String message = event.getMessage().getUnformattedText(); // get the message Minecraft.getMinecraft().thePlayer.addChatMessage(message); // repeat the message (as a test) } } I'm sure that I am doing something wrong, I just have no idea what. Thanks in advance.
×
×
  • Create New...

Important Information

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