Skip to content

Commit

Permalink
setup TTBlocks for port
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Oct 19, 2024
1 parent 68c075f commit 3cc1456
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.GameRules;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.world.level.LevelReader;
import net.minecraft.world.level.ScheduledTickAccess;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.BonemealableBlock;
Expand Down Expand Up @@ -71,12 +71,12 @@ public BlockState getStateForPlacement(BlockPlaceContext ctx) {
}

@Override
public @NotNull BlockState updateShape(@NotNull BlockState state, Direction direction, BlockState neighborState, LevelAccessor world, BlockPos pos, BlockPos neighborPos) {
@NotNull
protected BlockState updateShape(BlockState state, LevelReader level, ScheduledTickAccess scheduledTickAccess, BlockPos pos, Direction direction, BlockPos neighborPos, BlockState blockState2, RandomSource randomSource) {
if (isDouble(state.getValue(AGE))) {
return super.updateShape(state, direction, neighborState, world, pos, neighborPos);
} else {
return state.canSurvive(world, pos) ? state : Blocks.AIR.defaultBlockState();
return super.updateShape(state, level, scheduledTickAccess, pos, direction, neighborPos, blockState2, randomSource);
}
return state.canSurvive(level, pos) ? state : Blocks.AIR.defaultBlockState();
}

@Override
Expand All @@ -96,12 +96,12 @@ protected void createBlockStateDefinition(StateDefinition.@NotNull Builder<Block
}

@Override
public void entityInside(BlockState state, Level world, BlockPos pos, Entity entity) {
if (entity instanceof Ravager && world.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
world.destroyBlock(pos, true, entity);
public void entityInside(BlockState state, Level level, BlockPos pos, Entity entity) {
if (level instanceof ServerLevel server && entity instanceof Ravager && server.getGameRules().getBoolean(GameRules.RULE_MOBGRIEFING)) {
level.destroyBlock(pos, true, entity);
}

super.entityInside(state, world, pos, entity);
super.entityInside(state, level, pos, entity);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.block.state.properties.BooleanProperty;
import net.minecraft.world.level.block.state.properties.EnumProperty;
import net.minecraft.world.level.redstone.ExperimentalRedstoneUtils;
import net.minecraft.world.level.redstone.Orientation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -72,8 +74,9 @@ public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
protected void updateNeighborsInFront(@NotNull Level level, @NotNull BlockPos pos, @NotNull BlockState state) {
Direction direction = state.getValue(FACING);
BlockPos blockPos = pos.relative(direction.getOpposite());
level.neighborChanged(blockPos, this, pos);
level.updateNeighborsAtExceptFromFacing(blockPos, this, direction);
Orientation orientation = ExperimentalRedstoneUtils.initialOrientation(level, direction.getOpposite(), null);
level.neighborChanged(blockPos, this, orientation);
level.updateNeighborsAtExceptFromFacing(blockPos, this, direction, orientation);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import net.minecraft.core.BlockPos;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.ItemInteractionResult;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
Expand Down Expand Up @@ -34,7 +34,7 @@ public class BlockBehaviorMixin {
Player player,
InteractionHand interactionHand,
BlockHitResult hitResult,
CallbackInfoReturnable<ItemInteractionResult> info
CallbackInfoReturnable<InteractionResult> info
) {
if (blockState.getBlock() instanceof BrushableBlock) {
if (TTBlockConfig.get().suspiciousBlocks.place_items && blockState.hasProperty(TTBlockStateProperties.CAN_PLACE_ITEM)) {
Expand All @@ -46,11 +46,11 @@ public class BlockBehaviorMixin {
if (canPlaceIntoBlock) {
if (level.getBlockEntity(blockPos) instanceof BrushableBlockEntityInterface brushableBlockEntityInterface) {
brushableBlockEntityInterface.trailierTales$setItem(playerStack.split(1));
info.setReturnValue(ItemInteractionResult.SUCCESS);
info.setReturnValue(InteractionResult.SUCCESS);
return;
}
}
info.setReturnValue(ItemInteractionResult.PASS_TO_DEFAULT_BLOCK_INTERACTION);
info.setReturnValue(InteractionResult.TRY_WITH_EMPTY_HAND);
}
}
}
Expand Down
Loading

0 comments on commit 3cc1456

Please sign in to comment.