mirror of
https://github.com/EngineHub/WorldEdit.git
synced 2025-03-07 13:48:00 +08:00
[Forge] 1.20
This commit is contained in:
parent
a7ae8a9622
commit
4f75106857
@ -52,7 +52,7 @@
|
||||
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.32.0")
|
||||
implementation("org.spongepowered:spongegradle-plugin-development:2.0.2")
|
||||
implementation("org.spongepowered:vanillagradle:0.2.1-20220619.210040-41")
|
||||
implementation("net.minecraftforge.gradle:ForgeGradle:6.0.4")
|
||||
implementation("net.minecraftforge.gradle:ForgeGradle:6.0.6")
|
||||
implementation("net.fabricmc:fabric-loom:$loomVersion")
|
||||
implementation("net.fabricmc:sponge-mixin:$mixinVersion")
|
||||
implementation("org.enginehub.gradle:gradle-codecov-plugin:0.2.0")
|
||||
|
@ -12,11 +12,11 @@
|
||||
applyPlatformAndCoreConfiguration(javaRelease = 17)
|
||||
applyShadowConfiguration()
|
||||
|
||||
val minecraftVersion = "1.19.4"
|
||||
val minecraftVersion = "1.20"
|
||||
val nextMajorMinecraftVersion: String = minecraftVersion.split('.').let { (useless, major) ->
|
||||
"$useless.${major.toInt() + 1}"
|
||||
}
|
||||
val forgeVersion = "45.0.1"
|
||||
val forgeVersion = "46.0.1"
|
||||
|
||||
val apiClasspath = configurations.create("apiClasspath") {
|
||||
isCanBeResolved = true
|
||||
|
@ -22,7 +22,6 @@
|
||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||
import com.sk89q.worldedit.world.registry.PassthroughBlockMaterial;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.Material;
|
||||
import net.minecraft.world.level.material.PushReaction;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -34,53 +33,54 @@
|
||||
*/
|
||||
public class ForgeBlockMaterial extends PassthroughBlockMaterial {
|
||||
|
||||
private final Material delegate;
|
||||
private final BlockState block;
|
||||
|
||||
public ForgeBlockMaterial(Material delegate, BlockState block, @Nullable BlockMaterial secondary) {
|
||||
public ForgeBlockMaterial(BlockState block, @Nullable BlockMaterial secondary) {
|
||||
super(secondary);
|
||||
this.delegate = delegate;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAir() {
|
||||
return delegate == Material.AIR || super.isAir();
|
||||
return block.isAir() || super.isAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaque() {
|
||||
return delegate.isSolidBlocking();
|
||||
return block.canOcclude();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean isLiquid() {
|
||||
return delegate.isLiquid();
|
||||
return block.liquid();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean isSolid() {
|
||||
return delegate.isSolid();
|
||||
return block.isSolid();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFragileWhenPushed() {
|
||||
return delegate.getPushReaction() == PushReaction.DESTROY;
|
||||
return block.getPistonPushReaction() == PushReaction.DESTROY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUnpushable() {
|
||||
return delegate.getPushReaction() == PushReaction.BLOCK;
|
||||
return block.getPistonPushReaction() == PushReaction.BLOCK;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean isMovementBlocker() {
|
||||
return delegate.blocksMotion();
|
||||
return block.blocksMotion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBurnable() {
|
||||
return delegate.isFlammable();
|
||||
return block.ignitedByLava();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -90,7 +90,7 @@ public boolean isToolRequired() {
|
||||
|
||||
@Override
|
||||
public boolean isReplacedDuringPlacement() {
|
||||
return delegate.isReplaceable();
|
||||
return block.canBeReplaced();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public BlockMaterial getMaterial(BlockType blockType) {
|
||||
}
|
||||
return materialMap.computeIfAbsent(
|
||||
block.defaultBlockState(),
|
||||
s -> new ForgeBlockMaterial(s.getMaterial(), s, super.getMaterial(blockType))
|
||||
s -> new ForgeBlockMaterial(s, super.getMaterial(blockType))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -70,7 +70,7 @@ public Location getLocation() {
|
||||
float yaw = entity.getYRot();
|
||||
float pitch = entity.getXRot();
|
||||
|
||||
return new Location(ForgeAdapter.adapt((ServerLevel) entity.level), position, yaw, pitch);
|
||||
return new Location(ForgeAdapter.adapt((ServerLevel) entity.level()), position, yaw, pitch);
|
||||
} else {
|
||||
return new Location(NullWorld.getInstance());
|
||||
}
|
||||
@ -86,7 +86,7 @@ public boolean setLocation(Location location) {
|
||||
public Extent getExtent() {
|
||||
net.minecraft.world.entity.Entity entity = entityRef.get();
|
||||
if (entity != null) {
|
||||
return ForgeAdapter.adapt((ServerLevel) entity.level);
|
||||
return ForgeAdapter.adapt((ServerLevel) entity.level());
|
||||
} else {
|
||||
return NullWorld.getInstance();
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ public BaseEntity getState() {
|
||||
public Location getLocation() {
|
||||
Vector3 position = Vector3.at(this.player.getX(), this.player.getY(), this.player.getZ());
|
||||
return new Location(
|
||||
ForgeWorldEdit.inst.getWorld((ServerLevel) this.player.level),
|
||||
ForgeWorldEdit.inst.getWorld(this.player.serverLevel()),
|
||||
position,
|
||||
this.player.getYRot(),
|
||||
this.player.getXRot());
|
||||
@ -113,12 +113,12 @@ public boolean setLocation(Location location) {
|
||||
location.getYaw(), location.getPitch()
|
||||
);
|
||||
// This may be false if the teleport was cancelled by a mod
|
||||
return this.player.getLevel() == level;
|
||||
return this.player.serverLevel() == level;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return ForgeWorldEdit.inst.getWorld((ServerLevel) this.player.level);
|
||||
return ForgeWorldEdit.inst.getWorld(this.player.serverLevel());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -340,7 +340,8 @@ private void doRegen(Region region, Extent extent, RegenOptions options) throws
|
||||
// No spawners are needed for this world.
|
||||
ImmutableList.of(),
|
||||
// This controls ticking, we don't need it so set it to false.
|
||||
false
|
||||
false,
|
||||
originalWorld.getRandomSequences()
|
||||
)) {
|
||||
regenForWorld(region, extent, serverWorld, options);
|
||||
|
||||
@ -465,7 +466,11 @@ public void fixAfterFastMode(Iterable<BlockVector2> chunks) {
|
||||
public void fixLighting(Iterable<BlockVector2> chunks) {
|
||||
ServerLevel world = getWorld();
|
||||
for (BlockVector2 chunk : chunks) {
|
||||
world.getChunkSource().getLightEngine().retainData(new ChunkPos(chunk.getBlockX(), chunk.getBlockZ()), true);
|
||||
// Fetch the chunk after light initialization at least
|
||||
// We'll be doing a full relight anyways, so we don't need to be LIGHT yet
|
||||
world.getChunkSource().getLightEngine().lightChunk(world.getChunk(
|
||||
chunk.getBlockX(), chunk.getBlockZ(), ChunkStatus.INITIALIZE_LIGHT
|
||||
), false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -279,13 +279,13 @@ public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
&& lcb.getUseItem() == Event.Result.DENY;
|
||||
boolean isRightDeny = event instanceof PlayerInteractEvent.RightClickBlock rcb
|
||||
&& rcb.getUseItem() == Event.Result.DENY;
|
||||
if (isLeftDeny || isRightDeny || event.getEntity().level.isClientSide || event.getHand() == InteractionHand.OFF_HAND) {
|
||||
if (isLeftDeny || isRightDeny || event.getEntity().level().isClientSide || event.getHand() == InteractionHand.OFF_HAND) {
|
||||
return;
|
||||
}
|
||||
|
||||
WorldEdit we = WorldEdit.getInstance();
|
||||
ForgePlayer player = adaptPlayer((ServerPlayer) event.getEntity());
|
||||
ForgeWorld world = getWorld((ServerLevel) event.getEntity().level);
|
||||
ForgeWorld world = getWorld((ServerLevel) event.getEntity().level());
|
||||
Direction direction = ForgeAdapter.adaptEnumFacing(event.getFace());
|
||||
|
||||
if (event instanceof PlayerInteractEvent.LeftClickEmpty) {
|
||||
@ -323,7 +323,7 @@ public void onCommandEvent(CommandEvent event) throws CommandSyntaxException {
|
||||
if (!(parseResults.getContext().getSource().getEntity() instanceof ServerPlayer player)) {
|
||||
return;
|
||||
}
|
||||
if (player.level.isClientSide) {
|
||||
if (player.level().isClientSide) {
|
||||
return;
|
||||
}
|
||||
if (parseResults.getContext().getCommand() != CommandWrapper.FAKE_COMMAND) {
|
||||
|
@ -26,7 +26,7 @@
|
||||
import com.sk89q.worldedit.util.SideEffect;
|
||||
import com.sk89q.worldedit.util.SideEffectSet;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ChunkHolder;
|
||||
import net.minecraft.server.level.FullChunkStatus;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
@ -115,7 +115,7 @@ public void notifyBlockUpdate(LevelChunk chunk, BlockPos position, BlockState ol
|
||||
|
||||
@Override
|
||||
public boolean isChunkTicking(LevelChunk chunk) {
|
||||
return chunk.getFullStatus().isOrAfter(ChunkHolder.FullChunkStatus.TICKING);
|
||||
return chunk.getFullStatus().isOrAfter(FullChunkStatus.BLOCK_TICKING);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -162,5 +162,6 @@ public void updateNeighbors(BlockPos pos, BlockState oldState, BlockState newSta
|
||||
@Override
|
||||
public void onBlockStateChange(BlockPos pos, BlockState oldState, BlockState newState) {
|
||||
getWorld().onBlockStateChange(pos, oldState, newState);
|
||||
newState.onBlockStateChange(getWorld(), pos, oldState);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user