From b8bddfd9b3c5ef2c34f4d3cbee8e6c421052b8c6 Mon Sep 17 00:00:00 2001 From: ImHacking Date: Fri, 24 Jun 2022 03:18:10 -0400 Subject: [PATCH] Fixed a few errors that are to come. --- .../net/minecraft/server/EntityVillager.java | 18 +++--- .../minecraft/server/PathfinderGoalFloat.java | 2 +- .../server/PathfinderGoalMoveIndoors.java | 61 +++++++++++++++++++ .../PathfinderGoalMoveTowardsRestriction.java | 40 ++++++++++++ .../server/PathfinderGoalRandomStroll.java | 61 +++++++++++++++++++ 5 files changed, 173 insertions(+), 9 deletions(-) create mode 100644 TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveIndoors.java create mode 100644 TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveTowardsRestriction.java create mode 100644 TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalRandomStroll.java diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/EntityVillager.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/EntityVillager.java index f1c905a..6f5620e 100644 --- a/TacoSpigot-Server/src/main/java/net/minecraft/server/EntityVillager.java +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/EntityVillager.java @@ -33,8 +33,8 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { this.inventory = new InventorySubcontainer("Items", false, 8, (CraftVillager) this.getBukkitEntity()); // CraftBukkit add argument this.setProfession(i); this.setSize(0.6F, 1.8F); - ((Navigation) this.getNavigation()).b(true); - ((Navigation) this.getNavigation()).a(true); + (this.getNavigation()).b(true); + (this.getNavigation()).a(true); this.goalSelector.a(0, new PathfinderGoalFloat(this)); this.goalSelector.a(1, new PathfinderGoalAvoidTarget(this, EntityZombie.class, 8.0F, 0.6D, 0.6D)); this.goalSelector.a(1, new PathfinderGoalTradeWithPlayer(this)); @@ -216,7 +216,7 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { } public void setProfession(int i) { - this.datawatcher.watch(16, Integer.valueOf(i)); + this.datawatcher.watch(16, i); } public int getProfession() { @@ -462,7 +462,7 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { } if (s1 != null) { - ChatMessage chatmessage = new ChatMessage("entity.Villager." + s1, new Object[0]); + ChatMessage chatmessage = new ChatMessage("entity.Villager." + s1); chatmessage.getChatModifier().setChatHoverable(this.aQ()); chatmessage.getChatModifier().setInsertion(this.getUniqueID().toString()); @@ -497,7 +497,7 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { public EntityVillager b(EntityAgeable entityageable) { EntityVillager entityvillager = new EntityVillager(this.world); - entityvillager.prepare(this.world.E(new BlockPosition(entityvillager)), (GroupDataEntity) null); + entityvillager.prepare(this.world.E(new BlockPosition(entityvillager)), null); return entityvillager; } @@ -567,7 +567,9 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { ItemStack itemstack = this.inventory.getItem(j); if (itemstack != null) { - if (itemstack.getItem() == Items.BREAD && itemstack.count >= 3 * i || itemstack.getItem() == Items.POTATO && itemstack.count >= 12 * i || itemstack.getItem() == Items.CARROT && itemstack.count >= 12 * i) { + if (itemstack.getItem() == Items.BREAD && itemstack.count >= 3 * i + || itemstack.getItem() == Items.POTATO && itemstack.count >= 12 * i + || itemstack.getItem() == Items.CARROT && itemstack.count >= 12 * i) { return true; } @@ -751,11 +753,11 @@ public class EntityVillager extends EntityAgeable implements IMerchant, NPC { static class MerchantOptionRandomRange extends Tuple { public MerchantOptionRandomRange(int i, int j) { - super(Integer.valueOf(i), Integer.valueOf(j)); + super(i, j); } public int a(Random random) { - return ((Integer) this.a()).intValue() >= ((Integer) this.b()).intValue() ? ((Integer) this.a()).intValue() : ((Integer) this.a()).intValue() + random.nextInt(((Integer) this.b()).intValue() - ((Integer) this.a()).intValue() + 1); + return this.a() >= this.b() ? this.a() : this.a() + random.nextInt( this.b() - this.a() + 1); } } } diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalFloat.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalFloat.java index da019c1..6cc7601 100644 --- a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalFloat.java +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalFloat.java @@ -8,7 +8,7 @@ public class PathfinderGoalFloat extends PathfinderGoal { this.a = entityinsentient; entityinsentient.goalFloat = this; // PaperSpigot this.a(4); - ((Navigation) entityinsentient.getNavigation()).d(true); + (entityinsentient.getNavigation()).d(true); } public boolean a() { diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveIndoors.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveIndoors.java new file mode 100644 index 0000000..d853e8f --- /dev/null +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveIndoors.java @@ -0,0 +1,61 @@ +package net.minecraft.server; + +public class PathfinderGoalMoveIndoors extends PathfinderGoal { + private EntityCreature a; + private VillageDoor b; + private int c = -1; + private int d = -1; + + public PathfinderGoalMoveIndoors(EntityCreature var1) { + this.a = var1; + this.a(1); + } + + public boolean a() { + BlockPosition blockPosition = new BlockPosition(this.a); + if ((!this.a.world.w() || this.a.world.S() && !this.a.world.getBiome(blockPosition).e()) && !this.a.world.worldProvider.o()) { + if (this.a.bc().nextInt(50) != 0) { + return false; + } else if (this.c != -1 && this.a.e(this.c, this.a.locY, this.d) < 4.0) { + return false; + } else { + Village var2 = this.a.world.ae().getClosestVillage(blockPosition, 14); + if (var2 == null) { + return false; + } else { + this.b = var2.c(blockPosition); + return this.b != null; + } + } + } else { + return false; + } + } + + public boolean b() { + return !this.a.getNavigation().m(); + } + + public void c() { + this.c = -1; + BlockPosition var1 = this.b.e(); + int var2 = var1.getX(); + int var3 = var1.getY(); + int var4 = var1.getZ(); + if (this.a.b(var1) > 256.0) { + Vec3D var5 = RandomPositionGenerator.a(this.a, 14, 3, new Vec3D((double)var2 + 0.5, var3, (double)var4 + 0.5)); + if (var5 != null) { + this.a.getNavigation().a(var5.a, var5.b, var5.c, 1.0); + } + } else { + this.a.getNavigation().a((double)var2 + 0.5, var3, var4 + 0.5, 1.0); + } + + } + + public void d() { + this.c = this.b.e().getX(); + this.d = this.b.e().getZ(); + this.b = null; + } +} diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveTowardsRestriction.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveTowardsRestriction.java new file mode 100644 index 0000000..76641e9 --- /dev/null +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalMoveTowardsRestriction.java @@ -0,0 +1,40 @@ +package net.minecraft.server; + +public class PathfinderGoalMoveTowardsRestriction extends PathfinderGoal { + private EntityCreature a; + private double b; + private double c; + private double d; + private double e; + + public PathfinderGoalMoveTowardsRestriction(EntityCreature var1, double var2) { + this.a = var1; + this.e = var2; + this.a(1); + } + + public boolean a() { + if (this.a.cg()) { + return false; + } else { + BlockPosition var1 = this.a.ch(); + Vec3D var2 = RandomPositionGenerator.a(this.a, 16, 7, new Vec3D(var1.getX(), var1.getY(), var1.getZ())); + if (var2 == null) { + return false; + } else { + this.b = var2.a; + this.c = var2.b; + this.d = var2.c; + return true; + } + } + } + + public boolean b() { + return !this.a.getNavigation().m(); + } + + public void c() { + this.a.getNavigation().a(this.b, this.c, this.d, this.e); + } +} diff --git a/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalRandomStroll.java b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalRandomStroll.java new file mode 100644 index 0000000..8fc9c6a --- /dev/null +++ b/TacoSpigot-Server/src/main/java/net/minecraft/server/PathfinderGoalRandomStroll.java @@ -0,0 +1,61 @@ +package net.minecraft.server; + +public class PathfinderGoalRandomStroll extends PathfinderGoal { + private EntityCreature a; + private double b; + private double c; + private double d; + private double e; + private int f; + private boolean g; + + public PathfinderGoalRandomStroll(EntityCreature var1, double var2) { + this(var1, var2, 120); + } + + public PathfinderGoalRandomStroll(EntityCreature var1, double var2, int var4) { + this.a = var1; + this.e = var2; + this.f = var4; + this.a(1); + } + + public boolean a() { + if (!this.g) { + if (this.a.bh() >= 100) { + return false; + } + + if (this.a.bc().nextInt(this.f) != 0) { + return false; + } + } + + Vec3D var1 = RandomPositionGenerator.a(this.a, 10, 7); + if (var1 == null) { + return false; + } else { + this.b = var1.a; + this.c = var1.b; + this.d = var1.c; + this.g = false; + return true; + } + } + + public boolean b() { + return !this.a.getNavigation().m(); + } + + public void c() { + this.a.getNavigation().a(this.b, this.c, this.d, this.e); + } + + public void f() { + this.g = true; + } + + public void setTimeBetweenMovement(int var1) { + this.f = var1; + } +} \ No newline at end of file