Skip to content

Commit

Permalink
1.20.4 update
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeTheTech committed Mar 15, 2024
1 parent 23d5d1d commit aa8df9e
Show file tree
Hide file tree
Showing 23 changed files with 464 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/animal/BeePet.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import net.minecraft.world.entity.NeutralMob;
import net.minecraft.world.entity.animal.Animal;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;
Expand All @@ -27,6 +29,7 @@
import java.util.UUID;

public class BeePet extends Animal implements NeutralMob {
private volatile CraftEntity bukkitEntity;
private static final UniformInt PERSISTENT_ANGER_TIME = TimeUtil.rangeOfSeconds(20, 39);
private static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(BeePet.class, EntityDataSerializers.BYTE);
private static final EntityDataAccessor<Integer> DATA_REMAINING_ANGER_TIME = SynchedEntityData.defineId(BeePet.class, EntityDataSerializers.INT);
Expand Down Expand Up @@ -154,4 +157,23 @@ public boolean hasNectar() {
private boolean getFlag(int location) {
return (entityData.get(DATA_FLAGS_ID) & location) != 0;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/animal/FoxPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
import net.minecraft.world.entity.animal.Animal;
import net.minecraft.world.entity.animal.Fox;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class FoxPet extends Animal implements VariantHolder<Fox.Type> {
private volatile CraftEntity bukkitEntity;
private static final EntityDataAccessor<Integer> DATA_TYPE_ID = SynchedEntityData.defineId(FoxPet.class, EntityDataSerializers.INT);

public FoxPet(Player player, String[] data) {
Expand Down Expand Up @@ -82,4 +85,23 @@ protected SoundEvent getAmbientSound() {
public AgeableMob getBreedOffspring(ServerLevel world, AgeableMob entity) {
return null;
}

// 1.20.4+ fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4+ fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
1 change: 0 additions & 1 deletion src/main/java/lee/code/pets/pets/pet/animal/GoatPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.bukkit.event.entity.EntityTargetEvent;

public class GoatPet extends Goat {
//TODO look into riding movement, something seems off

public GoatPet(Player player, String[] data) {
super(EntityType.GOAT, ((CraftWorld) player.getLocation().getWorld()).getHandle());
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/animal/RabbitPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@
import net.minecraft.world.level.pathfinder.Path;
import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

import java.util.UUID;

public class RabbitPet extends Animal implements VariantHolder<Rabbit.Variant> {
private volatile CraftEntity bukkitEntity;
private static final EntityDataAccessor<Integer> DATA_TYPE_ID = SynchedEntityData.defineId(RabbitPet.class, EntityDataSerializers.INT);
private int jumpTicks;
private int jumpDuration;
Expand Down Expand Up @@ -229,6 +232,25 @@ public void setWantedPosition(double x, double y, double z, double speed) {
}
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}

public class RabbitJumpControl extends JumpControl {
private final Mob mob;
private boolean canJump;
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/animal/SnowGolemPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class SnowGolemPet extends Mob {
private volatile CraftEntity bukkitEntity;
private static final EntityDataAccessor<Byte> DATA_PUMPKIN_ID = SynchedEntityData.defineId(SnowGolemPet.class, EntityDataSerializers.BYTE);

public SnowGolemPet(Player player, String[] data) {
Expand Down Expand Up @@ -90,4 +93,23 @@ public void load(CompoundTag compoundTag) {
public boolean save(CompoundTag compoundTag) {
return false;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class WanderingTraderPet extends Mob {
private volatile CraftEntity bukkitEntity;

public WanderingTraderPet(Player player, String[] data) {
super(EntityType.WANDERING_TRADER, ((CraftWorld) player.getLocation().getWorld()).getHandle());
Expand Down Expand Up @@ -52,4 +55,23 @@ public void load(CompoundTag compoundTag) {
public boolean save(CompoundTag compoundTag) {
return false;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/fish/ElderGuardianPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Monster;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class ElderGuardianPet extends Monster {
private volatile CraftEntity bukkitEntity;

public ElderGuardianPet(Player player, String[] data) {
super(EntityType.ELDER_GUARDIAN, ((CraftWorld) player.getLocation().getWorld()).getHandle());
Expand Down Expand Up @@ -52,4 +55,23 @@ public boolean save(CompoundTag compoundTag) {
protected SoundEvent getAmbientSound() {
return isInWaterOrBubble() ? SoundEvents.ELDER_GUARDIAN_AMBIENT : SoundEvents.ELDER_GUARDIAN_AMBIENT_LAND;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/monster/BlazePet.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.monster.Monster;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class BlazePet extends Monster {
private volatile CraftEntity bukkitEntity;
private static final EntityDataAccessor<Byte> DATA_FLAGS_ID = SynchedEntityData.defineId(BlazePet.class, EntityDataSerializers.BYTE);

public BlazePet(Player player, String[] data) {
Expand Down Expand Up @@ -71,4 +74,23 @@ private void setCharged(boolean fireActive) {
else b = (byte)(b & -2);
entityData.set(DATA_FLAGS_ID, b);
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/monster/EnderDragonPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class EnderDragonPet extends Mob {
private volatile CraftEntity bukkitEntity;

public EnderDragonPet(Player player, String[] data) {
super(EntityType.ENDER_DRAGON, ((CraftWorld) player.getLocation().getWorld()).getHandle());
Expand Down Expand Up @@ -46,4 +49,23 @@ public void load(CompoundTag compoundTag) {
public boolean save(CompoundTag compoundTag) {
return false;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
22 changes: 22 additions & 0 deletions src/main/java/lee/code/pets/pets/pet/monster/EndermanPet.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.Mob;
import org.bukkit.craftbukkit.v1_20_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityTargetEvent;

public class EndermanPet extends Mob {
private volatile CraftEntity bukkitEntity;

public EndermanPet(Player player, String[] data) {
super(EntityType.ENDERMAN, ((CraftWorld) player.getLocation().getWorld()).getHandle());
Expand Down Expand Up @@ -52,4 +55,23 @@ public void load(CompoundTag compoundTag) {
public boolean save(CompoundTag compoundTag) {
return false;
}

// 1.20.4 fix
@Override
public CraftEntity getBukkitEntity() {
if (this.bukkitEntity == null) {
synchronized (this) {
if (this.bukkitEntity == null) {
return this.bukkitEntity = new CraftLivingEntity(this.level().getCraftServer(), this) {};
}
}
}
return this.bukkitEntity;
}

// 1.20.4 fix
@Override
public CraftLivingEntity getBukkitLivingEntity() {
return (CraftLivingEntity) this.getBukkitEntity();
}
}
Loading

0 comments on commit aa8df9e

Please sign in to comment.