-
Posts
5170 -
Joined
-
Last visited
-
Days Won
77
Everything posted by Choonster
-
A NullPointerException means you tried to call a method on or access a field of a null value. The only value on that line that can be null is the attachedEntity field. You need to check that it's not null before you try to call INBTSerializable#serializeNBT on it. This is basic Java knowledge.
-
You're not storing the facing in the metadata in getMetaFromState and you're treating the raw metadata value as both the facing and the variant in getStateFromMeta, which won't work. In getMetaFromState, you need to combine the facing and variant into a single metadata value using bitwise operators and then return it. In getStateFromMeta, you need to extract the facing and variant from the metadata using bitwise operators and then return the IBlockState with these values set. If your block can't have vertical facings, use EnumFacing.getHorizontal instead of EnumFacing.getFront to get the EnumFacing from its index. Use EnumFacing#getHorizontalIndex to get the horizontal index of an EnumFacing. Keep in mind that metadata is limited to 4 bits (16 possible values). If you have 4 possible facings (north, south, east, west), that only leaves room for 4 possible variants (because 4 * 4 = 16). Look at BlockAnvil for an example of a Block with two properties (facing and damage).
-
Post the FML log (logs/fml-client-latest.log in your Minecraft directory) in a spoiler (the eye icon in the editor). The two lines you've posted tell us almost nothing about what went wrong.
-
Not really, I don't know much about it myself. I've seen people recommend VisualVM for this sort of thing, you may also be able to use Minecraft's Profiler class. If you enable profiling in Minecraft (/debug start), you may be able to add a shutdown hook (Runtime#addShutdownHook) that saves the profiling output to a file (e.g. by running /debug stop). This would allow you to see what took so long after the server is stopped by the watchdog.
-
Questions about getting started with Forge modding
Choonster replied to kingkoronov's topic in Modder Support
There's a list of tutorials here. Some of them have been updated to 1.11.x, some of them are only on 1.9.x/1.10.x but the versions are fairly similar. -
Then the issue is probably with another one of your mods. Try removing all of the Malisis mods, I seem to remember them messing with Forge's internals at some point. If that doesn't fix it, post the complete FML log (logs/fml-client-latest.log); it may contain some useful information about the issue. If it doesn't, you'll need to remove mods until the issue no longer occurs.
-
You posted this in the wrong section, but it should be moved by a moderator soon. Does this occur without OptiFine? Does this occur if you revert to Forge 1.11.2-13.20.0.2227 (the Forge version supported by OptiFine 1.11.2_HD_U_B7)?
-
This is a crash induced by ServerHangWatchdog because a tick took longer than the maximum tick time (1 minute by default). You'll probably have to do some profiling to figure out what's taking so long.
-
Removing a Vanilla Smelting Recipe [1.10]
Choonster replied to minecraftbigfoot's topic in Modder Support
You can't compare ItemStacks using Object#equals, you need to use one of the static equality methods in the ItemStack class. You shouldn't be creating a new ItemStack at all, though. You need to get the ItemStack key from the Iterator and check its Item, metadata and NBT as appropriate to determine whether it should be removed. Iterator<E> is a generic type, don't use it (or any other generic type) without specifying its type argument. -
Removing a Vanilla Smelting Recipe [1.10]
Choonster replied to minecraftbigfoot's topic in Modder Support
Calling Map#remove with a new ItemStack on a Map with ItemStack keys won't do anything. ItemStack doesn't override Object#equals or Object#hashCode, so two ItemStacks are only considered to be the same key if they're the same object. Map#remove will only work here if you call it with an ItemStack object that's already a key in the Map. -
It should probably be fired just before the second if statement in WorldEntitySpawner.canCreatureTypeSpawnAtLocation. The event should include the EntityLiving.SpawnPlacementType, World, BlockPos and IBlockState and have an Event.Result that controls the behaviour (like LivingSpawnEvent.CheckSpawn). An alternative would be to add a method to EntityLiving.SpawnPlacementType that takes the World, BlockPos and IBlockState and returns a nullable Boolean or Optional<Boolean> functioning similar to Event.Result (allow, deny, default). You'd then need to add a field to EntityLiving.SpawnPlacementType to hold a delegate function for the method to call (like EnumEnchantmentType#canEnchantItem/EnumEnchantmentType#delegate). A Function<Triple<World, BlockPos, IBlockState>> would work, though it's a bit ugly.
-
Need help updaitng mod from 1.8.9 to 1.11.2
Choonster replied to NovaViper's topic in Modder Support
It was renamed to net.minecraft.util.text.translation.I18n and deprecated, because the server shouldn't be translating things (the dedicated server can only translate to en_US). Use net.minecraft.client.resources.I18n from the client instead (or send a TextComponentTranslation, which will translate to the client's locale). This hasn't changed. Override Block#hasTileEntity(IBlockState) to return true for any state that has a TileEntity and override Block#createTileEntity to create an return an instance of the TileEntity for the provided state. Which methods do you want to know about? Try looking at the TileEntity class or vanilla extensions of it. MCPBot can tell you the SRG name of a field/method in a specific version and also tell you the current MCP name of an SRG name. This issue tracker documents most renamed field/methods. Again, look at vanilla examples like BlockCactus or BlockBasePressurePlate. Store the block's bounding boxes as AABB fields. Override Block#getBoundingBox to return your Block's main bounding box, Block#getCollisionBoundingBox to return your Block's collision bounding box (if it's different to the main bounding box) and Block#getSelectedBoundingBox to return your Block's selection bounding box offset by the BlockPos (if it's different to the main bounding box). If your Block has multiple collision bounding boxes, override Block#addCollisionBoxToList (the instance method) to call Block.addCollisionBoxToList (the static method) for each bounding box. Entity#getRidingEntity returns the entity being ridden by this. Entity#getPassengers returns the entities riding this. -
IWorldEventListener & World variable [1.10]
Choonster replied to Matryoshika's topic in Modder Support
Create a new instance of your IWorldEventListener for each World and store the World in a field. ServerWorldEventHandler and RenderGlobal both do this. -
Which clients need which data and when? If a client always needs to know a particular value (e.g to render it on a HUD), send a packet to any relevant players when they log in and when the value changes. If a client only needs to know the value in a GUI, you can probably sync it through the Container (either using the built-in syncing packets or your own). If a bank account is only ever linked to one player, consider storing a player's bank account(s) in a player Capability instead of using World Saved Data.
-
Are there any errors in the log?
-
Your WorldSavedData class must have a constructor that takes a single String argument.
-
You're using the blocks Field twice and casting the value of the second call to List<Template.EntityInfo> instead of using the entities Field. This will throw a ClassCastException at runtime. It also looks like you're not actually using the size Field. I recommend following Java naming conventions by using CONSTANT_CASE for constant fields.
-
Set the tint index for each model face you want to be coloured at runtime and register an IBlockColor for the Block that returns the appropriate colour for each tint index depending on the location. Look at BlockColors for vanilla examples.
-
Use ReflectionHelper.findField or ReflectionHelper.findMethod to get a Field/Method object for the field/method and store it in a private static final field. You'll need to provide both the MCP and SRG names of the field/method. Use Field#get or Field#set to get or set the value of a field. If it's an instance field, pass the instance as the first argument. If it's a static field, pass null as the first argument instead. Use Method#invoke to call a method. If it's an instance method, pass the instance as the first argument. If it's a static method, pass null as the first argument instead. Pass the method's arguments as the vararg argument.
-
That's the correct way to create a ResourceLocation, assuming your shuriken texture is located at assets/<modid>/textures/items/shuriken.png. It's not directly related to your issue, but I noticed that you're extending the raw Render type instead of specifying its generic type argument. If you specify the type argument as EntityShuriken, you can delete the getEntityTexture(Entity) and doRender(Entity, ...) methods, since the getEntityTexture(EntityShuriken) and doRender(EntityShuriken, ...) methods will override the corresponding super methods. If you want your entity to render as an item model (like snowballs, ender pearls, eggs, etc.), you can use or extend RenderSnowball.
-
IRenderFactory#createRenderFor is called from the RenderManager constructor, before the RenderManager instance is stored in the Minecraft#renderManager field (used by Minecraft#getRenderManager). This means you're passing null as the RenderManager argument of your RenderShuriken constructor, so Render#bindTexture throws a NullPointerException when it tries to get the RenderManager#renderEngine field from it. You need to use the RenderManager instance passed as an argument to IRenderFactory#createRenderFor instead of trying to get it from Minecraft. This is also a general guideline you should follow: Use the data you've been given rather than trying to get the data yourself (unless you have a specific reason not to).
-
Even if they only run on older versions of Minecraft, the models produced by them should work in 1.11.2.
-
You can try Tabula or Qubble.