SteamWar/BauSystem2.0
Archiviert
12
0

QOL #203

Zusammengeführt
YoyoNow hat 44 Commits von QOL nach master 2023-10-06 14:59:48 +02:00 zusammengeführt
Nur Änderungen aus Commit c0b40d00a5 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -86,7 +86,6 @@ public class PlaceItemUtils {
* @param playSound enables sound of placing * @param playSound enables sound of placing
*/ */
public PlaceItemResult placeItem(Player player, ItemStack itemStack, Block against, BlockFace againstSide, EquipmentSlot hand, boolean force, boolean applyPhysics, boolean rotateAway, boolean playSound) { public PlaceItemResult placeItem(Player player, ItemStack itemStack, Block against, BlockFace againstSide, EquipmentSlot hand, boolean force, boolean applyPhysics, boolean rotateAway, boolean playSound) {
// TODO: Place inside of player
// If the ItemStack is null or air we cannot place it // If the ItemStack is null or air we cannot place it
if (itemStack == null) return PlaceItemResult.NO_ITEM_HELD; if (itemStack == null) return PlaceItemResult.NO_ITEM_HELD;
if (itemStack.getType().isAir()) return PlaceItemResult.NO_ITEM_HELD; if (itemStack.getType().isAir()) return PlaceItemResult.NO_ITEM_HELD;
@ -248,6 +247,23 @@ public class PlaceItemUtils {
worldAccessor.set(blockState, blockLocation.getWorld()); worldAccessor.set(blockState, blockLocation.getWorld());
} }
if (blockData.getMaterial().isSolid()) {
for (Player p : Bukkit.getOnlinePlayers()) {
Location min = p.getLocation().add(-0.3, 0, -0.3);
Location max = p.getLocation().add(0.3, p.isSneaking() ? 1.5 : 1.8, 0.3);
Location blockmin = block.getLocation();
Location blockmax = block.getLocation().add(1.0, 1.0, 1.0);
if (
max.getX() <= blockmin.getX() || min.getX() >= blockmax.getX() ||
max.getY() <= blockmin.getY() || min.getY() >= blockmax.getY() ||
max.getZ() <= blockmin.getZ() || min.getZ() >= blockmax.getZ()
) {
return PlaceItemResult.NO_PLACE_INSIDE_PLAYER;
}
}
}
// Set the generated BlockData to the BlockState and update the world without physics // Set the generated BlockData to the BlockState and update the world without physics
blockState.setBlockData(blockData); blockState.setBlockData(blockData);
blockState.update(true, false); blockState.update(true, false);
@ -471,6 +487,7 @@ public class PlaceItemUtils {
NO_BUILD(false), NO_BUILD(false),
NO_PLACE(false), NO_PLACE(false),
NO_DOUBLE_HIGH_BLOCK_SPACE(false), NO_DOUBLE_HIGH_BLOCK_SPACE(false),
NO_PLACE_INSIDE_PLAYER(false),
SUCCESS(true), SUCCESS(true),
; ;