feat: implement nms method WorldCore#pressButton to replace BlockUtils

This method uses vanilla functionality to press a button
'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 19:17:33 +02:00
parent 9c3d6e5339
commit 570db7b455
No known key found for this signature in database
GPG Key ID: 6A4A09E8ED946113
28 changed files with 334 additions and 0 deletions

View File

@ -38,6 +38,8 @@ public interface WorldCore {
void toggleLever(@NotNull Block bukkitBlock);
void pressButton(@NotNull Block bukkitBlock);
/**
* 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.

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.WorldCore;
import net.minecraft.server.v1_10_R1.Block;
import net.minecraft.server.v1_10_R1.BlockButtonAbstract;
import net.minecraft.server.v1_10_R1.BlockLever;
import net.minecraft.server.v1_10_R1.BlockPosition;
import net.minecraft.server.v1_10_R1.Chunk;
@ -112,4 +113,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_11_R1.Block;
import net.minecraft.server.v1_11_R1.BlockButtonAbstract;
import net.minecraft.server.v1_11_R1.BlockLever;
import net.minecraft.server.v1_11_R1.BlockPosition;
import net.minecraft.server.v1_11_R1.Chunk;
@ -112,4 +113,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_12_R1.Block;
import net.minecraft.server.v1_12_R1.BlockButtonAbstract;
import net.minecraft.server.v1_12_R1.BlockLever;
import net.minecraft.server.v1_12_R1.BlockPosition;
import net.minecraft.server.v1_12_R1.Chunk;
@ -112,4 +113,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_13_R1.BlockButtonAbstract;
import net.minecraft.server.v1_13_R1.BlockLever;
import net.minecraft.server.v1_13_R1.BlockPosition;
import net.minecraft.server.v1_13_R1.Chunk;
@ -113,4 +114,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_13_R2.BlockButtonAbstract;
import net.minecraft.server.v1_13_R2.BlockLever;
import net.minecraft.server.v1_13_R2.BlockPosition;
import net.minecraft.server.v1_13_R2.Chunk;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_14_R1.BlockButtonAbstract;
import net.minecraft.server.v1_14_R1.BlockLever;
import net.minecraft.server.v1_14_R1.BlockPosition;
import net.minecraft.server.v1_14_R1.Chunk;
@ -117,4 +118,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).interact(iBlockData, world, blockposition, null, null, null);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_15_R1.BlockButtonAbstract;
import net.minecraft.server.v1_15_R1.BlockLever;
import net.minecraft.server.v1_15_R1.BlockPosition;
import net.minecraft.server.v1_15_R1.Chunk;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R1.BlockButtonAbstract;
import net.minecraft.server.v1_16_R1.BlockLever;
import net.minecraft.server.v1_16_R1.BlockPosition;
import net.minecraft.server.v1_16_R1.Chunk;
@ -121,4 +122,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R2.BlockButtonAbstract;
import net.minecraft.server.v1_16_R2.BlockLever;
import net.minecraft.server.v1_16_R2.BlockPosition;
import net.minecraft.server.v1_16_R2.Chunk;
@ -121,4 +122,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.SWorld;
import com.craftaro.core.nms.world.WorldCore;
import net.minecraft.server.v1_16_R3.BlockButtonAbstract;
import net.minecraft.server.v1_16_R3.BlockLever;
import net.minecraft.server.v1_16_R3.BlockPosition;
import net.minecraft.server.v1_16_R3.Chunk;
@ -122,4 +123,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) 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.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.MobSpawnerAbstract;
import net.minecraft.world.level.block.BlockButtonAbstract;
import net.minecraft.world.level.block.BlockLever;
import net.minecraft.world.level.block.state.IBlockData;
import net.minecraft.world.level.chunk.Chunk;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((BlockLever) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
IBlockData iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPosition blockposition = craftBlock.getPosition();
WorldServer world = craftBlock.getCraftWorld().getHandle();
((BlockButtonAbstract) craftBlock.getNMS().getBlock()).d(iBlockData, world, blockposition);
}
}

View File

@ -14,6 +14,7 @@ import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
@ -119,4 +120,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
@ -114,4 +115,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
@ -114,4 +115,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
@ -114,4 +115,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
@ -115,4 +116,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -13,6 +13,7 @@ import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.BaseSpawner;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.ChunkStatus;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(iBlockData, world, blockposition);
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.core.SectionPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.ButtonBlock;
import net.minecraft.world.level.block.LeverBlock;
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
@ -120,4 +121,15 @@ public class WorldCoreImpl implements WorldCore {
((LeverBlock) craftBlock.getNMS().getBlock()).pull(iBlockData, world, blockposition, null);
}
@Override
public void pressButton(@NotNull Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockState iBlockData = ((CraftBlockData) craftBlock.getBlockData()).getState();
BlockPos blockposition = craftBlock.getPosition();
ServerLevel world = craftBlock.getCraftWorld().getHandle();
((ButtonBlock) craftBlock.getNMS().getBlock()).press(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.WorldCore;
import net.minecraft.server.v1_8_R1.Block;
import net.minecraft.server.v1_8_R1.BlockButtonAbstract;
import net.minecraft.server.v1_8_R1.BlockLever;
import net.minecraft.server.v1_8_R1.BlockPosition;
import net.minecraft.server.v1_8_R1.Chunk;
@ -114,4 +115,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_8_R2.Block;
import net.minecraft.server.v1_8_R2.BlockButtonAbstract;
import net.minecraft.server.v1_8_R2.BlockLever;
import net.minecraft.server.v1_8_R2.BlockPosition;
import net.minecraft.server.v1_8_R2.Chunk;
@ -114,4 +115,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_8_R3.Block;
import net.minecraft.server.v1_8_R3.BlockButtonAbstract;
import net.minecraft.server.v1_8_R3.BlockLever;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.Chunk;
@ -113,4 +114,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_9_R1.Block;
import net.minecraft.server.v1_9_R1.BlockButtonAbstract;
import net.minecraft.server.v1_9_R1.BlockLever;
import net.minecraft.server.v1_9_R1.BlockPosition;
import net.minecraft.server.v1_9_R1.Chunk;
@ -113,4 +114,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.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.WorldCore;
import net.minecraft.server.v1_9_R2.Block;
import net.minecraft.server.v1_9_R2.BlockButtonAbstract;
import net.minecraft.server.v1_9_R2.BlockLever;
import net.minecraft.server.v1_9_R2.BlockPosition;
import net.minecraft.server.v1_9_R2.Chunk;
@ -112,4 +113,16 @@ public class WorldCoreImpl implements WorldCore {
leverBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
@Override
public void pressButton(@NotNull org.bukkit.block.Block bukkitBlock) {
CraftBlock craftBlock = (CraftBlock) bukkitBlock;
BlockButtonAbstract buttonBlock = (BlockButtonAbstract) CraftMagicNumbers.getBlock(craftBlock);
IBlockData iBlockData = buttonBlock.getBlockData();
BlockPosition blockposition = new BlockPosition(craftBlock.getX(), craftBlock.getY(), craftBlock.getZ());
WorldServer world = ((CraftWorld) craftBlock.getWorld()).getHandle();
buttonBlock.interact(world, blockposition, iBlockData, null, null, null, null, 0, 0, 0);
}
}