Résolu Demie-dalle
-
Bonjour à tous aujourd’hui un problème récurrent,
Voilà ça fait maintenant quelques jours que j’essaye désespérément de créer des foutues demie-dalles sans réussir quoi que ce soit, j’ai suivie le tutoriel de Robin ici :
http://www.minecraftforgefrance.fr/showthread.php?tid=156
Et même suivie le GitHub de la 1.7 et essayer de comprendre pour réadapter en 1.8 mais rien ne fonctionne, j’ai quand même essayé plusieurs fois et je vous donne donc la dernière version de mon code :
public static BaseSlab emoSlab; public static BaseSlab emoDoubleSlab;
emoSlab = new BaseSlab(false, Material.wood); emoDoubleSlab = new BaseSlab(true, Material.wood); GameRegistry.registerBlock(emoSlab, "EmoSlab"); GameRegistry.registerBlock(emoDoubleSlab, "EmoDoubleSlab");
- La classe “BaseSlab” -
package mods.emotion.blocks.base; import mods.emotion.blocks.enumprop.EnumTree; import net.minecraft.block.BlockSlab; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyEnum; import net.minecraft.item.ItemStack; public class BaseSlab extends BlockSlab { public static final PropertyEnum VARIANT = PropertyEnum.create("variant", EnumTree.class); public static final String[] SlabTypes = new String[] {"cherry", "pear", "orange", "atlas", "pine", "coco"}; private boolean isDouble; public BaseSlab(boolean par1, Material materialIn) { super(materialIn); isDouble = par1; } @Override public String getUnlocalizedName(int meta) { if(meta < 0 || meta >= SlabTypes.length) { meta = 0; } return super.getUnlocalizedName() + "." + SlabTypes[meta]; } @Override public boolean isDouble() { return isDouble; } @Override public IProperty getVariantProperty() { return VARIANT; } @Override public Object getVariant(ItemStack stack) { return EnumTree.getStateFromMeta(stack.getMetadata() & 7); } }
- Client Proxy -
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(EmotionBlocks.emoSlab), 0, new ModelResourceLocation(Infos.MODID + ":emoSlab", "inventory")); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(EmotionBlocks.emoDoubleSlab), 0, new ModelResourceLocation(Infos.MODID + ":emoDoubleSlab", "inventory"));
Donc ça c’est pour les blocs, passons maintenant à l’item :
public static Item emoItemSlab = new BaseItemSlab(EmotionBlocks.emoSlab);
GameRegistry.registerItem(emoItemSlab, "EmoItemSlab");
- La classe “BaseItemSlab” -
package mods.emotion.items.base; import mods.emotion.blocks.EmotionBlocks; import mods.emotion.blocks.base.BaseSlab; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class BaseItemSlab extends ItemBlock { private final BaseSlab singleSlab; private final BaseSlab doubleSlab; public BaseItemSlab(Block block) { super(block); this.singleSlab = EmotionBlocks.emoSlab; this.doubleSlab = EmotionBlocks.emoDoubleSlab; this.setMaxDamage(0); this.setHasSubtypes(true); } public int getMetadata(int damage) { return damage; } public String getUnlocalizedName(ItemStack stack) { return this.singleSlab.getUnlocalizedName(stack.getMetadata()); } public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) { if(stack.stackSize == 0) { return false; } else if(!playerIn.canPlayerEdit(pos.offset(side), side, stack)) { return false; } else { Object object = this.singleSlab.getVariant(stack); IBlockState iblockstate = worldIn.getBlockState(pos); if(iblockstate.getBlock() == this.singleSlab) { IProperty iproperty = this.singleSlab.getVariantProperty(); Comparable comparable = iblockstate.getValue(iproperty); BaseSlab.EnumBlockHalf enumblockhalf = (BaseSlab.EnumBlockHalf)iblockstate.getValue(BaseSlab.HALF); if((side == EnumFacing.UP && enumblockhalf == BaseSlab.EnumBlockHalf.BOTTOM || side == EnumFacing.DOWN && enumblockhalf == BaseSlab.EnumBlockHalf.TOP) && comparable == object) { IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(iproperty, comparable); if(worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) { worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F); –stack.stackSize; } return true; } } return this.tryPlace(stack, worldIn, pos.offset(side), object) ? true : super.onItemUse(stack, playerIn, worldIn, pos, side, hitX, hitY, hitZ); } } @SideOnly(Side.CLIENT) public boolean canPlaceBlockOnSide(World worldIn, BlockPos pos, EnumFacing side, EntityPlayer player, ItemStack stack) { BlockPos blockpos1 = pos; IProperty iproperty = this.singleSlab.getVariantProperty(); Object object = this.singleSlab.getVariant(stack); IBlockState iblockstate = worldIn.getBlockState(pos); if(iblockstate.getBlock() == this.singleSlab) { boolean flag = iblockstate.getValue(BaseSlab.HALF) == BaseSlab.EnumBlockHalf.TOP; if((side == EnumFacing.UP && !flag || side == EnumFacing.DOWN && flag) && object == iblockstate.getValue(iproperty)) { return true; } } pos = pos.offset(side); IBlockState iblockstate1 = worldIn.getBlockState(pos); return iblockstate1.getBlock() == this.singleSlab && object == iblockstate1.getValue(iproperty) ? true : super.canPlaceBlockOnSide(worldIn, blockpos1, side, player, stack); } private boolean tryPlace(ItemStack stack, World worldIn, BlockPos pos, Object variantInStack) { IBlockState iblockstate = worldIn.getBlockState(pos); if(iblockstate.getBlock() == this.singleSlab) { Comparable comparable = iblockstate.getValue(this.singleSlab.getVariantProperty()); if(comparable == variantInStack) { IBlockState iblockstate1 = this.doubleSlab.getDefaultState().withProperty(this.singleSlab.getVariantProperty(), comparable); if(worldIn.checkNoEntityCollision(this.doubleSlab.getCollisionBoundingBox(worldIn, pos, iblockstate1)) && worldIn.setBlockState(pos, iblockstate1, 3)) { worldIn.playSoundEffect((double)((float)pos.getX() + 0.5F), (double)((float)pos.getY() + 0.5F), (double)((float)pos.getZ() + 0.5F), this.doubleSlab.stepSound.getPlaceSound(), (this.doubleSlab.stepSound.getVolume() + 1.0F) / 2.0F, this.doubleSlab.stepSound.getFrequency() * 0.8F); --stack.stackSize; } return true; } } return false; } }
- Client Proxy -
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(EmotionItems.emoItemSlab, 0, new ModelResourceLocation(Infos.MODID + ":emoItemSlab", "inventory"));
Voilà c’est tout, après n’essayez peut-être pas forcement de tirer quelque chose de ces classes (moi même ça me parait un peu flou), je vous avoue que je les ais plus faite pour vous montrer ma bonne volonté et vous assurez que j’ai déjà énormément essayé avant plutôt qu’autre chose.
J’espère juste que quelqu’un pourra m’éclairer d’avantage, me ramener sur un tutoriel, me donner un code sur GitHub ou m’expliquer plus en profondeur, bref comme d’habitude merci d’avance et j’aimerais vraiment pouvoir faire ces demie-dalles pour enfin passer à autre chose.
Ps: Les differentes sortes de planche que je vais utiliser pour ces demie-dalles ce trouves dans la classe “EnumTree” et “EnumNewTree” à savoir :
- Cherry
- Pear
- Orange
- Atlas
- Pine
- Coco
Ps2: Le log au cas ou :
[14:14:23] [Client thread/ERROR] [FML]: Fatal errors were detected during the transition from PREINITIALIZATION to INITIALIZATION. Loading cannot continue [14:14:23] [Client thread/ERROR] [FML]: mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1449.jar) Unloaded->Constructed->Pre-initialized Forge{11.14.3.1449} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1449.jar) Unloaded->Constructed->Pre-initialized emoMod{3.0} [Emotion's Mod] (bin) Unloaded->Constructed->Errored [14:14:23] [Client thread/ERROR] [FML]: The following problems were captured during this phase [14:14:23] [Client thread/ERROR] [FML]: Caught exception from emoMod java.lang.IllegalStateException: Can't free registry slot 198 occupied by net.minecraft.item.ItemBlock@3351f55 at net.minecraftforge.fml.common.registry.GameData.freeSlot(GameData.java:875) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:775) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:745) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:149) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:137) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at mods.emotion.items.EmotionItems.mainRegistry(EmotionItems.java:166) ~[bin/:?] at mods.emotion.main.MainRegistry.preInit(MainRegistry.java:54) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_75] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_75] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_75] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_75] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_75] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_75] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.8-11.14.3.1449.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_75] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_75] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_75] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:529) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:248) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:412) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:325) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_75] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_75] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_75] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_75] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] [14:14:23] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:571]: –-- Minecraft Crash Report ---- // Sorry :( Time: 24/06/15 14:14 Description: Initializing game java.lang.IllegalStateException: Can't free registry slot 198 occupied by net.minecraft.item.ItemBlock@3351f55 at net.minecraftforge.fml.common.registry.GameData.freeSlot(GameData.java:875) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:775) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:745) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:149) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:137) at mods.emotion.items.EmotionItems.mainRegistry(EmotionItems.java:166) at mods.emotion.main.MainRegistry.preInit(MainRegistry.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:212) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:119) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:529) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:248) at net.minecraft.client.Minecraft.startGame(Minecraft.java:412) at net.minecraft.client.Minecraft.run(Minecraft.java:325) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at net.minecraftforge.fml.common.registry.GameData.freeSlot(GameData.java:875) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:775) at net.minecraftforge.fml.common.registry.GameData.registerItem(GameData.java:745) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:149) at net.minecraftforge.fml.common.registry.GameRegistry.registerItem(GameRegistry.java:137) at mods.emotion.items.EmotionItems.mainRegistry(EmotionItems.java:166) at mods.emotion.main.MainRegistry.preInit(MainRegistry.java:54) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:212) at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) 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:119) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:529) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:248) at net.minecraft.client.Minecraft.startGame(Minecraft.java:412) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:325) at net.minecraft.client.main.Main.main(Main.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source) -- System Details -- Details: Minecraft Version: 1.8 Operating System: Windows 8.1 (amd64) version 6.3 Java Version: 1.7.0_75, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 774296848 bytes (738 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1449 4 mods loaded, 4 mods active mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1449.jar) Unloaded->Constructed->Pre-initialized Forge{11.14.3.1449} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1449.jar) Unloaded->Constructed->Pre-initialized emoMod{3.0} [Emotion's Mod] (bin) Unloaded->Constructed->Errored Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 353.30' Renderer: 'GeForce GTX 680/PCIe/SSE2' Launched Version: 1.8 LWJGL: 2.9.1 OpenGL: GeForce GTX 680/PCIe/SSE2 GL version 4.5.0 NVIDIA 353.30, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: [] Current Language: English (US) Profiler Position: N/A (disabled) [14:14:23] [Client thread/INFO] [STDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:571]: #@!@# Game crashed! Crash report saved to: #@!@# D:\Base\Downloads\Minecraft Moding\Forge Mod\eclipse\.\crash-reports\crash-2015-06-24_14.14.23-client.txt
-
Pourquoi tu essaye de faire un item ? Les slab sont deux blocs, un pour pour la moitié et l’autre pour le bloc complet.
-
A l’instar d’une porte j’ai pensé au vue de ce que j’avais sous la main que ça en avait besoin, ton tuto et Minecraft de base à aussi cette classe d’item donc sincèrement je croyais que j’étais complétement con à penser que ça avait rien à foutre là mais au final j’avais peut-être raison (mais dans ce cas à quoi sert cette item ?).
Sinon toi Robin tu pourrais peut-être m’aider à faire ces fameuses demi-dalles ou t’a pas encore eu le temps de toucher à la 1.8 à ce niveau ?
-
C’est pourtant expliqué dans le tutoriel de bloc avec metadata, et je suis persuadé de l’avoir expliqué dans le tutoriel vidéo sur les blocs. Chaque bloc possède un item associé (par défaut ItemBlock.class) et dans le cas des blocs avec metadata, des dalles et dans d’autres cas il faut utiliser un sa propre classe extends ItemBlock.
En ce qui concerne les portes, la canne à sucre et le gâteau je ne sais pas qu’est-ce qui à motivé Mojang a utiliser un item en plus, en tout cas ce n’est absolument pas nécessaire (dans mon mod privatizer j’ajoute une porte en utilisant un ItemBlock custom, du-coup pas besoin d’item en plus).
Et oui j’ai déjà fait des dalles en 1.8, mais je n’y ait plus touché depuis des mois, je ne sais même plus si elles sont entièrement fonctionnel ou pas.
Commences par relire le tutoriel 1.6, regardes un peu plus les classes de mc et supprimes-moi cette item x)
-
l’item bloc ? cela permet de donné les bons item (name) mais surtout de bien placer le bloc dans ce cas. Pour une porte, c’est différent l’item de la porte va permettre de posé le bloc du bas et du haut.
-
D’accord très bien, je vais le relire, tester quelque truc et voir comment ça ce passe.
Malheureusement comme je l’ai dis, je galère depuis un petit moment sur ça quand même et je crains que quelque conseil ne suffiront pas à m’aider
-
Bon bah je crois que c’est “bon”, en tous cas merci quand même à Robin et pour l’info l’item permet de placer la deuxième demie-dalle pour former une double demie-dalle. Avant en faite j’avais beaucoup de mal avec les jsons et je débutais le coding donc forcement j’arrivais pas vraiment à bidouiller mais maintenant c’est bon Bon ça à pas le même rendue étant donné que j’utilise la fonction :
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ){}
Pour placer la deuxième demie-dalle parce que je sais pas vraiment comment faire sinon pour faire en sorte que quand on clique droit sur le dessus du bloc seulement ça marche (en ajoutant le son du placement de bois qui n’est du coup pas présent) mais c’est déjà très bien comme ça et ça doit être encore améliorable alors.
Bref sinon voilà le code pour les personnes pas très téméraire qui voudrais faire ça facilement (méthode ultra condensée) :
public class BaseSlab extends BaseBlock { public static final PropertyEnum HALF = PropertyEnum.create("half", BaseSlab.EnumBlockHalf.class); private boolean isDouble; public BaseSlab(boolean par1, Material materialIn) { super(materialIn); isDouble = par1; IBlockState iblockstate = this.blockState.getBaseState(); if(!isDouble) { this.fullBlock = true; this.setCreativeTab(EmotionTab.EmotionCreativeTab5); iblockstate = iblockstate.withProperty(HALF, BaseSlab.EnumBlockHalf.BOTTOM); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } this.setHardness(2.0F); this.setResistance(5.0F); this.setStepSound(soundTypeWood); this.setLightOpacity(255); } public Item getItemDropped(IBlockState state, Random rand, int fortune) { if(this == EmotionBlocks.cherryDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.cherrySlab); if(this == EmotionBlocks.pearDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.pearSlab); if(this == EmotionBlocks.orangeDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.orangeSlab); if(this == EmotionBlocks.atlasDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.atlasSlab); if(this == EmotionBlocks.pineDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.pineSlab); if(this == EmotionBlocks.cocoDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.cocoSlab); return Item.getItemFromBlock(this); } @SideOnly(Side.CLIENT) public Item getItem(World worldIn, BlockPos pos) { if(this == EmotionBlocks.cherryDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.cherrySlab); if(this == EmotionBlocks.pearDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.pearSlab); if(this == EmotionBlocks.orangeDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.orangeSlab); if(this == EmotionBlocks.atlasDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.atlasSlab); if(this == EmotionBlocks.pineDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.pineSlab); if(this == EmotionBlocks.cocoDoubleSlab) return Item.getItemFromBlock(EmotionBlocks.cocoSlab); return Item.getItemFromBlock(this); } public IBlockState getStateFromMeta(int meta) { IBlockState iblockstate = this.getDefaultState(); if(!isDouble) { iblockstate = iblockstate.withProperty(HALF, (meta & 8) == 0 ? BaseSlab.EnumBlockHalf.BOTTOM : BaseSlab.EnumBlockHalf.TOP); } return iblockstate; } public int getMetaFromState(IBlockState state) { byte b0 = 0; int i = b0; if(!isDouble && state.getValue(HALF) == BaseSlab.EnumBlockHalf.TOP) { i |= 8; } return i; } protected BlockState createBlockState() { return isDouble ? new BlockState(this) : new BlockState(this, new IProperty[] {HALF}); } public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { if(player.getCurrentEquippedItem() != null) { if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.cherrySlab)) world.setBlockState(pos, EmotionBlocks.cherryDoubleSlab.getDefaultState()); if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.pearSlab)) world.setBlockState(pos, EmotionBlocks.pearDoubleSlab.getDefaultState()); if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.orangeSlab)) world.setBlockState(pos, EmotionBlocks.orangeDoubleSlab.getDefaultState()); if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.atlasSlab)) world.setBlockState(pos, EmotionBlocks.atlasDoubleSlab.getDefaultState()); if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.pineSlab)) world.setBlockState(pos, EmotionBlocks.pineDoubleSlab.getDefaultState()); if(player.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(EmotionBlocks.cocoSlab)) world.setBlockState(pos, EmotionBlocks.cocoDoubleSlab.getDefaultState()); if(!player.capabilities.isCreativeMode && –player.inventory.getCurrentItem().stackSize <= 0) { player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack)null); } return true; } return false; } protected boolean canSilkHarvest() { return false; } public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) { if(isDouble) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { IBlockState iblockstate = worldIn.getBlockState(pos); if(iblockstate.getBlock() == this) { if(iblockstate.getValue(HALF) == BaseSlab.EnumBlockHalf.TOP) { this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } } } public void setBlockBoundsForItemRender() { if(isDouble) { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); } else { this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F); } } public void addCollisionBoxesToList(World worldIn, BlockPos pos, IBlockState state, AxisAlignedBB mask, List list, Entity collidingEntity) { this.setBlockBoundsBasedOnState(worldIn, pos); super.addCollisionBoxesToList(worldIn, pos, state, mask, list, collidingEntity); } public boolean isOpaqueCube() { return isDouble; } public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer) { IBlockState iblockstate = super.onBlockPlaced(worldIn, pos, facing, hitX, hitY, hitZ, meta, placer).withProperty(HALF, BaseSlab.EnumBlockHalf.BOTTOM); return isDouble ? iblockstate : (facing != EnumFacing.DOWN && (facing == EnumFacing.UP || (double)hitY <= 0.5D) ? iblockstate : iblockstate.withProperty(HALF, BaseSlab.EnumBlockHalf.TOP)); } public int quantityDropped(Random random) { return isDouble ? 2 : 1; } public boolean isFullCube() { return isDouble; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) { if(isDouble) { return super.shouldSideBeRendered(worldIn, pos, side); } else if(side != EnumFacing.UP && side != EnumFacing.DOWN && !super.shouldSideBeRendered(worldIn, pos, side)) { return false; } else { BlockPos blockpos1 = pos.offset(side.getOpposite()); IBlockState iblockstate = worldIn.getBlockState(pos); IBlockState iblockstate1 = worldIn.getBlockState(blockpos1); boolean flag = isSlab(iblockstate.getBlock()) && iblockstate.getValue(HALF) == BaseSlab.EnumBlockHalf.TOP; boolean flag1 = isSlab(iblockstate1.getBlock()) && iblockstate1.getValue(HALF) == BaseSlab.EnumBlockHalf.TOP; return flag1 ? (side == EnumFacing.DOWN ? true : (side == EnumFacing.UP && super.shouldSideBeRendered(worldIn, pos, side) ? true : !isSlab(iblockstate.getBlock()) || !flag)) : (side == EnumFacing.UP ? true : (side == EnumFacing.DOWN && super.shouldSideBeRendered(worldIn, pos, side) ? true : !isSlab(iblockstate.getBlock()) || flag)); } } @SideOnly(Side.CLIENT) protected static boolean isSlab(Block blockIn) { return blockIn == EmotionBlocks.cherrySlab || blockIn == EmotionBlocks.pearSlab || blockIn == EmotionBlocks.orangeSlab || blockIn == EmotionBlocks.atlasSlab || blockIn == EmotionBlocks.pineSlab || blockIn == EmotionBlocks.cocoSlab; } public int getDamageValue(World worldIn, BlockPos pos) { return super.getDamageValue(worldIn, pos) & 7; } public static enum EnumBlockHalf implements IStringSerializable { TOP("top"), BOTTOM("bottom"); private final String name; private EnumBlockHalf(String name) { this.name = name; } public String toString() { return this.name; } public String getName() { return this.name; } } }