Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.16.4]DataPack, Object.class, RegisterObject, Custom Fluid, How to?


Cratthorax
 Share

Recommended Posts

Good evening,

a bit more progress and inherited info. I finally managed to understand why I couldn't perfectly connect my registry's to the object.class. You guys were right all the way. It was all about basic understanding of Java, and to correctly use fields, constants, properties etc. It's just one of 6 code languages I'm script kiddying, so bare with me.

It also made sense to understand, that my Fluid.class(not FluidBlock.class) was, from its logic, actually a "register".class just as my main register .class, and I could basically just have used all my fluid.class code inside the general registry as well. So it seems important you also give perfect label/naming/package structure to your mod, though I know from scripting with Papyrus, it isn't the worst thing to multithread.

However, the FluidRegistry.class has the FluidBlock.class registered like that now:

 
	    public static final RegistryObject<BlockCrudeOil> OIL_BLOCK = MatLibRegister.BLOCKS.register("crudeoil",
            () -> new BlockCrudeOil(null, AbstractBlock.Properties.create(MatLibFluidOil.MATOIL)
                    .doesNotBlockMovement().hardnessAndResistance(100f).noDrops()));    
	    /*public static final RegistryObject<FlowingFluidBlock> OIL_BLOCK = MatLibRegister.BLOCKS.register("crudeoil",
            () -> new FlowingFluidBlock(() -> MatLibFluidOil.OIL_FLUID.get(), AbstractBlock.Properties.create(MATOIL)
                    .doesNotBlockMovement().hardnessAndResistance(100f).noDrops()));*/

 

And this is the actual FluidBLock.class:

 
	package com.mofakin.matlib.common.block;
	import com.mofakin.matlib.common.fluid.MatLibFluidOil;
	import net.minecraft.block.BlockState;
import net.minecraft.block.FlowingFluidBlock;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.fluid.FlowingFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.FluidState;
import net.minecraft.util.Direction;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.IBlockReader;
	public class BlockCrudeOil extends FlowingFluidBlock {
	    public BlockCrudeOil(Object object, Properties props) {
        super(() -> (FlowingFluid) MatLibFluidOil.OIL_FLUID.get(), props);
    }
	    /*@Override
    public void entityInside(BlockState state, World worldIn, BlockPos pos, Entity entity) {
        if (entity instanceof LivingEntity && entity.tickCount % 10 == 0) {
            entity.hurt(DamageSourcePneumaticCraft.ETCHING_ACID, 1);
        }
    }*/
    
    @Override
    public boolean canHarvestBlock(BlockState state, IBlockReader world, BlockPos pos, PlayerEntity player)
    {
        return false;
    }
    
    @Override
    public int getFlammability(BlockState state, IBlockReader world, BlockPos pos, Direction face)
    {
        return 300;
    }
    
    @Override
    public boolean isFlammable(BlockState state, IBlockReader world, BlockPos pos, Direction face)
    {
        return true;
    }
    
    public int getFireSpreadSpeed(BlockState state, IBlockReader world, BlockPos pos, Direction face)
    {
        return 100;
    }
    
    public boolean canDisplace(FluidState fluidState, IBlockReader blockReader, BlockPos pos, Fluid fluid, Direction direction) {
        return false;
    }    
    
}

 

As you can see I forwarded the "catching" fire, burning, displacing, and "non harvestable" logic as well. Though I had to trace some of the methods back to 

package net.minecraftforge.common.extensions.IForgeBlock;

I changed the thread title as well, because I'm sure I'm not the last to search for this very delicate subject, of building custom fluids for worldGen.

 

Edited by Cratthorax
Link to comment
Share on other sites

1 hour ago, Cratthorax said:
RegistryObject<BlockCrudeOil>

This, by the way, doesn't need to be strictly typed to your class. You could just use RegistryObject<Block>

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

50 minutes ago, Draco18s said:

This, by the way, doesn't need to be strictly typed to your class. You could just use RegistryObject<Block>

That's interesting you say that. So basically the RegistryObject can be whatever it wants, but the new BlockCrudeOil is the one addressing the object.class?

This might be very well the reason why I can't get my custom oil tags working. I'd still have to "hack" the minecraft.water tag in order to give proper physics etc. to my custom fluid.

I've found some leftover traces from you, over here. But it wasn't a priority on my list, so after some struggle and fail I just moved on to more important topics. I shall test this tag thingy again with my newly gained kiddy skills...:)

Edited by Cratthorax
Link to comment
Share on other sites

3 hours ago, Cratthorax said:

So basically the RegistryObject can be whatever it wants

Well, no. You need to be able to cast the thing you want to register (in this case, a block). You can't make a RegistryObject<Item> store a new Block() for instance.

3 hours ago, Cratthorax said:

but the new BlockCrudeOil is the one addressing the object.class?

That's precisely what the new  keyword does.

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

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
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.

 Share



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • For now I have set it to null, but you can help -  public static final RegistryObject<ModSpawnEggItem> SKELETON_SPAWN_EGG = ITEMS.register("skeleton_spawn_egg", () -> new ModSpawnEggItem(null , 0x00FFA8, 0x326D59, new Item.Properties().tab(CreativeModeTab.TAB_MATERIALS)));  
    • Hello I've wanted to see if new forge is working for me and it doesn't.  I am getting error: This is happen when i tried to run it on Java Dev Kit 16/17: "[E] WARNING: Unknown module: cpw.mods.securejarhandler specified to --add-exports [E] Exception in thread "main" java.lang.module.FindException: Module org.objectweb.asm.commons not found, required by org.openjdk.nashorn [E]     at java.base/java.lang.module.Resolver.findFail(Resolver.java:893) [E]     at java.base/java.lang.module.Resolver.resolve(Resolver.java:192) [E]     at java.base/java.lang.module.Resolver.resolve(Resolver.java:141) [E]     at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:492) [E]     at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:298) [E]     at cpw.mods.bootstraplauncher.BootstrapLauncher.main(BootstrapLauncher.java:83) [E] " When i try to lunch it on Java runtime 7/8: "[E] Error: Could not create the Java Virtual Machine. [E] Error: A fatal exception has occurred. Program will exit. [E] Unrecognized option: -p [E]" I've tried to reinstall multiple java versions, re-downloading minecraft, changing lunching arguments, multiple forge versions for that minecraft version. Nothing works. Can someone point me what i could do make it work?   Thanks for help in advance. 
    • show the complete RegistryObject, you tried to create
    • Luis_ST Can you please show me an example I am trying to create a ForgeSpawnEggItem in my ModSpawnEgg class, but it keeps on saying the same error as shown above 
    • Time: 12/3/21 11:33 PM Description: Ticking entity java.lang.BootstrapMethodError: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/apache/logging/log4j/util/MessageSupplier"     at net.minecraftforge.eventbus.EventBus.handleException(EventBus.java:316) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:307) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}     at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:597) ~[?:?] {re:mixin,re:classloading}     at net.minecraftforge.event.ForgeEventFactory.gatherCapabilities(ForgeEventFactory.java:591) ~[?:?] {re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.doGatherCapabilities(CapabilityProvider.java:83) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.getCapabilities(CapabilityProvider.java:91) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraftforge.common.capabilities.CapabilityProvider.areCapsCompatible(CapabilityProvider.java:103) ~[?:?] {re:computing_frames,re:mixin,re:classloading}     at net.minecraft.item.ItemStack.func_77959_d(ItemStack.java:387) ~[?:?] {re:mixin,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,pl:mixin:APP:performant.mixins.json:item.ItemStackMixin,pl:mixin:APP:itemfilters-common.mixins.json:ItemStackMixin,pl:mixin:APP:epicfight.mixins.json:MixinItemStack,pl:mixin:A}     at net.minecraft.item.ItemStack.func_77989_b(ItemStack.java:375) ~[?:?] {re:mixin,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,re:classloading,xf:fml:forge:filled_map.4,xf:fml:forge:itemstack,pl:mixin:APP:performant.mixins.json:item.ItemStackMixin,pl:mixin:APP:itemfilters-common.mixins.json:ItemStackMixin,pl:mixin:APP:epicfight.mixins.json:MixinItemStack,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_241354_r_(LivingEntity.java:2267) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_241353_q_(LivingEntity.java:2239) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.LivingEntity.func_70071_h_(LivingEntity.java:2141) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:entity.LivingEntityMixin,pl:mixin:APP:citadel.mixins.json:LivingEntityMixin,pl:mixin:APP:environmental.mixins.json:LivingEntityMixin,pl:mixin:APP:allurement.mixins.json:LivingEntityAccessor,pl:mixin:APP:allurement.mixins.json:LivingEntityMixin,pl:mixin:APP:ars_nouveau.mixins.json:ExpInvokerMixin,pl:mixin:APP:ars_nouveau.mixins.json:MixinLivingEntity,pl:mixin:APP:personality.mixins.json:LivingEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorLivingEntity,pl:mixin:A}     at net.minecraft.entity.MobEntity.func_70071_h_(MobEntity.java:431) ~[?:?] {re:mixin,pl:accesstransformer:B,xf:OptiFine:default,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:APP:environmental.mixins.json:MobEntityMixin,pl:mixin:APP:assets/botania/botania.mixins.json:AccessorMobEntity,pl:mixin:APP:performant.mixins.json:entity.MobEntityDespawnMixin,pl:mixin:APP:performant.mixins.json:entity.MobEntityMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld.func_217479_a(ServerWorld.java:611) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:world.ServerWorldBlockUpdateMixin,pl:mixin:APP:abnormals_core.mixins.json:ServerWorldMixin,pl:mixin:APP:performant.mixins.json:world.ServerWorldMixin,pl:mixin:APP:performant.mixins.json:entity.MobServerWorldMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld$$Lambda$16565/514282080.accept(Unknown Source) ~[?:?] {}     at net.minecraft.world.World.func_217390_a(World.java:554) ~[?:?] {re:computing_frames,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,re:mixin,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,re:classloading,pl:accesstransformer:B,xf:fml:observerlib:coremodmethod,pl:mixin:APP:sereneseasons.mixins.json:MixinWorld,pl:mixin:APP:flywheel.mixins.json:TileWorldHookMixin,pl:mixin:A}     at net.minecraft.world.server.ServerWorld.func_72835_b(ServerWorld.java:404) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:performant.mixins.json:world.ServerWorldBlockUpdateMixin,pl:mixin:APP:abnormals_core.mixins.json:ServerWorldMixin,pl:mixin:APP:performant.mixins.json:world.ServerWorldMixin,pl:mixin:APP:performant.mixins.json:entity.MobServerWorldMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:851) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:787) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:118) ~[?:?] {re:mixin,xf:OptiFine:default,re:classloading,xf:OptiFine:default,pl:mixin:APP:smoothboot.mixins.json:client.IntegratedServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:642) [?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) [?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:structure_gel.mixins.json:MinecraftServerMixin,pl:mixin:APP:byg.mixins.json:server.MixinMinecraftServer,pl:mixin:APP:marg.mixins.json:MinecraftServerMixin,pl:mixin:A}     at net.minecraft.server.MinecraftServer$$Lambda$15673/85323444.run(Unknown Source) [?:?] {}     at java.lang.Thread.run(Thread.java:745) [?:1.8.0_51] {} Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of sun/misc/Launcher$AppClassLoader) previously initiated loading for a different type with name "org/apache/logging/log4j/util/MessageSupplier"     at java.lang.ClassLoader.defineClass1(Native Method) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.defineClass(ClassLoader.java:760) ~[?:1.8.0_51] {}     at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.defineClass(URLClassLoader.java:467) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.access$100(URLClassLoader.java:73) ~[?:1.8.0_51] {}     at java.net.URLClassLoader$1.run(URLClassLoader.java:368) ~[?:1.8.0_51] {}     at java.net.URLClassLoader$1.run(URLClassLoader.java:362) ~[?:1.8.0_51] {}     at java.security.AccessController.doPrivileged(Native Method) ~[?:1.8.0_51] {}     at java.net.URLClassLoader.findClass(URLClassLoader.java:361) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[?:1.8.0_51] {}     at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[?:1.8.0_51] {}     at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[?:1.8.0_51] {}     ... 25 more for full report https://pastebin.com/Did3vHvR    
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.