• 0

    posted a message on java.lang.NullPointerException: Unexpected error, Game Crash Creating Double slab by stacking single slabs

    Okay, so it says that the error is happening at line 152 of the ItemSlab class which is in the makeState() method.


    The line that is failing is: return this.doubleSlab.getDefaultState().withProperty(p_185055_1_, (T)p_185055_2_);


    The first parameter p_185055_1_ is of type IProperty and the second parameter p_185055_2_ is of type Comparable<?>.


    The error is a null pointer exception which means that one of the parts of the line is unexpectedly a null. It could be the parameters, but could also be the object like the doubleSlab itself or the default state returned.


    So the next step to debug is to use the debug mode of your IDE (Eclipse if that is what you're using). You need to set a breakpoint on line 152 in the ItemSlab class and it should trigger when you try to create a double slap. Then you can inspect all the parts of the statement to see what value they have and if any are null.


    You can also try to guess what the problem is. For example, it looks like the ItemSlab class is looking for a field called doubleSlab. Have you properly made a double slab in that field in your class?

    Posted in: Modification Development
  • 0

    posted a message on [RESOLVED] Get rid of shadows around block

    It might be related to the material you set for your block. You probably want a material that is "translucent". So I would suggest creating a new MaterialTranslucent() with whatever map color you want and also probably setNoPushMobility().

    Posted in: Modification Development
  • 0

    posted a message on Getting an error when setting up 1.12 modding workspace for eclipse

    Did you try just running them from command line directly (not batch with &&). Like one command: gradlew setupDecompWorkspace then wait for that to complete successfully then second command: gradlew eclipse.


    Also I think you can just give the gradlew command both arguments and just run it as gradlew setupDecompWorkspace eclipse.

    Posted in: Modification Development
  • 0

    posted a message on Generate new world and take screenshots with mod?
    Quote from undefined »

    Actually you shouldn't need to do all that. If you set up your workspace using gradlew setupDecompWorkspace, then you should be able to see all the vanilla source as a Referenced Library within your IDE. En Eclipse it is just in the Referenced Libraries -- I can't remember where it is in IntelliJ but it is definitely there too.


    Minecraft is not open source, but Java is a weird language because it was designed for "just in time" compilation meaning that the "source code" (well actually an intermediate type of obfuscated code) is distributed as the executable. This means that the JAR file is readable, except it might not be EASY to read because all the field and method names might be very cryptic and there won't be any comments. So MCP provided a crowd-sourced "mapping" to rename all the fields and methods so they are more understandable.


    You'll notice that Forge doesn't distribute Minecraft (that violates the license) but it will map a JAR that you download to make it more readable.


    Minecraft EULA explicitly allows modding, so nothing nefarious is going on.



    I feel like there must be some event to use here I just can't think of. I was considering also having onEntityJoinWorld just create a new thread and sleep for a minute or so, then try to take a screenshot with that thread....but that could get ugly and I'm no multithreading programming expert.

    The screenshot needs to be taken on the client side, since that is where the rendering happens. I think you should try using PlayerTickEvent but checking that you're on the client side. The "SP" player is the client-side player, so you could set a counter when SP player joins world and then count down in PlayerTickEvent and then like one second later initiate the same code as in the screenshot key binding.

    Posted in: Modification Development
  • 0

    posted a message on Generate new world and take screenshots with mod?

    So for event handling I have a tutorial here. I suspect you didn't register your handler properly -- the class needs further annotation and the method needs to be static.


    For coding where the sequence of execution might get complicated, I suggest putting in console print statements throughout your code to help you confirm proper operation (and help debug when things go wrong). So for example, in your event handling method I would put a System.out.println("Entity "+event.getEntity()+" joined world.") so you can confirm that the event is even firing.


    Get your events working and then when you get stuck on the next topic, I can try to help further.


    Regarding your question "What docs should I look through to find a method and class to do XYZ?" there isn't really much documentation except the code itself. There are tutorials (check out mine at jabelarminecraft.blogspot.com) though that can help you find your bearing.


    But otherwise I tend to just read the vanilla source code directly and try to figure it out. For example, just think about the things in vanilla Minecraft that are similar to what you're trying to do. In your case you might want to look at how "spectator" mode works since that involves a fairly free camera movement sort of thing that might be similar to what you need to do. And there is already a vanilla screenshot hotkey so look at how the code for that works for your screen capture.

    Posted in: Modification Development
  • 1

    posted a message on Generate new world and take screenshots with mod?

    It shouldn't be too hard.


    Just handle the EntityJoinedWorldEvent and check for it being your test player, if it is then move them (or move the view entity representing the camera) and take the screen shot.


    For the looping part, you can make a public static int field in your mod's main class and initialize that to the number of loops. Then you can handle the GuiOpenEvent and check for the new world gui, and if the loop counter is >0 then decrement it and cancel the vanilla one and just run the same code that would run if the user hit the New World button.


    I think that would work. To start the whole thing you'd just try to open the new world gui manually and then it should take over from there. It will loop through generating the new world and as soon as it is generated it will get your player to join which will give you opportunity to move the player and take the screen shot.


    Note, It is possible the joined world event fires a little bit early, plus if you teleport to a part of the world that isn't loaded yet it might take a few ticks, so you might either want to check that the chunks are loaded at the position before taking the screenshot, or just put in a delay you are certain will allow loading (maybe 5 seconds).

    Posted in: Modification Development
  • 1

    posted a message on GetGroundFromAbove
    Quote from XxRexRaptorxX»

    The strange thing is that all works fine if i only test for one block type. Like: foundGround = block != Blocks.AIR ;


    That is because you're using an OR operation (||) instead of an AND (&&). But probably the easiest way to understand the logic is to keep the OR and use the NOT operatior (!) on the result of the combined OR. Like this:


    foundGround = !(block == Blocks.AIR || block == Blocks.TALLGRASS || block == Blocks.SNOW_LAYER || block == Blocks.LEAVES || block == Blocks.LEAVES2 ||
    block == Blocks.LOG || block == Blocks.LOG2 || block == Blocks.RED_FLOWER || block == Blocks.YELLOW_FLOWER || block == Blocks.CACTUS || block == Blocks.WATERLILY);


    Basically, the logic makes more sense this way it is saying foundGround will be true if not any of the blocks match.

    Posted in: Modification Development
  • 1

    posted a message on GetGroundFromAbove

    If code doesn't do what you expect, just "trace" the execution. You can use debug views and breakpoints, but I find it is easier to just add console print statements throughout the code. Print out enough stuff so you know that the method is being called, what position it is checking and what it is finding at that position.


    It should be very, very obvious what is going wrong if you simply watch the execution.

    Posted in: Modification Development
  • 0

    posted a message on Add +1 to a variable every second?

    Well, if you want to do that for the player then you can do it in the PlayerTickEvent. If you want to do it for other entities maybe in the LivingUpdateEvent. These events fire every tick. There are 20 ticks per second so you'll want a counter that starts at 20 and counts down and when it reaches 0 to add one to the speed.


    You need to be careful with the counter though because to really calculate time exactly you'd want a timer for every player, but that can get complicated. I personally wouldn't worry about it being super accurate and instead use the built-in world time and just use the % operator to trigger every 20 ticks.


    So putting it together I would make an event handler for PlayerTickEvent, and check if the world time % 20 equals 0. If it does, then add 1 to speed or whatever you're trying to do.

    Posted in: Modification Development
  • 0

    posted a message on Add +1 to a variable every second?

    What class is your field in? Things like Entity and TileEntity already have methods that run every tick, like onLivingUpdate() or similar. So you can just do your math there.


    If your field is for something like generally for the world, then you can use the WorldTickEvent.

    Posted in: Modification Development
  • 0

    posted a message on Are there standard libraries for mod development? Specifically world gen?

    I think the structure classes have some helper functions to fill in spaces. But I think mostly rectangular, but maybe circles as well. In any case most of those would only take a simple nested loop to implement. So some exist, but probably can write your own almost as fast as finding them.

    Posted in: Modification Development
  • 0

    posted a message on Jabelar's Truly Magical Enchantment Glints
    Quote from coldplayrocks»

    The video is for your moving light source mod.


    Darn it. Okay, I edited the original post with screenshots.

    Posted in: Minecraft Mods
  • 0

    posted a message on GetGroundFromAbove

    That should work. The return value of y should be the Y for the ground block. If you want to be on top of that just add 1.


    What exactly isn't working with your code?

    Posted in: Modification Development
  • 0

    posted a message on I want to add a block with a direction.

    You made a mistake with your property initialization. In your code you have your FACING = BlockHorizontal.FACING. You can't do it like that cause you're referencing a property in a different class.


    To fix this you have two choices:

    1) Extend BlockHorizontal instead of Block class. Then you won't need your own property but will automatically get the property from BlockHorizontal.

    2) Copy the BlockHorizontal code in your class: public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

    Posted in: Modification Development
  • 0

    posted a message on Jabelar's Truly Magical Enchantment Glints

    Finally -- Colored Enchantment Glints!


    I've seen a lot of people ask for this, so I'm finally delivering! This mod allows you to individually customize the colors (and texture) of all the vanilla enchantments.


    You can also set the color used for any enchantments added by other mods, although all will get same color (in the future I hope to add the ability to allow that to be individually customized as well).


    You also have a choice between the default texture and one that has "runes" in the enchanting font (which is technically the Standard Galactic font).


    The color change should work everywhere there is enchantment glint, such as in your inventory, when they are entity items on the ground, and when you or others are equipped with them. (If you find somewhere they're not please file an issue.)

    Check Out The Screenshots





    Get It Now

    From my CurseForge page.


    If you like it please comment! Cheers!

    Posted in: Minecraft Mods
  • To post a comment, please or register a new account.