Add phantom allow-griefing option

This commit is contained in:
BillyGalbreath
2021-02-13 14:26:41 -06:00
parent b15a2e9bf2
commit 9537c770b0
49 changed files with 156 additions and 137 deletions

View File

@@ -3,6 +3,7 @@ From: William Blake Galbreath <Blake.Galbreath@GMail.com>
Date: Sun, 5 Jul 2020 22:19:49 -0500
Subject: [PATCH] Ridables
test
diff --git a/src/main/java/net/minecraft/server/AttributeDefaults.java b/src/main/java/net/minecraft/server/AttributeDefaults.java
index 8f95a4e49714e352b9cdf82d7f4acdd3459978ad..ab05b5e403cf54756aa35891dc0d950187a9d4ec 100644
@@ -2865,10 +2866,10 @@ index 0af6c9395b5d98e6bfa162f651d0e8cb89035afd..e402d4a77b57b8b12b7575a9793c30d7
this.goalSelector.a(2, new PathfinderGoalSit(this));
this.goalSelector.a(2, new PathfinderGoalFollowOwner(this, 1.0D, 5.0F, 1.0F, true));
diff --git a/src/main/java/net/minecraft/server/EntityPhantom.java b/src/main/java/net/minecraft/server/EntityPhantom.java
index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254cf3298a42 100644
index bdfe073dcd255a7359127f9ae3a962642be5526d..c70281fddcbe5a97a1eb176def99cdf31de37579 100644
--- a/src/main/java/net/minecraft/server/EntityPhantom.java
+++ b/src/main/java/net/minecraft/server/EntityPhantom.java
@@ -25,6 +25,58 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -25,6 +25,59 @@ public class EntityPhantom extends EntityFlying implements IMonster {
this.lookController = new EntityPhantom.f(this);
}
@@ -2918,6 +2919,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
+ org.bukkit.util.Vector target = loc.getDirection().normalize().multiply(100).add(loc.toVector());
+
+ net.pl3x.purpur.entity.PhantomFlames flames = new net.pl3x.purpur.entity.PhantomFlames(world, this);
+ flames.canGrief = world.purpurConfig.phantomAllowGriefing;
+ flames.shoot(target.getX() - locX(), target.getY() - locY(), target.getZ() - locZ(), 1.0F, 5.0F);
+ world.addEntity(flames);
+ return true;
@@ -2927,7 +2929,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
@Override
protected EntityAIBodyControl r() {
return new EntityPhantom.d(this);
@@ -33,6 +85,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -33,6 +86,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@Override
protected void initPathfinder() {
// Purpur start
@@ -2935,7 +2937,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
if (world.purpurConfig.phantomOrbitCrystalRadius > 0) {
this.goalSelector.a(1, new FindCrystalGoal(this));
this.goalSelector.a(2, new OrbitCrystalGoal(this));
@@ -40,6 +93,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -40,6 +94,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
this.goalSelector.a(3, new EntityPhantom.c()); // PickAttackGoal
this.goalSelector.a(4, new EntityPhantom.i()); // SweepAttackGoal
this.goalSelector.a(5, new EntityPhantom.e()); // OrbitPointGoal
@@ -2943,7 +2945,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
this.targetSelector.a(1, new EntityPhantom.b()); // AttackPlayer Goal
// Purpur end
}
@@ -126,7 +180,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -126,7 +181,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@Override
public void movementTick() {
@@ -2952,7 +2954,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
this.setOnFire(8);
}
@@ -368,7 +422,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -368,7 +423,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@Override
public boolean a() {
@@ -2961,7 +2963,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
if (this.c > 0) {
--this.c;
return false;
@@ -397,7 +451,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -397,7 +452,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@Override
public boolean b() {
@@ -2970,7 +2972,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
EntityLiving entityliving = EntityPhantom.this.getGoalTarget();
return entityliving != null ? EntityPhantom.this.a(entityliving, PathfinderTargetCondition.a) : false;
@@ -412,7 +466,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -412,7 +467,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@Override
public boolean a() {
@@ -2979,7 +2981,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
EntityLiving entityliving = EntityPhantom.this.getGoalTarget();
return entityliving != null ? EntityPhantom.this.a(EntityPhantom.this.getGoalTarget(), PathfinderTargetCondition.a) : false;
@@ -610,14 +664,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -610,14 +665,23 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
}
@@ -3005,7 +3007,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
}
class d extends EntityAIBodyControl {
@@ -633,7 +696,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -633,7 +697,7 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
}
@@ -3014,7 +3016,7 @@ index bdfe073dcd255a7359127f9ae3a962642be5526d..f8c3480045e86a18501db223c1b2254c
private float j = 0.1F;
@@ -642,7 +705,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
@@ -642,7 +706,19 @@ public class EntityPhantom extends EntityFlying implements IMonster {
}
@Override
@@ -5071,7 +5073,7 @@ index c314a8c9a921a95cea43b748e2037521d948e1e7..59f3122aab9940cb3c3c1efb2664ab08
public static int dungeonSeed = -1;
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
index 637cac2758a44e72794953b9fbca2accb7d86b6a..3d3505f538510fbef4a7d584fa5f03c48be184f7 100644
index 637cac2758a44e72794953b9fbca2accb7d86b6a..d8b5e091047210a8eff45e493f07d30ffa6d9f81 100644
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
@@ -42,11 +42,6 @@ public class PurpurWorldConfig {
@@ -5404,9 +5406,11 @@ index 637cac2758a44e72794953b9fbca2accb7d86b6a..3d3505f538510fbef4a7d584fa5f03c4
public double phantomAttackedByCrystalRadius = 0.0D;
public float phantomAttackedByCrystalDamage = 1.0F;
public double phantomOrbitCrystalRadius = 0.0D;
@@ -451,6 +663,11 @@ public class PurpurWorldConfig {
@@ -450,7 +662,13 @@ public class PurpurWorldConfig {
public int phantomBurnInLight = 0;
public boolean phantomIgnorePlayersWithTorch = false;
public boolean phantomBurnInDaylight = true;
+ public boolean phantomAllowGriefing = false;
private void phantomSettings() {
+ phantomRidable = getBoolean("mobs.phantom.ridable", phantomRidable);
+ phantomRidableInWater = getBoolean("mobs.phantom.ridable-in-water", phantomRidableInWater);
@@ -5416,8 +5420,11 @@ index 637cac2758a44e72794953b9fbca2accb7d86b6a..3d3505f538510fbef4a7d584fa5f03c4
phantomAttackedByCrystalRadius = getDouble("mobs.phantom.attacked-by-crystal-range", phantomAttackedByCrystalRadius);
phantomAttackedByCrystalDamage = (float) getDouble("mobs.phantom.attacked-by-crystal-damage", phantomAttackedByCrystalDamage);
phantomOrbitCrystalRadius = getDouble("mobs.phantom.orbit-crystal-radius", phantomOrbitCrystalRadius);
@@ -471,40 +688,184 @@ public class PurpurWorldConfig {
@@ -469,42 +687,187 @@ public class PurpurWorldConfig {
phantomBurnInLight = getInt("mobs.phantom.burn-in-light", phantomBurnInLight);
phantomBurnInDaylight = getBoolean("mobs.phantom.burn-in-daylight", phantomBurnInDaylight);
phantomIgnorePlayersWithTorch = getBoolean("mobs.phantom.ignore-players-with-torch", phantomIgnorePlayersWithTorch);
+ phantomAllowGriefing = getBoolean("mobs.phantom.allow-griefing", phantomAllowGriefing);
}
+ public boolean pigRidable = false;
@@ -5601,7 +5608,7 @@ index 637cac2758a44e72794953b9fbca2accb7d86b6a..3d3505f538510fbef4a7d584fa5f03c4
public int villagerBrainTicks = 1;
public boolean villagerUseBrainTicksOnlyWhenLagging = true;
public boolean villagerCanBeLeashed = false;
@@ -514,6 +875,8 @@ public class PurpurWorldConfig {
@@ -514,6 +877,8 @@ public class PurpurWorldConfig {
public int villagerSpawnIronGolemLimit = 0;
public boolean villagerCanBreed = true;
private void villagerSettings() {
@@ -5610,7 +5617,7 @@ index 637cac2758a44e72794953b9fbca2accb7d86b6a..3d3505f538510fbef4a7d584fa5f03c4
villagerBrainTicks = getInt("mobs.villager.brain-ticks", villagerBrainTicks);
villagerUseBrainTicksOnlyWhenLagging = getBoolean("mobs.villager.use-brain-ticks-only-when-lagging", villagerUseBrainTicksOnlyWhenLagging);
villagerCanBeLeashed = getBoolean("mobs.villager.can-be-leashed", villagerCanBeLeashed);
@@ -524,45 +887,108 @@ public class PurpurWorldConfig {
@@ -524,45 +889,108 @@ public class PurpurWorldConfig {
villagerCanBreed = getBoolean("mobs.villager.can-breed", villagerCanBreed);
}
@@ -6217,15 +6224,16 @@ index 0000000000000000000000000000000000000000..a01524c6abaec13d7249d7aba6da9e4b
+}
diff --git a/src/main/java/net/pl3x/purpur/entity/PhantomFlames.java b/src/main/java/net/pl3x/purpur/entity/PhantomFlames.java
new file mode 100644
index 0000000000000000000000000000000000000000..3059078c37deb35fcd20e27767f9b79503802cf4
index 0000000000000000000000000000000000000000..9a9e46d7ee247f9e43ae5c697f10e4665fd6e4e6
--- /dev/null
+++ b/src/main/java/net/pl3x/purpur/entity/PhantomFlames.java
@@ -0,0 +1,128 @@
@@ -0,0 +1,140 @@
+package net.pl3x.purpur.entity;
+
+import net.minecraft.server.BlockBase;
+import net.minecraft.server.DamageSource;
+import net.minecraft.server.Entity;
+import net.minecraft.server.EntityArmorStand;
+import net.minecraft.server.EntityLiving;
+import net.minecraft.server.EntityLlamaSpit;
+import net.minecraft.server.EntityPhantom;
@@ -6245,6 +6253,7 @@ index 0000000000000000000000000000000000000000..3059078c37deb35fcd20e27767f9b795
+public class PhantomFlames extends EntityLlamaSpit {
+ public EntityPhantom phantom;
+ public int ticksLived;
+ public boolean canGrief = false;
+
+ public PhantomFlames(EntityTypes<? extends EntityLlamaSpit> entitytypes, World world) {
+ super(entitytypes, world);
@@ -6285,6 +6294,10 @@ index 0000000000000000000000000000000000000000..3059078c37deb35fcd20e27767f9b795
+ onHit(hitResult);
+ }
+
+ if (dead) {
+ return;
+ }
+
+ double x = this.locX() + mot.x;
+ double y = this.locY() + mot.y;
+ double z = this.locZ() + mot.z;
@@ -6336,16 +6349,22 @@ index 0000000000000000000000000000000000000000..3059078c37deb35fcd20e27767f9b795
+ protected void onHit(MovingObjectPositionEntity rayTrace) {
+ Entity shooter = getShooter();
+ if (shooter instanceof EntityLiving) {
+ rayTrace.getEntity().damageEntity(DamageSource.indirectMobAttack(this, (EntityLiving) shooter).setProjectile(), world.purpurConfig.phantomFlameDamage);
+ if (world.purpurConfig.phantomFlameFireTime > 0) {
+ rayTrace.getEntity().setOnFire(world.purpurConfig.phantomFlameFireTime);
+ Entity target = rayTrace.getEntity();
+ if (canGrief || (target instanceof EntityLiving && !(target instanceof EntityArmorStand))) {
+ target.damageEntity(DamageSource.indirectMobAttack(this, (EntityLiving) shooter).setProjectile(), world.purpurConfig.phantomFlameDamage);
+ if (world.purpurConfig.phantomFlameFireTime > 0) {
+ target.setOnFire(world.purpurConfig.phantomFlameFireTime);
+ }
+ }
+ }
+ die();
+ }
+
+ protected void onHit(MovingObjectPositionBlock rayTrace) {
+ IBlockData iblockdata = world.getType(rayTrace.getBlockPosition());
+ iblockdata.a(world, iblockdata, rayTrace, this);
+ if (canGrief) {
+ IBlockData iblockdata = world.getType(rayTrace.getBlockPosition());
+ iblockdata.a(world, iblockdata, rayTrace, this);
+ }
+ die();
+ }
+}