Migrate AstraSoups to NeoForge as AstraCauldron
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package online.astradev.cauldron.mixin;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.*;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Fluid;
|
||||
import online.astradev.cauldron.AstraCauldron;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** NeoForge has no cancellable event for these vanilla cauldron mutations. */
|
||||
@Mixin({CauldronBlock.class, LayeredCauldronBlock.class})
|
||||
abstract class CauldronWeatherMixin {
|
||||
@Inject(method = "handlePrecipitation", at = @At("HEAD"), cancellable = true)
|
||||
private void soups$rain(BlockState state, Level level, BlockPos pos, Biome.Precipitation precipitation, CallbackInfo ci) {
|
||||
if (AstraCauldron.occupied(level, pos)) ci.cancel();
|
||||
}
|
||||
@Inject(method = "receiveStalactiteDrip", at = @At("HEAD"), cancellable = true)
|
||||
private void soups$drip(BlockState state, Level level, BlockPos pos, Fluid fluid, CallbackInfo ci) {
|
||||
if (AstraCauldron.occupied(level, pos)) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package online.astradev.cauldron.mixin;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.LayeredCauldronBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import online.astradev.cauldron.AstraCauldron;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
@Mixin(LayeredCauldronBlock.class)
|
||||
abstract class LayeredCauldronMixin {
|
||||
@Inject(method = "lowerFillLevel", at = @At("HEAD"), cancellable = true)
|
||||
private static void soups$lower(BlockState state, Level level, BlockPos pos, CallbackInfo ci) {
|
||||
if (AstraCauldron.occupied(level, pos)) ci.cancel();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package online.astradev.cauldron.mixin;
|
||||
|
||||
import net.minecraft.core.Holder;
|
||||
import net.minecraft.core.component.*;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.*;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
|
||||
/** Per-stack patch is sent to vanilla clients; no change to their assumed item defaults. */
|
||||
@Mixin(ItemStack.class)
|
||||
abstract class SoupStackMixin {
|
||||
@Inject(method = "<init>(Lnet/minecraft/core/Holder;ILnet/minecraft/core/component/PatchedDataComponentMap;)V", at = @At("RETURN"))
|
||||
private void soups$stackSize(Holder<Item> item, int count, PatchedDataComponentMap components, CallbackInfo ci) {
|
||||
var key = item.unwrapKey().orElse(null);
|
||||
if (key == null || !key.identifier().getNamespace().equals("minecraft")) return;
|
||||
switch (key.identifier().getPath()) {
|
||||
case "mushroom_stew", "rabbit_stew", "beetroot_soup", "suspicious_stew" -> components.set(DataComponents.MAX_STACK_SIZE, 16);
|
||||
default -> { }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user