Skip to content

Commit

Permalink
Merge branch 'EngineHub:version/7.3.x' into version/7.3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Euphillya authored Nov 26, 2024
2 parents 3deefc0 + 039380b commit 66556ff
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 32 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
7.3.9 (beta)
- Added support for 1.21.3.
7.3.9
- Added support for 1.21.3
- Fixed tools not behaving correctly when mods embed worlds in worlds

7.3.8
- [Bukkit] Update 1.21.1 adapter for Spigot breakage
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.sk89q.worldedit
version=7.3.9-SNAPSHOT
version=7.3.10-SNAPSHOT

org.gradle.jvmargs=-Xmx1500M
org.gradle.parallel=true
Expand Down
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ piston = "0.5.10"
autoValue = "1.10.4"
antlr = "4.13.1"

fabric-api = "0.106.1+1.21.3"
fabric-api = "0.109.0+1.21.3"

neogradle = "7.0.165"
neogradle = "7.0.171"
neoforge-minecraft = "1.21.3"

sponge-minecraft = "1.21.3"
Expand All @@ -22,7 +22,7 @@ sponge-api-major = "13"

# https://parchmentmc.org/docs/getting-started; note that we use older MC versions some times which is OK
parchment-minecraft = "1.21"
parchment-mappings = "2024.07.28"
parchment-mappings = "2024.11.10"

# https://repo.spongepowered.org/service/rest/repository/browse/maven-public/org/spongepowered/vanillagradle/
sponge-vanillagradle = "0.2.1-20241006.183638-89"
Expand All @@ -32,8 +32,8 @@ minimumAsm = "9.7"
minimumJdependency = "2.10"
minimumTinyRemapper = "0.8.11"

lang-worldeditBase = "7.3.7"
lang-version = "1589"
lang-worldeditBase = "7.3.9"
lang-version = "1642"

[libraries]
neogradle-neoform = { module = "net.neoforged.gradle:neoform", version.ref = "neogradle" }
Expand All @@ -48,7 +48,7 @@ jfrog-buildinfo = "org.jfrog.buildinfo:build-info-extractor-gradle:5.2.0"
# https://maven.fabricmc.net/net/fabricmc/sponge-mixin/
fabric-mixin = "net.fabricmc:sponge-mixin:0.15.3+mixin.0.8.7"

paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.4"
paperweight = "io.papermc.paperweight.userdev:io.papermc.paperweight.userdev.gradle.plugin:1.7.5"

linBus-bom = "org.enginehub.lin-bus:lin-bus-bom:0.2.0"
linBus-common.module = "org.enginehub.lin-bus:lin-bus-common"
Expand Down Expand Up @@ -92,7 +92,7 @@ fabric-minecraft = "com.mojang:minecraft:1.21.3"
fabric-loader = "net.fabricmc:fabric-loader:0.16.7"
fabric-permissions-api = "me.lucko:fabric-permissions-api:0.3.1"

neoforge = "net.neoforged:neoforge:21.3.2-beta"
neoforge = "net.neoforged:neoforge:21.3.40-beta"

# Mojang-provided libraries, CHECK AGAINST MINECRAFT for versions
guava = "com.google.guava:guava:32.1.3-jre!!"
Expand Down
2 changes: 1 addition & 1 deletion worldedit-bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: WorldEdit
main: com.sk89q.worldedit.bukkit.WorldEditPlugin
version: "${internalVersion}-Folia"
load: STARTUP
api-version: 1.13
api-version: 1.20
softdepend: [Vault]
author: EngineHub
website: https://enginehub.org/worldedit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ public boolean canUse(Actor player) {

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
World world = BlockTool.requireWorld(clicked);
int ox = clicked.getBlockX();
int oy = clicked.getBlockY();
int oz = clicked.getBlockZ();
BlockType initialType = clicked.getExtent().getBlock(clicked.toVector().toBlockPoint()).getBlockType();
BlockType initialType = world.getBlock(clicked.toVector().toBlockPoint()).getBlockType();

if (initialType.getMaterial().isAir()) {
return false;
Expand All @@ -67,7 +68,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
return false;
}

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);

try {
Expand All @@ -81,8 +82,9 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla

editSession.setBlock(pos, BlockTypes.AIR.getDefaultState());

((World) clicked.getExtent()).queueBlockBreakEffect(server, pos, initialType,
clicked.toVector().toBlockPoint().distanceSq(pos));
world.queueBlockBreakEffect(
server, pos, initialType, clicked.toVector().toBlockPoint().distanceSq(pos)
);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean canUse(Actor player) {
private boolean handleCycle(LocalConfiguration config, Player player, LocalSession session,
Location clicked, boolean forward) {

World world = (World) clicked.getExtent();
World world = BlockTool.requireWorld(clicked);

BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
BaseBlock block = world.getFullBlock(blockPoint);
Expand Down Expand Up @@ -87,7 +87,7 @@ private boolean handleCycle(LocalConfiguration config, Player player, LocalSessi
Property<Object> objProp = (Property<Object>) currentProperty;
BaseBlock newBlock = block.with(objProp, currentProperty.getValues().get(index));

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
editSession.disableBuffering();

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean canUse(Actor player) {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
BlockBag bag = session.getBlockBag(player);

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
try {
editSession.disableBuffering();
BlockVector3 position = clicked.toVector().toBlockPoint();
Expand All @@ -77,7 +77,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla

@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
BaseBlock targetBlock = clicked.getExtent().getFullBlock(clicked.toVector().toBlockPoint());

if (targetBlock != null) {
pattern = targetBlock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package com.sk89q.worldedit.command.tool;

import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.entity.Player;
Expand All @@ -27,11 +28,41 @@
import com.sk89q.worldedit.internal.util.NonAbstractForCompatibility;
import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;

import javax.annotation.Nullable;

public interface BlockTool extends Tool {

/**
* Helper method to require the world that should be used for a tool action.
*
* @param clicked the location that was clicked
* @return the world to use
*/
static World requireWorld(Location clicked) {
if (!(clicked.getExtent() instanceof World world)) {
throw new IllegalArgumentException("Location is not in a world: " + clicked);
}
return world;
}

/**
* Helper method to create an {@link EditSession} for a tool action.
*
* @param player the player
* @param clicked the location that was clicked
*/
static EditSession createEditSession(Player player, LocalSession session, Location clicked) {
World overrideToRestore = session.getWorldOverride();
session.setWorldOverride(BlockTool.requireWorld(clicked));
try {
return session.createEditSession(player);
} finally {
session.setWorldOverride(overrideToRestore);
}
}

/**
* Perform the primary action of this tool.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ public boolean actPrimary(Platform server, LocalConfiguration config,
Player player, LocalSession session, Location clicked,
@Nullable Direction face) {

final World world = (World) clicked.getExtent();
final World world = BlockTool.requireWorld(clicked);
final BlockState state = world.getBlock(clicked.toVector().toBlockPoint());

if (!isTreeBlock(state.getBlockType())) {
player.printError(TranslatableComponent.of("worldedit.tool.deltree.not-tree"));
return true;
}

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
try {
final Set<BlockVector3> blockSet = bfs(world, clicked.toVector().toBlockPoint());
if (blockSet == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public boolean canUse(Actor player) {

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
World world = (World) clicked.getExtent();
World world = BlockTool.requireWorld(clicked);

BlockVector3 origin = clicked.toVector().toBlockPoint();
BlockType initialType = world.getBlock(origin).getBlockType();
Expand All @@ -72,7 +72,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
return true;
}

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
try {
recurse(editSession, origin, origin, range, initialType, new HashSet<>());
} catch (MaxChangedBlocksException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public boolean canUse(Actor player) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {

World world = (World) clicked.getExtent();
World world = BlockTool.requireWorld(clicked);
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
BaseBlock block = world.getFullBlock(blockPoint);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public boolean canUse(Actor player) {

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
World world = (World) clicked.getExtent();
World world = BlockTool.requireWorld(clicked);

BlockVector3 origin = clicked.toVector().toBlockPoint();
BlockType initialType = world.getBlock(origin).getBlockType();
Expand All @@ -70,7 +70,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
return false;
}

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeManyDrop);

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class SelectionWand implements DoubleActionBlockTool {

@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
RegionSelector selector = session.getRegionSelector(BlockTool.requireWorld(clicked));
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();

if (selector.selectPrimary(blockPoint, ActorSelectorLimits.forActor(player))) {
Expand All @@ -47,7 +47,7 @@ public boolean actSecondary(Platform server, LocalConfiguration config, Player p

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
RegionSelector selector = session.getRegionSelector(player.getWorld());
RegionSelector selector = session.getRegionSelector(BlockTool.requireWorld(clicked));
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();

if (selector.selectSecondary(blockPoint, ActorSelectorLimits.forActor(player))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public boolean canUse(Actor player) {

@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
World world = (World) clicked.getExtent();
World world = BlockTool.requireWorld(clicked);
BlockVector3 blockPoint = clicked.toVector().toBlockPoint();
final BlockType blockType = world.getBlock(blockPoint).getBlockType();
if (blockType == BlockTypes.BEDROCK && !player.canDestroyBedrock()) {
return false;
}

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
editSession.getSurvivalExtent().setToolUse(config.superPickaxeDrop);
editSession.setBlock(blockPoint, BlockTypes.AIR.getDefaultState());
} catch (MaxChangedBlocksException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public boolean actPrimary(Platform server, LocalConfiguration config, Player pla
}
BlockBag bag = session.getBlockBag(player);

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
BlockStateHolder<?> block = editSession.getFullBlock(clicked.toVector().toBlockPoint());

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public boolean canUse(Actor player) {
@Override
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {

try (EditSession editSession = session.createEditSession(player)) {
try (EditSession editSession = BlockTool.createEditSession(player, session, clicked)) {
try {
boolean successful = false;

Expand Down

0 comments on commit 66556ff

Please sign in to comment.