Jump to content

Draconwolver

Members
  • Posts

    41
  • Joined

  • Last visited

Everything posted by Draconwolver

  1. Thanks, that was helpful. When I listen to the RenderLivingEvent.Specials.Pre event, should I suppress the raw type warning, or use something like RenderLivingEvent.Specials.Pre<? extends EntityLivingBase>?
  2. Okay, now I have a couple of (probably simple) questions. Why does cancelling RenderLivingEvent.Specials.Pre<AbstractClientPlayer> prevent all nametags from showing, rather than just players? What role does RenderPlayer::renderEntityName have in rendering player names? It seems to handle scores displayed under the player's name and then call Render::renderEntityName, which is also called by RenderLivingBase::renderName. So when a player's nametag needs to be rendered, which is called, RenderPlayer::renderEntityName or RenderLivingBase::renderName? RenderPlayer::renderEntityName RenderLivingBase::renderName Render::renderEntityName Render::renderLivingLabel
  3. I'd like to modify how player nametags are rendered, so I've started with the goal of cancelling their render in the first place. I'd like to do this by extending RenderPlayer, but I cannot seem to get it working. I've overridden RenderPlayer::renderEntityName to simply return without doing anything, but player nametags continue to render. Is this the wrong method to override? I don't see any calls to it in the source code, but I also don't see anything about rendering nametags in RenderPlayer::doRender.
  4. Whoops, I should've looked at the type hierarchy... Thank you.
  5. I know that WorldClient is client-side only, so I'm assuming that all the entities in WorldClient::getLoadedEntityList are client-side only. Does this mean that I can cast player entities in WorldClient::getLoadedEntityList to EntityPlayerSPs, the client-side player type? (EntityPlayer is what I am casting to at the moment, but I am wondering if there is something more specific I can use.)
  6. Just to reiterate my last question, is there a way to toggle this rendering while in-game?
  7. Oh, of course! I don't have access to my workspace right now, but I understand. Thanks! EDIT: Alrighty, I got it. Here's my FMLPreInitializationEvent handler: @EventHandler public void preInit(FMLPreInitializationEvent event) { RenderingRegistry.registerEntityRenderingHandler(EntityItem.class, new DiamondRenderFactory()); } And my DiamondRenderFactory class: public class DiamondRenderFactory implements IRenderFactory<EntityItem> { @Override public Render<? super EntityItem> createRenderFor(RenderManager manager) { return new RenderDiamond(manager, Minecraft.getMinecraft().getRenderItem()); } } And finally my RenderDiamond class: public class RenderDiamond extends RenderEntityItem { public RenderDiamond(RenderManager renderManagerIn, RenderItem p_i46167_2_) { super(renderManagerIn, p_i46167_2_); } @Override public void doRender(EntityItem entity, double x, double y, double z, float entityYaw, float partialTicks) { if (entity.getEntityItem().getItem() != Items.DIAMOND) { super.doRender(entity, x, y, z, entityYaw, partialTicks); } } }
  8. Thanks, I got it working by simply returning in the RenderEntityItem::doRender method that I overrode. However, what if I wanted to only hide specific kinds of EntityItems? If I copy the whole code for the RenderEntityItem::doRender method and paste it in my method override, there are some private fields that I do not have access to. Should I copy those in my class, too? EDIT: I was able to cancel the rendering of only one kind of item (e.g., diamonds) by copying and pasting like I explained above. Continuing with the additional complexity theme, is there a way to make this rendering toggleable through a KeyBinding or whatnot, or is this way of rendering permanent once the game loads?
  9. Please excuse me for needing guidance. Here is what I have in my FMLPreInitializationEvent handler: @EventHandler public void preInit(FMLPreInitializationEvent event) { RenderingRegistry.registerEntityRenderingHandler(EntityItem.class, new RenderItemFactory()); } My RenderItemFactory class: public class RenderItemFactory implements IRenderFactory<EntityItem> { @Override public Render<? super EntityItem> createRenderFor(RenderManager manager) { return new RenderEntityItem(manager, new RenderAnItem(/* What arguments do I use? */)); } } My RenderAnItem class: public class RenderAnItem extends RenderItem { public RenderAnItem(TextureManager textureManager, ModelManager modelManager, ItemColors itemColors) { super(textureManager, modelManager, itemColors); /* What goes here? */ } } Have I approached this wrong, or am I on the right track? Thanks.
  10. Bump; does anyone know how to cancel EntityItem rendering?
  11. I thought I did, and thank you. I'm surprised I didn't discover this method on my own before posting here...
  12. It's a a ClientChatReceivedEvent (so running client-side) and I'm using EntityPlayerSP#addMessage to print a message to the player when a certain message is received. I want the message I print to be printed after the message from the event shows up in chat, not before.
  13. By "resolves" I mean "finishes", as in event listeners no longer detect that the event is taking place. I need to do something after an event, as opposed to altering it or doing something before the event finishes. If it's some chat event, for instance, and I log a message to the player in my event listener, that message will be logged before my screen displays the original chat. Given this scenario, I'd like to log the message after I receive the chat.
  14. To my knowledge, an event resolves immediately after everything is done in its event handler. Is there a way to do something immediately after a specific event is over?
  15. For some reason ITextComponent's method didn't work for me, but TextComponentString's did as I expected. Perhaps it is because the message I am listening for contains What if the text contains multiple styles that may or may not be complexly strung together? E.g. String text = TextFormatting.RED + "My favorite color is " + TextFormatting.BOLD + TextFormatting.ITALIC + "red" + TextFormatting.RED + ". " + TextFormatting.YELLOW + "Can you read " + TextFormatting.OBFUSCATED + "this" + TextFormatting.GOLD + "?";
  16. Thank you, I figured it out with that information. I cast the ITextComponent to a TextComponentString and then compared TextComponentString::getFormattedText to my own String with some TextFormatting in it. I also noted that the placement of formatting must match exactly for the text to be considered equal.
  17. Thank you, the equals method worked perfectly for both the display name and lore.
  18. I don't. I check the NBT of the item I'm currently holding at certain times.
  19. How do I get the message from a ClientChatReceivedEvent in the form of a TextComponentString such as new TextComponentString(TextFormatting.AQUA + "I like trains."); Everything I've tried so far just results in a very long String with data about the message as opposed to just the message itself.
  20. I'm having trouble comparing the name and lore of an item to a name and lore that I specify. Here is some code that demonstrates my issue: public static final String NAME = TextFormatting.LIGHT_PURPLE + "Magic"; public NBTTagList lore = new NBTTagList(); lore.appendTag(new NBTTagString(TextFormatting.DARK_PURPLE + "This does magic stuff!")); lore.appendTag(new NBTTagString(TextFormatting.RED + "Magic stuff is magical.")); public ItemStack itemStack = // some ItemStack that has a display name of NAME and a lore of lore public NBTTagList getLore(ItemStack itemStack) { NBTTagCompound nbt = itemStack.getTagCompound(); if (nbt != null) { NBTTagCompound display = nbt.getCompoundTag("display"); if (display != null) { NBTTagList lore = display.getTagList("Lore", 8); if (lore != null) { return lore; } } } return new NBTTagList(); } public boolean displayNamesEqual = itemStack.getDisplayName() == NAME; public boolean loresEqual = getLore(itemStack).toString() == lore.toString(); // displayNamesEqual and loresEqual both evaluate to false Does it have to do something with the color/style of this information?
  21. Is there a way to detect if an EntityPlayer's body is completely horizontal?
  22. @tripl3dogdare @larsgerrits Thank you, this is very informational. I should've mentioned that I'm aware that all of this is client-side only, but thank you for the heads ups. Much of what I'm trying to do involves sending messages to the user, so it's hard to come by an event that provides a reference to the player returned by Minecraft::getMinecraft::player.
  23. As I've not modded for a while, I'd like to begin again on the right foot. I apologize in advance if there's some misunderstanding of Java on my part. 1. Is it safe to save the value from Minecraft::getMinecraft in a static variable? The return type is static so I'd assume so, but then wouldn't this be the same across all instances of Minecraft that are run? If a player decides to log into two different accounts on two different instances of Minecraft, how would Minecraft::getMinecraft::player return due to Minecraft::getMinecraft being static? 2. I'm confident that Minecraft::getMinecraft can be used safely as soon as the mod is loaded, but when is Minecraft::getMinecraft::player not null? Does the player have to load a world first? Is there an event I can listen to to set a non-null Minecraft::getMinecraft::player to a variable then not have to worry about it? 3. Likewise, when in the process of loading up a world does Minecraft::getMinecraft::world gain a value? Is there, again, an event that would let me know when this becomes non-null? Thanks, and please pardon my noobiness.
×
×
  • Create New...

Important Information

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