Jump to content

[SOLVED][1.11.2] Making a Double Plant (2 Block High Flower)


ModMCdl

Recommended Posts

So, I'm trying to implement a flower block that is a Double Plant, and after taking a look at the double plant class to try and figure out how this is done, it's left me with my head spinning. I'm usually able to reverse-engineer classes, but with the amount of variants that are used, I just can't figure out where the specific things I need are implemented. The latest info I can find is for 1.7.10 and I have verified that it doesn't translate over well.

 

Would anyone be willing to help simplify the process of going about this?

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Well the BlockDoublePlant has a property HALF that tells you if the block represents the UPPER or LOWER block of the 2 block group.  This property is stored in the blockstate.  So when you do a IBlockState state= world.getBlockState(BlockPos);  you can get the  value by  state.getValue(BlockDoublePlant.HALF);

 

The BlockDoublePlant then traps events such as getItemDropped, etc to determine which blockstate is present (UPPER or LOWER) and do appropriate action. i.e. upper should turn to air if the bottom block is destroyed/harvested

 

If you create a new class MyBlockDoublePlant and copy all the code over from BlockDoublePlant (extending BlockBush, implements IGrowable, net.minecraftforge.common.IShearable) then get rid of the variants you don't want, create your own EnumPlantTypes and tweak as needed. Should get you were you want to be. The json file for the blockstate would be similar to the double_rose.json, double_fern.json, etc taking note of the variants 'half=lower', 'half=upper'.

 

In your modblocks, create each variant appropriately with the MyBlockDoublePlant (or whatever you call the class).

 

You would also have to deal with generation in the biomes that you want, but that is next step if you were wanting auto generating plant.

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, aw_wolfe said:

If you create a new class MyBlockDoublePlant and copy all the code over from BlockDoublePlant (extending BlockBush, implements IGrowable, net.minecraftforge.common.IShearable) then get rid of the variants you don't want, create your own EnumPlantTypes and tweak as needed. Should get you were you want to be. The json file for the blockstate would be similar to the double_rose.json, double_fern.json, etc taking note of the variants 'half=lower', 'half=upper'.

 

Would it also be possible to get all of these variables directly from BlockDoublePlant and just reference them in my own mod? Or would I actually need to implement everything in the individual class for my own double plant?

ie. 

public class BlockAplant extends BlockDoublePlant

 

Edited by ModMCdl
  • Like 1

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

You can absolutely use the IProperties already defined in another class. In fact, it increases inter-mod compatibility!  As any mod that looks at a block and wants to fiddle around with the HALF property only needs to know about the vanilla HALF property and it can fiddle with your plant the same way it fiddles with a vanilla plant.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

54 minutes ago, Draco18s said:

You can absolutely use the IProperties already defined in another class. In fact, it increases inter-mod compatibility!  As any mod that looks at a block and wants to fiddle around with the HALF property only needs to know about the vanilla HALF property and it can fiddle with your plant the same way it fiddles with a vanilla plant.

Alright. So, please, bear with me for a minute here...

I've made my class extend BlockDoublePlant, and everything seems to be working fine. I've got everything working except for the actual model itself. I've 99% verified that it isn't a problem in my .json files, so I must be missing something to override in the class itself, I'm thinking something along the lines of the variants. 

 

BlockClass.java

Blockstates.json

 

Let me know if you need something else.

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

{ "model": "asphodelplant_bottom" }

 

Unable to load model asphodelplant_bottom in domain minecraft.

 

You're missing your mod ID.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

{ "model": "asphodelplant_bottom" }

 

Unable to load model asphodelplant_bottom in domain minecraft.

 

You're missing your mod ID.

Oh. I did fix that and it still isn't working. I didn't realize that I uploaded the errored .json. (Updated to fix).

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Yes, I have those. I've been digging around for a while in between editing and adding other parts of the code. I've verified that the .json are set up correctly. Everything is working except the model render. Originally, it was because I was calling on BlockDoubleClass and not defining what variant (sunflower, fern, etc). my new plant was. So. I've gone as far as to recreate my own DoubleBlock class named BlockTwoPlant, and calling upon that instead, only defining one variant (my plant), but for some reason, its still registering the variant I added as undefined. Source below:

 

BlockTwoPlant.java (My version of BlockDoublePlant, almost c+p)

BlockAsphodelPlant.java (My 2-high plant)

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Can you explain what exactly isn't working? 

1) plants not showing up in creativeTabs for you to place during creative?

2) plants not being created during biome creation?

3) plants showing up in creativeTabs, but without proper texture? pink/black squares?

etc...

 

  • Like 1
Link to comment
Share on other sites

2 hours ago, aw_wolfe said:

Can you explain what exactly isn't working? 

That's the problem, everything is working, the .json, the class file, but in the console, its trying to implement variants that are (to the best of my, and my comrades' knowledge), defined. 

 

I ended up writing my own class to handle a two-high plant (see BlockTwoPlant.java) above, and that runs fine, but for some reason, Minecraft/Forge are trying to call upon variants that I didn't implement.

 

The Error:

Spoiler

[21:05:55] [Client thread/ERROR] [FML]: Exception loading model for variant modmt:blockasphodelplant#facing=north,half=upper,variant=asphodelplant for blockstate "modmt:blockasphodelplant[facing=north,half=upper,variant=asphodelplant]"
net.minecraftforge.client.model.ModelLoaderRegistry$LoaderException: Exception loading model modmt:blockasphodelplant#facing=north,half=upper,variant=asphodelplant with loader VariantLoader.INSTANCE, skipping
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:153) ~[ModelLoaderRegistry.class:?]
    at net.minecraftforge.client.model.ModelLoader.registerVariant(ModelLoader.java:264) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelBakery.loadBlock(ModelBakery.java:153) ~[ModelBakery.class:?]
    at net.minecraftforge.client.model.ModelLoader.loadBlocks(ModelLoader.java:252) ~[ModelLoader.class:?]
    at net.minecraftforge.client.model.ModelLoader.setupModelRegistry(ModelLoader.java:159) ~[ModelLoader.class:?]
    at net.minecraft.client.renderer.block.model.ModelManager.onResourceManagerReload(ModelManager.java:28) [ModelManager.class:?]
    at net.minecraft.client.resources.SimpleReloadableResourceManager.registerReloadListener(SimpleReloadableResourceManager.java:122) [SimpleReloadableResourceManager.class:?]
    at net.minecraft.client.Minecraft.init(Minecraft.java:541) [Minecraft.class:?]
    at net.minecraft.client.Minecraft.run(Minecraft.java:387) [Minecraft.class:?]
    at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
    at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_131]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_131]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_131]
    at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
    at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: net.minecraft.client.renderer.block.model.ModelBlockDefinition$MissingVariantException
    at net.minecraft.client.renderer.block.model.ModelBlockDefinition.getVariant(ModelBlockDefinition.java:78) ~[ModelBlockDefinition.class:?]
    at net.minecraftforge.client.model.ModelLoader$VariantLoader.loadModel(ModelLoader.java:1257) ~[ModelLoader$VariantLoader.class:?]
    at net.minecraftforge.client.model.ModelLoaderRegistry.getModel(ModelLoaderRegistry.java:149) ~[ModelLoaderRegistry.class:?]
    ... 21 more
[21:05:55] [Client thread/FA

 

Edited by ModMCdl
Posted wrong error message

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Your block has 3 properties:

Horizontal Facing (4 values)

HALF (2 values)

PlantType (1 value)

All of this is encodable in 4 bits (you have 8 possible variations: 4 * 2 * 1)

 

Looking at your getMetaFromState method, if the top half of the block is set, the metadata is (8 + Facing). Otherwise it's (plant type).

However if we look at your getStateFromMeta method, we check if the metadata is >= 8, if it is, set HALF to true. Otherwise we decompose the other three bits into a Plant Type.

 

These two methods are not inverse of each other. Your getStateFromMeta discards the FACING property entirely.

 

THEN, ON TOP OF THAT, your json file ignores both the plant type and facing value:

{
    "variants": {
        "half=lower": { "model": "modmt:block/asphodelplant_bottom" },
        "half=upper":    { "model": "modmt:block/asphodelplant_top" }
    }
}

Those are not your only two variants! What about "facing=north,half=upper,variant=asphodelplant"?

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 minute ago, Draco18s said:

Those are not your only two variants! What about "facing=north,half=upper,variant=asphodelplant"?

Considering that the .json and the BlockTwoPlant.class were most stripped from the minecraft source, and neither included all of the variants, I didn't think they were necessary. 

 

Note: I did try implementing everything the console spat out at one point, but it didn't help, could you possible just example one for me? .json is still relatively new to me. I had just listed all of the respected variants that were listed but it didn't help.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

6 minutes ago, ModMCdl said:

Considering that the .json and the BlockTwoPlant.class were most stripped from the minecraft source, and neither included all of the variants, I didn't think they were necessary. 

Vanilla might (and probably does) use a custom IStateMapper object to strip some properties from needing to be present in the json file.

"It throws an error" is a far cry from "its not needed." If it throws an error either its needed or you did something wrong.

Quote

Note: I did try implementing everything the console spat out at one point, but it didn't help, could you possible just example one for me? .json is still relatively new to me. I had just listed all of the respected variants that were listed but it didn't help.

Take a look at

http://mcforge.readthedocs.io/en/latest/blockstates/forgeBlockstates/#forges-blockstates

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

5 minutes ago, Draco18s said:

Take a look at

Oh, that's a nifty little page there... thanks! You, draco, are a lifesaver.

 

 

2017-10-06_21.39.20.png

  • Like 2

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Alright, so now, I've gotten the models to work. But, I've encountered yet another problem: my flower now longer drops itself (when destroyed or clicked with bonemeal).

 

It was working earlier, and I do not know what I changed to make it not work.

 

BlockTwoPlant.java (my doubleblock class)

BlockAsphodelPlant.java (my flower)

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

return blockasphodelplant$enumplanttype == BlockTwoPlant.EnumPlantType.ASPHODELPLANT ? Items.AIR

"If the current block's plant type is Asphodel, then return air."

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

45 minutes ago, Draco18s said:

return blockasphodelplant$enumplanttype == BlockTwoPlant.EnumPlantType.ASPHODELPLANT ? Items.AIR

"If the current block's plant type is Asphodel, then return air."

Lol, jeez. Alright. I didn't realize that. Thanks.

 

However, that doesn't fix the bonemeal issue.

Edited by ModMCdl

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

what are you looking for the bonemeal to do?  If you want growing plants, your have to incorporate an age property.

Your cangrow..

 

 return blockasphodelplant$enumplanttype != BlockTwoPlant.EnumPlantType.ASPHODELPLANT && blockasphodelplant$enumplanttype != BlockTwoPlant.EnumPlantType.ASPHODELPLANT;

 

looks like it would always return false if plant type is ASPHODELPLANT, which in your case it would be, so cangrow always returns false, so grow is never called.

 

I haven't had my coffee yet, but that's how I'm reading it.

  • Like 1
Link to comment
Share on other sites

4 hours ago, aw_wolfe said:

what are you looking for the bonemeal to do?

I just want it to act like a normal DoublePlant, and drop itself when bonemeal is used. It was working properly before, and I cannot figure out what I did to mess it up.

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

4 hours ago, aw_wolfe said:

looks like it would always return false if plant type is ASPHODELPLANT, which in your case it would be, so cangrow always returns false, so grow is never called.

This was it. By removing that line and setting return true;it now works. Thanks!

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

On 10/8/2017 at 1:35 AM, ModMCdl said:

This was it. By removing that line and setting return true;it now works. Thanks!

Also as a suggestion, kindly please edit your first post to change the title so you can have a some sort of mark that this has been solved, like (SOLVED) or [SOLVED] so people have this same problem can tell if this is solved THANKS! ;)

Link to comment
Share on other sites

1 hour ago, TheRPGAdventurer said:

kindly please edit your first post to change the title so you can have a some sort of mark that this has been solved, like (SOLVED) or [SOLVED]

Done ^_^

Follow these rules when talking to me, and we'll get along fine.

1).I know Java fairly well. I don't know as much about modding. They are not the same, don't compare them.

2). I consider myself to always be learning. I make mistakes, you make mistakes. Who doesn't?

3). Insult me, and I will leave the thread. I have a real life, I don't have time to throw petty insults in a Minecraft Modding forum.

 

ModMCdl - Co-Founder and Director of Design for Artemis Game Studios

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • They were already updated, and just to double check I even did a cleanup and fresh update from that same page. I'm quite sure drivers are not the problem here. 
    • i tried downloading the drivers but it says no AMD graphics hardware has been detected    
    • Update your AMD/ATI drivers - get the drivers from their website - do not update via system  
    • As the title says i keep on crashing on forge 1.20.1 even without any mods downloaded, i have the latest drivers (nvidia) and vanilla minecraft works perfectly fine for me logs: https://pastebin.com/5UR01yG9
    • Hello everyone, I'm making this post to seek help for my modded block, It's a special block called FrozenBlock supposed to take the place of an old block, then after a set amount of ticks, it's supposed to revert its Block State, Entity, data... to the old block like this :  The problem I have is that the system breaks when handling multi blocks (I tried some fix but none of them worked) :  The bug I have identified is that the function "setOldBlockFields" in the item's "setFrozenBlock" function gets called once for the 1st block of multiblock getting frozen (as it should), but gets called a second time BEFORE creating the first FrozenBlock with the data of the 1st block, hence giving the same data to the two FrozenBlock :   Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=head] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@73681674 BlockEntityData : id:"minecraft:bed",x:3,y:-60,z:-6} Old Block Fields set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=3, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} Frozen Block Entity set BlockState : Block{minecraft:black_bed}[facing=east,occupied=false,part=foot] BlockPos{x=2, y=-60, z=-6} BlockEntity : net.minecraft.world.level.block.entity.BedBlockEntity@6d1aa3da BlockEntityData : {id:"minecraft:bed",x:2,y:-60,z:-6} here is the code inside my custom "freeze" item :    @Override     public @NotNull InteractionResult useOn(@NotNull UseOnContext pContext) {         if (!pContext.getLevel().isClientSide() && pContext.getHand() == InteractionHand.MAIN_HAND) {             BlockPos blockPos = pContext.getClickedPos();             BlockPos secondBlockPos = getMultiblockPos(blockPos, pContext.getLevel().getBlockState(blockPos));             if (secondBlockPos != null) {                 createFrozenBlock(pContext, secondBlockPos);             }             createFrozenBlock(pContext, blockPos);             return InteractionResult.SUCCESS;         }         return super.useOn(pContext);     }     public static void createFrozenBlock(UseOnContext pContext, BlockPos blockPos) {         BlockState oldState = pContext.getLevel().getBlockState(blockPos);         BlockEntity oldBlockEntity = oldState.hasBlockEntity() ? pContext.getLevel().getBlockEntity(blockPos) : null;         CompoundTag oldBlockEntityData = oldState.hasBlockEntity() ? oldBlockEntity.serializeNBT() : null;         if (oldBlockEntity != null) {             pContext.getLevel().removeBlockEntity(blockPos);         }         BlockState FrozenBlock = setFrozenBlock(oldState, oldBlockEntity, oldBlockEntityData);         pContext.getLevel().setBlockAndUpdate(blockPos, FrozenBlock);     }     public static BlockState setFrozenBlock(BlockState blockState, @Nullable BlockEntity blockEntity, @Nullable CompoundTag blockEntityData) {         BlockState FrozenBlock = BlockRegister.FROZEN_BLOCK.get().defaultBlockState();         ((FrozenBlock) FrozenBlock.getBlock()).setOldBlockFields(blockState, blockEntity, blockEntityData);         return FrozenBlock;     }  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.