Skip to content

Commit

Permalink
evaporate on mud to make clay
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexthw46 committed Mar 27, 2024
1 parent 329f5f5 commit c720c59
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
40 changes: 40 additions & 0 deletions src/main/java/alexthw/ars_elemental/mixin/EvaporateMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package alexthw.ars_elemental.mixin;

import com.hollingsworth.arsnouveau.api.spell.AbstractEffect;
import com.hollingsworth.arsnouveau.api.spell.SpellContext;
import com.hollingsworth.arsnouveau.api.spell.SpellResolver;
import com.hollingsworth.arsnouveau.api.util.BlockUtil;
import com.hollingsworth.arsnouveau.common.spell.effect.EffectEvaporate;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.BlockHitResult;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = EffectEvaporate.class, remap = false)
public abstract class EvaporateMixin extends AbstractEffect {


public EvaporateMixin(String tag, String description) {
super(tag, description);
}

@Inject(method = "evaporate", at = @At("HEAD"), cancellable = true)
public void evaporate(Level world, BlockPos p, BlockHitResult rayTraceResult, LivingEntity shooter, SpellContext context, SpellResolver resolver, CallbackInfo ci){

BlockState state = world.getBlockState(p);
if (BlockUtil.destroyRespectsClaim(getPlayer(shooter, (ServerLevel) world), world, p)) {
if (state.getBlock() == Blocks.MUD) {
world.setBlockAndUpdate(p, Blocks.CLAY.defaultBlockState());
ci.cancel();
}
}
}

}
5 changes: 3 additions & 2 deletions src/main/java/alexthw/ars_elemental/util/CompatUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ public static void checkCompats() {

public static SlotResult getCurio(LivingEntity player, Predicate<ItemStack> predicate) {
var lazy = CuriosApi.getCuriosInventory(player);
SlotResult noResult = new SlotResult(null, ItemStack.EMPTY);
if (lazy.isPresent()) {
var optional = lazy.resolve();
if (optional.isPresent()) {
var curioInv = optional.get();
return curioInv.findFirstCurio(predicate).orElse(null);
return curioInv.findFirstCurio(predicate).orElse(noResult);
}
}
return new SlotResult(null, ItemStack.EMPTY);
return noResult;
}


Expand Down
1 change: 1 addition & 0 deletions src/main/resources/ars_elemental.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"refmap": "ars_elemental.refmap.json",
"mixins": [
"DynamicLightMixin",
"EvaporateMixin",
"FlareMixin",
"FoxInvoker",
"GrowMixin",
Expand Down

0 comments on commit c720c59

Please sign in to comment.