Résolu Texture Four en fonction du son status
-
Bonjour
J’ai créer un block type four et je voudrais savoir commet faut-il faire pour modifier la texture de front fonction du status du four (éteint/allumé).
J’ai essayé avec un block metadata et je ne sais pas si mon block metadata fonctionne ou si cette façon de le faire n’est pas la bonne ? -
Il faut que tu aies 8 metadata différents, 4 pour quand c’est sur off, 1 pour chaque face et 4 pour quand c’est sur on, 1 pour chaque face.
Il te faut 2 icônes de face, une éteinte (metadata : 0 à 3) et une allumée (metadata : 4 à 7), et une fonction qui si on veut un four allumé ajoutera 4 à la metadata et si on veut un four éteint, retirera 4 à la metadata.
Cette fonction sera appelée par le tile entity qui détectera si le four doit être allumé ou non. -
Ou alors tu fais tout passé par le tile entity. Ça fonctionne aussi.
-
Oui, aussi, mais avec l’autre technique tu peux t’inspirer du four vanilla
-
C’est largement plus facile avec une TileEntity
-
Je crois que je ne m’y suis pas pris de la bonne façon
:::at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:624) ~[RenderItem.class:?] at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) ~[GuiIngame.class:?] at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) ~[GuiIngameForge.class:?] at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) ~[GuiIngameForge.class:?] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) ~[EntityRenderer.class:?] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) ~[Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:962) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:164) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?] at GradleStart.main(Unknown Source) [start/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_66] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_66] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_66] at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_66] at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) [idea_rt.jar:?] Caused by: java.lang.NullPointerException at com.google.SpyMan.Mechanicalcraft.common.BlockCrusher.Crusher.getIcon(Crusher.java:68) ~[Crusher.class:?] at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8451) ~[RenderBlocks.class:?] at net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem(RenderBlocks.java:8401) ~[RenderBlocks.class:?] at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:463) ~[RenderItem.class:?] at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:585) ~[RenderItem.class:?] … 20 more [09:40:00] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // Oops. Time: 02/03/16 09:40 Description: Rendering item java.lang.NullPointerException: Rendering item at com.google.SpyMan.Mechanicalcraft.common.BlockCrusher.Crusher.getIcon(Crusher.java:68) at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8451) at net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem(RenderBlocks.java:8401) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:463) at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:585) at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1114) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1067) at net.minecraft.client.Minecraft.run(Minecraft.java:962) at net.minecraft.client.main.Main.main(Main.java:164) 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:497) 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) 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:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.google.SpyMan.Mechanicalcraft.common.BlockCrusher.Crusher.getIcon(Crusher.java:68) at net.minecraft.client.renderer.RenderBlocks.getBlockIconFromSideAndMetadata(RenderBlocks.java:8451) at net.minecraft.client.renderer.RenderBlocks.renderBlockAsItem(RenderBlocks.java:8401) at net.minecraft.client.renderer.entity.RenderItem.renderItemIntoGUI(RenderItem.java:463) -- Item being rendered -- Details: Item Type: net.minecraft.item.ItemBlock@2f079444 Item Aux: 0 Item NBT: null Item Foil: false Stacktrace: at net.minecraft.client.renderer.entity.RenderItem.renderItemAndEffectIntoGUI(RenderItem.java:585) at net.minecraft.client.gui.GuiIngame.renderInventorySlot(GuiIngame.java:973) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:209) at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:144) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityClientPlayerMP['SpyMan'/201, l='MpServer', x=-546,33, y=5,62, z=-1234,60]] Chunk stats: MultiplayerChunkCache: 0, 0 Level seed: 0 Level generator: ID 01 - flat, ver 0\. Features enabled: false Level generator options: Level spawn location: World: (-554,4,-1237), Chunk: (at 6,0,11 in -35,-78; contains blocks -560,0,-1248 to -545,255,-1233), Region: (-2,-3; contains chunks -64,-96 to -33,-65, blocks -1024,0,-1536 to -513,255,-1025) Level time: 137871 game time, 1390 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 1 total; [EntityClientPlayerMP['SpyMan'/201, l='MpServer', x=-546,33, y=5,62, z=-1234,60]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:415) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2566) at net.minecraft.client.Minecraft.run(Minecraft.java:984) at net.minecraft.client.main.Main.main(Main.java:164) 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:497) 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) 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:497) at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
:::
[font=Courier Newpublic ]IIcon getIcon(int side, int metadata)
{
if (*side *== 0) return this.bottom%(#aaa9a7)[;
] else if (*side *== 1) return this.top%(#aaa9a7)[;
]
if ((*side *== 3 && *metadata *== 0) || (*side *== 4 && *metadata *== 1) || (*side *== 2 && *metadata *== 2) || (*side *== 5 && *metadata *== 3))
{
return this.frontOff%(#aaa9a7)[;
] }
%(#0187df)else if
{
if ((*side *== 3 && *metadata *== 0 + 4) || (*side *== 4 && *metadata *== 1 + 4) || (*side *== 2 && *metadata *== 2 + 4) || (*side *== 5 && *metadata *== 3 + 4))
{
return this.frontOn%(#aaa9a7)[;
] }
}
return this.side%(#aaa9a7)[;
]} -
at com.google.SpyMan.Mechanicalcraft.common.BlockCrusher.Crusher.getIcon(Crusher.java:68) ~[Crusher.class:?]
Tu as un NPE ligne 68 de ton Crusher.
-
D’accord mais commet je peut y remédier ?
-
D’abord il faudrait la class…Sinon on peut pas deviner le probleme
-
package com.google.SpyMan.Mechanicalcraft.common.BlockCrusher; import com.google.SpyMan.Mechanicalcraft.common.MechanicalCraft; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.ITileEntityProvider; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.inventory.IInventory; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.util.MathHelper; import net.minecraft.world.World; public class Crusher extends BlockContainer implements ITileEntityProvider { public Crusher(Material material) { super; setResistance; setHardness; setHarvestLevel("pickaxe", 2); } private static String machineType = "crusher"; public static String[] blockTexture = new String[] { MechanicalCraft.TEXTURE_NAME + "machine_side", MechanicalCraft.TEXTURE_NAME + machineType+"_front", MechanicalCraft.TEXTURE_NAME + machineType+"_front_on", MechanicalCraft.TEXTURE_NAME + "machine_bottom", MechanicalCraft.TEXTURE_NAME + %(#00b10f)["machine_top" }; private IIcon top, bottom, side, frontOn, frontOff; TileEntityCrusher tileEntityCrusher; public void registerBlockIcons(IIconRegister iiconRegister) { this.frontOn = iiconRegister.%(#afb8c5)registerIcon; this.frontOff = iiconRegister.%(#afb8c5)registerIcon; this.top = iiconRegister.%(#afb8c5)registerIcon; this.bottom = iiconRegister.%(#afb8c5)registerIcon; this.side = iiconRegister.%(#afb8c5)registerIcon; } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double) (living.rotationYaw %(#aaa9a7)* 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double) (living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } public IIcon getIcon(int side, int metadata) { if (side == 0) return this.bottom; else if (side == 1) return this.top; if ((side == 3 && metadata == 0) || (side == 4 && metadata == 1) || (side == 2 && metadata == 2) || (side == 5 && metadata == 3)) { return this.frontOff; } else if (tileEntityCrusher.isBurning()) { if ((side == 3 && metadata == 0 + 4) || (side == 4 && metadata == 1 + 4) || (side == 2 && metadata == 2 + 4) || (side == 5 && metadata == 3 + 4)) { return this.frontOn; } } return this.side; } @Override public TileEntity createNewTileEntity(World world, int metadata) { return new TileEntityCrusher(); } @Override public boolean hasTileEntity(int metadata) { return true; } public void breakBlock(World world, int x, int y, int z, Block block, int metadata) { TileEntity tileentity = world.getTileEntity(x, y, z); if (tileentity instanceof IInventory) { IInventory inv = (IInventory)tileentity; for (int i1 = 0; i1 < inv.getSizeInventory(); ++i1) { ItemStack itemstack = inv.getStackInSlot(i1); if (itemstack != null) { float f = world.rand.nextFloat() * 0.8F + 0.1F; float f1 = world.rand.nextFloat() * 0.8F + 0.1F; EntityItem entityitem; for (float f2 = world.rand.nextFloat() * 0.8F + 0.1F; itemstack.stackSize > 0; world.spawnEntityInWorld(entityitem)) { int j1 = world.rand.nextInt(21) + 10; if (j1 > itemstack.stackSize) { j1 = itemstack.stackSize; } itemstack.stackSize -= j1; entityitem = new EntityItem(world, (double)((float)x + f), (double)((float)y + f1), (double)((float)z + f2), new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage())); float f3 = 0.05F; entityitem.motionX = (double)((float)world.rand.nextGaussian() * f3); entityitem.motionY = (double)((float)world.rand.nextGaussian() * f3 + 0.2F); entityitem.motionZ = (double)((float)world.rand.nextGaussian() * f3); if (itemstack.hasTagCompound()) { entityitem.getEntityItem().setTagCompound((NBTTagCompound)itemstack.getTagCompound().copy()); } } } } world.func_147453_f(x, y, z, block); } super.breakBlock(world, x, y, z, block, metadata); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitx, float hity, float hitz) { if (world.isRemote) { return true; } else { player.openGui(MechanicalCraft.instance, 3, world, x, y, z); return true; } } }
-
Donc ligne 68 tu as else if (tileEntityCrusher.isBurning()), sauf qu’il ne peux pas l’avoir…du coup ça vient de ton TileEntity…
-
“TileEntityCrusher tileEntityCrusher;”
Il est toujours égal à null donc ça peut pas marcher, et de toute façon faut pas faire ça parce que t’a un tile entity différent par bloc. -
Comment je peut faire alors ???
-
Il faut que tu return la texture en fonction de la metadata
-
D’accord mais le metadata je le trouve où ?
-
Il y a un argument metadat dans ta fonction getIcon
-
Oui mais la valeur du metadata je là sort d’où?
–--------------------------------------------------------------------
EDIT: Si quelqu’un sait comment resoudre ce crash
Ceci n’a strictement rien a voir avec le sujet
[22:34:13] [Server thread/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.world.BlockEvent$HarvestDropsEvent@40e581af: java.lang.NullPointerException at com.google.SpyMan.Mechanicalcraft.common.Event.BlockEventHandler.onDrops(BlockEventHandler.java:50) ~[BlockEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_BlockEventHandler_onDrops_HarvestDropsEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140) [EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:162) [ForgeEventFactory.class:?] at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806) [Block.class:?] at net.minecraft.world.Explosion.doExplosionB(Explosion.java:221) [Explosion.class:?] at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:974) [WorldServer.class:?] at net.minecraft.world.World.createExplosion(World.java:2655) [World.class:?] at net.minecraft.entity.item.EntityTNTPrimed.explode(EntityTNTPrimed.java:98) [EntityTNTPrimed.class:?] at net.minecraft.entity.item.EntityTNTPrimed.onUpdate(EntityTNTPrimed.java:86) [EntityTNTPrimed.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) [World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) [WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2258) [World.class:?] at net.minecraft.world.World.updateEntities(World.java:2108) [World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) [WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) [MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) [IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] [22:34:13] [Server thread/ERROR] [FML]: Index: 1 Listeners: [22:34:13] [Server thread/ERROR] [FML]: 0: NORMAL [22:34:13] [Server thread/ERROR] [FML]: 1: ASM: com.google.SpyMan.Mechanicalcraft.common.Event.BlockEventHandler@5bb1b018 onDrops(Lnet/minecraftforge/event/world/BlockEvent$HarvestDropsEvent;)V [22:34:13] [Server thread/ERROR]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking entity at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:709) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) [MinecraftServer.class:?] at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) [MinecraftServer$2.class:?] Caused by: java.lang.NullPointerException at com.google.SpyMan.Mechanicalcraft.common.Event.BlockEventHandler.onDrops(BlockEventHandler.java:50) ~[BlockEventHandler.class:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_BlockEventHandler_onDrops_HarvestDropsEvent.invoke(.dynamic) ~[?:?] at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) ~[ASMEventHandler.class:?] at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140) ~[EventBus.class:?] at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:162) ~[ForgeEventFactory.class:?] at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806) ~[Block.class:?] at net.minecraft.world.Explosion.doExplosionB(Explosion.java:221) ~[Explosion.class:?] at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:974) ~[WorldServer.class:?] at net.minecraft.world.World.createExplosion(World.java:2655) ~[World.class:?] at net.minecraft.entity.item.EntityTNTPrimed.explode(EntityTNTPrimed.java:98) ~[EntityTNTPrimed.class:?] at net.minecraft.entity.item.EntityTNTPrimed.onUpdate(EntityTNTPrimed.java:86) ~[EntityTNTPrimed.class:?] at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) ~[WorldServer.class:?] at net.minecraft.world.World.updateEntity(World.java:2258) ~[World.class:?] at net.minecraft.world.World.updateEntities(World.java:2108) ~[World.class:?] at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) ~[WorldServer.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) ~[MinecraftServer.class:?] … 4 more [22:34:13] [Server thread/ERROR]: This crash report has been saved to: C:\Users\Family\Desktop\Java Modding\NewMechanicalCraft\eclipse\.\crash-reports\crash-2016-03-02_22.34.13-server.txt [22:34:13] [Server thread/INFO]: Stopping server [22:34:13] [Server thread/INFO]: Saving players [22:34:13] [Client thread/INFO] [STDOUT]: [net.minecraft.client.Minecraft:displayCrashReport:388]: –-- Minecraft Crash Report ---- // This doesn't make any sense! Time: 02/03/16 22:34 Description: Ticking entity java.lang.NullPointerException: Ticking entity at com.google.SpyMan.Mechanicalcraft.common.Event.BlockEventHandler.onDrops(BlockEventHandler.java:50) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_BlockEventHandler_onDrops_HarvestDropsEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140) at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:162) at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806) at net.minecraft.world.Explosion.doExplosionB(Explosion.java:221) at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:974) at net.minecraft.world.World.createExplosion(World.java:2655) at net.minecraft.entity.item.EntityTNTPrimed.explode(EntityTNTPrimed.java:98) at net.minecraft.entity.item.EntityTNTPrimed.onUpdate(EntityTNTPrimed.java:86) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) at net.minecraft.world.World.updateEntity(World.java:2258) at net.minecraft.world.World.updateEntities(World.java:2108) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at com.google.SpyMan.Mechanicalcraft.common.Event.BlockEventHandler.onDrops(BlockEventHandler.java:50) at cpw.mods.fml.common.eventhandler.ASMEventHandler_6_BlockEventHandler_onDrops_HarvestDropsEvent.invoke(.dynamic) at cpw.mods.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:54) at cpw.mods.fml.common.eventhandler.EventBus.post(EventBus.java:140) at net.minecraftforge.event.ForgeEventFactory.fireBlockHarvesting(ForgeEventFactory.java:162) at net.minecraft.block.Block.dropBlockAsItemWithChance(Block.java:806) at net.minecraft.world.Explosion.doExplosionB(Explosion.java:221) at net.minecraft.world.WorldServer.newExplosion(WorldServer.java:974) at net.minecraft.world.World.createExplosion(World.java:2655) at net.minecraft.entity.item.EntityTNTPrimed.explode(EntityTNTPrimed.java:98) at net.minecraft.entity.item.EntityTNTPrimed.onUpdate(EntityTNTPrimed.java:86) at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:2298) at net.minecraft.world.WorldServer.updateEntityWithOptionalForce(WorldServer.java:684) at net.minecraft.world.World.updateEntity(World.java:2258) -- Entity being ticked -- Details: Entity Type: PrimedTnt (net.minecraft.entity.item.EntityTNTPrimed) Entity ID: 274 Entity Name: Block of TNT Entity's Exact location: 7,50, 32,49, 192,49 Entity's Block location: World: (7,32,192), Chunk: (at 7,2,0 in 0,12; contains blocks 0,0,192 to 15,255,207), Region: (0,0; contains chunks 0,0 to 31,31, blocks 0,0,0 to 511,255,511) Entity's Momentum: -0,00, -0,00, 0,00 Stacktrace: at net.minecraft.world.World.updateEntities(World.java:2108) at net.minecraft.world.WorldServer.updateEntities(WorldServer.java:515) -- Affected level -- Details: Level name: TestGenOres All players: 1 total; [EntityPlayerMP['SpyMan'/129, l='TestGenOres', x=7,54, y=33,00, z=194,64]] Chunk stats: ServerChunkCache: 625 Drop: 0 Level seed: -7302235049456822426 Level generator: ID 00 - default, ver 1\. Features enabled: false Level generator options: Level spawn location: World: (-4,64,252), Chunk: (at 12,4,12 in -1,15; contains blocks -16,0,240 to -1,255,255), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511) Level time: 11121 game time, 11121 day time Level dimension: 0 Level storage version: 0x04ABD - Anvil Level weather: Rain time: 3184 (now: false), thunder time: 115577 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: true Stacktrace: at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:703) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:614) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:118) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:485) at net.minecraft.server.MinecraftServer$2.run(MinecraftServer.java:752)
package com.google.SpyMan.Mechanicalcraft.common.Event; import com.google.SpyMan.Mechanicalcraft.common.MechanicalCraft; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraftforge.event.world.BlockEvent; public class BlockEventHandler { @SubscribeEvent public void onDrops(BlockEvent.HarvestDropsEvent event) { if (event.block == Blocks.iron_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenIronOre, 2)); } if (event.block == Blocks.gold_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenGoldOre, 2)); } if (event.block == Blocks.lit_redstone_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenRedstoneOre, 2)); } if (event.block == Blocks.redstone_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenRedstoneOre, 2)); } if (event.block == Blocks.coal_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenCoalOre, 2)); } if (event.block == Blocks.diamond_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenDiamondOre, 2)); } if (event.block == Blocks.emerald_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenEmeraldOre, 2)); } if (event.block == MechanicalCraft.copperOre && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenCopperOre, 2)); } if (event.block == MechanicalCraft.tinOre && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenTinOre, 2)); } if (event.block == Blocks.lapis_ore && event.harvester.getHeldItem() != null && event.harvester.getHeldItem().getItem() == MechanicalCraft.redstoneDrill) { event.drops.clear(); event.drops.add(new ItemStack(MechanicalCraft.brokenLapisOre, 2)); } } }
-
Comment ça tu la sort d’où ? C’est le fonction getIcon qui la sort, appelée par mc (sauf erreur de ma part, ai pas codé en 1.7.10 depuis trèèès longtemps)
Et pour le crash, je peux pas bien voir sans les numéros de ligne mais vérifies bien que évent.drops soit pas null. -
Je pense que vais mettre en place une nouvelle règle.
Le prochain qui met une balise code ou une balise java à l’intérieur d’une balise spoiler va se manger un ban. Idem pour le prochain qui poste des logs sans la balise code ou du code sans la balise java.La balise code et la balise java ajoutent AUTOMATIQUEMENT un slider si le code est loin. Mettre une balise java ou code dans un spoiler aura juste pour effet d’avoir un rendu dégueulasse.
De même la balise java ajoute AUTOMATIQUEMENT les numéros de ligne et la couleur. C’était quoi ce message dégueulasse fait à base de quote de color, de b et de i ?Bref, pour le crash tu as un npe sur la ligne 50, ce qui est étrange.
Ce que je te conseil c’est de faire un bloc
if(event.harvester.getHeldItem() != null)
{
}
et de mettre toutes les conditions dedans (et du-coup retirer ce if présent à chaque condition). -
Désolé pour les balises j’avais oublier comme ça faisait longtemps que je n’avais posté de sujet
Quand j’ai dit “la valeur du metadata” je pensais a comment je la fait varié en fonction du status de mon block.
Elle va pas détecter toute seul si mon block est en marche ou pas, sachant que isBurning() ne fonctionne pas
et sinon j’ai oublier de préciser le crash des events c’est uniquement quand les blocks sont cassé avec quelque chose d’autre qu’une pioche, la main ou mon items Ce qui fait crash: un creeper casse les blocks ou la tnt ou les mobs qui le peuvent
PS: ça ce fonctionne pas, ça crash encore