#1209: Clean up various patches
By: Owen1212055 <23108066+Owen1212055@users.noreply.github.com>
This commit is contained in:
@@ -16,28 +16,28 @@
|
||||
public class EntityEgg extends EntityProjectileThrowable {
|
||||
|
||||
public EntityEgg(EntityTypes<? extends EntityEgg> entitytypes, World world) {
|
||||
@@ -47,22 +56,42 @@
|
||||
@@ -47,20 +56,47 @@
|
||||
protected void onHit(MovingObjectPosition movingobjectposition) {
|
||||
super.onHit(movingobjectposition);
|
||||
if (!this.level().isClientSide) {
|
||||
- if (this.random.nextInt(8) == 0) {
|
||||
+ boolean hatching = this.random.nextInt(8) == 0; // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ boolean hatching = this.random.nextInt(8) == 0;
|
||||
+ if (true) {
|
||||
+ // CraftBukkit end
|
||||
byte b0 = 1;
|
||||
|
||||
if (this.random.nextInt(32) == 0) {
|
||||
b0 = 4;
|
||||
}
|
||||
|
||||
- for (int i = 0; i < b0; ++i) {
|
||||
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
|
||||
+ // CraftBukkit start
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ EntityType hatchingType = EntityType.CHICKEN;
|
||||
+
|
||||
+ Entity shooter = this.getOwner();
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ if (shooter instanceof EntityPlayer) {
|
||||
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent((Player) shooter.getBukkitEntity(), (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, b0, hatchingType);
|
||||
+ this.level().getCraftServer().getPluginManager().callEvent(event);
|
||||
@@ -45,24 +45,27 @@
|
||||
+ b0 = event.getNumHatches();
|
||||
+ hatching = event.isHatching();
|
||||
+ hatchingType = event.getHatchingType();
|
||||
+ // If hatching is set to false, ensure child count is 0
|
||||
+ if (!hatching) {
|
||||
+ b0 = 0;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
for (int i = 0; i < b0; ++i) {
|
||||
- EntityChicken entitychicken = (EntityChicken) EntityTypes.CHICKEN.create(this.level());
|
||||
+ Entity entitychicken = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass()); // CraftBukkit
|
||||
|
||||
- if (entitychicken != null) {
|
||||
if (entitychicken != null) {
|
||||
- entitychicken.setAge(-24000);
|
||||
- entitychicken.moveTo(this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F);
|
||||
- this.level().addFreshEntity(entitychicken);
|
||||
+ if (hatching) {
|
||||
+ for (int i = 0; i < b0; ++i) {
|
||||
+ Entity entity = this.level().getWorld().createEntity(new org.bukkit.Location(this.level().getWorld(), this.getX(), this.getY(), this.getZ(), this.getYRot(), 0.0F), hatchingType.getEntityClass());
|
||||
+ if (entity != null) {
|
||||
+ if (entity.getBukkitEntity() instanceof Ageable) {
|
||||
+ ((Ageable) entity.getBukkitEntity()).setBaby();
|
||||
+ }
|
||||
+ this.level().getWorld().addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
|
||||
+ // CraftBukkit start
|
||||
+ if (entitychicken.getBukkitEntity() instanceof Ageable) {
|
||||
+ ((Ageable) entitychicken.getBukkitEntity()).setBaby();
|
||||
+ }
|
||||
+ this.level().addFreshEntity(entitychicken, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.level().broadcastEntityEvent(this, (byte) 3);
|
||||
|
||||
@@ -124,14 +124,14 @@
|
||||
if (iblockdata.is(TagsBlock.FIRE)) {
|
||||
- this.level().removeBlock(blockposition, false);
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState()).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, Blocks.AIR.defaultBlockState())) {
|
||||
+ this.level().removeBlock(blockposition, false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else if (AbstractCandleBlock.isLit(iblockdata)) {
|
||||
- AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false)).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(AbstractCandleBlock.LIT, false))) {
|
||||
+ AbstractCandleBlock.extinguish((EntityHuman) null, iblockdata, this.level(), blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
@@ -140,7 +140,7 @@
|
||||
- BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
|
||||
- this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false)).isCancelled()) {
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, blockposition, iblockdata.setValue(BlockCampfire.LIT, false))) {
|
||||
+ this.level().levelEvent((EntityHuman) null, 1009, blockposition, 0);
|
||||
+ BlockCampfire.dowse(this.getOwner(), this.level(), blockposition, iblockdata);
|
||||
+ this.level().setBlockAndUpdate(blockposition, (IBlockData) iblockdata.setValue(BlockCampfire.LIT, false));
|
||||
|
||||
@@ -1,32 +1,24 @@
|
||||
--- a/net/minecraft/world/entity/projectile/EntityTippedArrow.java
|
||||
+++ b/net/minecraft/world/entity/projectile/EntityTippedArrow.java
|
||||
@@ -142,6 +142,25 @@
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
private static final int NO_EFFECT_COLOR = -1;
|
||||
private static final DataWatcherObject<Integer> ID_EFFECT_COLOR = DataWatcher.defineId(EntityTippedArrow.class, DataWatcherRegistry.INT);
|
||||
private static final byte EVENT_POTION_PUFF = 0;
|
||||
- private PotionRegistry potion;
|
||||
+ public PotionRegistry potion; // CraftBukkit private -> public
|
||||
public final Set<MobEffect> effects;
|
||||
private boolean fixedColor;
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
return nbttagcompound != null && nbttagcompound.contains("CustomPotionColor", 99) ? nbttagcompound.getInt("CustomPotionColor") : -1;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start accessor methods
|
||||
+ public void refreshEffects() {
|
||||
+ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects)));
|
||||
+ }
|
||||
+
|
||||
+ public String getPotionType() {
|
||||
+ return BuiltInRegistries.POTION.getKey(this.potion).toString();
|
||||
+ }
|
||||
+
|
||||
+ public void setPotionType(String string) {
|
||||
+ this.potion = BuiltInRegistries.POTION.get(new net.minecraft.resources.MinecraftKey(string));
|
||||
+ this.getEntityData().set(EntityTippedArrow.ID_EFFECT_COLOR, PotionUtil.getColor((Collection) PotionUtil.getAllEffects(this.potion, (Collection) this.effects)));
|
||||
+ }
|
||||
+
|
||||
+ public boolean isTipped() {
|
||||
+ return !(this.effects.isEmpty() && this.potion == Potions.EMPTY);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public int getColor() {
|
||||
return (Integer) this.entityData.get(EntityTippedArrow.ID_EFFECT_COLOR);
|
||||
}
|
||||
@@ -212,7 +231,7 @@
|
||||
- private void updateColor() {
|
||||
+ public void updateColor() { // CraftBukkit private -> public
|
||||
this.fixedColor = false;
|
||||
if (this.potion == Potions.EMPTY && this.effects.isEmpty()) {
|
||||
this.entityData.set(EntityTippedArrow.ID_EFFECT_COLOR, -1);
|
||||
@@ -212,7 +212,7 @@
|
||||
mobeffect = (MobEffect) iterator.next();
|
||||
entityliving.addEffect(new MobEffect(mobeffect.getEffect(), Math.max(mobeffect.mapDuration((i) -> {
|
||||
return i / 8;
|
||||
@@ -35,7 +27,7 @@
|
||||
}
|
||||
|
||||
if (!this.effects.isEmpty()) {
|
||||
@@ -220,7 +239,7 @@
|
||||
@@ -220,7 +220,7 @@
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
mobeffect = (MobEffect) iterator.next();
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
--- a/net/minecraft/world/entity/projectile/EntityWitherSkull.java
|
||||
+++ b/net/minecraft/world/entity/projectile/EntityWitherSkull.java
|
||||
@@ -20,6 +20,8 @@
|
||||
@@ -20,6 +20,10 @@
|
||||
import net.minecraft.world.phys.MovingObjectPosition;
|
||||
import net.minecraft.world.phys.MovingObjectPositionEntity;
|
||||
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class EntityWitherSkull extends EntityFireball {
|
||||
|
||||
private static final DataWatcherObject<Boolean> DATA_DANGEROUS = DataWatcher.defineId(EntityWitherSkull.class, DataWatcherRegistry.BOOLEAN);
|
||||
@@ -63,7 +65,7 @@
|
||||
@@ -63,7 +67,7 @@
|
||||
if (entity.isAlive()) {
|
||||
this.doEnchantDamageEffects(entityliving, entity);
|
||||
} else {
|
||||
@@ -18,7 +20,7 @@
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -81,7 +83,7 @@
|
||||
@@ -81,7 +85,7 @@
|
||||
}
|
||||
|
||||
if (b0 > 0) {
|
||||
@@ -27,7 +29,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +94,15 @@
|
||||
@@ -92,7 +96,15 @@
|
||||
protected void onHit(MovingObjectPosition movingobjectposition) {
|
||||
super.onHit(movingobjectposition);
|
||||
if (!this.level().isClientSide) {
|
||||
|
||||
Reference in New Issue
Block a user