-
Posts
5160 -
Joined
-
Last visited
-
Days Won
76
Everything posted by Choonster
-
"It crashed" doesn't tell us anything. Post the FML log (logs/fml-client-latest.log in the game directory).
-
The Vanilla and Forge shaped and shapeless recipe classes ignore NBT on their ingredients. You'll need to create your own IRecipe implementation (probably extending an existing one) that checks NBT.
-
[1.11.2] Is there any alternate way of FluidContainerRegistry?
Choonster replied to LeoCTH's topic in Modder Support
-
[1.11.2] Is there any alternate way of FluidContainerRegistry?
Choonster replied to LeoCTH's topic in Modder Support
FluidRegistry.enableUniversalBucket must be called before preInit, like I said in my post. You also don't need to create or register your own bucket Item if you're using the Universal Bucket. -
[1.11.2] Is there any alternate way of FluidContainerRegistry?
Choonster replied to LeoCTH's topic in Modder Support
Enable the Universal Bucket by calling FluidRegistry.enableUniversalBucket before preInit (e.g. in a static initialiser of your @Mod class), then add your Fluid to the Universal Bucket by calling FluidRegistry.addBucketForFluid in preInit. There's no need to create your own bucket or handle any events, the Universal Bucket does it all for you. You can use UniversalBucket.getFilledBucket to get a Universal Bucket filled with a Fluid (ForgeModContainer#universalBucket stores Forge's UniversalBucket instance) or create an ItemStack of a fluid container, get its IFluidHandlerItem capability and fill it with IFluidHandler#fill. The FluidUtil class contains several methods for dealing with IFluidHandlers, including player interaction. -
That class is completely unrelated to your situation. It handles remapping old Block/Item registry names to new ones when they change.
-
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
As Draco said, you need to use reflection to access the field. PlayerInteractionManager#durabilityRemainingOnBlock is a non-static field, so it needs to be accessed from an instance rather than the class. This is a basic Java concept. Each player's PlayerInteractionManager instance is stored in the EntityPlayerMP#interactionManager field. Every EntityPlayer on the logical server (when World#isRemote is false) is an instance of EntityPlayerMP. -
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
If you look at the usages of World#sendBlockBreakProgress, you'll see that it's called from various places within PlayerInteractionManager; this is the server-side class that manages block interactions (e.g. breaking) for the player that the instance is attached to. When the player is in the process of breaking a block, PlayerInteractionManager#durabilityRemainingOnBlock stores the current break progress; this is passed to World#sendBlockBreakProgress whenever it changes. -
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
BlockEvent.BreakEvent. -
[1.11.2] Drawing a string on screen with multiple colors
Choonster replied to Coron's topic in Modder Support
If you look at GuiNewChat#drawChat (which renders the recent chat messages), you'll see that it renders each line by calling ITextComponent#getFormattedText to get the text with formatting codes and then FontRenderer#drawStringWithShadow to render the text. FontRenderer is responsible for interpreting the formatting codes and rendering each character with the appropriate colour and style. The vanilla FontRenderer only supports the colours and styles of the TextFormatting enum, you'd need to implement custom colours yourself.- 1 reply
-
- 1
-
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
Forge's documentation has a page on events here. -
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
The method is only called on the Item that the player is holding. This is a general principle in Minecraft: methods of classes like Item and Block are only called on the object involved in the interaction (e.g. breaking a block calls a method on the Block that was broken and the Item being held by the player that broke it). To change the behaviour of Blocks and Items added by Minecraft and other mods, you need to use events. -
You can set the acceptedMinecraftVersions property of your @Mod annotation to change which versions of Minecraft are allowed to run your mod. If your mod isn't actually compatible with a Minecraft version, it will likely crash at runtime when it encounters an incompatibility. Look at VersionRange.createFromVersionSpec for brief documentation of the version range format. Look at FMLModContainer#bindMetadata to see how FML replaces some specific version ranges with others (where multiple versions are compatible with each other).
-
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
Item#onBlockDestroyed is called when a player destroys a block while holding an ItemStack of the Item in their main hand (regardless of what that Item is). The ItemStack argument is the ItemStack in the player's main hand. It's not called in creative mode. -
2 questions about destroying blocks [Forge 1.11.2]
Choonster replied to SnakeBlock's topic in Modder Support
Use World#setBlockState to replace the IBlockState at the specified BlockPos with another. Use World#setBlockToAir to replace the IBlockState at the specified BlockPos with air (this just calls World#setBlockState). Use Block#getDefaultState to get the default IBlockState of a Block and IBlockState#withProperty to get an IBlockState with the IProperty set to the specified value. Forge has an introduction to block states here. You can call World#sendBlockBreakProgress to render the block breaking cracks on a block. If called from the logical client, it will update the break progress for that position. If called from the logical server, it will send a packet to all players within 32 blocks of the position (except the one whose entity ID was passed as the first argument) that calls the same method on their client. -
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.