mirror of
https://github.com/BG-Software-LLC/WildLoaders.git
synced 2024-11-21 11:46:46 +01:00
Removed obfuscated nms in favor of mojang-mappings jars
This commit is contained in:
parent
0094475513
commit
4d91255bac
@ -35,7 +35,6 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.bgsoftware.common.reflection:ReflectionUtils:latest"
|
||||
compileOnly "com.bgsoftware.common.remaps:RemapsChecker:1.0.0"
|
||||
}
|
||||
|
||||
task checkDebug() {
|
||||
@ -66,8 +65,6 @@ dependencies {
|
||||
|
||||
implementation 'com.bgsoftware.common.reflection:ReflectionUtils:latest'
|
||||
implementation 'com.bgsoftware.common.config:CommentedConfiguration:1.0.3'
|
||||
implementation 'com.bgsoftware.common.mappings:MappingsChecker:1.0.1'
|
||||
implementation 'com.bgsoftware.common.remaps:RemapsChecker:1.0.0'
|
||||
|
||||
// Spigot jars
|
||||
compileOnly "org.spigotmc:v1_8_R3:latest"
|
||||
@ -107,6 +104,8 @@ shadowJar {
|
||||
exclude archiveName
|
||||
}
|
||||
|
||||
exclude '*exclude.jar'
|
||||
|
||||
destinationDir = file("./target/")
|
||||
from sourceSets.getByName("main").output
|
||||
configurations = [project.configurations.getByName("runtimeClasspath")]
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,9 +1,18 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
gradlePluginPortal()
|
||||
maven { url "https://repo.papermc.io/repository/maven-public/" }
|
||||
}
|
||||
}
|
||||
|
||||
rootProject.name = 'WildLoaders'
|
||||
|
||||
include 'API'
|
||||
include 'Hook_EpicSpawners6'
|
||||
include 'Hook_EpicSpawners7'
|
||||
include 'Hook_FactionsUUID'
|
||||
include 'Hook_FactionsX'
|
||||
include 'Hook_Lands'
|
||||
include 'Hook_MassiveFactions'
|
||||
include 'Hook_SuperiorSkyblock'
|
||||
include 'v1_7_R4'
|
||||
@ -11,9 +20,8 @@ include 'v1_8_R3'
|
||||
include 'v1_12_R1'
|
||||
include 'v1_16_R3'
|
||||
include 'v1_17_R1'
|
||||
include 'v1_18_R1'
|
||||
include 'Hook_EpicSpawners7'
|
||||
include 'v1_18_R2'
|
||||
include 'Hook_Lands'
|
||||
include 'v1_19_R1'
|
||||
|
||||
include 'v1181'
|
||||
include 'v1182'
|
||||
include 'v1191'
|
||||
include 'v1192'
|
||||
include 'v119'
|
@ -1,6 +1,6 @@
|
||||
package com.bgsoftware.wildloaders;
|
||||
|
||||
import com.bgsoftware.common.mappings.MappingsChecker;
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.WildLoaders;
|
||||
import com.bgsoftware.wildloaders.api.WildLoadersAPI;
|
||||
import com.bgsoftware.wildloaders.command.CommandsHandler;
|
||||
@ -14,13 +14,16 @@ import com.bgsoftware.wildloaders.listeners.ChunksListener;
|
||||
import com.bgsoftware.wildloaders.listeners.PlayersListener;
|
||||
import com.bgsoftware.wildloaders.metrics.Metrics;
|
||||
import com.bgsoftware.wildloaders.nms.NMSAdapter;
|
||||
import com.bgsoftware.common.remaps.TestRemaps;
|
||||
import com.bgsoftware.wildloaders.utils.Pair;
|
||||
import com.bgsoftware.wildloaders.utils.ServerVersion;
|
||||
import com.bgsoftware.wildloaders.utils.database.Database;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.UnsafeValues;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
||||
|
||||
@ -93,35 +96,46 @@ public final class WildLoadersPlugin extends JavaPlugin implements WildLoaders {
|
||||
}
|
||||
|
||||
private boolean loadNMSAdapter() {
|
||||
String version = getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
try {
|
||||
nmsAdapter = (NMSAdapter) Class.forName(String.format("com.bgsoftware.wildloaders.nms.%s.NMSAdapter", version)).newInstance();
|
||||
String version = null;
|
||||
|
||||
String mappingVersionHash = nmsAdapter.getMappingsHash();
|
||||
if (ServerVersion.isLessThan(ServerVersion.v1_18)) {
|
||||
version = getServer().getClass().getPackage().getName().split("\\.")[3];
|
||||
} else {
|
||||
ReflectMethod<Integer> getDataVersion = new ReflectMethod<>(UnsafeValues.class, "getDataVersion");
|
||||
int dataVersion = getDataVersion.invoke(Bukkit.getUnsafe());
|
||||
|
||||
if (mappingVersionHash != null && !MappingsChecker.checkMappings(mappingVersionHash, version, error -> {
|
||||
log("&cFailed to retrieve allowed mappings for your server, skipping...");
|
||||
return true;
|
||||
})) {
|
||||
log("WildStacker does not support your version mappings... Please contact @Ome_R");
|
||||
log("Your mappings version: " + mappingVersionHash);
|
||||
return false;
|
||||
List<Pair<Integer, String>> versions = Arrays.asList(
|
||||
new Pair<>(2865, "v1181"),
|
||||
new Pair<>(2975, "v1182"),
|
||||
new Pair<>(3105, "v119"),
|
||||
new Pair<>(3117, "v1191"),
|
||||
new Pair<>(3120, "v1192")
|
||||
);
|
||||
|
||||
for (Pair<Integer, String> versionData : versions) {
|
||||
if (dataVersion <= versionData.first) {
|
||||
version = versionData.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (version == null) {
|
||||
log("Data version: " + dataVersion);
|
||||
}
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) {
|
||||
log("Couldn't load up with an adapter " + version + ". Please contact @Ome_R");
|
||||
return false;
|
||||
}
|
||||
|
||||
File mappingsFile = new File("mappings");
|
||||
if (mappingsFile.exists()) {
|
||||
if (version != null) {
|
||||
try {
|
||||
TestRemaps.testRemapsForClassesInPackage(mappingsFile,
|
||||
plugin.getClassLoader(), "com.bgsoftware.wildloaders.nms." + version);
|
||||
nmsAdapter = (NMSAdapter) Class.forName(String.format("com.bgsoftware.wildloaders.nms.%s.NMSAdapter", version)).newInstance();
|
||||
return true;
|
||||
} catch (Exception error) {
|
||||
error.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
log("&cThe plugin doesn't support your minecraft version.");
|
||||
log("&cPlease try a different version.");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -6,14 +6,10 @@ import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface NMSAdapter {
|
||||
|
||||
@Nullable
|
||||
String getMappingsHash();
|
||||
|
||||
String getTag(ItemStack itemStack, String key, String def);
|
||||
|
||||
ItemStack setTag(ItemStack itemStack, String key, String value);
|
||||
|
13
src/main/java/com/bgsoftware/wildloaders/utils/Pair.java
Normal file
13
src/main/java/com/bgsoftware/wildloaders/utils/Pair.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.bgsoftware.wildloaders.utils;
|
||||
|
||||
public final class Pair<E1, E2> {
|
||||
|
||||
public final E1 first;
|
||||
public final E2 second;
|
||||
|
||||
public Pair(E1 first, E2 second) {
|
||||
this.first = first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
}
|
34
v1181/build.gradle
Normal file
34
v1181/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.18.1-R0.1-SNAPSHOT")
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "${project.name}-exclude.jar"
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
tasks {
|
||||
reobfJar {
|
||||
File outputFile = new File(parent.projectDir, "archive/reobf/${project.name}.jar")
|
||||
outputJar.set(layout.buildDirectory.file(outputFile.getPath()))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_18') && !Boolean.valueOf(project.findProperty("nms.compile_v1_18").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1181;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(ServerPlayerGameMode.class,
|
||||
1, GameType.class, GameType.class);
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPCImpl(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
|
||||
|
||||
this.serverLevel = getLevel();
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.serverLevel);
|
||||
moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.serverLevel.addNewPlayer(this);
|
||||
|
||||
super.setBoundingBox(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.serverLevel.removePlayerImmediately(this, RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
super(PacketFlow.SERVERBOUND);
|
||||
this.channel = new DummyChannel();
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyServerGamePacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
|
||||
DummyServerGamePacketListenerImpl(MinecraftServer minecraftServer, ServerPlayer serverPlayer) {
|
||||
super(minecraftServer, new DummyConnection(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleContainerClick(ServerboundContainerClickPacket containerClickPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket movePlayerPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket signUpdatePacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(ServerboundPlayerActionPacket playerActionPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket useItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket setCarriedItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(ServerboundChatPacket chatPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1181;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage;
|
||||
|
||||
public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
private static final AABB EMPTY_BOUND = new AABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public EntityHologram(ServerLevel serverLevel, double x, double y, double z) {
|
||||
super(serverLevel, x, y, z);
|
||||
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setShowArms(false);
|
||||
setNoGravity(true);
|
||||
setNoBasePlate(true);
|
||||
setMarker(true);
|
||||
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true); // Custom name visible
|
||||
super.setBoundingBox(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAsPassenger(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag saveWithoutId(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repositionEntityAfterLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(Component component) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand hand) {
|
||||
// Prevent stand being equipped
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(SoundEvent soundEvent, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1181;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1181.loader.ChunkLoaderBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 8) ? def : compoundTag.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putString(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 4) ? def : compoundTag.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putLong(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack bukkitItem, String texture) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
CompoundTag skullOwner = compoundTag.contains("SkullOwner") ?
|
||||
compoundTag.getCompound("SkullOwner") : new CompoundTag();
|
||||
|
||||
CompoundTag properties = new CompoundTag();
|
||||
ListTag textures = new ListTag();
|
||||
CompoundTag signature = new CompoundTag();
|
||||
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties);
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
compoundTag.put("SkullOwner", skullOwner);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPCImpl(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot create loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
ChunkLoaderBlockEntity ChunkLoaderBlockEntity = new ChunkLoaderBlockEntity(chunkLoader, serverLevel, blockPos);
|
||||
serverLevel.addBlockEntityTicker(ChunkLoaderBlockEntity.getTicker());
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = -1;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
|
||||
return ChunkLoaderBlockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity = ChunkLoaderBlockEntity.chunkLoaderBlockEntityMap.remove(chunkPosLong);
|
||||
|
||||
if (chunkLoaderBlockEntity != null) {
|
||||
chunkLoaderBlockEntity.holograms.forEach(EntityHologram::removeHologram);
|
||||
chunkLoaderBlockEntity.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle)
|
||||
serverLevel.levelEvent(null, 2001, blockPos, Block.getId(serverLevel.getBlockState(blockPos)));
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = 16;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
World bukkitWorld = location.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
|
||||
BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos);
|
||||
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity)
|
||||
spawnerBlockEntity.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.loader;
|
||||
package com.bgsoftware.wildloaders.nms.v1181.loader;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.EntityHolograms;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v1181.EntityHologram;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -20,34 +19,32 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TileEntityChunkLoader extends TileEntity implements ITileEntityChunkLoader {
|
||||
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
|
||||
|
||||
public static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
|
||||
public static final Map<Long, ChunkLoaderBlockEntity> chunkLoaderBlockEntityMap = new HashMap<>();
|
||||
|
||||
public final List<EntityHolograms> holograms = new ArrayList<>();
|
||||
public final List<EntityHologram> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
public final TileEntityChunkLoaderTicker ticker;
|
||||
public final BlockPosition tilePosition;
|
||||
private final World world;
|
||||
private final ChunkLoaderBlockEntityTicker ticker;
|
||||
private final ServerLevel serverLevel;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
public boolean removed = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntityType", name = "COMMAND_BLOCK", type = Remap.Type.FIELD, remappedName = "v")
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity", name = "setLevel", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition) {
|
||||
super(TileEntityTypes.v, blockPosition.getHandle(), world.getBlockStateNoMappings(blockPosition.getHandle()));
|
||||
public ChunkLoaderBlockEntity(ChunkLoader chunkLoader, ServerLevel serverLevel, BlockPos blockPos) {
|
||||
super(BlockEntityType.COMMAND_BLOCK, blockPos, serverLevel.getBlockState(blockPos));
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
this.ticker = new TileEntityChunkLoaderTicker(this);
|
||||
this.tilePosition = blockPosition;
|
||||
this.world = world;
|
||||
this.ticker = new ChunkLoaderBlockEntityTicker(this);
|
||||
this.blockPos = blockPos;
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
a(world.getHandle());
|
||||
setLevel(serverLevel);
|
||||
|
||||
loaderBlock = world.getBlockState(blockPosition.getHandle()).getBlock();
|
||||
loaderBlock = serverLevel.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
@ -64,36 +61,28 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
tileEntityChunkLoaderMap.put(ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this);
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
chunkLoaderBlockEntityMap.put(chunkPosLong, this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = this.tilePosition.getY() + 1;
|
||||
double currentY = blockPos.getY() + 1;
|
||||
for (int i = hologramLines.size(); i > 0; i--) {
|
||||
EntityHolograms hologram = new EntityHolograms(world.getHandle(),
|
||||
this.tilePosition.getX() + 0.5, currentY, this.tilePosition.getZ() + 0.5);
|
||||
EntityHologram hologram = new EntityHologram(serverLevel, blockPos.getX() + 0.5, currentY, blockPos.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
world.addFreshEntity(hologram);
|
||||
serverLevel.addFreshEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public TileEntityTypes<?> getType() {
|
||||
return super.u();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
if (chunkLoader.isNotActive() || this.world.getBlockState(this.tilePosition.getHandle()).getBlock() != loaderBlock) {
|
||||
if (chunkLoader.isNotActive() || this.serverLevel.getBlockState(this.blockPos).getBlock() != loaderBlock) {
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
@ -105,7 +94,7 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHolograms hologram = holograms.get(hologramsAmount - i);
|
||||
EntityHologram hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
@ -133,20 +122,16 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "r")
|
||||
@Override
|
||||
public boolean r() {
|
||||
return isRemoved();
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
return removed || super.r();
|
||||
return removed || super.isRemoved();
|
||||
}
|
||||
|
||||
private void updateName(EntityHolograms hologram, String line) {
|
||||
public ChunkLoaderBlockEntityTicker getTicker() {
|
||||
return ticker;
|
||||
}
|
||||
|
||||
private void updateName(EntityHologram hologram, String line) {
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
@ -0,0 +1,30 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1181.loader;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
public record ChunkLoaderBlockEntityTicker(
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity) implements TickingBlockEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
chunkLoaderBlockEntity.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return chunkLoaderBlockEntity.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return chunkLoaderBlockEntity.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return BlockEntityType.getKey(chunkLoaderBlockEntity.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
34
v1182/build.gradle
Normal file
34
v1182/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.18.2-R0.1-SNAPSHOT")
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "${project.name}-exclude.jar"
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
tasks {
|
||||
reobfJar {
|
||||
File outputFile = new File(parent.projectDir, "archive/reobf/${project.name}.jar")
|
||||
outputJar.set(layout.buildDirectory.file(outputFile.getPath()))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_18') && !Boolean.valueOf(project.findProperty("nms.compile_v1_18").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1182;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(ServerPlayerGameMode.class,
|
||||
1, GameType.class, GameType.class);
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPCImpl(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
|
||||
|
||||
this.serverLevel = getLevel();
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.serverLevel);
|
||||
moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.serverLevel.addNewPlayer(this);
|
||||
|
||||
super.setBoundingBox(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.serverLevel.removePlayerImmediately(this, RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
super(PacketFlow.SERVERBOUND);
|
||||
this.channel = new DummyChannel();
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyServerGamePacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
|
||||
DummyServerGamePacketListenerImpl(MinecraftServer minecraftServer, ServerPlayer serverPlayer) {
|
||||
super(minecraftServer, new DummyConnection(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleContainerClick(ServerboundContainerClickPacket containerClickPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket movePlayerPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket signUpdatePacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(ServerboundPlayerActionPacket playerActionPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket useItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket setCarriedItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(ServerboundChatPacket chatPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1182;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage;
|
||||
|
||||
public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
private static final AABB EMPTY_BOUND = new AABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public EntityHologram(ServerLevel serverLevel, double x, double y, double z) {
|
||||
super(serverLevel, x, y, z);
|
||||
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setShowArms(false);
|
||||
setNoGravity(true);
|
||||
setNoBasePlate(true);
|
||||
setMarker(true);
|
||||
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true); // Custom name visible
|
||||
super.setBoundingBox(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAsPassenger(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag saveWithoutId(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repositionEntityAfterLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(Component component) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand hand) {
|
||||
// Prevent stand being equipped
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(SoundEvent soundEvent, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1182;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1182.loader.ChunkLoaderBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 8) ? def : compoundTag.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putString(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 4) ? def : compoundTag.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putLong(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack bukkitItem, String texture) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
CompoundTag skullOwner = compoundTag.contains("SkullOwner") ?
|
||||
compoundTag.getCompound("SkullOwner") : new CompoundTag();
|
||||
|
||||
CompoundTag properties = new CompoundTag();
|
||||
ListTag textures = new ListTag();
|
||||
CompoundTag signature = new CompoundTag();
|
||||
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties);
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
compoundTag.put("SkullOwner", skullOwner);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPCImpl(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot create loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
ChunkLoaderBlockEntity ChunkLoaderBlockEntity = new ChunkLoaderBlockEntity(chunkLoader, serverLevel, blockPos);
|
||||
serverLevel.addBlockEntityTicker(ChunkLoaderBlockEntity.getTicker());
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = -1;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
|
||||
return ChunkLoaderBlockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity = ChunkLoaderBlockEntity.chunkLoaderBlockEntityMap.remove(chunkPosLong);
|
||||
|
||||
if (chunkLoaderBlockEntity != null) {
|
||||
chunkLoaderBlockEntity.holograms.forEach(EntityHologram::removeHologram);
|
||||
chunkLoaderBlockEntity.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle)
|
||||
serverLevel.levelEvent(null, 2001, blockPos, Block.getId(serverLevel.getBlockState(blockPos)));
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = 16;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
World bukkitWorld = location.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
|
||||
BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos);
|
||||
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity)
|
||||
spawnerBlockEntity.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.loader;
|
||||
package com.bgsoftware.wildloaders.nms.v1182.loader;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.EntityHolograms;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v1182.EntityHologram;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -20,34 +19,32 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TileEntityChunkLoader extends TileEntity implements ITileEntityChunkLoader {
|
||||
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
|
||||
|
||||
public static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
|
||||
public static final Map<Long, ChunkLoaderBlockEntity> chunkLoaderBlockEntityMap = new HashMap<>();
|
||||
|
||||
public final List<EntityHolograms> holograms = new ArrayList<>();
|
||||
public final List<EntityHologram> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
public final TileEntityChunkLoaderTicker ticker;
|
||||
public final BlockPosition tilePosition;
|
||||
private final World world;
|
||||
private final ChunkLoaderBlockEntityTicker ticker;
|
||||
private final ServerLevel serverLevel;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
public boolean removed = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntityType", name = "COMMAND_BLOCK", type = Remap.Type.FIELD, remappedName = "v")
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity", name = "setLevel", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition) {
|
||||
super(TileEntityTypes.v, blockPosition.getHandle(), world.getBlockStateNoMappings(blockPosition.getHandle()));
|
||||
public ChunkLoaderBlockEntity(ChunkLoader chunkLoader, ServerLevel serverLevel, BlockPos blockPos) {
|
||||
super(BlockEntityType.COMMAND_BLOCK, blockPos, serverLevel.getBlockState(blockPos));
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
this.ticker = new TileEntityChunkLoaderTicker(this);
|
||||
this.tilePosition = blockPosition;
|
||||
this.world = world;
|
||||
this.ticker = new ChunkLoaderBlockEntityTicker(this);
|
||||
this.blockPos = blockPos;
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
a(world.getHandle());
|
||||
setLevel(serverLevel);
|
||||
|
||||
loaderBlock = world.getBlockState(blockPosition.getHandle()).getBlock();
|
||||
loaderBlock = serverLevel.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
@ -64,36 +61,28 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
tileEntityChunkLoaderMap.put(ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this);
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
chunkLoaderBlockEntityMap.put(chunkPosLong, this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = this.tilePosition.getY() + 1;
|
||||
double currentY = blockPos.getY() + 1;
|
||||
for (int i = hologramLines.size(); i > 0; i--) {
|
||||
EntityHolograms hologram = new EntityHolograms(world.getHandle(),
|
||||
this.tilePosition.getX() + 0.5, currentY, this.tilePosition.getZ() + 0.5);
|
||||
EntityHologram hologram = new EntityHologram(serverLevel, blockPos.getX() + 0.5, currentY, blockPos.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
world.addFreshEntity(hologram);
|
||||
serverLevel.addFreshEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "v")
|
||||
public TileEntityTypes<?> getType() {
|
||||
return super.v();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
if (chunkLoader.isNotActive() || this.world.getBlockState(this.tilePosition.getHandle()).getBlock() != loaderBlock) {
|
||||
if (chunkLoader.isNotActive() || this.serverLevel.getBlockState(this.blockPos).getBlock() != loaderBlock) {
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
@ -105,7 +94,7 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHolograms hologram = holograms.get(hologramsAmount - i);
|
||||
EntityHologram hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
@ -133,20 +122,16 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "r")
|
||||
@Override
|
||||
public boolean r() {
|
||||
return isRemoved();
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
return removed || super.r();
|
||||
return removed || super.isRemoved();
|
||||
}
|
||||
|
||||
private void updateName(EntityHolograms hologram, String line) {
|
||||
public ChunkLoaderBlockEntityTicker getTicker() {
|
||||
return ticker;
|
||||
}
|
||||
|
||||
private void updateName(EntityHologram hologram, String line) {
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
@ -0,0 +1,30 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1182.loader;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
public record ChunkLoaderBlockEntityTicker(
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity) implements TickingBlockEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
chunkLoaderBlockEntity.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return chunkLoaderBlockEntity.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return chunkLoaderBlockEntity.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return BlockEntityType.getKey(chunkLoaderBlockEntity.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
34
v119/build.gradle
Normal file
34
v119/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19-R0.1-SNAPSHOT")
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "${project.name}-exclude.jar"
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
tasks {
|
||||
reobfJar {
|
||||
File outputFile = new File(parent.projectDir, "archive/reobf/${project.name}.jar")
|
||||
outputJar.set(layout.buildDirectory.file(outputFile.getPath()))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_19') && !Boolean.valueOf(project.findProperty("nms.compile_v1_19").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.bgsoftware.wildloaders.nms.v119;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(ServerPlayerGameMode.class,
|
||||
1, GameType.class, GameType.class);
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPCImpl(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), null);
|
||||
|
||||
this.serverLevel = getLevel();
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.serverLevel);
|
||||
moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.serverLevel.addNewPlayer(this);
|
||||
|
||||
super.setBoundingBox(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.serverLevel.removePlayerImmediately(this, RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
super(PacketFlow.SERVERBOUND);
|
||||
this.channel = new DummyChannel();
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyServerGamePacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
|
||||
DummyServerGamePacketListenerImpl(MinecraftServer minecraftServer, ServerPlayer serverPlayer) {
|
||||
super(minecraftServer, new DummyConnection(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleContainerClick(ServerboundContainerClickPacket containerClickPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket movePlayerPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket signUpdatePacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(ServerboundPlayerActionPacket playerActionPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket useItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket setCarriedItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(ServerboundChatPacket chatPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.bgsoftware.wildloaders.nms.v119;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
||||
|
||||
public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
private static final AABB EMPTY_BOUND = new AABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public EntityHologram(ServerLevel serverLevel, double x, double y, double z) {
|
||||
super(serverLevel, x, y, z);
|
||||
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setShowArms(false);
|
||||
setNoGravity(true);
|
||||
setNoBasePlate(true);
|
||||
setMarker(true);
|
||||
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true); // Custom name visible
|
||||
super.setBoundingBox(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAsPassenger(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag saveWithoutId(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repositionEntityAfterLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(Component component) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand hand) {
|
||||
// Prevent stand being equipped
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(SoundEvent soundEvent, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.bgsoftware.wildloaders.nms.v119;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v119.loader.ChunkLoaderBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 8) ? def : compoundTag.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putString(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 4) ? def : compoundTag.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putLong(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack bukkitItem, String texture) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
CompoundTag skullOwner = compoundTag.contains("SkullOwner") ?
|
||||
compoundTag.getCompound("SkullOwner") : new CompoundTag();
|
||||
|
||||
CompoundTag properties = new CompoundTag();
|
||||
ListTag textures = new ListTag();
|
||||
CompoundTag signature = new CompoundTag();
|
||||
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties);
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
compoundTag.put("SkullOwner", skullOwner);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPCImpl(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot create loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
ChunkLoaderBlockEntity ChunkLoaderBlockEntity = new ChunkLoaderBlockEntity(chunkLoader, serverLevel, blockPos);
|
||||
serverLevel.addBlockEntityTicker(ChunkLoaderBlockEntity.getTicker());
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = -1;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
|
||||
return ChunkLoaderBlockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity = ChunkLoaderBlockEntity.chunkLoaderBlockEntityMap.remove(chunkPosLong);
|
||||
|
||||
if (chunkLoaderBlockEntity != null) {
|
||||
chunkLoaderBlockEntity.holograms.forEach(EntityHologram::removeHologram);
|
||||
chunkLoaderBlockEntity.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle)
|
||||
serverLevel.levelEvent(null, 2001, blockPos, Block.getId(serverLevel.getBlockState(blockPos)));
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = 16;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
World bukkitWorld = location.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
|
||||
BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos);
|
||||
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity)
|
||||
spawnerBlockEntity.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,16 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.loader;
|
||||
package com.bgsoftware.wildloaders.nms.v119.loader;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.EntityHolograms;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v119.EntityHologram;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -20,34 +19,32 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class TileEntityChunkLoader extends TileEntity implements ITileEntityChunkLoader {
|
||||
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
|
||||
|
||||
public static final Map<Long, TileEntityChunkLoader> tileEntityChunkLoaderMap = new HashMap<>();
|
||||
public static final Map<Long, ChunkLoaderBlockEntity> chunkLoaderBlockEntityMap = new HashMap<>();
|
||||
|
||||
public final List<EntityHolograms> holograms = new ArrayList<>();
|
||||
public final List<EntityHologram> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
public final TileEntityChunkLoaderTicker ticker;
|
||||
public final BlockPosition tilePosition;
|
||||
private final World world;
|
||||
private final ChunkLoaderBlockEntityTicker ticker;
|
||||
private final ServerLevel serverLevel;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
public boolean removed = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntityType", name = "COMMAND_BLOCK", type = Remap.Type.FIELD, remappedName = "v")
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity", name = "setLevel", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition) {
|
||||
super(TileEntityTypes.v, blockPosition.getHandle(), world.getBlockStateNoMappings(blockPosition.getHandle()));
|
||||
public ChunkLoaderBlockEntity(ChunkLoader chunkLoader, ServerLevel serverLevel, BlockPos blockPos) {
|
||||
super(BlockEntityType.COMMAND_BLOCK, blockPos, serverLevel.getBlockState(blockPos));
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
this.ticker = new TileEntityChunkLoaderTicker(this);
|
||||
this.tilePosition = blockPosition;
|
||||
this.world = world;
|
||||
this.ticker = new ChunkLoaderBlockEntityTicker(this);
|
||||
this.blockPos = blockPos;
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
a(world.getHandle());
|
||||
setLevel(serverLevel);
|
||||
|
||||
loaderBlock = world.getBlockState(blockPosition.getHandle()).getBlock();
|
||||
loaderBlock = serverLevel.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
@ -64,36 +61,28 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
tileEntityChunkLoaderMap.put(ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4), this);
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
chunkLoaderBlockEntityMap.put(chunkPosLong, this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = this.tilePosition.getY() + 1;
|
||||
double currentY = blockPos.getY() + 1;
|
||||
for (int i = hologramLines.size(); i > 0; i--) {
|
||||
EntityHolograms hologram = new EntityHolograms(world.getHandle(),
|
||||
this.tilePosition.getX() + 0.5, currentY, this.tilePosition.getZ() + 0.5);
|
||||
EntityHologram hologram = new EntityHologram(serverLevel, blockPos.getX() + 0.5, currentY, blockPos.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
world.addFreshEntity(hologram);
|
||||
serverLevel.addFreshEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public TileEntityTypes<?> getType() {
|
||||
return super.u();
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
if (chunkLoader.isNotActive() || this.world.getBlockState(this.tilePosition.getHandle()).getBlock() != loaderBlock) {
|
||||
if (chunkLoader.isNotActive() || this.serverLevel.getBlockState(this.blockPos).getBlock() != loaderBlock) {
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
@ -105,7 +94,7 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHolograms hologram = holograms.get(hologramsAmount - i);
|
||||
EntityHologram hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
@ -133,20 +122,16 @@ public final class TileEntityChunkLoader extends TileEntity implements ITileEnti
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.BlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "r")
|
||||
@Override
|
||||
public boolean r() {
|
||||
return isRemoved();
|
||||
}
|
||||
|
||||
public boolean isRemoved() {
|
||||
return removed || super.r();
|
||||
return removed || super.isRemoved();
|
||||
}
|
||||
|
||||
private void updateName(EntityHolograms hologram, String line) {
|
||||
public ChunkLoaderBlockEntityTicker getTicker() {
|
||||
return ticker;
|
||||
}
|
||||
|
||||
private void updateName(EntityHologram hologram, String line) {
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
@ -0,0 +1,30 @@
|
||||
package com.bgsoftware.wildloaders.nms.v119.loader;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
public record ChunkLoaderBlockEntityTicker(
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity) implements TickingBlockEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
chunkLoaderBlockEntity.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return chunkLoaderBlockEntity.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return chunkLoaderBlockEntity.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return BlockEntityType.getKey(chunkLoaderBlockEntity.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
34
v1191/build.gradle
Normal file
34
v1191/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.1-R0.1-SNAPSHOT")
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "${project.name}-exclude.jar"
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
tasks {
|
||||
reobfJar {
|
||||
File outputFile = new File(parent.projectDir, "archive/reobf/${project.name}.jar")
|
||||
outputJar.set(layout.buildDirectory.file(outputFile.getPath()))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_19') && !Boolean.valueOf(project.findProperty("nms.compile_v1_19").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -0,0 +1,162 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1191;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(ServerPlayerGameMode.class,
|
||||
1, GameType.class, GameType.class);
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPCImpl(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), null);
|
||||
|
||||
this.serverLevel = getLevel();
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.serverLevel);
|
||||
moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.serverLevel.addNewPlayer(this);
|
||||
|
||||
super.setBoundingBox(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.serverLevel.removePlayerImmediately(this, RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
super(PacketFlow.SERVERBOUND);
|
||||
this.channel = new DummyChannel();
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyServerGamePacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
|
||||
DummyServerGamePacketListenerImpl(MinecraftServer minecraftServer, ServerPlayer serverPlayer) {
|
||||
super(minecraftServer, new DummyConnection(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleContainerClick(ServerboundContainerClickPacket containerClickPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket movePlayerPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket signUpdatePacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(ServerboundPlayerActionPacket playerActionPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket useItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket setCarriedItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(ServerboundChatPacket chatPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1191;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
||||
|
||||
public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
private static final AABB EMPTY_BOUND = new AABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public EntityHologram(ServerLevel serverLevel, double x, double y, double z) {
|
||||
super(serverLevel, x, y, z);
|
||||
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setShowArms(false);
|
||||
setNoGravity(true);
|
||||
setNoBasePlate(true);
|
||||
setMarker(true);
|
||||
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true); // Custom name visible
|
||||
super.setBoundingBox(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAsPassenger(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag saveWithoutId(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repositionEntityAfterLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(Component component) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand hand) {
|
||||
// Prevent stand being equipped
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(SoundEvent soundEvent, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(RemovalReason removalReason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1191;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1191.loader.ChunkLoaderBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 8) ? def : compoundTag.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putString(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 4) ? def : compoundTag.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putLong(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack bukkitItem, String texture) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
CompoundTag skullOwner = compoundTag.contains("SkullOwner") ?
|
||||
compoundTag.getCompound("SkullOwner") : new CompoundTag();
|
||||
|
||||
CompoundTag properties = new CompoundTag();
|
||||
ListTag textures = new ListTag();
|
||||
CompoundTag signature = new CompoundTag();
|
||||
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties);
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
compoundTag.put("SkullOwner", skullOwner);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPCImpl(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot create loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
ChunkLoaderBlockEntity ChunkLoaderBlockEntity = new ChunkLoaderBlockEntity(chunkLoader, serverLevel, blockPos);
|
||||
serverLevel.addBlockEntityTicker(ChunkLoaderBlockEntity.getTicker());
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = -1;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
|
||||
return ChunkLoaderBlockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity = ChunkLoaderBlockEntity.chunkLoaderBlockEntityMap.remove(chunkPosLong);
|
||||
|
||||
if (chunkLoaderBlockEntity != null) {
|
||||
chunkLoaderBlockEntity.holograms.forEach(EntityHologram::removeHologram);
|
||||
chunkLoaderBlockEntity.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle)
|
||||
serverLevel.levelEvent(null, 2001, blockPos, Block.getId(serverLevel.getBlockState(blockPos)));
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = 16;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
World bukkitWorld = location.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
|
||||
BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos);
|
||||
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity)
|
||||
spawnerBlockEntity.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1191.loader;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1191.EntityHologram;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
|
||||
|
||||
public static final Map<Long, ChunkLoaderBlockEntity> chunkLoaderBlockEntityMap = new HashMap<>();
|
||||
|
||||
public final List<EntityHologram> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
private final ChunkLoaderBlockEntityTicker ticker;
|
||||
private final ServerLevel serverLevel;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
public boolean removed = false;
|
||||
|
||||
public ChunkLoaderBlockEntity(ChunkLoader chunkLoader, ServerLevel serverLevel, BlockPos blockPos) {
|
||||
super(BlockEntityType.COMMAND_BLOCK, blockPos, serverLevel.getBlockState(blockPos));
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
this.ticker = new ChunkLoaderBlockEntityTicker(this);
|
||||
this.blockPos = blockPos;
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
setLevel(serverLevel);
|
||||
|
||||
loaderBlock = serverLevel.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
|
||||
daysAmount = (short) (timeLeft / 86400);
|
||||
timeLeft = timeLeft % 86400;
|
||||
|
||||
hoursAmount = (short) (timeLeft / 3600);
|
||||
timeLeft = timeLeft % 3600;
|
||||
|
||||
minutesAmount = (short) (timeLeft / 60);
|
||||
timeLeft = timeLeft % 60;
|
||||
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
chunkLoaderBlockEntityMap.put(chunkPosLong, this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = blockPos.getY() + 1;
|
||||
for (int i = hologramLines.size(); i > 0; i--) {
|
||||
EntityHologram hologram = new EntityHologram(serverLevel, blockPos.getX() + 0.5, currentY, blockPos.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
serverLevel.addFreshEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
if (chunkLoader.isNotActive() || this.serverLevel.getBlockState(this.blockPos).getBlock() != loaderBlock) {
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunkLoader.isInfinite())
|
||||
return;
|
||||
|
||||
List<String> hologramLines = chunkLoader.getHologramLines();
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHologram hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
chunkLoader.tick();
|
||||
|
||||
if (!removed) {
|
||||
secondsAmount--;
|
||||
if (secondsAmount < 0) {
|
||||
secondsAmount = 59;
|
||||
minutesAmount--;
|
||||
if (minutesAmount < 0) {
|
||||
minutesAmount = 59;
|
||||
hoursAmount--;
|
||||
if (hoursAmount < 0) {
|
||||
hoursAmount = 23;
|
||||
daysAmount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Hologram> getHolograms() {
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return removed || super.isRemoved();
|
||||
}
|
||||
|
||||
public ChunkLoaderBlockEntityTicker getTicker() {
|
||||
return ticker;
|
||||
}
|
||||
|
||||
private void updateName(EntityHologram hologram, String line) {
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
||||
.replace("{1}", daysAmount + "")
|
||||
.replace("{2}", hoursAmount + "")
|
||||
.replace("{3}", minutesAmount + "")
|
||||
.replace("{4}", secondsAmount + "")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1191.loader;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
public record ChunkLoaderBlockEntityTicker(
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity) implements TickingBlockEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
chunkLoaderBlockEntity.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return chunkLoaderBlockEntity.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return chunkLoaderBlockEntity.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return BlockEntityType.getKey(chunkLoaderBlockEntity.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
34
v1192/build.gradle
Normal file
34
v1192/build.gradle
Normal file
@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
id("io.papermc.paperweight.userdev") version "1.3.8"
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
paperweightDevelopmentBundle("io.papermc.paper:dev-bundle:1.19.2-R0.1-SNAPSHOT")
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveFileName = "${project.name}-exclude.jar"
|
||||
}
|
||||
|
||||
assemble {
|
||||
dependsOn(reobfJar)
|
||||
}
|
||||
|
||||
tasks {
|
||||
reobfJar {
|
||||
File outputFile = new File(parent.projectDir, "archive/reobf/${project.name}.jar")
|
||||
outputJar.set(layout.buildDirectory.file(outputFile.getPath()))
|
||||
}
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_19') && !Boolean.valueOf(project.findProperty("nms.compile_v1_19").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -0,0 +1,163 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1192;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.PacketFlow;
|
||||
import net.minecraft.network.protocol.game.ServerboundChatPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundContainerClickPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundMovePlayerPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSetCarriedItemPacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundSignUpdatePacket;
|
||||
import net.minecraft.network.protocol.game.ServerboundUseItemPacket;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
import net.minecraft.server.level.ServerPlayerGameMode;
|
||||
import net.minecraft.server.network.ServerGamePacketListenerImpl;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.GameType;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPCImpl extends ServerPlayer implements ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(ServerPlayerGameMode.class,
|
||||
1, GameType.class, GameType.class);
|
||||
|
||||
private final ServerLevel serverLevel;
|
||||
private final AABB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
public ChunkLoaderNPCImpl(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), null);
|
||||
|
||||
this.serverLevel = getLevel();
|
||||
this.boundingBox = new AABB(new BlockPos(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.connection = new DummyServerGamePacketListenerImpl(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.gameMode, GameType.CREATIVE, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.serverLevel);
|
||||
moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.serverLevel.addNewPlayer(this);
|
||||
|
||||
super.setBoundingBox(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.getUUID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void die() {
|
||||
discard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.serverLevel.removePlayerImmediately(this, Entity.RemovalReason.UNLOADED_WITH_PLAYER);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.remove(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyConnection extends Connection {
|
||||
|
||||
DummyConnection() {
|
||||
super(PacketFlow.SERVERBOUND);
|
||||
this.channel = new DummyChannel();
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyServerGamePacketListenerImpl extends ServerGamePacketListenerImpl {
|
||||
|
||||
DummyServerGamePacketListenerImpl(MinecraftServer minecraftServer, ServerPlayer serverPlayer) {
|
||||
super(minecraftServer, new DummyConnection(), serverPlayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleContainerClick(ServerboundContainerClickPacket containerClickPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMovePlayer(ServerboundMovePlayerPacket movePlayerPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSignUpdate(ServerboundSignUpdatePacket signUpdatePacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handlePlayerAction(ServerboundPlayerActionPacket playerActionPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleUseItem(ServerboundUseItemPacket useItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleSetCarriedItem(ServerboundSetCarriedItemPacket setCarriedItemPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleChat(ServerboundChatPacket chatPacket) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
public void send(Packet<?> packet) {
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1192;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EquipmentSlot;
|
||||
import net.minecraft.world.entity.decoration.ArmorStand;
|
||||
import net.minecraft.world.entity.player.Player;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.phys.AABB;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
||||
|
||||
public final class EntityHologram extends ArmorStand implements Hologram {
|
||||
|
||||
private static final AABB EMPTY_BOUND = new AABB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
public EntityHologram(ServerLevel serverLevel, double x, double y, double z) {
|
||||
super(serverLevel, x, y, z);
|
||||
|
||||
setInvisible(true);
|
||||
setSmall(true);
|
||||
setShowArms(false);
|
||||
setNoGravity(true);
|
||||
setNoBasePlate(true);
|
||||
setMarker(true);
|
||||
|
||||
super.collides = false;
|
||||
super.setCustomNameVisible(true); // Custom name visible
|
||||
super.setBoundingBox(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.setCustomName(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.remove(RemovalReason.DISCARDED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.onGround) {
|
||||
this.onGround = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveAsPassenger(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag saveWithoutId(CompoundTag compoundTag) {
|
||||
// Do not save NBT.
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readAdditionalSaveData(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(CompoundTag compoundTag) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInvulnerableTo(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean repositionEntityAfterLoad() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomName(Component component) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCustomNameVisible(boolean visible) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Override
|
||||
public InteractionResult interactAt(Player player, Vec3 hitPos, InteractionHand hand) {
|
||||
// Prevent stand being equipped
|
||||
return InteractionResult.PASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EquipmentSlot equipmentSlot, ItemStack itemStack, boolean silent) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Override
|
||||
public AABB getBoundingBoxForCulling() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playSound(SoundEvent soundEvent, float volume, float pitch) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Entity.RemovalReason removalReason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,170 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1192;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1192.loader.ChunkLoaderBlockEntity;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.ListTag;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.SpawnerBlockEntity;
|
||||
import net.minecraft.world.level.chunk.LevelChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 8) ? def : compoundTag.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, String value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putString(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long def) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getTag();
|
||||
return compoundTag == null || !compoundTag.contains(key, 4) ? def : compoundTag.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack bukkitItem, String key, long value) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
compoundTag.putLong(key, value);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack bukkitItem, String texture) {
|
||||
ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
|
||||
CompoundTag compoundTag = itemStack.getOrCreateTag();
|
||||
|
||||
CompoundTag skullOwner = compoundTag.contains("SkullOwner") ?
|
||||
compoundTag.getCompound("SkullOwner") : new CompoundTag();
|
||||
|
||||
CompoundTag properties = new CompoundTag();
|
||||
ListTag textures = new ListTag();
|
||||
CompoundTag signature = new CompoundTag();
|
||||
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature);
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties);
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
compoundTag.put("SkullOwner", skullOwner);
|
||||
|
||||
return CraftItemStack.asBukkitCopy(itemStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPCImpl(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot create loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
ChunkLoaderBlockEntity ChunkLoaderBlockEntity = new ChunkLoaderBlockEntity(chunkLoader, serverLevel, blockPos);
|
||||
serverLevel.addBlockEntityTicker(ChunkLoaderBlockEntity.getTicker());
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = -1;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, true);
|
||||
}
|
||||
|
||||
return ChunkLoaderBlockEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
World bukkitWorld = loaderLoc.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity = ChunkLoaderBlockEntity.chunkLoaderBlockEntityMap.remove(chunkPosLong);
|
||||
|
||||
if (chunkLoaderBlockEntity != null) {
|
||||
chunkLoaderBlockEntity.holograms.forEach(EntityHologram::removeHologram);
|
||||
chunkLoaderBlockEntity.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle)
|
||||
serverLevel.levelEvent(null, 2001, blockPos, Block.getId(serverLevel.getBlockState(blockPos)));
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
LevelChunk levelChunk = ((CraftChunk) bukkitChunk).getHandle();
|
||||
levelChunk.getBlockEntities().values().stream()
|
||||
.filter(blockEntity -> blockEntity instanceof SpawnerBlockEntity)
|
||||
.forEach(blockEntity -> {
|
||||
((SpawnerBlockEntity) blockEntity).getSpawner().requiredPlayerRange = 16;
|
||||
});
|
||||
|
||||
ChunkPos chunkPos = levelChunk.getPos();
|
||||
serverLevel.setChunkForced(chunkPos.x, chunkPos.z, false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
World bukkitWorld = location.getWorld();
|
||||
|
||||
if (bukkitWorld == null)
|
||||
throw new IllegalArgumentException("Cannot remove loader in null world.");
|
||||
|
||||
ServerLevel serverLevel = ((CraftWorld) bukkitWorld).getHandle();
|
||||
BlockPos blockPos = new BlockPos(location.getX(), location.getY(), location.getZ());
|
||||
BlockEntity blockEntity = serverLevel.getBlockEntity(blockPos);
|
||||
if (blockEntity instanceof SpawnerBlockEntity spawnerBlockEntity)
|
||||
spawnerBlockEntity.getSpawner().requiredPlayerRange = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1192.loader;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.WChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1192.EntityHologram;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.server.level.ServerLevel;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class ChunkLoaderBlockEntity extends BlockEntity implements ITileEntityChunkLoader {
|
||||
|
||||
public static final Map<Long, ChunkLoaderBlockEntity> chunkLoaderBlockEntityMap = new HashMap<>();
|
||||
|
||||
public final List<EntityHologram> holograms = new ArrayList<>();
|
||||
private final WChunkLoader chunkLoader;
|
||||
private final Block loaderBlock;
|
||||
private final ChunkLoaderBlockEntityTicker ticker;
|
||||
private final ServerLevel serverLevel;
|
||||
private final BlockPos blockPos;
|
||||
|
||||
private short currentTick = 20;
|
||||
private short daysAmount, hoursAmount, minutesAmount, secondsAmount;
|
||||
public boolean removed = false;
|
||||
|
||||
public ChunkLoaderBlockEntity(ChunkLoader chunkLoader, ServerLevel serverLevel, BlockPos blockPos) {
|
||||
super(BlockEntityType.COMMAND_BLOCK, blockPos, serverLevel.getBlockState(blockPos));
|
||||
|
||||
this.chunkLoader = (WChunkLoader) chunkLoader;
|
||||
this.ticker = new ChunkLoaderBlockEntityTicker(this);
|
||||
this.blockPos = blockPos;
|
||||
this.serverLevel = serverLevel;
|
||||
|
||||
setLevel(serverLevel);
|
||||
|
||||
loaderBlock = serverLevel.getBlockState(blockPos).getBlock();
|
||||
|
||||
if (!this.chunkLoader.isInfinite()) {
|
||||
long timeLeft = chunkLoader.getTimeLeft();
|
||||
|
||||
daysAmount = (short) (timeLeft / 86400);
|
||||
timeLeft = timeLeft % 86400;
|
||||
|
||||
hoursAmount = (short) (timeLeft / 3600);
|
||||
timeLeft = timeLeft % 3600;
|
||||
|
||||
minutesAmount = (short) (timeLeft / 60);
|
||||
timeLeft = timeLeft % 60;
|
||||
|
||||
secondsAmount = (short) timeLeft;
|
||||
}
|
||||
|
||||
long chunkPosLong = ChunkPos.asLong(blockPos.getX() >> 4, blockPos.getZ() >> 4);
|
||||
chunkLoaderBlockEntityMap.put(chunkPosLong, this);
|
||||
|
||||
List<String> hologramLines = this.chunkLoader.getHologramLines();
|
||||
|
||||
double currentY = blockPos.getY() + 1;
|
||||
for (int i = hologramLines.size(); i > 0; i--) {
|
||||
EntityHologram hologram = new EntityHologram(serverLevel, blockPos.getX() + 0.5, currentY, blockPos.getZ() + 0.5);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
serverLevel.addFreshEntity(hologram);
|
||||
currentY += 0.23;
|
||||
holograms.add(hologram);
|
||||
}
|
||||
}
|
||||
|
||||
public void tick() {
|
||||
if (removed || ++currentTick <= 20)
|
||||
return;
|
||||
|
||||
currentTick = 0;
|
||||
|
||||
if (chunkLoader.isNotActive() || this.serverLevel.getBlockState(this.blockPos).getBlock() != loaderBlock) {
|
||||
chunkLoader.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
if (chunkLoader.isInfinite())
|
||||
return;
|
||||
|
||||
List<String> hologramLines = chunkLoader.getHologramLines();
|
||||
|
||||
int hologramsAmount = holograms.size();
|
||||
for (int i = hologramsAmount; i > 0; i--) {
|
||||
EntityHologram hologram = holograms.get(hologramsAmount - i);
|
||||
updateName(hologram, hologramLines.get(i - 1));
|
||||
}
|
||||
|
||||
chunkLoader.tick();
|
||||
|
||||
if (!removed) {
|
||||
secondsAmount--;
|
||||
if (secondsAmount < 0) {
|
||||
secondsAmount = 59;
|
||||
minutesAmount--;
|
||||
if (minutesAmount < 0) {
|
||||
minutesAmount = 59;
|
||||
hoursAmount--;
|
||||
if (hoursAmount < 0) {
|
||||
hoursAmount = 23;
|
||||
daysAmount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Hologram> getHolograms() {
|
||||
return Collections.unmodifiableList(holograms);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return removed || super.isRemoved();
|
||||
}
|
||||
|
||||
public ChunkLoaderBlockEntityTicker getTicker() {
|
||||
return ticker;
|
||||
}
|
||||
|
||||
private void updateName(EntityHologram hologram, String line) {
|
||||
assert chunkLoader.getWhoPlaced().getName() != null;
|
||||
hologram.setHologramName(line
|
||||
.replace("{0}", chunkLoader.getWhoPlaced().getName())
|
||||
.replace("{1}", daysAmount + "")
|
||||
.replace("{2}", hoursAmount + "")
|
||||
.replace("{3}", minutesAmount + "")
|
||||
.replace("{4}", secondsAmount + "")
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1192.loader;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityType;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
|
||||
public record ChunkLoaderBlockEntityTicker(
|
||||
ChunkLoaderBlockEntity chunkLoaderBlockEntity) implements TickingBlockEntity {
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
chunkLoaderBlockEntity.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRemoved() {
|
||||
return chunkLoaderBlockEntity.isRemoved();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return chunkLoaderBlockEntity.getBlockPos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return BlockEntityType.getKey(chunkLoaderBlockEntity.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_12_R1;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_12_R1.loader.TileEntityChunkLoader;
|
||||
@ -24,27 +23,15 @@ import org.bukkit.craftbukkit.v1_12_R1.util.LongHash;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings({"ConstantConditions", "unused"})
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
private static final ReflectMethod<Void> TILE_ENTITY_LOAD = new ReflectMethod<>(TileEntity.class, "load", NBTTagCompound.class);
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
|
||||
|
||||
if (!tagCompound.hasKeyOfType(key, 8))
|
||||
return def;
|
||||
|
||||
return tagCompound.getString(key);
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
return tagCompound == null || !tagCompound.hasKeyOfType(key, 8) ? def : tagCompound.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,6 +39,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
|
||||
|
||||
assert tagCompound != null;
|
||||
|
||||
tagCompound.set(key, new NBTTagString(value));
|
||||
|
||||
nmsItem.setTag(tagCompound);
|
||||
@ -62,12 +51,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
|
||||
|
||||
if (!tagCompound.hasKeyOfType(key, 4))
|
||||
return def;
|
||||
|
||||
return tagCompound.getLong(key);
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
return tagCompound == null || !tagCompound.hasKeyOfType(key, 4) ? def : tagCompound.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -75,6 +60,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
NBTTagCompound tagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
|
||||
|
||||
assert tagCompound != null;
|
||||
|
||||
tagCompound.set(key, new NBTTagLong(value));
|
||||
|
||||
nmsItem.setTag(tagCompound);
|
||||
@ -88,6 +75,8 @@ public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapt
|
||||
|
||||
NBTTagCompound nbtTagCompound = nmsItem.hasTag() ? nmsItem.getTag() : new NBTTagCompound();
|
||||
|
||||
assert nbtTagCompound != null;
|
||||
|
||||
NBTTagCompound skullOwner = nbtTagCompound.hasKey("SkullOwner") ? nbtTagCompound.getCompound("SkullOwner") : new NBTTagCompound();
|
||||
|
||||
NBTTagCompound properties = new NBTTagCompound();
|
||||
|
@ -24,16 +24,8 @@ import org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
|
@ -31,19 +31,8 @@ import org.bukkit.craftbukkit.v1_17_R1.util.CraftMagicNumbers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
private static final ReflectMethod<TickingBlockEntity> CREATE_TICKING_BLOCK = new ReflectMethod<>(
|
||||
Chunk.class, "a", TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
|
@ -1,36 +0,0 @@
|
||||
group 'v1_18_R1'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://papermc.io/repo/repository/maven-public/" }
|
||||
maven { url "https://libraries.minecraft.net/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:v1_18_R1-Paper:b68"
|
||||
|
||||
compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-20211210.153434-2'
|
||||
|
||||
compileOnly 'com.mojang:authlib:3.2.38'
|
||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||
compileOnly 'com.mojang:brigadier:1.0.18'
|
||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||
compileOnly 'com.google.code.gson:gson:2.9.0'
|
||||
compileOnly 'net.kyori:adventure-key:4.9.3'
|
||||
compileOnly 'net.kyori:examination-api:1.3.0'
|
||||
compileOnly 'net.kyori:adventure-api:4.9.3'
|
||||
compileOnly 'net.md-5:bungeecord-chat:1.16-R0.4'
|
||||
compileOnly 'io.netty:netty-all:4.1.72.Final'
|
||||
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_18') && !Boolean.valueOf(project.findProperty("nms.compile_v1_18").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.entity.Entity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockDig;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockPlace;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInHeldItemSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInUpdateSign;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerPlayer", name = "gameMode", type = Remap.Type.FIELD, remappedName = "d")
|
||||
public ChunkLoaderNPC(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.world.getHandle());
|
||||
entity.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getUUID",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cm")
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.cm();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "discard",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "ah")
|
||||
@Override
|
||||
public void die() {
|
||||
ah();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getBoundingBoxForCulling",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.world.removePlayer(this, RemovalReason.d);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
@Remap(classPath = "net.minecraft.network.protocol.PacketFlow", name = "SERVERBOUND", type = Remap.Type.FIELD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "channel", type = Remap.Type.FIELD, remappedName = "k")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "address", type = Remap.Type.FIELD, remappedName = "l")
|
||||
DummyNetworkManager() {
|
||||
super(EnumProtocolDirection.a);
|
||||
this.k = new DummyChannel();
|
||||
this.l = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyPlayerConnection extends PlayerConnection {
|
||||
|
||||
DummyPlayerConnection(MinecraftServer minecraftServer, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, new DummyNetworkManager(), entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleContainerClick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInWindowClick packetPlayInWindowClick) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleMovePlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInFlying packetPlayInFlying) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSignUpdate",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInUpdateSign packetPlayInUpdateSign) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handlePlayerAction",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockDig packetPlayInBlockDig) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleUseItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockPlace packetPlayInBlockPlace) {
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSetCarriedItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInHeldItemSlot packetPlayInHeldItemSlot) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleChat",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInChat packetPlayInChat) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "send",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(Packet<?> packet) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.EnumInteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EnumItemSlot;
|
||||
import net.minecraft.world.entity.decoration.EntityArmorStand;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftChatMessage;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EntityHolograms extends EntityArmorStand implements Hologram {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setInvisible", type = Remap.Type.METHOD, remappedName = "j")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setSmall", type = Remap.Type.METHOD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setShowArms", type = Remap.Type.METHOD, remappedName = "r")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setNoGravity", type = Remap.Type.METHOD, remappedName = "e")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setNoBasePlate", type = Remap.Type.METHOD, remappedName = "s")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setMarker", type = Remap.Type.METHOD, remappedName = "t")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setCustomNameVisible", type = Remap.Type.METHOD, remappedName = "n")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setBoundingBox", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public EntityHolograms(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
j(true); // Invisible
|
||||
a(true); // Small
|
||||
r(false); // Arms
|
||||
e(true); // No Gravity
|
||||
s(true); // Base Plate
|
||||
t(true); // Marker
|
||||
super.collides = false;
|
||||
super.n(true); // Custom name visible
|
||||
super.a(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.a(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.a(RemovalReason.b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "k")
|
||||
@Override
|
||||
public void k() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.z) {
|
||||
this.z = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "onGround",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "z")
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.z) {
|
||||
this.z = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "addAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveAsPassenger",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveWithoutId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
@Override
|
||||
public NBTTagCompound f(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "readAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "load",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "g")
|
||||
@Override
|
||||
public void g(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "isInvulnerableTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "repositionEntityAfterLoad",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "bj")
|
||||
@Override
|
||||
public boolean bj() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomNameVisible",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "n")
|
||||
@Override
|
||||
public void n(boolean flag) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand",
|
||||
name = "interactAt",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean flag) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getBoundingBoxForCulling",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "playSound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason entity_removalreason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.loader.TileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.item.ItemStack;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.block.entity.TileEntity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_18_R1.util.CraftMagicNumbers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk", name = "createTicker", type = Remap.Type.METHOD)
|
||||
private static final ReflectMethod<TickingBlockEntity> CREATE_TICKING_BLOCK = new ReflectMethod<>(
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 8))
|
||||
return def;
|
||||
|
||||
return tagCompound.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagString.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 4))
|
||||
return def;
|
||||
|
||||
return tagCompound.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, long value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagLong.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
NBTTagCompound skullOwner = tagCompound.contains("SkullOwner") ?
|
||||
tagCompound.getCompound("SkullOwner") : new NBTTagCompound();
|
||||
|
||||
NBTTagCompound properties = new NBTTagCompound();
|
||||
|
||||
NBTTagList textures = new NBTTagList();
|
||||
NBTTagCompound signature = new NBTTagCompound();
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature.getHandle());
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties.getHandle());
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
tagCompound.put("SkullOwner", skullOwner.getHandle());
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPC(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
|
||||
world.addBlockEntityTicker(tileEntityChunkLoader.ticker);
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = -1;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), true);
|
||||
}
|
||||
|
||||
return tileEntityChunkLoader;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long tileEntityLong = ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
|
||||
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
|
||||
if (tileEntityChunkLoader != null) {
|
||||
tileEntityChunkLoader.holograms.forEach(EntityHolograms::removeHologram);
|
||||
tileEntityChunkLoader.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle) {
|
||||
world.levelEvent(null, 2001, blockPosition.getHandle(),
|
||||
IBlockData.getId(world.getBlockStateNoMappings(blockPosition.getHandle())));
|
||||
}
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = 16;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
assert location.getWorld() != null;
|
||||
World world = new World(((CraftWorld) location.getWorld()).getHandle());
|
||||
|
||||
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
|
||||
TileEntity mobSpawner = new TileEntity(world.getBlockEntity(blockPosition.getHandle()));
|
||||
|
||||
mobSpawner.getSpawner().m = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.loader;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
|
||||
public record TileEntityChunkLoaderTicker(TileEntityChunkLoader tileEntityChunkLoader) implements TickingBlockEntity {
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a() {
|
||||
tileEntityChunkLoader.tick();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b() {
|
||||
return tileEntityChunkLoader.isRemoved();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
@Override
|
||||
public BlockPosition c() {
|
||||
return tileEntityChunkLoader.tilePosition.getHandle();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public String d() {
|
||||
return TileEntityTypes.a(tileEntityChunkLoader.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings;
|
||||
|
||||
public abstract class MappedObject<E> {
|
||||
|
||||
protected final E handle;
|
||||
|
||||
protected MappedObject(E handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public E getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.core;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
|
||||
public class BlockPosition extends MappedObject<net.minecraft.core.BlockPosition> {
|
||||
|
||||
public BlockPosition(double x, double y, double z) {
|
||||
this(new net.minecraft.core.BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
public BlockPosition(net.minecraft.core.BlockPosition handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getX",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public int getX() {
|
||||
return handle.u();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getY",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "v")
|
||||
public int getY() {
|
||||
return handle.v();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getZ",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "w")
|
||||
public int getZ() {
|
||||
return handle.w();
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.nbt;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
||||
public class NBTTagCompound extends MappedObject<net.minecraft.nbt.NBTTagCompound> {
|
||||
|
||||
public static NBTTagCompound ofNullable(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
return handle == null ? null : new NBTTagCompound(handle);
|
||||
}
|
||||
|
||||
public NBTTagCompound() {
|
||||
this(new net.minecraft.nbt.NBTTagCompound());
|
||||
}
|
||||
|
||||
public NBTTagCompound(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public boolean contains(String key, int type) {
|
||||
return handle.b(key, type);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "l")
|
||||
public String getString(String key) {
|
||||
return handle.l(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "put",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void put(String key, NBTBase nbtBase) {
|
||||
handle.a(key, nbtBase);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public long getLong(String key) {
|
||||
return handle.i(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "e")
|
||||
public boolean contains(String key) {
|
||||
return handle.e(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getCompound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "p")
|
||||
public NBTTagCompound getCompound(String key) {
|
||||
return new NBTTagCompound(handle.p(key));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "putString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void putString(String key, String value) {
|
||||
handle.a(key, value);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.World;
|
||||
|
||||
public class Entity extends MappedObject<net.minecraft.world.entity.Entity> {
|
||||
|
||||
public Entity(net.minecraft.world.entity.Entity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getLevel",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "W")
|
||||
public World getWorld() {
|
||||
return new World(handle.W());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "moveTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
handle.b(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.item;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemStack extends MappedObject<net.minecraft.world.item.ItemStack> {
|
||||
|
||||
public ItemStack(net.minecraft.world.item.ItemStack handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getOrCreateTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "t")
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
return new NBTTagCompound(handle.t());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "s")
|
||||
public NBTTagCompound getTag() {
|
||||
return NBTTagCompound.ofNullable(handle.s());
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
|
||||
public class ChunkCoordIntPair extends MappedObject<net.minecraft.world.level.ChunkCoordIntPair> {
|
||||
|
||||
public ChunkCoordIntPair(net.minecraft.world.level.ChunkCoordIntPair handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "x",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "c")
|
||||
public int getX() {
|
||||
return handle.c;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "z",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "d")
|
||||
public int getZ() {
|
||||
return handle.d;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "asLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public static long asLong(int x, int z) {
|
||||
return net.minecraft.world.level.ChunkCoordIntPair.a(x, z);
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
public class World extends MappedObject<net.minecraft.world.level.World> {
|
||||
|
||||
public World(net.minecraft.world.level.World handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "setChunkForced",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void setChunkForced(int chunkX, int chunkZ, boolean load) {
|
||||
((WorldServer) handle).a(chunkX, chunkZ, load);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "addNewPlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
public void addNewPlayer(EntityPlayer entityPlayer) {
|
||||
((WorldServer) handle).c(entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "removePlayerImmediately",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void removePlayer(EntityPlayer entityPlayer, Entity.RemovalReason removalReason) {
|
||||
((WorldServer) handle).a(entityPlayer, removalReason);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockState",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a_")
|
||||
public net.minecraft.world.level.block.state.IBlockData getBlockStateNoMappings(BlockPosition blockPosition) {
|
||||
return handle.a_(blockPosition);
|
||||
}
|
||||
|
||||
public IBlockData getBlockState(BlockPosition blockPosition) {
|
||||
return new IBlockData(getBlockStateNoMappings(blockPosition));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c_")
|
||||
public TileEntity getBlockEntity(BlockPosition blockPosition) {
|
||||
return handle.c_(blockPosition);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.LevelWriter",
|
||||
name = "addFreshEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void addFreshEntity(Entity entity) {
|
||||
handle.b(entity);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "addBlockEntityTicker",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void addBlockEntityTicker(TickingBlockEntity blockEntityTicker) {
|
||||
handle.a(blockEntityTicker);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "levelEvent",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void levelEvent(EntityPlayer entityPlayer, int i, BlockPosition blockPosition, int j) {
|
||||
handle.a(entityPlayer, i, blockPosition, j);
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.block.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import net.minecraft.world.level.MobSpawnerAbstract;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
|
||||
public class TileEntity extends MappedObject<net.minecraft.world.level.block.entity.TileEntity> {
|
||||
|
||||
public TileEntity(net.minecraft.world.level.block.entity.TileEntity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.SpawnerBlockEntity",
|
||||
name = "getSpawner",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
public MobSpawnerAbstract getSpawner() {
|
||||
return ((TileEntityMobSpawner) handle).d();
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.block.state;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class IBlockData extends MappedObject<net.minecraft.world.level.block.state.IBlockData> {
|
||||
|
||||
public IBlockData(net.minecraft.world.level.block.state.IBlockData handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase",
|
||||
name = "getBlock",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public Block getBlock() {
|
||||
return handle.b();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.Block",
|
||||
name = "getId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public static int getId(net.minecraft.world.level.block.state.IBlockData blockData) {
|
||||
return Block.i(blockData);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.chunk;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Chunk extends MappedObject<net.minecraft.world.level.chunk.Chunk> {
|
||||
|
||||
public Chunk(net.minecraft.world.level.chunk.Chunk handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk",
|
||||
name = "getBlockEntities",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "E")
|
||||
public Map<BlockPosition, TileEntity> getBlockEntities() {
|
||||
return handle.E();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.ChunkAccess",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
public ChunkCoordIntPair getPos() {
|
||||
return new ChunkCoordIntPair(handle.f());
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
group 'v1_18_R2'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://papermc.io/repo/repository/maven-public/" }
|
||||
maven { url "https://libraries.minecraft.net/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:v1_18_R2-Paper:b225"
|
||||
|
||||
compileOnly 'io.papermc.paper:paper-api:1.18.2-R0.1-20220305.050345-9'
|
||||
|
||||
compileOnly 'com.mojang:authlib:3.2.38'
|
||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||
compileOnly 'com.mojang:brigadier:1.0.18'
|
||||
compileOnly 'com.google.guava:guava:31.0.1-jre'
|
||||
compileOnly 'com.google.code.gson:gson:2.9.0'
|
||||
compileOnly 'net.kyori:adventure-key:4.9.3'
|
||||
compileOnly 'net.kyori:examination-api:1.3.0'
|
||||
compileOnly 'net.kyori:adventure-api:4.9.3'
|
||||
compileOnly 'net.md-5:bungeecord-chat:1.16-R0.4'
|
||||
compileOnly 'io.netty:netty-all:4.1.72.Final'
|
||||
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_18') && !Boolean.valueOf(project.findProperty("nms.compile_v1_18").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -1,208 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.entity.Entity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockDig;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockPlace;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInHeldItemSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInUpdateSign;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerPlayer", name = "gameMode", type = Remap.Type.FIELD, remappedName = "d")
|
||||
public ChunkLoaderNPC(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())));
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.world.getHandle());
|
||||
entity.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getUUID",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cm")
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return super.cm();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "discard",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "ah")
|
||||
@Override
|
||||
public void die() {
|
||||
ah();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getBoundingBoxForCulling",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return this.boundingBox;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.world.removePlayer(this, RemovalReason.d);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
@Remap(classPath = "net.minecraft.network.protocol.PacketFlow", name = "SERVERBOUND", type = Remap.Type.FIELD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "channel", type = Remap.Type.FIELD, remappedName = "m")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "address", type = Remap.Type.FIELD, remappedName = "n")
|
||||
DummyNetworkManager() {
|
||||
super(EnumProtocolDirection.a);
|
||||
this.m = new DummyChannel();
|
||||
this.n = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyPlayerConnection extends PlayerConnection {
|
||||
|
||||
DummyPlayerConnection(MinecraftServer minecraftServer, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, new DummyNetworkManager(), entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleContainerClick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInWindowClick packetPlayInWindowClick) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleMovePlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInFlying packetPlayInFlying) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSignUpdate",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInUpdateSign packetPlayInUpdateSign) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handlePlayerAction",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockDig packetPlayInBlockDig) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleUseItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockPlace packetPlayInBlockPlace) {
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSetCarriedItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInHeldItemSlot packetPlayInHeldItemSlot) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleChat",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInChat packetPlayInChat) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "send",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(Packet<?> packet) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,245 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.EnumInteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EnumItemSlot;
|
||||
import net.minecraft.world.entity.decoration.EntityArmorStand;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftChatMessage;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EntityHolograms extends EntityArmorStand implements Hologram {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setInvisible", type = Remap.Type.METHOD, remappedName = "j")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setSmall", type = Remap.Type.METHOD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setShowArms", type = Remap.Type.METHOD, remappedName = "r")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setNoGravity", type = Remap.Type.METHOD, remappedName = "e")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setNoBasePlate", type = Remap.Type.METHOD, remappedName = "s")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setMarker", type = Remap.Type.METHOD, remappedName = "t")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setCustomNameVisible", type = Remap.Type.METHOD, remappedName = "n")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setBoundingBox", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public EntityHolograms(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
j(true); // Invisible
|
||||
a(true); // Small
|
||||
r(false); // Arms
|
||||
e(true); // No Gravity
|
||||
s(true); // Base Plate
|
||||
t(true); // Marker
|
||||
super.collides = false;
|
||||
super.n(true); // Custom name visible
|
||||
super.a(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.a(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.a(RemovalReason.b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "k")
|
||||
@Override
|
||||
public void k() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.y) {
|
||||
this.y = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "onGround",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "y")
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.y) {
|
||||
this.y = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "addAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveAsPassenger",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveWithoutId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
@Override
|
||||
public NBTTagCompound f(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "readAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "load",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "g")
|
||||
@Override
|
||||
public void g(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "isInvulnerableTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "repositionEntityAfterLoad",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "bj")
|
||||
@Override
|
||||
public boolean bj() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomNameVisible",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "n")
|
||||
@Override
|
||||
public void n(boolean flag) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand",
|
||||
name = "interactAt",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean flag) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getBoundingBoxForCulling",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "cx")
|
||||
@Override
|
||||
public AxisAlignedBB cx() {
|
||||
return EMPTY_BOUND;
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "playSound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason entity_removalreason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.loader.TileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.item.ItemStack;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.block.entity.TileEntity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_18_R2.util.CraftMagicNumbers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk", name = "createTicker", type = Remap.Type.METHOD)
|
||||
private static final ReflectMethod<TickingBlockEntity> CREATE_TICKING_BLOCK = new ReflectMethod<>(
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 8))
|
||||
return def;
|
||||
|
||||
return tagCompound.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagString.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 4))
|
||||
return def;
|
||||
|
||||
return tagCompound.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, long value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagLong.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
NBTTagCompound skullOwner = tagCompound.contains("SkullOwner") ?
|
||||
tagCompound.getCompound("SkullOwner") : new NBTTagCompound();
|
||||
|
||||
NBTTagCompound properties = new NBTTagCompound();
|
||||
|
||||
NBTTagList textures = new NBTTagList();
|
||||
NBTTagCompound signature = new NBTTagCompound();
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature.getHandle());
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties.getHandle());
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
tagCompound.put("SkullOwner", skullOwner.getHandle());
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPC(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
|
||||
world.addBlockEntityTicker(tileEntityChunkLoader.ticker);
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = -1;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), true);
|
||||
}
|
||||
|
||||
return tileEntityChunkLoader;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long tileEntityLong = ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
|
||||
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
|
||||
if (tileEntityChunkLoader != null) {
|
||||
tileEntityChunkLoader.holograms.forEach(EntityHolograms::removeHologram);
|
||||
tileEntityChunkLoader.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle) {
|
||||
world.levelEvent(null, 2001, blockPosition.getHandle(),
|
||||
IBlockData.getId(world.getBlockStateNoMappings(blockPosition.getHandle())));
|
||||
}
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = 16;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
assert location.getWorld() != null;
|
||||
World world = new World(((CraftWorld) location.getWorld()).getHandle());
|
||||
|
||||
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
|
||||
TileEntity mobSpawner = new TileEntity(world.getBlockEntity(blockPosition.getHandle()));
|
||||
|
||||
mobSpawner.getSpawner().m = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.loader;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
|
||||
public record TileEntityChunkLoaderTicker(TileEntityChunkLoader tileEntityChunkLoader) implements TickingBlockEntity {
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a() {
|
||||
tileEntityChunkLoader.tick();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b() {
|
||||
return tileEntityChunkLoader.isRemoved();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
@Override
|
||||
public BlockPosition c() {
|
||||
return tileEntityChunkLoader.tilePosition.getHandle();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public String d() {
|
||||
return TileEntityTypes.a(tileEntityChunkLoader.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings;
|
||||
|
||||
public abstract class MappedObject<E> {
|
||||
|
||||
protected final E handle;
|
||||
|
||||
protected MappedObject(E handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public E getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.core;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
|
||||
public class BlockPosition extends MappedObject<net.minecraft.core.BlockPosition> {
|
||||
|
||||
public BlockPosition(double x, double y, double z) {
|
||||
this(new net.minecraft.core.BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
public BlockPosition(net.minecraft.core.BlockPosition handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getX",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public int getX() {
|
||||
return handle.u();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getY",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "v")
|
||||
public int getY() {
|
||||
return handle.v();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getZ",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "w")
|
||||
public int getZ() {
|
||||
return handle.w();
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.nbt;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
||||
public class NBTTagCompound extends MappedObject<net.minecraft.nbt.NBTTagCompound> {
|
||||
|
||||
public static NBTTagCompound ofNullable(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
return handle == null ? null : new NBTTagCompound(handle);
|
||||
}
|
||||
|
||||
public NBTTagCompound() {
|
||||
this(new net.minecraft.nbt.NBTTagCompound());
|
||||
}
|
||||
|
||||
public NBTTagCompound(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public boolean contains(String key, int type) {
|
||||
return handle.b(key, type);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "l")
|
||||
public String getString(String key) {
|
||||
return handle.l(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "put",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void put(String key, NBTBase nbtBase) {
|
||||
handle.a(key, nbtBase);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public long getLong(String key) {
|
||||
return handle.i(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "e")
|
||||
public boolean contains(String key) {
|
||||
return handle.e(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getCompound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "p")
|
||||
public NBTTagCompound getCompound(String key) {
|
||||
return new NBTTagCompound(handle.p(key));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "putString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void putString(String key, String value) {
|
||||
handle.a(key, value);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.World;
|
||||
|
||||
public class Entity extends MappedObject<net.minecraft.world.entity.Entity> {
|
||||
|
||||
public Entity(net.minecraft.world.entity.Entity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getLevel",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "W")
|
||||
public World getWorld() {
|
||||
return new World(handle.W());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "moveTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
handle.b(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.item;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemStack extends MappedObject<net.minecraft.world.item.ItemStack> {
|
||||
|
||||
public ItemStack(net.minecraft.world.item.ItemStack handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getOrCreateTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
return new NBTTagCompound(handle.u());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "t")
|
||||
public NBTTagCompound getTag() {
|
||||
return NBTTagCompound.ofNullable(handle.t());
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
|
||||
public class ChunkCoordIntPair extends MappedObject<net.minecraft.world.level.ChunkCoordIntPair> {
|
||||
|
||||
public ChunkCoordIntPair(net.minecraft.world.level.ChunkCoordIntPair handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "x",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "c")
|
||||
public int getX() {
|
||||
return handle.c;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "z",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "d")
|
||||
public int getZ() {
|
||||
return handle.d;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "asLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public static long asLong(int x, int z) {
|
||||
return net.minecraft.world.level.ChunkCoordIntPair.a(x, z);
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
public class World extends MappedObject<net.minecraft.world.level.World> {
|
||||
|
||||
public World(net.minecraft.world.level.World handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "setChunkForced",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void setChunkForced(int chunkX, int chunkZ, boolean load) {
|
||||
((WorldServer) handle).a(chunkX, chunkZ, load);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "addNewPlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
public void addNewPlayer(EntityPlayer entityPlayer) {
|
||||
((WorldServer) handle).c(entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "removePlayerImmediately",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void removePlayer(EntityPlayer entityPlayer, Entity.RemovalReason removalReason) {
|
||||
((WorldServer) handle).a(entityPlayer, removalReason);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockState",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a_")
|
||||
public net.minecraft.world.level.block.state.IBlockData getBlockStateNoMappings(BlockPosition blockPosition) {
|
||||
return handle.a_(blockPosition);
|
||||
}
|
||||
|
||||
public IBlockData getBlockState(BlockPosition blockPosition) {
|
||||
return new IBlockData(getBlockStateNoMappings(blockPosition));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c_")
|
||||
public TileEntity getBlockEntity(BlockPosition blockPosition) {
|
||||
return handle.c_(blockPosition);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.LevelWriter",
|
||||
name = "addFreshEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void addFreshEntity(Entity entity) {
|
||||
handle.b(entity);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "addBlockEntityTicker",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void addBlockEntityTicker(TickingBlockEntity blockEntityTicker) {
|
||||
handle.a(blockEntityTicker);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "levelEvent",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void levelEvent(EntityPlayer entityPlayer, int i, BlockPosition blockPosition, int j) {
|
||||
handle.a(entityPlayer, i, blockPosition, j);
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.block.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import net.minecraft.world.level.MobSpawnerAbstract;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
|
||||
public class TileEntity extends MappedObject<net.minecraft.world.level.block.entity.TileEntity> {
|
||||
|
||||
public TileEntity(net.minecraft.world.level.block.entity.TileEntity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.SpawnerBlockEntity",
|
||||
name = "getSpawner",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
public MobSpawnerAbstract getSpawner() {
|
||||
return ((TileEntityMobSpawner) handle).d();
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.block.state;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class IBlockData extends MappedObject<net.minecraft.world.level.block.state.IBlockData> {
|
||||
|
||||
public IBlockData(net.minecraft.world.level.block.state.IBlockData handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase",
|
||||
name = "getBlock",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public Block getBlock() {
|
||||
return handle.b();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.Block",
|
||||
name = "getId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public static int getId(net.minecraft.world.level.block.state.IBlockData blockData) {
|
||||
return Block.i(blockData);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.chunk;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_18_R2.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Chunk extends MappedObject<net.minecraft.world.level.chunk.Chunk> {
|
||||
|
||||
public Chunk(net.minecraft.world.level.chunk.Chunk handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk",
|
||||
name = "getBlockEntities",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "E")
|
||||
public Map<BlockPosition, TileEntity> getBlockEntities() {
|
||||
return handle.E();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.ChunkAccess",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
public ChunkCoordIntPair getPos() {
|
||||
return new ChunkCoordIntPair(handle.f());
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
group 'v1_19_R1'
|
||||
|
||||
java {
|
||||
toolchain {
|
||||
languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven { url "https://papermc.io/repo/repository/maven-public/" }
|
||||
maven { url "https://libraries.minecraft.net/" }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.spigotmc:v1_19_R1-Paper:git-4a4ee79"
|
||||
|
||||
compileOnly 'io.papermc.paper:paper-api:1.19-R0.1-SNAPSHOT'
|
||||
|
||||
compileOnly 'com.mojang:authlib:3.2.38'
|
||||
compileOnly 'com.mojang:datafixerupper:4.0.26'
|
||||
compileOnly 'com.mojang:brigadier:1.0.18'
|
||||
compileOnly 'com.google.guava:guava:31.1-jre'
|
||||
compileOnly 'com.google.code.gson:gson:2.9.0'
|
||||
compileOnly 'net.kyori:adventure-key:4.10.1'
|
||||
compileOnly 'net.kyori:examination-api:1.3.0'
|
||||
compileOnly 'net.kyori:adventure-api:4.10.1'
|
||||
compileOnly 'net.md-5:bungeecord-chat:1.16-R0.4'
|
||||
compileOnly 'io.netty:netty-all:4.1.77.Final'
|
||||
|
||||
compileOnly project(":API")
|
||||
compileOnly parent
|
||||
}
|
||||
|
||||
if (project.hasProperty('nms.compile_v1_19') && !Boolean.valueOf(project.findProperty("nms.compile_v1_19").toString())) {
|
||||
project.tasks.all { task -> task.enabled = false }
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.handlers.NPCHandler;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.entity.Entity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.npc.DummyChannel;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.network.NetworkManager;
|
||||
import net.minecraft.network.protocol.EnumProtocolDirection;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockDig;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInBlockPlace;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInChat;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInFlying;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInHeldItemSlot;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInUpdateSign;
|
||||
import net.minecraft.network.protocol.game.PacketPlayInWindowClick;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.PlayerInteractManager;
|
||||
import net.minecraft.server.network.PlayerConnection;
|
||||
import net.minecraft.world.level.EnumGamemode;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public final class ChunkLoaderNPC extends EntityPlayer implements com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC {
|
||||
|
||||
private static final ReflectMethod<Void> SET_GAMEMODE = new ReflectMethod<>(PlayerInteractManager.class,
|
||||
1, EnumGamemode.class, EnumGamemode.class);
|
||||
|
||||
private final World world;
|
||||
private final AxisAlignedBB boundingBox;
|
||||
|
||||
private boolean dieCall = false;
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerPlayer", name = "gameMode", type = Remap.Type.FIELD, remappedName = "d")
|
||||
public ChunkLoaderNPC(MinecraftServer minecraftServer, Location location, UUID uuid) {
|
||||
super(minecraftServer, ((CraftWorld) location.getWorld()).getHandle(),
|
||||
new GameProfile(uuid, NPCHandler.getName(location.getWorld().getName())), null);
|
||||
|
||||
Entity entity = new Entity(this);
|
||||
this.world = entity.getWorld();
|
||||
this.boundingBox = new AxisAlignedBB(new BlockPosition(location.getX(), location.getY(), location.getZ()));
|
||||
|
||||
this.b = new DummyPlayerConnection(minecraftServer, this);
|
||||
|
||||
SET_GAMEMODE.invoke(this.d, EnumGamemode.b, null);
|
||||
clientViewDistance = 1;
|
||||
|
||||
fauxSleeping = true;
|
||||
|
||||
spawnIn(this.world.getHandle());
|
||||
entity.moveTo(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
|
||||
this.world.addNewPlayer(this);
|
||||
|
||||
super.a(this.boundingBox);
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUniqueId() {
|
||||
return getBukkitEntity().getUniqueId();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "discard",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "ah")
|
||||
@Override
|
||||
public void die() {
|
||||
ah();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason removalReason) {
|
||||
if (!dieCall) {
|
||||
dieCall = true;
|
||||
this.world.removePlayer(this, RemovalReason.d);
|
||||
dieCall = false;
|
||||
} else {
|
||||
super.a(removalReason);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation() {
|
||||
return getBukkitEntity().getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
public static class DummyNetworkManager extends NetworkManager {
|
||||
|
||||
@Remap(classPath = "net.minecraft.network.protocol.PacketFlow", name = "SERVERBOUND", type = Remap.Type.FIELD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "channel", type = Remap.Type.FIELD, remappedName = "m")
|
||||
@Remap(classPath = "net.minecraft.network.Connection", name = "address", type = Remap.Type.FIELD, remappedName = "n")
|
||||
DummyNetworkManager() {
|
||||
super(EnumProtocolDirection.a);
|
||||
this.m = new DummyChannel();
|
||||
this.n = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class DummyPlayerConnection extends PlayerConnection {
|
||||
|
||||
DummyPlayerConnection(MinecraftServer minecraftServer, EntityPlayer entityPlayer) {
|
||||
super(minecraftServer, new DummyNetworkManager(), entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleContainerClick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInWindowClick packetPlayInWindowClick) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleMovePlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInFlying packetPlayInFlying) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSignUpdate",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInUpdateSign packetPlayInUpdateSign) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handlePlayerAction",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockDig packetPlayInBlockDig) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleUseItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInBlockPlace packetPlayInBlockPlace) {
|
||||
|
||||
}
|
||||
|
||||
public void disconnect(String s) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleSetCarriedItem",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInHeldItemSlot packetPlayInHeldItemSlot) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "handleChat",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(PacketPlayInChat packetPlayInChat) {
|
||||
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.network.ServerGamePacketListenerImpl",
|
||||
name = "send",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void a(Packet<?> packet) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,227 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1;
|
||||
|
||||
import com.bgsoftware.wildloaders.api.holograms.Hologram;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.network.chat.IChatBaseComponent;
|
||||
import net.minecraft.sounds.SoundEffect;
|
||||
import net.minecraft.world.EnumHand;
|
||||
import net.minecraft.world.EnumInteractionResult;
|
||||
import net.minecraft.world.damagesource.DamageSource;
|
||||
import net.minecraft.world.entity.EnumItemSlot;
|
||||
import net.minecraft.world.entity.decoration.EntityArmorStand;
|
||||
import net.minecraft.world.entity.player.EntityHuman;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
import net.minecraft.world.level.World;
|
||||
import net.minecraft.world.phys.AxisAlignedBB;
|
||||
import net.minecraft.world.phys.Vec3D;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftArmorStand;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftChatMessage;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class EntityHolograms extends EntityArmorStand implements Hologram {
|
||||
|
||||
private static final AxisAlignedBB EMPTY_BOUND = new AxisAlignedBB(0D, 0D, 0D, 0D, 0D, 0D);
|
||||
|
||||
private CraftEntity bukkitEntity;
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setInvisible", type = Remap.Type.METHOD, remappedName = "j")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setSmall", type = Remap.Type.METHOD, remappedName = "a")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setShowArms", type = Remap.Type.METHOD, remappedName = "r")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setNoGravity", type = Remap.Type.METHOD, remappedName = "e")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setNoBasePlate", type = Remap.Type.METHOD, remappedName = "s")
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand", name = "setMarker", type = Remap.Type.METHOD, remappedName = "t")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setCustomNameVisible", type = Remap.Type.METHOD, remappedName = "n")
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity", name = "setBoundingBox", type = Remap.Type.METHOD, remappedName = "a")
|
||||
public EntityHolograms(World world, double x, double y, double z) {
|
||||
super(world, x, y, z);
|
||||
j(true); // Invisible
|
||||
a(true); // Small
|
||||
r(false); // Arms
|
||||
e(true); // No Gravity
|
||||
s(true); // Base Plate
|
||||
t(true); // Marker
|
||||
super.collides = false;
|
||||
super.n(true); // Custom name visible
|
||||
super.a(EMPTY_BOUND);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public void setHologramName(String name) {
|
||||
super.b(CraftChatMessage.fromStringOrNull(name));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void removeHologram() {
|
||||
super.a(RemovalReason.b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.entity.Entity getEntity() {
|
||||
return getBukkitEntity();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "k")
|
||||
@Override
|
||||
public void k() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.y) {
|
||||
this.y = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "onGround",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "y")
|
||||
@Override
|
||||
public void inactiveTick() {
|
||||
// Disable normal ticking for this entity.
|
||||
|
||||
// Workaround to force EntityTrackerEntry to send a teleport packet immediately after spawning this entity.
|
||||
if (this.y) {
|
||||
this.y = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "addAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public void b(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveAsPassenger",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public boolean d(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return false;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "saveWithoutId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
@Override
|
||||
public NBTTagCompound f(NBTTagCompound nbttagcompound) {
|
||||
// Do not save NBT.
|
||||
return nbttagcompound;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "readAdditionalSaveData",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "load",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "g")
|
||||
@Override
|
||||
public void g(NBTTagCompound nbttagcompound) {
|
||||
// Do not load NBT.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "isInvulnerableTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b(DamageSource source) {
|
||||
/*
|
||||
* The field Entity.invulnerable is private.
|
||||
* It's only used while saving NBTTags, but since the entity would be killed
|
||||
* on chunk unload, we prefer to override isInvulnerable().
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomName",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public void b(IChatBaseComponent ichatbasecomponent) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "setCustomNameVisible",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "n")
|
||||
@Override
|
||||
public void n(boolean flag) {
|
||||
// Locks the custom name.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.decoration.ArmorStand",
|
||||
name = "interactAt",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public EnumInteractionResult a(EntityHuman human, Vec3D vec3d, EnumHand enumhand) {
|
||||
// Prevent stand being equipped
|
||||
return EnumInteractionResult.d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemSlot(EnumItemSlot enumitemslot, ItemStack itemstack, boolean flag) {
|
||||
// Prevent stand being equipped
|
||||
}
|
||||
|
||||
public void forceSetBoundingBox(AxisAlignedBB boundingBox) {
|
||||
super.a(boundingBox);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "playSound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(SoundEffect soundeffect, float f, float f1) {
|
||||
// Remove sounds.
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "remove",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a(RemovalReason entity_removalreason) {
|
||||
// Prevent being killed.
|
||||
}
|
||||
|
||||
@Override
|
||||
public CraftEntity getBukkitEntity() {
|
||||
if (bukkitEntity == null) {
|
||||
bukkitEntity = new CraftArmorStand((CraftServer) Bukkit.getServer(), this);
|
||||
}
|
||||
return bukkitEntity;
|
||||
}
|
||||
|
||||
}
|
@ -1,206 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1;
|
||||
|
||||
import com.bgsoftware.common.reflection.ReflectMethod;
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.loader.TileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.core.BlockPosition;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.item.ItemStack;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.block.entity.TileEntity;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.chunk.Chunk;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.nbt.NBTTagLong;
|
||||
import net.minecraft.nbt.NBTTagString;
|
||||
import net.minecraft.world.level.block.entity.BlockEntityTicker;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftChunk;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftServer;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.craftbukkit.v1_19_R1.util.CraftMagicNumbers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk", name = "createTicker", type = Remap.Type.METHOD)
|
||||
private static final ReflectMethod<TickingBlockEntity> CREATE_TICKING_BLOCK = new ReflectMethod<>(
|
||||
net.minecraft.world.level.chunk.Chunk.class, "a",
|
||||
net.minecraft.world.level.block.entity.TileEntity.class, BlockEntityTicker.class);
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return ((CraftMagicNumbers) CraftMagicNumbers.INSTANCE).getMappingsVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 8))
|
||||
return def;
|
||||
|
||||
return tagCompound.getString(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, String value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagString.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getTag(org.bukkit.inventory.ItemStack itemStack, String key, long def) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getTag();
|
||||
|
||||
if (tagCompound == null || !tagCompound.contains(key, 4))
|
||||
return def;
|
||||
|
||||
return tagCompound.getLong(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack setTag(org.bukkit.inventory.ItemStack itemStack, String key, long value) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
tagCompound.put(key, NBTTagLong.a(value));
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public org.bukkit.inventory.ItemStack getPlayerSkull(org.bukkit.inventory.ItemStack itemStack, String texture) {
|
||||
ItemStack nmsItem = new ItemStack(CraftItemStack.asNMSCopy(itemStack));
|
||||
NBTTagCompound tagCompound = nmsItem.getOrCreateTag();
|
||||
|
||||
NBTTagCompound skullOwner = tagCompound.contains("SkullOwner") ?
|
||||
tagCompound.getCompound("SkullOwner") : new NBTTagCompound();
|
||||
|
||||
NBTTagCompound properties = new NBTTagCompound();
|
||||
|
||||
NBTTagList textures = new NBTTagList();
|
||||
NBTTagCompound signature = new NBTTagCompound();
|
||||
signature.putString("Value", texture);
|
||||
textures.add(signature.getHandle());
|
||||
|
||||
properties.put("textures", textures);
|
||||
|
||||
skullOwner.put("Properties", properties.getHandle());
|
||||
skullOwner.putString("Id", UUID.randomUUID().toString());
|
||||
|
||||
tagCompound.put("SkullOwner", skullOwner.getHandle());
|
||||
|
||||
return CraftItemStack.asBukkitCopy(nmsItem.getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public com.bgsoftware.wildloaders.api.npc.ChunkLoaderNPC createNPC(Location location, UUID uuid) {
|
||||
return new ChunkLoaderNPC(((CraftServer) Bukkit.getServer()).getServer(), location, uuid);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public ITileEntityChunkLoader createLoader(ChunkLoader chunkLoader) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
TileEntityChunkLoader tileEntityChunkLoader = new TileEntityChunkLoader(chunkLoader, world, blockPosition);
|
||||
world.addBlockEntityTicker(tileEntityChunkLoader.ticker);
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = -1;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), true);
|
||||
}
|
||||
|
||||
return tileEntityChunkLoader;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void removeLoader(ChunkLoader chunkLoader, boolean spawnParticle) {
|
||||
Location loaderLoc = chunkLoader.getLocation();
|
||||
assert loaderLoc.getWorld() != null;
|
||||
|
||||
World world = new World(((CraftWorld) loaderLoc.getWorld()).getHandle());
|
||||
BlockPosition blockPosition = new BlockPosition(loaderLoc.getX(), loaderLoc.getY(), loaderLoc.getZ());
|
||||
|
||||
long tileEntityLong = ChunkCoordIntPair.asLong(blockPosition.getX() >> 4, blockPosition.getZ() >> 4);
|
||||
TileEntityChunkLoader tileEntityChunkLoader = TileEntityChunkLoader.tileEntityChunkLoaderMap.remove(tileEntityLong);
|
||||
if (tileEntityChunkLoader != null) {
|
||||
tileEntityChunkLoader.holograms.forEach(EntityHolograms::removeHologram);
|
||||
tileEntityChunkLoader.removed = true;
|
||||
}
|
||||
|
||||
if (spawnParticle) {
|
||||
world.levelEvent(null, 2001, blockPosition.getHandle(),
|
||||
IBlockData.getId(world.getBlockStateNoMappings(blockPosition.getHandle())));
|
||||
}
|
||||
|
||||
for (org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
|
||||
Chunk chunk = new Chunk(((CraftChunk) bukkitChunk).getHandle());
|
||||
chunk.getBlockEntities().values().stream()
|
||||
.filter(nmsTileEntity -> nmsTileEntity instanceof TileEntityMobSpawner)
|
||||
.forEach(nmsTileEntity -> {
|
||||
TileEntity tileEntity = new TileEntity(nmsTileEntity);
|
||||
tileEntity.getSpawner().m = 16;
|
||||
});
|
||||
|
||||
ChunkCoordIntPair chunkCoords = chunk.getPos();
|
||||
|
||||
world.setChunkForced(chunkCoords.getX(), chunkCoords.getZ(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.BaseSpawner",
|
||||
name = "requiredPlayerRange",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "m")
|
||||
@Override
|
||||
public void updateSpawner(Location location, boolean reset) {
|
||||
assert location.getWorld() != null;
|
||||
World world = new World(((CraftWorld) location.getWorld()).getHandle());
|
||||
|
||||
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
|
||||
TileEntity mobSpawner = new TileEntity(world.getBlockEntity(blockPosition.getHandle()));
|
||||
|
||||
mobSpawner.getSpawner().m = reset ? 16 : -1;
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.loader;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntityTypes;
|
||||
|
||||
public record TileEntityChunkLoaderTicker(TileEntityChunkLoader tileEntityChunkLoader) implements TickingBlockEntity {
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "tick",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
@Override
|
||||
public void a() {
|
||||
tileEntityChunkLoader.tick();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "isRemoved",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
@Override
|
||||
public boolean b() {
|
||||
return tileEntityChunkLoader.isRemoved();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
@Override
|
||||
public BlockPosition c() {
|
||||
return tileEntityChunkLoader.tilePosition.getHandle();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.TickingBlockEntity",
|
||||
name = "getType",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
@Override
|
||||
public String d() {
|
||||
return TileEntityTypes.a(tileEntityChunkLoader.getType()) + "";
|
||||
}
|
||||
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings;
|
||||
|
||||
public abstract class MappedObject<E> {
|
||||
|
||||
protected final E handle;
|
||||
|
||||
protected MappedObject(E handle) {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
public E getHandle() {
|
||||
return handle;
|
||||
}
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.core;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
|
||||
public class BlockPosition extends MappedObject<net.minecraft.core.BlockPosition> {
|
||||
|
||||
public BlockPosition(double x, double y, double z) {
|
||||
this(new net.minecraft.core.BlockPosition(x, y, z));
|
||||
}
|
||||
|
||||
public BlockPosition(net.minecraft.core.BlockPosition handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getX",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public int getX() {
|
||||
return handle.u();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getY",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "v")
|
||||
public int getY() {
|
||||
return handle.v();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.core.Vec3i",
|
||||
name = "getZ",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "w")
|
||||
public int getZ() {
|
||||
return handle.w();
|
||||
}
|
||||
|
||||
}
|
@ -1,77 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.nbt;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import net.minecraft.nbt.NBTBase;
|
||||
|
||||
public class NBTTagCompound extends MappedObject<net.minecraft.nbt.NBTTagCompound> {
|
||||
|
||||
public static NBTTagCompound ofNullable(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
return handle == null ? null : new NBTTagCompound(handle);
|
||||
}
|
||||
|
||||
public NBTTagCompound() {
|
||||
this(new net.minecraft.nbt.NBTTagCompound());
|
||||
}
|
||||
|
||||
public NBTTagCompound(net.minecraft.nbt.NBTTagCompound handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public boolean contains(String key, int type) {
|
||||
return handle.b(key, type);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "l")
|
||||
public String getString(String key) {
|
||||
return handle.l(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "put",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void put(String key, NBTBase nbtBase) {
|
||||
handle.a(key, nbtBase);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public long getLong(String key) {
|
||||
return handle.i(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "contains",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "e")
|
||||
public boolean contains(String key) {
|
||||
return handle.e(key);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "getCompound",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "p")
|
||||
public NBTTagCompound getCompound(String key) {
|
||||
return new NBTTagCompound(handle.p(key));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.nbt.CompoundTag",
|
||||
name = "putString",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void putString(String key, String value) {
|
||||
handle.a(key, value);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.World;
|
||||
|
||||
public class Entity extends MappedObject<net.minecraft.world.entity.Entity> {
|
||||
|
||||
public Entity(net.minecraft.world.entity.Entity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "getLevel",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "W")
|
||||
public World getWorld() {
|
||||
return new World(handle.W());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.entity.Entity",
|
||||
name = "moveTo",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void moveTo(double x, double y, double z, float yaw, float pitch) {
|
||||
handle.b(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.item;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
public class ItemStack extends MappedObject<net.minecraft.world.item.ItemStack> {
|
||||
|
||||
public ItemStack(net.minecraft.world.item.ItemStack handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getOrCreateTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "v")
|
||||
public NBTTagCompound getOrCreateTag() {
|
||||
return new NBTTagCompound(handle.v());
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.item.ItemStack",
|
||||
name = "getTag",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "u")
|
||||
public NBTTagCompound getTag() {
|
||||
return NBTTagCompound.ofNullable(handle.u());
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
|
||||
public class ChunkCoordIntPair extends MappedObject<net.minecraft.world.level.ChunkCoordIntPair> {
|
||||
|
||||
public ChunkCoordIntPair(net.minecraft.world.level.ChunkCoordIntPair handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "x",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "e")
|
||||
public int getX() {
|
||||
return handle.e;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "z",
|
||||
type = Remap.Type.FIELD,
|
||||
remappedName = "f")
|
||||
public int getZ() {
|
||||
return handle.f;
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.ChunkPos",
|
||||
name = "asLong",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
public static long asLong(int x, int z) {
|
||||
return net.minecraft.world.level.ChunkCoordIntPair.c(x, z);
|
||||
}
|
||||
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.block.state.IBlockData;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.server.level.EntityPlayer;
|
||||
import net.minecraft.server.level.WorldServer;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.level.block.entity.TickingBlockEntity;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
public class World extends MappedObject<net.minecraft.world.level.World> {
|
||||
|
||||
public World(net.minecraft.world.level.World handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "setChunkForced",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void setChunkForced(int chunkX, int chunkZ, boolean load) {
|
||||
((WorldServer) handle).a(chunkX, chunkZ, load);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "addNewPlayer",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c")
|
||||
public void addNewPlayer(EntityPlayer entityPlayer) {
|
||||
((WorldServer) handle).c(entityPlayer);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "removePlayerImmediately",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void removePlayer(EntityPlayer entityPlayer, Entity.RemovalReason removalReason) {
|
||||
((WorldServer) handle).a(entityPlayer, removalReason);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockState",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a_")
|
||||
public net.minecraft.world.level.block.state.IBlockData getBlockStateNoMappings(BlockPosition blockPosition) {
|
||||
return handle.a_(blockPosition);
|
||||
}
|
||||
|
||||
public IBlockData getBlockState(BlockPosition blockPosition) {
|
||||
return new IBlockData(getBlockStateNoMappings(blockPosition));
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "getBlockEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "c_")
|
||||
public TileEntity getBlockEntity(BlockPosition blockPosition) {
|
||||
return handle.c_(blockPosition);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.LevelWriter",
|
||||
name = "addFreshEntity",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public void addFreshEntity(Entity entity) {
|
||||
handle.b(entity);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.Level",
|
||||
name = "addBlockEntityTicker",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void addBlockEntityTicker(TickingBlockEntity blockEntityTicker) {
|
||||
handle.a(blockEntityTicker);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.server.level.ServerLevel",
|
||||
name = "levelEvent",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "a")
|
||||
public void levelEvent(EntityPlayer entityPlayer, int i, BlockPosition blockPosition, int j) {
|
||||
handle.a(entityPlayer, i, blockPosition, j);
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.block.entity;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import net.minecraft.world.level.MobSpawnerAbstract;
|
||||
import net.minecraft.world.level.block.entity.TileEntityMobSpawner;
|
||||
|
||||
public class TileEntity extends MappedObject<net.minecraft.world.level.block.entity.TileEntity> {
|
||||
|
||||
public TileEntity(net.minecraft.world.level.block.entity.TileEntity handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.entity.SpawnerBlockEntity",
|
||||
name = "getSpawner",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "d")
|
||||
public MobSpawnerAbstract getSpawner() {
|
||||
return ((TileEntityMobSpawner) handle).d();
|
||||
}
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.block.state;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
|
||||
public class IBlockData extends MappedObject<net.minecraft.world.level.block.state.IBlockData> {
|
||||
|
||||
public IBlockData(net.minecraft.world.level.block.state.IBlockData handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.state.BlockBehaviour$BlockStateBase",
|
||||
name = "getBlock",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "b")
|
||||
public Block getBlock() {
|
||||
return handle.b();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.block.Block",
|
||||
name = "getId",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "i")
|
||||
public static int getId(net.minecraft.world.level.block.state.IBlockData blockData) {
|
||||
return Block.i(blockData);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.chunk;
|
||||
|
||||
import com.bgsoftware.common.remaps.Remap;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.MappedObject;
|
||||
import com.bgsoftware.wildloaders.nms.v1_19_R1.mappings.net.minecraft.world.level.ChunkCoordIntPair;
|
||||
import net.minecraft.core.BlockPosition;
|
||||
import net.minecraft.world.level.block.entity.TileEntity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class Chunk extends MappedObject<net.minecraft.world.level.chunk.Chunk> {
|
||||
|
||||
public Chunk(net.minecraft.world.level.chunk.Chunk handle) {
|
||||
super(handle);
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.LevelChunk",
|
||||
name = "getBlockEntities",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "E")
|
||||
public Map<BlockPosition, TileEntity> getBlockEntities() {
|
||||
return handle.E();
|
||||
}
|
||||
|
||||
@Remap(classPath = "net.minecraft.world.level.chunk.ChunkAccess",
|
||||
name = "getPos",
|
||||
type = Remap.Type.METHOD,
|
||||
remappedName = "f")
|
||||
public ChunkCoordIntPair getPos() {
|
||||
return new ChunkCoordIntPair(handle.f());
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_7_R4;
|
||||
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_7_R4.loader.TileEntityChunkLoader;
|
||||
@ -22,16 +21,8 @@ import org.bukkit.craftbukkit.v1_7_R4.util.LongHash;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
|
@ -1,6 +1,5 @@
|
||||
package com.bgsoftware.wildloaders.nms.v1_8_R3;
|
||||
|
||||
import com.bgsoftware.wildloaders.WildLoadersPlugin;
|
||||
import com.bgsoftware.wildloaders.api.loaders.ChunkLoader;
|
||||
import com.bgsoftware.wildloaders.loaders.ITileEntityChunkLoader;
|
||||
import com.bgsoftware.wildloaders.nms.v1_8_R3.loader.TileEntityChunkLoader;
|
||||
@ -22,16 +21,8 @@ import org.bukkit.craftbukkit.v1_8_R3.util.LongHash;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public final class NMSAdapter implements com.bgsoftware.wildloaders.nms.NMSAdapter {
|
||||
|
||||
private static final WildLoadersPlugin plugin = WildLoadersPlugin.getPlugin();
|
||||
|
||||
@Override
|
||||
public String getMappingsHash() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTag(org.bukkit.inventory.ItemStack itemStack, String key, String def) {
|
||||
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
|
||||
|
Loading…
Reference in New Issue
Block a user