Skip to content

Commit

Permalink
stop werewolf players to transform if there is no space for the new m…
Browse files Browse the repository at this point in the history
…odel
  • Loading branch information
Cheaterpaul committed Jun 7, 2024
1 parent aeb0189 commit eda905b
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,26 +184,30 @@ public int getDuration(IWerewolfPlayer werewolf) {
}

@Override
public boolean canBeUsedBy(IWerewolfPlayer player) {
if (player.getRepresentingPlayer() instanceof ServerPlayer && (!PermissionAPI.getPermission((ServerPlayer) player.getRepresentingPlayer(), Permissions.TRANSFORMATION) || !PermissionAPI.getPermission((ServerPlayer) player.getRepresentingPlayer(), Permissions.FORM))) {
public boolean canBeUsedBy(IWerewolfPlayer werewolf) {
Player player = werewolf.getRepresentingPlayer();
if (player instanceof ServerPlayer && (!PermissionAPI.getPermission((ServerPlayer) player, Permissions.TRANSFORMATION) || !PermissionAPI.getPermission((ServerPlayer) player, Permissions.FORM))) {
return false;
}
if (player.getRepresentingPlayer().isPassenger() && !this.form.isHumanLike()) return false;
boolean active = player.getActionHandler().isActionActive(this);
if (player.isPassenger() && !this.form.isHumanLike()) return false;
boolean active = werewolf.getActionHandler().isActionActive(this);
if (active) {
if (Helper.isFullMoon(player.getRepresentingPlayer().getCommandSenderWorld())) {
return player.getSkillHandler().isSkillEnabled(ModSkills.FREE_WILL.get());
if (Helper.isFullMoon(player.getCommandSenderWorld())) {
return werewolf.getSkillHandler().isSkillEnabled(ModSkills.FREE_WILL.get());
} else {
return true;
}
} else {
if (player.getForm().isTransformed()) {
if (this.form.getSize(player.getPose()).map(dimensions -> dimensions.makeBoundingBox(player.position())).filter(s -> player.level().collidesWithSuffocatingBlock(player, s)).isPresent()) {
return false;
}
if (werewolf.getForm().isTransformed()) {
return true;
} else {
if (player.getRepresentingPlayer().level().getBiome(player.getRepresentingEntity().blockPosition()).is(ModBiomes.WEREWOLF_FOREST)) {
if (player.level().getBiome(werewolf.getRepresentingEntity().blockPosition()).is(ModBiomes.WEREWOLF_FOREST)) {
return true;
} else {
return ((WerewolfPlayer) player).getSpecialAttributes().transformationTime < 0.7;
return ((WerewolfPlayer) werewolf).getSpecialAttributes().transformationTime < 0.7;
}
}
}
Expand Down

0 comments on commit eda905b

Please sign in to comment.