mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 08:27:43 +01:00
83 lines
4.0 KiB
Diff
83 lines
4.0 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <blake.galbreath@gmail.com>
|
|
Date: Sun, 12 Apr 2020 13:19:34 -0500
|
|
Subject: [PATCH] |FEAT| Chickens can retaliate
|
|
|
|
Chickens will fight back if you attack them.
|
|
|
|
$-----------------------------$
|
|
mobs:
|
|
chicken:
|
|
retaliate:
|
|
default: false
|
|
description: |-
|
|
Fights back if it gets attacked
|
|
$-----------------------------$
|
|
|
|
diff --git a/src/main/java/net/minecraft/world/entity/animal/Chicken.java b/src/main/java/net/minecraft/world/entity/animal/Chicken.java
|
|
index 9fe68301b9a6efd703fb9d2215a9cd3b2f017a4e..35cf6b9fb4d72df905d93bf52c02846b21b04007 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/animal/Chicken.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/animal/Chicken.java
|
|
@@ -66,6 +66,9 @@ public class Chicken extends Animal {
|
|
@Override
|
|
public void initAttributes() {
|
|
this.getAttribute(Attributes.MAX_HEALTH).setBaseValue(this.level.purpurConfig.chickenMaxHealth);
|
|
+ if (level.purpurConfig.chickenRetaliate) {
|
|
+ this.getAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(2.0D);
|
|
+ }
|
|
}
|
|
// Purpur end
|
|
|
|
@@ -73,13 +76,21 @@ public class Chicken extends Animal {
|
|
protected void registerGoals() {
|
|
this.goalSelector.addGoal(0, new FloatGoal(this));
|
|
this.goalSelector.addGoal(0, new net.pl3x.purpur.entity.ai.HasRider(this)); // Purpur
|
|
- this.goalSelector.addGoal(1, new PanicGoal(this, 1.4D));
|
|
+ // this.goalSelector.addGoal(1, new PanicGoal(this, 1.4D)); // Purpur - moved down
|
|
this.goalSelector.addGoal(2, new BreedGoal(this, 1.0D));
|
|
this.goalSelector.addGoal(3, new TemptGoal(this, 1.0D, Chicken.FOOD_ITEMS, false));
|
|
this.goalSelector.addGoal(4, new FollowParentGoal(this, 1.1D));
|
|
this.goalSelector.addGoal(5, new WaterAvoidingRandomStrollGoal(this, 1.0D));
|
|
this.goalSelector.addGoal(6, new LookAtPlayerGoal(this, Player.class, 6.0F));
|
|
this.goalSelector.addGoal(7, new RandomLookAroundGoal(this));
|
|
+ // Purpur start
|
|
+ if (level.purpurConfig.chickenRetaliate) {
|
|
+ this.goalSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.MeleeAttackGoal(this, 1.0D, false));
|
|
+ this.targetSelector.addGoal(1, new net.minecraft.world.entity.ai.goal.target.HurtByTargetGoal(this));
|
|
+ } else {
|
|
+ this.goalSelector.addGoal(1, new PanicGoal(this, 1.4D));
|
|
+ }
|
|
+ // Purpur end
|
|
}
|
|
|
|
@Override
|
|
@@ -88,7 +99,7 @@ public class Chicken extends Animal {
|
|
}
|
|
|
|
public static AttributeSupplier.Builder createAttributes() {
|
|
- return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 4.0D).add(Attributes.MOVEMENT_SPEED, 0.25D);
|
|
+ return Mob.createMobAttributes().add(Attributes.MAX_HEALTH, 4.0D).add(Attributes.MOVEMENT_SPEED, 0.25D).add(Attributes.ATTACK_DAMAGE, 0.0D); // Purpur
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
index 241ba6a10eda5bf97adb09cc2ae423da6036d55f..8692ca2751ba6ed6ad989843261b13d2eeba669e 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurWorldConfig.java
|
|
@@ -250,6 +250,7 @@ public class PurpurWorldConfig {
|
|
public boolean chickenRidable = false;
|
|
public boolean chickenRidableInWater = false;
|
|
public double chickenMaxHealth = 4.0D;
|
|
+ public boolean chickenRetaliate = false;
|
|
private void chickenSettings() {
|
|
chickenRidable = getBoolean("mobs.chicken.ridable", chickenRidable);
|
|
chickenRidableInWater = getBoolean("mobs.chicken.ridable-in-water", chickenRidableInWater);
|
|
@@ -259,6 +260,7 @@ public class PurpurWorldConfig {
|
|
set("mobs.chicken.attributes.max_health", oldValue);
|
|
}
|
|
chickenMaxHealth = getDouble("mobs.chicken.attributes.max_health", chickenMaxHealth);
|
|
+ chickenRetaliate = getBoolean("mobs.chicken.retaliate", chickenRetaliate);
|
|
}
|
|
|
|
public boolean codRidable = false;
|