Jump to content

Corbeno

Members
  • Posts

    16
  • Joined

  • Last visited

Everything posted by Corbeno

  1. I need to log some information to a text document... How would I do that? For example, I have a... String text = "hello!"; and I want to put and save that to a text file, and be able to do it multiple times (on the same text file) with a new line.. Any help?
  2. Sorry about that, didnt see that reply (went to bed)! Thankyou so much though, that makes sense.
  3. I have the following code BlockPos blockPos = new BlockPos(player.posX,player.posY,player.posZ); String text = ((TileEntitySign)world.getTileEntity(blockPos)).signText[0].toString() System.out.println(text); It's all working fine and dandy, except the print is something like.. TextComponent{text='I like trains', siblings=[], style=Style{hasParent=false, color=null, bold=null, italic=null, underlined=null, obfuscated=null, clickEvent=null, hoverEvent=null, insertion=null}} I only want to get the text='I like trains', into a string, not the rest of that jibberish. Any help? *sorry if I'm posting too much.. I look things up and am honestly clueless..*
  4. So if I'm correct it would be.. BlockPos blockPos = new BlockPos(x,y,z); String text = ((TileEntitySign)world.getTileEntity(blockPos)).signText[0].toString(); (The toString is because their incompatible types.. might not use it though..) ??
  5. I'm trying to read the text off of a sign, with no luck.. Here's what I've tried.... String line1 = ((TileEntitySign)world.getBlockTileEntity(player.posX,player.posY,player.posZ)).signText[0]; Everything is fine, except the ".getBlockTileEntity" I'm so lost on how to actually get the method! Halp!
  6. Never mind. I'm really slow sometimes. Disregard that last post..... Heres the working code... public class KeyInputHandler { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; World world = Minecraft.getMinecraft().theWorld; if(ExampleMod.keyBindings.isPressed()) { BlockPos BlockPosition = new BlockPos(player.posX, player.posY, player.posZ); if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ System.out.println("FOUDN SIGN YESSSSSSSSSSSSSSS"); } } } }
  7. public class KeyInputHandler { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; World world = new Minecraft.getMinecraft().theWorld(); if(ExampleMod.keyBindings.isPressed()) { BlockPos BlockPosition = new BlockPos(player.posX, player.posY, player.posZ); if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ } } } } This is the code I have In it, the ".getMinecraft()" makes an error "cannot resolve symbol" I honestly don't know how to fix that. Do you?
  8. Okay, but I honestly don't have any clue how to check the event.phase (I'll research ) When I do do World world = Minecraft.getMinecraft().theWorld the .getMinecraft 's symbol isn't resolved....
  9. Here is my new code then for the KeyInputHandler public class KeyInputHandler { @SubscribeEvent public void onKeyInput(TickEvent.ClientTickEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(ExampleMod.keyBindings.isPressed()) { BlockPos BlockPosition = new BlockPos(player.posX, player.posY, player.posZ); if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ } } } } 1) Why use ClientTickEvent? That seems to run more often.. (not just checking on keyinputs, but every tick.) 2) Would you do World world = Minecraft.getMinecraft().theWorld; ?
  10. @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(ExampleMod.keyBindings.isPressed()) { System.out.println("Player's x is" + player.posX); System.out.println("Player's y is" + player.posY); System.out.println("Player's z is" + player.posZ); BlockPos BlockPosition = new BlockPos(player.posX, player.posY, player.posZ); if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ } } } I'm playing around, trying to read sign data, and right now I'm trying to detect if the sign is at the player's location (I can move it relative to the player). It's in a keyInputEvent (currently) because I have it detect on a keypress.
  11. yes I understand that I need to do that. Do I need to create a new instance of World (with capital)? or does it need to be something else..
  12. then how do I make an instance of "world" so to say? I'm not too good with the terminology.
  13. Whenever I use the following code... if(world.getBlockState(BlockPosition).getBlock() == Blocks.standing_sign || world.getBlockState(BlockPosition).getBlock() == Blocks.wall_sign){ } both "world"s produce an error of Cannot resolve symbol "world". What am I doing wrong?
  14. Oh, I completely forgot the brackets! thankyou! I'll change to the ClientTickEvent.
  15. Note: I am very new to forge modding. public class KeyInputHandler { @SubscribeEvent public void onKeyInput(InputEvent.KeyInputEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(ExampleMod.keyBindings.isPressed()) System.out.println("ping"); System.out.println(player.posX); } } I have a keyInputHandler, so it fires every time a key is pressed. The problem I'm having is that what It's outputting. With this code, I get the message in my terminal (im using intellij). [12:56:48] [Client thread/INFO]: [com.example.examplemod.KeyInputHandler:onKeyInput:18]: ping 1183.323231183142 1183.323231183142 And any other keybind I press (moving around, spacebar, etc, it's spitting out the changing x pos on my player. Any help? (I'm not good at explaining my code haha..)
×
×
  • Create New...

Important Information

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