Skip to content

Commit

Permalink
1.21.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MATRIX-feather committed Jan 14, 2025
1 parent 610f168 commit e20d4f4
Show file tree
Hide file tree
Showing 21 changed files with 66 additions and 203 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
project_version=1.5.0.rc4
project_version=1.3.5

# FM Protocols
protocols_version=b15c1841
protocols_use_local_build=false
protocols_local_version=1.1.5

mc_version=1.21.4
minecraft_version=1.21.4-R0.1-SNAPSHOT
mc_version=1.21.1
minecraft_version=1.21.1-R0.1-SNAPSHOT

# Dependencies
protocollib_version=5.3.0
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/xyz/nifeather/morph/FeatherMorphMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected void enable()
pluginManager = Bukkit.getPluginManager();
var bukkitVersion = Bukkit.getMinecraftVersion();

String primaryVersion = "1.21.4";
String primaryVersion = "1.21.1";
String[] compatVersions = new String[] { primaryVersion };
if (Arrays.stream(compatVersions).noneMatch(bukkitVersion::equals))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public boolean handle(Player player, DisguiseState state)
if (playerGameMode == GameMode.SPECTATOR)
playersToShow.removeIf(p -> p.getGameMode() != playerGameMode);

bossbar.progress((float) (player.getHealth() / player.getAttribute(Attribute.MAX_HEALTH).getValue()));
bossbar.progress((float) (player.getHealth() / player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()));
//bossbar.name(this.getBossbarName(state, option));

if (state.canDisplayBossbar())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public List<Packet<?>> buildPlayerInfoPackets(SingleWatcher watcher)
spawnUUID, watcher.readEntryOrThrow(CustomEntries.PROFILE),
watcher.readEntryOrDefault(CustomEntries.PROFILE_LISTED, false),
114514, GameType.DEFAULT_MODE,
null, true, 0, null
null, null
)
);

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ else if (packetType == PacketType.Play.Server.ENTITY_TELEPORT)
private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent event)
{
//获取此包的来源实体
var sourceNmsEntity = getNmsPlayerFrom(packet.id());
var sourceNmsEntity = getNmsPlayerFrom(packet.getId());
if (sourceNmsEntity == null)
return;

Expand All @@ -83,15 +83,21 @@ private void onTeleport(ClientboundTeleportEntityPacket packet, PacketEvent even
if (!isDragon && !isPhantom)
return;

float yaw = packet.change().yRot();
float pitch = packet.change().xRot();
var yaw = packet.getyRot();
var pitch = packet.getxRot();

yaw = isDragon ? (yaw + 180f) : yaw;
pitch = isPhantom ? -pitch : pitch;
var playerYaw = isDragon ? (sourcePlayer.getYaw() + 180f) : sourcePlayer.getYaw();
var finalYaw = (playerYaw / 360f) * 256f;
yaw = (byte)finalYaw;

var playerPitch = isPhantom ? -sourcePlayer.getPitch() : sourcePlayer.getPitch();

var finalPitch = (playerPitch / 360f) * 256f;
pitch = (byte)finalPitch;

var container = event.getPacket();
container.getBytes().write(0, Mth.packDegrees(yaw));
container.getBytes().write(1, Mth.packDegrees(pitch));
container.getBytes().write(0, yaw);
container.getBytes().write(1, pitch);
}

private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent event)
Expand All @@ -107,9 +113,9 @@ private void onHeadRotation(ClientboundRotateHeadPacket packet, PacketEvent even
if (watcher == null || watcher.getEntityType() != EntityType.ENDER_DRAGON)
return;

var newHeadYaw = packet.getYHeadRot() + 180f;
var newHeadYaw = (byte)(((sourcePlayer.getYaw() + 180f) / 360f) * 256f);

var newPacket = new ClientboundRotateHeadPacket(sourceNmsEntity, Mth.packDegrees(newHeadYaw));
var newPacket = new ClientboundRotateHeadPacket(sourceNmsEntity, newHeadYaw);
var finalPacket = PacketContainer.fromPacket(newPacket);
getFactory().markPacketOurs(finalPacket);

Expand All @@ -136,11 +142,17 @@ private void onLookPacket(ClientboundMoveEntityPacket packet, PacketEvent event)
if (!isDragon && !isPhantom)
return;

float yaw = packet.getyRot();
float pitch = packet.getxRot();
var yaw = packet.getyRot();
var pitch = packet.getxRot();

var playerYaw = isDragon ? (sourcePlayer.getYaw() + 180f) : sourcePlayer.getYaw();
var finalYaw = (playerYaw / 360f) * 256f;
yaw = (byte)finalYaw;

var playerPitch = isPhantom ? -sourcePlayer.getPitch() : sourcePlayer.getPitch();

yaw = isDragon ? (yaw + 180f) : yaw;
pitch = isPhantom ? -pitch : pitch;
var finalPitch = (playerPitch / 360f) * 256f;
pitch = (byte)finalPitch;

ClientboundMoveEntityPacket newPacket;

Expand All @@ -150,7 +162,7 @@ private void onLookPacket(ClientboundMoveEntityPacket packet, PacketEvent event)
{
newPacket = new ClientboundMoveEntityPacket.Rot(
sourcePlayer.getEntityId(),
Mth.packDegrees(yaw), Mth.packDegrees(pitch),
yaw, pitch,
packet.isOnGround()
);
}
Expand All @@ -167,7 +179,7 @@ else if (packetType == PacketType.Play.Server.REL_ENTITY_MOVE_LOOK)
newPacket = new ClientboundMoveEntityPacket.PosRot(
sourcePlayer.getEntityId(),
packet.getXa(), packet.getYa(), packet.getZa(),
Mth.packDegrees(yaw), Mth.packDegrees(pitch),
yaw, pitch,
packet.isOnGround()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private ClientboundSoundPacket getClientboundSoundPacket(PacketEvent event, Pack
// 获取正要播放的音效
AtomicReference<ResourceLocation> resourceLocationRef = new AtomicReference<>(null);
left.ifPresent(rK -> resourceLocationRef.set(rK.location()));
right.ifPresent(se -> resourceLocationRef.set(se.location()));
right.ifPresent(se -> resourceLocationRef.set(se.getLocation()));

if (resourceLocationRef.get() == null) return null;
SoundEvent sound = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public WatcherIndex()
setTypeWatcher(EntityType.ARMADILLO, ArmadilloWatcher::new);
setTypeWatcher(EntityType.SHULKER, ShulkerWatcher::new);
setTypeWatcher(EntityType.PUFFERFISH, PufferfishWatcher::new);

setTypeWatcher(EntityType.CREAKING, CreakingWatcher::new);
}

private void setTypeWatcher(EntityType type, Function<Player, SingleWatcher> func)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private static <T> Registry<T> lookupRegistryOrThrow(ResourceKey<Registry<T>> re
{
setupLevel();

return level.registryAccess().lookup(registryKey).orElseThrow();
return level.registryAccess().registryOrThrow(registryKey);
}

public static <T> Holder<T> getHolderOrThrow(ResourceLocation location, ResourceKey<Registry<T>> registryKey)
Expand All @@ -35,7 +35,7 @@ public static <T> Holder<T> getHolderOrThrow(ResourceLocation location, Resource

var registry = lookupRegistryOrThrow(registryKey);

var ref = registry.get(location).orElse(null);
var ref = registry.getHolder(location).orElse(null);
if (ref == null)
throw new NullPointerException("Reference for key '%s' does not found in the registry '%s'.".formatted(location, registry.key()));

Expand All @@ -51,7 +51,7 @@ public static <T> Holder<T> getHolderOrThrow(ResourceKey<T> key, ResourceKey<Reg

var registry = lookupRegistryOrThrow(registryKey);

var ref = registry.get(key).orElse(null);
var ref = registry.getHolder(key).orElse(null);
if (ref == null)
throw new NullPointerException("Reference for key '%s' does not found in the registry '%s'.".formatted(key, registry.key()));

Expand Down
18 changes: 0 additions & 18 deletions src/main/java/xyz/nifeather/morph/events/CommonEventProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.type.CreakingHeart;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -627,23 +626,6 @@ else if (revealingLevel == RevealingHandler.RevealingLevel.SUSPECT)
e.setCancelled(e.isCancelled() || !shouldTarget);
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onAdvancement(BlockBreakEvent event)
{
var block = event.getBlock();

if (block.getType() != Material.CREAKING_HEART)
return;

if (!(block.getBlockData() instanceof CreakingHeart creakingHeart))
return;

if (!creakingHeart.isActive() || !creakingHeart.isNatural())
return;

morphs.grantMorphToPlayer(event.getPlayer(), EntityType.CREAKING.getKey().asString());
}

private void onPlayerKillEntity(Player player, Entity entity)
{
if (!(entity instanceof LivingEntity) && !(entity.getType() == EntityType.ARMOR_STAND))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void onEntityAdded(EntityAddToWorldEvent e)
addAvoidEntityGoal(goalSelector, pathfinderMob);

// 添加TargetGoal
nmsMob.goalSelector.addGoal(-1, new FeatherMorphNearestAttackableGoal(manager, nmsMob, Player.class, true, (living, world) -> true));
nmsMob.goalSelector.addGoal(-1, new FeatherMorphNearestAttackableGoal(manager, nmsMob, Player.class, true, living -> true));
}

private void addAvoidEntityGoal(GoalSelector goalSelector, PathfinderMob sourceMob)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package xyz.nifeather.morph.misc.mobs.ai;

import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.NeutralMob;
import net.minecraft.world.entity.ai.attributes.Attributes;
import net.minecraft.world.entity.ai.goal.target.NearestAttackableTargetGoal;
Expand All @@ -11,6 +12,8 @@
import xyz.nifeather.morph.MorphManager;
import xyz.nifeather.morph.utilities.EntityTypeUtils;

import java.util.function.Predicate;

/**
* 此Goal将被添加到生物,作为附加的TargetGoal执行。
*/
Expand All @@ -20,7 +23,7 @@ public class FeatherMorphNearestAttackableGoal extends NearestAttackableTargetGo

public FeatherMorphNearestAttackableGoal(MorphManager morphManager,
net.minecraft.world.entity.Mob mob, Class<Player> targetClass,
boolean checkVisibility, TargetingConditions.Selector targetPredicate)
boolean checkVisibility, Predicate<LivingEntity> targetPredicate)
{
super(mob, targetClass, checkVisibility, targetPredicate);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void showFakePlayer(UUID disguiseUUID, GameProfile profile)
disguiseUUID, profile,
true,
114514, GameType.DEFAULT_MODE,
null, true, 0, null
null, null
)
);

Expand Down Expand Up @@ -166,7 +166,7 @@ public void handle(Player player)
disguiseUUID, profile,
true,
114514, GameType.DEFAULT_MODE,
null, true, 0, null
null, null
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public VanillaAnimationProvider()
this.registerAnimSet(EntityType.FROG, new FrogAnimationSet());
this.registerAnimSet(EntityType.WOLF, new WolfAnimationSet());
this.registerAnimSet(EntityType.PANDA, new PandaAnimationSet());
this.registerAnimSet(EntityType.CREAKING, new CreakingAnimationSet());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,9 @@ private void tryAddModifier(DisguiseState state)
}

var craftLiving = (net.minecraft.world.entity.LivingEntity) ((CraftLivingEntity)living).getHandleRaw();
var mobMaxHealth = craftLiving.craftAttributes.getAttribute(Attribute.MAX_HEALTH).getBaseValue();
var mobMaxHealth = craftLiving.craftAttributes.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();

// patch: CREAKING only have half heart, and we don't want that.
if (state.getEntityType() == EntityType.CREAKING)
mobMaxHealth = 20;

var playerAttribute = player.getAttribute(Attribute.MAX_HEALTH);
var playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);

if (mobMaxHealth <= 0d)
{
Expand Down Expand Up @@ -401,7 +397,7 @@ private void executeThenScaleHealth(Player player, AttributeInstance attributeIn

private void removeAllHealthModifiers(Player player)
{
var attribute = player.getAttribute(Attribute.MAX_HEALTH);
var attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
assert attribute != null;

this.executeThenScaleHealth(player, attribute, () -> attribute.removeModifier(healthModifierKey));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,18 @@ public void generateAbilities()
this.getConfiguration(EntityType.HORSE)
.addAbilityIdentifier(AbilityType.ATTRIBUTE)
.appendOption(AbilityType.ATTRIBUTE, AttributeModifyOption
.from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, 0.5d)
.with(Attribute.STEP_HEIGHT, AttributeModifyOption.OperationType.add, 0.4d));
.from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, 0.5d)
.with(Attribute.GENERIC_STEP_HEIGHT, AttributeModifyOption.OperationType.add, 0.4d));

this.getConfiguration(EntityType.IRON_GOLEM)
.addAbilityIdentifier(AbilityType.ATTRIBUTE)
.appendOption(
AbilityType.ATTRIBUTE,
AttributeModifyOption
.from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6)
.with(Attribute.KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d)
.with(Attribute.ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 15)
.with(Attribute.ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.55d)
.from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6)
.with(Attribute.GENERIC_KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d)
.with(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 15)
.with(Attribute.GENERIC_ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.55d)
)
.addAbilityIdentifier(AbilityType.EXTRA_KNOCKBACK)
.appendOption(
Expand All @@ -219,10 +219,10 @@ public void generateAbilities()
.appendOption(
AbilityType.ATTRIBUTE,
AttributeModifyOption
.from(Attribute.MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6)
.with(Attribute.KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d)
.with(Attribute.ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 30)
.with(Attribute.ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6d)
.from(Attribute.GENERIC_MOVEMENT_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6)
.with(Attribute.GENERIC_KNOCKBACK_RESISTANCE, AttributeModifyOption.OperationType.add, 1d)
.with(Attribute.GENERIC_ATTACK_DAMAGE, AttributeModifyOption.OperationType.add, 30)
.with(Attribute.GENERIC_ATTACK_SPEED, AttributeModifyOption.OperationType.multiply_base, -0.6d)
)
.addAbilityIdentifier(AbilityType.WARDEN);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public int executeSkill(Player player, DisguiseState state, SkillAbilityConfigur
meta.addCustomEffect(potionEffect, true);

Potion targetPotion = null;
var potionRef = BuiltInRegistries.POTION.get(ResourceLocation.parse(info.type.getKey().asString()))
var potionRef = BuiltInRegistries.POTION.getHolder(ResourceLocation.parse(info.type.getKey().asString()))
.orElse(null);

if (potionRef != null && potionRef.isBound())
Expand Down
Loading

0 comments on commit e20d4f4

Please sign in to comment.