This commit is contained in:
paulevsGitch 2020-10-24 19:00:58 +03:00
parent 35f9c02d76
commit bc7217aff3
6 changed files with 23 additions and 56 deletions

View file

@ -6,6 +6,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
@ -19,15 +20,24 @@ import ru.betterend.registry.BlockRegistry;
import ru.betterend.registry.BlockTagRegistry;
import ru.betterend.util.BlocksHelper;
@Mixin(ChorusPlantBlock.class)
public class ChorusPlantBlockMixin {
@Mixin(value = ChorusPlantBlock.class, priority = 500)
public abstract class ChorusPlantBlockMixin extends Block {
public ChorusPlantBlockMixin(Settings settings) {
super(settings);
}
@Inject(method = "<init>*", at = @At("TAIL"))
private void beOnInit(AbstractBlock.Settings settings, CallbackInfo info) {
this.setDefaultState(this.getDefaultState().with(BlocksHelper.ROOTS, false));
}
@Inject(method = "appendProperties", at = @At("TAIL"))
private void addProperties(StateManager.Builder<Block, BlockState> builder, CallbackInfo info) {
private void beAddProperties(StateManager.Builder<Block, BlockState> builder, CallbackInfo info) {
builder.add(BlocksHelper.ROOTS);
}
@Inject(method = "canPlaceAt", at = @At("HEAD"), cancellable = true)
private void canPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
private void beCanPlace(BlockState state, WorldView world, BlockPos pos, CallbackInfoReturnable<Boolean> info) {
if (world.getBlockState(pos.down()).isOf(BlockRegistry.CHORUS_NYLIUM)) {
info.setReturnValue(true);
info.cancel();
@ -35,7 +45,7 @@ public class ChorusPlantBlockMixin {
}
@Inject(method = "withConnectionProperties", at = @At("RETURN"), cancellable = true)
private void withConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
private void beConnectionProperties(BlockView world, BlockPos pos, CallbackInfoReturnable<BlockState> info) {
BlockState plant = info.getReturnValue();
if (plant.isOf(Blocks.CHORUS_PLANT)) {
if (!plant.get(Properties.DOWN) && world.getBlockState(pos.down()).isIn(BlockTagRegistry.END_GROUND)) {