diff --git a/patches/net/minecraft/util/EntityDamageSourceIndirect.java.patch b/patches/net/minecraft/util/EntityDamageSourceIndirect.java.patch index 95cb10a..8b55e8a 100644 --- a/patches/net/minecraft/util/EntityDamageSourceIndirect.java.patch +++ b/patches/net/minecraft/util/EntityDamageSourceIndirect.java.patch @@ -1,6 +1,17 @@ --- ../src-base/minecraft/net/minecraft/util/EntityDamageSourceIndirect.java +++ ../src-work/minecraft/net/minecraft/util/EntityDamageSourceIndirect.java -@@ -33,4 +33,11 @@ +@@ -13,6 +13,10 @@ + { + super(p_i1568_1_, p_i1568_2_); + this.indirectEntity = p_i1568_3_; ++ // KCauldron start - pass projectlie source ++ if (damageSourceEntity != null && damageSourceEntity.getBukkitEntity() instanceof org.bukkit.entity.Projectile && indirectEntity.getBukkitEntity() instanceof org.bukkit.projectiles.ProjectileSource) ++ ((org.bukkit.entity.Projectile) damageSourceEntity.getBukkitEntity()).setShooter((org.bukkit.projectiles.ProjectileSource) indirectEntity.getBukkitEntity()); ++ // KCauldron end + } + + public Entity getSourceOfDamage() +@@ -33,4 +37,11 @@ String s1 = s + ".item"; return itemstack != null && itemstack.hasDisplayName() && StatCollector.canTranslate(s1) ? new ChatComponentTranslation(s1, new Object[] {p_151519_1_.func_145748_c_(), ichatcomponent, itemstack.func_151000_E()}): new ChatComponentTranslation(s, new Object[] {p_151519_1_.func_145748_c_(), ichatcomponent}); } diff --git a/src/main/java/kcauldron/entity/CustomProjectileEntity.java b/src/main/java/kcauldron/entity/CustomProjectileEntity.java new file mode 100644 index 0000000..b758fcc --- /dev/null +++ b/src/main/java/kcauldron/entity/CustomProjectileEntity.java @@ -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; + } +} diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java index 9c87aa4..e2ff042 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftEntity.java @@ -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 }