Posts posted by Choonster
-
-
2 minutes ago, OrangeVillager61 said:
Lastly, how do I allow the button to dynamically change from following to follow and vice versa in the text as a confirmation that the packet had been sent and worked?
Override GuiButton#drawButton to set GuiButton#displayString based on the villager's following state and then call the super method.
-
-
3 minutes ago, OrangeVillager61 said:
I know but what kind of compound I use to set the serialization?
In writeEntityToNBT, call INBTSerializable#serializeNBT to serialise the ItemStackHandler to a compound tag and then call NBTTagCompound#setTag on the compound tag argument, passing the serialised ItemStackHandler compound tag as the second argument.
In readEntityFromNBT, call NBTTagCompound#getCompoundTag on the compound tag argument to get the serialised ItemStackHandler compound tag, then pass it to INBTSerializable#deserializeNBT to deserialise the ItemStackHandler.
8 minutes ago, OrangeVillager61 said:Also, I've been getting this error, do you know what it means?
That's not an error, that's someone printing a UUID to stdout. I don't think Vanilla or Forge do this, so it's probably your code.
-
22 minutes ago, Jay Avery said:
I'm trying to figure out how to name and define versions for my mod. I know that any version will only be compatible with a single minecraft/forge version - which will be defined in @Mod.acceptedMinecraftVersions, in "mcversion" in the mcmod.info, and in the minecraft version section in build.gradle. (Am I on the right lines so far?)
That's correct.
22 minutes ago, Jay Avery said:With other things as their default, the mod only allows a client to connect to a server which has the exact same mod version. So, say a 1.0.0.0 client can't connect to a 1.0.1.0 server. I'd like to allow clients to connect as long as their major version matches - so 1.0.1.0 should be able to connect to 1.0.0.0, but 2.0.0.0 shouldn't. I know there's @Mod.acceptableRemoteVersions. But I just tested that by setting it to the exact current version of the mod (i.e., I expected the result of this to be the same as if I hadn't changed this from the default at all), and ended up being able to connect to a server that wasn't even forge, let alone had my mod installed. Do I need to change a setting elsewhere, like in build.gradle or mcmod.info too? Have I misunderstood what acceptableRemoteVersions is supposed to do?
@Mod#acceptableRemoteVerions expects a version range, not just a single version. It's parsed using VersionRange.createFromVersionSpec, which has a doc comment explaining the format.
-
36 minutes ago, OrangeVillager61 said:
How do I do that? Is this what you suggested?
That's the right method, but you actually need to store the compound tag returned by it in the compound tag you receive as an argument to writeEntityToNBT. Currently you're just discarding it.
You also need to do the reverse with INBTSerializable#deserializeNBT in the readEntityFromNBT method.
Why are you checking World#isRemote? It's not necessary in these methods and may break things.
-
Edited by Choonster
19 minutes ago, OrangeVillager61 said:The hiring mostly works but I have one major issue:
The inventories are reset on reload, I have no clue how to prevent this.
You never write the IItemHandler to or read it from NBT, so it's not persisted when the entity is unloaded/reloaded. Do this using the INBTSerialializable methods implemented by ItemStackHandler.
-
Just now, IvanSteklow said:
What's wrong?
You're registering the Class with the event bus, but your event handler method isn't static. If you register the Class, you need to use a static method. If you register an instance, you need to use an instance method. The documentation explains this.
There's no reason to create a new object of a known class and immediately call Object#getClass on it, just use a class literal.
-
Edited by Choonster
@Mod.EventHandler is only for FML lifecycle events that extend net.minecraftforge.fml.common.event.FMLEvent, e.g. FMLPreInitializationEvent or FMLServerStartedEvent and only works in your @Mod class.
@SubscribeEvent is used for gameplay events that extend net.minecraftforge.fml.common.eventhandler.Event, e.g. PlayerInteractEvent.RightClickItem or TickEvent.ServerTickEvent.
Forge's documentation explains events in more detail here.
The ItemStack returned by PlayerInteractEvent#getItemStack will never be reference equal to an ItemStack you've just created, because they're not the same object (which is what the == operator checks). To compare ItemStacks, either get the Item, metadata, etc. and compare those or use the static equality methods in the ItemStack class. Since you're only checking the Item, use ItemStack#getItem to get the Item and check if it's equal to (==) Items.GLASS_BOTTLE.
-
4 hours ago, theDataSmith said:
When I use ModelLoader.setCustomModelResourceLocation to register the model for the ItemBlock, it uses the blockstates json, not the models/item json. How to I make it use the models/item json?
Forge tries to load the item model first and only tries to load the model from the blockstates file if that fails. I have a more detailed explanation of the model loading process here.
If it's not loading your item models, the FML log should have an error message explaining why.
-
-
-
-
-
If you update to the latest MCP mappings, DamageSource#getSourceOfDamage/getEntity have been renamed to DamageSource#getImmediateSource/getTrueSource respectively.
This makes it clearer which entity is which.
-
I encountered several issues with your code:
You're registering two different IMessageHandlers (HireVillagerPacket and ChangeFollowPacket) for the same IMessage class (MessageSendEntityId), which doesn't work. Each IMessage class can only have a single IMessageHandler.
These classes are poorly named. HireVillagerPacket and ChangeFollowPacket are packet handlers, not packets. MessageSendEntityId tells me what the packet sends, but it doesn't tell me the most important piece of information: why the packet is sent, i.e. what action does it perform? You use Packet in the handler names but you use Message in the packet name, pick one and stick with it.
GuiHandler#getClientGuiElement incorrectly returns a Container instead of a GuiScreen for the Hauler ID.
GuiIvVillagerHauler uses ContainerIvVillagerHireNitwit instead of ContainerIvVillagerHauler.
ContainerIvVillagerHauler adds 15 Slots for the villager's inventory, but the IItemHandler created in IvVillager only has one slot.
The Button_Hire and Button_Follow classes no longer serve a purpose, you can replace their usages with regular GuiButtons.
When you have an if statement that does nothing but set the value of a boolean variable (like in GuiIvVillagerHireNitwit#actionPerformed), you can move the expression used as the condition of the if statement directly to the initialisation of the boolean variable and remove the if statement.
When you have a boolean variable declared directly before and only used in the condition of the if statement, you can move the expression used to initialise it directly into the condition of the if statement and remove the boolean variable. If the condition of an if statement is particularly complex, it can be clearer to keep some parts of it as variables.
I've fixed these issues and pushed the changes to GitHub. You can view and/or merge the changes here.
You appear to be using GitHub's web UI to upload changes to your repository, I highly recommend using a proper local Git client instead. This will allow you to create more fine-grained commits with descriptive messages rather than lumping all your changes into a single commit with a message like "Add files via upload".
-
Edited by Choonster
4 hours ago, bignose956 said:I have a throwable entity that works great and I am satisfied with the onImpact and onUpdate methods, but It still lacks a render. In it's item form it renders fine, but I cannot figure out how to render its entity state. I looked at the RenderSnowball class, but I cannot understand the constructor, which requires three different objects (RenderManager, Item, RenderItem), but got stuck when I came to the constructor for RenderItem and RenderManager because they both require a TextureManager object (which I do not know how to construct). The problem with the TextureManager is that it requires a IResourceManager object in its constructor, and IResourceManagers are interfaces (I'm inexperienced with interfaces).
Can anyone explain to me how to render an EntityThrowable or provide me with an accurate 1.8.9 tutorial?
You don't create the RenderManager or RenderItem instances yourself, you use the instances Minecraft has already created.
To register a Render for an Entity class, call RenderingRegistry.registerEntityRenderingHandler(Class<T>, IRenderFactory<? super T>) in preInit. In the IRenderFactory#createRenderFor implementation, create and return the Render instance.
You receive the RenderManager instance as an argument of IRenderFactory#createRenderFor and you can get the RenderItem instance using Minecraft#getRenderItem.
This advice applies to all versions from 1.8.9 onwards.
4 hours ago, bignose956 said:Uhhh, you might wan't double check that. 1.8.9 is still on forge (http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.8.9.html), and this is the official Forge Forums. Furthermore, I've been receiving help with 1.8.9 this whole week, and you are the only person that has made an unsupported claim about it.
1.7.10 and earlier are still available for download, but they're not supported on this forum. I believe 1.8.9 is still supported, but you should really update.
-
-
7 minutes ago, Nukley said:
Our main culprit for waiting is most likely the fact that, MCP hasnt been updated to 1.12 as of this writing. This could also be the reason why optifine, which usually doesnt require forge, is not updated to 1.12 as well. So were basically waiting on Searge for this one, dont spam his twitter about it though.
There are already experimental builds of Forge for 1.12 available, but they're not ready for general use.
-
-
-
Gradle generates the Eclipse project when you run the eclipse task.
Forge's documentation explains how to set up a development environment here.
-
-
59 minutes ago, Bektor said:
Also in your last answer you suggested using world capability or WorldSavedData. So what's exactly the difference between these two and which one would be a better choice to give also other mods access to the polution data saved per chunk so that these mods may add their own blocks and items using the values from them?
I also guess that those world capability stuff is just this thing here: AttachCapabilityEvent<World>
World Saved Data lets you store data per-dimension or per-map. World Capabilities are just a nicer wrapper around per-dimension WorldSavedData. For a public API, I recommend using Capabilities rather than World Saved Data.
I helped someone with a similar system and created my own implementation of it in this thread. You can see the API here and the implementation here.
-
The getBiomeSpecificBlockState method fires the BiomeEvent.GetVillageBlockID event, which allows you to change the IBlockState returned by it based on the Biome.
To change the IBlockState:
- Subscribe to the event. Note that it's fired on MinecraftForge.TERRAIN_GEN_BUS rather than MinecraftForge.EVENT_BUS.
- Check that the Biome is Ice Plains.
- Use BiomeEvent.GetVillageBlockID#getOriginal to get the original IBlockState.
- Set the replacement IBlockState with BiomeEvent.GetVillageBlockID#setReplacement.
- Set the event's result to Event.Result.DENY with Event#setResult to use the replacement IBlockState instead of the original.
[1.12] Block destroyed method
in Modder Support
Block#breakBlock is called when a block is replaced by another block, regardless of what caused the replacement.