3
0

Implement custom bukkit's entity for modded projectiles

Fix #150
This commit is contained in:
Sergey Shatunov
2016-02-03 22:42:59 +07:00
parent 7114a28fc6
commit 3b321e3116
3 changed files with 63 additions and 2 deletions

View File

@ -0,0 +1,48 @@
package kcauldron.entity;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.projectiles.ProjectileSource;
import net.minecraft.entity.Entity;
import net.minecraftforge.cauldron.entity.CraftCustomEntity;
public class CustomProjectileEntity extends CraftCustomEntity implements Projectile {
private ProjectileSource shooter;
private boolean doesBounce;
public CustomProjectileEntity(CraftServer server, Entity entity) {
super(server, entity);
}
@Override
public LivingEntity _INVALID_getShooter() {
throw new IllegalStateException("Not implemented!");
}
@Override
public ProjectileSource getShooter() {
return shooter;
}
@Override
public void _INVALID_setShooter(LivingEntity shooter) {
throw new IllegalStateException("Not implemented!");
}
@Override
public void setShooter(ProjectileSource shooter) {
this.shooter = shooter;
}
@Override
public boolean doesBounce() {
return doesBounce;
}
@Override
public void setBounce(boolean doesBounce) {
this.doesBounce = doesBounce;
}
}

View File

@ -172,7 +172,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
else if (entity instanceof net.minecraft.entity.item.EntityTNTPrimed) { return new CraftTNTPrimed(server, (net.minecraft.entity.item.EntityTNTPrimed) entity); }
else if (entity instanceof net.minecraft.entity.item.EntityFireworkRocket) { return new CraftFirework(server, (net.minecraft.entity.item.EntityFireworkRocket) entity); }
// Cauldron - used for custom entities that extend Entity directly
else if (entity instanceof net.minecraft.entity.Entity) { return new CraftCustomEntity(server, (net.minecraft.entity.Entity) entity); }
else if (entity instanceof net.minecraft.entity.Entity) {
if (entity instanceof net.minecraft.entity.IProjectile) return new kcauldron.entity.CustomProjectileEntity(server, entity); // KCauldron
return new CraftCustomEntity(server, (net.minecraft.entity.Entity) entity); }
throw new AssertionError("Unknown entity " + entity == null ? null : entity.getClass() + ": " + entity); // Cauldron - show the entity that caused exception
}