aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch')
-rw-r--r--patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch271
1 files changed, 271 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch
new file mode 100644
index 0000000000..c726efdf25
--- /dev/null
+++ b/patch-remap/mache-vineflower/net/minecraft/world/entity/monster/SpellcasterIllager.java.patch
@@ -0,0 +1,271 @@
+--- a/net/minecraft/world/entity/monster/SpellcasterIllager.java
++++ b/net/minecraft/world/entity/monster/SpellcasterIllager.java
+@@ -15,20 +15,25 @@
+ import net.minecraft.world.entity.LivingEntity;
+ import net.minecraft.world.entity.ai.goal.Goal;
+ import net.minecraft.world.level.Level;
++// CraftBukkit start
++import org.bukkit.craftbukkit.event.CraftEventFactory;
++// CraftBukkit end
+
+ public abstract class SpellcasterIllager extends AbstractIllager {
++
+ private static final EntityDataAccessor<Byte> DATA_SPELL_CASTING_ID = SynchedEntityData.defineId(SpellcasterIllager.class, EntityDataSerializers.BYTE);
+ protected int spellCastingTickCount;
+- private SpellcasterIllager.IllagerSpell currentSpell = SpellcasterIllager.IllagerSpell.NONE;
++ private SpellcasterIllager.IllagerSpell currentSpell;
+
+ protected SpellcasterIllager(EntityType<? extends SpellcasterIllager> entityType, Level level) {
+ super(entityType, level);
++ this.currentSpell = SpellcasterIllager.IllagerSpell.NONE;
+ }
+
+ @Override
+ protected void defineSynchedData() {
+ super.defineSynchedData();
+- this.entityData.define(DATA_SPELL_CASTING_ID, (byte)0);
++ this.entityData.define(SpellcasterIllager.DATA_SPELL_CASTING_ID, (byte) 0);
+ }
+
+ @Override
+@@ -44,51 +49,48 @@
+ }
+
+ @Override
+- public AbstractIllager.IllagerArmPose getArmPose() {
+- if (this.isCastingSpell()) {
+- return AbstractIllager.IllagerArmPose.SPELLCASTING;
+- } else {
+- return this.isCelebrating() ? AbstractIllager.IllagerArmPose.CELEBRATING : AbstractIllager.IllagerArmPose.CROSSED;
+- }
++ public AbstractIllager.a getArmPose() {
++ return this.isCastingSpell() ? AbstractIllager.a.SPELLCASTING : (this.isCelebrating() ? AbstractIllager.a.CELEBRATING : AbstractIllager.a.CROSSED);
+ }
+
+ public boolean isCastingSpell() {
+- return this.level().isClientSide ? this.entityData.get(DATA_SPELL_CASTING_ID) > 0 : this.spellCastingTickCount > 0;
++ return this.level().isClientSide ? (Byte) this.entityData.get(SpellcasterIllager.DATA_SPELL_CASTING_ID) > 0 : this.spellCastingTickCount > 0;
+ }
+
+ public void setIsCastingSpell(SpellcasterIllager.IllagerSpell currentSpell) {
+ this.currentSpell = currentSpell;
+- this.entityData.set(DATA_SPELL_CASTING_ID, (byte)currentSpell.id);
++ this.entityData.set(SpellcasterIllager.DATA_SPELL_CASTING_ID, (byte) currentSpell.id);
+ }
+
+- protected SpellcasterIllager.IllagerSpell getCurrentSpell() {
+- return !this.level().isClientSide ? this.currentSpell : SpellcasterIllager.IllagerSpell.byId(this.entityData.get(DATA_SPELL_CASTING_ID));
++ public SpellcasterIllager.IllagerSpell getCurrentSpell() {
++ return !this.level().isClientSide ? this.currentSpell : SpellcasterIllager.IllagerSpell.byId((Byte) this.entityData.get(SpellcasterIllager.DATA_SPELL_CASTING_ID));
+ }
+
+ @Override
+ protected void customServerAiStep() {
+ super.customServerAiStep();
+ if (this.spellCastingTickCount > 0) {
+- this.spellCastingTickCount--;
++ --this.spellCastingTickCount;
+ }
++
+ }
+
+ @Override
+ public void tick() {
+ super.tick();
+ if (this.level().isClientSide && this.isCastingSpell()) {
+- SpellcasterIllager.IllagerSpell currentSpell = this.getCurrentSpell();
+- double d = currentSpell.spellColor[0];
+- double d1 = currentSpell.spellColor[1];
+- double d2 = currentSpell.spellColor[2];
+- float f = this.yBodyRot * (float) (Math.PI / 180.0) + Mth.cos((float)this.tickCount * 0.6662F) * 0.25F;
+- float cos = Mth.cos(f);
+- float sin = Mth.sin(f);
+- this.level()
+- .addParticle(ParticleTypes.ENTITY_EFFECT, this.getX() + (double)cos * 0.6, this.getY() + 1.8, this.getZ() + (double)sin * 0.6, d, d1, d2);
+- this.level()
+- .addParticle(ParticleTypes.ENTITY_EFFECT, this.getX() - (double)cos * 0.6, this.getY() + 1.8, this.getZ() - (double)sin * 0.6, d, d1, d2);
++ SpellcasterIllager.IllagerSpell entityillagerwizard_spell = this.getCurrentSpell();
++ double d0 = entityillagerwizard_spell.spellColor[0];
++ double d1 = entityillagerwizard_spell.spellColor[1];
++ double d2 = entityillagerwizard_spell.spellColor[2];
++ float f = this.yBodyRot * 0.017453292F + Mth.cos((float) this.tickCount * 0.6662F) * 0.25F;
++ float f1 = Mth.cos(f);
++ float f2 = Mth.sin(f);
++
++ this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getX() + (double) f1 * 0.6D, this.getY() + 1.8D, this.getZ() + (double) f2 * 0.6D, d0, d1, d2);
++ this.level().addParticle(ParticleTypes.ENTITY_EFFECT, this.getX() - (double) f1 * 0.6D, this.getY() + 1.8D, this.getZ() - (double) f2 * 0.6D, d0, d1, d2);
+ }
++
+ }
+
+ protected int getSpellCastingTime() {
+@@ -97,80 +99,45 @@
+
+ protected abstract SoundEvent getCastingSoundEvent();
+
+- protected static enum IllagerSpell {
+- NONE(0, 0.0, 0.0, 0.0),
+- SUMMON_VEX(1, 0.7, 0.7, 0.8),
+- FANGS(2, 0.4, 0.3, 0.35),
+- WOLOLO(3, 0.7, 0.5, 0.2),
+- DISAPPEAR(4, 0.3, 0.3, 0.8),
+- BLINDNESS(5, 0.1, 0.1, 0.2);
++ public static enum IllagerSpell {
+
+- private static final IntFunction<SpellcasterIllager.IllagerSpell> BY_ID = ByIdMap.continuous(
+- illagerSpell -> illagerSpell.id, values(), ByIdMap.OutOfBoundsStrategy.ZERO
+- );
++ NONE(0, 0.0D, 0.0D, 0.0D), SUMMON_VEX(1, 0.7D, 0.7D, 0.8D), FANGS(2, 0.4D, 0.3D, 0.35D), WOLOLO(3, 0.7D, 0.5D, 0.2D), DISAPPEAR(4, 0.3D, 0.3D, 0.8D), BLINDNESS(5, 0.1D, 0.1D, 0.2D);
++
++ private static final IntFunction<SpellcasterIllager.IllagerSpell> BY_ID = ByIdMap.continuous((entityillagerwizard_spell) -> {
++ return entityillagerwizard_spell.id;
++ }, values(), ByIdMap.a.ZERO);
+ final int id;
+ final double[] spellColor;
+
+- private IllagerSpell(int id, double red, double green, double blue) {
+- this.id = id;
+- this.spellColor = new double[]{red, green, blue};
++ private IllagerSpell(int i, double d0, double d1, double d2) {
++ this.id = i;
++ this.spellColor = new double[]{d0, d1, d2};
+ }
+
+ public static SpellcasterIllager.IllagerSpell byId(int id) {
+- return BY_ID.apply(id);
++ return (SpellcasterIllager.IllagerSpell) SpellcasterIllager.IllagerSpell.BY_ID.apply(id);
+ }
+ }
+
+- protected class SpellcasterCastingSpellGoal extends Goal {
+- public SpellcasterCastingSpellGoal() {
+- this.setFlags(EnumSet.of(Goal.Flag.MOVE, Goal.Flag.LOOK));
+- }
+-
+- @Override
+- public boolean canUse() {
+- return SpellcasterIllager.this.getSpellCastingTime() > 0;
+- }
+-
+- @Override
+- public void start() {
+- super.start();
+- SpellcasterIllager.this.navigation.stop();
+- }
+-
+- @Override
+- public void stop() {
+- super.stop();
+- SpellcasterIllager.this.setIsCastingSpell(SpellcasterIllager.IllagerSpell.NONE);
+- }
+-
+- @Override
+- public void tick() {
+- if (SpellcasterIllager.this.getTarget() != null) {
+- SpellcasterIllager.this.getLookControl()
+- .setLookAt(
+- SpellcasterIllager.this.getTarget(), (float)SpellcasterIllager.this.getMaxHeadYRot(), (float)SpellcasterIllager.this.getMaxHeadXRot()
+- );
+- }
+- }
+- }
+-
+ protected abstract class SpellcasterUseSpellGoal extends Goal {
++
+ protected int attackWarmupDelay;
+ protected int nextAttackTickCount;
+
++ protected SpellcasterUseSpellGoal() {}
++
+ @Override
+ public boolean canUse() {
+- LivingEntity target = SpellcasterIllager.this.getTarget();
+- return target != null
+- && target.isAlive()
+- && !SpellcasterIllager.this.isCastingSpell()
+- && SpellcasterIllager.this.tickCount >= this.nextAttackTickCount;
++ LivingEntity entityliving = SpellcasterIllager.this.getTarget();
++
++ return entityliving != null && entityliving.isAlive() ? (SpellcasterIllager.this.isCastingSpell() ? false : SpellcasterIllager.this.tickCount >= this.nextAttackTickCount) : false;
+ }
+
+ @Override
+ public boolean canContinueToUse() {
+- LivingEntity target = SpellcasterIllager.this.getTarget();
+- return target != null && target.isAlive() && this.attackWarmupDelay > 0;
++ LivingEntity entityliving = SpellcasterIllager.this.getTarget();
++
++ return entityliving != null && entityliving.isAlive() && this.attackWarmupDelay > 0;
+ }
+
+ @Override
+@@ -178,9 +145,10 @@
+ this.attackWarmupDelay = this.adjustedTickDelay(this.getCastWarmupTime());
+ SpellcasterIllager.this.spellCastingTickCount = this.getCastingTime();
+ this.nextAttackTickCount = SpellcasterIllager.this.tickCount + this.getCastingInterval();
+- SoundEvent spellPrepareSound = this.getSpellPrepareSound();
+- if (spellPrepareSound != null) {
+- SpellcasterIllager.this.playSound(spellPrepareSound, 1.0F, 1.0F);
++ SoundEvent soundeffect = this.getSpellPrepareSound();
++
++ if (soundeffect != null) {
++ SpellcasterIllager.this.playSound(soundeffect, 1.0F, 1.0F);
+ }
+
+ SpellcasterIllager.this.setIsCastingSpell(this.getSpell());
+@@ -188,11 +156,17 @@
+
+ @Override
+ public void tick() {
+- this.attackWarmupDelay--;
++ --this.attackWarmupDelay;
+ if (this.attackWarmupDelay == 0) {
++ // CraftBukkit start
++ if (!CraftEventFactory.handleEntitySpellCastEvent(SpellcasterIllager.this, this.getSpell())) {
++ return;
++ }
++ // CraftBukkit end
+ this.performSpellCasting();
+ SpellcasterIllager.this.playSound(SpellcasterIllager.this.getCastingSoundEvent(), 1.0F, 1.0F);
+ }
++
+ }
+
+ protected abstract void performSpellCasting();
+@@ -210,4 +184,36 @@
+
+ protected abstract SpellcasterIllager.IllagerSpell getSpell();
+ }
++
++ protected class SpellcasterCastingSpellGoal extends Goal {
++
++ public SpellcasterCastingSpellGoal() {
++ this.setFlags(EnumSet.of(Goal.Type.MOVE, Goal.Type.LOOK));
++ }
++
++ @Override
++ public boolean canUse() {
++ return SpellcasterIllager.this.getSpellCastingTime() > 0;
++ }
++
++ @Override
++ public void start() {
++ super.start();
++ SpellcasterIllager.this.navigation.stop();
++ }
++
++ @Override
++ public void stop() {
++ super.stop();
++ SpellcasterIllager.this.setIsCastingSpell(SpellcasterIllager.IllagerSpell.NONE);
++ }
++
++ @Override
++ public void tick() {
++ if (SpellcasterIllager.this.getTarget() != null) {
++ SpellcasterIllager.this.getLookControl().setLookAt(SpellcasterIllager.this.getTarget(), (float) SpellcasterIllager.this.getMaxHeadYRot(), (float) SpellcasterIllager.this.getMaxHeadXRot());
++ }
++
++ }
++ }
+ }