Jump to content

V0idWa1k3r

Members
  • Posts

    1773
  • Joined

  • Last visited

  • Days Won

    61

Everything posted by V0idWa1k3r

  1. Your blend function is still wrong. Why do you keep changing it in it's entirety? I told you to change the first parameter, not the second one. The second parameter is supposed to be ONE_MINUS_SRC_COLOR.
  2. Also you are telling it to render an empty list of strings which is not very productive. It is supposed to contain the description of the item.
  3. Show your new code.
  4. Your blend function is incorrect. The first parameter is supposed to be ZERO. Also blend isn't enabled by the time RenderGameOverlayEvent.Pre fires. You have to enable it first. Use GuiUtils#drawHoveringText. The one that takes an ItemStack as it's first parameter. Be aware that rendering the text disables blend and changes the state's color. So you will have to enable blend back and change the color to white after you are done.
  5. What is 10 divided by 100? It's 0. 99 / 100 is also 0. Only 100 / 100 is 1. Dividing anything that doesn't have decimal points will just discard anything beyond them. You need to cast one of these to something that has a decimal point, like a float.
  6. You didn't... do anything? I see no mentions of property overrides in your ItemSyringe. ModItem, ItemBase, etc is an anti-pattern. Don't use it. Oh also anything like IHasModel is stupid. All items need models and there is nothing about model registration that requires access to something private/protected in the item. And yes, your ModItem is basically a fancy IHasModel. Don't use it. Register your models in the ModelRegistryEvent. Instantinate your items directly in the RegistryEvent. Not anywhere else. Not in pre init. If you need a reference to the item later use ObjectHolders. There is no reason for this to exist. if(blood == cap || blood == cap - 1 || blood == cap - 2) { blood = cap; } else { blood += 3; } => blood = Math.min(this.cap, blood + 3); Any reason you are storing the cap in the NBT? You are only referencing the one declared by your Item instance.
  7. First of all you can't do this This will crash the server because GuiScreen doesn't exist on the server. Why are you extending GuiScreen anyway? There is no reason to do so. This will never be false. The RenderGameOverlayEvent fires, well, when the overlay HUD is rendered. The player is never null by then. This will never be false. The player can't have a non-null inventory. This will never be false. The inventory will always have it's armor list instantinated. All of this can be replaced with one line of code: ItemStack helmet = Minecraft.getMinecraft().player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); There, you are done. This does a lot of things to GL state which are not supposed to be there when the HUD is rendered, thus the game can't properly draw the rest of it and all you see is a black screen, hence the Don't call this method. It doesn't really work during the HUD pass anyway. GlStateManager.disableBlend(); GlStateManager.disableAlpha(); GlStateManager.enableDepth(); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); Why are you disabling blending? The rest of the HUD rendering expects it to be enabled. And if you are disabling it there is no logic in setting the blend function to something else afterwards. Same with the alpha. Don't disable it. In fact don't enable it in the first place, it is irrelevant.
  8. You can use property overrides.
  9. What exactly do you not understand? World#playSound takes in a player that "initiated" the sound aka the one to not play the sound to on the server and the one to play the sound to on the client, the position of the sound, the sound itself(you can find all sounds in the game at SoundEvents class), the category(you can find all categories in SoundCategory class), the volume and the pitch. World#spawnParticle takes in a particle type to spawn(you can find all particles in the EnumParticleTypes class), the X, Y and Z position of the particle, the X, Y and Z motion of the particle and optional additional arguments for the particle(for example ITEM_CRACK takes an ID and the metadata of the item). Most particles do not have additional arguments.
  10. What do you mean by Did you create the file in a text editor? Using the @Config annotation system? Using the Configuration class? You need to either use the @Config annotation system or the Configuration class. If you are using the annotation system it is as simple as referencing a field from the annotated class. If you are using Configuration you will need to load it in the FMLPreInitializationEvent and store to a field. You can then obtain the values by using Configuration#get to get a property and then use one of the getters of the Property to actually get the value. For example: Configuration cfg = ... // Read in FMLPreInitializationEvent. int experienceValue = cgf.get("stats", "experienceValue", 15).getInt();
  11. getExtendedState is only used when rendering the block. It is only ever called in BlockRendererDispatcher#renderBlock and ForgeHooksClient.getDamageModel.
  12. You can subscribe to anything that is a descendant of net.minecraftforge.fml.common.eventhandler.Event regardless of it's package.
  13. public List<BakedQuad> colorQuads(List<BakedQuad> quads, int color) { for (int i = 0; i < quads.size(); i++) { net.minecraftforge.client.model.pipeline.LightUtil.renderQuadColor(Tessellator.getInstance().getBuffer(), quads.get(i), color); } return quads; } renderQuadColor renders the quad. It doesn't change the properties of said quad. So this would obviously do nothing to the quad. int colorRGBA = 0; colorRGBA |= 0x00 << 16;// r colorRGBA |= 0xFF << 8; // g colorRGBA |= 0x00 << 0; // b colorRGBA |= 0xFF << 24;// a renderQuadsColor(bufferbuilder, quads, colorRGBA); Or you could simply write int colorRGBA = 0xFF00FF00; And have the same effect without the bitshifts and or. As for the actual question. Quads are usually stored in the ITEM vertex format which has the color element. So you can absolutely apply color to BakedQuads. It is pretty straight forward. Each quad contains 4 vertices which each contain the elements of the format in the order specified by that format. In BakedQuads those vertices are unified into a single array: protected final int[] vertexData; This doesn't stop you from modifying the vertex data by modifying the array. So the logical order of operations would be to iterate 4 times(4 vertices per quad), get the color element in the array by multiplying the current vertex's index with the size of each vertex and adding the offset to the color element. All that data is available to you in the format of the quad. So basically you would need to create a custom BakedQuad wrapper and change what you return in the BakedQuad#getVertexData method. This might be tough to understand so here is a functional example: private static class ColoredQuad extends BakedQuad { private boolean wasRecolored; // Caching whether the recoloring occured. private int[] vertexData; // The data of the quad. // Wrapper constructor public ColoredQuad(BakedQuad original) { super(original.getVertexData(), original.getTintIndex(), original.getFace(), original.getSprite(), original.shouldApplyDiffuseLighting(), original.getFormat()); this.vertexData = original.getVertexData(); } private void recolor() { // First getting the format of the quad. VertexFormat format = this.format; // Getting the size of each vertex. int size = format.getIntegerSize(); // Getting the color offset. Dividing by 4 because the offset is specified in bytes. int offset = format.getColorOffset() / 4; // The color you want to recolor the quad to. Note that the format for the color is ABGR! int newColor = 0xFF0000FF; // Iterating over the vertices(4 vertices per quad) for (int i = 0; i < 4; i++) { // Modifying the element of the vertex at [i] at [offset] with the new color. this.vertexData[offset + size * i] = newColor; } // Caching that the operation was performed. this.wasRecolored = true; } // The vertex data getter. @Override public int[] getVertexData() { // Recolor the quad if it wasn't recolored. if (!this.wasRecolored) { this.recolor(); } return this.vertexData; } } And here is how it looks when I replace the model of the Iron Ingot with the one that colored the quads:
  14. That is a bad assumption since that FontRenderer object is used to draw every piece of text in the game. If it was somehow modified to not work then there would be no text in the game at all. I would assume that this "LabyMod" either cancels the RenderGameOverlayEvent in which case you either want your event to be handled before it is cancelled(either make the priority higher or set receiveCanceled to true) or it replaces the in-game HUD to it's own version that doesn't throw the event in which case go complain to that mod that they are breaking functionality. I assume it would also be possible to render your HUD in a RenderTickEvent but I've never worked with it and don't know what the GL matrix is set to at the time.
  15. Override item#getItemBurnTime and return the value you want.
  16. Use capabilities.
  17. Those fields @Animefan8888 is talking about are not annotated with @ObjectHolder though as far as I can see.
  18. Well obviously it won't be the case when the RightClickBlock event fires. This event happens before any vanilla logic runs and thus before the game even has a chance to open the GUI. You need another event. For example the GuiOpenEvent. Then you can use GuiOpenEvent.gui instead of Minecraft.currentScreen. Edit: Now when I think about it that won't work either. The client is never aware of the items within the chest and by extension the Container when it is opened. The game sends the packet to the client after the GUI is opened that tells the client about the items. So you would have to hook into some sort of TickEvent and chack your container there. You would need to detect when the GUI is opened(probably via the GuiOpenEvent) set some boolean somewhere to true, in your TickEvent check whether the boolean is true and check the contents of the container. If they are not empty do whatever you want to do and set the boolean to false.
  19. This is still not the right way to cast things. This is not about mine or anyoneelses ego. This is about you and your coding. If you don't know the language you are using you won't be able to do much. You will encounter issues you won't be able to solve because you don't know how, like right now. And you will come to this forum again asking a question that can be solved just by knowing the language. And we will have to tell you the same thing I am telling you right now - learn java before starting to mod. You WILL have issues.
  20. Well then you should probably learn java before starting to make mods. Otherwise you are trying to assemble a rocket without a guide.
  21. They are different classes. An EntityPig is a descendant of EntityLivingBase, but EntityItem or EntityArrow isn't.
  22. You don't have to put anything for "item" since it is a variable already, look at the example provided. As for "model location" you would put something like new ModelResourceLocation(item.getRegistryName(), "inventory"); In your ModelRegistryEvent.
  23. EntityLivingBase#addPotionEffect. You can't add a PotionEffect to an Entity since Entity objects can't have them in the first place. Only the descendants of EntityLivingBase may have potion effects.
  24. You can get the current GUI opened with Minecraft.currentScreen. Then if it's a chest that GUI will be an instance of GuiContainer. You can then access the Container of that GUI with GuiContainer.inventorySlots. Finally you can iterate all ItemStacks of that container with Container.inventoryItemStacks.
×
×
  • Create New...

Important Information

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