Skip to content

Commit

Permalink
Fix smithing recipes and freezing after death
Browse files Browse the repository at this point in the history
  • Loading branch information
Dariensg committed Jun 30, 2023
1 parent e654019 commit 85a2def
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ protected boolean checkCompatibility(Enchantment ench) {
@Override
public boolean canEnchant(ItemStack stack) {
Item stackItem = stack.getItem();
return stackItem instanceof AxeItem || stackItem instanceof BowItem || stackItem instanceof CrossbowItem || this.category.canEnchant(stackItem);
return stackItem instanceof AxeItem || stackItem instanceof BowItem || stackItem instanceof CrossbowItem || this.category.canEnchant(stackItem) || stack.canApplyAtEnchantingTable(this);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ private void MM_setEnchantsOnCreation(EntityType entityType, LivingEntity shoote
@Inject(method = "onHitEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/projectile/AbstractArrow;doPostHurtEffects(Lnet/minecraft/world/entity/LivingEntity;)V"))
private void MM_dealArrowEnchants(EntityHitResult hitResult, CallbackInfo ci) {
if (this.freezingLevel > 0) {
if (hitResult.getEntity() instanceof LivingEntity livingEntity && !livingEntity.level.isClientSide()) {
if (hitResult.getEntity() instanceof LivingEntity livingEntity && !livingEntity.level.isClientSide() && !livingEntity.isDeadOrDying()) {
livingEntity.setTicksFrozen(Math.max(livingEntity.getTicksFrozen(), livingEntity.getTicksRequiredToFreeze() + 120 * this.freezingLevel));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ private void MM_calculateEnchantEffects(Entity targetEntity, CallbackInfo ci, fl
}

private void applyFreezingEffects(Entity targetEntity, int level) {
if (targetEntity instanceof LivingEntity livingTarget && !livingTarget.level.isClientSide()) {
if (targetEntity instanceof LivingEntity livingTarget && !livingTarget.level.isClientSide() && !livingTarget.isDeadOrDying()) {
livingTarget.setTicksFrozen(Math.max(livingTarget.getTicksFrozen(), livingTarget.getTicksRequiredToFreeze() + 120 * level));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ItemStack assemble(Container inv) {

outerLoop:
for (Enchantment enchantment : enchantments) {
if (itemstack.canApplyAtEnchantingTable(enchantment) && areEnchantsCompatible(itemstack, enchantment)) {
if (enchantment.canEnchant(itemstack) && areEnchantsCompatible(itemstack, enchantment)) {
ListTag nbtList = itemstack.getEnchantmentTags();

for (int i = 0; i < nbtList.size(); i++) {
Expand Down

0 comments on commit 85a2def

Please sign in to comment.