Everything posted by V0idWa1k3r
-
Entity Not Spawning
You can't do this in the entity constructor since models are client-side and this will crash the server. EntityCreature doesn't have ATTACK_DAMAGE registered at all, hence the NPE when getting it. You need to register the attribute first with AbstractAttributeMap#registerAttribute. See EntityMob for an example.
-
Custom Model Armor in Hand
public net.minecraft.client.model.ModelBiped getArmorModel(EntityLivingBase entityLiving, ItemStack itemStack, EntityEquipmentSlot armorSlot, net.minecraft.client.model.ModelBiped _default) The custom model for the armor must be an instance of ModelBiped. Unless you want to invent a way to convert a IBakedModel into a ModelBiped this is impossible with this method. Even if you go around this method and use events to render a IBakedModel you will have a nightmare trying to animate parts of it(you can't split the model into parts because the item needs to be a single model obviously and armor parts are rotated differently).
-
Custom Crafting recipes MInecraft Problem
You need to specify all of those variants in the ingredient. Or if you want stuff from other mods to be accepted as well you'd need to use the ore dictionary. Here is an example of using ore dict(I specify stuff in the _constants file but you can specify them directly in your ingredients, having a _constants just allows you to reuse ingredients instead of having to type them over and over again) The recipes use json. the "data" is just a json property of the object named after your ingredient key.
-
Custom Model Armor in Hand
You would need to make an identical model in json/obj and make the item have that model just as any other item. And before you ask - yes, there is a way to reuse your ModelBiped code and no, I won't be supporting it or explaining it as it is not the use case for it. Make a model for your item in something like BlockBench and export it to both json(item model) and java(armor model).
-
[Solved] [1.12.2] Display custom vignette
You can specify an alpha test function that would cut off pixels that are too transparent. GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO); This is not the blend function the vignette uses but I guess if it works for your texture just fine then you can keep it... Change the Z level to something big and negative. You can also remove the depth manipulations while you are at it. And change the event to Post instead of Pre. Also an important note - Pre and Post events fire for each HUD element! That means that you are rendering your overlay multiple times over and over again. You need to check the current element being rendered. In your case it would be ALL. if (event.getType() == RenderGameOverlayEvent.ElementType.ALL)
-
Efficiency Regarding Checking Two Objects
It is easier to list objects that ARE singletons. As a rule of thumb anything that is a IForgeRegistryEntry is a singleton.
-
Custom Crafting recipes MInecraft Problem
No it isn't. / is as valid of a character as any other one in java. \ is the escape character. It can't work just fine because it's syntax is invalid. Stone has subtypes and uses metadata to differentiate between variants and as such a data property must be specified in the ingredient. You are not specifying one.
-
[Solved] [1.12.2] Display custom vignette
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.
-
[Solved] [1.12.2] Display custom vignette
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.
-
[Solved] [1.12.2] Display custom vignette
Show your new code.
-
[Solved] [1.12.2] Display custom vignette
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.
-
[1.12.2] dynamic item textures
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.
-
[1.12.2] dynamic item textures
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.
-
[Solved] [1.12.2] Display custom vignette
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.
-
[1.12.2] dynamic item textures
You can use property overrides.
-
[1.10.2] Particles+Sound
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.
-
how to pull info from a cfg file?
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();
-
[1.12.2] getMaterial and actual state
getExtendedState is only used when rendering the block. It is only ever called in BlockRendererDispatcher#renderBlock and ForgeHooksClient.getDamageModel.
-
Can we subscribe to FML events?
You can subscribe to anything that is a descendant of net.minecraftforge.fml.common.eventhandler.Event regardless of it's package.
-
[1.12] Is there a way to color BakedQuad's?
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:
-
compatibility issue
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.
-
Item Burn/Fuel Values
Override item#getItemBurnTime and return the value you want.
-
How to set a variable on a entity?
Use capabilities.
-
[1.12.2] Weird missing model variant error (#null/inventory)
Those fields @Animefan8888 is talking about are not annotated with @ObjectHolder though as far as I can see.
-
How to read the itemdescription from the chest?
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.
IPS spam blocked by CleanTalk.