1.6.4 (Event)Rendre un bloc vanilla indestructible



  • Bonjour à toutes et à tous !

    Je cherche un moyen, qui je pense, est de passer par un event BlockEvent.BreakEvent ?
    Pour faire en sorte qu'un bloc en vanilla puisse être indestructible !

    malheureusement après maintes tentatives je n'y arrive pas

    j'ai testé un

    if(event instanceof BlockGrass)

    mais il me marque une erreur "Incompatible conditional operand types BlockEvent.BreakEvent and BlockGrass"

    Donc je sais pas par où passer…

    Merci de votre aide encore une fois !

    -ZeAmateis-


  • Rédacteurs

    je pense que tu peux faire que lors que le block est détruit, il ne drop rien et est tout de suite replacer à sa position


  • Moddeurs confirmés Rédacteurs Administrateurs

    Salut,
    if(event.block instanceof BlockGrass)

    Si tu essaye de comparer un event avec un bloc, normal que ça fonctionne pas …



  • Ah ok


    Il faut que je passe par quoi du coup ? Robin ?


  • Rédacteurs

    Comme ça :

    if(event.block == Block.grass) {
    event.drops.clear();
    event.world.setBlock(event.x, event.y, event.z, Blocks.grass)
    event.world.setBlockMetadataWithNotify(event.x, event.y, event.z, event.world.getBlockMetadata(event.x, event.y, event.z), 2);
    }
    

    le code viens de la 1.7 donc il te reste juste à ajouter les .blockid et modifier le nom des class (Blocks -> Block)


  • Moddeurs confirmés Rédacteurs Administrateurs

    if(event.block instanceof BlockGrass)
    {
    event.setCancel(true);
    }
    

    Bien plus simple.



  • Ah ! Et avant que le sujet soit en résolu, y'a-t-il un moyen de bloquer un craft via un event ou autre chose ?

    Ou sinon j'ouvre un autre topic d'aide


  • Rédacteurs

    la FFMTLibs dispose de méthode pour retirer les recettes d'un item, block ou ItemStack



  • Je vais voir ça


  • Moddeurs confirmés Rédacteurs Administrateurs



  • Ah ! Une erreur est survenue en Multijoueur !

    Crash Report

    :::

    –-- Minecraft Crash Report ----
    // Oh - I know what I did wrong!
    
    Time: 28/06/14 19:31
    Description: Exception in server tick loop
    
    java.lang.NoClassDefFoundError: net/minecraft/server/integrated/IntegratedServer
    at viruz.zeamateis.event.BreakEvent.breakEvent(BreakEvent.java:17)
    at net.minecraftforge.event.ASMEventHandler_28_BreakEvent_breakEvent_BreakEvent.invoke(.dynamic)
    at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39)
    at net.minecraftforge.event.EventBus.post(EventBus.java:108)
    at net.minecraftforge.common.ForgeHooks.onBlockBreakEvent(ForgeHooks.java:473)
    at net.minecraft.item.ItemInWorldManager.func_73084_b(ItemInWorldManager.java:361)
    at net.minecraft.item.ItemInWorldManager.func_73082_a(ItemInWorldManager.java:302)
    at net.minecraft.network.NetServerHandler.func_72510_a(NetServerHandler.java:790)
    at net.minecraft.network.packet.Packet14BlockDig.func_73279_a(Packet14BlockDig.java:67)
    at net.minecraft.network.TcpConnection.func_74428_b(TcpConnection.java:470)
    at net.minecraft.network.NetServerHandler.func_72570_d(NetServerHandler.java:233)
    at net.minecraft.network.NetworkListenThread.func_71747_b(NetworkListenThread.java:54)
    at net.minecraft.server.dedicated.DedicatedServerListenThread.func_71747_b(DedicatedServerListenThread.java:34)
    at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:910)
    at net.minecraft.server.dedicated.DedicatedServer.func_71190_q(DedicatedServer.java:330)
    at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:777)
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:659)
    at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
    Caused by: java.lang.ClassNotFoundException: net.minecraft.server.integrated.IntegratedServer
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 18 more
    Caused by: java.lang.RuntimeException: Attempted to load class bkz for invalid side SERVER
    at cpw.mods.fml.common.asm.transformers.SideTransformer.transform(SideTransformer.java:51)
    at net.minecraft.launchwrapper.LaunchClassLoader.runTransformers(LaunchClassLoader.java:274)
    at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:172)
    ... 20 more
    
    A detailed walkthrough of the error, its code path and all known details is as follows:
    ---------------------------------------------------------------------------------------
    
    -- System Details --
    Details:
    Minecraft Version: 1.6.4
    Operating System: Windows 8.1 (amd64) version 6.3
    Java Version: 1.7.0_60, Oracle Corporation
    Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    Memory: 263846112 bytes (251 MB) / 536870912 bytes (512 MB) up to 954728448 bytes (910 MB)
    JVM Flags: 1 total; -Xmx1024M
    AABB Pool Size: 560 (31360 bytes; 0 MB) allocated, 363 (20328 bytes; 0 MB) used
    Suspicious classes: FML and Forge are installed
    IntCache: cache: 0, tcache: 0, allocated: 3, tallocated: 71
    CraftBukkit Information:
    Running: MCPC+ version git-MCPC-Plus-jenkins-MCPC-Plus-164-251 (MC: 1.6.4) (Implementing API version 1.6.4-R2.1-SNAPSHOT) true
    Plugins: { LongerTimev1 v1 de.devTobi.Zeitenplugin.Zeitenmain [],}
    Warnings: DEFAULT
    Threads: { WAITING Finalizer: [java.lang.Object.wait(Native Method), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.ReferenceQueue.remove(Unknown Source), java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)], RUNNABLE Command Reader: [org.fusesource.jansi.internal.Kernel32._getch(Native Method), org.fusesource.jansi.internal.WindowsSupport.readByte(WindowsSupport.java:46), org.bukkit.craftbukkit.libs.jline.WindowsTerminal.readByte(WindowsTerminal.java:184), org.bukkit.craftbukkit.libs.jline.WindowsTerminal.access$000(WindowsTerminal.java:53), org.bukkit.craftbukkit.libs.jline.WindowsTerminal$1.read(WindowsTerminal.java:151), java.io.FilterInputStream.read(Unknown Source), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader$1.read(ConsoleReader.java:167), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:267), org.bukkit.craftbukkit.libs.jline.internal.InputStreamReader.read(InputStreamReader.java:204), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readCharacter(ConsoleReader.java:995), org.bukkit.craftbukkit.libs.jline.console.ConsoleReader.readLine(ConsoleReader.java:1167), net.minecraft.server.dedicated.DedicatedServerCommandThread.run(DedicatedServerCommandThread.java:38)], TIMED_WAITING Thread-5: [java.lang.Thread.sleep(Native Method), net.minecraft.server.dedicated.DedicatedServerSleepThread.run(DedicatedServerSleepThread.java:23)], RUNNABLE DestroyJavaVM: [], RUNNABLE Connection #1 read thread: [java.net.SocketInputStream.socketRead0(Native Method), java.net.SocketInputStream.read(Unknown Source), java.net.SocketInputStream.read(Unknown Source), java.io.FilterInputStream.read(Unknown Source), org.bouncycastle.crypto.io.CipherInputStream.nextChunk(Unknown Source), org.bouncycastle.crypto.io.CipherInputStream.read(Unknown Source), java.io.DataInputStream.readUnsignedByte(Unknown Source), net.minecraft.network.packet.Packet.func_73272_a(Packet.java:159), net.minecraft.network.TcpConnection.func_74447_i(TcpConnection.java:327), net.minecraft.network.TcpConnection.func_74450_c(TcpConnection.java:556), net.minecraft.network.TcpReaderThread.run(TcpReaderThread.java:23)], TIMED_WAITING Spigot Watchdog Thread: [java.lang.Thread.sleep(Native Method), org.spigotmc.WatchdogThread.run(WatchdogThread.java:174)], RUNNABLE Listen thread: [java.net.DualStackPlainSocketImpl.accept0(Native Method), java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source), java.net.AbstractPlainSocketImpl.accept(Unknown Source), java.net.PlainSocketImpl.accept(Unknown Source), java.net.ServerSocket.implAccept(Unknown Source), java.net.ServerSocket.accept(Unknown Source), net.minecraft.server.ServerListenThread.run(ServerListenThread.java:82)], TIMED_WAITING Spigot Metrics Thread: [java.lang.Object.wait(Native Method), java.util.TimerThread.mainLoop(Unknown Source), java.util.TimerThread.run(Unknown Source)], TIMED_WAITING Connection #1 write thread: [java.lang.Thread.sleep(Native Method), net.minecraft.network.TcpWriterThread.run(TcpWriterThread.java:49)], WAITING Thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(Unknown Source), java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source), java.util.concurrent.LinkedBlockingQueue.take(Unknown Source), cpw.mods.fml.relauncher.FMLRelaunchLog$ConsoleLogThread.run(FMLRelaunchLog.java:83), java.lang.Thread.run(Unknown Source)], WAITING Reference Handler: [java.lang.Object.wait(Native Method), java.lang.Object.wait(Object.java:503), java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)], TIMED_WAITING Snooper Timer: [java.lang.Object.wait(Native Method), java.util.TimerThread.mainLoop(Unknown Source), java.util.TimerThread.run(Unknown Source)], RUNNABLE Signal Dispatcher: [], TIMED_WAITING File IO Thread: [java.lang.Thread.sleep(Native Method), net.minecraft.world.storage.ThreadedFileIOBase.func_75736_b(ThreadedFileIOBase.java:61), net.minecraft.world.storage.ThreadedFileIOBase.run(ThreadedFileIOBase.java:27), java.lang.Thread.run(Unknown Source)], RUNNABLE Server thread: [java.lang.Thread.dumpThreads(Native Method), java.lang.Thread.getAllStackTraces(Unknown Source), org.bukkit.craftbukkit.v1_6_R3.CraftCrashReport.call(CraftCrashReport.java:27), net.minecraft.crash.CrashReportCategory.func_71500_a(CrashReportCategory.java:106), net.minecraft.crash.CrashReport.func_71504_g(CrashReport.java:58), net.minecraft.crash.CrashReport.<init>(CrashReport.java:40), net.minecraft.server.MinecraftServer.run(MinecraftServer.java:689), net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)], RUNNABLE Attach Listener: [], WAITING Chunk I/O Executor Thread-1: [sun.misc.Unsafe.park(Native Method), java.util.concurrent.locks.LockSupport.park(Unknown Source), java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source), java.util.concurrent.LinkedBlockingQueue.take(Unknown Source), java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source), java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source), java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source), java.lang.Thread.run(Unknown Source)],}
    Recent tasks from 1212-1242{}
    FML: MCP v8.11 FML v6.4.49.965 Minecraft Forge 9.11.1.965 13 mods loaded, 13 mods active
    mcp{8.09} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FML{6.4.49.965} [Forge Mod Loader] (craftbukkit.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Forge{9.11.1.965} [Minecraft Forge] (craftbukkit.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Backpack{1.18.17} [Backpack] (backpack-1.18.17-1.6.2.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    BiblioCraft{1.5.5} [BiblioCraft] (BiblioCraft.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    customnpcs{1.6.4} [CustomNpcs] (CustomNPC's.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    FlansMod{4.1} [Flans Mod] (FlansMod.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    cfm{3.2.7} [§4MrCrayfish's Furniture Mod] (Furniture'sMod.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    GraveStoneMod{1.6.2 v5.2} [GraveStone] (GraveStones_Mod_1.6.4_v1.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    pcl{2.1.0} [PCL] (pcl2.1.0 mc1.6.4.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    lanterns{1.1.0} [Lanterns] (lanterns1.1.0 mc1.6.4.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    ThirstMod{1.7.6} [Thirst Mod] (ThirstMod.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    ViruZ{3.0} [ViruZ] (ViruZ.zip) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available->Available
    Profiler Position: N/A (disabled)
    Vec3 Pool Size: 33 (1848 bytes; 0 MB) allocated, 20 (1120 bytes; 0 MB) used
    Player Count: 1 / 20; [EntityPlayerMP['TheAmateis'/48, l='world', x=63,26, y=67,00, z=60,91](TheAmateis at 63.26245040868265,67.0,60.905744304639406)]
    Is Modded: Definitely; Server brand changed to 'mcpc,craftbukkit,fml,forge'
    Type: Dedicated Server (map_server.txt)
    

    :::


    La classe de l'event

    :::

    package viruz.zeamateis.event;
    
    import net.minecraft.block.BlockDirt;
    import net.minecraft.block.BlockGrass;
    import net.minecraft.block.BlockStone;
    import net.minecraftforge.event.ForgeSubscribe;
    import net.minecraftforge.event.world.BlockEvent;
    import cpw.mods.fml.client.FMLClientHandler;
    
    public class BreakEvent
    {
    @ForgeSubscribe
    public void breakEvent(BlockEvent.BreakEvent event)
    {
    if(event.block instanceof BlockGrass || event.block instanceof BlockStone || event.block instanceof BlockDirt)
    {
    if(FMLClientHandler.instance().getClient().thePlayer.capabilities.isCreativeMode)
    {
    event.setCanceled(false);
    }
    else
    {
    event.setCanceled(true);
    }
    }
    }
    
    }
    
    

    :::

    L'event est enregistré comme ça dans la fonction Init

    MinecraftForge.EVENT_BUS.register(new BreakEvent());</init>


  • Moddeurs confirmés Rédacteurs Administrateurs

    FMLClientHandler.instance().getClient().thePlayer.capabilities.isCreativ?eMode n'existe pas en client.
    remplace par event.getPlayer().capabilities.isCreativ?eMode



  • Voilà ! Merci !


Log in to reply