Gun Coding

7 posts / 0 new
Last post
Offline
Last seen: 9 months 1 week ago
Joined: 04/11/2015 - 15:34
Gems: 0
Gun Coding

Hi there im working on some new guns for my modpack. for the 3d renders i use blender since i know what to do. but im trying to imploment a cool down code and bullets for my magazines. ive been working on code for a week now but i just want to know the gun code. please respond 



Offline
Last seen: 7 months 5 days ago
Joined: 02/24/2015 - 19:32
Gems: -1
you want the code for a gun?

you want the code for a gun?

:D

 

package mod.mcreator;//based on master condiguration
 
import cpw.mods.fml.client.*;
import cpw.mods.fml.client.registry.*;
import cpw.mods.fml.common.*;
import cpw.mods.fml.common.asm.*;
import cpw.mods.fml.common.asm.transformers.*;
import cpw.mods.fml.common.discovery.*;
import cpw.mods.fml.common.discovery.asm.*;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.functions.*;
import cpw.mods.fml.common.network.*;
import cpw.mods.fml.common.registry.*;
import cpw.mods.fml.common.toposort.*;
import cpw.mods.fml.common.versioning.*;
import cpw.mods.fml.relauncher.*;
import cpw.mods.fml.server.*;
import net.minecraft.block.*;
import net.minecraft.block.material.*;
import net.minecraft.client.*;
import net.minecraft.client.audio.*;
import net.minecraft.client.entity.*;
import net.minecraft.client.gui.*;
import net.minecraft.client.gui.achievement.*;
import net.minecraft.client.gui.inventory.*;
import net.minecraft.client.model.*;
import net.minecraft.client.multiplayer.*;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.*;
import net.minecraft.client.renderer.culling.*;
import net.minecraft.client.renderer.entity.*;
import net.minecraft.client.renderer.tileentity.*;
import net.minecraft.client.settings.*;
import net.minecraft.command.*;
import net.minecraft.crash.*;
import net.minecraft.creativetab.*;
import net.minecraft.dispenser.*;
import net.minecraft.enchantment.*;
import net.minecraft.entity.*;
import net.minecraft.entity.ai.*;
import net.minecraft.entity.boss.*;
import net.minecraft.entity.effect.*;
import net.minecraft.entity.item.*;
import net.minecraft.entity.monster.*;
import net.minecraft.entity.passive.*;
import net.minecraft.entity.player.*;
import net.minecraft.entity.projectile.*;
import net.minecraft.inventory.*;
import net.minecraft.item.*;
import net.minecraft.item.crafting.*;
import net.minecraft.nbt.*;
import net.minecraft.network.*;
import net.minecraft.network.rcon.*;
import net.minecraft.pathfinding.*;
import net.minecraft.potion.*;
import net.minecraft.profiler.*;
import net.minecraft.server.*;
import net.minecraft.server.dedicated.*;
import net.minecraft.server.gui.*;
import net.minecraft.server.integrated.*;
import net.minecraft.server.management.*;
import net.minecraft.src.*;
import net.minecraft.stats.*;
import net.minecraft.tileentity.*;
import net.minecraft.util.*;
import net.minecraft.village.*;
import net.minecraft.world.*;
import net.minecraft.world.biome.*;
import net.minecraft.world.chunk.*;
import net.minecraft.world.chunk.storage.*;
import net.minecraft.world.demo.*;
import net.minecraft.world.gen.*;
import net.minecraft.world.gen.feature.*;
import net.minecraft.world.gen.layer.*;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.storage.*;
import net.minecraftforge.classloading.*;
import net.minecraftforge.client.*;
import net.minecraftforge.client.event.*;
import net.minecraftforge.client.event.sound.*;
import net.minecraftforge.common.*;
import net.minecraftforge.event.*;
import net.minecraftforge.event.entity.*;
import net.minecraftforge.event.entity.item.*;
import net.minecraftforge.event.entity.living.*;
import net.minecraftforge.event.entity.minecart.*;
import net.minecraftforge.event.entity.player.*;
import net.minecraftforge.event.terraingen.*;
import net.minecraftforge.event.world.*;
import net.minecraftforge.oredict.*;
import net.minecraftforge.transformers.*;
import net.minecraft.init.*;
import java.util.*;
 
public class mcreator_aK12 {
 
public mcreator_aK12(){}
 
public static Item block;
public static Object instance;
 
public void load(){
 
GameRegistry.addRecipe(new ItemStack(block, 1), new Object[]{
"012", "345", "678", Character.valueOf('0'), new ItemStack(mcreator_packedIronItem.block, 1), Character.valueOf('1'), new ItemStack(Items.redstone, 1), Character.valueOf('2'), new ItemStack(Items.dye, 1, 1), Character.valueOf('3'), new ItemStack(mcreator_mediumGunBarrel.block, 1), Character.valueOf('4'), new ItemStack(mcreator_largeGunBody.block, 1), Character.valueOf('5'), new ItemStack(mcreator_mediumGunStock.block, 1), Character.valueOf('6'), new ItemStack(mcreator_packedIronItem.block, 1), Character.valueOf('7'), new ItemStack(mcreator_aK12Ammo.block, 1), Character.valueOf('8'), new ItemStack(mcreator_packedIronItem.block, 1), 
});
}
 
public void registerRenderers(){}
public void generateNether(World world, Random random, int chunkX, int chunkZ){}
public void generateSurface(World world, Random random, int chunkX, int chunkZ){}
public int addFuel(ItemStack fuel){
return 0;
}
public void serverLoad(FMLServerStartingEvent event){}
public void preInit(FMLPreInitializationEvent event){}
 
static{
block = (new ItemgGUN());
Item.itemRegistry.addObject(1249, "aK12", block);
}
 
static class ItemgGUN extends Item{
 
public ItemgGUN(){
super();
setMaxDamage(200);
maxStackSize = 1;
setFull3D();
setUnlocalizedName("aK12");
setTextureName("AK12");
setCreativeTab(CreativeTabs.tabCombat);
}
 
public int getMaxItemUseDuration(ItemStack par1ItemStack)
    {
        return 72000;
    }
 
   public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, final EntityPlayer par3EntityPlayer){
 
        boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0;
 
        if (flag || par3EntityPlayer.inventory.hasItem(mcreator_aK12Ammo.block))
        {
            float f = 5.0F;
 
            EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0F)
            {
 
public void onCollideWithPlayer(EntityPlayer entity){
super.onCollideWithPlayer(entity);
int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
World world = this.worldObj;
 
}
 
            public void onUpdate(){
    super.onUpdate();
    int i = MathHelper.floor_double(this.boundingBox.minX + 0.001D);
    int j = MathHelper.floor_double(this.boundingBox.minY + 0.001D);
    int k = MathHelper.floor_double(this.boundingBox.minZ + 0.001D);
    World world = this.worldObj;
    Entity entity = (Entity)par3EntityPlayer;
    
    if (this.worldObj.getBlock(i, j, k) != Blocks.air || this.worldObj.getBlock(i, j-1, k) != Blocks.air ||
    this.worldObj.getBlock(i, j+1, k) != Blocks.air ||
    this.worldObj.getBlock(i+1, j, k) != Blocks.air || this.worldObj.getBlock(i-1, j, k) != Blocks.air
    || this.worldObj.getBlock(i, j, k+1) != Blocks.air || this.worldObj.getBlock(i, j, k-1) != Blocks.air){
     
      this.kill();
    }
 
            }
 
            };
 
                entityarrow.setIsCritical(true);
                entityarrow.setDamage(1.9);
                entityarrow.setKnockbackStrength(1);
 
                if(false){
                entityarrow.setFire(100);
}
 
            par1ItemStack.damageItem(1, par3EntityPlayer);
            par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);
 
            if (flag)
            {
                entityarrow.canBePickedUp = 2;
            }
            else
            {
                par3EntityPlayer.inventory.consumeInventoryItem(mcreator_aK12Ammo.block);
            }
 
            if (!par2World.isRemote)
            {
                par2World.spawnEntityInWorld(entityarrow);
            }
            World world = par2World;
            EntityPlayer entity = par3EntityPlayer;
int i = (int)entity.posX;
int j = (int)entity.posY;
int k = (int)entity.posZ;
            
if(true){
world.createExplosion((Entity)null, i, j, k, 0.2F, true);
}
 
        }
 
        return par1ItemStack;
    }
 
 
 
    /**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack par1ItemStack)
    {
        return EnumAction.bow;
    }
 
 
}}
Offline
Last seen: 9 months 1 week ago
Joined: 04/11/2015 - 15:34
Gems: 0
is this for 3d modeling for

is this for 3d modeling for guns?

 

Offline
Last seen: 7 months 5 days ago
Joined: 02/24/2015 - 19:32
Gems: -1
RE:is this for 3d modeling for

@iNeverrMiss  Oh, No, just basic code for the gun.. Sorry I miunderstood.

TheBeast's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/13/2015 - 21:08
Gems: 0
And how i can create a model

And how i can create a model for the  bullet? because i´m tired of arrows

TheBeast's picture
Offline
Last seen: 7 months 1 week ago
Joined: 05/13/2015 - 21:08
Gems: 0
RE:And how i can create a model

@TheBeast plz reply 

Offline
Last seen: 9 months 1 week ago
Joined: 04/11/2015 - 15:34
Gems: 0
RE:RE:And how i can create a model

@TheBeast you cant make it like that. but i am working on some code that will work with it. so i may post it soon just for now im experementing with some gun code in eclipse