use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.
the class NMSInventory_v1_12_R1 method getTileEntity.
private static TileEntityWildChest getTileEntity(Chest chest) {
Location loc = chest.getLocation();
World world = ((CraftWorld) loc.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
return (TileEntityWildChest) world.getTileEntity(blockPosition);
}
use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_16_R3 method playChestAction.
@Override
public void playChestAction(Location location, boolean open) {
World world = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
TileEntityChest tileChest = (TileEntityChest) world.getTileEntity(blockPosition);
if (tileChest != null)
world.playBlockAction(blockPosition, tileChest.getBlock().getBlock(), 1, open ? 1 : 0);
}
use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method playChestAction.
@Override
public void playChestAction(Location location, boolean open) {
World world = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
TileEntityChest tileChest = (TileEntityChest) world.getTileEntity(blockPosition);
if (tileChest != null)
world.playBlockAction(blockPosition, world.getType(blockPosition).getBlock(), 1, open ? 1 : 0);
}
use of net.minecraft.server.v1_16_R2.World in project WildChests by BG-Software-LLC.
the class NMSAdapter_v1_8_R3 method getNearbyItems.
@Override
public Stream<Item> getNearbyItems(Location location, int range, boolean onlyChunk, KeySet blacklisted, KeySet whitelisted) {
World world = ((CraftWorld) location.getWorld()).getHandle();
List<Entity> entityList = new ArrayList<>();
if (onlyChunk) {
Chunk chunk = ((CraftChunk) location.getChunk()).getHandle();
for (int i = 0; i < chunk.entitySlices.length; i++) entityList.addAll(chunk.entitySlices[i]);
entityList = entityList.stream().filter(entity -> entity instanceof EntityItem).collect(Collectors.toList());
} else {
AxisAlignedBB boundingBox = new AxisAlignedBB(location.getX() + range, location.getY() + range, location.getZ() + range, location.getX() - range, location.getY() - range, location.getZ() - range);
entityList = world.a((Entity) null, boundingBox, entity -> entity instanceof EntityItem);
}
return entityList.stream().map(entity -> (Item) entity.getBukkitEntity()).filter(item -> !blacklisted.contains(item.getItemStack()) && (whitelisted.isEmpty() || whitelisted.contains(item.getItemStack())));
}
use of net.minecraft.server.v1_16_R2.World in project PublicCrafters by BananaPuncher714.
the class CustomContainerWorkbench method shiftClick.
// Overrides 1.15.1
@Override
public ItemStack shiftClick(EntityHuman entityhuman, int i) {
ItemStack itemstack = ItemStack.b;
Slot slot = (Slot) this.slots.get(i);
if (slot != null && slot.hasItem()) {
ItemStack itemstack1 = slot.getItem();
itemstack = itemstack1.cloneItemStack();
if (i == 0) {
this.containerAccess.a((world, blockposition) -> {
itemstack1.getItem().b(itemstack1, world, entityhuman);
});
if (!this.a(itemstack1, 10, 46, true)) {
return ItemStack.b;
}
slot.a(itemstack1, itemstack);
} else if (i >= 10 && i < 46 ? !this.a(itemstack1, 1, 10, false) && (i < 37 ? !this.a(itemstack1, 37, 46, false) : !this.a(itemstack1, 10, 37, false)) : !this.a(itemstack1, 10, 46, false)) {
return ItemStack.b;
}
if (itemstack1.isEmpty()) {
slot.set(ItemStack.b);
} else {
slot.d();
}
if (itemstack1.getCount() == itemstack.getCount()) {
return ItemStack.b;
}
ItemStack itemstack2 = slot.a(entityhuman, itemstack1);
if (i == 0) {
entityhuman.drop(itemstack2, false);
}
}
return itemstack;
}
Aggregations