Jump to content

chris140989

Members
  • Posts

    9
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

chris140989's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thanks for your answere. I have followed the steps you did describe, but it seems like my customCow is still moving it's head from time to time. Thus it doesn't do what I want it to do.. It seems like the body and head aren't in sync, because sometimes the cow is moving into a direction, where it's head is not facing to. My classes are: customCow: public class Animal extends EntityCow { public Animal(World worldIn) { super(worldIn); this.tasks.taskEntries.clear(); this.targetTasks.taskEntries.clear(); } protected boolean isAIEnabled() { return false; } protected MyEntityLookHelper getEntityLookHelper() { return new MyEntityLookHelper(this); } protected MyEntityBodyHelper getEntityBodyHelper() { return new MyEntityBodyHelper(this); } } customEntityBodyHelper: public class MyEntityBodyHelper extends EntityBodyHelper { public MyEntityBodyHelper(EntityLivingBase p_i1611_1_) { super(p_i1611_1_); } @Override public void updateRenderAngles() { } } customEntityLookHelper public class MyEntityLookHelper extends EntityLookHelper { public MyEntityLookHelper(EntityLiving p_i1613_1_) { super(p_i1613_1_); } @Override public void onUpdateLook() { } } It didn't worked with just the EntityLookHelper, so I created a EntityBodyHelper aswell, because I've read somewhere that it is associated with it too. Any advice?
  2. Hi there, I am trying to create my own CowEntity and I want it to do nothing. The reason is, that I want to control it by remote. My Problem is, that the Cow is moving his Head and because of that it moves into the wrong direction. Is there a possibility, to deactivate all movement of an Entity? Like just freezing it. My Class right now: public class Animal extends EntityCow { public Animal(World worldIn) { super(worldIn); this.tasks.taskEntries.clear(); } protected boolean isAIEnabled() { return false; } } I cleared the Tasklist, to not make it wander around and stuff like that and disabled the AI.
  3. Hi there, I wan't to create a chatCommand which let's rotate the Players looking direction by 90° to the left. E.g. if the Player is looking to north, I want him to look to the west after performing the command. The problem is, that the view of the Player does not get changed after performing the Command, but the rotationYaw get's a new value. Here is my method: public void turnLeft() { // The actor is the Player performing the command. int yaw = ((int) this.actor.rotationYaw) % 360; if (yaw < 0) { yaw += 360; } this.actor.addChatComponentMessage(new ChatComponentTranslation("yaw = " + yaw)); if (315 < yaw || yaw <= 45) { this.actor.rotationYaw = yaw - 90; } else if (45 < yaw && yaw <= 135) { this.actor.rotationYaw = 360; } else if (135 < yaw && yaw <= 225) { this.actor.rotationYaw = yaw - 90; } else if (225 < yaw && yaw <= 315) { this.actor.rotationYaw = yaw - 90; } } Is there any method I can use to force the Client to update the rotationYaw of an player? Edit: Managed to find the right method and forced the update with another method. Here is the correct method in case somebody is interested.. public void linksUm() { int yaw = ((int) this.actor.rotationYaw) % 360; if (yaw < 0) { yaw += 360; } this.actor.addChatComponentMessage(new ChatComponentTranslation("yaw = " + yaw)); this.actorPosition = this.actor.getPosition(); this.actor.rotationYaw = yaw - 90; this.actor.setPositionAndUpdate(actorPosition.getX(), actorPosition.getY(), actorPosition.getZ()); }
  4. I have now managed to create the /move command, the player knows walks 5 blocks towards north if the player is facing in that direction. Here is my Actor.class with the move()- Method: public class Actor { EntityPlayer actor; BlockPos actorPosition; public Actor(ICommandSender sender) { actor = (EntityPlayer) sender.getCommandSenderEntity(); } public void vor() { actorPosition = actor.getPosition(); // Yaw is direction left to right int yaw = (int) actor.rotationYaw; // Pitch is direction top to bottom int pitch = (int) actor.rotationPitch; // -224 to -135 == north if (yaw > -224 && yaw < -135) { actor.addChatComponentMessage(new ChatComponentTranslation("Facing North!")); // actor.setPositionAndRotation(actorPosition.getX(), // actorPosition.getY(), actorPosition.getZ() - 10, yaw, 0); actor.setPositionAndUpdate(actorPosition.getX(), actorPosition.getY(), actorPosition.getZ() - 5); } actor.addChatComponentMessage(new ChatComponentTranslation("pitch = " + pitch + " | yaw = " + yaw)); } public String getName() { return this.actor.getDisplayNameString(); } } Now I want to create the /turnLeft command, meaning if the player looks north, he should look towards west after the command. I figured out that the method EntityPlayer.setPositionAndRotation() should be the key, but when I run it, it does not update the player location. Can I somehow force the player to update his position?
  5. Hi there, I want to create some Chat Commands for the Player to control his movement, e.g. /move -> player goes 1 step into viewing direction or /turnLeft -> player turns to 90° to the left. I have created a Actor.class, containing the move, turnLeft etc. methods. To perform the commands i used the EntityPlayer object given by the sender, using the command. This EntityPlayer object is called actor. To update the players position i used the method EntityPlayer.setPostionAndUpdate(int x, int y, int z); The problem is, that the player has to move into different direction depending on his viewingDirection. And here comes the trick because I don't know how to get the viewingDirection. Does anybody has an advice how I can access it? Hope this was clear enough to state out the problem I am facing. Edit: I've found out that we should use the Minecraft.getMinecraft().getRenderViewEntity()- method to access the viewingDirection from players, this method returns a entity-object. But I still don't know how to work with it. Can anybody help me?
  6. Alright, changed my class so it will extend CommandBase. The compareTo method i deleted and the aliases I won't need either so i deleted them aswell. Found another mistake I made: I totally forgot about the @Mod annotation in the base Mod file, which obviously was the error why it didn't worked. Thanks for your time and help Thread can be closed.
  7. I can't see the problem then.. Here are the current classes again. BaseMod: public class MinecraftHamster { // Set the ID of the mod (Should be lower case). public static final String MODID = "MinecraftHamster"; // Set the "Name" of the mod. public static final String MODNAME = "MinecraftHamster"; // Set the version of the mod. public static final String MODVER = "0.0.1"; // Tell Forge what instance to use. @Instance(value = MinecraftHamster.MODID) public static MinecraftHamster instance; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void load(FMLServerStartingEvent event) { event.registerServerCommand(new StartHamsterCommand()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } StartHamsterCommand: public class StartHamsterCommand implements ICommand { private List aliases; public StartHamsterCommand() { this.aliases = new ArrayList(); this.aliases.add("startHamster"); } @Override public int compareTo(Object arg0) { // TODO Auto-generated method stub return 0; } @Override public String getName() { return "startHamster"; } @Override public String getCommandUsage(ICommandSender sender) { return "startHamster"; } @Override public List getAliases() { return this.aliases; } @Override public void execute(ICommandSender sender, String[] input) throws CommandException { sender.addChatMessage(new ChatComponentTranslation("Hamster wird gestartet..")); } @Override public boolean canCommandSenderUse(ICommandSender sender) { return true; } @Override public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { // TODO Auto-generated method stub return null; } @Override public boolean isUsernameIndex(String[] args, int index) { // TODO Auto-generated method stub return false; } }
  8. Oh my god.. you are right, didn't see that it is another EventType. Changed it and now I can use event.registerServerCommand(new myCommand()); but when I try to use this command in Minecraft, it says that the command does not exist. @Override public String getCommandUsage(ICommandSender sender) { return "startHamster"; } If I make the commandUsage like this, it should be possible to trigger the command with /startHamster in Minecraft right?
  9. Hey there, I have a problem with ChatCommands aka ServerCommands. First of all i tried creating one by myself with this guide (http://www.minecraftforge.net/wiki/Server_Command), but it seems outdated. I tried to find a solution by myself but couldn't find any working example on this. I believe that my main problem is that I can't register the event since event.registerServerCommand(myCommand()); doesn't work or is not existence anymore. Here is my sourcecode: BaseMod: package minecraftHamster; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.Mod.Instance; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; public class MinecraftHamster { // Set the ID of the mod (Should be lower case). public static final String MODID = "MinecraftHamster"; // Set the "Name" of the mod. public static final String MODNAME = "MinecraftHamster"; // Set the version of the mod. public static final String MODVER = "0.0.1"; // Tell Forge what instance to use. @Instance(value = MinecraftHamster.MODID) public static MinecraftHamster instance; @EventHandler public void preInit(FMLPreInitializationEvent event) { } @EventHandler public void load(FMLInitializationEvent event) { event.registerServerCommand(new StartHamsterCommand()); } @EventHandler public void postInit(FMLPostInitializationEvent event) { } } ChatCommandClass: package minecraftHamster; import java.util.List; import net.minecraft.command.CommandException; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; import net.minecraft.util.BlockPos; import net.minecraft.util.ChatComponentTranslation; import net.minecraft.util.IChatComponent; public class StartHamsterCommand implements ICommand { private String commandName = "startHamster"; @Override public int compareTo(Object arg0) { // TODO Auto-generated method stub return 0; } @Override public String getName() { return this.commandName; } @Override public String getCommandUsage(ICommandSender sender) { return this.commandName; } @Override public List getAliases() { // TODO Auto-generated method stub return null; } @Override public void execute(ICommandSender sender, String[] input) throws CommandException { if (input.equals(this.commandName)) { sender.addChatMessage(new ChatComponentTranslation("Hamster wird gestartet..")); } else { sender.addChatMessage(new ChatComponentTranslation("This is not a command")); return; } } @Override public boolean canCommandSenderUse(ICommandSender sender) { return true; } @Override public List addTabCompletionOptions(ICommandSender sender, String[] args, BlockPos pos) { // TODO Auto-generated method stub return null; } @Override public boolean isUsernameIndex(String[] args, int index) { // TODO Auto-generated method stub return false; } } Any advice on this would be awesome.. Another question: Is there a documentation for Forge anywhere? Cause I have the feeling that kind of any tutorial is outdated and nearly all methods got changed..
×
×
  • Create New...

Important Information

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