Jump to content

perromercenary00

Members
  • Posts

    849
  • Joined

  • Last visited

  • Days Won

    5

Everything posted by perromercenary00

  1. i guest this is not whath you are talking about coz RenderingRegistry.registerEntityRenderingHandler(flechaMercenaria.class, new renderFlechaMercenaria(Minecraft.getMinecraft().getRenderManager())); //not work or this RenderingRegistry.registerEntityRenderingHandler(flechaMercenaria.class, new Minecraft.getMinecraft().getRenderManager() ); //either the other think i do was change the contructor in the renderFlechaMercenaria() to look like this public renderFlechaMercenaria() { super(Minecraft.getMinecraft().getRenderManager() ); //super(p_i46193_1_); } nop still not geting it but thanks
  2. i dont get it. what is this RenderManager where i get it, its something from i must create and objet Minecraft.getMinecraft().getRenderManager() arr = new Minecraft.getMinecraft().getRenderManager(flechaMercenaria.class); RenderingRegistry.registerEntityRenderingHandler(flechaMercenaria.class, new renderFlechaMercenaria(arr)); dont seems to work
  3. good days i have little experience whith entityes in general but long ago i doo a pair of custom arrows the only thing was this two has been left whitout a texture today i retake the work for wath i read i just need the code of the arrow and the code for the render but idont know how to register this render or where flechaMercenaria.java package mercenarymod.items.arcos; import mercenarymod.Mercenary; import mercenarymod.utilidades.nbtMercenaria; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class flechaMercenaria extends Item { public flechaMercenaria() { String name = "flechaMercenaria"; setUnlocalizedName(Mercenary.MODID + "_" + name); GameRegistry.registerItem(this, name); setCreativeTab(Mercenary.herramientas); this.maxStackSize = 64; this.setMaxDamage(0); } //######################################################################################3 @Override public ModelResourceLocation getModel(ItemStack flechas, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria00", "inventory"); /* switch(flechas.stackSize){ case 1: modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria00", "inventory");break; case 2: modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria01", "inventory");break; default : modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/flechaMercenaria02", "inventory");break; } */ return modelresourcelocation; } //####################################################################################3 @Override public ItemStack onItemRightClick(ItemStack flechas, World worldIn, EntityPlayer playerIn) { return flechas; } public int getItemEnchantability() { return 1; } } renderFlechaMercenaria package mercenarymod.items.render; import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.WorldRenderer; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.MathHelper; import net.minecraft.util.ResourceLocation; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import org.lwjgl.opengl.GL11; @SideOnly(Side.CLIENT) public class renderFlechaMercenaria extends Render { private static final ResourceLocation arrowTextures = new ResourceLocation("modmercenario:textures/entity/arrow.png"); private static final String __OBFID = "CL_00000978"; public renderFlechaMercenaria(RenderManager p_i46193_1_) { super(p_i46193_1_); } public void doRender(EntityArrow p_180551_1_, double p_180551_2_, double p_180551_4_, double p_180551_6_, float p_180551_8_, float p_180551_9_) { this.bindEntityTexture(p_180551_1_); GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); GlStateManager.pushMatrix(); GlStateManager.translate((float)p_180551_2_, (float)p_180551_4_, (float)p_180551_6_); GlStateManager.rotate(p_180551_1_.prevRotationYaw + (p_180551_1_.rotationYaw - p_180551_1_.prevRotationYaw) * p_180551_9_ - 90.0F, 0.0F, 1.0F, 0.0F); GlStateManager.rotate(p_180551_1_.prevRotationPitch + (p_180551_1_.rotationPitch - p_180551_1_.prevRotationPitch) * p_180551_9_, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); byte b0 = 0; float f2 = 0.0F; float f3 = 0.5F; float f4 = (float)(0 + b0 * 10) / 32.0F; float f5 = (float)(5 + b0 * 10) / 32.0F; float f6 = 0.0F; float f7 = 0.15625F; float f8 = (float)(5 + b0 * 10) / 32.0F; float f9 = (float)(10 + b0 * 10) / 32.0F; float f10 = 0.05625F; GlStateManager.enableRescaleNormal(); float f11 = (float)p_180551_1_.arrowShake - p_180551_9_; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GlStateManager.rotate(f12, 0.0F, 0.0F, 1.0F); } GlStateManager.rotate(45.0F, 1.0F, 0.0F, 0.0F); GlStateManager.scale(f10, f10, f10); GlStateManager.translate(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); worldrenderer.startDrawingQuads(); worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); worldrenderer.startDrawingQuads(); worldrenderer.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); worldrenderer.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); worldrenderer.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); worldrenderer.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); worldrenderer.startDrawingQuads(); worldrenderer.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); worldrenderer.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); worldrenderer.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); worldrenderer.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); tessellator.draw(); } GlStateManager.disableRescaleNormal(); GlStateManager.popMatrix(); super.doRender(p_180551_1_, p_180551_2_, p_180551_4_, p_180551_6_, p_180551_8_, p_180551_9_); } protected ResourceLocation getEntityTexture(EntityArrow p_180550_1_) { return arrowTextures; } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity entity) { return this.getEntityTexture((EntityArrow)entity); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render<T extends Entity>) and this method has signature public void func_76986_a(T entity, double d, double d1, * double d2, float f, float f1). But JAD is pre 1.5 so doe */ public void doRender(Entity entity, double x, double y, double z, float p_76986_8_, float partialTicks) { this.doRender((EntityArrow)entity, x, y, z, p_76986_8_, partialTicks); } } im basing this code in some scatter info about 1.7 im trying to register this in the postInit from my ClientProxy but lloks like its something misiong insede the parentesys from renderFlechaMercenaria("It askme for something here and itis not a 'null' ") ClientProxy.java //@Mod.EventHandler //public void postInit(FMLPostInitializationEvent event) { public void postInit() { System.out.println("########\n\n\n ClientProxy postInit()"); MinecraftForge.EVENT_BUS.register(new NotificationMercenaria(Minecraft.getMinecraft(), null)); RenderingRegistry.registerEntityRenderingHandler(flechaMercenaria.class, new renderFlechaMercenaria(null)); }
  4. hello i been doing more research and find a piece of working code, adapted it to mi needs and is working but there is thing i dont get im calculating the position of my items icon to be at lower left side of the screen using private int posX=0, posY=0, mulY=-1; int displayWidth=mc.displayWidth; int displayHeight=mc.displayHeight; int offsetX=16; int offsetY=((displayHeight/2)-80); 16 pixel from the left side and 80 pixel from the botom its works but only when the option "GUI SCALE: NORMAL" if i change it the icon disapears i think it goes out of picture. the original code sets the icon to the uper left and uses ScaledResolution sr = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); posX =sr.getScaledWidth() - 160; posY =sr.getScaledHeight() - 32; mulY = -1; how i solve this to adapt the icon position to the state of "GUI SCALE: package mercenarymod.gui; import mercenarymod.items.MercenaryModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.renderer.entity.RenderItem; import net.minecraft.client.resources.model.ModelManager; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import org.lwjgl.opengl.GL11; public class NotificationMercenaria extends Gui { private Minecraft mc; private int posX=0, posY=0, mulY=-1; private int conteo=0; private String icono="modmercenario:textures/items/comunes/transparencia.png";//transparencia public NotificationMercenaria(Minecraft mc, Configuration config) { super(); this.mc = mc; //Save the top left corner of the fully visible notification to posX, posY and mulY. ScaledResolution sr = new ScaledResolution(this.mc, this.mc.displayWidth, this.mc.displayHeight); posX = 0;//sr.getScaledWidth() - 160; posY = 0;//sr.getScaledHeight() - 32; mulY = -1; //String[] position = config.get(Configuration.CATEGORY_GENERAL, "position", "top-left").getString().split("-"); //if (position[0] == "top") { posY = 0; mulY = 1; } //if (position[1] == "left") posX = 0; //posY = 0; mulY = 1;posX = 0; } private String text = ""; @SubscribeEvent(priority = EventPriority.NORMAL) public void onRender(RenderGameOverlayEvent event) { //Render above the chat if(event.isCancelable() || event.type != RenderGameOverlayEvent.ElementType.ALL) return; //Render only if there's a new notification conteo++; int displayWidth=mc.displayWidth; int displayHeight=mc.displayHeight; System.out.println("with="+displayWidth+" Height="+displayHeight); if ( (conteo%20)==0 ){ int modo=0; EntityPlayer playerIn=mc.thePlayer; int hand = playerIn.inventory.currentItem; ItemStack stack0 = playerIn.inventory.getCurrentItem(); if (stack0 != null){ //System.out.println("stack0="+stack0.getUnlocalizedName()); Item item0 = stack0.getItem(); // boolean transparencia=true; int municion = getInttag(stack0, "municion"); int municionmaxima =getInttag(stack0, "municionmaxima"); int municiondisponible=getInttag(stack0, "municiondisponible"); int tipomunicion=getInttag(stack0, "tipomunicion"); int tipocargador=getInttag(stack0, "tipocargador"); int tipocargadormax=getInttag(stack0, "tipocargadormax"); int tipodisparo=getInttag(stack0, "tipodisparo"); int tipodisparomax=getInttag(stack0, "tipodisparomax"); boolean reload= getBooleantag(stack0, "reload"); boolean shoot= getBooleantag(stack0, "shoot"); boolean unload= getBooleantag(stack0, "unload"); float strength=getFloattag(stack0, "strength"); boolean enable= getBooleantag(stack0, "enable"); if (unload){modo=1;} if (tipocargador<=0){modo=2;} if (item0.equals(MercenaryModItems.subfusil90PNF)){ switch(modo){ case 0: icono="modmercenario:textures/items/armasdefuego/subfusil90pnf/90PNF_icono.png";break; case 1: icono="modmercenario:textures/items/armasdefuego/subfusil90pnf/90PNF_descargar.png";break; case 2: icono="modmercenario:textures/items/armasdefuego/subfusil90pnf/90PNF_SC.png";break; } switch(tipodisparo){ case 0: text=""+municion+"/"+municionmaxima+" Manual";break; case 1: text=""+municion+"/"+municionmaxima+" SemiAutomatico";break; case 2: text=""+municion+"/"+municionmaxima+" Automatico";break; }transparencia=false;} if (item0.equals(MercenaryModItems.vallestaMercenaria)){ switch(tipomunicion){ case 0: icono="modmercenario:textures/items/arcos/flecha00.png";break; case 1: icono="modmercenario:textures/items/arcos/flecha01.png";break; case 2: icono="modmercenario:textures/items/arcos/flecha02.png";break; }text=""+municiondisponible; transparencia=false;} if (item0.equals(MercenaryModItems.arcoMercenario)){ switch(tipomunicion){ case 0: icono="modmercenario:textures/items/arcos/flecha00.png";break; case 1: icono="modmercenario:textures/items/arcos/flecha01.png";break; case 2: icono="modmercenario:textures/items/arcos/flecha02.png";break; }text=""+municiondisponible; transparencia=false;} if (item0.equals(MercenaryModItems.pistola75NF)){ switch(modo){ case 0: icono="modmercenario:textures/items/armasdefuego/pistola75nf/75NF_icono.png";break; case 1: icono="modmercenario:textures/items/armasdefuego/pistola75nf/75NF_descargar.png";break; case 2: icono="modmercenario:textures/items/armasdefuego/pistola75nf/75NF_icono.png";break; }text=""+municion+" / "+municionmaxima ;transparencia=false;} if (item0.equals(MercenaryModItems.pistola1911colt)){ switch(modo){ case 0: icono="modmercenario:textures/items/armasdefuego/pistola1911colt/pistola1911colt_icono.png";break; case 1: icono="modmercenario:textures/items/armasdefuego/pistola1911colt/pistola1911colt_descargar.png";break; case 2: icono="modmercenario:textures/items/armasdefuego/pistola1911colt/pistola1911colt_icono.png";break; }text=""+municion+" / "+municionmaxima ;transparencia=false;} if (item0.equals(MercenaryModItems.cargador1911colt)){ icono="modmercenario:textures/items/armasdefuego/pistola1911colt/cargador1911colt_icono.png"; text=""+municion+" / "+municionmaxima ;transparencia=false;} if (item0.equals(MercenaryModItems.cargador75NF)){ icono="modmercenario:textures/items/armasdefuego/pistola75nf/cargador_75NF_icono.png"; text=""+municion+" / "+municionmaxima ;transparencia=false;} if (item0.equals(MercenaryModItems.cargador90PNF)){ icono="modmercenario:textures/items/armasdefuego/subfusil90pnf/90PNF_cargador_icono.png"; text=""+municion+" / "+municionmaxima ;transparencia=false;} if (item0.equals(MercenaryModItems.cargadorBeretta)){ icono="modmercenario:textures/items/armasdefuego/pistola1911colt/cargador1911colt_icono.png"; text=""+municion+" / "+municionmaxima ;transparencia=false;} if (transparencia){icono="modmercenario:textures/items/comunes/transparencia.png";text="";}// }//(stack0 != null) }//( (conteo%20)==0 ) //Prepare rendering GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_LIGHTING); int offsetX=16; int offsetY=((displayHeight/2)-80); this.mc.renderEngine.bindTexture(new ResourceLocation(icono)); //drawModalRectWithCustomSizedTexture(int x, int y,float u,float v,int width,int height,float textureWidth,float textureHeight); this.drawModalRectWithCustomSizedTexture(posX + offsetX, posY + offsetY, 0.0F, 0.0F, 60, 60, 60.0F, 60.0F); //imagen al 60% //this.drawModalRectWithCustomSizedTexture(posX + 8, posY + 8, 0.0F, 0.0F, 200, 200 , 200.0F, 200.0F); this.mc.fontRendererObj.drawStringWithShadow(text, posX + offsetX, ((posY + offsetY)+40) , 0xffcccccc); //this.mc.fontRendererObj.drawStringWithShadow(text, posX + 32 + 8, posX + 8, 0xffcccccc); } //#########################################################################3 public static int[] getIntArraytag(ItemStack item, String tag){ int[] array = new int[5]; NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); array[0]=9999; return array; } array=etiquetas.getIntArray(tag); return array; } //#########################################################################3 public static void setIntArraytag(ItemStack item, String tag, int[] value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setIntArray(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static float getFloattag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 999.9F; } float ex=etiquetas.getFloat(tag); return ex; } //#########################################################################3 public static void setFloattag(ItemStack item, String tag, float value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setFloat(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static int getInttag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 9999; } int ex=etiquetas.getInteger(tag); return ex; } //#########################################################################3 public static void setInttag(ItemStack item, String tag, int value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setInteger(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static Boolean getBooleantag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return false; } boolean ex=etiquetas.getBoolean(tag); return ex; } //#########################################################################3 public static void setBooleantag(ItemStack item, String tag, boolean value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = item.getTagCompound(); } etiquetas.setBoolean(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 }//fin de la classe
  5. bueno is that is a little messy long and full of coments in spanish. package mercenarymod.items.herramientas; import java.util.ArrayList; import java.util.List; import java.util.Properties; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.StatList; import net.minecraft.util.BlockPos; import net.minecraft.util.EnumFacing; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; import mercenarymod.materialesMercenarios; import mercenarymod.Mercenary; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.properties.PropertyDirection; import net.minecraft.block.state.IBlockState; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.entity.projectile.EntitySnowball; import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import mercenarymod.items.MercenaryModItems; import mercenarymod.utilidades.registrarTextura; import mercenarymod.utilidades.chat; import mercenarymod.utilidades.util; import net.minecraft.block.state.IBlockState; public class taladroMercenario extends Item{ public taladroMercenario(){ String name = "taladroMercenario"; setUnlocalizedName(Mercenary.MODID + "_" + name); GameRegistry.registerItem(this, name); setCreativeTab(Mercenary.herramientas); this.setHasSubtypes(true); this.maxStackSize = 1; this.setMaxDamage(4000); ;} //#####################################################################################3 /* public void onUpdate(ItemStack taladro, World worldIn, Entity entityIn, int itemSlot, boolean isSelected) { if (isSelected){ boolean enUso=false; EntityPlayer playerIn= (EntityPlayer) entityIn; if(!worldIn.isRemote){ if(getBooleantag(taladro, "enable")){ System.out.println("enable"); int texturajson=getInttag(taladro, "texturajson"); texturajson++; setInttag(taladro, "texturajson",texturajson); if(texturajson >= 64){ setBooleantag(taladro, "enable",false); setInttag(taladro, "texturajson",0); } } } }//is selected }*/ //######################################################################################3 public ModelResourceLocation getModel(ItemStack taladro, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation= new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario", "inventory"); int tick; tick=(1000-useRemaining); if (tick>999){tick=0;} //tick=tick/2; int ciclo=8; int texturajson=0; boolean shoot= getBooleantag(taladro, "shoot"); boolean reload= getBooleantag(taladro, "reload"); boolean unload= getBooleantag(taladro, "unload"); boolean enable= getBooleantag(taladro, "enable"); int tipocargador=getInttag(taladro, "tipocargador"); int tipoperforacion=getInttag(taladro, "tipoperforacion"); int municion= getInttag(taladro, "municion"); if (tick>0){texturajson=3;} if(reload & (municion<=0) ){ tick=tick/2; switch(tick){ default : texturajson=3;break; case 1: case 2: case 3: texturajson=4;break; case 4: case 5: case 6: texturajson=5;break; case 7: case 8: case 9: texturajson=6;break; case 10: case 11: case 12: texturajson=7;break; case 13: case 14: case 15: texturajson=8;break; case 16: case 17: case 18: texturajson=9;break; } } if(shoot & (municion>0)){ switch(tick){ case 0: texturajson=0;break; default : texturajson=2;break; } } if( !shoot & !reload & (municion>0)){ switch(tick){ case 0: texturajson=0;break; default : texturajson=1;break; } } if(!enable){texturajson=0;} switch(texturajson){ default : modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario", "inventory");break; case 1: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_encendido", "inventory");break; case 2: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_encendido2", "inventory");break; case 3: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A00", "inventory");break; case 4: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A01", "inventory");break; case 5: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A02", "inventory");break; case 6: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A03", "inventory");break; case 7: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A04", "inventory");break; case 8: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A05", "inventory");break; case 9: modelresourcelocation = new ModelResourceLocation("modmercenario:herramientas/taladro/taladroMercenario_A06", "inventory");break; } return modelresourcelocation; } //######################################################################################3 @Override public ItemStack onItemRightClick(ItemStack taladro, World worldIn, EntityPlayer playerIn) { if ( !worldIn.isRemote ){ boolean inicializado = getBooleantag(taladro, "inicializado"); if (!inicializado){ intialize(taladro, playerIn); chat.chatgr(playerIn, "Inicializada en onItemRightClick"); } } playerIn.setItemInUse(taladro, this.getMaxItemUseDuration(taladro)); chat.chatm(playerIn, "onItemRightClick"); return taladro; } //####################################################################################3 @Override public boolean onEntitySwing(EntityLivingBase entityLiving, ItemStack taladro) { EntityPlayer playerIn = (EntityPlayer) entityLiving; World worldIn =entityLiving.getEntityWorld(); if ( !worldIn.isRemote ){ boolean inicializado = getBooleantag(taladro, "inicializado"); if (!inicializado){ intialize(taladro, playerIn); setBooleantag(taladro, "inicializado",true); chat.chatgr(playerIn, "Inicializada en onEntitySwing"); } } if ( !worldIn.isRemote & (entityLiving.isSneaking()) ){ int tipoperforacion=getInttag(taladro, "tipoperforacion"); int spell0 = EnchantmentHelper.getEfficiencyModifier(playerIn); int spell1 = EnchantmentHelper.getFortuneModifier(playerIn); switch(spell0){ case 0:{ switch(tipoperforacion){ default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break; case 1: setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break; case 2: setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false); chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break; case 3: setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true); chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break; //case 4: setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break; }};break; case 1:{ switch(tipoperforacion){ default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break; case 1: setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break; case 2: setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false); chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break; case 3: setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true); chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break; case 4: setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break; }};break; case 2:{ switch(tipoperforacion){ default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break; case 1: setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break; case 2: setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false); chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break; case 3: setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true); chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break; case 4: setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break; case 5: setInttag(taladro, "tipoperforacion",6);chat.chatdp(playerIn, "Modo Venticinco blockes");break; }};break; case 3:{ switch(tipoperforacion){ default: setInttag(taladro, "tipoperforacion",1);chat.chatdp(playerIn, "Modo un blocke");break; case 1: setInttag(taladro, "tipoperforacion",2);chat.chatdp(playerIn, "Modo Dos blockes");break; case 2: setInttag(taladro, "tipoperforacion",3);setBooleantag(taladro, "izquierda",false); chat.chatdp(playerIn, "Modo Cuatro blockes izquierda");break; case 3: setInttag(taladro, "tipoperforacion",4);setBooleantag(taladro, "izquierda",true); chat.chatdp(playerIn, "Modo Cuatro blockes derecha");break; case 4: setInttag(taladro, "tipoperforacion",5);chat.chatdp(playerIn, "Modo Nueve blockes");break; case 5: setInttag(taladro, "tipoperforacion",6);chat.chatdp(playerIn, "Modo Venticinco blockes");break; case 6: setInttag(taladro, "tipoperforacion",7);chat.chatdp(playerIn, "Modo CuarentayNueve blockes");break; }};break; }//switch(spell0) } return true; } //###################################################################################3 public static EnumFacing playerRotation(EntityPlayer playerIn){ double rotation=playerIn.getRotationYawHead(); if (rotation >= -180){;} if (rotation < -180){rotation=180+(rotation+180);} if (rotation <= 180){;} if (rotation > 180){rotation=(-180)+(rotation-180);} //chat.chatda(playerIn, "rotation="+playerIn.getRotationYawHead() ); //chat.chatr(playerIn, "rotation="+rotation ); if ( rotation > -45 & rotation < 45 ){ //chat.chatr(playerIn, "=sur=" ); return EnumFacing.SOUTH; } if ( rotation < -135 | rotation > 135 ){ //chat.chatr(playerIn, "=Norte=" ); return EnumFacing.NORTH;} if ( rotation > 45 & rotation < 135 ){ //chat.chatr(playerIn, "=oeste=" ); return EnumFacing.WEST;} if ( rotation < -45 & rotation > -135 ){ //chat.chatr(playerIn, "=este=" ); return EnumFacing.EAST;} return EnumFacing.NORTH; } //###################################################################################3 public static ArrayList<BlockPos> areaAfectada(World worldIn, EntityPlayer playerIn, ItemStack taladro){ BlockPos b=null; ArrayList<BlockPos> salida = new ArrayList<BlockPos>(); int bx=0,by=0,bz=0; int tipoperforacion=getInttag(taladro, "tipoperforacion"); boolean izquierda=getBooleantag(taladro, "izquierda"); MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(6, 1.0F); if(mop != null) { b= mop.getBlockPos(); bx=b.getX(); by=b.getY(); bz=b.getZ(); } EnumFacing sid= mop.sideHit; salida.add(b); switch(tipoperforacion){ case 2:{ if ( (sid.equals(EnumFacing.UP)) ) { EnumFacing lado= playerRotation(playerIn); if (lado.equals(EnumFacing.NORTH)){salida.add(b.south());} if (lado.equals(EnumFacing.SOUTH)){salida.add(b.north());} if (lado.equals(EnumFacing.EAST)){salida.add(b.west());} if (lado.equals(EnumFacing.WEST)){salida.add(b.east());} } if ( (sid.equals(EnumFacing.DOWN)) ) { EnumFacing lado= playerRotation(playerIn); if (lado.equals(EnumFacing.NORTH)){salida.add(b.north());} if (lado.equals(EnumFacing.SOUTH)){salida.add(b.south());} if (lado.equals(EnumFacing.EAST)){salida.add(b.east());} if (lado.equals(EnumFacing.WEST)){salida.add(b.west());} } if ( (sid.equals(EnumFacing.EAST))|(sid.equals(EnumFacing.WEST))|(sid.equals(EnumFacing.NORTH))|(sid.equals(EnumFacing.SOUTH)) ) { salida.add(b.down());} };break; case 3: case 4: { if (sid.equals(EnumFacing.NORTH)){ salida.add(b.down()); if(izquierda){ salida.add(b.west()); salida.add(b.west().down()); }else{ salida.add(b.east()); salida.add(b.east().down()); } } if (sid.equals(EnumFacing.SOUTH)){ salida.add(b.down()); if(izquierda){ salida.add(b.east()); salida.add(b.east().down()); }else{ salida.add(b.west()); salida.add(b.west().down()); } } if (sid.equals(EnumFacing.EAST)){ salida.add(b.down()); if(izquierda){ salida.add(b.north()); salida.add(b.north().down()); }else{ salida.add(b.south()); salida.add(b.south().down()); } } if (sid.equals(EnumFacing.WEST)){ salida.add(b.down()); if(izquierda){ salida.add(b.south()); salida.add(b.south().down()); }else{ salida.add(b.north()); salida.add(b.north().down()); } } if ( (sid.equals(EnumFacing.DOWN)) ) { EnumFacing lado= playerRotation(playerIn); if(izquierda){ if (lado.equals(EnumFacing.NORTH)){ salida.add(b.north());salida.add(b.east());salida.add(b.east().north() );} if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.south());salida.add(b.west());salida.add(b.west().south() );} if (lado.equals(EnumFacing.EAST)){ salida.add(b.east());salida.add(b.south());salida.add(b.east().south() );} if (lado.equals(EnumFacing.WEST)){ salida.add(b.west());salida.add(b.north());salida.add(b.west().north() );} }else{ if (lado.equals(EnumFacing.NORTH)){ salida.add(b.north());salida.add(b.west());salida.add(b.west().north() );} if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.south());salida.add(b.east());salida.add(b.east().south() );} if (lado.equals(EnumFacing.EAST)){ salida.add(b.east());salida.add(b.north());salida.add(b.east().north() );} if (lado.equals(EnumFacing.WEST)){ salida.add(b.west());salida.add(b.south());salida.add(b.west().south() );} } } if ( (sid.equals(EnumFacing.UP)) ) { EnumFacing lado= playerRotation(playerIn); if(izquierda){//romper ala derecha if (lado.equals(EnumFacing.NORTH)){ salida.add(b.south());salida.add(b.east());salida.add(b.east().south() );} if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.north());salida.add(b.west());salida.add(b.west().north() );} if (lado.equals(EnumFacing.EAST)){ salida.add(b.west());salida.add(b.south());salida.add(b.west().south() );} if (lado.equals(EnumFacing.WEST)){ salida.add(b.east());salida.add(b.north());salida.add(b.east().north() );} }else{ if (lado.equals(EnumFacing.NORTH)){ salida.add(b.south());salida.add(b.west());salida.add(b.west().south() );} if (lado.equals(EnumFacing.SOUTH)){ salida.add(b.north());salida.add(b.east());salida.add(b.east().north() );} if (lado.equals(EnumFacing.EAST)){ salida.add(b.west());salida.add(b.north());salida.add(b.west().north() );} if (lado.equals(EnumFacing.WEST)){ salida.add(b.east());salida.add(b.south());salida.add(b.east().south() );} } } };break; //case 3: 4: case 5:{ if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){ salida.add(b.up()); salida.add(b.down()); salida.add(b.west()); salida.add(b.west().down()); salida.add(b.west().up()); salida.add(b.east()); salida.add(b.east().down()); salida.add(b.east().up()); } if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){ salida.add(b.up()); salida.add(b.down()); salida.add(b.north()); salida.add(b.north().down()); salida.add(b.north().up()); salida.add(b.south()); salida.add(b.south().down()); salida.add(b.south().up()); } if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){ salida.add(b.east()); salida.add(b.west()); salida.add(b.north()); salida.add(b.north().east()); salida.add(b.north().west()); salida.add(b.south()); salida.add(b.south().east()); salida.add(b.south().west()); } };break;//case 5: case 6:{ // 5x5 chat.chatdp(playerIn, "AQui"); int x=b.getX(),y=b.getY(),z=b.getZ(); int a=2; int xmin=x-a, xmax=x+a,ymin=y-a, ymax=y+a,zmin=z-a, zmax=z+a; BlockPos b6=b; if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){ for (int dx=xmin ; dx<= xmax ; dx++){ for (int dy=ymin ; dy<= ymax ; dy++){ //for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(dx,dy,z); salida.add(b6); }} } if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){ //for (int dx=xmin ; dx<= xmax ; dx++){ for (int dy=ymin ; dy<= ymax ; dy++){ for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(x,dy,dz); salida.add(b6); }} } if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){ for (int dx=xmin ; dx<= xmax ; dx++){ //for (int dy=ymin ; dy<= ymax ; dy++){ for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(dx,y,dz); salida.add(b6); }} } };break;//case 6: case 7:{ // 7x7 chat.chatdp(playerIn, "AQui"); int x=b.getX(),y=b.getY(),z=b.getZ(); int a=3; int xmin=x-a, xmax=x+a,ymin=y-a, ymax=y+a,zmin=z-a, zmax=z+a; BlockPos b6=b; if ( (sid.equals(EnumFacing.NORTH)) | (sid.equals(EnumFacing.SOUTH)) ){ for (int dx=xmin ; dx<= xmax ; dx++){ for (int dy=ymin ; dy<= ymax ; dy++){ //for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(dx,dy,z); salida.add(b6); }} } if ( (sid.equals(EnumFacing.EAST)) | (sid.equals(EnumFacing.WEST)) ){ //for (int dx=xmin ; dx<= xmax ; dx++){ for (int dy=ymin ; dy<= ymax ; dy++){ for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(x,dy,dz); salida.add(b6); }} } if ( (sid.equals(EnumFacing.UP)) | (sid.equals(EnumFacing.DOWN)) ){ for (int dx=xmin ; dx<= xmax ; dx++){ //for (int dy=ymin ; dy<= ymax ; dy++){ for (int dz=zmin ; dz<= zmax ; dz++){ b6=new BlockPos(dx,y,dz); salida.add(b6); }} } };break;//case 7: }//switch(tipoperforacion) return salida; } //###################################################################################3 public static ArrayList<BlockPos> arearompible(World worldIn, EntityPlayer playerIn, ItemStack taladro,ArrayList<BlockPos> b){ int lb=b.size(); ArrayList<BlockPos> salida = new ArrayList<BlockPos>(); salida.clear(); for (int db=0 ; db < lb ; db++){ if ( (hardenessb( worldIn,playerIn, b.get(db))) > -1){ salida.add( b.get(db) ); } } return salida; } //#########################################################################################/ public static void romper(World worldIn,EntityPlayer playerIn,ItemStack taladro,ArrayList<BlockPos> b) { if (!worldIn.isRemote){ int lb=b.size(); for (int db=0 ; db < lb ; db++){ worldIn.destroyBlock(b.get(db), true); } taladro.damageItem(1, playerIn); } } //#########################################################################################/ public static int[] coordenadas(World worldIn,EntityPlayer playerIn,int distancia) { int bx=0; int by=0; int bz=0; BlockPos b=null; MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(distancia, 1.0F); if(mop != null) { b= mop.getBlockPos(); bx=b.getX(); by=b.getY(); bz=b.getZ(); } EnumFacing sid= mop.sideHit; int [] salida=new int[5]; salida[0]=bx;salida[1]=by;salida[2]=bz;salida[3]=0; return salida; } //#########################################################################################/ public static BlockPos coordenadasb(World worldIn,EntityPlayer playerIn,int distancia) { BlockPos b=null; MovingObjectPosition mop = Minecraft.getMinecraft().getRenderViewEntity().rayTrace(distancia, 1.0F); if(mop != null) { b= mop.getBlockPos(); } return b; } //####################################################################################3 public static int hardenessb(World worldIn,EntityPlayer playerIn, BlockPos b){ IBlockState bls0=worldIn.getBlockState(b); Block blk0=bls0.getBlock(); int hard=(int)blk0.getBlockHardness(worldIn, b); Material mt = blk0.getMaterial(); if (mt != Material.grass & mt != Material.ground & mt != Material.clay & mt != Material.rock & mt != Material.coral & mt != Material.cactus & mt != Material.craftedSnow & mt != Material.gourd & mt != Material.iron & mt != Material.sand & mt != Material.snow ){hard=-1;} return hard; } //####################################################################################3 public static int lamasdura(World worldIn,EntityPlayer playerIn, ArrayList<BlockPos> bl ){ int harder=-1; int hard=-1; int lb=bl.size(); for (int db=0 ; db < lb ; db++){ hard=hardenessb(worldIn,playerIn, bl.get(db)); if (hard>harder){harder=hard;} } return harder; } //####################################################################################3 @Override public void onUsingTick(ItemStack taladro, EntityPlayer playerIn, int count) { int tick; tick=(1000-count); int ciclo=8; int ticksnesesarios=getInttag(taladro, "ticksnesesarios"); int municion= getInttag(taladro, "municion"); boolean reload = getBooleantag(taladro, "reload"); boolean shoot = getBooleantag(taladro, "shoot"); if (tick > 0){ if ( ((tick % 4) ==0) | (tick==1) ) { World worldIn = playerIn.getEntityWorld(); if ( (!worldIn.isRemote) ){ if ( !reload & ((tick==1 ) | ((tick%4)==0)) ){ //chat.chatm(playerIn, "tick="+tick); if (shoot){worldIn.playSoundAtEntity(playerIn, "modmercenario:taladromercenario03", 0.6F, 0.6F );} else{ if (municion>0){ worldIn.playSoundAtEntity(playerIn, "modmercenario:taladromercenario01", 1.1F, 1.1F ); } } } if ( reload & (tick==1 ) ){ //chat.chatm(playerIn, "reload tick="+tick); worldIn.playSoundAtEntity(playerIn, "modmercenario:suspencionderedstoneActivada", 0.6F, 0.6F ); } }}} if ( ((municion==0) | (tick>4)) & ((tick >= ticksnesesarios) & (!reload)) ) {playerIn.stopUsingItem();} } //####################################################################################3 @Override public void onPlayerStoppedUsing(ItemStack taladro, World worldIn, EntityPlayer playerIn, int timeLeft) { int tick; tick=1000-timeLeft; int ciclo=8; if(!worldIn.isRemote){ boolean unload = getBooleantag(taladro, "unload"); boolean shoot = getBooleantag(taladro, "shoot"); boolean reload = getBooleantag(taladro, "reload"); boolean enable = getBooleantag(taladro, "enable"); boolean habilitado=true; int municion= getInttag(taladro, "municion"); int municionmaxima = getInttag(taladro, "municionmaxima"); int ticksnesesarios= getInttag(taladro, "ticksnesesarios"); int tipoperforacion=getInttag(taladro, "tipoperforacion"); ArrayList<BlockPos> bl = new ArrayList<BlockPos>();bl.clear(); ArrayList<BlockPos> bl0 = new ArrayList<BlockPos>();bl0.clear(); bl=areaAfectada(worldIn, playerIn, taladro); BlockPos b=bl.get(0); chat.chatm(playerIn, "shoot"+shoot ); chat.chatm(playerIn, "reload"+ reload); chat.chatm(playerIn, "enable"+enable ); chat.chatm(playerIn, "municion"+municion ); chat.chatm(playerIn, "municionmaxima"+municionmaxima ); chat.chatm(playerIn, "ticksnesesarios"+ticksnesesarios ); chat.chatm(playerIn, "tipoperforacion"+ tipoperforacion); //chat.chatm(playerIn, ""+ ); //recargar if (habilitado & reload & (tick>=30)){ if( playerIn.inventory.hasItem(MercenaryModItems.suspensionderedstoneActivada) ) { //Municion Maxima Bug setInttag(taladro, "municion", 256 );//municionmaxima playerIn.inventory.consumeInventoryItem(MercenaryModItems.suspensionderedstoneActivada); playerIn.inventory.addItemStackToInventory(new ItemStack(Items.glass_bottle,1,0) ); setBooleantag(taladro, "reload",false); habilitado=false; } } //mandar a recargar si esta vacia if (habilitado & !reload & !shoot & (municion<=0) ){ if( playerIn.inventory.hasItem(MercenaryModItems.suspensionderedstoneActivada) ) { setBooleantag(taladro, "reload",true); setBooleantag(taladro, "enable",true); habilitado=false; } else {chat.chatm(playerIn, "No hay suspencion de redstone activada para recargar este taladro");} } //mandar a romper if (habilitado & !reload & !shoot & (municion>0) ){ if ( (hardenessb(worldIn,playerIn, b)) > (-1) ){ bl0=arearompible(worldIn, playerIn, taladro,bl); int lamasdura=lamasdura(worldIn, playerIn, bl0 ); int lamasdura0=lamasdura; int [] bb = new int[5]; bb[0]=b.getX(); bb[1]=b.getY(); bb[2]=b.getZ(); if (lamasdura > 4 & lamasdura < 21 ){lamasdura0=lamasdura*2;} setInttag(taladro, "ticksnesesarios", (lamasdura0*2) ); setInttag(taladro, "dureza", lamasdura); setBooleantag(taladro, "shoot", enable); setBooleantag(taladro, "enable",true); setBooleantag(taladro, "reload",false); setBooleantag(taladro, "unload",false); setIntArraytag(taladro, "coordenadas", bb); habilitado=false; } } //romper if (habilitado & !reload & shoot & (municion>0) & (tick>=ticksnesesarios) ){ //prueba int [] coor0 = getIntArraytag(taladro, "coordenadas"); if(coor0[0]==b.getX()){ if(coor0[1]==b.getY()){ if(coor0[2]==b.getZ()){ bl0=arearompible(worldIn, playerIn, taladro,bl); romper(worldIn, playerIn, taladro, bl0); int dureza=(getInttag(taladro, "dureza") /4 )+2 ; municion=municion-dureza; }}} setBooleantag(taladro, "shoot", false); setBooleantag(taladro, "enable",true); setBooleantag(taladro, "reload",false); setBooleantag(taladro, "unload",false); setInttag(taladro, "municion", municion); //romper(worldIn, playerIn,taladro, bl); habilitado=false; } if (habilitado){ setBooleantag(taladro, "shoot", false); setBooleantag(taladro, "enable",true); setBooleantag(taladro, "reload",false); setBooleantag(taladro, "unload",false); setInttag(taladro, "ticksnesesarios", 0 ); setInttag(taladro, "dureza", -1); } }//is ! remote } //########################################################################3 //########################################################################3 @Override public ItemStack onItemUseFinish(ItemStack taladro, World worldIn, EntityPlayer playerIn) { if(!worldIn.isRemote){ setBooleantag(taladro, "shoot", false); setBooleantag(taladro, "enable",true); setBooleantag(taladro, "reload",false); setBooleantag(taladro, "unload",false); }//is ! remote return taladro; } //########################################################################3 @Override public int getMaxItemUseDuration(ItemStack taladro) { return 1000; } @Override public EnumAction getItemUseAction(ItemStack taladro) { return EnumAction.NONE; } //#########################################################################3 public static void intialize(ItemStack taladro, EntityPlayer playerIn){ //System.out.println("#\n#\n#\n Incializacion"); int mm=0; int tp=0; switch(taladro.getMetadata()){ default: mm=0;break; case 0: case 1: case 2: mm=20;tp=1;break; case 3: case 4: case 5: mm=32;tp=2;break; case 6: case 7: case 8: mm=128;tp=3;break; } int m=0; switch(taladro.getMetadata()){ default: m=0;break; case 0: case 3: case 6: m=0;break; case 1: case 4: case 7: m=mm/2;break; case 2: case 5: case 8: m=mm;break; } int [] array = new int[5]; array[0]=0;array[1]=0;array[2]=0;array[3]=0; setInttag(taladro, "texturajson", 0); setInttag(taladro, "municion", 0); setInttag(taladro, "municionmaxima", 256); setInttag(taladro, "ticksnesesarios", 0); setInttag(taladro, "tipomunicion", 0); setInttag(taladro, "dureza", 0); setInttag(taladro, "tipoperforacion", 1); setIntArraytag(taladro,"coordenadas",array); setBooleantag(taladro, "izquierda",false); setBooleantag(taladro, "reload", false); setBooleantag(taladro, "shoot", false); setBooleantag(taladro, "unload", false); setFloattag(taladro, "strength", 0.0F); setBooleantag(taladro, "enable", true); setBooleantag(taladro, "inicializado", true); } //#########################################################################3 public static float getFloattag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 999.9F; } float ex=etiquetas.getFloat(tag); return ex; } //#########################################################################3 public static void setFloattag(ItemStack item, String tag, float value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setFloat(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static int[] getIntArraytag(ItemStack item, String tag){ int[] array = new int[5]; NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); array[0]=9999; return array; } array=etiquetas.getIntArray(tag); return array; } //#########################################################################3 public static void setIntArraytag(ItemStack item, String tag, int[] value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setIntArray(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static int getInttag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return 9999; } int ex=etiquetas.getInteger(tag); return ex; } //#########################################################################3 public static void setInttag(ItemStack item, String tag, int value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); } etiquetas.setInteger(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public static Boolean getBooleantag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = new NBTTagCompound(); item.setTagCompound(etiquetas); return false; } boolean ex=etiquetas.getBoolean(tag); return ex; } //#########################################################################3 public static void setBooleantag(ItemStack item, String tag, boolean value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ etiquetas = item.getTagCompound(); } etiquetas.setBoolean(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 public int getItemEnchantability() { return 1; } //#########################################################################3 @SideOnly(Side.CLIENT) public void addInformation(ItemStack taladro, EntityPlayer playerIn, List list, boolean aBoolean) { int municion =getInttag(taladro, "municion"); if((municion>9998)||(municion<0)){ intialize(taladro, playerIn); } String lore="RedStone="+municion; String lore0=""; String lore1="Uses solution of redstone activated"; String lore2="Hold LeftShift + LeftClick to Change hole size"; //getInttag(taladro, "tipocargador");taladro.getMetadata() switch(getInttag(taladro, "tipoperforacion")){ case 1: lore0="current mode one Block";break; case 2: lore0="current mode two Blocks";break; case 3: lore0="current mode four Blocks left";break; case 4: lore0="current mode four Blocks Rigth";break; case 5: lore0="current mode nine Blocks";break; case 6: lore0="current mode twentyFive Blocks";break; case 7: lore0="current mode FourtyNine Blocks";break; } list.add(lore); list.add(lore0); list.add(lore1); list.add(lore2); } //#########################################################################3 } [!code] i have a little trouble whit something i call switch animation to try and minimize that bug i set mi code to write nbttags only in onstop using, http://www.minecraftforge.net/forum/index.php/topic,28710.msg148126.html#msg148126 this code check if there is redstone in the drill but the name of nbtag is called internaly "municion" the method to break blocks is called romper() //line646 and only is called when (!worldIn.isremote) and i belibe the trouble has to be whith thath
  6. yap the error says it at net.minecraft.inventory.Container.getSlot(Container.java:138) ~[Container.class:?] begins in the line 138 from Container.java but this one could be before whitouth see code and whith this 36, iam 80% thath there is a "for" to scan the player inventory and is set to for (int x=0; x <= inventorysize; x++) when it must be only x < inventorysize
  7. hello ibeen working whith the guides and get stuck whi this ForgeSubscribe error: "The import net.minecraftforge.event.ForgeSubscribe cannot be resolved"; there is not import net.minecraftforge.event.ForgeSubscribe; in 1.8 and sems like eclipse could find it could some one point me where it is the equivalent of ForgeSubscribe in 1.8 thanks
  8. ñaaa well in this moment this item is no using the keybind or the packages, whi it i have 3 guns and two bows that make use of key bind and packages to change shoot mode an onload the clip and all o this work in server is this one drill and there is a shears the comon factor is than this items breaks blocks the others just spawn entityes i dont wana reddo the drill coze it take like two days of coding
  9. good days i have a few months working on a mod, one day i decide to test it in a server and it crash i have like 180 items betwin tools and blocks i get stressed and shit all and begin again at this point i have a lot of items 3 fireguns and two bows that work well on server and a package system and a keybind system all of this works well on the server and in the client then i have this this item breaks blocks has diferent modes from 1 block to 4 blocks can be upgrade whith efficence to break wider tunnels and uses suspension of redstone for fuel. this is video is from the normal minecraft client and here it works perfect but when try to use the item in server it does absolutly nothing the last time i have this same trouble was becose i forgot to override the methods in the items, this is not the case everithing is overrided jumm any idea ? what else could cause than an item works on client but not in server
  10. good days i wana doo something that sound some how easy but i dont think so. i alredy make a fn p90 gun i have done it complex it can shoot on manual semi and automatic mode has its bullets clip ap to 64 bullets and can work whith diferen types of munition i been set keybinds to extract clip and change the shoot mode. but now i wanna give this weapon a little icon in the down left side of the screen showing munition and shooting mode only visible when the gun is selected and i dont know where to start i been reading the guide for tile entityes but that kind of gui looks like it stop the player from moving while open suggestion??
  11. good days i have this gun clip i wanna reload in the workbench by just puit in whith a stack of bullets, lets say i put the clip whith a stack of 64 bullets in the output get the reloaded clip whith 64 bullets inside but in the left side remain 63 bullets https://drive.google.com/file/d/0B8sU_NyZQBd7UzJVaHYzMW5YYjQ/view?usp=sharing it just consume one bullet from the stack of 64 and return the clip whit 32 bullts but it must consume 32 bullets not just one this is the recipe GameRegistry.addShapelessRecipe(new ItemStack(MercenaryModItems.clipFor90PNF,1,2), //output new ItemStack(MercenaryModItems.clipEmpty90PNF_vacio, 1,0), //input new ItemStack(MercenaryModItems.bullet5728mm ,32,0) ); //input someone know how to fix this
  12. yes at mostly there is this animation who ocurs when receeds to grab the next item in the hotbar. like i was teling later it makes the item to go down and then to come up but whith the next item in the series of experiments, i do realize that when you change any nbt tag in a item this does the "swicth animation" no matter what i change i think is becose the item get reset minecraft someway deletes the old one and create a new one whith the new data then minecraft reloaded it as new so it makes the "switch animation" to change from the old item to the new whithin the new data soo could'n be posible to make an animation based in Nbttags whithout this anoying feature //################################################################################## public ModelResourceLocation getModel(ItemStack prueba, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation= new ModelResourceLocation("modmercenario:prueba/prueba00", "inventory"); int texturajson=getInttag(prueba, "texturajson"); //nbtTag gets read here switch(texturajson){ default : modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba00", "inventory");break; case 1: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba01", "inventory");break; case 2: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba02", "inventory");break; case 3: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba03", "inventory");break; } return modelresourcelocation; } conclusion : minecraft does "switch animation" When * you switch items • nbttag data change • when yo rigth click aiming to a close block but not an entity based on this I reddo mi code way it only write nbttags on onPlayerStoppedUsing() and calculate how many bullets has been shoot and do swicht textures based on the value of int timeLeft and int useRemaining still less anoying but still anoying it does the switch animation everytime i release rigth click thats when it writes the nbttags values for munition remaining and stuff look at this other video what i wanna fix its this gun moving up and down every time i shoot. that moving up and down animation is what i call "switch animation" and this last one im pretty pride of this machine gun it just do "switch animation" when onPlayerStoppedUsing() just when end shooting or when end load or reload animation the 64 bullets are done in just 4 seconds if there is no way to dissably "switch animation" the only i could thing is make my own nbttag system reading and writing to plain text file every gun value per gun and my own ticking class based in onUpdate(). just to not use nbttags
  13. good nigths this is little hard topic to explain, english is not mi native languague but event in espanish is hard to explain, vainilla minecraft has a custom animation on the items when you switch items , i dont know how is called ill named it "switch animation" you has a ironsword in the first slot of the hotbar then you change to the second slot that has an apple so minecraft do animated in way the iron sword moves down and then the apple comes up, this is a video showing what im talking about i discover this animation gets executed when an item enter in use whith the command playerIn.setItemInUse(ItemStack this.getMaxItemUseDuration(ItemStack)); when you have a bow and begin to pull it actualy do "switch animation" one time, then behaves normaly switch textures while you hold rigth click until you release the arrow and this is a trouble for what im triying to do, in this video i show the issue whith vainilla bow then whit mi custom bow and last mi custom pistol. this is what im triying to do, "fireguns", in this one when i shoot it does "switch animation" the pistol moves down change texture and then comes up, i put the zomby pigman to state that the pistol actualy works i du not know why mi videos dont get the sounds but well thats another trouble i been doing some experiments to realize whats happening. first this is the base of this type of animations this is my way of doit based more or less the way vainilla bow behaves //######################################################################################3 public ModelResourceLocation getModel(ItemStack prueba, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation= new ModelResourceLocation("modmercenario:prueba/prueba00", "inventory"); int texturajson=getInttag(prueba, "texturajson"); } switch(texturajson){ default : modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba00", "inventory");break; case 1: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba01", "inventory");break; case 2: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba02", "inventory");break; case 3: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba03", "inventory");break; case 4: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba04", "inventory");break; case 5: modelresourcelocation = new ModelResourceLocation("modmercenario:prueba/prueba05", "inventory");break; } return modelresourcelocation; } //######################################################################################3 public static int getInttag(ItemStack item, String tag){ NBTTagCompound taggs = item.getTagCompound(); if (taggs == null){ intialize(item); taggs = item.getTagCompound(); } int ex=taggs.getInteger(tag); return ex; } //#########################################################################3 public static void intialize(ItemStack prueba){ setInttag(prueba, "itemtick", 0); //count ticks especial cases setInttag(prueba, "texturajson", 0); //set json file in use setInttag(prueba, "municion", 0); setInttag(prueba, "municionmaxima", 20); setInttag(prueba, "municiondisponible", 0); setInttag(prueba, "munitiontype", 0); setInttag(prueba, "cliptype", 1); setBooleantag(prueba, "reload", false); setBooleantag(prueba, "shoot", false); setBooleantag(prueba, "unload", false); setBooleantag(prueba, "enable", false); //enables the onUpdate method } //#########################################################################3 in this case i select the texture to use whith the item based on the value of nbttag "texturejson" it has a trouble, and this was hard to understand at first sig it looks like a normal behaveor that minecraft do "swicht animation" every time i change the nbttag "texturejson" but its not i discover in mi experiments that when you change any nbttag its does the "swicht animation" i make take this custom item prueba.java and using onupdate() method to change nbttag "texturejson" from 0 to 6 and then stop , and it do this every time i touch left click in first person you can see the freeky "swicht animation" muving the item up and down the thirth person view is not afected, in this onupdate() method i comented everithing it has to be whith nbt "texturejson" just let the reading and writhing of nbttag "itemtick" and happend the same the item bounds up and down like crazy, but this time has nothing to do whit onItemRigthclick or set item on use. im to tired now to continue but the point its is posible to disable "swicht animation" just let item desapear and another apear in its place whitout animation, or how are they doing to animate items in [1.8]
  14. no i do the changes in the nbtags and no, the trouble persist mabi is a bug i been triying other tings looks that when no mather where i doit , if something change the nbttags from an item this get reset and playerIn.setItemInUse get restarted. //#########################################################################3 public static int getInttag(ItemStack item, String tag){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ intialize(item); etiquetas = item.getTagCompound(); } int ex=etiquetas.getInteger(tag); return ex; } //#########################################################################3 public static void setInttag(ItemStack item, String tag, int value){ NBTTagCompound etiquetas = item.getTagCompound(); if (etiquetas == null){ intialize(item); etiquetas = item.getTagCompound(); } etiquetas.setInteger(tag, value); item.setTagCompound(etiquetas); } //#########################################################################3 i gonna make another post exposing my teories.
  15. interesting this was fast, i gonna use that in my code
  16. this one an the other one post and some how related but this is it lets say i have a halebale in the first slot of the hotbar and a wool block in the secund if i change from slot 0 to slot 1, it start this animation, the halebale moves down and woolblock cames up this is the normal minecraft behaveour and you can see it every time you move in the hotbar this animation can be disabled ? i want just to disappear the halebale and then apear in the steves hand the wool block
  17. good days im triying to make an animated item swiching json files but i been notice when in my code try to write an nbt in the onUsingTick() method i just break and causes the playerIn.setItemInUse(pistola, this.getMaxItemUseDuration(pistola)); to stop and execute onPlayerStoppedUsing() for example @Override public int getMaxItemUseDuration(ItemStack pistola) { return 1000; } @Override public EnumAction getItemUseAction(ItemStack pistola) { return EnumAction.NONE; } //######################################################################################3 @Override public ItemStack onItemRightClick(ItemStack pistola, World worldIn, EntityPlayer playerIn) { playerIn.setItemInUse(pistola, this.getMaxItemUseDuration(pistola)); return pistola; } //######################################################################################3 @Override public void onUsingTick(ItemStack pistola, EntityPlayer playerIn, int count) { setInttag(pistola,"munition", 0 ); } //#########################################################################3 public static void setInttag(ItemStack its, String tag, int value){ try{ NBTTagCompound nsInt= its.getTagCompound(); nsInt.setInteger(tag, value); its.setTagCompound(nsInt); }catch(Throwable any) { NBTTagCompound nsInt = new NBTTagCompound(); nsInt.setInteger(tag, value); its.setTagCompound(nsInt); }} //#########################################################################3 @Override public void onPlayerStoppedUsing(ItemStack pistola, World worldIn, EntityPlayer playerIn, int timeLeft) { System.out.println(" timeLeft"+ timeLeft); } when i release rigth click it get stuck and dont reach onPlayerStoppedUsing , it continues until it counts to 1000, but if i comment //setInttag(pistola,"munition", 0 ); in onUsingTick() [22:13:17] [Client thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft999 [22:13:17] [server thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft999 [22:13:18] [Client thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft996 [22:13:18] [server thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft996 [22:13:20] [Client thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft988 [22:13:20] [server thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft988 [22:13:21] [Client thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft984 [22:13:21] [server thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft984 [22:13:23] [Client thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft987 [22:13:23] [server thread/INFO] [sTDOUT]: [mercenarymod.items.armasdefuego.pistola75nf.pistola75NF:onPlayerStoppedUsing:460]: timeLeft987 it begins to work like it must jummmm ¿is there a work aroun thath alow my to writte nbts from onUsingTick() ?
  18. good days im fixing some items i get this again i have this crossbow and i want it to remian down the crosshair horizontally aiming to the crosshair exactly in the middle of the screen this rotation works on some imaginary point at the down rigth side of the screen "translation": [ 0, 0, 0 ], and the other i want to set down the crosshair exactly in the horizontal middle is when pulling the bow animation EnumAction.BOW i wanna steve pulling the bow rigth down the crosshair when pulling but on hand this hass been, well close to the point but not where it must be https://drive.google.com/file/d/0B8sU_NyZQBd7R29VNkhCSnF6Q2s/view?usp=sharing { "parent": "builtin/generated", "textures": { "layer0": "modmercenario:items/arcos/vallestaMercenaria00" }, "display": { "thirdperson": { "rotation": [ 0, 90, -35 ], "translation": [ 0, 1.25, -3.5 ], "scale": [ 0.85, 0.85, 0.85 ] }, "firstperson": { "rotation": [ 0, -135, 25 ], "translation": [ 0, 4, 2 ], "scale": [ 1.7, 1.7, 1.7 ] } } }
  19. good days i been creating a custom bow and a custom arrow, the bow is ready item arrow its done but entity arrow, I have the code, it does less damage than vainilla arrow but more speed i can pickup this custom arrow but dont get how to make it load a texture is invisible soo the first question is , this is 1.8 the render must be a json file or a techne model ? then how i declare it in this entity arrow class and i been reading thath the renders for entities must have entraces in the proxy files im like newbee whit this of proxy's well thankyou. flechaMercenaria_entity.java package mercenarymod.items.arcos; import java.util.List; import mercenarymod.items.MercenaryModItems; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IProjectile; import net.minecraft.entity.monster.EntityEnderman; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.Items; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.play.server.S2BPacketChangeGameState; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.BlockPos; import net.minecraft.util.DamageSource; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.MathHelper; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.ResourceLocation; import net.minecraft.util.Vec3; import net.minecraft.world.World; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; public class flechaMercenaria_entity extends Entity implements IProjectile { private int xTile = -1; private int yTile = -1; private int zTile = -1; private Block inTile; private int inData; private boolean inGround; /** 1 if the player can pick up the arrow */ public int canBePickedUp; /** Seems to be some sort of timer for animating an arrow. */ public int arrowShake; /** The owner of this arrow. */ public Entity shootingEntity; private int ticksInGround; private int ticksInAir; //Daño causado = (3.68*damage/0.24) 0.24 3.68 private double damage = 0.30D; //0.20 equivale a 3.06 de daño //0.62D; //0.62 equivale a 8.184 de daño /** The amount of knockback an arrow applies when it hits a mob. */ private int knockbackStrength=0; private static final String __OBFID = "CL_00001715"; public flechaMercenaria_entity(World worldIn) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); } public flechaMercenaria_entity(World worldIn, double x, double y, double z) { super(worldIn); this.renderDistanceWeight = 10.0D; this.setSize(0.5F, 0.5F); this.setPosition(x, y, z); } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, EntityLivingBase p_i1755_3_, float p_i1755_4_, float p_i1755_5_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.posY = shooter.posY + (double)shooter.getEyeHeight() - 0.10000000149011612D; double d0 = p_i1755_3_.posX - shooter.posX; double d1 = p_i1755_3_.getEntityBoundingBox().minY + (double)(p_i1755_3_.height / 3.0F) - this.posY; double d2 = p_i1755_3_.posZ - shooter.posZ; double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2); if (d3 >= 1.0E-7D) { float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F; float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI)); double d4 = d0 / d3; double d5 = d2 / d3; this.setLocationAndAngles(shooter.posX + d4, this.posY, shooter.posZ + d5, f2, f3); float f4 = (float)(d3 * 0.20000000298023224D); this.setThrowableHeading(d0, d1 + (double)f4, d2, p_i1755_4_, p_i1755_5_); } } public flechaMercenaria_entity(World worldIn, EntityLivingBase shooter, float p_i1756_3_) { super(worldIn); this.renderDistanceWeight = 10.0D; this.shootingEntity = shooter; if (shooter instanceof EntityPlayer) { this.canBePickedUp = 1; } this.setSize(0.5F, 0.5F); this.setLocationAndAngles(shooter.posX, shooter.posY + (double)shooter.getEyeHeight(), shooter.posZ, shooter.rotationYaw, shooter.rotationPitch); this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.posY -= 0.10000000149011612D; this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F); this.setPosition(this.posX, this.posY, this.posZ); this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI)); this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI)); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, p_i1756_3_ * 1.5F, 1.0F); } protected void entityInit() { this.dataWatcher.addObject(16, Byte.valueOf((byte)0)); } /** * Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction. * * @param inaccuracy Higher means more error. */ public void setThrowableHeading(double x, double y, double z, float velocity, float inaccuracy) { float f2 = MathHelper.sqrt_double(x * x + y * y + z * z); x /= (double)f2; y /= (double)f2; z /= (double)f2; x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)inaccuracy; x *= (double)velocity; y *= (double)velocity; z *= (double)velocity; this.motionX = x; this.motionY = y; this.motionZ = z; float f3 = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI); this.ticksInGround = 0; } @SideOnly(Side.CLIENT) public void func_180426_a(double p_180426_1_, double p_180426_3_, double p_180426_5_, float p_180426_7_, float p_180426_8_, int p_180426_9_, boolean p_180426_10_) { this.setPosition(p_180426_1_, p_180426_3_, p_180426_5_); this.setRotation(p_180426_7_, p_180426_8_); } /** * Sets the velocity to the args. Args: x, y, z */ @SideOnly(Side.CLIENT) public void setVelocity(double x, double y, double z) { this.motionX = x; this.motionY = y; this.motionZ = z; if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(x * x + z * z); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch; this.prevRotationYaw = this.rotationYaw; this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch); this.ticksInGround = 0; } } /** * Called to update the entity's position/logic. */ public void onUpdate() { super.onUpdate(); if (this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F) { float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f) * 180.0D / Math.PI); } BlockPos blockpos = new BlockPos(this.xTile, this.yTile, this.zTile); IBlockState iblockstate = this.worldObj.getBlockState(blockpos); Block block = iblockstate.getBlock(); if (block.getMaterial() != Material.air) { block.setBlockBoundsBasedOnState(this.worldObj, blockpos); AxisAlignedBB axisalignedbb = block.getCollisionBoundingBox(this.worldObj, blockpos, iblockstate); if (axisalignedbb != null && axisalignedbb.isVecInside(new Vec3(this.posX, this.posY, this.posZ))) { this.inGround = true; } } if (this.arrowShake > 0) { --this.arrowShake; } if (this.inGround) { int j = block.getMetaFromState(iblockstate); if (block == this.inTile && j == this.inData) { ++this.ticksInGround; if (this.ticksInGround >= 1200) { this.setDead(); } } else { this.inGround = false; this.motionX *= (double)(this.rand.nextFloat() * 0.2F); this.motionY *= (double)(this.rand.nextFloat() * 0.2F); this.motionZ *= (double)(this.rand.nextFloat() * 0.2F); this.ticksInGround = 0; this.ticksInAir = 0; } } else { ++this.ticksInAir; Vec3 vec31 = new Vec3(this.posX, this.posY, this.posZ); Vec3 vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false); vec31 = new Vec3(this.posX, this.posY, this.posZ); vec3 = new Vec3(this.posX + this.motionX, this.posY + this.motionY, this.posZ + this.motionZ); if (movingobjectposition != null) { vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord); } Entity entity = null; List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D)); double d0 = 0.0D; int i; float f1; for (i = 0; i < list.size(); ++i) { Entity entity1 = (Entity)list.get(i); if (entity1.canBeCollidedWith() && (entity1 != this.shootingEntity || this.ticksInAir >= 5)) { f1 = 0.3F; AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().expand((double)f1, (double)f1, (double)f1); MovingObjectPosition movingobjectposition1 = axisalignedbb1.calculateIntercept(vec31, vec3); if (movingobjectposition1 != null) { double d1 = vec31.distanceTo(movingobjectposition1.hitVec); if (d1 < d0 || d0 == 0.0D) { entity = entity1; d0 = d1; } } } } if (entity != null) { movingobjectposition = new MovingObjectPosition(entity); } if (movingobjectposition != null && movingobjectposition.entityHit != null && movingobjectposition.entityHit instanceof EntityPlayer) { EntityPlayer entityplayer = (EntityPlayer)movingobjectposition.entityHit; if (entityplayer.capabilities.disableDamage || this.shootingEntity instanceof EntityPlayer && !((EntityPlayer)this.shootingEntity).canAttackPlayer(entityplayer)) { movingobjectposition = null; } } float f2; float f3; float f4; if (movingobjectposition != null) { if (movingobjectposition.entityHit != null) { f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); int k = MathHelper.ceiling_double_int((double)f2 * this.damage); if (this.getIsCritical()) { k += this.rand.nextInt(k / 2 + 2); } DamageSource damagesource; if (this.shootingEntity == null) { damagesource = DamageSource.causeThrownDamage(this, this); } else { damagesource = DamageSource.causeThrownDamage(this, this.shootingEntity); } if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman)) { movingobjectposition.entityHit.setFire(5); } if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) { if (movingobjectposition.entityHit instanceof EntityLivingBase) { EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit; if (!this.worldObj.isRemote) { entitylivingbase.setArrowCountInEntity(entitylivingbase.getArrowCountInEntity() + 1); } if (this.knockbackStrength > 0) { f4 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); if (f4 > 0.0F) { movingobjectposition.entityHit.addVelocity(this.motionX * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4, 0.1D, this.motionZ * (double)this.knockbackStrength * 0.6000000238418579D / (double)f4); } } if (this.shootingEntity instanceof EntityLivingBase) { EnchantmentHelper.func_151384_a(entitylivingbase, this.shootingEntity); EnchantmentHelper.func_151385_b((EntityLivingBase)this.shootingEntity, entitylivingbase); } if (this.shootingEntity != null && movingobjectposition.entityHit != this.shootingEntity && movingobjectposition.entityHit instanceof EntityPlayer && this.shootingEntity instanceof EntityPlayerMP) { ((EntityPlayerMP)this.shootingEntity).playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(6, 0.0F)); } } this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); if (!(movingobjectposition.entityHit instanceof EntityEnderman)) { this.setDead(); } } else { this.motionX *= -0.10000000149011612D; this.motionY *= -0.10000000149011612D; this.motionZ *= -0.10000000149011612D; this.rotationYaw += 180.0F; this.prevRotationYaw += 180.0F; this.ticksInAir = 0; } } else { BlockPos blockpos1 = movingobjectposition.getBlockPos(); this.xTile = blockpos1.getX(); this.yTile = blockpos1.getY(); this.zTile = blockpos1.getZ(); iblockstate = this.worldObj.getBlockState(blockpos1); this.inTile = iblockstate.getBlock(); this.inData = this.inTile.getMetaFromState(iblockstate); this.motionX = (double)((float)(movingobjectposition.hitVec.xCoord - this.posX)); this.motionY = (double)((float)(movingobjectposition.hitVec.yCoord - this.posY)); this.motionZ = (double)((float)(movingobjectposition.hitVec.zCoord - this.posZ)); f3 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ); this.posX -= this.motionX / (double)f3 * 0.05000000074505806D; this.posY -= this.motionY / (double)f3 * 0.05000000074505806D; this.posZ -= this.motionZ / (double)f3 * 0.05000000074505806D; this.playSound("random.bowhit", 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F)); this.inGround = true; this.arrowShake = 7; this.setIsCritical(false); if (this.inTile.getMaterial() != Material.air) { this.inTile.onEntityCollidedWithBlock(this.worldObj, blockpos1, iblockstate, this); } } } if (this.getIsCritical()) { for (i = 0; i < 4; ++i) { this.worldObj.spawnParticle(EnumParticleTypes.CRIT, this.posX + this.motionX * (double)i / 4.0D, this.posY + this.motionY * (double)i / 4.0D, this.posZ + this.motionZ * (double)i / 4.0D, -this.motionX, -this.motionY + 0.2D, -this.motionZ, new int[0]); } } this.posX += this.motionX; this.posY += this.motionY; this.posZ += this.motionZ; f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ); this.rotationYaw = (float)(Math.atan2(this.motionX, this.motionZ) * 180.0D / Math.PI); for (this.rotationPitch = (float)(Math.atan2(this.motionY, (double)f2) * 180.0D / Math.PI); this.rotationPitch - this.prevRotationPitch < -180.0F; this.prevRotationPitch -= 360.0F) { ; } while (this.rotationPitch - this.prevRotationPitch >= 180.0F) { this.prevRotationPitch += 360.0F; } while (this.rotationYaw - this.prevRotationYaw < -180.0F) { this.prevRotationYaw -= 360.0F; } while (this.rotationYaw - this.prevRotationYaw >= 180.0F) { this.prevRotationYaw += 360.0F; } this.rotationPitch = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * 0.2F; this.rotationYaw = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * 0.2F; f3 = 0.99F; f1 = 0.05F; if (this.isInWater()) { for (int l = 0; l < 4; ++l) { f4 = 0.25F; this.worldObj.spawnParticle(EnumParticleTypes.WATER_BUBBLE, this.posX - this.motionX * (double)f4, this.posY - this.motionY * (double)f4, this.posZ - this.motionZ * (double)f4, this.motionX, this.motionY, this.motionZ, new int[0]); } f3 = 0.6F; } if (this.isWet()) { this.extinguish(); } this.motionX *= (double)f3; this.motionY *= (double)f3; this.motionZ *= (double)f3; this.motionY -= (double)f1; this.setPosition(this.posX, this.posY, this.posZ); this.doBlockCollisions(); } } /** * (abstract) Protected helper method to write subclass entity data to NBT. */ public void writeEntityToNBT(NBTTagCompound tagCompound) { tagCompound.setShort("xTile", (short)this.xTile); tagCompound.setShort("yTile", (short)this.yTile); tagCompound.setShort("zTile", (short)this.zTile); tagCompound.setShort("life", (short)this.ticksInGround); ResourceLocation resourcelocation = (ResourceLocation)Block.blockRegistry.getNameForObject(this.inTile); tagCompound.setString("inTile", resourcelocation == null ? "" : resourcelocation.toString()); tagCompound.setByte("inData", (byte)this.inData); tagCompound.setByte("shake", (byte)this.arrowShake); tagCompound.setByte("inGround", (byte)(this.inGround ? 1 : 0)); tagCompound.setByte("pickup", (byte)this.canBePickedUp); tagCompound.setDouble("damage", this.damage); } /** * (abstract) Protected helper method to read subclass entity data from NBT. */ public void readEntityFromNBT(NBTTagCompound tagCompund) { this.xTile = tagCompund.getShort("xTile"); this.yTile = tagCompund.getShort("yTile"); this.zTile = tagCompund.getShort("zTile"); this.ticksInGround = tagCompund.getShort("life"); if (tagCompund.hasKey("inTile", ) { this.inTile = Block.getBlockFromName(tagCompund.getString("inTile")); } else { this.inTile = Block.getBlockById(tagCompund.getByte("inTile") & 255); } this.inData = tagCompund.getByte("inData") & 255; this.arrowShake = tagCompund.getByte("shake") & 255; this.inGround = tagCompund.getByte("inGround") == 1; if (tagCompund.hasKey("damage", 99)) { this.damage = tagCompund.getDouble("damage"); } if (tagCompund.hasKey("pickup", 99)) { this.canBePickedUp = tagCompund.getByte("pickup"); } else if (tagCompund.hasKey("player", 99)) { this.canBePickedUp = tagCompund.getBoolean("player") ? 1 : 0; } } /** * Called by a player entity when they collide with an entity */ public void onCollideWithPlayer(EntityPlayer entityIn) { if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0) { boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && entityIn.capabilities.isCreativeMode; if (this.canBePickedUp == 1 && !entityIn.inventory.addItemStackToInventory(new ItemStack(MercenaryModItems.flechaMercenaria, 1))) { flag = false; } if (flag) { this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F); entityIn.onItemPickup(this, 1); this.setDead(); } } } /** * returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to * prevent them from trampling crops */ protected boolean canTriggerWalking() { return false; } public void setDamage(double p_70239_1_) { this.damage = p_70239_1_; } public double getDamage() { return this.damage; } /** * Sets the amount of knockback the arrow applies when it hits a mob. */ public void setKnockbackStrength(int p_70240_1_) { this.knockbackStrength = p_70240_1_; } /** * If returns false, the item will not inflict any damage against entities. */ public boolean canAttackWithItem() { return false; } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public void setIsCritical(boolean p_70243_1_) { byte b0 = this.dataWatcher.getWatchableObjectByte(16); if (p_70243_1_) { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 | 1))); } else { this.dataWatcher.updateObject(16, Byte.valueOf((byte)(b0 & -2))); } } /** * Whether the arrow has a stream of critical hit particles flying behind it. */ public boolean getIsCritical() { byte b0 = this.dataWatcher.getWatchableObjectByte(16); return (b0 & 1) != 0; } }
  20. first yes, charcoal is metadata 1 form item.coal in mi mod i make a charcoalblock GameRegistry.addRecipe(new ItemStack(MercenaryModBlocks.charcoal, 1,0), new Object[] {"###", "###", "###", '#',new ItemStack(Items.coal ,1,1) }); and second you must create a parental json whith the dimensions you like, but this block its gona be hard to apilate, put one block up on another
  21. good nigths this afthernoon i get epiphany in a hangover and realize mi troubles the magic word Override when i do long time ago the first handgun i forget to override the onitemrigthclick from then i do all the rest items reusing this code changing only just things i need to change, and realize to the trouble whith nbttags returning null was just becoze some tags get written on local world this is the new clean code i gonna use to redo all the rest this one its workin on the server package mercenarymod.items.arcos; import mercenarymod.Mercenary; import mercenarymod.items.MercenaryModItems; import mercenarymod.utilidades.chat; import mercenarymod.utilidades.nbtMercenaria; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.stats.StatList; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class arcoMercenario extends Item { public arcoMercenario() { String name = "arcoMercenario"; setUnlocalizedName(Mercenary.MODID + "_" + name); GameRegistry.registerItem(this, name); setCreativeTab(Mercenary.herramientas); this.maxStackSize = 1; this.setMaxDamage(1000); } //####################################################################################3 @Override public ModelResourceLocation getModel(ItemStack arco, EntityPlayer playerIn, int useRemaining){ int tick; if (useRemaining>970){tick=30-(useRemaining-970);} else {tick=30;} ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory"); int municion= getInttag(arco, "municion"); if(municion < 0 | municion > 9998){intialize(arco,playerIn);} int texturajson=getInttag(arco, "texturajson"); boolean shoot = getBooleantag(arco, "shoot"); switch(texturajson){ case 0:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory") ;break; case 1:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario01", "inventory") ;break; case 2:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario02", "inventory") ;break; case 3:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario03", "inventory") ;break; } if (shoot){ switch(tick){ case 0: setInttag(arco, "texturajson",0 );break; case 1: setInttag(arco, "texturajson",1 );break; case 12: setInttag(arco, "texturajson",2 );break; case 24: setInttag(arco, "texturajson",3 );break; } //System.out.println("useRemaining="+useRemaining+"\ntexturajson="+texturajson+"\n f="+getFloattag(arco, "strength")+" tick="+tick); //System.out.println("tick="+tick); } //setInttag(arco, "municion",10 ); return modelresourcelocation; } //#########################################################################3 @Override public ItemStack onItemRightClick(ItemStack arco, World worldIn, EntityPlayer playerIn) { //System.out.println(" On rigth click "); setBooleantag(arco, "shoot", true); playerIn.setItemInUse(arco, this.getMaxItemUseDuration(arco)); return arco; } //####################################################################################3 @Override public void onUsingTick(ItemStack arco, EntityPlayer player, int count) { } @Override public void onPlayerStoppedUsing(ItemStack arco, World worldIn, EntityPlayer playerIn, int timeLeft) { int tick; if (timeLeft>970){tick=30-(timeLeft-970);} else {tick=30;} float f=((tick/30F)*3F); if (!worldIn.isRemote){ playerIn.inventory.consumeInventoryItem(MercenaryModItems.flechaMercenaria); EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f ); worldIn.spawnEntityInWorld(entityarrow); //chat.chatdp(playerIn, "shooting force f="+f); setBooleantag(arco, "shoot", false); arco.damageItem(1, playerIn);//dañar con el uso } } @Override public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { return stack; } public int getMaxItemUseDuration(ItemStack stack) { return 1000; } @Override public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } //#########################################################################3 public static void intialize(ItemStack arco, EntityPlayer playerIn){ //System.out.println("#\n#\n#\n Incializacion"); setInttag(arco, "texturajson", 0); setInttag(arco, "municion", 0); setBooleantag(arco, "reload", false); setBooleantag(arco, "shoot", false); setBooleantag(arco, "unload", false); setFloattag(arco, "strength", 0.0F); } //#########################################################################3 public static int getInttag(ItemStack its, String tag){ NBTTagCompound nsInt = new NBTTagCompound(); try { NBTTagCompound exi= its.getTagCompound(); int ex=exi.getInteger(tag); return ex; } catch (Throwable any) { return 9999; } } //#########################################################################3 public static void setInttag(ItemStack its, String tag, int value){ try{ NBTTagCompound nsInt= its.getTagCompound(); nsInt.setInteger(tag, value); its.setTagCompound(nsInt); }catch(Throwable any) { NBTTagCompound nsInt = new NBTTagCompound(); nsInt.setInteger(tag, value); its.setTagCompound(nsInt); }} //#########################################################################3 public static float getFloattag(ItemStack its, String tag){ NBTTagCompound nsInt = new NBTTagCompound(); try { NBTTagCompound exi= its.getTagCompound(); float ex=exi.getFloat(tag); return ex; } catch (Throwable any) { return 9999.00F; } } //#########################################################################3 public static void setFloattag(ItemStack its, String tag, float value){ try{ NBTTagCompound nsInt= its.getTagCompound(); nsInt.setFloat(tag, value); its.setTagCompound(nsInt); }catch(Throwable any) { NBTTagCompound nsInt = new NBTTagCompound(); nsInt.setFloat(tag, value); its.setTagCompound(nsInt); }} //#########################################################################3 public static Boolean getBooleantag(ItemStack its, String tag){ NBTTagCompound nsInt = new NBTTagCompound(); try { NBTTagCompound exi= its.getTagCompound(); boolean ex=exi.getBoolean(tag); return ex; } catch (Throwable any) { return false; } } //#########################################################################3 public static void setBooleantag(ItemStack its, String tag, boolean value){ try{ NBTTagCompound nsInt= its.getTagCompound(); nsInt.setBoolean(tag, value); its.setTagCompound(nsInt); }catch(Throwable any) { NBTTagCompound nsInt = new NBTTagCompound(); nsInt.setBoolean(tag, value); its.setTagCompound(nsInt); }} //#########################################################################3 public int getItemEnchantability() { return 1; } //#########################################################################3 } there is still this little one misbehavior when using the bow it begins to swing the bow , but is not like the swing of the pickaxe this is more like, let say i have a rawMutton on slot 0 of the hotbar and a block of wool in the second slot and i change from slot 0 to slot 2 the rawMutton goes down and the block of wool cames up, i think this is the behaviour of changin json files but dont understand why is happen to my items but is not hapening in the vainilla bow change texture
  22. bueno then this is the normal behavior that whas the first thing i think, but in the greywolfs code he puts the items gameregistry and unlocalizated name in commonProxy, that dont work in mi code i dunot know why then the mercenaryModitems.class must be in the preinit from the main class to initializate all mi items this is the way i been seen it other codes about the bow not working, this is just a scrap from all mi code i just get remove everything else, recipes, blocks, events, to make more easy the reason way this items fail, i have made a lot of items thath do something when rigth click, guns that shoot, chainsaw , drills dinamite but any of this items works when runing on a server and now i I think the fault lies in the proxyes in this case the bow must consume an arrow, thingten then release the arrow this is not happening when runing in the server but in eclipse or in minecraft normal game this works i have a video here to prove it and this post is the begining of this threath http://www.minecraftforge.net/forum/index.php/topic,28397.0.html and now then the question is the code i put on 7zip file this is the rigth way of using proxyes. ?
  23. good days alredy remove the notations "@Mod.EventHandler" in clienproxy and commondproxy and now i have some progress and some new questions I set some systemouts to see whats working and now eclipse its ignoring the CommonProxy but is loading ClientProxy and CommonProxy is the one registering the items in to workaround i have to move the mercenaryModItems.init(); to the preInit() in the main class whit this fix i get the items registered and now the bow works in eclipse then compile it and put the jar in the server and this is odd very odd cos server is loading CommonProxy and do it whitout show any error eclipse ignores commond proxy so i cant'n initialize mi items there, but in minecraftServer it loads anyway still having the same issue from long before, i have this item bow, it works in eclipse and if i put it in normal vainilla minecraft its works as well ,but when in a server it does nothing and sometimes desapear or become another item. jumm so long the questions are, -why is eclipse and vainilla minecraft ignoring this commond proxy but server dont -why this bow works in eclipse and vainilla minecraft but not in server this is the source code https://drive.google.com/file/d/0B8sU_NyZQBd7Rk9VcXpLWWZTNXc/view?usp=sharing this is the compiled mod https://drive.google.com/file/d/0B8sU_NyZQBd7ZmhNZThUZE9JSEU/view?usp=sharing thi is log from server cmd [08:43:27] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:preInit:26]: ######## CommonProxy preInit() 08:43:27] [server thread/INFO] [FML]: Applying holder lookups [08:43:27] [server thread/INFO] [FML]: Holder lookups applied [08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Loading properties [08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Default game type: SURVIVAL [08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Generating keypair [08:43:27] [server thread/INFO] [net.minecraft.server.dedicated.DedicatedServer]: Starting Minecraft server on *:25565 [08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: **** SERVER IS RUNNING IN OFFLINE/INSECURE MODE! [08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: The server will make no attempt to authenticate usernames. Beware. [08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: While this makes the game possible to play without internet access, it also opens up the ability for hackers to connect with any username they choose. [08:43:27] [server thread/WARN] [net.minecraft.server.dedicated.DedicatedServer]: To change this, set "online-mode" to "true" in the server.properties file. [08:43:27] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:init:40]: ######## CommonProxy init() [08:43:27] [server thread/INFO] [sTDOUT]: [com.example.examplemod.ExampleMod:init:18]: DIRT BLOCK >> tile.dirt [08:43:28] [server thread/INFO] [sTDOUT]: [mercenarymod.CommonProxy:postInit:53]: ######## CommonProxy postInit() clean CommonProxy package mercenarymod; import mercenarymod.blocks.MercenaryModBlocks; import mercenarymod.items.MercenaryModItems; import net.minecraft.item.Item; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class CommonProxy { // Client stuff public void registerRenderers() { // Nothing here as the server doesn't render graphics or entities! } //@Mod.EventHandler public void preInit() { System.out.println("########\n\n\n CommonProxy preInit()"); //MercenaryModItems.init(); } //@Mod.EventHandler public void init() { System.out.println("########\n\n\n CommonProxy init()"); } //@Mod.EventHandler public void postInit() { System.out.println("########\n\n\n CommonProxy postInit()"); } } clean ClientProxy package mercenarymod; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import mercenarymod.CommonProxy; import mercenarymod.blocks.MercenaryModBlocks; import mercenarymod.items.MercenaryModItems; public class ClientProxy extends CommonProxy { //@Override public void registerRenderers() { // This is for rendering entities and so forth later on } public void preInit(){ System.out.println("########\n\n\n ClientProxy preInit()"); } public void init() { System.out.println("########\n\n\n ClientProxy init()"); mercenarymod.MercenaryModTexturas.init(); } public void postInit() { System.out.println("########\n\n\n ClientProxy postInit()"); } }
  24. good days im trying to fix some omisions in my first mod and there is this proxy thing, in the basic guides they dont speak much about proxy's, now i been reading MinecraftByExample codes to realize how to use proxies, for whath i habe understood, there is this this to proxy's for the way , commonProxy run in local world and server and here goes every item/block registry and the unlocalizated name variable and clienProxy run just in local world and has the register textures to use whith the items, so there is mi piece of mod whit just one item a bow "arcoMercenario" package mercenarymod; import mercenarymod.blocks.MercenaryModBlocks; import mercenarymod.items.MercenaryModItems; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.client.registry.RenderingRegistry; import net.minecraftforge.fml.common.FMLCommonHandler; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.SidedProxy; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraft.creativetab.CreativeTabs; @Mod(modid = Mercenary.MODID, version = Mercenary.VERSION) public class Mercenary { public static final String MODID = "modmercenario"; public static final String VERSION = "1.7"; public static SimpleNetworkWrapper network; // Says where the client and server 'proxy' code is loaded. @SidedProxy(clientSide="mercenario.ClientProxy", serverSide="mercenarymod.CommonProxy") public static CommonProxy proxy; @EventHandler public void preInit(FMLPreInitializationEvent event) { proxy.preInit(event); } @EventHandler public void init(FMLInitializationEvent event) { proxy.init(event); } @EventHandler public void postInit(FMLPostInitializationEvent event) { proxy.postInit(event); } public static CreativeTabs herramientas = new CreativeTabs("Herraminetas armas y\n armaduras mercenarias") { @Override @SideOnly(Side.CLIENT) public Item getTabIconItem() { //return MercenaryModItems.aceroMercenario; return Items.potato; } }; public static CreativeTabs materiales = new CreativeTabs("materiales mercenarios") { @Override @SideOnly(Side.CLIENT) public Item getTabIconItem() { //return MercenaryModItems.nokiaMercenaria; return Items.potato; } }; } eclipse make my add the "event" inside proxy.preInit(event); coz "The method preInit(FMLPreInitializationEvent) in the type CommonProxy is not applicable for the arguments ()" mercenario.ClientProxy package mercenarymod; import net.minecraft.client.Minecraft; import net.minecraft.client.resources.model.ModelBakery; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import mercenarymod.CommonProxy; import mercenarymod.blocks.MercenaryModBlocks; import mercenarymod.items.MercenaryModItems; public class ClientProxy extends CommonProxy { @Override public void registerRenderers() { // This is for rendering entities and so forth later on } @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { Configuration config = new Configuration(event.getSuggestedConfigurationFile()); } @Mod.EventHandler public void init(FMLInitializationEvent event) { ModelBakery.addVariantName(MercenaryModItems.arcoMercenario, new String[]{ "modmercenario:arcos/arcomercenario/arcomercenario00", "modmercenario:arcos/arcomercenario/arcomercenario01", "modmercenario:arcos/arcomercenario/arcomercenario02", "modmercenario:arcos/arcomercenario/arcomercenario03", "modmercenario:arcos/arcomercenario/flechaMercenaria" }); Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(MercenaryModItems.arcoMercenario,0 , new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory")); } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { } } mercenarymod.CommonProxy package mercenarymod; import mercenarymod.blocks.MercenaryModBlocks; import mercenarymod.items.MercenaryModItems; import net.minecraft.item.Item; import net.minecraftforge.common.config.Configuration; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.event.FMLPreInitializationEvent; import net.minecraftforge.fml.common.registry.GameRegistry; public class CommonProxy { // Client stuff public void registerRenderers() { // Nothing here as the server doesn't render graphics or entities! } public static Item arcoMercenario; @Mod.EventHandler public void preInit(FMLPreInitializationEvent event) { arcoMercenario = (mercenarymod.items.arcos.arcoMercenario)(new mercenarymod.items.arcos.arcoMercenario().setUnlocalizedName("arcoMercenario")); GameRegistry.registerItem(arcoMercenario, "arcoMercenario"); } @Mod.EventHandler public void init(FMLInitializationEvent event) { } @Mod.EventHandler public void postInit(FMLPostInitializationEvent event) { } } the bow mercenarymod.items.arcos.arcoMercenario.java package mercenarymod.items.arcos; import mercenarymod.Mercenary; import mercenarymod.items.MercenaryModItems; import mercenarymod.utilidades.chat; import mercenarymod.utilidades.nbtMercenaria; import net.minecraft.client.resources.model.ModelResourceLocation; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.stats.StatList; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.registry.GameRegistry; public class arcoMercenario extends Item { //public static String name = "arcoMercenario"; int tick=0; int texturajson=0; boolean tighten=false; boolean animacion=false; boolean continuar=false; float f=0.0F; int municion=0; int municionMax=0; static int municionMax0=32; public arcoMercenario() { //setUnlocalizedName(Mercenary.MODID + "_" + name); //GameRegistry.registerItem(this, name); setCreativeTab(Mercenary.herramientas); this.maxStackSize = 1; this.setMaxDamage(500); } //######################################################################################3 @Override public ModelResourceLocation getModel(ItemStack arco, EntityPlayer playerIn, int useRemaining){ ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory"); animacion(arco, playerIn); if ((tick%10)==0){ //just to not check it every tick, it lags animacion=nbtMercenaria.getBooleantag(arco, "animacion"); //System.out.println("Animacion="+animacion); if(!animacion){ tighten=false; } } //System.out.println("textura="+textura); switch(this.texturajson){ default:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario00", "inventory") ;break; case 1:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario01", "inventory") ;break; case 2:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario02", "inventory") ;break; case 3:modelresourcelocation = new ModelResourceLocation("modmercenario:arcos/arcomercenario/arcomercenario03", "inventory") ;break; } tick++; if (tick>100){tick=0;nbtMercenaria.setBooleantag(arco, "animacion",false);animacion=false;} return modelresourcelocation; } //####################################################################################3 void animacion(ItemStack arco, EntityPlayer playerIn){ //int tick //System.out.println("()this.thick="+tick+" cambioDeBotella="+cambioDeBotella+" giro="+giro); if ((tighten)){ System.out.println("tighten="+tick); switch (tick){ case 0: texturajson=0;f=0.50F;break; case 7: texturajson=1;f=1.00F;break; case 14: texturajson=2;f=1.50F;break; case 21: texturajson=3;f=2.00F;break; case 28: if(continuar){tick=20;};break; case 30: texturajson=0;tick=0;nbtMercenaria.setBooleantag(arco, "animacion",false);tighten=false;break; } } else{texturajson=0;} } //####################################################################################3 void inicializar(ItemStack arco){ //this do nothing for now int municion=0; int metadata=arco.getMetadata(); switch(metadata){ case 1: municion=municionMax0/2;break; case 2: municion=municionMax0;break; default:municion=0;break; } nbtMercenaria.setInttag(arco, "municion", municion); nbtMercenaria.setBooleantag(arco, "animacion", false); nbtMercenaria.setBooleantag(arco, "liberar", false); nbtMercenaria.setInttag(arco, "cargador", 0); nbtMercenaria.setInttag(arco, "textura", 0); } //####################################################################################3 public void onPlayerStoppedUsing(ItemStack arco, World worldIn, EntityPlayer playerIn, int timeLeft) { if (!worldIn.isRemote){ playerIn.inventory.consumeInventoryItem(MercenaryModItems.flechaMercenaria); EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f ); worldIn.spawnEntityInWorld(entityarrow); chat.chatdp(playerIn, "disparando f="+f); f=0.0F; nbtMercenaria.setBooleantag(arco, "animacion", false); } texturajson=0;tick=0;tighten=false;continuar=false; } public ItemStack onItemUseFinish(ItemStack stack, World worldIn, EntityPlayer playerIn) { //texturajson=0;tick=0;tighten=false; return stack; } public int getMaxItemUseDuration(ItemStack stack) { return 72000; } public EnumAction getItemUseAction(ItemStack stack) { return EnumAction.BOW; } //#####################################################################################3 public ItemStack onItemRightClick(ItemStack arco, World worldIn, EntityPlayer playerIn) { if (!worldIn.isRemote){ /* BlockPos ppos=playerIn.getPosition(); double x=ppos.getX(); double y=ppos.getY(); double z=ppos.getZ(); EntityBreakingFX(worldIn, x, y, z, Items.emerald); */ if (playerIn.capabilities.isCreativeMode || playerIn.inventory.hasItem(MercenaryModItems.flechaMercenaria)){ //mercenaryArrow //|| playerIn.inventory.hasItem(Items.arrow)){ //municion=nbtMercenaria.getInttag(arco, "municion"); //not now nbtMercenaria.setBooleantag(arco, "animacion", true); animacion=true; tighten=true; //chat.chatdp(playerIn, "has item "+tick); }} if (tighten){ playerIn.setItemInUse(arco, this.getMaxItemUseDuration(arco)); tick=0; continuar=true; //chat.chatdp(playerIn, "En Uso"+tick); // in use } return arco; } public int getItemEnchantability() { return 1; } } it shows no errors in eclipse but when try to run 08:00:08] [Client thread/ERROR] [FML]: Caught exception from modmercenario java.lang.NullPointerException at net.minecraft.client.resources.model.ModelBakery.addVariantName(ModelBakery.java:835) ~[forgeSrc-1.8-11.14.1.1336.jar:?] at mercenarymod.ClientProxy.init(ClientProxy.java:38) ~[bin/:?] at mercenarymod.Mercenary.init(Mercenary.java:61) ~[bin/:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76] at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:518) ~[forgeSrc-1.8-11.14.1.1336.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:208) ~[forgeSrc-1.8-11.14.1.1336.jar:?] at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:187) ~[forgeSrc-1.8-11.14.1.1336.jar:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76] at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?] at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?] at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?] at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:118) [LoadController.class:?] at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:692) [Loader.class:?] at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:291) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_76] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_76] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_76] at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_76] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:85) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] [08:00:08] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:660]: ---- Minecraft Crash Report ---- // On the bright side, I bought you a teddy bear! i need thath modelBakery in CommonProxy to register the json's for the pulling animation but lets remove it to later fix now minecraft runs but there is no bow anywhere the register dont works i dunnot now why , an the modelBakery is an importan issue coz eclipse says nothings wrong whith code i get mas i dont have any idea of whath coul be posibly wrong here help please
  25. im letting this post here. I realize that I have basic flaws that must be addresed first before continue. fuck there is like 180 items in mi mod i must fix on hand
×
×
  • Create New...

Important Information

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