mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 08:00:02 +03:00
186 lines
7.1 KiB
Diff
186 lines
7.1 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/EntityHanging.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/EntityHanging.java
|
|
@@ -3,6 +3,7 @@
|
|
import com.google.common.base.Predicate;
|
|
import javax.annotation.Nullable;
|
|
import net.minecraft.block.BlockRedstoneDiode;
|
|
+import net.minecraft.block.material.Material;
|
|
import net.minecraft.block.state.IBlockState;
|
|
import net.minecraft.entity.effect.EntityLightningBolt;
|
|
import net.minecraft.entity.item.EntityItem;
|
|
@@ -18,6 +19,9 @@
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.world.World;
|
|
import org.apache.commons.lang3.Validate;
|
|
+import org.bukkit.entity.Hanging;
|
|
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
|
+import org.bukkit.event.hanging.HangingBreakEvent;
|
|
|
|
public abstract class EntityHanging extends Entity
|
|
{
|
|
@@ -29,7 +33,7 @@
|
|
}
|
|
};
|
|
private int tickCounter1;
|
|
- protected BlockPos hangingPosition;
|
|
+ public BlockPos hangingPosition;
|
|
@Nullable
|
|
public EnumFacing facingDirection;
|
|
|
|
@@ -49,7 +53,7 @@
|
|
{
|
|
}
|
|
|
|
- protected void updateFacingWithBoundingBox(EnumFacing facingDirectionIn)
|
|
+ public void updateFacingWithBoundingBox(EnumFacing facingDirectionIn)
|
|
{
|
|
Validate.notNull(facingDirectionIn);
|
|
Validate.isTrue(facingDirectionIn.getAxis().isHorizontal());
|
|
@@ -61,7 +65,7 @@
|
|
|
|
protected void updateBoundingBox()
|
|
{
|
|
- if (this.facingDirection != null)
|
|
+ /*if (this.facingDirection != null)
|
|
{
|
|
double d0 = (double)this.hangingPosition.getX() + 0.5D;
|
|
double d1 = (double)this.hangingPosition.getY() + 0.5D;
|
|
@@ -95,26 +99,88 @@
|
|
d7 = d7 / 32.0D;
|
|
d8 = d8 / 32.0D;
|
|
this.setEntityBoundingBox(new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8));
|
|
+ }*/
|
|
+ if(this.facingDirection != null) {
|
|
+ this.setEntityBoundingBox(calculateBoundingBox(this, this.hangingPosition, this.facingDirection, getWidthPixels(), getHeightPixels()));
|
|
}
|
|
}
|
|
+ // CraftBukkit start - break out BB calc into own method
|
|
+ public static AxisAlignedBB calculateBoundingBox(Entity entity, BlockPos pos, EnumFacing direction, int width, int height) {
|
|
+ double d0 = (double)pos.getX() + 0.5D;
|
|
+ double d1 = (double)pos.getY() + 0.5D;
|
|
+ double d2 = (double)pos.getZ() + 0.5D;
|
|
+ double d3 = 0.46875D;
|
|
+ double d4 = offs(width);
|
|
+ double d5 = offs(height);
|
|
+ d0 = d0 - (double)direction.getFrontOffsetX() * 0.46875D;
|
|
+ d2 = d2 - (double)direction.getFrontOffsetZ() * 0.46875D;
|
|
+ d1 = d1 + d5;
|
|
+ EnumFacing enumfacing = direction.rotateYCCW();
|
|
+ d0 = d0 + d4 * (double)enumfacing.getFrontOffsetX();
|
|
+ d2 = d2 + d4 * (double)enumfacing.getFrontOffsetZ();
|
|
+ if(entity != null) {
|
|
+ entity.posX = d0;
|
|
+ entity.posY = d1;
|
|
+ entity.posZ = d2;
|
|
+ }
|
|
+ //this.posX = d0;
|
|
+ //this.posY = d1;
|
|
+ //this.posZ = d2;
|
|
+ double d6 = (double)width;
|
|
+ double d7 = (double)height;
|
|
+ double d8 = (double)width;
|
|
|
|
- private double offs(int p_190202_1_)
|
|
+ if (direction.getAxis() == EnumFacing.Axis.Z)
|
|
+ {
|
|
+ d8 = 1.0D;
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ d6 = 1.0D;
|
|
+ }
|
|
+
|
|
+ d6 = d6 / 32.0D;
|
|
+ d7 = d7 / 32.0D;
|
|
+ d8 = d8 / 32.0D;
|
|
+ return new AxisAlignedBB(d0 - d6, d1 - d7, d2 - d8, d0 + d6, d1 + d7, d2 + d8);
|
|
+ }
|
|
+
|
|
+ private static double offs(int p_190202_1_)
|
|
{
|
|
return p_190202_1_ % 32 == 0 ? 0.5D : 0.0D;
|
|
}
|
|
|
|
public void onUpdate()
|
|
{
|
|
+
|
|
this.prevPosX = this.posX;
|
|
this.prevPosY = this.posY;
|
|
this.prevPosZ = this.posZ;
|
|
|
|
- if (this.tickCounter1++ == 100 && !this.worldObj.isRemote)
|
|
+ if (this.tickCounter1++ == this.worldObj.spigotConfig.hangingTickFrequency && !this.worldObj.isRemote) // Spigot
|
|
{
|
|
this.tickCounter1 = 0;
|
|
|
|
if (!this.isDead && !this.onValidSurface())
|
|
{
|
|
+ // CraftBukkit start - fire break events
|
|
+ Material material = this.worldObj.getBlockState(new BlockPos(this)).getMaterial();
|
|
+ HangingBreakEvent.RemoveCause cause;
|
|
+
|
|
+ if (!material.equals(Material.AIR)) {
|
|
+ // TODO: This feels insufficient to catch 100% of suffocation cases
|
|
+ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION;
|
|
+ } else {
|
|
+ cause = HangingBreakEvent.RemoveCause.PHYSICS;
|
|
+ }
|
|
+
|
|
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
|
|
+ this.worldObj.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (isDead || event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.setDead();
|
|
this.onBroken((Entity)null);
|
|
}
|
|
@@ -183,6 +249,20 @@
|
|
{
|
|
if (!this.isDead && !this.worldObj.isRemote)
|
|
{
|
|
+ // CraftBukkit start - fire break events
|
|
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT);
|
|
+ if (source.getEntity() != null) {
|
|
+ event = new HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), source.getEntity() == null ? null : source.getEntity().getBukkitEntity());
|
|
+ } else if (source.isExplosion()) {
|
|
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION);
|
|
+ }
|
|
+
|
|
+ this.worldObj.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (this.isDead || event.isCancelled()) {
|
|
+ return true;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.setDead();
|
|
this.setBeenAttacked();
|
|
this.onBroken(source.getEntity());
|
|
@@ -196,6 +276,16 @@
|
|
{
|
|
if (!this.worldObj.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
|
|
{
|
|
+ if (this.isDead) return; // CraftBukkit
|
|
+ // CraftBukkit start - fire break events
|
|
+ // TODO - Does this need its own cause? Seems to only be triggered by pistons
|
|
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
|
|
+ this.worldObj.getServer().getPluginManager().callEvent(event);
|
|
+
|
|
+ if (this.isDead || event.isCancelled()) {
|
|
+ return;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
this.setDead();
|
|
this.onBroken((Entity)null);
|
|
}
|
|
@@ -203,7 +293,7 @@
|
|
|
|
public void addVelocity(double x, double y, double z)
|
|
{
|
|
- if (!this.worldObj.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D)
|
|
+ if (false && !this.worldObj.isRemote && !this.isDead && x * x + y * y + z * z > 0.0D) // CraftBukkit - not needed
|
|
{
|
|
this.setDead();
|
|
this.onBroken((Entity)null);
|