[Idea]: Folia support for OpenInv #196
@@ -98,11 +98,17 @@ public interface IAnySilentContainer {
|
||||
|
||||
Directional directional = (Directional) blockData;
|
||||
BlockFace face = directional.getFacing();
|
||||
boundingBox.shift(face.getDirection());
|
||||
// Return whether or not bounding boxes overlap.
|
||||
return block.getRelative(face, 1).getBoundingBox().overlaps(boundingBox);
|
||||
}
|
||||
Block relative = block.getRelative(face, 1);
|
||||
|
||||
if (isShulkerIgnoreBoundingBox(relative)) {
|
||||
// Certain special cases are ignored. Signs, simple redstone, etc.
|
||||
return false;
|
||||
}
|
||||
|
||||
boundingBox.expand(face.getDirection(), 0.5);
|
||||
// Return whether or not bounding boxes overlap.
|
||||
return relative.getBoundingBox().overlaps(boundingBox);
|
||||
}
|
||||
|
||||
if (!(blockState instanceof org.bukkit.block.Chest)) {
|
||||
return false;
|
||||
@@ -140,6 +146,14 @@ public interface IAnySilentContainer {
|
||||
return isChestBlocked(relative);
|
||||
}
|
||||
|
||||
boolean isShulkerIgnoreBoundingBox(Block block);
|
||||
|
||||
/**
|
||||
* Determine whether or not a chest is blocked.
|
||||
*
|
||||
* @param chest the chest block
|
||||
* @return true if the chest block cannot be opened under ordinary circumstances
|
||||
*/
|
||||
default boolean isChestBlocked(Block chest) {
|
||||
org.bukkit.block.Block relative = chest.getRelative(0, 1, 0);
|
||||
return relative.getType().isOccluding()
|
||||
|
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_16_R3;
|
||||
import com.lishid.openinv.OpenInv;
|
||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.logging.Level;
|
||||
import net.minecraft.server.v1_16_R3.Block;
|
||||
import net.minecraft.server.v1_16_R3.BlockBarrel;
|
||||
import net.minecraft.server.v1_16_R3.BlockChest;
|
||||
@@ -46,8 +47,10 @@ import net.minecraft.server.v1_16_R3.TileEntityEnderChest;
|
||||
import net.minecraft.server.v1_16_R3.TileEntityLootable;
|
||||
import net.minecraft.server.v1_16_R3.TileInventory;
|
||||
import net.minecraft.server.v1_16_R3.World;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -66,6 +69,23 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShulkerIgnoreBoundingBox(org.bukkit.block.Block bukkitBlock) {
|
||||
org.bukkit.World bukkitWorld = bukkitBlock.getWorld();
|
||||
if (!(bukkitWorld instanceof CraftWorld)) {
|
||||
bukkitWorld = Bukkit.getWorld(bukkitWorld.getUID());
|
||||
}
|
||||
if (!(bukkitWorld instanceof CraftWorld)) {
|
||||
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
||||
OpenInv.getPlugin(OpenInv.class).getLogger().log(Level.WARNING, exception.getMessage(), exception);
|
||||
return false;
|
||||
}
|
||||
|
||||
final World world = ((CraftWorld) bukkitWorld).getHandle();
|
||||
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
||||
return world.getType(blockPosition).d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateContainer(@NotNull final Player bukkitPlayer, final boolean silentchest,
|
||||
@NotNull final org.bukkit.block.Block bukkitBlock) {
|
||||
|
@@ -39,7 +39,7 @@
|
||||
<artifactId>spigot</artifactId>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<scope>provided</scope>
|
||||
<version>1.17-R0.1-SNAPSHOT</version>
|
||||
<version>1.17.1-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<artifactId>openinvapi</artifactId>
|
||||
|
@@ -48,8 +48,10 @@ import net.minecraft.world.level.block.entity.TileEntityEnderChest;
|
||||
import net.minecraft.world.level.block.entity.TileEntityLootable;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.world.level.block.state.properties.BlockPropertyChestType;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -69,6 +71,24 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isShulkerIgnoreBoundingBox(org.bukkit.block.Block bukkitBlock) {
|
||||
org.bukkit.World bukkitWorld = bukkitBlock.getWorld();
|
||||
if (!(bukkitWorld instanceof CraftWorld)) {
|
||||
bukkitWorld = Bukkit.getWorld(bukkitWorld.getUID());
|
||||
}
|
||||
if (!(bukkitWorld instanceof CraftWorld)) {
|
||||
Exception exception = new IllegalStateException("AnySilentContainer access attempted on an unknown world!");
|
||||
OpenInv.getPlugin(OpenInv.class).getLogger().log(Level.WARNING, exception.getMessage(), exception);
|
||||
return false;
|
||||
}
|
||||
|
||||
final World world = ((CraftWorld) bukkitWorld).getHandle();
|
||||
final BlockPosition blockPosition = new BlockPosition(bukkitBlock.getX(), bukkitBlock.getY(), bukkitBlock.getZ());
|
||||
// isLargeVoxelShape
|
||||
return world.getType(blockPosition).d();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateContainer(
|
||||
@NotNull final Player bukkitPlayer,
|
||||
|
@@ -16,7 +16,7 @@
|
||||
#
|
||||
|
||||
# TODO FIGURE OUT AND REMOVE WHEN LESS STRESS
|
||||
hacky_versions=("1.16.5-R0.1-SNAPSHOT" "1.17-R0.1-SNAPSHOT")
|
||||
hacky_versions=("1.16.5-R0.1-SNAPSHOT" "1.17.1-R0.1-SNAPSHOT")
|
||||
for hacky_version in "${hacky_versions[@]}"; do
|
||||
echo "$hacky_version"
|
||||
done
|
||||
|
Reference in New Issue
Block a user