Skip to content

Commit

Permalink
Fixed CassCastExceptions in OBlockCactus.
Browse files Browse the repository at this point in the history
This fixes #131
There was an unchecked cast to EntityLiving where it could
be any kind of entity interacting with the cactus.
  • Loading branch information
damagefilter committed Mar 22, 2013
1 parent 588e685 commit 7690240
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/OBlockCactus.java
Expand Up @@ -8,6 +8,7 @@ protected OBlockCactus(int i) {
this.a(OCreativeTabs.c);
}

@Override
public void a(OWorld oworld, int i, int j, int k, Random random) {
if (oworld.c(i, j + 1, k)) {
int l;
Expand All @@ -30,34 +31,41 @@ public void a(OWorld oworld, int i, int j, int k, Random random) {
}
}

@Override
public OAxisAlignedBB b(OWorld oworld, int i, int j, int k) {
float f = 0.0625F;

return OAxisAlignedBB.a().a((double) ((float) i + f), (double) j, (double) ((float) k + f), (double) ((float) (i + 1) - f), (double) ((float) (j + 1) - f), (double) ((float) (k + 1) - f));
}

@Override
public boolean b() {
return false;
}

@Override
public boolean c() {
return false;
}

@Override
public int d() {
return 13;
}

@Override
public boolean c(OWorld oworld, int i, int j, int k) {
return !super.c(oworld, i, j, k) ? false : this.f(oworld, i, j, k);
}

@Override
public void a(OWorld oworld, int i, int j, int k, int l) {
if (!this.f(oworld, i, j, k)) {
oworld.a(i, j, k, true);
}
}

@Override
public boolean f(OWorld oworld, int i, int j, int k) {
if (oworld.g(i - 1, j, k).a()) {
return false;
Expand All @@ -74,9 +82,10 @@ public boolean f(OWorld oworld, int i, int j, int k) {
}
}

@Override
public void a(OWorld oworld, int i, int j, int k, OEntity oentity) {
// CanaryMod Damage hook: Cactus
HookParametersDamage ev = (HookParametersDamage) etc.getLoader().callHook(PluginLoader.Hook.DAMAGE, new HookParametersDamage(null, new LivingEntity((OEntityLiving) oentity), DamageType.CACTUS.getDamageSource(), 1));
HookParametersDamage ev = (HookParametersDamage) etc.getLoader().callHook(PluginLoader.Hook.DAMAGE, new HookParametersDamage(null, new BaseEntity(oentity), DamageType.CACTUS.getDamageSource(), 1));
if (oentity instanceof OEntityLiving && ev.isCanceled()) {
return;
}
Expand Down

0 comments on commit 7690240

Please sign in to comment.