Jump to content

Prevent FULL AUTO item use


xanderindalzone

Recommended Posts

Hi, I had these variables in my Gun's class but I believe these wont work properly and can bug every Gun item ingame, since these 4 variables can change in the code.

I think I can recode the last 3 variables inside methods so they work the same, but I dont know how to recode the "ticks_trigger_pressed" variable to make it work exactly the same so it doesn't bug the rest of guns in the game.

I really need it to make the gun fire in semi auto mode. That variable counts the ticks that the ItemUseBindingKey is pressed.

Quote

    //Maintenance Attributes
    protected int ticks_trigger_pressed=0; 
    protected boolean is_aiming=false;
    protected boolean is_reloading=false;
    public static double PREVIOUS_FOV=Minecraft.getInstance().gameSettings.fov;

 

Here are the Gun methods where I use this variable:

Quote

    @Override
    public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
        
        //PERMITE DISPARAR DESPUES DE QUE SE SUELTE EL CLICK DERECHO(EN ARMAS SEMIAUTOMATICAS)        
        if(!Minecraft.getInstance().gameSettings.keyBindUseItem.isKeyDown())
        {
            ticks_trigger_pressed=0;
        }
        if(entityIn instanceof PlayerEntity) 
        {
        ReloadHandler(worldIn, (PlayerEntity) entityIn);
        }

        //ZoomHandler();//DEHABILITADO POR AHORA <--------------
    }
    
public ActionResult<ItemStack> onItemRightClickPrivateEvent(World worldIn, PlayerEntity playerIn) {
        
        if(ticks_trigger_pressed>1)
        {
            return new ActionResult<ItemStack>(ActionResultType.SUCCESS, playerIn.getHeldItemMainhand());
        }
        ticks_trigger_pressed++;
        
        if(playerIn.getHeldItemMainhand().getDamage()<this.gun_mag) {
            
            shootGun(worldIn, playerIn); //DISPARAR ARMA
            playerIn.getHeldItemMainhand().damageItem(1, playerIn, null);
            if(!(playerIn.getHeldItemMainhand().getDamage()<this.gun_mag)) 
            {            
                worldIn.playSound(null, playerIn.getPosition(), SoundEvents.BLOCK_ANVIL_PLACE, SoundCategory.PLAYERS, 1.0F, 3.0F);
            }
        }
        else 
        {
            worldIn.playSound(null, playerIn.getPosition(), GunSoundEvents.SOUND_no_ammo_click, SoundCategory.PLAYERS, 1.0F, 1.0F);
        }
        return new ActionResult<ItemStack>(ActionResultType.SUCCESS, playerIn.getHeldItemMainhand());
    }

PD: the second method doesnt have @Override because I use it calling it from an event.

 

 

Is there any other way that I can achieve this without using Object attribute variables in the Guns Class?

Link to comment
Share on other sites

Items are singletons, there is only one instance of them therefor you cannot just put variables in them. You should write these values to the NBT of the ItemStack your item is in.

 

Edit: On a separate note, if you call that method from a clientside event (like a keybind press) it won't do anything without packets, just use the methods provided to you from Item.

Edited by Novârch

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

3 hours ago, diesieben07 said:

This is already broken, you are on the server here (potentially). The server has no idea about key bindings or even the Minecraft class.

 

You have to use the "use item" mechanic that is already provided by Minecraft (see bow and similar items).

Is there an alternative to Minecraft.getInstance()? Because there are some events where I need to access what's the item that the player is holding and I dont know how to access the player with the event Object.

 

Here for example:

Quote

@SubscribeEvent
        public static void displayGunStatus(RenderGameOverlayEvent.Text event) {
            if(!ServerLifecycleHooks.getCurrentServer().isSinglePlayer())
            {
                return;
            }
            PlayerEntity player = Minecraft.getInstance().player;
            int yd = event.getWindow().getScaledHeight();
            int xd = event.getWindow().getScaledWidth();
            int x=(int) (xd*0.01);
            int y=(int) (yd*0.8);
            int x2=(int) (xd*0.5);
            int y2=(int) (yd*0.8);
            if(Minecraft.getInstance().player.getHeldItemMainhand().getItem() instanceof GunBase)
            {
                GunBase gun = (GunBase) player.getHeldItemMainhand().getItem();
                FontRenderer TextRenderer = Minecraft.getInstance().fontRenderer;
                String text = "Gun AMMO: ";
                String textAmmo = "["+(gun.gun_mag-player.getHeldItemMainhand().getDamage())+"/"+gun.gun_mag+"]";
                TextRenderer.drawStringWithShadow(text, x+10, y, 16777215);
                TextRenderer.drawStringWithShadow(textAmmo, x+10, y+10, 16245549);
                if(!((gun.gun_mag-player.getHeldItemMainhand().getDamage())>0))
                {
                    String text1="No AMMO!";
                    String text2="Press R to reload!";
                    TextRenderer.drawStringWithShadow(text1, x+10, y+20, 16730698);
                    TextRenderer.drawStringWithShadow(text2, x+10, y+30, 16777215);        
                }
                if(player.getCooldownTracker().hasCooldown(gun)) 
                {
                    
                    String text3="Reloading!";
                    System.out.println(text3);
                    TextRenderer.drawStringWithShadow(text3, x2+10, y2, 61256);
                }
            }

        }

Would "@OnlyIn(Dist.CLIENT)" work? I asume that makes the method call only in client but I could be wrong XD
 

Also I dont know if this code prevents the mod in servers from running the event code, to prevent the server to access the Minecraft.getInstance(), i just found the code in some random post XD:

Quote

           if(!ServerLifecycleHooks.getCurrentServer().isSinglePlayer())
            {
                return;
            }

 

 

 

PD: the event displays the ammo left in the mag when the player is holding a gun

Edited by xanderindalzone
Link to comment
Share on other sites

44 minutes ago, xanderindalzone said:

if(!ServerLifecycleHooks.getCurrentServer().isSinglePlayer())

And now your this code will be useless in multiplayer.

Good job.

Oh also:

44 minutes ago, xanderindalzone said:

PlayerEntity player = Minecraft.getInstance().player;

Having dumped out early in that way does not stop this line from crashing the server.

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 hours ago, diesieben07 said:

In your example however you have a client-only event, so of course you can access Minecraft#player.

So let me get this clear.... all the events located in the package "package net.minecraftforge.client.event;" are ONLY called in client-side? so is it safe to use Minecraft.getInstance() in those?

 

Link to comment
Share on other sites

8 hours ago, diesieben07 said:

You have to use the "use item" mechanic that is already provided by Minecraft (see bow and similar items).

Quote

public class GunBase extends BowItem

Quote

    @Override
    public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
        System.out.println("STOPPED USING");
        super.onPlayerStoppedUsing(stack, worldIn, entityLiving, timeLeft);
    }

I extended the gun class from BowItem but this method which it says its supposed to be called when you stop holding right click with the item(Gun in this case), its never being called.

Link to comment
Share on other sites

12 minutes ago, diesieben07 said:

Post more of your code.

You probably don't want to extend BowItem though.

 

 

The Gun Event that calls the Gun using method: 

(I was using this event method instead of the item method because I didnt want the gun to do the default use animation)

(I temporaly disabled the setCanceled() line to see if that was causing the "onPlayerStoppedUsing" not working)

Quote

    @SubscribeEvent    //DISPARAR SIN ANIMACION
    public static void shootGun(PlayerInteractEvent.RightClickItem event)
    {
        PlayerEntity player = event.getPlayer();
        if(player != null){
            Item item = player.getHeldItemMainhand().getItem();
            if(item instanceof GunBase){
                //event.setCanceled(true);
                ((GunBase) item).onItemRightClickPrivateEvent(player.world, player);
            }
        }
    }

 

 

Gun class:

Quote

public class GunBase extends BowItem
{
    
    public int gun_mag;
    
    public Item ammo_used;
    public float gun_damage;
    public float gun_accuracy;
    public float gun_recoil;
    public float gun_bullet_speed;
    public int gun_firing_rate;
    public int gun_reload_cooldown;
    public int gun_reload_cooldown_cock;
    public float zoom_fov;
    public boolean gun_is_full_auto;
    
    //=============
    //BROKEN CODE!! NEEDS FIXING
    //=============
    //Maintenance Attributes
    protected int ticks_trigger_pressed=0; 
    protected boolean is_aiming=false;
    protected boolean is_reloading=false;
    public static double PREVIOUS_FOV=Minecraft.getInstance().gameSettings.fov;
    //=============
    

    public GunBase(Properties properties) {
        super(properties);
        Init.ModItems.add(this);
    }
    
    
    
    //=============
    //BROKEN CODE!! NEEDS FIXING
    //=============
    public boolean isAiming() 
    {
        return this.is_aiming;
    }
    
//==========================================================================================================
//COMPORTAMIENTOS DEL ITEM
    
    //CANCELAR ANIMACION DE SWING DEL ITEM
    @Override
    public boolean onEntitySwing(ItemStack stack, LivingEntity entity) {return true;}
    //CANCELA GOLPES A ENTITIES
    @Override
    public boolean onLeftClickEntity(ItemStack stack, PlayerEntity player, Entity entity){return true;}
    //CANCELA PODER ROMPER BLOQUES CON ESTE ITEM
    @Override
    public boolean canPlayerBreakBlockWhileHolding(BlockState state, World worldIn, BlockPos pos, PlayerEntity player){return false;}
    
    @Override
    public Multimap<String, AttributeModifier> getAttributeModifiers(EquipmentSlotType equipmentSlot) {
        Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(equipmentSlot);
        multimap.put(SharedMonsterAttributes.ATTACK_SPEED.getName(), new AttributeModifier(ATTACK_SPEED_MODIFIER, "Tool modifier", 20, Operation.ADDITION));
        return multimap;
    }
    
//==========================================================================================================    
    
    //PERMITE DISPARAR DESPUES DE QUE SE SUELTE EL CLICK DERECHO(EN ARMAS SEMIAUTOMATICAS)    
    @Override
    public void onPlayerStoppedUsing(ItemStack stack, World worldIn, LivingEntity entityLiving, int timeLeft) {
        System.out.println("STOPPED USING");
        super.onPlayerStoppedUsing(stack, worldIn, entityLiving, timeLeft);
    }
    
    

    
    
    @Override
    public void inventoryTick(ItemStack stack, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) {
        
        
        if(entityIn instanceof PlayerEntity) 
        {
        ReloadHandler(worldIn, (PlayerEntity) entityIn);
        }

        //ZoomHandler();//DEHABILITADO POR AHORA <--------------
    }
    
public ActionResult<ItemStack> onItemRightClickPrivateEvent(World worldIn, PlayerEntity playerIn) {
        
        //DEHABILITADO POR AHORA <--------------
        if(ticks_trigger_pressed>1&&false)
        {
            
            return new ActionResult<ItemStack>(ActionResultType.SUCCESS, playerIn.getHeldItemMainhand());
        }
        ticks_trigger_pressed++;
        
        if(playerIn.getHeldItemMainhand().getDamage()<this.gun_mag) {
            
            shootGun(worldIn, playerIn); //DISPARAR ARMA
            playerIn.getHeldItemMainhand().damageItem(1, playerIn, null);
            if(!(playerIn.getHeldItemMainhand().getDamage()<this.gun_mag)) 
            {            
                worldIn.playSound(null, playerIn.getPosition(), SoundEvents.BLOCK_ANVIL_PLACE, SoundCategory.PLAYERS, 1.0F, 3.0F);
            }
        }
        else 
        {
            worldIn.playSound(null, playerIn.getPosition(), GunSoundEvents.SOUND_no_ammo_click, SoundCategory.PLAYERS, 1.0F, 1.0F);
        }
        return new ActionResult<ItemStack>(ActionResultType.SUCCESS, playerIn.getHeldItemMainhand());
    }
    

//===========================================================================================
//PRIVATE METHOD
//===========================================================================================
    private void shootGun(World worldIn, PlayerEntity playerIn) 
    {
        double posX = playerIn.getPosX();
        double posY = playerIn.getPosY();
        double posZ = playerIn.getPosZ();
        Vec3d look = playerIn.getLookVec();
        World world = playerIn.getEntityWorld();
        
        
        //ArrowEntity bullet = new ArrowEntity(world, 1.0D, 1.0D, 1.0D);
        PistolBulletEntity bullet = new PistolBulletEntity(Init.PISTOL_BULLET_ENTITY, 1.0D, 1.0D, 1.0D, world);
        
        //=======================================================
        //PROPIEDADES DEL DISPARO
        //=======================================================
        //SPAWNEAR FOGONAZO
        worldIn.addParticle(ParticleTypes.CLOUD, posX+(look.x*1.5D), posY+(look.y*1.5D)+1.5D, posZ+(look.z*1.5D), 0.0D, 0.5D, 0.0D);
        
        //POSICION INICIAL DE LA BALA
        if(playerIn.rotationPitch>60) 
        {
            bullet.setPosition(posX+(look.x*1.3D), posY+(look.y*1.5D)+1.0D, posZ+(look.z*1.3D));    
        }
        else
        {
            bullet.setPosition(posX+(look.x*1.3D), posY+(look.y*1.5D)+1.3D, posZ+(look.z*1.3D));
        }
        
        
        //ESTABLECE EL DAÑO DE LA BALA
        bullet.setBulletDamage(this.gun_damage);
        
        //ESTABLECE EL ALCANCE DE LA BALA
        bullet.setVelocity(look.x*this.gun_bullet_speed, (look.y*this.gun_bullet_speed), look.z*this.gun_bullet_speed);
        
        //ESTABLECE LA CADENCIA DEL ARMA
        playerIn.getCooldownTracker().setCooldown(this, this.gun_firing_rate); //TICKS - 30 TICKS = 1 seg
        
        //ESTABLECE EL RETROCESO MAXIMO DEL DISPARO
        float recoil_pitch = (float) -(((gun_recoil)*Math.random()));    //ES SIEMPRE NEGATIVO, SIEMPRE TENDRA RETROCESO HACIA ARRIBA
        float recoil_yaw = (float) ((float) gun_recoil-((gun_recoil*2)*Math.random()));
        playerIn.rotationPitch=playerIn.rotationPitch+recoil_pitch;
        playerIn.rotationYaw=playerIn.rotationYaw+recoil_yaw;
        
        

        if(!world.isRemote)
        {
            world.addEntity(bullet);
            shootingGunSound(worldIn, playerIn, this);
        }
        
        
    }


    private void shootingGunSound(World worldIn, PlayerEntity playerIn, GunBase gun) 
    {
        if(gun instanceof Colt1911) 
        {
            worldIn.playSound(null, playerIn.getPosition(), GunSoundEvents.SOUND_shot_Colt1911, SoundCategory.PLAYERS, 1.0F, 1.0F);
        }
    }
    
    private void reloadingGunSound(World worldIn, PlayerEntity playerIn, GunBase gun, boolean cock_reload) 
    {
        if(gun instanceof Colt1911) 
        {
            if(cock_reload)
            {
                worldIn.playSound(null, playerIn.getPosition(), GunSoundEvents.SOUND_reload_Colt1911_cock, SoundCategory.PLAYERS, 1.0F, 1.0F);
                playerIn.getCooldownTracker().setCooldown(Init.PISTOL_COLT_1911, this.gun_reload_cooldown_cock); //TICKS - 30 TICKS = 1 seg
                
            }
            else
            {
                worldIn.playSound(null, playerIn.getPosition(), GunSoundEvents.SOUND_reload_Colt1911, SoundCategory.PLAYERS, 1.0F, 1.0F);
                playerIn.getCooldownTracker().setCooldown(Init.PISTOL_COLT_1911, this.gun_reload_cooldown); //TICKS - 30 TICKS = 1 seg
            }
        }
    }
    
    
    
    
    
    
    
    private boolean ReloadHandler(World worldIn, PlayerEntity player) {
        int ammo_left = (this.gun_mag-player.getHeldItemMainhand().getDamage());    
        boolean cock_reload = false;
        
            if(CustomGunsMod.KEY_GUN_RELOAD.isKeyDown())
            {
                
                //COMPRUEBA SI EL CARGADOR SE PUEDE RECARGAR
                if(ammo_left!=this.gun_mag)    
                {
                    if(ammo_left==0) {cock_reload=true;}
                    
                    
                    //COMPRUEBA SI EL JUGADOR TIENE MUNICION EN EL INVENTARIO
                    if(player.inventory.hasItemStack(new ItemStack(this.ammo_used))) 
                    {
                        for(int slotIndex=0; slotIndex<player.inventory.mainInventory.size(); slotIndex++) 
                        {
                            int ammo_needed = this.gun_mag-ammo_left;
                            ItemStack item = player.inventory.getStackInSlot(slotIndex).copy();
                            if(item.getItem() == this.ammo_used)
                            {
                                if(!worldIn.isRemote) 
                                {
                                    ammo_left=removeAmmo(player, ammo_needed, ammo_left, item, slotIndex);
                                }
                                else
                                {
                                    ammo_left=removeAmmo(player, ammo_needed, ammo_left, item, slotIndex);
                                }
                                reloadingGunSound(worldIn, player, this, cock_reload);
                                is_reloading=true;
                            }
                        }
                        return true;
                    }
                }
            }
            return false;
        }
        
    //DEVUELVE LA MUNICION QUE FALTA
    private int removeAmmo(PlayerEntity player, int ammo_needed, int ammo_left, ItemStack item, int slotIndex)
    {
        if(ammo_needed<item.getCount())
        {
            item.shrink(ammo_needed);
            player.inventory.setInventorySlotContents(slotIndex, item);
            player.getHeldItemMainhand().damageItem(-ammo_needed, player, null);
            ammo_left=this.gun_mag;
        }
        else
        {
            player.inventory.setInventorySlotContents(slotIndex, new ItemStack(Blocks.AIR));
            player.getHeldItemMainhand().damageItem(-item.getCount(), player, null);
            ammo_left=ammo_left+item.getCount();
        }
        return ammo_left;
    }

    
}

 

PD: I know I have some broken code, i'll fix that later

Link to comment
Share on other sites

13 hours ago, diesieben07 said:

As for your issue... please post a working Git repo so we can actually debug this. This is impossible to do just starting at the code because this is a complicated problem.

Quote

I know I still have some broken attributes in the GunBase class, I'll fix them later...

 

By the way, the PASS type didn't seem to cancel the item use animation, but the FAIL type does cancel it. But the animation is still playing when the item damage is updating(when the gun fires or reloads).

 

PD: I didn't have time to properly upload the project to the repo, but all the java classes are there.

Edited by xanderindalzone
Link to comment
Share on other sites

1 hour ago, xanderindalzone said:

PD: I didn't have time to properly upload the project to the repo, but all the java classes are there.

You need to post a proper Gradle repo, as otherwise other people cannot debug it.

 

As for your mod, I would suggest starting off with a simple mod that adds a few items/blocks first before tackling a gun mod. It seems that what you are trying to do is beyond your knowledge of modding, and therefore is hard for you to do everything at once. A less steep learning curve would suit you better (start with adding items, then adding functionalities to them, then learn about sides and networking, then entities, etc).

Edited by DavidM

Some tips:

Spoiler

Modder Support:

Spoiler

1. Do not follow tutorials on YouTube, especially TechnoVision (previously called Loremaster) and HarryTalks, due to their promotion of bad practice and usage of outdated code.

2. Always post your code.

3. Never copy and paste code. You won't learn anything from doing that.

4. 

Quote

Programming via Eclipse's hotfixes will get you nowhere

5. Learn to use your IDE, especially the debugger.

6.

Quote

The "picture that's worth 1000 words" only works if there's an obvious problem or a freehand red circle around it.

Support & Bug Reports:

Spoiler

1. Read the EAQ before asking for help. Remember to provide the appropriate log(s).

2. Versions below 1.11 are no longer supported due to their age. Update to a modern version of Minecraft to receive support.

 

 

Link to comment
Share on other sites

Quote

I managed to upload the full project to that same repo, I had to update the paths in the Run .launch files to be able to run the game from eclipse again because I had to clone the repo to a different local folder because it didn't let me push the changes of my existing folder where the project was at.

 

I hope you can test it yourself and tell me how to stop the item from spamming bullets while holding right click, cus for the current gun I only what it to fire once each right click since its semi automatic.

 

PD: Ignore the "Reloading" message that pops up everytime the gun shoots, i forgot to remove that since that part of the code is not ready.

Edited by xanderindalzone
Link to comment
Share on other sites

Also, have this in mind, I have custom key settings for my minecraft, so the mod keybinding "R" is not actually my current reload Key(but it is R by default) it currently just says "Press R to Reload" in the message when the gun has no ammo because thats the default key of that new KeyBinding.

Link to comment
Share on other sites

3 minutes ago, xanderindalzone said:

is not actually my current reload Key(but it is R by default) it currently just says "Press R to Reload"

You can use KeyBind#getLocalizedName to get what you want here.

  • Thanks 1

It's sad how much time mods spend saying "x is no longer supported on this forum. Please update to a modern version of Minecraft to receive support".

Link to comment
Share on other sites

22 minutes ago, diesieben07 said:
  • You cannot do this, KeyBinding is a client-only class.
  • You cannot do this, RenderTypeLookup is a client-only class.
  • Please don't spam the log with things like this. Nobody cares.
  • You are subscribing to a lot of client-only events in this class. Client-only events must be in a separate event handler and you must explicitly tell @EventBusSubscriber that it is a client-only event handler (by passing Dist.CLIENT).
  • You cannot create registry entries in static initializers (here, here). Use the appropriate registry events or DeferredRegister.
  • You never register the sound events you create here.
  • Do not use a "base class" for blocks and items (BlockBase, ItemBase, BlockItemBase in your case). Using inheritance for code-reuse is an antipattern.
  • You are now extending BowItem, because I told you to use the "item use" mechanic as seen in the bow. I did not tell you to extend BowItem. You also completely bypass the most important method of BowItem, because you override it without calling super: onItemRightClick. You need to call setActiveHand so that the game knows the Item is being used. onItemRightClick will not trigger again then until right click is released (or the max use duration is reached). Again: Look at BowItem. Don't extend it.

Thank you for taking your time to analize my code, I'll start fixing stuff when I have a moment.

Link to comment
Share on other sites

5 hours ago, diesieben07 said:
  • You cannot do this, KeyBinding is a client-only class.
  • You cannot do this, RenderTypeLookup is a client-only class.
  • Please don't spam the log with things like this. Nobody cares.
  • You are subscribing to a lot of client-only events in this class. Client-only events must be in a separate event handler and you must explicitly tell @EventBusSubscriber that it is a client-only event handler (by passing Dist.CLIENT).
  • You cannot create registry entries in static initializers (here, here). Use the appropriate registry events or DeferredRegister.
  • You never register the sound events you create here.
  • Do not use a "base class" for blocks and items (BlockBase, ItemBase, BlockItemBase in your case). Using inheritance for code-reuse is an antipattern.
  • You are now extending BowItem, because I told you to use the "item use" mechanic as seen in the bow. I did not tell you to extend BowItem. You also completely bypass the most important method of BowItem, because you override it without calling super: onItemRightClick. You need to call setActiveHand so that the game knows the Item is being used. onItemRightClick will not trigger again then until right click is released (or the max use duration is reached). Again: Look at BowItem. Don't extend it.

 

 

I've done 2, 3 and 4 from the list atm, but I dont know if this alternative for the transparent glass is appropiate.

 

Quote

@Mod.EventBusSubscriber(modid = CustomGunsMod.MOD_ID, bus = Bus.FORGE, value = Dist.CLIENT)
public class ClientBlockEvents 
{
    
    /*
     * Renders the Glass Blocks as transparent
     */
    @SubscribeEvent
    public static void renderTransparentGlass(RenderGameOverlayEvent event)
    {
        //Renderiza este bloque con textura trasnparente
        RenderTypeLookup.setRenderLayer(Init.ARMORED_GLASS_BLOCK, RenderType.getCutoutMipped());
    }

}

 

 

Link to comment
Share on other sites

I don't know why you'd need to set glass to be transparent every render frame though.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

FMLClientSetupEvent

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

1 hour ago, xanderindalzone said:

FMLClientSetupEvent

Quote

Called on {@link net.minecraftforge.api.distmarker.Dist#CLIENT} - the game client.

 

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

On 7/3/2020 at 4:59 PM, diesieben07 said:

You cannot create registry entries in static initializers (here, here). Use the appropriate registry events or DeferredRegister.

I've been a bit busy this weekend but now I'm working with the mod again....

 

94c6661c632299b330d40dac9e26de9c.png

 

45d5cefd2216f647316c730bb5340573.png

 

Is this the proper way of registering stuff now? This is what I saw in a DeferredRegister tutorial.

 

I asume the way to access the Objects in code is with "InitItems.BULLET_CAL_45.get()" because it's at least working normally.

  

But correct me if i'm wrong. 

Link to comment
Share on other sites

On 7/3/2020 at 4:59 PM, diesieben07 said:

You cannot do this, KeyBinding is a client-only class.

I just have this left to do to fix Client-Side Only issues i think.

I've directly created the KeyBinding object inside the register method in the client event, also removing the static init I had, but now I cannot access the key from outside to check for example, if that key is being pressed.

 

13132ff2099163178b798bbe58ba10eb.png

3ef34faaa7c8b34aa2bdd37b12d5e8dd.png

 

Is there a way to check that key status? or a better way to register the key without violating the Client-Side Only code thing, and being able to access it by other methods?

Link to comment
Share on other sites

Well, you registered a new keybinding. Did you create a static reference to hold it? Did you do anything to make sure that reference had a value?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.