mirror of
https://github.com/Dreeam-qwq/Gale.git
synced 2026-01-04 15:31:45 +00:00
96 lines
7.3 KiB
Diff
96 lines
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Martijn Muijsers <martijnmuijsers@live.nl>
|
|
Date: Thu, 1 Dec 2022 00:37:50 +0100
|
|
Subject: [PATCH] Cache ominous banner item
|
|
|
|
License: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
Gale - https://galemc.org
|
|
|
|
This patch is based on the following mixin:
|
|
"me/jellysquid/mods/lithium/mixin/ai/raid/RaiderEntityMixin.java"
|
|
By: 2No2Name <2No2Name@web.de>
|
|
As part of: Lithium (https://github.com/CaffeineMC/lithium-fabric)
|
|
Licensed under: LGPL-3.0 (https://www.gnu.org/licenses/lgpl-3.0.html)
|
|
|
|
diff --git a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
|
index f4e5ada556a7fc7adac9b8d3e75ace483f753782..14b0fb4a1d7bc752fc041dbc850ad457a24c939a 100644
|
|
--- a/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
|
+++ b/src/main/java/net/minecraft/advancements/critereon/EntityEquipmentPredicate.java
|
|
@@ -15,7 +15,7 @@ public record EntityEquipmentPredicate(Optional<ItemPredicate> head, Optional<It
|
|
public static final Codec<EntityEquipmentPredicate> CODEC = RecordCodecBuilder.create((instance) -> {
|
|
return instance.group(ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "head").forGetter(EntityEquipmentPredicate::head), ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "chest").forGetter(EntityEquipmentPredicate::chest), ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "legs").forGetter(EntityEquipmentPredicate::legs), ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "feet").forGetter(EntityEquipmentPredicate::feet), ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "mainhand").forGetter(EntityEquipmentPredicate::mainhand), ExtraCodecs.strictOptionalField(ItemPredicate.CODEC, "offhand").forGetter(EntityEquipmentPredicate::offhand)).apply(instance, EntityEquipmentPredicate::new);
|
|
});
|
|
- public static final EntityEquipmentPredicate CAPTAIN = EntityEquipmentPredicate.Builder.equipment().head(ItemPredicate.Builder.item().of(Items.WHITE_BANNER).hasNbt(Raid.getLeaderBannerInstance().getTag())).build();
|
|
+ public static final EntityEquipmentPredicate CAPTAIN = EntityEquipmentPredicate.Builder.equipment().head(ItemPredicate.Builder.item().of(Items.WHITE_BANNER).hasNbt(Raid.LEADER_BANNER.getTag())).build(); // Gale - Lithium - cache ominous banner item
|
|
|
|
public boolean matches(@Nullable Entity entity) {
|
|
if (entity instanceof LivingEntity livingEntity) {
|
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raid.java b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
index 5a0a6de4c6f0d554b9efbb8b3dcf4e0c5bee7baf..ea0df00966cf9900a8a0153099bbb04e5b47116d 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raid.java
|
|
@@ -706,7 +706,7 @@ public class Raid {
|
|
this.level.getRaids().setDirty();
|
|
}
|
|
|
|
- public static ItemStack getLeaderBannerInstance() {
|
|
+ private static ItemStack createLeaderBanner() { // Gale - Lithium - cache ominous banner item
|
|
ItemStack itemstack = new ItemStack(Items.WHITE_BANNER);
|
|
CompoundTag nbttagcompound = new CompoundTag();
|
|
ListTag nbttaglist = (new BannerPattern.Builder()).addPattern(BannerPatterns.RHOMBUS_MIDDLE, DyeColor.CYAN).addPattern(BannerPatterns.STRIPE_BOTTOM, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_CENTER, DyeColor.GRAY).addPattern(BannerPatterns.BORDER, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.STRIPE_MIDDLE, DyeColor.BLACK).addPattern(BannerPatterns.HALF_HORIZONTAL, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.CIRCLE_MIDDLE, DyeColor.LIGHT_GRAY).addPattern(BannerPatterns.BORDER, DyeColor.BLACK).toListTag();
|
|
@@ -718,6 +718,14 @@ public class Raid {
|
|
return itemstack;
|
|
}
|
|
|
|
+ // Gale start - Lithium - cache ominous banner item
|
|
+ public static final ItemStack LEADER_BANNER = createLeaderBanner();
|
|
+
|
|
+ public static ItemStack getLeaderBannerInstance() {
|
|
+ return LEADER_BANNER.copy();
|
|
+ }
|
|
+ // Gale end - Lithium - cache ominous banner item
|
|
+
|
|
@Nullable
|
|
public Raider getLeader(int wave) {
|
|
return (Raider) this.groupToLeaderMap.get(wave);
|
|
diff --git a/src/main/java/net/minecraft/world/entity/raid/Raider.java b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
|
index cdbc925ef61b8b439415f0a89368227890bcecb2..8a467b21867c4c624bbefd0aef5cc14d40391ca2 100644
|
|
--- a/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
|
+++ b/src/main/java/net/minecraft/world/entity/raid/Raider.java
|
|
@@ -47,7 +47,7 @@ public abstract class Raider extends PatrollingMonster {
|
|
|
|
protected static final EntityDataAccessor<Boolean> IS_CELEBRATING = SynchedEntityData.defineId(Raider.class, EntityDataSerializers.BOOLEAN);
|
|
static final Predicate<ItemEntity> ALLOWED_ITEMS = (entityitem) -> {
|
|
- return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.getLeaderBannerInstance());
|
|
+ return !entityitem.hasPickUpDelay() && entityitem.isAlive() && ItemStack.matches(entityitem.getItem(), Raid.LEADER_BANNER); // Gale - Lithium - cache ominous banner item
|
|
};
|
|
@Nullable
|
|
protected Raid raid;
|
|
@@ -149,7 +149,7 @@ public abstract class Raider extends PatrollingMonster {
|
|
}
|
|
}
|
|
|
|
- if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance()) && entityhuman != null) {
|
|
+ if (!itemstack.isEmpty() && ItemStack.matches(itemstack, Raid.LEADER_BANNER) && entityhuman != null) { // Gale - Lithium - cache ominous banner item
|
|
MobEffectInstance mobeffect = entityhuman.getEffect(MobEffects.BAD_OMEN);
|
|
byte b0 = 1;
|
|
int i;
|
|
@@ -244,7 +244,7 @@ public abstract class Raider extends PatrollingMonster {
|
|
ItemStack itemstack = item.getItem();
|
|
boolean flag = this.hasActiveRaid() && this.getCurrentRaid().getLeader(this.getWave()) != null;
|
|
|
|
- if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.getLeaderBannerInstance())) {
|
|
+ if (this.hasActiveRaid() && !flag && ItemStack.matches(itemstack, Raid.LEADER_BANNER)) { // Gale - Lithium - cache ominous banner item
|
|
// Paper start
|
|
if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityPickupItemEvent(this, item, 0, false).isCancelled()) {
|
|
return;
|
|
@@ -322,7 +322,7 @@ public abstract class Raider extends PatrollingMonster {
|
|
if (!this.mob.level().getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING) || !this.mob.canPickUpLoot()) return false; // Paper - respect game and entity rules for picking up items
|
|
Raid raid = this.mob.getCurrentRaid();
|
|
|
|
- if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.getLeaderBannerInstance())) {
|
|
+ if (this.mob.hasActiveRaid() && !this.mob.getCurrentRaid().isOver() && this.mob.canBeLeader() && !ItemStack.matches(this.mob.getItemBySlot(EquipmentSlot.HEAD), Raid.LEADER_BANNER)) { // Gale - Lithium - cache ominous banner item
|
|
Raider entityraider = raid.getLeader(this.mob.getWave());
|
|
|
|
if (entityraider == null || !entityraider.isAlive()) {
|