mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-25 12:05:53 +01:00
#686: Expand Strider and Steerable entity API
This commit is contained in:
parent
e2403a3d2c
commit
32acc26217
97
nms-patches/EntityStrider.patch
Normal file
97
nms-patches/EntityStrider.patch
Normal file
@ -0,0 +1,97 @@
|
||||
--- a/net/minecraft/server/EntityStrider.java
|
||||
+++ b/net/minecraft/server/EntityStrider.java
|
||||
@@ -14,7 +14,7 @@
|
||||
private static final DataWatcherObject<Integer> bx = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.b);
|
||||
private static final DataWatcherObject<Boolean> by = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.i);
|
||||
private static final DataWatcherObject<Boolean> bz = DataWatcher.a(EntityStrider.class, DataWatcherRegistry.i);
|
||||
- private final SaddleStorage bA;
|
||||
+ public final SaddleStorage bA; // CraftBukkit PAIL private -> public, rename saddleStorage
|
||||
private PathfinderGoalTempt bB;
|
||||
private PathfinderGoalPanic bC;
|
||||
|
||||
@@ -264,7 +264,12 @@
|
||||
IBlockData iblockdata1 = this.aJ();
|
||||
boolean flag = iblockdata.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || iblockdata1.a((Tag) TagsBlock.STRIDER_WARM_BLOCKS) || this.b((Tag) TagsFluid.LAVA) > 0.0D;
|
||||
|
||||
- this.t(!flag);
|
||||
+ // CraftBukkit start
|
||||
+ if (!flag ^ this.eL()) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callStriderTemperatureChangeEvent(this, !flag);
|
||||
+ this.t(!flag);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
super.tick();
|
||||
this.eV();
|
||||
this.checkBlockCollisions();
|
||||
@@ -390,36 +395,36 @@
|
||||
@Override
|
||||
public GroupDataEntity prepare(GeneratorAccess generatoraccess, DifficultyDamageScaler difficultydamagescaler, EnumMobSpawn enummobspawn, @Nullable GroupDataEntity groupdataentity, @Nullable NBTTagCompound nbttagcompound) {
|
||||
EntityZombie.GroupDataZombie entityzombie_groupdatazombie = null;
|
||||
- EntityStrider$GroupData$Rider entitystrider$groupdata$rider;
|
||||
+ EntityStrider.GroupData.Rider entitystrider_groupdata_rider;
|
||||
|
||||
- if (groupdataentity instanceof EntityStrider.a) {
|
||||
- entitystrider$groupdata$rider = ((EntityStrider.a) groupdataentity).a;
|
||||
+ if (groupdataentity instanceof EntityStrider.GroupData) {
|
||||
+ entitystrider_groupdata_rider = ((EntityStrider.GroupData) groupdataentity).a;
|
||||
} else if (!this.isBaby()) {
|
||||
if (this.random.nextInt(30) == 0) {
|
||||
- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.PIGLIN_RIDER;
|
||||
+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.PIGLIN_RIDER;
|
||||
entityzombie_groupdatazombie = new EntityZombie.GroupDataZombie(EntityZombie.a(this.random), false);
|
||||
} else if (this.random.nextInt(10) == 0) {
|
||||
- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.BABY_RIDER;
|
||||
+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.BABY_RIDER;
|
||||
} else {
|
||||
- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.NO_RIDER;
|
||||
+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.NO_RIDER;
|
||||
}
|
||||
|
||||
- groupdataentity = new EntityStrider.a(entitystrider$groupdata$rider);
|
||||
- ((EntityAgeable.a) groupdataentity).a(entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.NO_RIDER ? 0.5F : 0.0F);
|
||||
+ groupdataentity = new EntityStrider.GroupData(entitystrider_groupdata_rider);
|
||||
+ ((EntityAgeable.a) groupdataentity).a(entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.NO_RIDER ? 0.5F : 0.0F);
|
||||
} else {
|
||||
- entitystrider$groupdata$rider = EntityStrider$GroupData$Rider.NO_RIDER;
|
||||
+ entitystrider_groupdata_rider = EntityStrider.GroupData.Rider.NO_RIDER;
|
||||
}
|
||||
|
||||
Object object = null;
|
||||
|
||||
- if (entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.BABY_RIDER) {
|
||||
+ if (entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.BABY_RIDER) {
|
||||
EntityStrider entitystrider = (EntityStrider) EntityTypes.STRIDER.a(generatoraccess.getMinecraftWorld());
|
||||
|
||||
if (entitystrider != null) {
|
||||
object = entitystrider;
|
||||
entitystrider.setAgeRaw(-24000);
|
||||
}
|
||||
- } else if (entitystrider$groupdata$rider == EntityStrider$GroupData$Rider.PIGLIN_RIDER) {
|
||||
+ } else if (entitystrider_groupdata_rider == EntityStrider.GroupData.Rider.PIGLIN_RIDER) {
|
||||
EntityPigZombie entitypigzombie = (EntityPigZombie) EntityTypes.ZOMBIFIED_PIGLIN.a(generatoraccess.getMinecraftWorld());
|
||||
|
||||
if (entitypigzombie != null) {
|
||||
@@ -461,12 +466,19 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static class a extends EntityAgeable.a {
|
||||
+ public static class GroupData extends EntityAgeable.a {
|
||||
+
|
||||
+ public final EntityStrider.GroupData.Rider a;
|
||||
+
|
||||
+ public GroupData(EntityStrider.GroupData.Rider entitystrider_groupdata_rider) {
|
||||
+ this.a = entitystrider_groupdata_rider;
|
||||
+ }
|
||||
+
|
||||
+ public static enum Rider {
|
||||
|
||||
- public final EntityStrider$GroupData$Rider a;
|
||||
+ NO_RIDER, BABY_RIDER, PIGLIN_RIDER;
|
||||
|
||||
- public a(EntityStrider$GroupData$Rider entitystrider$groupdata$rider) {
|
||||
- this.a = entitystrider$groupdata$rider;
|
||||
+ private Rider() {}
|
||||
}
|
||||
}
|
||||
}
|
18
nms-patches/SaddleStorage.patch
Normal file
18
nms-patches/SaddleStorage.patch
Normal file
@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/server/SaddleStorage.java
|
||||
+++ b/net/minecraft/server/SaddleStorage.java
|
||||
@@ -35,6 +35,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit add setBoostTicks(int)
|
||||
+ public void setBoostTicks(int ticks) {
|
||||
+ this.a = true; // PAIL rename boosting
|
||||
+ this.b = 0; // PAIL rename currentBoostTicks
|
||||
+ this.c = ticks; // PAIL rename boostTicks
|
||||
+ this.d.set(this.e, this.c); // PAIL rename dataWatcher, dataWatcherBoostTicks
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
nbttagcompound.setBoolean("Saddle", this.hasSaddle());
|
||||
}
|
@ -1,11 +1,14 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EntityPig;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Pig;
|
||||
|
||||
public class CraftPig extends CraftAnimals implements Pig {
|
||||
|
||||
public CraftPig(CraftServer server, EntityPig entity) {
|
||||
super(server, entity);
|
||||
}
|
||||
@ -20,6 +23,40 @@ public class CraftPig extends CraftAnimals implements Pig {
|
||||
getHandle().saddleStorage.setSaddle(saddled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().saddleStorage.a ? getHandle().saddleStorage.c : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoostTicks(int ticks) {
|
||||
Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0");
|
||||
|
||||
getHandle().saddleStorage.setBoostTicks(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentBoostTicks() {
|
||||
return getHandle().saddleStorage.a ? getHandle().saddleStorage.b : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentBoostTicks(int ticks) {
|
||||
if (!getHandle().saddleStorage.a) {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().saddleStorage.c;
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().saddleStorage.b = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getSteerMaterial() {
|
||||
return Material.CARROT_ON_A_STICK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityPig getHandle() {
|
||||
return (EntityPig) entity;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.bukkit.craftbukkit.entity;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import net.minecraft.server.EntityStrider;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Strider;
|
||||
@ -11,6 +13,60 @@ public class CraftStrider extends CraftAnimals implements Strider {
|
||||
super(server, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShivering() {
|
||||
return getHandle().eL(); // PAIL rename isShivering
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShivering(boolean shivering) {
|
||||
this.getHandle().t(shivering); // PAIL rename setShivering
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasSaddle() {
|
||||
return getHandle().hasSaddle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaddle(boolean saddled) {
|
||||
getHandle().bA.setSaddle(saddled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBoostTicks() {
|
||||
return getHandle().bA.a ? getHandle().bA.c : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBoostTicks(int ticks) {
|
||||
Preconditions.checkArgument(ticks >= 0, "ticks must be >= 0");
|
||||
|
||||
getHandle().bA.setBoostTicks(ticks);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentBoostTicks() {
|
||||
return getHandle().bA.a ? getHandle().bA.b : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCurrentBoostTicks(int ticks) {
|
||||
if (!getHandle().bA.a) {
|
||||
return;
|
||||
}
|
||||
|
||||
int max = getHandle().bA.c;
|
||||
Preconditions.checkArgument(ticks >= 0 && ticks <= max, "boost ticks must not exceed 0 or %d (inclusive)", max);
|
||||
|
||||
this.getHandle().bA.b = ticks;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Material getSteerMaterial() {
|
||||
return Material.WARPED_FUNGUS_ON_A_STICK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityStrider getHandle() {
|
||||
return (EntityStrider) entity;
|
||||
|
@ -39,6 +39,7 @@ import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.EntityPotion;
|
||||
import net.minecraft.server.EntityRaider;
|
||||
import net.minecraft.server.EntitySlime;
|
||||
import net.minecraft.server.EntityStrider;
|
||||
import net.minecraft.server.EntityTypes;
|
||||
import net.minecraft.server.EntityVillager;
|
||||
import net.minecraft.server.EntityWaterAnimal;
|
||||
@ -113,6 +114,7 @@ import org.bukkit.entity.PigZombie;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Raider;
|
||||
import org.bukkit.entity.Strider;
|
||||
import org.bukkit.entity.ThrownExpBottle;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
@ -180,6 +182,7 @@ import org.bukkit.event.entity.PlayerLeashEntityEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.StriderTemperatureChangeEvent;
|
||||
import org.bukkit.event.entity.VillagerCareerChangeEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
@ -1576,4 +1579,9 @@ public class CraftEventFactory {
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
return event;
|
||||
}
|
||||
|
||||
public static void callStriderTemperatureChangeEvent(EntityStrider strider, boolean shivering) {
|
||||
StriderTemperatureChangeEvent event = new StriderTemperatureChangeEvent((Strider) strider.getBukkitEntity(), shivering);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user