Fix placer not working

This commit is contained in:
Mrbysco 2024-10-16 23:29:06 +02:00
parent 8e06e4bcb0
commit a117dd5340
2 changed files with 16 additions and 10 deletions

View file

@ -78,16 +78,20 @@ public class TileEntityBreaker extends TileEntityInventoryBase implements MenuPr
public static <T extends BlockEntity> void serverTick(Level level, BlockPos pos, BlockState state, T t) { public static <T extends BlockEntity> void serverTick(Level level, BlockPos pos, BlockState state, T t) {
if (t instanceof TileEntityBreaker tile) { if (t instanceof TileEntityBreaker tile) {
tile.serverTick(); tile.serverTick();
}
}
if (!tile.isRedstonePowered && !tile.isPulseMode) { @Override
if (tile.currentTime > 0) { protected void serverTick() {
tile.currentTime--; super.serverTick();
if (tile.currentTime <= 0) { if (!isRedstonePowered && !isPulseMode) {
tile.doWork(); if (currentTime > 0) {
} currentTime--;
} else { if (currentTime <= 0) {
tile.currentTime = 15; doWork();
} }
} else {
currentTime = 15;
} }
} }
} }

View file

@ -23,6 +23,7 @@ import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.player.Player;
import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items; import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level; import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.Blocks;
@ -165,8 +166,9 @@ public final class WorldUtil {
if (level instanceof ServerLevel && StackUtil.isValid(stack) && pos != null) { if (level instanceof ServerLevel && StackUtil.isValid(stack) && pos != null) {
BlockPos offsetPos = pos.relative(side); BlockPos offsetPos = pos.relative(side);
BlockState state = level.getBlockState(offsetPos); BlockState state = level.getBlockState(offsetPos);
Block block = state.getBlock(); boolean replaceable = state.canBeReplaced(new BlockPlaceContext(level, null, InteractionHand.MAIN_HAND, stack,
boolean replaceable = false; //= block.canBeReplaced(world, offsetPos); //TODO new BlockHitResult(new Vec3(0, 0, 0), side, pos, false)
));
//Redstone //Redstone
if (replaceable && stack.getItem() == Items.REDSTONE) { if (replaceable && stack.getItem() == Items.REDSTONE) {