.2 : energy mechanic / api / "cable"
-
Salut, alors voila mon problème :
j’essais d’enregistrer des blocks/items avec le gameregistry mais ca crzash je suppose que ce n’est plus la meme facon que l’1.10.2 ?[font=DejaVu Sans Monopublic static ]Block BLOCK_ROCK_GENERATOR = new BlockMachineRockGenerator(Material.IRON).setUnlocalizedName("block_rock_generator")%(#aaa9a7)[; ] public AdvancedProcessingBlocks() { this.registerBlocks()%(#aaa9a7)[; ]} public void registerBlocks() { GameRegistry.<Block>register(BLOCK_ROCK_GENERATOR).setRegistryName("rock_generator")%(#aaa9a7)[; ] GameRegistry.<Item>register(new ItemBlock(BLOCK_ROCK_GENERATOR), BLOCK_ROCK_GENERATOR.getRegistryName())%(#aaa9a7)[; ]}
[font=DejaVu Sans Monopublic ]AdvancedProcessingItems() { this.registerItems()%(#aaa9a7)[; ]} public static final Item ITEM_WRENCH = new ItemWrench().setUnlocalizedName("item_wrench")%(#aaa9a7)[; ] public void registerItems() { GameRegistry.register(ITEM_WRENCH).setRegistryName("wrench")%(#aaa9a7)[; ]}
net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from Advanced Processing (advancedprocessing) Caused by: java.lang.IllegalArgumentException: No registry name set for object Block{null} (net.spyman.advprocess.common.blocks.BlockMachineRockGenerator) at net.minecraftforge.fml.common.registry.GameData.register_impl(GameData.java:222) at net.minecraftforge.fml.common.registry.GameRegistry.register(GameRegistry.java:155) at net.spyman.advprocess.common.blocks.AdvancedProcessingBlocks.registerBlocks(AdvancedProcessingBlocks.java:21) at net.spyman.advprocess.common.blocks.AdvancedProcessingBlocks.<init>(AdvancedProcessingBlocks.java:16) at net.spyman.advprocess.common.AdvancedProcessing.preInit(AdvancedProcessing.java:34) 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 net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:643) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:246) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:224) 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.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:147) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:268) at net.minecraft.client.Minecraft.init(Minecraft.java:478) at net.minecraft.client.Minecraft.run(Minecraft.java:387) at net.minecraft.client.main.Main.main(Main.java:118) 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 net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) 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 net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) 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.intellij.rt.execution.application.AppMain.main(AppMain.java:147) ```</init>
-
Ton setRegistryName est mal placé. Il faut faire comme ça :
GameRegistry.<block>register(BLOCK_ROCK_GENERATOR.setRegistryName("rock_generator"));
Ou alors comme ça :
public static Block BLOCK_ROCK_GENERATOR = new BlockMachineRockGenerator(Material.IRON).setUnlocalizedName("block_rock_generator").setRegistryName("rock_generator"); ```</block>
-
Merci maintenant ça fonctionne et aussi je souhaiterais savoir comme faire un block orientable ?
-
Regardes la citrouille.
Le principe est le même qu’en 1.7.10, sauf que maintenant tout passe par les blockstates. -
J’ai fait comme le four mais bon il s’oriente pas trop
{
“parent”: “block/orientable”,
“textures”:
{
“top”: “modid:blocks/stone_mill_top”,
“bottom”: “modid:blocks/stone_machine_bottom”,
“front”: “modid:blocks/stone_mill_front”,
“side”: “modid:blocks/stone_mill_side”
}
}et aussi comme je peut specifie la texture du dessous car le “bottom ne fonctionne pas”
-
Jsp pas pourquoi mais il cherche la variante “normal” et si je la met bah y aura pas de block orientable
{ "variants": { "facing=north": { "model": "modid:stone_mill" }, "facing=south": { "model": "modid:stone_mill", "y": 180 }, "facing=west": { "model": "modid:stone_mill", "y": 270 }, "facing=east": { "model": "modid:stone_mill", "y": 90 } } }
et puis si je la met pas il rend pas le block
block model
{ "parent": "block/orientable", "textures": { "top": "modid:blocks/stone_mill_top", "bottom": "modid:blocks/stone_machine_bottom", "front": "modid:blocks/stone_mill_front", "side": "modid:blocks/stone_mill_side" } }
-
Montres la classe de ton block.
-
bon par contre elle est un peut vide
import net.minecraft.block.material.Material; public class BlockMachineStoneMill extends BlockStoneMachine { public BlockMachineStoneMill() { } }
-
Dans ce cas, c’est normal : qand un block n’a pas de blockState, minecraft prend la valeur “normal”. Si tu veux que ton block soit orientable, il faut que tu joue avec les BlockStates dans la class de ton block. Il y as quelques tutos qui peuvent t’aider :
-
Il y a aussi la classe de la pumpkin qui pourrait t’aider (ou de n’importe quel block orientable )
-
J’ai essayé de faire quelques petits testes mais j’y arrive pas en aillant jeté un coup d’œil dans la class de la pumpkin et du four
-
Envoies ton code actuel.
-
package net.spyman.advprocess.common.blocks; import net.minecraft.block.BlockHorizontal; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; public class BlockMachineStoneMill extends BlockStoneMachine { public static final PropertyDirection FACING = BlockHorizontal.FACING; public BlockMachineStoneMill() { this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH)); } private void setDefaultFacing(World worldIn, BlockPos pos, IBlockState state) { if (!worldIn.isRemote) { IBlockState iblockstate = worldIn.getBlockState(pos.north()); IBlockState iblockstate1 = worldIn.getBlockState(pos.south()); IBlockState iblockstate2 = worldIn.getBlockState(pos.west()); IBlockState iblockstate3 = worldIn.getBlockState(pos.east()); EnumFacing enumfacing = (EnumFacing)state.getValue(FACING); if (enumfacing == EnumFacing.NORTH && iblockstate.isFullBlock() && !iblockstate1.isFullBlock()) { enumfacing = EnumFacing.SOUTH; } else if (enumfacing == EnumFacing.SOUTH && iblockstate1.isFullBlock() && !iblockstate.isFullBlock()) { enumfacing = EnumFacing.NORTH; } else if (enumfacing == EnumFacing.WEST && iblockstate2.isFullBlock() && !iblockstate3.isFullBlock()) { enumfacing = EnumFacing.EAST; } else if (enumfacing == EnumFacing.EAST && iblockstate3.isFullBlock() && !iblockstate2.isFullBlock()) { enumfacing = EnumFacing.WEST; } worldIn.setBlockState(pos, state.withProperty(FACING, enumfacing), 2); } } }
-
ya pas juste une petite solution ??
-
Il te manque ces fonctions :
public IBlockState withRotation(IBlockState state, Rotation rot) { return state.withProperty(FACING, rot.rotate((EnumFacing)state.getValue(FACING))); } /** * Returns the blockstate with the given mirror of the passed blockstate. If inapplicable, returns the passed * blockstate. */ public IBlockState withMirror(IBlockState state, Mirror mirrorIn) { return state.withRotation(mirrorIn.toRotation((EnumFacing)state.getValue(FACING))); } /** * Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the * IBlockstate */ public IBlockState getStateForPlacement(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite()); } /** * Convert the given metadata into a BlockState for this Block */ public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(meta)); } /** * Convert the BlockState into the correct metadata value */ public int getMetaFromState(IBlockState state) { return ((EnumFacing)state.getValue(FACING)).getHorizontalIndex(); } protected BlockStateContainer createBlockState() { return new BlockStateContainer(this, new IProperty[] {FACING}); }
-
Ok merci je savais pas quil fallait toutes ces fonctions et aussi quand on casse le block il y a des particles sauf que je les ai sur l’un de mes blocks mais pas sur lautre, sur lautre cest le rose/noir de la texture buggé
y a t-il un moyen de changer cela ? -
Regardes dans le fichier json, normalement il faut ajouter un truc du genre “particle”:“la texture”.
-
C’est un peu particulier pour les blocs en 1.10+
Il faut désormais un ItemBlock, voilà quelques bouts de codes que j’utilise
Ceci dans le constructeur d’un block “mère” en gros ta classe mère pour tout tes blocs
setBlockName(this, unlocalizedName); final ItemBlock itemBlock = new ItemBlock(this); itemBlock.setRegistryName(this.getRegistryName()); GameRegistry.register(this); GameRegistry.register(itemBlock);
Et pour la fonction setBlockName()
public static void setBlockName(Block blockIn, String unlocalizedName) { blockIn.setRegistryName("tonModID", unlocalizedName); blockIn.setUnlocalizedName(unlocalizedName); }
Ensuite tu déclare tes blocs de la plus simple des manières:
public static final Block testBlock= new BlockTest("nom_Unlocalized");
Et voilà tu enregistre les rendu pour les .json avec normalement:
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register();
Et paf tu as de beaux chocapics avec le nouveau système de registry() de forge
-
Ok merci jai mes paticles maintenant
et aussi quelqun sait-t-il comment creer des “cable” ? car moi j’en n’ai absolument aucunes idées -
Même pas une petite idée ?