-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
116 additions
and
12 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
plugins { | ||
id("io.papermc.paperweight.userdev") version "1.5.10" // Check for new versions at https://plugins.gradle.org/plugin/io.papermc.paperweight.userdev | ||
} | ||
|
||
dependencies { | ||
paperweight.paperDevBundle("1.17.1-R0.1-SNAPSHOT") | ||
compileOnly(project(":api")) | ||
} | ||
|
||
tasks { | ||
assemble { | ||
dependsOn(reobfJar) | ||
} | ||
compileJava { | ||
options.encoding = "UTF-8" | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
nms/v1_17_R1/src/main/java/fr/euphyllia/skyllia/utils/nms/v1_17_R1/PlayerNMS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package fr.euphyllia.skyllia.utils.nms.v1_17_R1; | ||
|
||
import fr.euphyllia.skyllia.api.SkylliaAPI; | ||
import fr.euphyllia.skyllia.api.utils.scheduler.SchedulerTask; | ||
import fr.euphyllia.skyllia.api.utils.scheduler.model.SchedulerType; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class PlayerNMS extends fr.euphyllia.skyllia.api.utils.nms.PlayerNMS { | ||
|
||
public void setOwnWorldBorder(JavaPlugin main, Player player, @NotNull Location centerBorder, double borderSize, int warningBlocks, int warningTime) { | ||
SkylliaAPI.getSchedulerTask().getScheduler(SchedulerTask.SchedulerSoft.MINECRAFT) | ||
.execute(SchedulerType.ENTITY, player, schedulerTask -> { | ||
final net.minecraft.world.level.border.WorldBorder worldBorderPlayer = new net.minecraft.world.level.border.WorldBorder(); | ||
worldBorderPlayer.world = ((org.bukkit.craftbukkit.v1_17_R1.CraftWorld) centerBorder.getWorld()).getHandle(); | ||
worldBorderPlayer.setCenter(centerBorder.getBlockX(), centerBorder.getBlockZ()); | ||
worldBorderPlayer.setSize(borderSize); | ||
worldBorderPlayer.setWarningBlocks(warningBlocks); | ||
worldBorderPlayer.setWarningTime(warningTime); | ||
final net.minecraft.network.protocol.game.ClientboundInitializeBorderPacket updateWorldBorderPacket = new net.minecraft.network.protocol.game.ClientboundInitializeBorderPacket(worldBorderPlayer); | ||
org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer craftPlayer = ((org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) player); | ||
craftPlayer.getHandle().connection.send(updateWorldBorderPacket); | ||
}); | ||
} | ||
|
||
|
||
} |
47 changes: 47 additions & 0 deletions
47
nms/v1_17_R1/src/main/java/fr/euphyllia/skyllia/utils/nms/v1_17_R1/WorldNMS.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package fr.euphyllia.skyllia.utils.nms.v1_17_R1; | ||
|
||
import fr.euphyllia.skyllia.api.skyblock.model.Position; | ||
import fr.euphyllia.skyllia.api.world.WorldFeedback; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.ChunkPos; | ||
import net.minecraft.world.level.GameType; | ||
import org.bukkit.GameMode; | ||
import org.bukkit.World; | ||
import org.bukkit.WorldCreator; | ||
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; | ||
|
||
|
||
public class WorldNMS extends fr.euphyllia.skyllia.api.utils.nms.WorldNMS { | ||
|
||
static GameType getGameType(GameMode gameMode) { | ||
return switch (gameMode) { | ||
case SURVIVAL -> GameType.SURVIVAL; | ||
case CREATIVE -> GameType.CREATIVE; | ||
case ADVENTURE -> GameType.ADVENTURE; | ||
case SPECTATOR -> GameType.SPECTATOR; | ||
}; | ||
} | ||
|
||
@Override | ||
public WorldFeedback.FeedbackWorld createWorld(WorldCreator creator) { | ||
throw new UnsupportedOperationException(); | ||
} | ||
|
||
@Override | ||
public void resetChunk(World craftWorld, Position position) { | ||
final ServerLevel serverLevel = ((CraftWorld) craftWorld).getHandle(); | ||
io.papermc.paper.util.TickThread.ensureTickThread("Cannot regenerate chunk asynchronously"); | ||
final net.minecraft.server.level.ServerChunkCache serverChunkCache = serverLevel.getChunkSource(); | ||
final ChunkPos chunkPos = new ChunkPos(position.x(), position.z()); | ||
final net.minecraft.world.level.chunk.LevelChunk levelChunk = serverChunkCache.getChunk(chunkPos.x, chunkPos.z, true); | ||
final Iterable<BlockPos> blockPosIterable = BlockPos.betweenClosed(chunkPos.getMinBlockX(), serverLevel.getMinBuildHeight(), chunkPos.getMinBlockZ(), chunkPos.getMaxBlockX(), serverLevel.getMaxBuildHeight() - 1, chunkPos.getMaxBlockZ()); | ||
for (final BlockPos blockPos : blockPosIterable) { | ||
levelChunk.removeBlockEntity(blockPos); | ||
serverLevel.setBlock(blockPos, net.minecraft.world.level.block.Blocks.AIR.defaultBlockState(), 16); | ||
} | ||
for (final BlockPos blockPos : blockPosIterable) { // Fix memory issue client | ||
serverChunkCache.blockChanged(blockPos); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters