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) {
if (t instanceof TileEntityBreaker tile) {
tile.serverTick();
}
}
if (!tile.isRedstonePowered && !tile.isPulseMode) {
if (tile.currentTime > 0) {
tile.currentTime--;
if (tile.currentTime <= 0) {
tile.doWork();
@Override
protected void serverTick() {
super.serverTick();
if (!isRedstonePowered && !isPulseMode) {
if (currentTime > 0) {
currentTime--;
if (currentTime <= 0) {
doWork();
}
} else {
tile.currentTime = 15;
}
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.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
@ -165,8 +166,9 @@ public final class WorldUtil {
if (level instanceof ServerLevel && StackUtil.isValid(stack) && pos != null) {
BlockPos offsetPos = pos.relative(side);
BlockState state = level.getBlockState(offsetPos);
Block block = state.getBlock();
boolean replaceable = false; //= block.canBeReplaced(world, offsetPos); //TODO
boolean replaceable = state.canBeReplaced(new BlockPlaceContext(level, null, InteractionHand.MAIN_HAND, stack,
new BlockHitResult(new Vec3(0, 0, 0), side, pos, false)
));
//Redstone
if (replaceable && stack.getItem() == Items.REDSTONE) {