feat: implement nms method WorldCore#toggleLever to replace BlockUtils

This method uses vanilla functionality to toggle a lever
'the vanilla way'.
This differs a bit from the original implementation,
but I think this is the more desired one.
This commit is contained in:
Christian Koop 2024-10-02 18:54:40 +02:00
parent f7c9dfe1c5
commit 9c3d6e5339
No known key found for this signature in database
GPG Key ID: 6A4A09E8ED946113
28 changed files with 359 additions and 0 deletions

View File

@ -36,6 +36,8 @@ public interface WorldCore {
void updateAdjacentComparators(@NotNull Block bukkitBlock); void updateAdjacentComparators(@NotNull Block bukkitBlock);
void toggleLever(@NotNull Block bukkitBlock);
/** /**
* Ticks all inactive spawners in a specific chunk ignoring the minimum required players within a specific range.<br> * Ticks all inactive spawners in a specific chunk ignoring the minimum required players within a specific range.<br>
* A spawner is deemed inactive if no player is within its activation range. * A spawner is deemed inactive if no player is within its activation range.

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_10_R1.Block; import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockLever;
import net.minecraft.server.v1_10_R1.BlockPosition; import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Chunk; import net.minecraft.server.v1_10_R1.Chunk;
import net.minecraft.server.v1_10_R1.ChunkSection; import net.minecraft.server.v1_10_R1.ChunkSection;
@ -99,4 +100,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_11_R1.Block; import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockLever;
import net.minecraft.server.v1_11_R1.BlockPosition; import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Chunk; import net.minecraft.server.v1_11_R1.Chunk;
import net.minecraft.server.v1_11_R1.ChunkSection; import net.minecraft.server.v1_11_R1.ChunkSection;
@ -99,4 +100,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_12_R1.Block; import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.BlockLever;
import net.minecraft.server.v1_12_R1.BlockPosition; import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.Chunk; import net.minecraft.server.v1_12_R1.Chunk;
import net.minecraft.server.v1_12_R1.ChunkSection; import net.minecraft.server.v1_12_R1.ChunkSection;
@ -99,4 +100,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, null, 0, 0, 0);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_13_R1.BlockLever;
import net.minecraft.server.v1_13_R1.BlockPosition; import net.minecraft.server.v1_13_R1.BlockPosition;
import net.minecraft.server.v1_13_R1.Chunk; import net.minecraft.server.v1_13_R1.Chunk;
import net.minecraft.server.v1_13_R1.ChunkSection; import net.minecraft.server.v1_13_R1.ChunkSection;
@ -20,6 +21,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_13_R1.CraftChunk; import org.bukkit.craftbukkit.v1_13_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_13_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_13_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -100,4 +102,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null, 0, 0, 0);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_13_R2.BlockLever;
import net.minecraft.server.v1_13_R2.BlockPosition; import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.Chunk; import net.minecraft.server.v1_13_R2.Chunk;
import net.minecraft.server.v1_13_R2.ChunkSection; import net.minecraft.server.v1_13_R2.ChunkSection;
@ -20,6 +21,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_13_R2.CraftChunk; import org.bukkit.craftbukkit.v1_13_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_13_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_13_R2.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null, 0, 0, 0);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_14_R1.BlockLever;
import net.minecraft.server.v1_14_R1.BlockPosition; import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk; import net.minecraft.server.v1_14_R1.Chunk;
import net.minecraft.server.v1_14_R1.ChunkCoordIntPair; import net.minecraft.server.v1_14_R1.ChunkCoordIntPair;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_14_R1.CraftChunk; import org.bukkit.craftbukkit.v1_14_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_14_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -104,4 +106,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_15_R1.BlockLever;
import net.minecraft.server.v1_15_R1.BlockPosition; import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Chunk; import net.minecraft.server.v1_15_R1.Chunk;
import net.minecraft.server.v1_15_R1.ChunkCoordIntPair; import net.minecraft.server.v1_15_R1.ChunkCoordIntPair;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_15_R1.CraftChunk; import org.bukkit.craftbukkit.v1_15_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_15_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_15_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R1.BlockLever;
import net.minecraft.server.v1_16_R1.BlockPosition; import net.minecraft.server.v1_16_R1.BlockPosition;
import net.minecraft.server.v1_16_R1.Chunk; import net.minecraft.server.v1_16_R1.Chunk;
import net.minecraft.server.v1_16_R1.ChunkCoordIntPair; import net.minecraft.server.v1_16_R1.ChunkCoordIntPair;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_16_R1.CraftChunk; import org.bukkit.craftbukkit.v1_16_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -108,4 +110,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R2.BlockLever;
import net.minecraft.server.v1_16_R2.BlockPosition; import net.minecraft.server.v1_16_R2.BlockPosition;
import net.minecraft.server.v1_16_R2.Chunk; import net.minecraft.server.v1_16_R2.Chunk;
import net.minecraft.server.v1_16_R2.ChunkCoordIntPair; import net.minecraft.server.v1_16_R2.ChunkCoordIntPair;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_16_R2.CraftChunk; import org.bukkit.craftbukkit.v1_16_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R2.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -108,4 +110,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
} }

View File

@ -7,6 +7,7 @@ import com.craftaro.core.nms.world.SItemStack;
import com.craftaro.core.nms.world.SSpawner; import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R3.BlockLever;
import net.minecraft.server.v1_16_R3.BlockPosition; import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.Chunk; import net.minecraft.server.v1_16_R3.Chunk;
import net.minecraft.server.v1_16_R3.ChunkCoordIntPair; import net.minecraft.server.v1_16_R3.ChunkCoordIntPair;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_16_R3.CraftChunk; import org.bukkit.craftbukkit.v1_16_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock; import org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_16_R3.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -109,4 +111,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.WorldServer;
import net.minecraft.util.profiling.GameProfilerFiller; import net.minecraft.util.profiling.GameProfilerFiller;
import net.minecraft.world.level.ChunkCoordIntPair; import net.minecraft.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.MobSpawnerAbstract; import net.minecraft.world.level.MobSpawnerAbstract;
import net.minecraft.world.level.block.BlockLever;
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.Chunk; import net.minecraft.world.level.chunk.Chunk;
import net.minecraft.world.level.chunk.ChunkSection; import net.minecraft.world.level.chunk.ChunkSection;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_17_R1.CraftChunk; import org.bukkit.craftbukkit.v1_17_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_17_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_17_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateAdjacentComparators(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
} }

View File

@ -8,11 +8,15 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
@ -22,6 +26,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_18_R1.CraftChunk; import org.bukkit.craftbukkit.v1_18_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_18_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_18_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -104,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -8,11 +8,15 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection;
import net.minecraft.world.level.material.FluidState; import net.minecraft.world.level.material.FluidState;
@ -22,6 +26,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_18_R2.CraftChunk; import org.bukkit.craftbukkit.v1_18_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_18_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_18_R2.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -103,4 +108,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk; import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -101,4 +103,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk; import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_19_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -101,4 +103,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.LevelChunkSection; import net.minecraft.world.level.chunk.LevelChunkSection;
@ -22,6 +23,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_19_R2.CraftChunk; import org.bukkit.craftbukkit.v1_19_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_19_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R2.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -101,4 +103,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -23,6 +24,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_19_R3.CraftChunk; import org.bukkit.craftbukkit.v1_19_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock; import org.bukkit.craftbukkit.v1_19_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_19_R3.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -102,4 +104,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -24,6 +25,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_20_R1.CraftChunk; import org.bukkit.craftbukkit.v1_20_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_20_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -24,6 +25,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_20_R2.CraftChunk; import org.bukkit.craftbukkit.v1_20_R2.CraftChunk;
import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock; import org.bukkit.craftbukkit.v1_20_R2.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R2.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner; import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.ChunkStatus;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -24,6 +25,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_20_R3.CraftChunk; import org.bukkit.craftbukkit.v1_20_R3.CraftChunk;
import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock; import org.bukkit.craftbukkit.v1_20_R3.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R3.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity; import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -24,6 +25,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_20_R4.CraftChunk; import org.bukkit.craftbukkit.v1_20_R4.CraftChunk;
import org.bukkit.craftbukkit.v1_20_R4.block.CraftBlock; import org.bukkit.craftbukkit.v1_20_R4.block.CraftBlock;
import org.bukkit.craftbukkit.v1_20_R4.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
} }

View File

@ -12,6 +12,7 @@ import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller; import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity; import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunk;
@ -24,6 +25,7 @@ import org.bukkit.block.Block;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_21_R1.CraftChunk; import org.bukkit.craftbukkit.v1_21_R1.CraftChunk;
import org.bukkit.craftbukkit.v1_21_R1.block.CraftBlock; import org.bukkit.craftbukkit.v1_21_R1.block.CraftBlock;
import org.bukkit.craftbukkit.v1_21_R1.block.data.CraftBlockData;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -107,4 +109,15 @@ public class WorldCoreImpl implements WorldCore {
serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock()); serverLevel.updateNeighbourForOutputSignal(craftBlock.getPosition(), craftBlock.getNMS().getBlock());
} }
@Override
public void toggleLever(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition, null);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_8_R1.Block; import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.BlockLever;
import net.minecraft.server.v1_8_R1.BlockPosition; import net.minecraft.server.v1_8_R1.BlockPosition;
import net.minecraft.server.v1_8_R1.Chunk; import net.minecraft.server.v1_8_R1.Chunk;
import net.minecraft.server.v1_8_R1.ChunkSection; import net.minecraft.server.v1_8_R1.ChunkSection;
@ -101,4 +102,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_8_R2.Block; import net.minecraft.server.v1_8_R2.Block;
import net.minecraft.server.v1_8_R2.BlockLever;
import net.minecraft.server.v1_8_R2.BlockPosition; import net.minecraft.server.v1_8_R2.BlockPosition;
import net.minecraft.server.v1_8_R2.Chunk; import net.minecraft.server.v1_8_R2.Chunk;
import net.minecraft.server.v1_8_R2.ChunkSection; import net.minecraft.server.v1_8_R2.ChunkSection;
@ -101,4 +102,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_8_R3.Block; import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockLever;
import net.minecraft.server.v1_8_R3.BlockPosition; import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Chunk; import net.minecraft.server.v1_8_R3.Chunk;
import net.minecraft.server.v1_8_R3.ChunkSection; import net.minecraft.server.v1_8_R3.ChunkSection;
@ -100,4 +101,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_9_R1.Block; import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockLever;
import net.minecraft.server.v1_9_R1.BlockPosition; import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.Chunk; import net.minecraft.server.v1_9_R1.Chunk;
import net.minecraft.server.v1_9_R1.ChunkSection; import net.minecraft.server.v1_9_R1.ChunkSection;
@ -100,4 +101,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
} }

View File

@ -8,6 +8,7 @@ import com.craftaro.core.nms.world.SSpawner;
import com.craftaro.core.nms.world.SWorld; import com.craftaro.core.nms.world.SWorld;
import com.craftaro.core.nms.world.WorldCore; import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_9_R2.Block; import net.minecraft.server.v1_9_R2.Block;
import net.minecraft.server.v1_9_R2.BlockLever;
import net.minecraft.server.v1_9_R2.BlockPosition; import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.Chunk; import net.minecraft.server.v1_9_R2.Chunk;
import net.minecraft.server.v1_9_R2.ChunkSection; import net.minecraft.server.v1_9_R2.ChunkSection;
@ -99,4 +100,16 @@ public class WorldCoreImpl implements WorldCore {
Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType()); Block nmsBlock = CraftMagicNumbers.getBlock(bukkitBlock.getType());
serverLevel.updateAdjacentComparators(blockPos, nmsBlock); serverLevel.updateAdjacentComparators(blockPos, nmsBlock);
} }
@Override
public void toggleLever(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockLever leverBlock = (BlockLever) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = leverBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
} }