Jump to content

Nique84

Members
  • Posts

    16
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

Nique84's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Well i ended up doing it this way. Thanks for the help! public class PlayerEventHandler { private Block lastBlock; @SubscribeEvent public void onPlayerTick(PlayerTickEvent event) { if (event.side == Side.CLIENT) { EntityPlayer player = event.player; World world = player.worldObj; MovingObjectPosition mop = player.rayTrace(5, 1.0F); if (mop != null && mop.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK && !world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) { Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); if (lastBlock != block) { int metaData = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ); Item item = Item.getItemFromBlock(block); String unlocalizedName = item.getUnlocalizedName(new ItemStack(block, 1, metaData)); String blockName = StatCollector.translateToLocal(unlocalizedName + ".name"); Main.instance.log.info("--> Player looks at: " + blockName); lastBlock = block; } } } } }
  2. Indeed, i noticed that. On just the client it's working but on a server it's not. So my guess now is that i have to use the PlayerTickEvent's world.rayTraceBlocks() method to find the block?
  3. I ended up doing it like this. It looks ugly to me but it works. public class EntityPlayer { private Block lastBlock; @SubscribeEvent public void onUpdate(LivingUpdateEvent event) { if (event.entity instanceof net.minecraft.entity.player.EntityPlayer) { MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(5, 1.0F); if(mop != null) { World world = event.entityLiving.worldObj; if (!world.isAirBlock(mop.blockX, mop.blockY, mop.blockZ)) { Block block = world.getBlock(mop.blockX, mop.blockY, mop.blockZ); if (lastBlock != block) { int metaData = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ); ItemBlock itemBlock = (ItemBlock) ItemBlock.getItemFromBlock(block); String blockName = StatCollector.translateToLocal(itemBlock.getUnlocalizedName(new ItemStack(block, 1, metaData)) + ".name"); Main.instance.log.info("--> Player looks at: " + blockName); lastBlock = block; } } } } } }
  4. I created a EntityPlayer class that is registered to Forge's event bus in the Mainclass. This is just temporary code to get the current block. I will change that in the future. public class EntityPlayer { private Block lastBlock; @SubscribeEvent public void onUpdate(LivingUpdateEvent event) { if (event.entity instanceof net.minecraft.entity.player.EntityPlayer) { MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(5, 1.0F); if(mop != null) { int blockHitSide = mop.sideHit; Block block = event.entityLiving.worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ); if (lastBlock != block) { Main.instance.log.info("--> Player looks at: " + block.getLocalizedName()); lastBlock = block; } } } } } Edit: I added int metaData = world.getBlockMetadata(mop.blockX, mop.blockY, mop.blockZ); to the function and now i get the damage value. Now i need to construct the name of the block. Which is (in my opinion) kinda weird. Is there no getLocalizedName() for vanilla subblocks? I tried to find such function but i'm unable to search in the forge reference lib. Even when i'm searching on "block.log.oak.name". Eclipse is just returning "no results" while i know it is in the lang file.
  5. I've made code that uses raytrace to get the actual block the user is looking at. For just blocks it's working fine but for subblocks (like different types of wood) its not working. It seems there is no function for getting the localized name for the vanilla subblocks. I have thought about Item item = Item.getItemFromBlock(anyblock) But then the getUnlocalizedName() name requires me to add a stack. But i do not want to create a new stack because when i create a new stack, the damage must be set manually. And thats just not what i want. I want to retrieve the current damage of the current item so i can get its unlocalized name. How do i retrieve the damage of an item? Or even better, isn't there a better way of retrieving the sub blocks 'full' name? (not just Wood, but Oak Wood) I've tried to take a look in the gui (because of the tool tips) but appearantly the File Search in Eclipse doesn't work for Referenced Libraries. I can't find anything.. even if i set to search delegate.
  6. Because i want to see (and maybe adjust) the parameters (hardness) for the ore block generation in the world i need to know where, for example the Iron Ore Block is defined. Yes i can adjust the parameters on the fly but i need to know what they are right now, out of the box. I couldn't find them in the vanilla blocks package. Also, in what class is the ore generation defined? I couldn't find that one too
  7. Wow, a furnace recipe? Thats a facepalm for me. I'm sorry haha.
  8. Might be a simple and stupid question but i'm unable to find the recipe for green dye in vanilla. I know i have to look for the Itemstack 'damage' paramters (and then number 2 as thats the id for green) but there is no recipe for green dye. although.. we all know we get green dye from a cactus. Where is that cactus to green dye recipe defined?
  9. Full control over server/chat messages. Except for those two messages, we already have full control. Can be handy if a server owner wants to tidy up the chat with his own styles (color, text, format). For example: Messages like: [-] Username (left the server), [+] Username (entered server), [>] Username (left world), [<] Username (entered world) We were able to do this with bukkit plugins but bukkit is gone.
  10. I would like to see 2 (simple) event hooks that allow modders to adjust the hardcoded (yellow) colored "player joined the Game" and "player left the game" messages that are broadcasted serverwide once a player joins or leaves the server (not just the world). Sadly enough these messages are send from the deep. As of version 1.8, the join message is being send from the initializeConnectionToPlayer() function in the ServerConfigurationManager class (the message is being send on line 171). The leave message is being send from the onDisconnect() function in the NetHandlerPlayServer class (line 732). If we could hook up there and adjust the message, it would be great. Currently, the only way to change this behavior is to intercept the Netty packages before they get send, or catch them on the client and then adjust them. Both are nasty, the later requires the user to install a 'server' mod on the client. That's kinda awkward.
  11. That's right. I also thought about this but then i realized they hardcoded the color of the text.
  12. I understand. Any reason why there is no hook over there? Would be great if modders could get control over that part too by an event. Without Netty the only 'neat' way to do it is create a coremod. Little too deep for me .
  13. Aha, thanks. So basically what your solution does is catching and modifying the (from the server received) message on the client? (correct me if i'm wrong, i'm trying to understand the concept here). Am i forced to ship my mod to every client then? (I want the mod to be on the server only. Not really a client mod, but if there is no other way..). Edit: Oh wait a minute. I see ServerChatEvent too. Let's figure that out. Maybe i can catch it before it is even send to the clients. (that would be ideally)
×
×
  • Create New...

Important Information

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