Jump to content

somarani

Members
  • Posts

    55
  • Joined

  • Last visited

Everything posted by somarani

  1. I've never worked with packets before. Do you know of any good tutorials or could you briefly explain it? Thank you
  2. Hi, I created a custom level up system based on kills. To monitor player kills and level, I added 2 NBT values.On a keypress, I want the chat to print out the player stats (kill and level NBT values). To use those nbt values, I need an entity player. Usually when using the NBT values with other events, I use event.player or event.getSource, etc. But i can't seem to find anything like that using the KeyInputEvent. Does anyone know of a good way I can do this? Here is my key handler class public class SoulMenu { private final Minecraft mc; public static final int loc = 0; private static final String[] desc = {"menu.desc"}; private static final int[] keyValues = {Keyboard.KEY_L}; public static final KeyBinding[] keys = new KeyBinding[desc.length]; public SoulMenu() { mc = Minecraft.getMinecraft(); for(int i = 0; i < desc.length; ++i) { keys[i] = new KeyBinding(desc[i], keyValues[i], StatCollector.translateToLocal("soulcraft.label")); ClientRegistry.registerKeyBinding(keys[i]); Minecraft.getMinecraft().gameSettings.loadOptions(); } } @SubscribeEvent(priority = EventPriority.NORMAL) public void onKeyInput(KeyInputEvent event) { if(mc.inGameHasFocus) { if(keys[loc].isPressed()) { NBTSoulLevel.showLevel(/*i need a player*/); } } } } And this is the NBT class @SubscribeEvent public void Event(PlayerLoggedInEvent event) { NBTTagCompound tag = event.player.getEntityData(); NBTBase modeTag = tag.getTag("level"); } public static void incrementTag(EntityPlayer player) { if(player != null){ NBTTagCompound tag = player.getEntityData(); NBTBase modeTag = tag.getTag("level"); tag.setInteger("level", tag.getInteger("level") + 1);} } public static void setTag(int num, EntityPlayer player) { if(player != null){ NBTTagCompound tag = player.getEntityData(); NBTBase modeTag = tag.getTag("level"); tag.setInteger("level", num);} } public static int getTag(EntityPlayer player) { if(player != null){ NBTTagCompound tag = player.getEntityData(); NBTBase modeTag = tag.getTag("level"); return tag.getInteger("level"); } return 0; } public static void showLevel(EntityPlayer player){ GuiNewChat chat = Minecraft.getMinecraft().ingameGUI .getChatGUI(); chat.printChatMessage(new ChatComponentText( "Kills \u00a7b" + NBTKillCreate.getTag(player))); chat.printChatMessage(new ChatComponentText( "Level \u00a7b" + getTag(player))); chat.printChatMessage(new ChatComponentText( "Kills to next level \u00a7b" + NBTKillCreate.getTag(player))); } }
  3. BUMP. No one knows?
  4. It's the same code I have above. The only condition I have to kill it is if the difficulty is peaceful. The mob works fine if spawned through its spawn egg, but dissapears if I spawn it in any other way.
  5. Ok here is the whole output from when he first spawned Spawning entity on client Entity spawned on client X: -388.0,Y:6.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:6.0,Z:-494.0, client side? =false, isDead =false X: -388.0,Y:6.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:5.9231925,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:5.772594574068951,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:5.551128321694432,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:5.261600127278932,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.906705242455058,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.489032186941148,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.011066975123075,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false X: -388.0,Y:4.0,Z:-494.0, client side? =true, isDead =false setDead() called
  6. Ok, this is what I get from that X: -393.0,Y:6.0,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:6.0,Z:-482.0, client side? =false, isDead =false X: -393.0,Y:6.0,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:5.9231925,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:5.772594574068951,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:5.551128321694432,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:5.261600127278932,Z:-482.0, client side? =true, isDead =false X: -393.0,Y:4.906705242455058,Z:-482.0, client side? =true, isDead =false Those are the first couple lines. After the 3rd time it stays the same. I'm not sure why client side is true since im only spawning when world is not remote. Also why is it true at first, turns false then goes back to true.
  7. I did the print line and the boss does spawn, then he just disappears (the coordinates print out about 5 times then he dies. Here is his code http://pastebin.com/kf36ddZQ OR package somarani.soulcraft.mobboss; import org.omg.CORBA.PUBLIC_MEMBER; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import scala.annotation.varargs; import scala.reflect.internal.Trees.This; import somarani.soulcraft.common.SoulCraft; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiNewChat; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.IRangedAttackMob; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIArrowAttack; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIFleeSun; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIRestrictSun; import net.minecraft.entity.ai.EntityAISwimming; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.boss.BossStatus; import net.minecraft.entity.boss.IBossDisplayData; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagInt; import net.minecraft.util.ChatComponentText; import net.minecraft.util.DamageSource; import net.minecraft.util.MathHelper; import net.minecraft.world.EnumDifficulty; import net.minecraft.world.World; import net.minecraftforge.common.util.Constants.NBT; public class EntitySoulBossMob extends EntityMob implements IRangedAttackMob, IBossDisplayData { public static int count = 1000; public static int lightning = 0; public EntitySoulBossMob(World par1World) { super(par1World); this.stepHeight = 3f; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth) .setBaseValue(200d); } public void onLivingUpdate() { System.out.println("X: " + this.posX + ",Y:" + this.posY + ",Z:" + this.posZ ); BossStatus.setBossStatus(this, true); EntityPlayer entityplayer = this.worldObj .getClosestVulnerablePlayerToEntity(this, 16.0D); if (entityplayer != null) { int x = (int) entityplayer.posX; int y = (int) entityplayer.posY; int z = (int) entityplayer.posZ; EntityCreeper creeper = new EntityCreeper(worldObj); EntitySkeleton skeleton = new EntitySkeleton(worldObj); EntitySpider spider = new EntitySpider(worldObj); EntityZombie zombie = new EntityZombie(worldObj); creeper.setPosition(x + 10, y + 10, z); skeleton.setPosition(this.posX, this.posY, this.posZ); spider.setPosition(x + 5, y, z + 5); zombie.setPosition(this.posX, this.posY, this.posZ); if (count > 169) { if (!worldObj.isRemote) { worldObj.spawnEntityInWorld(creeper); worldObj.spawnEntityInWorld(creeper); worldObj.spawnEntityInWorld(skeleton); worldObj.spawnEntityInWorld(skeleton); worldObj.spawnEntityInWorld(skeleton); worldObj.spawnEntityInWorld(spider); worldObj.spawnEntityInWorld(zombie); worldObj.spawnEntityInWorld(zombie); count = 0; } } else count++; } if (this.getHealth() == 0) { if (!worldObj.isRemote) { this.worldObj.spawnEntityInWorld(new EntityLightningBolt( this.worldObj, this.posX, this.posY, this.posZ)); this.worldObj.spawnEntityInWorld(new EntityLightningBolt( this.worldObj, this.posX, this.posY, this.posZ)); this.worldObj.spawnEntityInWorld(new EntityLightningBolt( this.worldObj, this.posX, this.posY, this.posZ)); } } if (worldObj.difficultySetting == EnumDifficulty.PEACEFUL) { this.kill(); } if (lightning >= 150) { if (entityplayer != null) { int x = (int) entityplayer.posX; int y = (int) entityplayer.posY; int z = (int) entityplayer.posZ; if (!worldObj.isRemote) { this.worldObj.spawnEntityInWorld(new EntityLightningBolt( this.worldObj, x + 3, y, z + 2)); lightning = 0; } } } else { lightning++; } super.onLivingUpdate(); } public void onDeath(DamageSource par1DamageSource) { World world = worldObj; if (!world.isRemote) { int j = this.rand.nextInt(2) + 1; this.dropItem(SoulCraft.smallSoulFragment, j); } super.onDeath(par1DamageSource); } @Override public void attackEntityWithRangedAttack(EntityLivingBase var1, float var2) { // TODO Auto-generated method stub } }
  8. Ok this is the new code. Now it happens like you said it would. The boss spawns for a few seconds then disappears, although the diamond block and lightning work just fine. public void onEntityCollidedWithBlock(World world1, int x, int y, int z, Entity entity) { if (!(entity instanceof EntityPlayer)) { entity.setDead(); } System.out.println(entity); if (entity instanceof EntityItem) { if (entity.toString().contains("spideressence")) { spider = true; } if (entity.toString().contains("bonehelmet")) { skull = true; } if (entity.toString().contains("creeperessence")) { creeper = true; } if (entity.toString().contains("zombieeessence")) { zombie = true; } if(spider && skull && creeper && zombie){ World world = entity.worldObj; if(!world.isRemote){ shouldSpawn = true; EntitySoulBossMob boss = new EntitySoulBossMob(world); boss.posX = x + 2; boss.posY= y + 2; boss.posZ = z +2 ; world.spawnEntityInWorld(new EntityLightningBolt(world, x, y, z)); world.setBlockToAir(x, y, z); world.setBlock(x, y, z, Blocks.diamond_block); // for testing purposes. world.spawnEntityInWorld(boss); } } } }
  9. Hi, I created a boss and want a way to spawn him. I have a block in my mod that allows players (and items) to walk through. So to spawn the boss, you throw 4 items into the block, the items and the block disappear and the boss spawns. For some reason this wont work. The lightning strikes but I get no sound or fire and I get the boss bar but I dont see him. To further test this, I made it place a diamond block when you throw the items. The block does appear but when you right click it, it goes back to the old block. Does anyone know why this is happening? code - http://pastebin.com/19aBpwCi OR package somarani.soulcraft.block; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; import net.minecraft.entity.effect.EntityLightningBolt; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import somarani.soulcraft.common.SoulCraft; import somarani.soulcraft.mobboss.EntitySoulBossMob; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockSoulGlass extends Block { public static boolean skull = false; public static boolean spider = false; public static boolean creeper = false; public static boolean zombie = false; public static boolean shouldSpawn = false; public BlockSoulGlass(Material p_i45394_1_) { super(p_i45394_1_); setHardness(2f); setResistance(5f); setBlockName("soulglass"); setCreativeTab(SoulCraft.tabSoul); setLightLevel(0f); setBlockTextureName("soulcraft:soulglass"); GameRegistry.registerBlock(this, "soulglass"); } @SideOnly(Side.CLIENT) public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, java.util.List par3List, boolean par4) { par3List.add("Allows ONLY players to walk right through"); } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { Block block = p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_); if (this == SoulCraft.soulGlass) { if (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) != p_149646_1_.getBlockMetadata(p_149646_2_ - Facing.offsetsXForSide[p_149646_5_], p_149646_3_ - Facing.offsetsYForSide[p_149646_5_], p_149646_4_ - Facing.offsetsZForSide[p_149646_5_])) { return true; } if (block == this) { return false; } } return true; } @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 0; } @SideOnly(Side.CLIENT) public boolean isOpaqueCube() { return false; } public void onEntityCollidedWithBlock(World p_149670_1_, int x, int y, int z, Entity entity) { if (!(entity instanceof EntityPlayer)) { entity.setDead(); } System.out.println(entity); if (entity instanceof EntityItem) { if (entity.toString().contains("spideressence")) { spider = true; } if (entity.toString().contains("bonehelmet")) { skull = true; } if (entity.toString().contains("creeperessence")) { creeper = true; } if (entity.toString().contains("zombieeessence")) { zombie = true; } if(spider && skull && creeper && zombie){ shouldSpawn = true; EntitySoulBossMob mob = new EntitySoulBossMob(Minecraft.getMinecraft().theWorld); mob.posX = x + 2; mob.posY = y; mob.posZ = z + 2; Minecraft.getMinecraft().theWorld.spawnEntityInWorld(new EntityLightningBolt(Minecraft.getMinecraft().theWorld, x, y, z)); Minecraft.getMinecraft().theWorld.spawnEntityInWorld(mob); Minecraft.getMinecraft().theWorld.setBlockToAir(x, y, z); Minecraft.getMinecraft().theWorld.setBlock(x, y, z, Blocks.diamond_block); // for testing purposes. } } } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } public boolean renderAsNormalBlock() { return false; } }
  10. I'm trying to make a block when right clicked takes on the texture of the block you clicked it with. With the code I have, it does change the texture but it requires me to place a block somewhere to update and it changes it for all instances of the block. Is there a way to do it so only the block you click on changes, and to make it happen instantly? Thankyou package somarani.soulcraft.block; import java.util.List; import com.sun.org.apache.bcel.internal.generic.RETURN; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; import net.minecraft.item.ItemStack; import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.Facing; import net.minecraft.util.IIcon; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import scala.reflect.internal.Trees.Return; import somarani.soulcraft.common.SoulCraft; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class BlockClearSoulGlass extends Block { @SideOnly(Side.CLIENT) private IIcon icon; public BlockClearSoulGlass(Material p_i45394_1_) { super(p_i45394_1_); setHardness(2f); setResistance(5f); setBlockName("clearsoulglass"); setCreativeTab(SoulCraft.tabSoul); setLightLevel(0f); setBlockTextureName("soulcraft:isg"); GameRegistry.registerBlock(this, "clearsoulglass"); } @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister p_149651_1_) { icon = this.blockIcon; icon = p_149651_1_.registerIcon("soulcraft:clearsoulglass"); } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityPlayer, int side, float hitX, float hitY, float hitZ){ if(entityPlayer.getCurrentEquippedItem() != null){ ItemStack stack = entityPlayer.getCurrentEquippedItem(); icon = stack.getIconIndex(); } return true; } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(IBlockAccess p_149673_1_, int p_149673_2_, int p_149673_3_, int p_149673_4_, int p_149673_5_){ return icon; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_) { return true; } @SideOnly(Side.CLIENT) public int getRenderBlockPass() { return 0; } @SideOnly(Side.CLIENT) public boolean isOpaqueCube() { return false; } public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity entity) { if(!(entity instanceof EntityPlayer)){ entity.setDead(); } } public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4) { return null; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } }
  11. I've never worked with NBT before. Do you mind explaining how I create them, or link me to a tutorial that explains it well?
  12. I'm trying to make a block that teleports you to another (of the same) block on the Y axis. This is the code I have so far, and it works great, except that if I have more than 2 of the block on the Y axis it will teleport you up more than once, probably because it's still registering the keypress as down. If you tap really quickly, it will teleport you only once. Is there a way to make it so it delays it, or you have to repress the key for it to register it? Thank you package somarani.soulcraft.block; import java.awt.event.KeyEvent; import somarani.soulcraft.common.SoulCraft; import cpw.mods.fml.common.gameevent.PlayerEvent.PlayerLoggedInEvent; import cpw.mods.fml.common.registry.GameRegistry; import net.java.games.input.Keyboard; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.World; public class BlockEnder extends Block { public BlockEnder(Material p_i45394_1_) { super(p_i45394_1_); setHardness(4f); setResistance(4f); setBlockName("enderblock"); setCreativeTab(SoulCraft.tabSoul); setLightLevel(1.0f); setBlockTextureName("soulcraft:enderblock1"); GameRegistry.registerBlock(this, "enderblock"); } @Override public void onEntityCollidedWithBlock (World world, int x, int y, int z, Entity entity) { if (entity instanceof EntityPlayer){ EntityPlayer player = (EntityPlayer)entity; KeyEvent event = null; if(org.lwjgl.input.Keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_LSHIFT)){ int Y= y - 100; for(int i = y - 2; i > Y; i-- ){ if (world.blockExists(x, i, z)){ if (world.getBlock(x, i, z) == SoulCraft.enderBlock){ player.setPositionAndUpdate(x + 0.5d, i + 1, z + 0.5d); world.playSoundAtEntity(player, "mob.endermen.portal", 1.0f, 1.0f); break; } } } } else if (org.lwjgl.input.Keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_SPACE)){ int Y= y + 100; for(int i = y + 2; i < Y; i++ ){ if (world.blockExists(x, i, z)){ if (world.getBlock(x, i, z) == SoulCraft.enderBlock){ player.setPositionAndUpdate(x + 0.5d, i + 1, z + 0.5d); world.playSoundAtEntity(player, "mob.endermen.portal", 1.0f, 1.0f); player.motionY = 0; break; } } } } } } @Override public AxisAlignedBB getCollisionBoundingBoxFromPool (World world, int x, int y, int z) { return AxisAlignedBB.getBoundingBox(x, y, z, (double) x + 1.0D, (double) y + 0.9D, (double) z + 1.0D); } }
  13. This is the new code, but it still doesn't work , the messages never show up. And to make sure my subscribe event works, I did a dummy PlayerTickEvent and it worked. Does anyone know why I cant get this to work? package somarani.soulcraft.event; import somarani.soulcraft.common.SoulCraft; import net.minecraft.client.Minecraft; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.DamageSource; import net.minecraftforge.event.entity.living.LivingAttackEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent.PlayerTickEvent; public class EntityHurtHandler { @SubscribeEvent public void Event(LivingAttackEvent event) { System.out.println("test 1"); if (event.entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) event.entity; System.out.println("test 2"); if(event.source.isExplosion() && player.inventory.getStackInSlot(player.inventory.currentItem).getItem() == SoulCraft.creeperBow){ event.setCanceled(true); } } } }
  14. I did this but it wont work, what did I do wrong? public class EntityHurtHandler { @SubscribeEvent public void Event(LivingAttackEvent event) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(event.entity instanceof EntityPlayer && event.source.isExplosion() && player.inventory.getStackInSlot(player.inventory.currentItem).getItem() == SoulCraft.creeperBow){ event.setCanceled(true); } } }
  15. Hi, is there a way to make a player immune to explosive damage when they have a certain item in hand?
  16. I did that and it still didn't work, plus I also need to modify some of the existing code
  17. I'm trying to make a bow. I copy-pasted the stock bow class and edited it but I can't get the 3rd person animation to work. If looks fine in 1st person but doesn't change fov, but in 3rd person it looks like this: http://gyazo.com/d53be5e49c2a70598bfad2f7fdfb88a8 Does anyone know how I can get FOV to work and how I can get 3rd person animation package somarani.soulcraft.item; import net.minecraft.client.renderer.texture.IIconRegister; 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.entity.projectile.EntitySnowball; import net.minecraft.init.Items; import net.minecraft.item.EnumAction; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.IIcon; import net.minecraft.world.World; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.player.ArrowLooseEvent; import net.minecraftforge.event.entity.player.ArrowNockEvent; import somarani.soulcraft.common.SoulCraft; import somarani.soulcraft.mob.EntityFireBolt; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class ItemBlazeBow extends Item { public static final String[] bowPullIconNameArray = new String[] {"pulling_0", "pulling_1", "pulling_2"}; @SideOnly(Side.CLIENT) private IIcon[] iconArray; private static final String __OBFID = "CL_00001777"; public ItemBlazeBow() { this.maxStackSize = 1; this.setMaxDamage(384); this.setCreativeTab(SoulCraft.tabSoul); setTextureName("soulcraft:bow_standby"); GameRegistry.registerItem(this, "blazebow"); } public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) { return Items.blaze_powder == par2ItemStack.getItem() ? true : super.getIsRepairable(par1ItemStack, par2ItemStack); } public void registerIcons(IIconRegister iconRegister){ iconArray = new IIcon[4]; this.itemIcon = iconRegister.registerIcon("soulcraft:bow_standby"); iconArray[0] = iconRegister.registerIcon("soulcraft:bow_pulling_0"); iconArray[1] = iconRegister.registerIcon("soulcraft:bow_pulling_1"); iconArray[2] = iconRegister.registerIcon("soulcraft:bow_pulling_2"); } /** * called when the player releases the use item button. Args: itemstack, world, entityplayer, itemInUseCount */ public void onPlayerStoppedUsing(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer, int par4) { int j = this.getMaxItemUseDuration(par1ItemStack) - par4; ArrowLooseEvent event = new ArrowLooseEvent(par3EntityPlayer, par1ItemStack, j); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return; } j = event.charge; boolean flag = par3EntityPlayer.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, par1ItemStack) > 0; if (flag || par3EntityPlayer.inventory.hasItem(SoulCraft.explosiveArrow)) { float f = (float)j / 20.0F; f = (f * f + f * 2.0F) / 3.0F; if ((double)f < 0.1D) { return; } if (f > 1.0F) { f = 1.0F; } EntityArrow entityarrow = new EntityArrow(par2World, par3EntityPlayer, f * 2.0f); if (f == 1.0F) { entityarrow.setIsCritical(true); } int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, par1ItemStack); if (k > 0) { entityarrow.setDamage(entityarrow.getDamage() + (double)k * 0.5D + 0.5D); } int l = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, par1ItemStack); if (l > 0) { entityarrow.setKnockbackStrength(l); } entityarrow.setFire(100); par1ItemStack.damageItem(1, par3EntityPlayer); par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F); if (flag) { entityarrow.canBePickedUp = 2; } else { par3EntityPlayer.inventory.consumeInventoryItem(SoulCraft.explosiveArrow); } entityarrow.setDamage(entityarrow.getDamage() + 1.8d); if (!par2World.isRemote) { par2World.spawnEntityInWorld(entityarrow); } } } public ItemStack onEaten(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { return par1ItemStack; } /** * How long it takes to use or consume an item */ public int getMaxItemUseDuration(ItemStack par1ItemStack) { return 72000; } /** * returns the action that specifies what animation to play when the items is being used */ public EnumAction getItemUseAction(ItemStack par1ItemStack) { return EnumAction.bow; } /** * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer */ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { ArrowNockEvent event = new ArrowNockEvent(par3EntityPlayer, par1ItemStack); MinecraftForge.EVENT_BUS.post(event); if (event.isCanceled()) { return event.result; } if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(SoulCraft.explosiveArrow)) { par3EntityPlayer.setItemInUse(par1ItemStack, this.getMaxItemUseDuration(par1ItemStack)); } return par1ItemStack; } @Override @SideOnly(Side.CLIENT) public IIcon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) { if (usingItem == null) { return itemIcon; } int ticksInUse = stack.getMaxItemUseDuration() - useRemaining; if (ticksInUse > 17) { return iconArray[2]; } else if (ticksInUse > 13) { return iconArray[1]; } else if (ticksInUse > 0) { return iconArray[0]; } else { return itemIcon; } } /** * Return the enchantability factor of the item, most of the time is based on material. */ public int getItemEnchantability() { return 1; } /** * used to cycle through icons based on their used duration, i.e. for the bow */ @SideOnly(Side.CLIENT) public IIcon getItemIconForUseDuration(int par1) { return this.iconArray[par1]; } }
  18. Hi, in my mod I have this code in my Pre-Init method to spawn my mob: EntityRegistry.addSpawn(EntityLostSoulMob.class, 120, 2, 5, EnumCreatureType.monster,BiomeGenBase.beach, BiomeGenBase.desert, BiomeGenBase.extremeHills, BiomeGenBase.forest, BiomeGenBase.jungle, BiomeGenBase.plains, BiomeGenBase.taiga, BiomeGenBase.taigaHills, BiomeGenBase.frozenRiver, BiomeGenBase.frozenOcean, BiomeGenBase.swampland, BiomeGenBase.extremeHillsEdge, BiomeGenBase.extremeHills,BiomeGenBase.forestHills, BiomeGenBase.hell, BiomeGenBase.sky, BiomeGenBase.icePlains,BiomeGenBase.mushroomIsland, BiomeGenBase.mesaPlateau); although 120 is apparently very high this makes the mob spawn at good amounts, less than all the other mobs (creeper, zombie, etc.) When I'm only playing my mod this number is alright, but when I added it to a modpack to try it out they started spawning at incredibly large amounts. What is a good number to have the weight at so its balanced. And what factors could make my monster spawn uncontrollably?
  19. I have armor that when worn endermen dont attack you anymore. I looked at the endermen code and it uses a private boolean method shouldAttackPlayer which I cannot override, how would I go about making them not attack me? Thanks
  20. If i do that it drops 2 ingots. One that I can pickup and one that just stays on the ground. Is there a way I can fix this, and is there a better way to drop the ingot rather than player.entityDropItem?
  21. Hi, Ive been trying to create an autosmelting pickaxe. I got it working, but the problem is it only drops the ingot once when I start the world. I did a println to check what the stack was. The first time It gave me "1xitem.ingotIron@0" but then after that it gave me "0xitem.ingotIron@0". Why does it only work the first time? public boolean onBlockDestroyed(ItemStack itemStack, World world, Block block, int x, int y, int z, EntityLivingBase player) { ItemStack stack = FurnaceRecipes.smelting().getSmeltingResult(new ItemStack(block)); if (stack != null) { System.out.println(stack); world.setBlockToAir(x, y, z); player.entityDropItem(stack, 1); } return true; }
  22. Do you mind showing me some of your code to speed up the player, I would really appreciate that!
  23. You need to create a class for your block, and declare it like this public static Block objectName = new className(Material.rock); and in your block class make it extend Block
  24. I tried the sharedmonsterattributes, but the problem with that is when I change the speed that way, my screen goes crazy. It starts zooming in and out.
  25. Does anyone know of a way I can fix this, or another approach that wont give me troubles? Thanks
×
×
  • Create New...

Important Information

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