
Nique84
Members-
Posts
16 -
Joined
-
Last visited
Everything posted by Nique84
-
[1.7.10] Getting the 'full' localized name of the 'block'.
Nique84 replied to Nique84's topic in Modder Support
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; } } } } } -
[1.7.10] Getting the 'full' localized name of the 'block'.
Nique84 replied to Nique84's topic in Modder Support
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? -
[1.7.10] Getting the 'full' localized name of the 'block'.
Nique84 replied to Nique84's topic in Modder Support
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; } } } } } } -
[1.7.10] Getting the 'full' localized name of the 'block'.
Nique84 replied to Nique84's topic in Modder Support
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. -
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.
-
[1.7.10] Where are the vanilla ore blocks defined?
Nique84 replied to Nique84's topic in Modder Support
Thanks! -
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
-
Wow, a furnace recipe? Thats a facepalm for me. I'm sorry haha.
-
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?
-
Even better
-
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.
-
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.
-
[1.7.10] Changing a simple chat message not so simple...
Nique84 replied to Nique84's topic in Modder Support
That's right. I also thought about this but then i realized they hardcoded the color of the text. -
[1.7.10] Changing a simple chat message not so simple...
Nique84 replied to Nique84's topic in Modder Support
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 . -
[1.7.10] Changing a simple chat message not so simple...
Nique84 replied to Nique84's topic in Modder Support
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) -
So, i thought, lets do this. I know how to program but i aint a pro. Lets start with something simple: Remove or change that simple message when the user logs in on the server. I'm talking about the "User joined the game" and "User left the game" message. Not that 'client side' MOTD message you get when u logon a server. I mean that message that is being broadcasted serverwide to all players. I want to customize that but it seems that the function responsible for that is the initializeConnectionToPlayer() function from the ServerConfigurationManager class. In version (MC 1.7.10) line 157 to 169 to be exactly. It prepares the chatcomponentTranslation and then sends it. In the beginning i stumbled upon those forge events and i instantly started looking up the reference for player login events. With no luck. I read about the ability of cancellation of events so that was really disappointing. So, my question is.. are we able to remove that message and replace it by my own? And i mean that one on line 169? this.sendChatMsg(chatcomponenttranslation); I just want to be pointed in the right direction. I noticed it is part of an abstract class. Thanks!