1 package pcc.chemicraft.item;
3 import java.util.Iterator;
5 import net.minecraft.entity.Entity;
6 import net.minecraft.entity.EntityLiving;
7 import net.minecraft.entity.player.EntityPlayer;
8 import net.minecraft.item.Item;
9 import net.minecraft.item.ItemStack;
10 import net.minecraft.potion.Potion;
11 import net.minecraft.potion.PotionEffect;
12 import net.minecraft.util.AxisAlignedBB;
13 import net.minecraft.util.DamageSource;
14 import net.minecraft.world.World;
15 import pcc.chemicraft.ChemiCraft;
17 public class ItemRadiationGun extends Item {
21 public ItemRadiationGun(int par1) {
23 this.setCreativeTab(ChemiCraft.creativeTabChemiCraft);
24 this.maxStackSize = 1;
28 public String getTextureFile() {
29 return ChemiCraft.instance.ITEM_TEXTURE;
33 public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World,
34 EntityPlayer par3EntityPlayer) {
36 boolean isCreative = par3EntityPlayer.capabilities.isCreativeMode;
38 if (this.delay <= 0) {
40 if (par3EntityPlayer.inventory.hasItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex)) {
41 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
42 par3EntityPlayer.inventory.consumeInventoryItem(ChemiCraft.instance.itemRadiationBallet.shiftedIndex);
43 par2World.playSound(par3EntityPlayer.posX,
44 par3EntityPlayer.posY,
45 par3EntityPlayer.posZ,
46 "mob.endermen.portal",
50 if (!par2World.isRemote) {
54 this.field_00001(par1ItemStack, par2World, par3EntityPlayer);
55 par2World.playSound(par3EntityPlayer.posX,
56 par3EntityPlayer.posY,
57 par3EntityPlayer.posZ,
58 "mob.endermen.portal",
62 if (!par2World.isRemote) {
69 return super.onItemRightClick(par1ItemStack, par2World, par3EntityPlayer);
72 private void field_00001(ItemStack par1ItemStack, World par2World,
73 EntityPlayer par3EntityPlayer) {
75 double minX = par3EntityPlayer.posX;
76 double minZ = par3EntityPlayer.posZ;
77 double maxX = par3EntityPlayer.posX - Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
78 double maxZ = par3EntityPlayer.posZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * 20;
79 double posY = par3EntityPlayer.posY;
80 for(distance = 0;distance < Math.abs(((minX-maxX) + (minZ-maxZ))) / 2;distance++){
81 AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(
82 minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
84 minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
85 minX + -Math.sin(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance,
87 minZ + Math.cos(Math.toRadians(par3EntityPlayer.rotationYaw)) * distance
88 ).expand(1.5, 3, 1.5);
90 Iterator itr = par2World.getEntitiesWithinAABB(EntityLiving.class, aabb).iterator();
92 EntityLiving entity = (EntityLiving) itr.next();
93 if(entity != par3EntityPlayer){
94 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), 10);
95 entity.attackEntityFrom(DamageSource.causePlayerDamage(par3EntityPlayer), (int) (10 + Math.random() * 11));
96 entity.addPotionEffect(new PotionEffect(Potion.moveSlowdown.getId(), 1, 20*20));
97 entity.addPotionEffect(new PotionEffect(Potion.weakness.getId(), 1, 20*20));
104 public void onUpdate(ItemStack par1ItemStack, World par2World,
105 Entity par3Entity, int par4, boolean par5) {
106 if (this.delay > 0 && !par2World.isRemote) {