Custom bubble column

This commit is contained in:
paulevsGitch 2020-12-13 18:34:18 +03:00
parent 40cb23494f
commit 4640d1d533
11 changed files with 136 additions and 55 deletions

View file

@ -1,41 +0,0 @@
package ru.betterend.mixin.common;
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.CallbackInfoReturnable;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.BubbleColumnBlock;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.BlockView;
import net.minecraft.world.WorldView;
import ru.betterend.registry.EndBlocks;
@Mixin(value = BubbleColumnBlock.class, priority = 100)
public abstract class BubbleColumnBlockMixin extends Block {
public BubbleColumnBlockMixin(Settings settings) {
super(settings);
}
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
BlockState blockState = world.getBlockState(pos.down());
if (blockState.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
info.setReturnValue(true);
info.cancel();
}
}
@Inject(method = "calculateDrag", at = @At("RETURN"), cancellable = true)
private static void beCalculateDrag(BlockView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
if (info.getReturnValue()) {
BlockState state = world.getBlockState(pos.down());
if (state.isOf(EndBlocks.HYDROTHERMAL_VENT)) {
info.setReturnValue(false);
info.cancel();
}
}
}
}