mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-15 12:01:51 +01:00
Add entity widths to MCAccessBukkit. Compile with Bukkit 1.7.2-R0.3.
* "Swiftly" add entity widths to MCAccessBukkit (mostly switch). * Compile CompatBukkit with Bukkit 1.7.2-R0.3 from now on.
This commit is contained in:
parent
da6b580f2a
commit
7dba18cf67
@ -22,7 +22,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.5.2-R1.0</version>
|
<version>1.7.2-R0.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -11,8 +11,11 @@ import org.bukkit.command.CommandMap;
|
|||||||
import org.bukkit.entity.ComplexEntityPart;
|
import org.bukkit.entity.ComplexEntityPart;
|
||||||
import org.bukkit.entity.ComplexLivingEntity;
|
import org.bukkit.entity.ComplexLivingEntity;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
@ -70,10 +73,13 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getHeight(final Entity entity) {
|
public double getHeight(final Entity entity) {
|
||||||
|
// TODO: Copy defaults like with widths.
|
||||||
final double entityHeight = 1.0;
|
final double entityHeight = 1.0;
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
|
return Math.max(((LivingEntity) entity).getEyeHeight(), entityHeight);
|
||||||
} else return entityHeight;
|
} else {
|
||||||
|
return entityHeight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,6 +94,102 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getWidth(final Entity entity) {
|
||||||
|
// TODO: Make readable from file for defaults + register individual getters where appropriate.
|
||||||
|
// TODO: For height too. [Automatize most by spawning + checking?]
|
||||||
|
// Values taken from 1.7.10.
|
||||||
|
final EntityType type = entity.getType();
|
||||||
|
switch(type){
|
||||||
|
// TODO: case COMPLEX_PART:
|
||||||
|
case ENDER_SIGNAL: // this.a(0.25F, 0.25F);
|
||||||
|
case FIREWORK: // this.a(0.25F, 0.25F);
|
||||||
|
case FISHING_HOOK: // this.a(0.25F, 0.25F);
|
||||||
|
case DROPPED_ITEM: // this.a(0.25F, 0.25F);
|
||||||
|
case SNOWBALL: // (projectile) this.a(0.25F, 0.25F);
|
||||||
|
return 0.25;
|
||||||
|
case CHICKEN: // this.a(0.3F, 0.7F);
|
||||||
|
case SILVERFISH: // this.a(0.3F, 0.7F);
|
||||||
|
return 0.3f;
|
||||||
|
case SMALL_FIREBALL: // this.a(0.3125F, 0.3125F);
|
||||||
|
case WITHER_SKULL: // this.a(0.3125F, 0.3125F);
|
||||||
|
return 0.3125f;
|
||||||
|
case GHAST: // this.a(4.0F, 4.0F);
|
||||||
|
case SNOWMAN: // this.a(0.4F, 1.8F);
|
||||||
|
return 0.4f;
|
||||||
|
case ARROW: // this.a(0.5F, 0.5F);
|
||||||
|
case BAT: // this.a(0.5F, 0.9F);
|
||||||
|
case EXPERIENCE_ORB: // this.a(0.5F, 0.5F);
|
||||||
|
case ITEM_FRAME: // hanging: this.a(0.5F, 0.5F);
|
||||||
|
case PAINTING: // hanging: this.a(0.5F, 0.5F);
|
||||||
|
return 0.5f;
|
||||||
|
case PLAYER: // FAST RETURN
|
||||||
|
case ZOMBIE:
|
||||||
|
case PIG_ZOMBIE:
|
||||||
|
case SKELETON:
|
||||||
|
case CREEPER:
|
||||||
|
case ENDERMAN:
|
||||||
|
case OCELOT:
|
||||||
|
case BLAZE:
|
||||||
|
case VILLAGER:
|
||||||
|
case WITCH:
|
||||||
|
case WOLF:
|
||||||
|
return 0.6f; // (Default entity width.)
|
||||||
|
case CAVE_SPIDER: // this.a(0.7F, 0.5F);
|
||||||
|
return 0.7f;
|
||||||
|
case COW: // this.a(0.9F, 1.3F);
|
||||||
|
case MUSHROOM_COW: // this.a(0.9F, 1.3F);
|
||||||
|
case PIG: // this.a(0.9F, 0.9F);
|
||||||
|
case SHEEP: // this.a(0.9F, 1.3F);
|
||||||
|
case WITHER: // this.a(0.9F, 4.0F);
|
||||||
|
return 0.9f;
|
||||||
|
case SQUID: // this.a(0.95F, 0.95F);
|
||||||
|
return 0.95f;
|
||||||
|
case PRIMED_TNT: // this.a(0.98F, 0.98F);
|
||||||
|
return 0.98f;
|
||||||
|
case FIREBALL: // (EntityFireball) this.a(1.0F, 1.0F);
|
||||||
|
return 1.0f;
|
||||||
|
case IRON_GOLEM: // this.a(1.4F, 2.9F);
|
||||||
|
case SPIDER: // this.a(1.4F, 0.9F);
|
||||||
|
return 1.4f;
|
||||||
|
case BOAT: // this.a(1.5F, 0.6F);
|
||||||
|
return 1.5f;
|
||||||
|
case ENDER_CRYSTAL: // this.a(2.0F, 2.0F);
|
||||||
|
return 2.0f;
|
||||||
|
case GIANT: // this.height *= 6.0F; this.a(this.width * 6.0F, this.length * 6.0F);
|
||||||
|
return 3.6f; // (Better than nothing.)
|
||||||
|
case ENDER_DRAGON: // this.a(16.0F, 8.0F);
|
||||||
|
return 16.0f;
|
||||||
|
// Variable size:
|
||||||
|
case SLIME:
|
||||||
|
case MAGMA_CUBE:
|
||||||
|
if (entity instanceof Slime) {
|
||||||
|
// setSize(i): this.a(0.6F * (float) i, 0.6F * (float) i);
|
||||||
|
return 0.6f * ((Slime) entity).getSize();
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Check by instance for minecarts (too many).
|
||||||
|
if (entity instanceof Minecart) {
|
||||||
|
return 0.98f; // this.a(0.98F, 0.7F);
|
||||||
|
}
|
||||||
|
// Latest Bukkit API.
|
||||||
|
try {
|
||||||
|
switch (type) {
|
||||||
|
case LEASH_HITCH: // hanging: this.a(0.5F, 0.5F);
|
||||||
|
return 0.5;
|
||||||
|
case HORSE: // this.a(1.4F, 1.6F);
|
||||||
|
return 1.4f;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (Throwable t) {}
|
||||||
|
// Default entity width.
|
||||||
|
return 0.6f;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlmostBoolean isBlockLiquid(final int id) {
|
public AlmostBoolean isBlockLiquid(final int id) {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
@ -104,12 +206,6 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public double getWidth(final Entity entity) {
|
|
||||||
// TODO
|
|
||||||
return 0.6f;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlmostBoolean isIllegalBounds(final Player player) {
|
public AlmostBoolean isIllegalBounds(final Player player) {
|
||||||
if (player.isDead()) {
|
if (player.isDead()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user