1.12.2 Faire un dab



  • Salut ! je veux faire une animation de dab mais ca ne va pas.
    Quelqu'un pourrait il m'aider ?

    PacketHandler

    public class PacketHandler
    {
        public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MODID);
    
        public static void init()
        {
            INSTANCE.registerMessage(MessageDab.class, MessageDab.class, 0, Side.SERVER);
            INSTANCE.registerMessage(MessageUpdate.class, MessageUpdate.class, 1, Side.CLIENT);
        }
    }
    

    ModKeys

    public class ModKeys
    {
        public static KeyBinding dab;
        
        public static void init()
        {
            dab = new KeyBinding("key.dab", Keyboard.KEY_R, "key.categories.Dab");
        }
        
        public static void register()
        {
            ClientRegistry.registerKeyBinding(dab);
        }
    }
    
    

    MessageUpdate

    public class MessageUpdate implements IMessage, IMessageHandler<MessageUpdate, IMessage>
    {
        private int playerId;
        private boolean dabbing;
    
        public MessageUpdate()
        {
        }
    
        public MessageUpdate(int playerId, boolean dabbing)
        {
            this.playerId = playerId;
            this.dabbing = dabbing;
        }
    
        @Override
        public void toBytes(ByteBuf buf)
        {
            buf.writeInt(playerId);
            buf.writeBoolean(dabbing);
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
            this.playerId = buf.readInt();
            this.dabbing = buf.readBoolean();
        }
    
        @Override
        public IMessage onMessage(MessageUpdate message, MessageContext ctx) 
        {
            Entity entity = Minecraft.getMinecraft().world.getEntityByID(message.playerId);
            if(entity instanceof EntityPlayer)
            {
                entity.getEntityData().setBoolean("dabbing", message.dabbing);
            }
            return null;
        }
    }
    

    ClientProxy

    public class ClientProxy extends CommonProxy implements IProxy
    {
        @Override
        public void registerItemRederer(Item item, int meta)
        {
            ModelLoader.setCustomModelResourceLocation(item, meta, new ModelResourceLocation(item.getRegistryName(), "inventory"));
            
        }
        
        @Override
        public void init()
        {
            MinecraftForge.EVENT_BUS.register(new InputEvent());
            
            ModelPlayerAPI.register(Reference.MODID, ModelPlayerOverride.class);
            
            ModKeys.init();
            ModKeys.register();
        }
        
    }
    
    

    IProxy

    public interface IProxy 
    {
        public void init();
    }
    

    Main

    @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION, dependencies = Reference.DEPENDENCIES)
    public class Main
    {
        public static final CreativeTabs BadassTab = new BadassTab("BadassTab");
    
        @Instance
        public static Main instance;
            
        @SidedProxy(clientSide = Reference.CLIENT, serverSide = Reference.COMMON)
        public static CommonProxy proxy;
        public static IProxy proxy2;
    
        @EventHandler
        public static void preInit(FMLPreInitializationEvent e)
        {
            RegistryHandler.preInitRegistries();
            Config.init(e.getSuggestedConfigurationFile());
            
            PacketHandler.init();
        }
        
        @EventHandler
        public static void init(FMLInitializationEvent e)
        {
            RegistryHandler.initRegistries();
            proxy2.init();
        }
        
        @EventHandler
        public static void postInit(FMLPostInitializationEvent e)
        {
            
        }
        
    }
    

    Config

    public class Config
    {
    public static Configuration config;
        
        public static final String CATEGORY_GENERAL = "general";
        
        public static boolean showHint;
        
        public static void init(File file)
        {
            if (config == null)
            {
                config = new Configuration(file);
            }
            loadConfig();
            config.save();
        }
        
        public static void loadConfig()
        {
            showHint = config.getBoolean("show-hint", CATEGORY_GENERAL, true, "Hint the key to Dab upon joining a world.");
        }
    }
    
    

    Reference

    public class Reference
    {
        public static final String MODID = "badassmod";
        public static final String NAME = "The Badass Mod";
        public static final String VERSION = "1.0.0";
        public static final String CLIENT = "com.drastic.mod.proxy.ClientProxy";
        public static final String COMMON = "com.drastic.mod.proxy.CommonProxy";
        
        public static final int ENTITY_TROLL_GOD = 120;
        public static final int ENTITY_GB_TNT = 121;
        public static final int ENTITY_Drastic_TNT = 122;
        public static final String DEPENDENCIES = "required-after:RenderPlayerAPI@[1.0,)";
    
    }
    
    

    CommonProxy

    public class CommonProxy
    {
        public void registerItemRederer(Item item, int meta)
        {
            
        }
        
    }
    
    

    MessageDab

    
    public class MessageDab implements IMessage, IMessageHandler<MessageDab, IMessage>
    {
        private boolean dabbing;
    
        public MessageDab()
        {
        }
    
        public MessageDab(boolean dabbing)
        {
            this.dabbing = dabbing;
        }
    
        @Override
        public void toBytes(ByteBuf buf)
        {
            buf.writeBoolean(dabbing);
        }
    
        @Override
        public void fromBytes(ByteBuf buf)
        {
            this.dabbing = buf.readBoolean();
        }
    
        @Override
        public IMessage onMessage(MessageDab message, MessageContext ctx) 
        {
            EntityPlayer player = ctx.getServerHandler().player;
            player.getEntityData().setBoolean("dabbing", message.dabbing);
            PacketHandler.INSTANCE.sendToAllAround(new MessageUpdate(player.getEntityId(), message.dabbing), new TargetPoint(player.dimension, player.posX, player.posY, player.posZ, 64));
            return null;
        }
    }
    

    InputEvent

    public class InputEvent
    {
        public static boolean dabbing = false;
        public static boolean printed = false;
        
        public static final int MAX_DABBING_HELD = 8;
        public static int dabbingHeld = 0;
        public static int prevDabbingHeld = 0;
        
        public static float firstPersonPartialTicks;
    
        public String connectionType;
    
        
        @SubscribeEvent
        public void onKeyInput(KeyInputEvent event)
        {
            if(ModKeys.dab.isKeyDown())
            {
                if(!dabbing)
                {
                    if("MODDED".equals(connectionType))
                        PacketHandler.INSTANCE.sendToServer(new MessageDab(true));
                    dabbing = true;
                }
            }
            else
            {
                if("MODDED".equals(connectionType))
                    PacketHandler.INSTANCE.sendToServer(new MessageDab(false));
                dabbing = false;
            }
        }
        
        @SubscribeEvent
        public void onTick(TickEvent.ClientTickEvent event) 
        {
            prevDabbingHeld = dabbingHeld;
            
            if(dabbing && dabbingHeld < MAX_DABBING_HELD) 
            {
                dabbingHeld++;
            } 
            else if(!dabbing && dabbingHeld > 0)
            {
                dabbingHeld--;
            }
        }
        
        @SubscribeEvent
        public void onJoin(PlayerEvent.PlayerLoggedInEvent event)
        {
            if(!printed)
            {
                event.player.sendMessage(new TextComponentString(TextFormatting.GOLD.toString() + TextFormatting.BOLD.toString() + "Press " + Keyboard.getKeyName(ModKeys.dab.getKeyCode()) + " to Dab!"));
                printed = true;
            }
        }
        
        @SubscribeEvent
        public void onRender(RenderHandEvent event) 
        {
            firstPersonPartialTicks = event.getPartialTicks();
        }
    
        @SubscribeEvent
        public void onConnect(FMLNetworkEvent.ClientConnectedToServerEvent event)
        {
            this.connectionType = event.getConnectionType();
        }
    }
    
    

    ModelPlayerOverride

    public class ModelPlayerOverride extends ModelPlayerBase
    {
        private static float thirdPersonPartialTicks;
        
        public ModelPlayerOverride(ModelPlayerAPI modelPlayerAPI)
        {
            super(modelPlayerAPI);
        }
        
        @Override
        public void afterSetLivingAnimations(EntityLivingBase arg0, float arg1, float arg2, float partialTicks) 
        {
            thirdPersonPartialTicks = partialTicks;
        }
    
        @Override
        public void afterSetRotationAngles(float paramFloat1, float paramFloat2, float paramFloat3, float paramFloat4, float paramFloat5, float paramFloat6, net.minecraft.entity.Entity paramEntity)
        {
            boolean isOurPlayer = paramEntity.getEntityId() == Minecraft.getMinecraft().player.getEntityId();
            
            if(paramEntity.getEntityData().getBoolean("dabbing") || (isOurPlayer && InputEvent.prevDabbingHeld > 0))
            {
                float heldPercent = (InputEvent.prevDabbingHeld + (InputEvent.dabbingHeld - InputEvent.prevDabbingHeld) * thirdPersonPartialTicks) / InputEvent.MAX_DABBING_HELD;
                
                if(!isOurPlayer) heldPercent = 1.0F;
                
                this.modelPlayer.bipedRightArm.rotateAngleX = (float) Math.toRadians(-90F * heldPercent);
                this.modelPlayer.bipedRightArm.rotateAngleY = (float) Math.toRadians(-35F * heldPercent);
                
                this.modelPlayer.bipedRightArmwear.rotateAngleX = (float) Math.toRadians(-90F * heldPercent);
                this.modelPlayer.bipedRightArmwear.rotateAngleY = (float) Math.toRadians(-35F * heldPercent);
                
                this.modelPlayer.bipedLeftArm.rotateAngleX = (float) Math.toRadians(15F * heldPercent);
                this.modelPlayer.bipedLeftArm.rotateAngleY = (float) Math.toRadians(15F * heldPercent);
                this.modelPlayer.bipedLeftArm.rotateAngleZ = (float) Math.toRadians(-110F * heldPercent);
                
                this.modelPlayer.bipedLeftArmwear.rotateAngleX = (float) Math.toRadians(15F * heldPercent);
                this.modelPlayer.bipedLeftArmwear.rotateAngleY = (float) Math.toRadians(15F * heldPercent);
                this.modelPlayer.bipedLeftArmwear.rotateAngleZ = (float) Math.toRadians(-110F * heldPercent);
    
                float rotationX = paramEntity.rotationPitch;
                this.modelPlayer.bipedHead.rotateAngleX = (float) Math.toRadians(-rotationX * heldPercent) + (float) Math.toRadians(45F * heldPercent + rotationX);
    
                float rotationY = (((EntityPlayer) paramEntity).renderYawOffset - paramEntity.rotationYaw);
                this.modelPlayer.bipedHead.rotateAngleY = (float) Math.toRadians(rotationY * heldPercent) + (float) Math.toRadians(35F * heldPercent - rotationY);
    
                this.modelPlayer.bipedHeadwear.rotateAngleX = (float) Math.toRadians(45F * heldPercent);
                this.modelPlayer.bipedHeadwear.rotateAngleY = (float) Math.toRadians(35F * heldPercent);
                
                if(isOurPlayer)
                {
                    if(Minecraft.getMinecraft().gameSettings.thirdPersonView == 0)
                    {
                        heldPercent = (InputEvent.prevDabbingHeld + (InputEvent.dabbingHeld - InputEvent.prevDabbingHeld) * InputEvent.firstPersonPartialTicks) / InputEvent.MAX_DABBING_HELD;
    
                        GlStateManager.rotate(-50F * heldPercent, 1, 0, 0);
                        GlStateManager.rotate(30F * heldPercent, 0, 1, 0);
                        GlStateManager.rotate(-30F * heldPercent, 0, 0, 1);
                        GlStateManager.translate(-0.3 * heldPercent, -0.2 * heldPercent, -0.5 * heldPercent);
                    }
                }
            }
        }
    }
    

    Merci !



  • finalement j'ai refait pareil sur un mod vide et ca marche. je n'ai qua le mettre en dépendence



  • @Drastic le crash report :

    ---- Minecraft Crash Report ----
    // There are four lights!
    
    Time: 2/21/20 10:49 PM
    Description: There was a severe problem during mod loading that has caused the game to fail
    
    net.minecraftforge.fml.common.LoaderExceptionModCrash: Caught exception from The Badass Mod (badassmod)
    Caused by: java.lang.NullPointerException
    	at com.drastic.mod.Main.init(Main.java:48)
    	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:639)
    	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.initializeMods(Loader.java:749)
    	at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:336)
    	at net.minecraft.client.Minecraft.init(Minecraft.java:582)
    	at net.minecraft.client.Minecraft.run(Minecraft.java:422)
    	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:25)
    
    
    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: Windows 10 (amd64) version 10.0
    	Java Version: 1.8.0_181, Oracle Corporation
    	Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
    	Memory: 712927672 bytes (679 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
    	JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
    	IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
    	FML: MCP 9.42 Powered by Forge 14.23.5.2847 7 mods loaded, 7 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 |
    	|:----- |:--------------- |:------------ |:-------------------------------- |:--------- |
    	| LCHI  | minecraft       | 1.12.2       | minecraft.jar                    | None      |
    	| LCHI  | mcp             | 9.42         | minecraft.jar                    | None      |
    	| LCHI  | FML             | 8.0.99.99    | forgeSrc-1.12.2-14.23.5.2847.jar | None      |
    	| LCHI  | forge           | 14.23.5.2847 | forgeSrc-1.12.2-14.23.5.2847.jar | None      |
    	| LCHI  | RenderPlayerAPI | 1.0          | minecraft.jar                    | None      |
    	| LCHE  | badassmod       | 1.0.0        | bin                              | None      |
    	| LCH   | examplemod      | 1.0          | RenderPlayerAPI-1.12.2-1.0.jar   | None      |
    
    	Loaded coremods (and transformers): 
    RenderPlayerAPIPlugin (RenderPlayerAPI-1.12.2-1.0.jar)
      api.player.forge.RenderPlayerAPITransformer
    	GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.6.0 NVIDIA 441.66' Renderer: 'GeForce GTX 1050/PCIe/SSE2'
    


  • UP SVP


  • Moddeurs confirmés Rédacteurs Administrateurs

    Bonjour,
    La ligne 48 de la classe Main c'est laquelle ?



  • proxy2.init



  • @robin4002 ya une possibilité de passer en vocal ?


  • Moddeurs confirmés Rédacteurs Administrateurs

    Normal d'avoir un NPE ... Ta variable proxy2 n'est jamais initialisé.
    Et j'ai l'impression qu'elle ne sert à rien de toute façon. Pourquoi l'avoir créé ?

    Non, je ne fais pas de support en vocal.



  • finalement j'ai refait pareil sur un mod vide et ca marche. je n'ai qua le mettre en dépendence


Log in to reply