13
0
geforkt von Mirrors/Paper

SPIGOT-7300, #1180: Add new DamageSource API providing enhanced information about entity damage

By: Doc <nachito94@msn.com>
Dieser Commit ist enthalten in:
CraftBukkit/Spigot 2024-02-11 09:54:25 +11:00
Ursprung db4af65c2e
Commit 49b5ee78bb
29 geänderte Dateien mit 640 neuen und 310 gelöschten Zeilen

Datei anzeigen

@ -1,25 +1,24 @@
--- a/net/minecraft/world/damagesource/DamageSource.java --- a/net/minecraft/world/damagesource/DamageSource.java
+++ b/net/minecraft/world/damagesource/DamageSource.java +++ b/net/minecraft/world/damagesource/DamageSource.java
@@ -20,6 +20,38 @@ @@ -20,6 +20,81 @@
private final Entity directEntity; private final Entity directEntity;
@Nullable @Nullable
private final Vec3D damageSourcePosition; private final Vec3D damageSourcePosition;
+ // CraftBukkit start + // CraftBukkit start
+ private boolean sweep; + @Nullable
+ private boolean melting; + private org.bukkit.block.Block directBlock; // The block that caused the damage. damageSourcePosition is not used for all block damages
+ private boolean poison; + private boolean withSweep = false;
+ + private boolean melting = false;
+ public boolean isSweep() { + private boolean poison = false;
+ return sweep; + private Entity customCausingEntity = null; // This field is a helper for when causing entity damage is not set by vanilla
+ }
+ +
+ public DamageSource sweep() { + public DamageSource sweep() {
+ this.sweep = true; + this.withSweep = true;
+ return this; + return this;
+ } + }
+ +
+ public boolean isMelting() { + public boolean isSweep() {
+ return melting; + return this.withSweep;
+ } + }
+ +
+ public DamageSource melting() { + public DamageSource melting() {
@ -27,15 +26,68 @@
+ return this; + return this;
+ } + }
+ +
+ public boolean isPoison() { + public boolean isMelting() {
+ return poison; + return this.melting;
+ } + }
+ +
+ public DamageSource poison() { + public DamageSource poison() {
+ this.poison = true; + this.poison = true;
+ return this; + return this;
+ } + }
+
+ public boolean isPoison() {
+ return this.poison;
+ }
+
+ public Entity getCausingEntity() {
+ return (this.customCausingEntity != null) ? this.customCausingEntity : this.causingEntity;
+ }
+
+ public DamageSource customCausingEntity(Entity entity) {
+ DamageSource damageSource = this.cloneInstance();
+ damageSource.customCausingEntity = entity;
+ return damageSource;
+ }
+
+ public org.bukkit.block.Block getDirectBlock() {
+ return this.directBlock;
+ }
+
+ public DamageSource directBlock(net.minecraft.world.level.World world, net.minecraft.core.BlockPosition blockPosition) {
+ if (blockPosition == null || world == null) {
+ return this;
+ }
+ return directBlock(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockPosition));
+ }
+
+ public DamageSource directBlock(org.bukkit.block.Block block) {
+ if (block == null) {
+ return this;
+ }
+ // Cloning the instance lets us return unique instances of DamageSource without affecting constants defined in DamageSources
+ DamageSource damageSource = this.cloneInstance();
+ damageSource.directBlock = block;
+ return damageSource;
+ }
+
+ private DamageSource cloneInstance() {
+ DamageSource damageSource = new DamageSource(this.type, this.directEntity, this.causingEntity, this.damageSourcePosition);
+ damageSource.directBlock = this.getDirectBlock();
+ damageSource.withSweep = this.isSweep();
+ damageSource.poison = this.isPoison();
+ damageSource.melting = this.isMelting();
+ return damageSource;
+ }
+ // CraftBukkit end + // CraftBukkit end
public String toString() { public String toString() {
return "DamageSource (" + this.type().msgId() + ")"; return "DamageSource (" + this.type().msgId() + ")";
@@ -33,7 +108,7 @@
return this.causingEntity != this.directEntity;
}
- private DamageSource(Holder<DamageType> holder, @Nullable Entity entity, @Nullable Entity entity1, @Nullable Vec3D vec3d) {
+ public DamageSource(Holder<DamageType> holder, @Nullable Entity entity, @Nullable Entity entity1, @Nullable Vec3D vec3d) {
this.type = holder;
this.causingEntity = entity1;
this.directEntity = entity;

Datei anzeigen

@ -5,8 +5,8 @@
private final DamageSource outsideBorder; private final DamageSource outsideBorder;
private final DamageSource genericKill; private final DamageSource genericKill;
+ // CraftBukkit start + // CraftBukkit start
+ public final DamageSource melting; + private final DamageSource melting;
+ public final DamageSource poison; + private final DamageSource poison;
public DamageSources(IRegistryCustom iregistrycustom) { public DamageSources(IRegistryCustom iregistrycustom) {
this.damageTypes = iregistrycustom.registryOrThrow(Registries.DAMAGE_TYPE); this.damageTypes = iregistrycustom.registryOrThrow(Registries.DAMAGE_TYPE);
@ -16,3 +16,20 @@
this.inFire = this.source(DamageTypes.IN_FIRE); this.inFire = this.source(DamageTypes.IN_FIRE);
this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT); this.lightningBolt = this.source(DamageTypes.LIGHTNING_BOLT);
this.onFire = this.source(DamageTypes.ON_FIRE); this.onFire = this.source(DamageTypes.ON_FIRE);
@@ -81,6 +87,16 @@
return new DamageSource(this.damageTypes.getHolderOrThrow(resourcekey), entity, entity1);
}
+ // CraftBukkit start
+ public DamageSource melting() {
+ return this.melting;
+ }
+
+ public DamageSource poison() {
+ return this.poison;
+ }
+ // CraftBukkit end
+
public DamageSource inFire() {
return this.inFire;
}

Datei anzeigen

@ -5,7 +5,7 @@
super.applyEffectTick(entityliving, i); super.applyEffectTick(entityliving, i);
if (entityliving.getHealth() > 1.0F) { if (entityliving.getHealth() > 1.0F) {
- entityliving.hurt(entityliving.damageSources().magic(), 1.0F); - entityliving.hurt(entityliving.damageSources().magic(), 1.0F);
+ entityliving.hurt(entityliving.damageSources().poison, 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON + entityliving.hurt(entityliving.damageSources().poison(), 1.0F); // CraftBukkit - DamageSource.MAGIC -> CraftEventFactory.POISON
} }
} }

Datei anzeigen

@ -181,11 +181,12 @@
} }
this.checkBelowWorld(); this.checkBelowWorld();
@@ -540,15 +668,48 @@ @@ -540,15 +668,47 @@
public void lavaHurt() { public void lavaHurt() {
if (!this.fireImmune()) { if (!this.fireImmune()) {
- this.setSecondsOnFire(15); - this.setSecondsOnFire(15);
- if (this.hurt(this.damageSources().lava(), 4.0F)) {
+ // CraftBukkit start - Fallen in lava TODO: this event spams! + // CraftBukkit start - Fallen in lava TODO: this event spams!
+ if (this instanceof EntityLiving && remainingFireTicks <= 0) { + if (this instanceof EntityLiving && remainingFireTicks <= 0) {
+ // not on fire yet + // not on fire yet
@ -201,11 +202,10 @@
+ // This will be called every single tick the entity is in lava, so don't throw an event + // This will be called every single tick the entity is in lava, so don't throw an event
+ this.setSecondsOnFire(15, false); + this.setSecondsOnFire(15, false);
+ } + }
+ CraftEventFactory.blockDamage = (lastLavaContact) == null ? null : org.bukkit.craftbukkit.block.CraftBlock.at(level, lastLavaContact); +
if (this.hurt(this.damageSources().lava(), 4.0F)) { + if (this.hurt(this.damageSources().lava().directBlock(level, lastLavaContact), 4.0F)) {
this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F); this.playSound(SoundEffects.GENERIC_BURN, 0.4F, 2.0F + this.random.nextFloat() * 0.4F);
} }
+ CraftEventFactory.blockDamage = null;
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls + // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
} }
@ -231,7 +231,7 @@
int j = i * 20; int j = i * 20;
if (this instanceof EntityLiving) { if (this instanceof EntityLiving) {
@@ -699,6 +860,28 @@ @@ -699,6 +859,28 @@
block.updateEntityAfterFallOn(this.level(), this); block.updateEntityAfterFallOn(this.level(), this);
} }
@ -260,7 +260,7 @@
if (this.onGround()) { if (this.onGround()) {
block.stepOn(this.level(), blockposition, iblockdata, this); block.stepOn(this.level(), blockposition, iblockdata, this);
} }
@@ -1026,6 +1209,20 @@ @@ -1026,6 +1208,20 @@
return SoundEffects.GENERIC_SPLASH; return SoundEffects.GENERIC_SPLASH;
} }
@ -281,7 +281,7 @@
protected void checkInsideBlocks() { protected void checkInsideBlocks() {
AxisAlignedBB axisalignedbb = this.getBoundingBox(); AxisAlignedBB axisalignedbb = this.getBoundingBox();
BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D); BlockPosition blockposition = BlockPosition.containing(axisalignedbb.minX + 1.0E-7D, axisalignedbb.minY + 1.0E-7D, axisalignedbb.minZ + 1.0E-7D);
@@ -1440,6 +1637,7 @@ @@ -1440,6 +1636,7 @@
this.yo = d1; this.yo = d1;
this.zo = d4; this.zo = d4;
this.setPos(d3, d1, d4); this.setPos(d3, d1, d4);
@ -289,7 +289,7 @@
} }
public void moveTo(Vec3D vec3d) { public void moveTo(Vec3D vec3d) {
@@ -1634,6 +1832,12 @@ @@ -1634,6 +1831,12 @@
return false; return false;
} }
@ -302,7 +302,7 @@
public void awardKillScore(Entity entity, int i, DamageSource damagesource) { public void awardKillScore(Entity entity, int i, DamageSource damagesource) {
if (entity instanceof EntityPlayer) { if (entity instanceof EntityPlayer) {
CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource); CriterionTriggers.ENTITY_KILLED_PLAYER.trigger((EntityPlayer) entity, this, damagesource);
@@ -1662,16 +1866,22 @@ @@ -1662,16 +1865,22 @@
} }
public boolean saveAsPassenger(NBTTagCompound nbttagcompound) { public boolean saveAsPassenger(NBTTagCompound nbttagcompound) {
@ -327,7 +327,7 @@
return true; return true;
} }
} }
@@ -1682,16 +1892,38 @@ @@ -1682,16 +1891,38 @@
} }
public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) { public NBTTagCompound saveWithoutId(NBTTagCompound nbttagcompound) {
@ -370,7 +370,7 @@
nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot())); nbttagcompound.put("Rotation", this.newFloatList(this.getYRot(), this.getXRot()));
nbttagcompound.putFloat("FallDistance", this.fallDistance); nbttagcompound.putFloat("FallDistance", this.fallDistance);
nbttagcompound.putShort("Fire", (short) this.remainingFireTicks); nbttagcompound.putShort("Fire", (short) this.remainingFireTicks);
@@ -1699,7 +1931,28 @@ @@ -1699,7 +1930,28 @@
nbttagcompound.putBoolean("OnGround", this.onGround()); nbttagcompound.putBoolean("OnGround", this.onGround());
nbttagcompound.putBoolean("Invulnerable", this.invulnerable); nbttagcompound.putBoolean("Invulnerable", this.invulnerable);
nbttagcompound.putInt("PortalCooldown", this.portalCooldown); nbttagcompound.putInt("PortalCooldown", this.portalCooldown);
@ -400,7 +400,7 @@
IChatBaseComponent ichatbasecomponent = this.getCustomName(); IChatBaseComponent ichatbasecomponent = this.getCustomName();
if (ichatbasecomponent != null) { if (ichatbasecomponent != null) {
@@ -1748,7 +2001,7 @@ @@ -1748,7 +2000,7 @@
nbttagcompound.put("Tags", nbttaglist); nbttagcompound.put("Tags", nbttaglist);
} }
@ -409,7 +409,7 @@
if (this.isVehicle()) { if (this.isVehicle()) {
nbttaglist = new NBTTagList(); nbttaglist = new NBTTagList();
iterator = this.getPassengers().iterator(); iterator = this.getPassengers().iterator();
@@ -1757,7 +2010,7 @@ @@ -1757,7 +2009,7 @@
Entity entity = (Entity) iterator.next(); Entity entity = (Entity) iterator.next();
NBTTagCompound nbttagcompound1 = new NBTTagCompound(); NBTTagCompound nbttagcompound1 = new NBTTagCompound();
@ -418,7 +418,7 @@
nbttaglist.add(nbttagcompound1); nbttaglist.add(nbttagcompound1);
} }
} }
@@ -1767,6 +2020,11 @@ @@ -1767,6 +2019,11 @@
} }
} }
@ -430,7 +430,7 @@
return nbttagcompound; return nbttagcompound;
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Saving entity NBT");
@@ -1850,6 +2108,45 @@ @@ -1850,6 +2107,45 @@
} else { } else {
throw new IllegalStateException("Entity has invalid position"); throw new IllegalStateException("Entity has invalid position");
} }
@ -476,7 +476,7 @@
} catch (Throwable throwable) { } catch (Throwable throwable) {
CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT"); CrashReport crashreport = CrashReport.forThrowable(throwable, "Loading entity NBT");
CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded"); CrashReportSystemDetails crashreportsystemdetails = crashreport.addCategory("Entity being loaded");
@@ -1871,6 +2168,12 @@ @@ -1871,6 +2167,12 @@
return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null; return entitytypes.canSerialize() && minecraftkey != null ? minecraftkey.toString() : null;
} }
@ -489,7 +489,7 @@
protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void readAdditionalSaveData(NBTTagCompound nbttagcompound);
protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound); protected abstract void addAdditionalSaveData(NBTTagCompound nbttagcompound);
@@ -1925,9 +2228,22 @@ @@ -1925,9 +2227,22 @@
} else if (this.level().isClientSide) { } else if (this.level().isClientSide) {
return null; return null;
} else { } else {
@ -512,7 +512,7 @@
this.level().addFreshEntity(entityitem); this.level().addFreshEntity(entityitem);
return entityitem; return entityitem;
} }
@@ -2025,6 +2341,27 @@ @@ -2025,6 +2340,27 @@
if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) { if (!flag && (!this.canRide(entity) || !entity.canAddPassenger(this))) {
return false; return false;
} else { } else {
@ -540,7 +540,7 @@
if (this.isPassenger()) { if (this.isPassenger()) {
this.stopRiding(); this.stopRiding();
} }
@@ -2058,7 +2395,7 @@ @@ -2058,7 +2394,7 @@
Entity entity = this.vehicle; Entity entity = this.vehicle;
this.vehicle = null; this.vehicle = null;
@ -549,7 +549,7 @@
} }
} }
@@ -2089,10 +2426,38 @@ @@ -2089,10 +2425,38 @@
} }
} }
@ -589,7 +589,7 @@
if (this.passengers.size() == 1 && this.passengers.get(0) == entity) { if (this.passengers.size() == 1 && this.passengers.get(0) == entity) {
this.passengers = ImmutableList.of(); this.passengers = ImmutableList.of();
} else { } else {
@@ -2104,6 +2469,7 @@ @@ -2104,6 +2468,7 @@
entity.boardingCooldown = 60; entity.boardingCooldown = 60;
this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity); this.gameEvent(GameEvent.ENTITY_DISMOUNT, entity);
} }
@ -597,7 +597,7 @@
} }
protected boolean canAddPassenger(Entity entity) { protected boolean canAddPassenger(Entity entity) {
@@ -2190,14 +2556,20 @@ @@ -2190,14 +2555,20 @@
if (this.isInsidePortal) { if (this.isInsidePortal) {
MinecraftServer minecraftserver = worldserver.getServer(); MinecraftServer minecraftserver = worldserver.getServer();
@ -621,7 +621,7 @@
this.level().getProfiler().pop(); this.level().getProfiler().pop();
} }
@@ -2321,6 +2693,13 @@ @@ -2321,6 +2692,13 @@
} }
public void setSwimming(boolean flag) { public void setSwimming(boolean flag) {
@ -635,7 +635,7 @@
this.setSharedFlag(4, flag); this.setSharedFlag(4, flag);
} }
@@ -2370,8 +2749,12 @@ @@ -2370,8 +2748,12 @@
return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false; return this.getTeam() != null ? this.getTeam().isAlliedTo(scoreboardteambase) : false;
} }
@ -649,7 +649,7 @@
} }
public boolean getSharedFlag(int i) { public boolean getSharedFlag(int i) {
@@ -2390,7 +2773,7 @@ @@ -2390,7 +2772,7 @@
} }
public int getMaxAirSupply() { public int getMaxAirSupply() {
@ -658,7 +658,7 @@
} }
public int getAirSupply() { public int getAirSupply() {
@@ -2398,7 +2781,18 @@ @@ -2398,7 +2780,18 @@
} }
public void setAirSupply(int i) { public void setAirSupply(int i) {
@ -678,7 +678,7 @@
} }
public int getTicksFrozen() { public int getTicksFrozen() {
@@ -2425,11 +2819,41 @@ @@ -2425,11 +2818,40 @@
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
this.setRemainingFireTicks(this.remainingFireTicks + 1); this.setRemainingFireTicks(this.remainingFireTicks + 1);
@ -713,16 +713,15 @@
+ if (this.fireImmune()) { + if (this.fireImmune()) {
+ return; + return;
+ } + }
+ CraftEventFactory.entityDamage = entitylightning; +
+ if (!this.hurt(this.damageSources().lightningBolt(), 5.0F)) { + if (!this.hurt(this.damageSources().lightningBolt().customCausingEntity(entitylightning), 5.0F)) {
+ CraftEventFactory.entityDamage = null;
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
} }
public void onAboveBubbleCol(boolean flag) { public void onAboveBubbleCol(boolean flag) {
@@ -2594,15 +3018,38 @@ @@ -2594,15 +3016,38 @@
@Nullable @Nullable
public Entity changeDimension(WorldServer worldserver) { public Entity changeDimension(WorldServer worldserver) {
@ -763,7 +762,7 @@
this.level().getProfiler().popPush("reloading"); this.level().getProfiler().popPush("reloading");
Entity entity = this.getType().create(worldserver); Entity entity = this.getType().create(worldserver);
@@ -2610,10 +3057,22 @@ @@ -2610,10 +3055,22 @@
entity.restoreFrom(this); entity.restoreFrom(this);
entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot()); entity.moveTo(shapedetectorshape.pos.x, shapedetectorshape.pos.y, shapedetectorshape.pos.z, shapedetectorshape.yRot, entity.getXRot());
entity.setDeltaMovement(shapedetectorshape.speed); entity.setDeltaMovement(shapedetectorshape.speed);
@ -789,7 +788,7 @@
} }
this.removeAfterChangingDimensions(); this.removeAfterChangingDimensions();
@@ -2634,20 +3093,34 @@ @@ -2634,20 +3091,34 @@
@Nullable @Nullable
protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) { protected ShapeDetectorShape findDimensionEntryPoint(WorldServer worldserver) {
@ -829,7 +828,7 @@
IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos); IBlockData iblockdata = this.level().getBlockState(this.portalEntrancePos);
EnumDirection.EnumAxis enumdirection_enumaxis; EnumDirection.EnumAxis enumdirection_enumaxis;
Vec3D vec3d; Vec3D vec3d;
@@ -2664,8 +3137,8 @@ @@ -2664,8 +3135,8 @@
vec3d = new Vec3D(0.5D, 0.0D, 0.0D); vec3d = new Vec3D(0.5D, 0.0D, 0.0D);
} }
@ -840,7 +839,7 @@
} }
} else { } else {
BlockPosition blockposition1; BlockPosition blockposition1;
@@ -2675,8 +3148,14 @@ @@ -2675,8 +3146,14 @@
} else { } else {
blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos()); blockposition1 = worldserver.getHeightmapPos(HeightMap.Type.MOTION_BLOCKING_NO_LEAVES, worldserver.getSharedSpawnPos());
} }
@ -856,7 +855,7 @@
} }
} }
@@ -2684,8 +3163,23 @@ @@ -2684,8 +3161,23 @@
return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose())); return BlockPortalShape.getRelativePosition(blockutil_rectangle, enumdirection_enumaxis, this.position(), this.getDimensions(this.getPose()));
} }
@ -882,7 +881,7 @@
} }
public boolean canChangeDimensions() { public boolean canChangeDimensions() {
@@ -2806,6 +3300,12 @@ @@ -2806,6 +3298,12 @@
} }
} }
@ -895,7 +894,7 @@
public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) { public boolean teleportTo(WorldServer worldserver, double d0, double d1, double d2, Set<RelativeMovement> set, float f, float f1) {
float f2 = MathHelper.clamp(f1, -90.0F, 90.0F); float f2 = MathHelper.clamp(f1, -90.0F, 90.0F);
@@ -2825,7 +3325,11 @@ @@ -2825,7 +3323,11 @@
entity.moveTo(d0, d1, d2, f, f2); entity.moveTo(d0, d1, d2, f, f2);
entity.setYHeadRot(f); entity.setYHeadRot(f);
this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION); this.setRemoved(Entity.RemovalReason.CHANGED_DIMENSION);
@ -908,7 +907,7 @@
} }
return true; return true;
@@ -2931,7 +3435,26 @@ @@ -2931,7 +3433,26 @@
} }
public final void setBoundingBox(AxisAlignedBB axisalignedbb) { public final void setBoundingBox(AxisAlignedBB axisalignedbb) {
@ -936,7 +935,7 @@
} }
protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) { protected float getEyeHeight(EntityPose entitypose, EntitySize entitysize) {
@@ -3246,6 +3769,11 @@ @@ -3246,6 +3767,11 @@
vec3d = vec3d.add(vec3d1); vec3d = vec3d.add(vec3d1);
++k1; ++k1;
} }

Datei anzeigen

@ -16,7 +16,7 @@
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) { if (this.level().getBiome(this.blockPosition()).is(BiomeTags.SNOW_GOLEM_MELTS)) {
- this.hurt(this.damageSources().onFire(), 1.0F); - this.hurt(this.damageSources().onFire(), 1.0F);
+ this.hurt(this.damageSources().melting, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING + this.hurt(this.damageSources().melting(), 1.0F); // CraftBukkit - DamageSources.ON_FIRE -> CraftEventFactory.MELTING
} }
if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) { if (!this.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {

Datei anzeigen

@ -10,17 +10,16 @@
} }
} }
@@ -334,7 +336,9 @@ @@ -334,7 +336,7 @@
@Override @Override
public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) { public void thunderHit(WorldServer worldserver, EntityLightning entitylightning) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = entitylightning; // CraftBukkit - this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE);
this.hurt(this.damageSources().lightningBolt(), Float.MAX_VALUE); + this.hurt(this.damageSources().lightningBolt().customCausingEntity(entitylightning), Float.MAX_VALUE); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit
} }
@Override @Override
@@ -491,12 +495,14 @@ @@ -491,12 +493,14 @@
} else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) { } else if (this.turtle.layEggCounter > this.adjustedTickDelay(200)) {
World world = this.turtle.level(); World world = this.turtle.level();

Datei anzeigen

@ -43,13 +43,3 @@
if (this.level().setBlock(blockposition, this.blockState, 3)) { if (this.level().setBlock(blockposition, this.blockState, 3)) {
((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition))); ((WorldServer) this.level()).getChunkSource().chunkMap.broadcast(this, new PacketPlayOutBlockChange(blockposition, this.level().getBlockState(blockposition)));
this.discard(); this.discard();
@@ -255,7 +272,9 @@
float f2 = (float) Math.min(MathHelper.floor((float) i * this.fallDamagePerDistance), this.fallDamageMax);
this.level().getEntities((Entity) this, this.getBoundingBox(), predicate).forEach((entity) -> {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entity.hurt(damagesource2, f2);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
});
boolean flag = this.blockState.is(TagsBlock.ANVIL);

Datei anzeigen

@ -14,7 +14,7 @@
public class EntityEnderPearl extends EntityProjectileThrowable { public class EntityEnderPearl extends EntityProjectileThrowable {
public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) { public EntityEnderPearl(EntityTypes<? extends EntityEnderPearl> entitytypes, World world) {
@@ -54,23 +61,36 @@ @@ -54,23 +61,34 @@
EntityPlayer entityplayer = (EntityPlayer) entity; EntityPlayer entityplayer = (EntityPlayer) entity;
if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) { if (entityplayer.connection.isAcceptingMessages() && entityplayer.level() == this.level() && !entityplayer.isSleeping()) {
@ -56,15 +56,13 @@
- entity.hurt(this.damageSources().fall(), 5.0F); - entity.hurt(this.damageSources().fall(), 5.0F);
+ entityplayer.connection.teleport(teleEvent.getTo()); + entityplayer.connection.teleport(teleEvent.getTo());
+ entity.resetFallDistance(); + entity.resetFallDistance();
+ CraftEventFactory.entityDamage = this; + entity.hurt(this.damageSources().fall().customCausingEntity(this), 5.0F); // CraftBukkit
+ entity.hurt(this.damageSources().fall(), 5.0F);
+ CraftEventFactory.entityDamage = null;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS); this.level().playSound((EntityHuman) null, this.getX(), this.getY(), this.getZ(), SoundEffects.PLAYER_TELEPORT, SoundCategory.PLAYERS);
} }
} else if (entity != null) { } else if (entity != null) {
@@ -100,7 +120,7 @@ @@ -100,7 +118,7 @@
public Entity changeDimension(WorldServer worldserver) { public Entity changeDimension(WorldServer worldserver) {
Entity entity = this.getOwner(); Entity entity = this.getOwner();

Datei anzeigen

@ -1,12 +1,11 @@
--- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java --- a/net/minecraft/world/entity/projectile/EntityEvokerFangs.java
+++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java +++ b/net/minecraft/world/entity/projectile/EntityEvokerFangs.java
@@ -129,7 +129,9 @@ @@ -129,7 +129,7 @@
if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) { if (entityliving.isAlive() && !entityliving.isInvulnerable() && entityliving != entityliving1) {
if (entityliving1 == null) { if (entityliving1 == null) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = this; // CraftBukkit - entityliving.hurt(this.damageSources().magic(), 6.0F);
entityliving.hurt(this.damageSources().magic(), 6.0F); + entityliving.hurt(this.damageSources().magic().customCausingEntity(this), 6.0F); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.entityDamage = null; // CraftBukkit
} else { } else {
if (entityliving1.isAlliedTo((Entity) entityliving)) { if (entityliving1.isAlliedTo((Entity) entityliving)) {
return; return;

Datei anzeigen

@ -1,15 +1,6 @@
--- a/net/minecraft/world/entity/projectile/EntityFireworks.java --- a/net/minecraft/world/entity/projectile/EntityFireworks.java
+++ b/net/minecraft/world/entity/projectile/EntityFireworks.java +++ b/net/minecraft/world/entity/projectile/EntityFireworks.java
@@ -28,6 +28,8 @@ @@ -143,7 +143,7 @@
import net.minecraft.world.phys.MovingObjectPositionEntity;
import net.minecraft.world.phys.Vec3D;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFireworks extends IProjectile implements ItemSupplier {
public static final DataWatcherObject<ItemStack> DATA_ID_FIREWORKS_ITEM = DataWatcher.defineId(EntityFireworks.class, DataWatcherRegistry.ITEM_STACK);
@@ -143,7 +145,7 @@
MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity); MovingObjectPosition movingobjectposition = ProjectileHelper.getHitResultOnMoveVector(this, this::canHitEntity);
if (!this.noPhysics) { if (!this.noPhysics) {
@ -18,7 +9,7 @@
this.hasImpulse = true; this.hasImpulse = true;
} }
@@ -158,7 +160,11 @@ @@ -158,7 +158,11 @@
} }
if (!this.level().isClientSide && this.life > this.lifetime) { if (!this.level().isClientSide && this.life > this.lifetime) {
@ -31,7 +22,7 @@
} }
} }
@@ -174,7 +180,11 @@ @@ -174,7 +178,11 @@
protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) { protected void onHitEntity(MovingObjectPositionEntity movingobjectpositionentity) {
super.onHitEntity(movingobjectpositionentity); super.onHitEntity(movingobjectpositionentity);
if (!this.level().isClientSide) { if (!this.level().isClientSide) {
@ -44,7 +35,7 @@
} }
} }
@@ -184,7 +194,11 @@ @@ -184,7 +192,11 @@
this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this); this.level().getBlockState(blockposition).entityInside(this.level(), blockposition, this);
if (!this.level().isClientSide() && this.hasExplosion()) { if (!this.level().isClientSide() && this.hasExplosion()) {
@ -57,23 +48,3 @@
} }
super.onHitBlock(movingobjectpositionblock); super.onHitBlock(movingobjectpositionblock);
@@ -210,7 +224,9 @@
if (f > 0.0F) {
if (this.attachedToEntity != null) {
+ CraftEventFactory.entityDamage = this; // CraftBukkit
this.attachedToEntity.hurt(this.damageSources().fireworks(this, this.getOwner()), 5.0F + (float) (nbttaglist.size() * 2));
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
double d0 = 5.0D;
@@ -237,7 +253,9 @@
if (flag) {
float f1 = f * (float) Math.sqrt((5.0D - (double) this.distanceTo(entityliving)) / 5.0D);
+ CraftEventFactory.entityDamage = this; // CraftBukkit
entityliving.hurt(this.damageSources().fireworks(this, this.getOwner()), f1);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
}
}

Datei anzeigen

@ -28,7 +28,7 @@
public static DamageSource getDefaultDamageSource(World world, @Nullable Entity entity) { public static DamageSource getDefaultDamageSource(World world, @Nullable Entity entity) {
return world.damageSources().explosion(entity, getIndirectSourceEntityInternal(entity)); return world.damageSources().explosion(entity, getIndirectSourceEntityInternal(entity));
@@ -85,7 +99,7 @@ @@ -85,17 +99,18 @@
this.hitPlayers = Maps.newHashMap(); this.hitPlayers = Maps.newHashMap();
this.level = world; this.level = world;
this.source = entity; this.source = entity;
@ -37,7 +37,11 @@
this.x = d0; this.x = d0;
this.y = d1; this.y = d1;
this.z = d2; this.z = d2;
@@ -96,6 +110,7 @@ this.fire = flag;
this.blockInteraction = explosion_effect;
- this.damageSource = damagesource == null ? world.damageSources().explosion(this) : damagesource;
+ this.damageSource = damagesource == null ? world.damageSources().explosion(this).customCausingEntity(entity) : damagesource.customCausingEntity(entity); // CraftBukkit - handle source entity
this.damageCalculator = explosiondamagecalculator == null ? this.makeDamageCalculator(entity) : explosiondamagecalculator;
this.smallExplosionParticles = particleparam; this.smallExplosionParticles = particleparam;
this.largeExplosionParticles = particleparam1; this.largeExplosionParticles = particleparam1;
this.explosionSound = soundeffect; this.explosionSound = soundeffect;
@ -57,7 +61,7 @@
this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z)); this.level.gameEvent(this.source, GameEvent.EXPLODE, new Vec3D(this.x, this.y, this.z));
Set<BlockPosition> set = Sets.newHashSet(); Set<BlockPosition> set = Sets.newHashSet();
boolean flag = true; boolean flag = true;
@@ -228,7 +248,37 @@ @@ -228,7 +248,35 @@
d9 /= d11; d9 /= d11;
d10 /= d11; d10 /= d11;
if (this.damageCalculator.shouldDamageEntity(this, entity)) { if (this.damageCalculator.shouldDamageEntity(this, entity)) {
@ -74,7 +78,6 @@
+ continue; + continue;
+ } + }
+ +
+ CraftEventFactory.entityDamage = source;
+ entity.lastDamageCancelled = false; + entity.lastDamageCancelled = false;
+ +
+ if (entity instanceof EntityEnderDragon) { + if (entity instanceof EntityEnderDragon) {
@ -88,7 +91,6 @@
+ entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity)); + entity.hurt(this.damageSource, this.damageCalculator.getEntityDamageAmount(this, entity));
+ } + }
+ +
+ CraftEventFactory.entityDamage = null;
+ if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled + if (entity.lastDamageCancelled) { // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Skip entity if damage event was cancelled
+ continue; + continue;
+ } + }
@ -96,7 +98,7 @@
} }
double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity); double d12 = (1.0D - d7) * (double) getSeenPercent(vec3d, entity);
@@ -247,6 +297,14 @@ @@ -247,6 +295,14 @@
d10 *= d13; d10 *= d13;
Vec3D vec3d1 = new Vec3D(d8, d9, d10); Vec3D vec3d1 = new Vec3D(d8, d9, d10);
@ -111,7 +113,7 @@
entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1)); entity.setDeltaMovement(entity.getDeltaMovement().add(vec3d1));
if (entity instanceof EntityHuman) { if (entity instanceof EntityHuman) {
EntityHuman entityhuman = (EntityHuman) entity; EntityHuman entityhuman = (EntityHuman) entity;
@@ -287,9 +345,63 @@ @@ -287,9 +343,63 @@
SystemUtils.shuffle(this.toBlow, this.level.random); SystemUtils.shuffle(this.toBlow, this.level.random);
ObjectListIterator objectlistiterator = this.toBlow.iterator(); ObjectListIterator objectlistiterator = this.toBlow.iterator();
@ -175,7 +177,7 @@
this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> { this.level.getBlockState(blockposition).onExplosionHit(this.level, blockposition, this, (itemstack, blockposition1) -> {
addOrAppendStack(list, itemstack, blockposition1); addOrAppendStack(list, itemstack, blockposition1);
@@ -314,7 +426,11 @@ @@ -314,7 +424,11 @@
BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next(); BlockPosition blockposition1 = (BlockPosition) objectlistiterator1.next();
if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) { if (this.random.nextInt(3) == 0 && this.level.getBlockState(blockposition1).isAir() && this.level.getBlockState(blockposition1.below()).isSolidRender(this.level, blockposition1.below())) {
@ -188,7 +190,7 @@
} }
} }
} }
@@ -322,6 +438,7 @@ @@ -322,6 +436,7 @@
} }
private static void addOrAppendStack(List<Pair<ItemStack, BlockPosition>> list, ItemStack itemstack, BlockPosition blockposition) { private static void addOrAppendStack(List<Pair<ItemStack, BlockPosition>> list, ItemStack itemstack, BlockPosition blockposition) {

Datei anzeigen

@ -18,13 +18,12 @@
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockCactus.AGE, 0);
worldserver.setBlock(blockposition, iblockdata1, 4); worldserver.setBlock(blockposition, iblockdata1, 4);
@@ -119,7 +121,9 @@ @@ -119,7 +121,7 @@
@Override @Override
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
+ CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.hurt(world.damageSources().cactus(), 1.0F);
entity.hurt(world.damageSources().cactus(), 1.0F); + entity.hurt(world.damageSources().cactus().directBlock(world, blockposition), 1.0F); // CraftBukkit
+ CraftEventFactory.blockDamage = null; // CraftBukkit
} }
@Override @Override

Datei anzeigen

@ -1,27 +1,15 @@
--- a/net/minecraft/world/level/block/BlockCampfire.java --- a/net/minecraft/world/level/block/BlockCampfire.java
+++ b/net/minecraft/world/level/block/BlockCampfire.java +++ b/net/minecraft/world/level/block/BlockCampfire.java
@@ -50,6 +50,10 @@ @@ -106,7 +106,7 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+// CraftBukkit end
+
public class BlockCampfire extends BlockTileEntity implements IBlockWaterlogged {
public static final MapCodec<BlockCampfire> CODEC = RecordCodecBuilder.mapCodec((instance) -> {
@@ -106,7 +110,9 @@
@Override @Override
public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { public void entityInside(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { if ((Boolean) iblockdata.getValue(BlockCampfire.LIT) && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.hurt(world.damageSources().inFire(), (float) this.fireDamage);
entity.hurt(world.damageSources().inFire(), (float) this.fireDamage); + entity.hurt(world.damageSources().inFire().directBlock(world, blockposition), (float) this.fireDamage); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit
} }
super.entityInside(iblockdata, world, blockposition, entity); super.entityInside(iblockdata, world, blockposition, entity);
@@ -216,6 +222,11 @@ @@ -216,6 +216,11 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) { if (!world.isClientSide && iprojectile.isOnFire() && iprojectile.mayInteract(world, blockposition) && !(Boolean) iblockdata.getValue(BlockCampfire.LIT) && !(Boolean) iblockdata.getValue(BlockCampfire.WATERLOGGED)) {

Datei anzeigen

@ -1,12 +1,11 @@
--- a/net/minecraft/world/level/block/BlockMagma.java --- a/net/minecraft/world/level/block/BlockMagma.java
+++ b/net/minecraft/world/level/block/BlockMagma.java +++ b/net/minecraft/world/level/block/BlockMagma.java
@@ -30,7 +30,9 @@ @@ -30,7 +30,7 @@
@Override @Override
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) { public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
if (!entity.isSteppingCarefully() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) { if (!entity.isSteppingCarefully() && entity instanceof EntityLiving && !EnchantmentManager.hasFrostWalker((EntityLiving) entity)) {
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit - entity.hurt(world.damageSources().hotFloor(), 1.0F);
entity.hurt(world.damageSources().hotFloor(), 1.0F); + entity.hurt(world.damageSources().hotFloor().directBlock(world, blockposition), 1.0F); // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit
} }
super.stepOn(world, blockposition, iblockdata, entity); super.stepOn(world, blockposition, iblockdata, entity);

Datei anzeigen

@ -1,12 +1,11 @@
--- a/net/minecraft/world/level/block/BlockSweetBerryBush.java --- a/net/minecraft/world/level/block/BlockSweetBerryBush.java
+++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java +++ b/net/minecraft/world/level/block/BlockSweetBerryBush.java
@@ -28,6 +28,14 @@ @@ -28,6 +28,13 @@
import net.minecraft.world.phys.shapes.VoxelShape; import net.minecraft.world.phys.shapes.VoxelShape;
import net.minecraft.world.phys.shapes.VoxelShapeCollision; import net.minecraft.world.phys.shapes.VoxelShapeCollision;
+// CraftBukkit start +// CraftBukkit start
+import java.util.Collections; +import java.util.Collections;
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory; +import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack; +import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.player.PlayerHarvestBlockEvent; +import org.bukkit.event.player.PlayerHarvestBlockEvent;
@ -15,7 +14,7 @@
public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement { public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement {
public static final MapCodec<BlockSweetBerryBush> CODEC = simpleCodec(BlockSweetBerryBush::new); public static final MapCodec<BlockSweetBerryBush> CODEC = simpleCodec(BlockSweetBerryBush::new);
@@ -69,7 +77,7 @@ @@ -69,7 +76,7 @@
if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) { if (i < 3 && randomsource.nextInt(5) == 0 && worldserver.getRawBrightness(blockposition.above(), 0) >= 9) {
IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1); IBlockData iblockdata1 = (IBlockData) iblockdata.setValue(BlockSweetBerryBush.AGE, i + 1);
@ -24,17 +23,16 @@
worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1)); worldserver.gameEvent(GameEvent.BLOCK_CHANGE, blockposition, GameEvent.a.of(iblockdata1));
} }
@@ -84,7 +92,9 @@ @@ -84,7 +91,7 @@
double d1 = Math.abs(entity.getZ() - entity.zOld); double d1 = Math.abs(entity.getZ() - entity.zOld);
if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) { if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.hurt(world.damageSources().sweetBerryBush(), 1.0F);
entity.hurt(world.damageSources().sweetBerryBush(), 1.0F); + entity.hurt(world.damageSources().sweetBerryBush().directBlock(world, blockposition), 1.0F); // CraftBukkit
+ CraftEventFactory.blockDamage = null; // CraftBukkit
} }
} }
@@ -101,7 +111,15 @@ @@ -101,7 +108,15 @@
} else if (i > 1) { } else if (i > 1) {
int j = 1 + world.random.nextInt(2); int j = 1 + world.random.nextInt(2);

Datei anzeigen

@ -1,40 +1,27 @@
--- a/net/minecraft/world/level/block/PointedDripstoneBlock.java --- a/net/minecraft/world/level/block/PointedDripstoneBlock.java
+++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java +++ b/net/minecraft/world/level/block/PointedDripstoneBlock.java
@@ -43,6 +43,11 @@ @@ -132,6 +132,11 @@
import net.minecraft.world.phys.shapes.VoxelShapeCollision;
import net.minecraft.world.phys.shapes.VoxelShapes;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class PointedDripstoneBlock extends Block implements Fallable, IBlockWaterlogged {
public static final MapCodec<PointedDripstoneBlock> CODEC = simpleCodec(PointedDripstoneBlock::new);
@@ -132,6 +137,11 @@
BlockPosition blockposition = movingobjectpositionblock.getBlockPos(); BlockPosition blockposition = movingobjectpositionblock.getBlockPos();
if (iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) { if (iprojectile.mayInteract(world, blockposition) && iprojectile.mayBreak(world) && iprojectile instanceof EntityThrownTrident && iprojectile.getDeltaMovement().length() > 0.6D) {
+ // CraftBukkit start + // CraftBukkit start
+ if (!CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) { + if (!org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.defaultBlockState())) {
+ return; + return;
+ } + }
+ // CraftBukkit end + // CraftBukkit end
world.destroyBlock(blockposition, true); world.destroyBlock(blockposition, true);
} }
@@ -141,7 +151,9 @@ @@ -141,7 +146,7 @@
@Override @Override
public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) { public void fallOn(World world, IBlockData iblockdata, BlockPosition blockposition, Entity entity, float f) {
if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) { if (iblockdata.getValue(PointedDripstoneBlock.TIP_DIRECTION) == EnumDirection.UP && iblockdata.getValue(PointedDripstoneBlock.THICKNESS) == DripstoneThickness.TIP) {
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit - entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite());
entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite()); + entity.causeFallDamage(f + 2.0F, 2.0F, world.damageSources().stalagmite().directBlock(world, blockposition)); // CraftBukkit
+ CraftEventFactory.blockDamage = null; // CraftBukkit
} else { } else {
super.fallOn(world, iblockdata, blockposition, entity, f); super.fallOn(world, iblockdata, blockposition, entity, f);
} }
@@ -386,15 +398,15 @@ @@ -386,15 +391,15 @@
if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) { if (isUnmergedTipWithDirection(iblockdata, enumdirection.getOpposite())) {
createMergedTips(iblockdata, worldserver, blockposition1); createMergedTips(iblockdata, worldserver, blockposition1);
} else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) { } else if (iblockdata.isAir() || iblockdata.is(Blocks.WATER)) {
@ -53,7 +40,7 @@
} }
private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) { private static void createMergedTips(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
@@ -409,8 +421,8 @@ @@ -409,8 +414,8 @@
blockposition1 = blockposition.below(); blockposition1 = blockposition.below();
} }
@ -64,7 +51,7 @@
} }
public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) { public static void spawnDripParticle(World world, BlockPosition blockposition, IBlockData iblockdata) {
@@ -443,7 +455,7 @@ @@ -443,7 +448,7 @@
return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> { return (BlockPosition) findBlockVertical(generatoraccess, blockposition, enumdirection.getAxisDirection(), bipredicate, (iblockdata1) -> {
return isTip(iblockdata1, flag); return isTip(iblockdata1, flag);
@ -73,7 +60,7 @@
} }
} }
@@ -559,7 +571,7 @@ @@ -559,7 +564,7 @@
return canDripThrough(world, blockposition1, iblockdata); return canDripThrough(world, blockposition1, iblockdata);
}; };
@ -82,7 +69,7 @@
} }
@Nullable @Nullable
@@ -568,7 +580,7 @@ @@ -568,7 +573,7 @@
return canDripThrough(world, blockposition1, iblockdata); return canDripThrough(world, blockposition1, iblockdata);
}; };

Datei anzeigen

@ -1,18 +1,6 @@
--- a/net/minecraft/world/level/block/entity/TileEntityConduit.java --- a/net/minecraft/world/level/block/entity/TileEntityConduit.java
+++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java +++ b/net/minecraft/world/level/block/entity/TileEntityConduit.java
@@ -27,6 +27,11 @@ @@ -201,7 +201,7 @@
import net.minecraft.world.phys.AxisAlignedBB;
import net.minecraft.world.phys.Vec3D;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class TileEntityConduit extends TileEntity {
private static final int BLOCK_REFRESH_RATE = 2;
@@ -201,7 +206,7 @@
EntityHuman entityhuman = (EntityHuman) iterator.next(); EntityHuman entityhuman = (EntityHuman) iterator.next();
if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) { if (blockposition.closerThan(entityhuman.blockPosition(), (double) j) && entityhuman.isInWaterOrRain()) {
@ -21,18 +9,16 @@
} }
} }
@@ -230,8 +235,13 @@ @@ -230,8 +230,11 @@
} }
if (tileentityconduit.destroyTarget != null) { if (tileentityconduit.destroyTarget != null) {
- world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F); - world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
- tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F); - tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F);
+ // CraftBukkit start + // CraftBukkit start
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); + if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic().directBlock(world, blockposition), 4.0F)) { // CraftBukkit
+ if (tileentityconduit.destroyTarget.hurt(world.damageSources().magic(), 4.0F)) { + world.playSound(null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ world.playSound((EntityHuman) null, tileentityconduit.destroyTarget.getX(), tileentityconduit.destroyTarget.getY(), tileentityconduit.destroyTarget.getZ(), SoundEffects.CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
+ } + }
+ CraftEventFactory.blockDamage = null;
+ // CraftBukkit end + // CraftBukkit end
} }

Datei anzeigen

@ -16,6 +16,7 @@ import org.bukkit.Keyed;
import org.bukkit.MusicInstrument; import org.bukkit.MusicInstrument;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructure;
import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.generator.structure.CraftStructureType;
@ -24,6 +25,7 @@ import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.craftbukkit.util.Handleable; import org.bukkit.craftbukkit.util.Handleable;
import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType; import org.bukkit.generator.structure.StructureType;
@ -115,6 +117,9 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
if (bukkitClass == TrimPattern.class) { if (bukkitClass == TrimPattern.class) {
return new CraftRegistry<>(TrimPattern.class, registryHolder.registryOrThrow(Registries.TRIM_PATTERN), CraftTrimPattern::new); return new CraftRegistry<>(TrimPattern.class, registryHolder.registryOrThrow(Registries.TRIM_PATTERN), CraftTrimPattern::new);
} }
if (bukkitClass == DamageType.class) {
return new CraftRegistry<>(DamageType.class, registryHolder.registryOrThrow(Registries.DAMAGE_TYPE), CraftDamageType::new);
}
return null; return null;
} }

Datei anzeigen

@ -0,0 +1,37 @@
package org.bukkit.craftbukkit.damage;
import net.minecraft.world.damagesource.DamageEffects;
import org.bukkit.Sound;
import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.damage.DamageEffect;
public class CraftDamageEffect implements DamageEffect {
private final DamageEffects damageEffects;
public CraftDamageEffect(DamageEffects damageEffects) {
this.damageEffects = damageEffects;
}
public DamageEffects getHandle() {
return this.damageEffects;
}
@Override
public Sound getSound() {
return CraftSound.minecraftToBukkit(this.getHandle().sound());
}
public static DamageEffect getById(String id) {
for (DamageEffects damageEffects : DamageEffects.values()) {
if (damageEffects.getSerializedName().equalsIgnoreCase(id)) {
return toBukkit(damageEffects);
}
}
return null;
}
public static DamageEffect toBukkit(DamageEffects damageEffects) {
return new CraftDamageEffect(damageEffects);
}
}

Datei anzeigen

@ -0,0 +1,128 @@
package org.bukkit.craftbukkit.damage;
import java.util.Objects;
import net.minecraft.world.phys.Vec3D;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.util.CraftLocation;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Entity;
public class CraftDamageSource implements DamageSource {
private final net.minecraft.world.damagesource.DamageSource damageSource;
private final DamageType damageType;
public CraftDamageSource(net.minecraft.world.damagesource.DamageSource damageSource) {
this.damageSource = damageSource;
this.damageType = CraftDamageType.minecraftHolderToBukkit(damageSource.typeHolder());
}
public net.minecraft.world.damagesource.DamageSource getHandle() {
return this.damageSource;
}
public World getCausingEntityWorld() {
org.bukkit.entity.Entity causingEntity = getCausingEntity();
return causingEntity != null ? causingEntity.getWorld() : null;
}
public Block getDirectBlock() {
return this.getHandle().getDirectBlock();
}
@Override
public DamageType getDamageType() {
return this.damageType;
}
@Override
public org.bukkit.entity.Entity getCausingEntity() {
net.minecraft.world.entity.Entity entity = this.getHandle().getCausingEntity();
return (entity != null) ? entity.getBukkitEntity() : null;
}
@Override
public org.bukkit.entity.Entity getDirectEntity() {
net.minecraft.world.entity.Entity entity = this.getHandle().getDirectEntity();
return (entity != null) ? entity.getBukkitEntity() : null;
}
@Override
public Location getDamageLocation() {
Vec3D vec3D = this.getHandle().sourcePositionRaw();
return (vec3D != null) ? CraftLocation.toBukkit(vec3D, this.getCausingEntityWorld()) : null;
}
@Override
public Location getSourceLocation() {
Vec3D vec3D = this.getHandle().getSourcePosition();
return (vec3D != null) ? CraftLocation.toBukkit(vec3D, this.getCausingEntityWorld()) : null;
}
@Override
public boolean isIndirect() {
return this.getHandle().getCausingEntity() != this.getHandle().getDirectEntity();
}
@Override
public float getFoodExhaustion() {
return this.damageType.getExhaustion();
}
@Override
public boolean scalesWithDifficulty() {
return this.getHandle().scalesWithDifficulty();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof DamageSource)) {
return false;
}
DamageSource other = (DamageSource) obj;
return Objects.equals(this.getDamageType(), other.getDamageType()) && Objects.equals(this.getCausingEntity(), other.getCausingEntity())
&& Objects.equals(this.getDirectEntity(), other.getDirectEntity()) && Objects.equals(this.getDamageLocation(), other.getDamageLocation());
}
@Override
public int hashCode() {
int result = 1;
result = 31 * result + this.damageType.hashCode();
result = 31 * result + (this.getCausingEntity() != null ? this.getCausingEntity().hashCode() : 0);
result = 31 * result + (this.getDirectEntity() != null ? this.getDirectEntity().hashCode() : 0);
result = 31 * result + (this.getDamageLocation() != null ? this.getDamageLocation().hashCode() : 0);
return result;
}
@Override
public String toString() {
return "DamageSource{damageType=" + this.getDamageType() + ",causingEntity=" + this.getCausingEntity() + ",directEntity=" + this.getDirectEntity() + ",damageLocation=" + this.getDamageLocation() + "}";
}
public static DamageSource buildFromBukkit(DamageType damageType, Entity causingEntity, Entity directEntity, Location damageLocation) {
net.minecraft.core.Holder<net.minecraft.world.damagesource.DamageType> holderDamageType = CraftDamageType.bukkitToMinecraftHolder(damageType);
net.minecraft.world.entity.Entity nmsCausingEntity = null;
if (causingEntity instanceof CraftEntity craftCausingEntity) {
nmsCausingEntity = craftCausingEntity.getHandle();
}
net.minecraft.world.entity.Entity nmsDirectEntity = null;
if (directEntity instanceof CraftEntity craftDirectEntity) {
nmsDirectEntity = craftDirectEntity.getHandle();
}
Vec3D vec3D = (damageLocation == null) ? null : CraftLocation.toVec3D(damageLocation);
return new CraftDamageSource(new net.minecraft.world.damagesource.DamageSource(holderDamageType, nmsDirectEntity, nmsCausingEntity, vec3D));
}
}

Datei anzeigen

@ -0,0 +1,46 @@
package org.bukkit.craftbukkit.damage;
import com.google.common.base.Preconditions;
import org.bukkit.Location;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Entity;
public class CraftDamageSourceBuilder implements DamageSource.Builder {
private final DamageType damageType;
private Entity causingEntity;
private Entity directEntity;
private Location damageLocation;
public CraftDamageSourceBuilder(DamageType damageType) {
Preconditions.checkArgument(damageType != null, "DamageType cannot be null");
this.damageType = damageType;
}
@Override
public DamageSource.Builder withCausingEntity(Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
this.causingEntity = entity;
return this;
}
@Override
public DamageSource.Builder withDirectEntity(Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
this.directEntity = entity;
return this;
}
@Override
public DamageSource.Builder withDamageLocation(Location location) {
Preconditions.checkArgument(location != null, "Location cannot be null");
this.damageLocation = location.clone();
return this;
}
@Override
public DamageSource build() {
return CraftDamageSource.buildFromBukkit(damageType, causingEntity, directEntity, damageLocation);
}
}

Datei anzeigen

@ -0,0 +1,126 @@
package org.bukkit.craftbukkit.damage;
import com.google.common.base.Preconditions;
import net.minecraft.core.Holder;
import net.minecraft.core.IRegistry;
import net.minecraft.core.registries.Registries;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.util.Handleable;
import org.bukkit.damage.DamageEffect;
import org.bukkit.damage.DamageScaling;
import org.bukkit.damage.DamageType;
import org.bukkit.damage.DeathMessageType;
public class CraftDamageType implements DamageType, Handleable<net.minecraft.world.damagesource.DamageType> {
private final NamespacedKey key;
private final net.minecraft.world.damagesource.DamageType damageType;
public CraftDamageType(NamespacedKey key, net.minecraft.world.damagesource.DamageType damageType) {
this.key = key;
this.damageType = damageType;
}
@Override
public net.minecraft.world.damagesource.DamageType getHandle() {
return this.damageType;
}
@Override
public String getTranslationKey() {
return this.getHandle().msgId();
}
@Override
public DamageScaling getDamageScaling() {
return damageScalingToBukkit(this.getHandle().scaling());
}
@Override
public DamageEffect getDamageEffect() {
return CraftDamageEffect.toBukkit(this.getHandle().effects());
}
@Override
public DeathMessageType getDeathMessageType() {
return deathMessageTypeToBukkit(this.getHandle().deathMessageType());
}
@Override
public float getExhaustion() {
return this.getHandle().exhaustion();
}
@Override
public NamespacedKey getKey() {
return this.key;
}
@Override
public String toString() {
return "CraftDamageType{" + "key=" + this.getKey() + ",damageScaling=" + this.getDamageScaling() + ",damageEffect=" + this.getDamageEffect() + ",deathMessageType=" + this.getDeathMessageType() + ",exhaustion=" + this.getExhaustion() + "}";
}
public static DeathMessageType deathMessageTypeToBukkit(net.minecraft.world.damagesource.DeathMessageType deathMessageType) {
return switch (deathMessageType) {
case DEFAULT -> DeathMessageType.DEFAULT;
case FALL_VARIANTS -> DeathMessageType.FALL_VARIANTS;
case INTENTIONAL_GAME_DESIGN -> DeathMessageType.INTENTIONAL_GAME_DESIGN;
default -> throw new IllegalArgumentException("NMS DeathMessageType." + deathMessageType + " cannot be converted to a Bukkit DeathMessageType.");
};
}
public static net.minecraft.world.damagesource.DeathMessageType deathMessageTypeToNMS(DeathMessageType deathMessageType) {
return switch (deathMessageType) {
case DEFAULT -> net.minecraft.world.damagesource.DeathMessageType.DEFAULT;
case FALL_VARIANTS -> net.minecraft.world.damagesource.DeathMessageType.FALL_VARIANTS;
case INTENTIONAL_GAME_DESIGN -> net.minecraft.world.damagesource.DeathMessageType.INTENTIONAL_GAME_DESIGN;
default -> throw new IllegalArgumentException("Bukkit DeathMessageType." + deathMessageType + " cannot be converted to a NMS DeathMessageType.");
};
}
public static DamageScaling damageScalingToBukkit(net.minecraft.world.damagesource.DamageScaling damageScaling) {
return switch (damageScaling) {
case ALWAYS -> DamageScaling.ALWAYS;
case WHEN_CAUSED_BY_LIVING_NON_PLAYER -> DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER;
case NEVER -> DamageScaling.NEVER;
default -> throw new IllegalArgumentException("NMS DamageScaling." + damageScaling + " cannot be converted to a Bukkit DamageScaling");
};
}
public static net.minecraft.world.damagesource.DamageScaling damageScalingToNMS(DamageScaling damageScaling) {
return switch (damageScaling) {
case ALWAYS -> net.minecraft.world.damagesource.DamageScaling.ALWAYS;
case WHEN_CAUSED_BY_LIVING_NON_PLAYER -> net.minecraft.world.damagesource.DamageScaling.WHEN_CAUSED_BY_LIVING_NON_PLAYER;
case NEVER -> net.minecraft.world.damagesource.DamageScaling.NEVER;
default -> throw new IllegalArgumentException("Bukkit DamageScaling." + damageScaling + " cannot be converted to a NMS DamageScaling");
};
}
public static DamageType minecraftHolderToBukkit(Holder<net.minecraft.world.damagesource.DamageType> minecraftHolder) {
return minecraftToBukkit(minecraftHolder.value());
}
public static Holder<net.minecraft.world.damagesource.DamageType> bukkitToMinecraftHolder(DamageType bukkitDamageType) {
Preconditions.checkArgument(bukkitDamageType != null);
IRegistry<net.minecraft.world.damagesource.DamageType> registry = CraftRegistry.getMinecraftRegistry(Registries.DAMAGE_TYPE);
if (registry.wrapAsHolder(bukkitToMinecraft(bukkitDamageType)) instanceof Holder.c<net.minecraft.world.damagesource.DamageType> holder) {
return holder;
}
throw new IllegalArgumentException("No Reference holder found for " + bukkitDamageType
+ ", this can happen if a plugin creates its own damage type with out properly registering it.");
}
public static net.minecraft.world.damagesource.DamageType bukkitToMinecraft(DamageType bukkitDamageType) {
return CraftRegistry.bukkitToMinecraft(bukkitDamageType);
}
public static DamageType minecraftToBukkit(net.minecraft.world.damagesource.DamageType minecraftDamageType) {
return CraftRegistry.minecraftToBukkit(minecraftDamageType, Registries.DAMAGE_TYPE, Registry.DAMAGE_TYPE);
}
}

Datei anzeigen

@ -2,6 +2,7 @@ package org.bukkit.craftbukkit.entity;
import net.minecraft.world.entity.boss.EntityComplexPart; import net.minecraft.world.entity.boss.EntityComplexPart;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.damage.DamageSource;
import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.EnderDragonPart; import org.bukkit.entity.EnderDragonPart;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -26,6 +27,11 @@ public class CraftEnderDragonPart extends CraftComplexPart implements EnderDrago
return "CraftEnderDragonPart"; return "CraftEnderDragonPart";
} }
@Override
public void damage(double amount, DamageSource damageSource) {
getParent().damage(amount, damageSource);
}
@Override @Override
public void damage(double amount) { public void damage(double amount) {
getParent().damage(amount); getParent().damage(amount);

Datei anzeigen

@ -51,6 +51,7 @@ import org.bukkit.block.Block;
import org.bukkit.craftbukkit.CraftServer; import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.CraftSound; import org.bukkit.craftbukkit.CraftSound;
import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.damage.CraftDamageSource;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey; import org.bukkit.craftbukkit.entity.memory.CraftMemoryKey;
import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper; import org.bukkit.craftbukkit.entity.memory.CraftMemoryMapper;
import org.bukkit.craftbukkit.inventory.CraftEntityEquipment; import org.bukkit.craftbukkit.inventory.CraftEntityEquipment;
@ -280,13 +281,11 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
@Override @Override
public void damage(double amount) { public void damage(double amount) {
damage(amount, null); damage(amount, getHandle().damageSources().generic());
} }
@Override @Override
public void damage(double amount, org.bukkit.entity.Entity source) { public void damage(double amount, org.bukkit.entity.Entity source) {
Preconditions.checkState(!getHandle().generation, "Cannot damage entity during world generation");
DamageSource reason = getHandle().damageSources().generic(); DamageSource reason = getHandle().damageSources().generic();
if (source instanceof HumanEntity) { if (source instanceof HumanEntity) {
@ -295,7 +294,21 @@ public class CraftLivingEntity extends CraftEntity implements LivingEntity {
reason = getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle()); reason = getHandle().damageSources().mobAttack(((CraftLivingEntity) source).getHandle());
} }
entity.hurt(reason, (float) amount); damage(amount, reason);
}
@Override
public void damage(double amount, org.bukkit.damage.DamageSource damageSource) {
Preconditions.checkArgument(damageSource != null, "damageSource cannot be null");
damage(amount, ((CraftDamageSource) damageSource).getHandle());
}
private void damage(double amount, DamageSource damageSource) {
Preconditions.checkArgument(damageSource != null, "damageSource cannot be null");
Preconditions.checkState(!getHandle().generation, "Cannot damage entity during world generation");
entity.hurt(damageSource, (float) amount);
} }
@Override @Override

Datei anzeigen

@ -39,7 +39,6 @@ import net.minecraft.world.entity.animal.EntityAnimal;
import net.minecraft.world.entity.animal.EntityFish; import net.minecraft.world.entity.animal.EntityFish;
import net.minecraft.world.entity.animal.EntityGolem; import net.minecraft.world.entity.animal.EntityGolem;
import net.minecraft.world.entity.animal.EntityWaterAnimal; import net.minecraft.world.entity.animal.EntityWaterAnimal;
import net.minecraft.world.entity.boss.enderdragon.EntityEnderDragon;
import net.minecraft.world.entity.item.EntityItem; import net.minecraft.world.entity.item.EntityItem;
import net.minecraft.world.entity.monster.EntityGhast; import net.minecraft.world.entity.monster.EntityGhast;
import net.minecraft.world.entity.monster.EntityIllagerWizard; import net.minecraft.world.entity.monster.EntityIllagerWizard;
@ -95,6 +94,7 @@ import org.bukkit.craftbukkit.block.CraftBlock;
import org.bukkit.craftbukkit.block.CraftBlockState; import org.bukkit.craftbukkit.block.CraftBlockState;
import org.bukkit.craftbukkit.block.CraftBlockStates; import org.bukkit.craftbukkit.block.CraftBlockStates;
import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.damage.CraftDamageSource;
import org.bukkit.craftbukkit.entity.CraftEntity; import org.bukkit.craftbukkit.entity.CraftEntity;
import org.bukkit.craftbukkit.entity.CraftLivingEntity; import org.bukkit.craftbukkit.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.entity.CraftPlayer; import org.bukkit.craftbukkit.entity.CraftPlayer;
@ -258,8 +258,6 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class CraftEventFactory { public class CraftEventFactory {
public static org.bukkit.block.Block blockDamage; // For use in EntityDamageByBlockEvent
public static Entity entityDamage; // For use in EntityDamageByEntityEvent
// helper methods // helper methods
private static boolean canBuild(WorldServer world, Player player, int x, int z) { private static boolean canBuild(WorldServer world, Player player, int x, int z) {
@ -939,38 +937,18 @@ public class CraftEventFactory {
} }
private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) { private static EntityDamageEvent handleEntityDamageEvent(Entity entity, DamageSource source, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
CraftDamageSource bukkitDamageSource = new CraftDamageSource(source);
Entity damager = source.getCausingEntity();
if (source.is(DamageTypeTags.IS_EXPLOSION)) { if (source.is(DamageTypeTags.IS_EXPLOSION)) {
DamageCause damageCause;
Entity damager = entityDamage;
entityDamage = null;
EntityDamageEvent event;
if (damager == null) { if (damager == null) {
event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.BLOCK_EXPLOSION, modifiers, modifierFunctions); return callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.BLOCK_EXPLOSION, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
} else if (entity instanceof EntityEnderDragon && /*PAIL FIXME ((EntityEnderDragon) entity).target == damager*/ false) {
event = new EntityDamageEvent(entity.getBukkitEntity(), DamageCause.ENTITY_EXPLOSION, modifiers, modifierFunctions);
} else {
if (damager instanceof org.bukkit.entity.TNTPrimed) {
damageCause = DamageCause.BLOCK_EXPLOSION;
} else {
damageCause = DamageCause.ENTITY_EXPLOSION;
}
event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), entity.getBukkitEntity(), damageCause, modifiers, modifierFunctions);
} }
event.setCancelled(cancelled); DamageCause damageCause = (damager.getBukkitEntity() instanceof org.bukkit.entity.TNTPrimed) ? DamageCause.BLOCK_EXPLOSION : DamageCause.ENTITY_EXPLOSION;
return callEntityDamageEvent(damager, entity, damageCause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
callEvent(event); } else if (damager != null || source.getDirectEntity() != null) {
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
} else {
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
}
return event;
} else if (source.getEntity() != null || source.getDirectEntity() != null) {
Entity damager = source.getEntity();
DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK; DamageCause cause = (source.isSweep()) ? DamageCause.ENTITY_SWEEP_ATTACK : DamageCause.ENTITY_ATTACK;
if (source.isIndirect() && source.getDirectEntity() != null) { if (bukkitDamageSource.isIndirect() && source.getDirectEntity() != null) {
damager = source.getDirectEntity(); damager = source.getDirectEntity();
} }
@ -984,37 +962,25 @@ public class CraftEventFactory {
cause = DamageCause.THORNS; cause = DamageCause.THORNS;
} else if (source.is(DamageTypes.SONIC_BOOM)) { } else if (source.is(DamageTypes.SONIC_BOOM)) {
cause = DamageCause.SONIC_BOOM; cause = DamageCause.SONIC_BOOM;
} else if (source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) {
cause = DamageCause.FALLING_BLOCK;
} else if (source.is(DamageTypes.LIGHTNING_BOLT)) {
cause = DamageCause.LIGHTNING;
} else if (source.is(DamageTypes.FALL)) {
cause = DamageCause.FALL;
} else if (source.is(DamageTypes.DRAGON_BREATH)) {
cause = DamageCause.DRAGON_BREATH;
} else if (source.is(DamageTypes.MAGIC)) {
cause = DamageCause.MAGIC;
} }
return callEntityDamageEvent(damager, entity, cause, modifiers, modifierFunctions, cancelled); return callEntityDamageEvent(damager, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
} else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) { } else if (source.is(DamageTypes.FELL_OUT_OF_WORLD)) {
EntityDamageEvent event = new EntityDamageByBlockEvent(null, entity.getBukkitEntity(), DamageCause.VOID, modifiers, modifierFunctions); return callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.VOID, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
event.setCancelled(cancelled);
callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
} else {
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
}
return event;
} else if (source.is(DamageTypes.LAVA)) { } else if (source.is(DamageTypes.LAVA)) {
EntityDamageEvent event = (new EntityDamageByBlockEvent(blockDamage, entity.getBukkitEntity(), DamageCause.LAVA, modifiers, modifierFunctions)); return callEntityDamageEvent(source.getDirectBlock(), entity, DamageCause.LAVA, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
event.setCancelled(cancelled); } else if (source.getDirectBlock() != null) {
DamageCause cause;
Block damager = blockDamage;
blockDamage = null; // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call
callEvent(event);
blockDamage = damager; // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
} else {
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
}
return event;
} else if (blockDamage != null) {
DamageCause cause = null;
Block damager = blockDamage;
if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_ANVIL)) { if (source.is(DamageTypes.CACTUS) || source.is(DamageTypes.SWEET_BERRY_BUSH) || source.is(DamageTypes.STALAGMITE) || source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_ANVIL)) {
cause = DamageCause.CONTACT; cause = DamageCause.CONTACT;
} else if (source.is(DamageTypes.HOT_FLOOR)) { } else if (source.is(DamageTypes.HOT_FLOOR)) {
@ -1024,50 +990,12 @@ public class CraftEventFactory {
} else if (source.is(DamageTypes.IN_FIRE)) { } else if (source.is(DamageTypes.IN_FIRE)) {
cause = DamageCause.FIRE; cause = DamageCause.FIRE;
} else { } else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager, source.getMsgId())); throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, source.getDirectBlock(), source.getMsgId()));
} }
EntityDamageEvent event = new EntityDamageByBlockEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions); return callEntityDamageEvent(source.getDirectBlock(), entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
event.setCancelled(cancelled);
blockDamage = null; // SPIGOT-6639: Clear blockDamage to allow other entity damage during event call
callEvent(event);
blockDamage = damager; // SPIGOT-6639: Re-set blockDamage so that other entities which are also getting damaged have the right cause
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
} else {
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
}
return event;
} else if (entityDamage != null) {
DamageCause cause = null;
CraftEntity damager = entityDamage.getBukkitEntity();
entityDamage = null;
if (source.is(DamageTypes.FALLING_STALACTITE) || source.is(DamageTypes.FALLING_BLOCK) || source.is(DamageTypes.FALLING_ANVIL)) {
cause = DamageCause.FALLING_BLOCK;
} else if (damager instanceof LightningStrike) {
cause = DamageCause.LIGHTNING;
} else if (source.is(DamageTypes.FALL)) {
cause = DamageCause.FALL;
} else if (source.is(DamageTypes.DRAGON_BREATH)) {
cause = DamageCause.DRAGON_BREATH;
} else if (source.is(DamageTypes.MAGIC)) {
cause = DamageCause.MAGIC;
} else {
throw new IllegalStateException(String.format("Unhandled damage of %s by %s from %s", entity, damager.getHandle(), source.getMsgId()));
}
EntityDamageEvent event = new EntityDamageByEntityEvent(damager, entity.getBukkitEntity(), cause, modifiers, modifierFunctions);
event.setCancelled(cancelled);
callEvent(event);
if (!event.isCancelled()) {
event.getEntity().setLastDamageCause(event);
} else {
entity.lastDamageCancelled = true; // SPIGOT-5339, SPIGOT-6252, SPIGOT-6777: Keep track if the event was canceled
}
return event;
} }
DamageCause cause = null; DamageCause cause;
if (source.is(DamageTypes.IN_FIRE)) { if (source.is(DamageTypes.IN_FIRE)) {
cause = DamageCause.FIRE; cause = DamageCause.FIRE;
} else if (source.is(DamageTypes.STARVE)) { } else if (source.is(DamageTypes.STARVE)) {
@ -1104,24 +1032,25 @@ public class CraftEventFactory {
cause = DamageCause.CUSTOM; cause = DamageCause.CUSTOM;
} }
if (cause != null) { return callEntityDamageEvent((Entity) null, entity, cause, bukkitDamageSource, modifiers, modifierFunctions, cancelled);
return callEntityDamageEvent(null, entity, cause, modifiers, modifierFunctions, cancelled);
}
throw new IllegalStateException(String.format("Unhandled damage of %s from %s", entity, source.getMsgId()));
} }
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions) { private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
return callEntityDamageEvent(damager, damagee, cause, modifiers, modifierFunctions, false);
}
private static EntityDamageEvent callEntityDamageEvent(Entity damager, Entity damagee, DamageCause cause, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
EntityDamageEvent event; EntityDamageEvent event;
if (damager != null) { if (damager != null) {
event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, modifiers, modifierFunctions); event = new EntityDamageByEntityEvent(damager.getBukkitEntity(), damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
} else { } else {
event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, modifiers, modifierFunctions); event = new EntityDamageEvent(damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
} }
return callEntityDamageEvent(event, damagee, cancelled);
}
private static EntityDamageEvent callEntityDamageEvent(Block damager, Entity damagee, DamageCause cause, org.bukkit.damage.DamageSource bukkitDamageSource, Map<DamageModifier, Double> modifiers, Map<DamageModifier, Function<? super Double, Double>> modifierFunctions, boolean cancelled) {
EntityDamageByBlockEvent event = new EntityDamageByBlockEvent(damager, damagee.getBukkitEntity(), cause, bukkitDamageSource, modifiers, modifierFunctions);
return callEntityDamageEvent(event, damagee, cancelled);
}
private static EntityDamageEvent callEntityDamageEvent(EntityDamageEvent event, Entity damagee, boolean cancelled) {
event.setCancelled(cancelled); event.setCancelled(cancelled);
callEvent(event); callEvent(event);

Datei anzeigen

@ -57,9 +57,14 @@ import org.bukkit.craftbukkit.CraftRegistry;
import org.bukkit.craftbukkit.attribute.CraftAttribute; import org.bukkit.craftbukkit.attribute.CraftAttribute;
import org.bukkit.craftbukkit.attribute.CraftAttributeInstance; import org.bukkit.craftbukkit.attribute.CraftAttributeInstance;
import org.bukkit.craftbukkit.block.data.CraftBlockData; import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.craftbukkit.damage.CraftDamageEffect;
import org.bukkit.craftbukkit.damage.CraftDamageSourceBuilder;
import org.bukkit.craftbukkit.inventory.CraftItemStack; import org.bukkit.craftbukkit.inventory.CraftItemStack;
import org.bukkit.craftbukkit.legacy.CraftLegacy; import org.bukkit.craftbukkit.legacy.CraftLegacy;
import org.bukkit.craftbukkit.potion.CraftPotionType; import org.bukkit.craftbukkit.potion.CraftPotionType;
import org.bukkit.damage.DamageEffect;
import org.bukkit.damage.DamageSource;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.CreativeCategory; import org.bukkit.inventory.CreativeCategory;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
@ -384,6 +389,17 @@ public final class CraftMagicNumbers implements UnsafeValues {
return new CraftPotionType(namespacedKey, potionRegistry); return new CraftPotionType(namespacedKey, potionRegistry);
} }
@Override
public DamageEffect getDamageEffect(String key) {
Preconditions.checkArgument(key != null, "key cannot be null");
return CraftDamageEffect.getById(key);
}
@Override
public DamageSource.Builder createDamageSourceBuilder(DamageType damageType) {
return new CraftDamageSourceBuilder(damageType);
}
/** /**
* This helper class represents the different NBT Tags. * This helper class represents the different NBT Tags.
* <p> * <p>

Datei anzeigen

@ -0,0 +1,30 @@
package org.bukkit.damage;
import static org.junit.jupiter.api.Assertions.*;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.junit.jupiter.api.Test;
public class DamageTypeTest {
@Test
public void testDeathMessageType() {
for (DeathMessageType deathMessageType : DeathMessageType.values()) {
assertNotNull(CraftDamageType.deathMessageTypeToNMS(deathMessageType), deathMessageType.name());
}
for (net.minecraft.world.damagesource.DeathMessageType deathMessageType : net.minecraft.world.damagesource.DeathMessageType.values()) {
assertNotNull(CraftDamageType.deathMessageTypeToBukkit(deathMessageType), deathMessageType.name());
}
}
@Test
public void testDamageScale() {
for (DamageScaling damageScaling : DamageScaling.values()) {
assertNotNull(CraftDamageType.damageScalingToNMS(damageScaling), damageScaling.name());
}
for (net.minecraft.world.damagesource.DamageScaling damageScaling : net.minecraft.world.damagesource.DamageScaling.values()) {
assertNotNull(CraftDamageType.damageScalingToBukkit(damageScaling), damageScaling.name());
}
}
}

Datei anzeigen

@ -13,6 +13,7 @@ import org.bukkit.Keyed;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.craftbukkit.util.CraftNamespacedKey; import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.damage.DamageType;
import org.bukkit.inventory.meta.trim.TrimMaterial; import org.bukkit.inventory.meta.trim.TrimMaterial;
import org.bukkit.inventory.meta.trim.TrimPattern; import org.bukkit.inventory.meta.trim.TrimPattern;
import org.bukkit.support.AbstractTestingBase; import org.bukkit.support.AbstractTestingBase;
@ -20,6 +21,12 @@ import org.junit.jupiter.api.Test;
public class RegistryConstantsTest extends AbstractTestingBase { public class RegistryConstantsTest extends AbstractTestingBase {
@Test
public void testDamageType() {
this.testExcessConstants(DamageType.class, Registry.DAMAGE_TYPE);
this.testMissingConstants(DamageType.class, Registries.DAMAGE_TYPE);
}
@Test @Test
public void testTrimMaterial() { public void testTrimMaterial() {
this.testExcessConstants(TrimMaterial.class, Registry.TRIM_MATERIAL); this.testExcessConstants(TrimMaterial.class, Registry.TRIM_MATERIAL);

Datei anzeigen

@ -10,12 +10,14 @@ import org.bukkit.GameEvent;
import org.bukkit.MusicInstrument; import org.bukkit.MusicInstrument;
import org.bukkit.craftbukkit.CraftGameEvent; import org.bukkit.craftbukkit.CraftGameEvent;
import org.bukkit.craftbukkit.CraftMusicInstrument; import org.bukkit.craftbukkit.CraftMusicInstrument;
import org.bukkit.craftbukkit.damage.CraftDamageType;
import org.bukkit.craftbukkit.enchantments.CraftEnchantment; import org.bukkit.craftbukkit.enchantments.CraftEnchantment;
import org.bukkit.craftbukkit.generator.structure.CraftStructure; import org.bukkit.craftbukkit.generator.structure.CraftStructure;
import org.bukkit.craftbukkit.generator.structure.CraftStructureType; import org.bukkit.craftbukkit.generator.structure.CraftStructureType;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial; import org.bukkit.craftbukkit.inventory.trim.CraftTrimMaterial;
import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern; import org.bukkit.craftbukkit.inventory.trim.CraftTrimPattern;
import org.bukkit.craftbukkit.potion.CraftPotionEffectType; import org.bukkit.craftbukkit.potion.CraftPotionEffectType;
import org.bukkit.damage.DamageType;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.generator.structure.Structure; import org.bukkit.generator.structure.Structure;
import org.bukkit.generator.structure.StructureType; import org.bukkit.generator.structure.StructureType;
@ -40,6 +42,7 @@ public class RegistriesArgumentProvider implements ArgumentsProvider {
DATA.add(Arguments.of(StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class)); DATA.add(Arguments.of(StructureType.class, Registries.STRUCTURE_TYPE, CraftStructureType.class, net.minecraft.world.level.levelgen.structure.StructureType.class));
DATA.add(Arguments.of(TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.armortrim.TrimMaterial.class)); DATA.add(Arguments.of(TrimMaterial.class, Registries.TRIM_MATERIAL, CraftTrimMaterial.class, net.minecraft.world.item.armortrim.TrimMaterial.class));
DATA.add(Arguments.of(TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.armortrim.TrimPattern.class)); DATA.add(Arguments.of(TrimPattern.class, Registries.TRIM_PATTERN, CraftTrimPattern.class, net.minecraft.world.item.armortrim.TrimPattern.class));
DATA.add(Arguments.of(DamageType.class, Registries.DAMAGE_TYPE, CraftDamageType.class, net.minecraft.world.damagesource.DamageType.class));
} }
@Override @Override