Résolu Ajout de plusieurs Fluids
-
Donc quelle seriat la solution svp
-
oui voila.
public class FluidInit(){ public FluidInit(){ registerAllFluids(); registerAllFluidBlocks(); createBuckets(); refreshReferences(); } public static void registerAllFluids(){ //public static final Fluid Beer_Fluid = new BeerInit("beer_liquid",new ResourceLocation("psychedelicraft:blocks/beer_still"), new ResourceLocation("psychedelicraft:blocks/beer_flow")); //fluidbeer_liquid = new FluidCore("coffee", References.MODID).setDensity(900).setViscosity(2000); // FluidRegistry.registerFluid(fluidbeer_liquid); } public static void createBuckets(){ // FluidRegistry.addBucketForFluid(fluidCrudeOil); } public static void refreshReferences() { //fluidCrudeOil = FluidRegistry.getFluid("crude_oil"); } }
////////////////////////////////////////////////////////////////////////////////////////////////////
Class blockInitpublic class Blockinit extends BlockFluidClassic protected String modName; protected String name; public Blockinit(Fluid fluid, Material material, String modName, String name){ super(fluid, material); this.name = name; this.modName = modName; setUnlocalizedName(modName + ".fluid." + name); displacements.put(this, false); } public Blockinit(Fluid fluid, Material material, String name) { this(fluid, material, References.MODID, name); } @Override public Boolean isEntityInsideMaterial(IBlockAccess world, BlockPos blockpos, IBlockState iblockstate, Entity entity, double yToTest, Material materialIn, boolean testingHead) { if (this.density < 0) { return false; } if (testingHead) { return true; } // if (iblockstate.getMaterial().equals(this.blockMaterial)) { // if (yToTest <= blockpos.getY() + 1 + getQuantaPercentage(world, blockpos)) { // return true; // } // } return super.isEntityInsideMaterial(world, blockpos, iblockstate, entity, yToTest, materialIn, testingHead); } @Override @SideOnly (Side.CLIENT) public void randomDisplayTick(IBlockState state, World world, BlockPos pos, Random rand) { double px = pos.getX() + rand.nextFloat(); double py = pos.getY() - 1.05D; double pz = pos.getZ() + rand.nextFloat(); if (density < 0) { py = pos.getY() + 2.10D; } if (rand.nextInt(20) == 0 && world.isSideSolid(pos.add(0, densityDir, 0), densityDir == -1 ? EnumFacing.UP : EnumFacing.DOWN) && !world.getBlockState(pos.add(0, 2 * densityDir, 0)).getMaterial().blocksMovement()) { Particle fx = new EntityDropParticleFX(world, px, py, pz, particleRed, particleGreen, particleBlue, densityDir); FMLClientHandler.instance().getClient().effectRenderer.addEffect(fx); } } @Override public boolean canCreatureSpawn(IBlockState state, IBlockAccess world, BlockPos pos, net.minecraft.entity.EntityLiving.SpawnPlacementType type) { return false; } @Override public boolean canDisplace(IBlockAccess world, BlockPos pos) { if (!shouldDisplaceFluids && world.getBlockState(pos).getMaterial().isLiquid()) { return false; } return super.canDisplace(world, pos); } @Override public boolean displaceIfPossible(World world, BlockPos pos) { if (!shouldDisplaceFluids && world.getBlockState(pos).getMaterial().isLiquid()) { return false; } return super.displaceIfPossible(world, pos); } /* ACCESSORS */ public int getDensitySafe() { return density; } public int getDensityDirSafe() { return densityDir; } public float getParticleRed() { return particleRed; } public float getParticleGreen() { return particleGreen; } public float getParticleBlue() { return particleBlue; } @Override @SideOnly (Side.CLIENT) public Vec3d getFogColor(World world, BlockPos pos, IBlockState state, Entity entity, Vec3d originalColor, float partialTicks) { return new Vec3d(getParticleRed(), getParticleGreen(), getParticleBlue()); } /* IModelRegister */ @Override @SideOnly (Side.CLIENT) public void registerModels() { Item item = Item.getItemFromBlock(this); StateMapper mapper = new StateMapper(modName, "fluid", name); // Item Model ModelBakery.registerItemVariants(item); ModelLoader.setCustomMeshDefinition(item, mapper); // Block Model ModelLoader.setCustomStateMapper(this, mapper); }
-
et pour finir cette classe la,
public class StateMapper extends StateMapperBase implements ItemMeshDefinition { public final ModelResourceLocation location; public StateMapper(String modName, String fileName, String modelName) { this.location = new ModelResourceLocation(modName + ":" + fileName, modelName); } @Override protected ModelResourceLocation getModelResourceLocation(IBlockState state) { return location; } @Override public ModelResourceLocation getModelLocation(ItemStack stack) { return location; } }
-
Tu appelle quekque par cette classe StateMapper
Sinon Merci beaucoup
-
Es ce que je pourrait voir ta class BeerFluid svp
Merci d’avance
-
https://we.tl/t-NwLPyBe10A version lite
-
Bon j’ai un peu trifouillé dans mes classes et maintenant ça MARCHE : je peut ajouter plusieurs fluids dans mon jeu !!!
sauf que maintenant j’ai ce warning dans mon Minecraft client:
A mod has attempted to assign Block Block{minecraft:air} to the Fluid 'molten_iridium' but this Fluid has already been linked to the Block Block{minecraft:air}. You may have duplicate Fluid Blocks as a result. It *may* be possible to configure your mods to avoid this. [07:22:51] [Client thread/WARN] [FML]: **************************************** [07:22:51] [Client thread/WARN] [FML]: * Registry Block: The object Block{feurimod:molten_feurium} has been registered twice for the same name feurimod:molten_feurium. [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:307) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:288) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:120) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:161) [07:22:51] [Client thread/WARN] [FML]: * at fr.luky.feurimod.utils.handlers.RegistryHandler.registerBlocks(RegistryHandler.java:29) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_RegistryHandler_registerBlocks_Register.invoke(.dynamic)... [07:22:51] [Client thread/WARN] [FML]: **************************************** [07:22:51] [Client thread/WARN] [FML]: **************************************** [07:22:51] [Client thread/WARN] [FML]: * Registry Block: The object Block{feurimod:molten_iridium} has been registered twice for the same name feurimod:molten_iridium. [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:307) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:288) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:120) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:161) [07:22:51] [Client thread/WARN] [FML]: * at fr.luky.feurimod.utils.handlers.RegistryHandler.registerBlocks(RegistryHandler.java:29) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_RegistryHandler_registerBlocks_Register.invoke(.dynamic)... [07:22:51] [Client thread/WARN] [FML]: **************************************** [07:22:51] [Client thread/WARN] [FML]: **************************************** [07:22:51] [Client thread/WARN] [FML]: * Registry Block: The object Block{feurimod:molten_tritium} has been registered twice for the same name feurimod:molten_tritium. [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:307) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.add(ForgeRegistry.java:288) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.register(ForgeRegistry.java:120) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.registries.ForgeRegistry.registerAll(ForgeRegistry.java:161) [07:22:51] [Client thread/WARN] [FML]: * at fr.luky.feurimod.utils.handlers.RegistryHandler.registerBlocks(RegistryHandler.java:29) [07:22:51] [Client thread/WARN] [FML]: * at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_RegistryHandler_registerBlocks_Register.invoke(.dynamic)... [07:22:51] [Client thread/WARN] [FML]: ****************************************
et mon Minecraft serveur crash:
---- Minecraft Crash Report ---- // You're mean. Time: 04/04/20 13:14 Description: Exception in server tick loop java.lang.NoClassDefFoundError: net/minecraft/client/renderer/ItemMeshDefinition at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at net.minecraftforge.fml.common.ProxyInjector.inject(ProxyInjector.java:85) at net.minecraftforge.fml.common.FMLModContainer.constructMod(FMLModContainer.java:613) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:219) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:197) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at com.google.common.eventbus.Subscriber.invokeSubscriberMethod(Subscriber.java:91) at com.google.common.eventbus.Subscriber$SynchronizedSubscriber.invokeSubscriberMethod(Subscriber.java:150) at com.google.common.eventbus.Subscriber$1.run(Subscriber.java:76) at com.google.common.util.concurrent.MoreExecutors$DirectExecutor.execute(MoreExecutors.java:399) at com.google.common.eventbus.Subscriber.dispatchEvent(Subscriber.java:71) at com.google.common.eventbus.Dispatcher$PerThreadQueuedDispatcher.dispatch(Dispatcher.java:116) at com.google.common.eventbus.EventBus.post(EventBus.java:217) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:136) at net.minecraftforge.fml.common.Loader.loadMods(Loader.java:595) at net.minecraftforge.fml.server.FMLServerHandler.beginServerLoading(FMLServerHandler.java:98) at net.minecraftforge.fml.common.FMLCommonHandler.onServerStart(FMLCommonHandler.java:333) at net.minecraft.server.dedicated.DedicatedServer.init(DedicatedServer.java:128) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:552) at java.lang.Thread.run(Thread.java:748) Caused by: java.lang.ClassNotFoundException: net.minecraft.client.renderer.ItemMeshDefinition at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:191) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ... 35 more Caused by: net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerException: Exception in class transformer net.minecraftforge.fml.common.asm.transformers.SideTransformer@690e7b89 from coremod FMLCorePlugin at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:260) at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:279) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:176) ... 37 more Caused by: java.lang.RuntimeException: Attempted to load class net/minecraft/client/renderer/ItemMeshDefinition for invalid side SERVER at net.minecraftforge.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:62) at net.minecraftforge.fml.common.asm.ASMTransformerWrapper$TransformerWrapper.transform(ASMTransformerWrapper.java:256) ... 39 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Mac OS X (x86_64) version 10.13.6 Java Version: 1.8.0_231, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 165931984 bytes (158 MB) / 286261248 bytes (273 MB) up to 954728448 bytes (910 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.5.2847 6 mods loaded, 6 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:----- |:--------- |:------------ |:-------------------------------- |:--------- | | LC | minecraft | 1.12.2 | minecraft.jar | None | | LC | mcp | 9.42 | minecraft.jar | None | | LC | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2847.jar | None | | LC | forge | 14.23.5.2847 | forgeSrc-1.12.2-14.23.5.2847.jar | None | | L | feurimod | Bêta 1.2 | Feurimod | None | | L | jei | 4.15.0.293 | jei_1.12.2-4.15.0.293.jar | None | Loaded coremods (and transformers): Profiler Position: N/A (disabled) Is Modded: Definitely; Server brand changed to 'fml,forge' Type: Dedicated Server (map_server.txt
Il y a quelqu’un pour m’aider svp ??
-
Les blocs de tes fluides sont enregistrés deux fois, surement car tu as appeler deux fois la fonction register.
Et le crash du serveur c’est parce que
ItemMeshDefinition
n’est que disponible sur le client et pas sur le serveur.
Visiblement tu l’utilises actuelle dans ta classe principale, il faut le déplacer vers le client proxy pour éviter ce crash. -
Pour les blocs de fluids je l’ai ai erengistré a la fois comme bloc normal et a la fois comme block fluid
EDIT: en fait ma commande registerMeshandStates etait sur le common proxy avec ma méthode de register de bloc
et le serveur se lance corectement -
hey tout le monde, je reprend ce topic car mon problème se raporte au fluids crées ci dessus :
Je voudrait changer la couleure des flammes et les dagats lorsque je rentre dans mon fluids.J’ai fait pas mal de recherche dans le code source de mc sans rien trouver…
Comment puis je faire pour modifier cecis ?
Merci d’avance, Luky -
toujour aucune réponse ???
-
Il n’y as vraiment personne pour trouver réponse à mon problème ???
-
Bonjour,
je ne m’y connais pas vraiment en mod, mais la réponse que tu cherches devrais quand même se trouver dans le code source de minecraft, tu devrais aller regarder du côté des propriétés de la lave(même si je pense que tu l’as déjà fais), si tu ne trouves pas, utilise “ctrl +f”. -
he bien le problème c’est que j’amerais récupérer l’item du sceau de mon fluid sauf que comme l’item est généré par forge, je ne sais pas comment faire
-
@ck_luky Bonjour c’est un peu tard mais je sais comment faire le seau de ton fluid, il faut créer cette classe ->
public class ModBucket extends ItemBucket { public ModBucket(String name, Block containedBlock) { super(containedBlock); setUnlocalizedName(name); setRegistryName(MODID , name); // tu fais comme avec tes autres classes d'items(au cas où tu aurais une liste d'item par exemple) } }
Ensuite là où tu init tes items :
FLUID_BUCKET = new ModBucket("fluid_bucket",FeuriModBlocks.FLUID_BLOCK).setContainerItem(Items.BUCKET);//le bucket vanilla
-
Merci beaucoup @zombibi57 na ce n’est pas du tous tard puisque le problème n’est toujours pas résolu !!!
une fois que mon item sceau est créé je fais comment pour lui faire spawn le fluid en question avec les propriétés que je veux??Merci d’avance
-
@ck_luky avec un event, le FillBucketEvent :
@SubscribeEvent public static void onBucketUsed(FillBucketEvent event) { if(event.getEmptyBucket().getItem() == ItemsMod.BUCKET_VIDE) {// créé un seau moddé vide ou utilise Items.BUCKET de minecraft World eventWorld = event.getWorld(); if(event.getTarget() == null) { return; } BlockPos hitPos = Objects.requireNonNull(event.getTarget()).getBlockPos(); if(event.getTarget().hitVec != null && eventWorld.getBlockState(hitPos) == BlocksMods.FLUID_BLOCK.getDefaultState()) { event.setFilledBucket(new ItemStack(ExaItemsMods.FLUID_BUCKET, 1)); eventWorld.setBlockToAir(hitPos); event.setResult(Event.Result.ALLOW); } } }
Comme je l’ai dit en commentaire, il te faut un seau de vide de base qui une fois rempli donne ton fluid bucket(ou tu utilise le bucket de minecraft).