Fork of Poseidon providing Bukkit #1060 to older Beta versions (b1.0-b1.7.3)
1package net.minecraft.server;
2
3import org.bukkit.Location;
4import org.bukkit.craftbukkit.event.CraftEventFactory;
5import org.bukkit.craftbukkit.inventory.CraftItemStack;
6import org.bukkit.event.entity.EntityDeathEvent;
7import org.bukkit.event.player.PlayerBucketFillEvent;
8
9import uk.betacraft.uberbukkit.UberbukkitConfig;
10
11public class EntitySquid extends EntityWaterAnimal {
12
13 public float a = 0.0F;
14 public float b = 0.0F;
15 public float c = 0.0F;
16 public float f = 0.0F;
17 public float g = 0.0F;
18 public float h = 0.0F;
19 public float i = 0.0F;
20 public float j = 0.0F;
21 private float k = 0.0F;
22 private float l = 0.0F;
23 private float m = 0.0F;
24 private float n = 0.0F;
25 private float o = 0.0F;
26 private float p = 0.0F;
27
28 public EntitySquid(World world) {
29 super(world);
30 this.texture = "/mob/squid.png";
31 this.b(0.95F, 0.95F);
32 this.l = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
33 }
34
35 public void b(NBTTagCompound nbttagcompound) {
36 super.b(nbttagcompound);
37 }
38
39 public void a(NBTTagCompound nbttagcompound) {
40 super.a(nbttagcompound);
41 }
42
43 protected String g() {
44 return null;
45 }
46
47 protected String h() {
48 return null;
49 }
50
51 protected String i() {
52 return null;
53 }
54
55 protected float k() {
56 return 0.4F;
57 }
58
59 protected int j() {
60 return 0;
61 }
62
63 protected void q() {
64 // CraftBukkit start - whole method
65 java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
66
67 int count = this.random.nextInt(3) + 1;
68 if (count > 0) {
69 loot.add(new org.bukkit.inventory.ItemStack(org.bukkit.Material.INK_SACK, count));
70 }
71
72 org.bukkit.World bworld = this.world.getWorld();
73 org.bukkit.entity.Entity entity = this.getBukkitEntity();
74
75 EntityDeathEvent event = new EntityDeathEvent(entity, loot);
76 this.world.getServer().getPluginManager().callEvent(event);
77
78 for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
79 bworld.dropItemNaturally(entity.getLocation(), stack);
80 }
81 // CraftBukkit end
82 }
83
84 public boolean a(EntityHuman entityhuman) {
85 // uberbukkit
86 if (UberbukkitConfig.getInstance().getBoolean("mechanics.allow_milking_squids", false)) {
87 ItemStack itemstack = entityhuman.inventory.getItemInHand();
88
89 if (itemstack != null && itemstack.id == Item.BUCKET.id) {
90 // CraftBukkit start - got milk?
91 Location loc = this.getBukkitEntity().getLocation();
92 PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(entityhuman, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Item.MILK_BUCKET);
93
94 if (event.isCancelled()) {
95 return false;
96 }
97
98 CraftItemStack itemInHand = (CraftItemStack) event.getItemStack();
99 byte data = itemInHand.getData() == null ? (byte) 0 : itemInHand.getData().getData();
100 itemstack = new ItemStack(itemInHand.getTypeId(), itemInHand.getAmount(), data);
101
102 entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, itemstack);
103 // CraftBukkit end
104
105 return true;
106 } else {
107 return false;
108 }
109 } else {
110 return false;
111 }
112 }
113
114 public boolean ad() {
115 return this.world.a(this.boundingBox.b(0.0D, -0.6000000238418579D, 0.0D), Material.WATER, this);
116 }
117
118 public void v() {
119 super.v();
120 this.b = this.a;
121 this.f = this.c;
122 this.h = this.g;
123 this.j = this.i;
124 this.g += this.l;
125 if (this.g > 6.2831855F) {
126 this.g -= 6.2831855F;
127 if (this.random.nextInt(10) == 0) {
128 this.l = 1.0F / (this.random.nextFloat() + 1.0F) * 0.2F;
129 }
130 }
131
132 if (this.ad()) {
133 float f;
134
135 if (this.g < 3.1415927F) {
136 f = this.g / 3.1415927F;
137 this.i = MathHelper.sin(f * f * 3.1415927F) * 3.1415927F * 0.25F;
138 if ((double) f > 0.75D) {
139 this.k = 1.0F;
140 this.m = 1.0F;
141 } else {
142 this.m *= 0.8F;
143 }
144 } else {
145 this.i = 0.0F;
146 this.k *= 0.9F;
147 this.m *= 0.99F;
148 }
149
150 if (!this.Y) {
151 this.motX = (double) (this.n * this.k);
152 this.motY = (double) (this.o * this.k);
153 this.motZ = (double) (this.p * this.k);
154 }
155
156 f = MathHelper.a(this.motX * this.motX + this.motZ * this.motZ);
157 this.K += (-((float) Math.atan2(this.motX, this.motZ)) * 180.0F / 3.1415927F - this.K) * 0.1F;
158 this.yaw = this.K;
159 this.c += 3.1415927F * this.m * 1.5F;
160 this.a += (-((float) Math.atan2((double) f, this.motY)) * 180.0F / 3.1415927F - this.a) * 0.1F;
161 } else {
162 this.i = MathHelper.abs(MathHelper.sin(this.g)) * 3.1415927F * 0.25F;
163 if (!this.Y) {
164 this.motX = 0.0D;
165 this.motY -= 0.08D;
166 this.motY *= 0.9800000190734863D;
167 this.motZ = 0.0D;
168 }
169
170 this.a = (float) ((double) this.a + (double) (-90.0F - this.a) * 0.02D);
171 }
172 }
173
174 public void a(float f, float f1) {
175 this.move(this.motX, this.motY, this.motZ);
176 }
177
178 protected void c_() {
179 if (this.random.nextInt(50) == 0 || !this.bA || this.n == 0.0F && this.o == 0.0F && this.p == 0.0F) {
180 float f = this.random.nextFloat() * 3.1415927F * 2.0F;
181
182 this.n = MathHelper.cos(f) * 0.2F;
183 this.o = -0.1F + this.random.nextFloat() * 0.2F;
184 this.p = MathHelper.sin(f) * 0.2F;
185 }
186
187 this.U();
188 }
189}