Jump to content

robodude

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by robodude

  1. I have no clue here is the entire class. package com.fredtech.tutorial.wuppy; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLiving; import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.Vec3; import net.minecraftforge.event.ForgeSubscribe; import net.minecraftforge.event.entity.player.PlayerInteractEvent; import net.minecraftforge.event.entity.player.PlayerInteractEvent.Action; public class SmiteEventHandle { public SmiteEventHandle() { // TODO Auto-generated constructor stub } @ForgeSubscribe public void onInteract(PlayerInteractEvent event){ long id = 0; try{ id = event.entityPlayer.getHeldItem().itemID; }catch(Exception e){} if(event.action == Action.RIGHT_CLICK_AIR && id == Wuppy.smiter.itemID) { Vec3 loc = event.entityPlayer.getLookVec(); MovingObjectPosition pos = event.entityPlayer.rayTrace(100, 2.0F); //try{ try{ //event.entityPlayer.worldObj.spawnEntityInWorld(new net.minecraft.entity.effect.EntityLightningBolt(event.entityPlayer.worldObj, pos.blockX, pos.blockY, pos.blockZ)); }catch(Exception e){} try{ event.entityPlayer.worldObj.createExplosion(event.entityLiving.worldObj.getClosestPlayerToEntity(event.entityLiving, 50), pos.blockX, pos.blockY, pos.blockZ, 3.0F, true); }catch(Exception e){} //}catch(Exception e){} try{ EntityLiving mob = (EntityLiving) pos.entityHit; mob.setEntityHealth(mob.getHealth() - 20); }catch(Exception e){} event.entityPlayer.sendChatToPlayer(pos.blockX + ", " + pos.blockY + ", " + pos.blockZ); } } }
  2. When I create an explosion it sometimes leaves behind invisible blocks, when I reload the world the invisible blocks reappear. Code: event.entityPlayer.worldObj.createExplosion(event.entityLiving.worldObj.getClosestPlayerToEntity(event.entityLiving, 50), pos.blockX, pos.blockY, pos.blockZ, 3.0F, true); Extra Info: This code is within a PlayerInteractEvent method
  3. PlayerInteractEvent, could you show me how to make one of those?
  4. How do I make a cooldown for a forge event? I have an event i only want executed every 10 seconds.
  5. This is probably very easy but I am kinda new to forge. Also, the command im looking for is the player.getTargetBlock(int) from the bukkit api equivalent for the forge api.
  6. I have an item that needs to tp the player to a far off location that it is looking at i.e. a cliff face in the distance much like the jumpto command in worldedit. How do I find the block the player is looking at in the distance?
  7. How do I edit the NBT code of a mob spawner so it spawns mobs with specific properties. I.E. charged creepers Code: world.setBlock(x, y - 1, z, Block.mobSpawner.blockID); TileEntityMobSpawner zombies = (TileEntityMobSpawner)world.getBlockTileEntity(x, y - 1, z); zombies.func_98049_a().setMobID("Villager");
  8. I know this is an extremely broad topic but if someone could point to me to some good Forge tutorials on this subject as I can only find modloader tutorials. Thanks!
  9. How do I do that and still get a spawn egg and natural spawns?
  10. Sorry my code is a little messy at the moment as a result of me trying to fix this stupid error, just ignore that I really need help on the problem of the non-rendered mob.
  11. Hello when I run this mod and activate the spawn egg the mob spawns and makes its sound but is invisible and doesnt render BaseMod: package com.fredtech.tutorial.wuppy; import java.awt.Color; import java.util.Map; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.EntityEggInfo; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.src.BaseMod; import net.minecraft.src.ModLoader; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.registry.EntityRegistry; @Mod(modid = Wuppy.modid, name = "Wuppy", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class Wuppy extends BaseMod { public static final String modid = "FredTech_Wuppy"; public static Block testBlock; public static Item testItem; public static Item blaster; @Init public void load(FMLInitializationEvent event){ testBlock = new TestBlock(500, Material.rock).setUnlocalizedName("testBlock"); testItem = new TestItem(5000).setUnlocalizedName("testItem"); blaster = new Blaster(5001).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("blaster"); EntityRegistry.registerModEntity(Bolt.class, "Bolt", 0,this,256,1,true); RenderingRegistry.registerEntityRenderingHandler(Bolt.class, new BoltRenderer()); ModLoader.registerEntityID(MobTest.class, "TestMob", 31); ModLoader.addSpawn("TestMob", 15, -5, 1, EnumCreatureType.creature); ModLoader.addLocalization("entity.TestMob.name", "Test Mob"); EntityList.entityEggs.put(Integer.valueOf(31), new EntityEggInfo(31, 894731, (new Color(21,15,6).getRGB()))); Register.registerItems(); } @Override public String getVersion() { // TODO Auto-generated method stub return null; } @Override public void load() { } @Override public void addRenderer(Map var1) { var1.put(MobTest.class, new RenderLiving(new ModelMob(),.5f)); } } Register: package com.fredtech.tutorial.wuppy; import java.awt.Color; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.EntityEggInfo; import net.minecraft.entity.EntityList; import net.minecraft.entity.EnumCreatureType; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.src.ModLoader; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; public class Register { public static void registerItems(){ ItemStack godSword = new ItemStack(Item.swordDiamond); godSword.addEnchantment(Enchantment.unbreaking, 10); godSword.addEnchantment(Enchantment.smite, 10); godSword.addEnchantment(Enchantment.knockback, 2); godSword.addEnchantment(Enchantment.looting, 10); godSword.addEnchantment(Enchantment.fireAspect, 10); godSword.addEnchantment(Enchantment.sharpness, 10); godSword.addEnchantment(Enchantment.baneOfArthropods, 10); GameRegistry.registerBlock(Wuppy.testBlock, Wuppy.modid+Wuppy.testBlock.getUnlocalizedName2()); GameRegistry.addShapelessRecipe(new ItemStack(Wuppy.testBlock), new Object[]{ new ItemStack(Item.diamond, 1), new ItemStack(Block.stone, 1),new ItemStack(Item.dyePowder, 1, 15) }); GameRegistry.addRecipe(new ItemStack(Wuppy.testBlock), new Object[]{ "XZX", "CXC", 'X', Item.ingotGold, 'C', Block.stone, 'Z', new ItemStack(Item.dyePowder, 1, 15) }); GameRegistry.addRecipe(godSword, new Object[]{ " C", " B ", "A ", 'A', Item.stick, 'B', new ItemStack(Item.diamond, 5), 'C', new ItemStack(Item.emerald, 5) }); ModLoader.registerEntityID(MobTest.class, "TestMob", 50); ModLoader.addSpawn("TestMob", 15, -5, 1, EnumCreatureType.creature); ModLoader.addLocalization("enity.TestMob.name", "Test Mob"); EntityList.entityEggs.put(Integer.valueOf(50), new EntityEggInfo(50,894731, (new Color(21,15,6).getRGB()))); LanguageRegistry.addName(Wuppy.testBlock, "Test Block"); LanguageRegistry.addName(Wuppy.testItem, "Test Item"); LanguageRegistry.addName(Wuppy.blaster, "Blaster"); MinecraftForge.EVENT_BUS.register(new ItemClickHandle()); } } MobTest: package com.fredtech.tutorial.wuppy; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveTwardsRestriction; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.Item; import net.minecraft.world.World; public class MobTest extends EntityCreature { public MobTest(World worldObj) { super(worldObj); this.texture = "/mob/GreenMonster.png"; this.moveSpeed = 0.4f;//sets how fast this mob moves isImmuneToFire = false; //below this is all the ai tasks that specify how the mob will behave mess around with it to see what happens this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, false)); this.tasks.addTask(2, new EntityAIMoveTwardsRestriction(this, this.moveSpeed)); this.tasks.addTask(3, new EntityAIWander(this, this.moveSpeed)); this.tasks.addTask(4, new EntityAILookIdle(this)); this.targetTasks.addTask(0, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 25.0F, 0, true)); } @Override public int getMaxHealth() { // TODO Auto-generated method stub return 10; } public boolean isAIEnabled() { return true; } protected String getLivingSound() { return "mob.pig.say"; } protected String getHurtSound() { return "mob.pig.say"; } protected String getDeathSound() { return "mob.pig.death"; } protected int getDropItemId() { return 200; } protected boolean canDespawn() { return true; } } ModelMob (Generated by Techne): package com.fredtech.tutorial.wuppy; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; import net.minecraft.entity.Entity; public class ModelMob extends ModelBase { //fields ModelRenderer Leg2; ModelRenderer Leg1; ModelRenderer Body; ModelRenderer Arm1; ModelRenderer Arm2; ModelRenderer Head; public ModelMob() { textureWidth = 64; textureHeight = 128; Leg2 = new ModelRenderer(this, 48, 49); Leg2.addBox(-2F, 0F, -2F, 4, 11, 4); Leg2.setRotationPoint(-4F, 13F, 0F); Leg2.setTextureSize(64, 128); Leg2.mirror = true; setRotation(Leg2, 0F, 0F, 0F); Leg1 = new ModelRenderer(this, 31, 49); Leg1.addBox(-2F, 0F, -2F, 4, 11, 4); Leg1.setRotationPoint(2F, 13F, 0F); Leg1.setTextureSize(64, 128); Leg1.mirror = true; setRotation(Leg1, 0F, 0F, 0F); Body = new ModelRenderer(this, 0, 68); Body.addBox(0F, 0F, 0F, 12, 7, 7); Body.setRotationPoint(-7F, 7F, -3F); Body.setTextureSize(64, 128); Body.mirror = true; setRotation(Body, 0F, 0F, 0F); Arm1 = new ModelRenderer(this, 0, 34); Arm1.addBox(0F, -1F, -9F, 4, 3, 12); Arm1.setRotationPoint(5F, 8F, -3F); Arm1.setTextureSize(64, 128); Arm1.mirror = true; setRotation(Arm1, 0F, 0F, 0F); Arm2 = new ModelRenderer(this, 0, 19); Arm2.addBox(-4F, -1F, -10F, 4, 3, 12); Arm2.setRotationPoint(-7F, 8F, -3F); Arm2.setTextureSize(64, 128); Arm2.mirror = true; setRotation(Arm2, 0F, 0F, 0F); Head = new ModelRenderer(this, 0, 0); Head.addBox(-3F, -6F, -2F, 8, 6, 5); Head.setRotationPoint(-2F, 7F, 0F); Head.setTextureSize(64, 128); Head.mirror = true; setRotation(Head, 0F, 0F, 0F); } public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5) { super.render(entity, f, f1, f2, f3, f4, f5); setRotationAngles(f, f1, f2, f3, f4, f5); Leg2.render(f5); Leg1.render(f5); Body.render(f5); Arm1.render(f5); Arm2.render(f5); Head.render(f5); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5) { // super.setRotationAngles(f, f1, f2, f3, f4, f5); } } This is all the code that has to do with this issue GreenMonster.png is located at /forge/mcp/src/minecraft/mobs
  12. Thank you so much, someone needs to change the tutorial for entity rendering on the wiki.
  13. Hi, I am a veteran java programmer and also frequently make mods for bukkit. I thought I would try out forge modding, it sounded interesting. But, I am a noob at forge and need some help with some code that is probably simple to yall. When I run minecraft the entity Bolt is not rendered when fired from the Blaster Item. It simply does not show up, but, it acts like it works, meaning when the invisible bolt impacts the world all the code is run and the explosion is created, its just not shown to the player. Heres the code: Base Code: package com.fredtech.tutorial.wuppy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.Init; import cpw.mods.fml.common.Mod.Instance; import cpw.mods.fml.common.SidedProxy; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.network.NetworkMod; @Mod(modid = Wuppy.modid, name = "Wuppy", version = "1.0") @NetworkMod(clientSideRequired = true, serverSideRequired = false) public class Wuppy { @Instance("Wuppy") public static Wuppy instance; @SidedProxy(clientSide="com.fredtech.tutorial.wuppy.client.ClientProxy", serverSide="com.fredtech.tutorial.wuppy.CommonProxy") public static CommonProxy proxy; public static final String modid = "FredTech_Wuppy"; public static Block testBlock; public static Item testItem; public static Item blaster; @Init public void load(FMLInitializationEvent event){ proxy.registerRenderInformation(); testBlock = new TestBlock(500, Material.rock).setUnlocalizedName("testBlock"); testItem = new TestItem(5000).setUnlocalizedName("testItem"); blaster = new Blaster(5001).setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("blaster"); Register.registerItems(); } } Register: package com.fredtech.tutorial.wuppy; import net.minecraft.block.Block; import net.minecraft.enchantment.Enchantment; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraftforge.common.MinecraftForge; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.LanguageRegistry; public class Register { public static void registerItems(){ ItemStack godSword = new ItemStack(Item.swordDiamond); godSword.addEnchantment(Enchantment.unbreaking, 10); godSword.addEnchantment(Enchantment.smite, 10); godSword.addEnchantment(Enchantment.knockback, 2); godSword.addEnchantment(Enchantment.looting, 10); godSword.addEnchantment(Enchantment.fireAspect, 10); godSword.addEnchantment(Enchantment.sharpness, 10); godSword.addEnchantment(Enchantment.baneOfArthropods, 10); GameRegistry.registerBlock(Wuppy.testBlock, Wuppy.modid+Wuppy.testBlock.getUnlocalizedName2()); GameRegistry.addShapelessRecipe(new ItemStack(Wuppy.testBlock), new Object[]{ new ItemStack(Item.diamond, 1), new ItemStack(Block.stone, 1),new ItemStack(Item.dyePowder, 1, 15) }); GameRegistry.addRecipe(new ItemStack(Wuppy.testBlock), new Object[]{ "XZX", "CXC", 'X', Item.ingotGold, 'C', Block.stone, 'Z', new ItemStack(Item.dyePowder, 1, 15) }); GameRegistry.addRecipe(godSword, new Object[]{ " C", " B ", "A ", 'A', Item.stick, 'B', new ItemStack(Item.diamond, 5), 'C', new ItemStack(Item.emerald, 5) }); LanguageRegistry.addName(Wuppy.testBlock, "Test Block"); LanguageRegistry.addName(Wuppy.testItem, "Test Item"); LanguageRegistry.addName(Wuppy.blaster, "Blaster"); MinecraftForge.EVENT_BUS.register(new ItemClickHandle()); } } The Renderer Class package com.fredtech.tutorial.wuppy; import net.minecraft.client.renderer.Tessellator; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import net.minecraft.client.renderer.entity.Render; import net.minecraft.entity.Entity; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.util.MathHelper; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class BoltRenderer extends Render { public void renderBolt(Bolt par1EntityArrow, double par2, double par4, double par6, float par8, float par9) { this.loadTexture("/item/arrows.png"); GL11.glPushMatrix(); GL11.glTranslatef((float)par2, (float)par4, (float)par6); GL11.glRotatef(par1EntityArrow.prevRotationYaw + (par1EntityArrow.rotationYaw - par1EntityArrow.prevRotationYaw) * par9 - 90.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(par1EntityArrow.prevRotationPitch + (par1EntityArrow.rotationPitch - par1EntityArrow.prevRotationPitch) * par9, 0.0F, 0.0F, 1.0F); Tessellator tessellator = Tessellator.instance; 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; GL11.glEnable(GL12.GL_RESCALE_NORMAL); float f11 = 0; if (f11 > 0.0F) { float f12 = -MathHelper.sin(f11 * 3.0F) * f11; GL11.glRotatef(f12, 0.0F, 0.0F, 1.0F); } GL11.glRotatef(45.0F, 1.0F, 0.0F, 0.0F); GL11.glScalef(f10, f10, f10); GL11.glTranslatef(-4.0F, 0.0F, 0.0F); GL11.glNormal3f(f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f9); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); GL11.glNormal3f(-f10, 0.0F, 0.0F); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-7.0D, 2.0D, -2.0D, (double)f6, (double)f8); tessellator.addVertexWithUV(-7.0D, 2.0D, 2.0D, (double)f7, (double)f8); tessellator.addVertexWithUV(-7.0D, -2.0D, 2.0D, (double)f7, (double)f9); tessellator.addVertexWithUV(-7.0D, -2.0D, -2.0D, (double)f6, (double)f9); tessellator.draw(); for (int i = 0; i < 4; ++i) { GL11.glRotatef(90.0F, 1.0F, 0.0F, 0.0F); GL11.glNormal3f(0.0F, 0.0F, f10); tessellator.startDrawingQuads(); tessellator.addVertexWithUV(-8.0D, -2.0D, 0.0D, (double)f2, (double)f4); tessellator.addVertexWithUV(8.0D, -2.0D, 0.0D, (double)f3, (double)f4); tessellator.addVertexWithUV(8.0D, 2.0D, 0.0D, (double)f3, (double)f5); tessellator.addVertexWithUV(-8.0D, 2.0D, 0.0D, (double)f2, (double)f5); tessellator.draw(); } GL11.glDisable(GL12.GL_RESCALE_NORMAL); GL11.glPopMatrix(); } public void doRender(Entity par1Entity, double par2, double par4, double par6, float par8, float par9) { this.renderBolt((Bolt)par1Entity, par2, par4, par6, par8, par9); } } The Entity Code: package com.fredtech.tutorial.wuppy; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.util.MovingObjectPosition; import net.minecraft.world.World; public class Bolt extends EntityThrowable { public Bolt(World par1World) { super(par1World); // TODO Auto-generated constructor stub setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F); } public Bolt(World par1World, EntityLiving par2EntityLiving) { super(par1World, par2EntityLiving); setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F); } public Bolt(World par1World, double par2, double par4, double par6) { super(par1World, par2, par4, par6); setThrowableHeading(this.motionX, this.motionY, this.motionZ, 2.0F, 1.0F); } @Override protected void onImpact(MovingObjectPosition movingobjectposition) { try { EntityLiving mob = (EntityLiving) movingobjectposition.entityHit; mob.setEntityHealth(mob.getHealth() - 20); mob.setFire(60); } catch(Exception e){ } this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 3.0F, true); this.setDead(); } @Override protected float getGravityVelocity() { return 0; } } And the client proxy: package com.fredtech.tutorial.wuppy.client; import com.fredtech.tutorial.wuppy.Bolt; import com.fredtech.tutorial.wuppy.BoltRenderer; import com.fredtech.tutorial.wuppy.CommonProxy; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.registry.EntityRegistry; import net.minecraftforge.client.MinecraftForgeClient; public class ClientProxy extends CommonProxy { @Override public void registerRenderInformation() { EntityRegistry.registerGlobalEntityID(Bolt.class, "Bolt", EntityRegistry.findGlobalUniqueEntityId()); RenderingRegistry.instance().registerEntityRenderingHandler(Bolt.class, new BoltRenderer()); } } That should be all yall need to look at, the rest of the mod is working fine. Thanks so much.
×
×
  • Create New...

Important Information

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