[CI SKIP] Updated mapping names to match minecraft's

This commit is contained in:
OmerBenGera 2022-03-12 20:25:49 +02:00
parent dbf47ce159
commit 579dfe8bfa
3 changed files with 63 additions and 62 deletions

View File

@ -39,15 +39,15 @@ public final class ChunkLoaderNPC_v1_18_R2 extends EntityPlayer implements Chunk
this.b = new DummyPlayerConnection(minecraftServer, this);
NMSMappings_v1_18_R2.setGameMode(this.d, EnumGamemode.b);
NMSMappings_v1_18_R2.setGameModeForPlayer(this.d, EnumGamemode.b);
clientViewDistance = 1;
fauxSleeping = true;
spawnIn(getWorld(this));
setLocation(this, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
moveTo(this, location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
addPlayerJoin(getWorldServer(this), this);
addNewPlayer(getLevel(this), this);
super.a(EMPTY_BOUND);
}
@ -71,7 +71,7 @@ public final class ChunkLoaderNPC_v1_18_R2 extends EntityPlayer implements Chunk
public void a(RemovalReason removalReason) {
if(!dieCall) {
dieCall = true;
removePlayer(getWorldServer(this), this);
removePlayer(getLevel(this), this);
dieCall = false;
}
else {

View File

@ -54,7 +54,7 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = getOrCreateTag(nmsItem);
if(!hasKeyOfType(tagCompound, key, 8))
if(!contains(tagCompound, key, 8))
return def;
return getString(tagCompound, key);
@ -65,7 +65,7 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = getOrCreateTag(nmsItem);
set(tagCompound, key, NBTTagString.a(value));
put(tagCompound, key, NBTTagString.a(value));
return CraftItemStack.asBukkitCopy(nmsItem);
}
@ -75,7 +75,7 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = getOrCreateTag(nmsItem);
if(!hasKeyOfType(tagCompound, key, 4))
if(!contains(tagCompound, key, 4))
return def;
return getLong(tagCompound, key);
@ -86,7 +86,7 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
ItemStack nmsItem = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tagCompound = getOrCreateTag(nmsItem);
set(tagCompound, key, NBTTagLong.a(value));
put(tagCompound, key, NBTTagLong.a(value));
return CraftItemStack.asBukkitCopy(nmsItem);
}
@ -97,22 +97,22 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
NBTTagCompound nbtTagCompound = getOrCreateTag(nmsItem);
NBTTagCompound skullOwner = hasKey(nbtTagCompound, "SkullOwner") ?
NBTTagCompound skullOwner = NMSMappings_v1_18_R2.contains(nbtTagCompound, "SkullOwner") ?
getCompound(nbtTagCompound, "SkullOwner") : new NBTTagCompound();
NBTTagCompound properties = new NBTTagCompound();
NBTTagList textures = new NBTTagList();
NBTTagCompound signature = new NBTTagCompound();
setString(signature, "Value", texture);
putString(signature, "Value", texture);
textures.add(signature);
set(properties, "textures", textures);
put(properties, "textures", textures);
set(skullOwner, "Properties", properties);
setString(skullOwner,"Id", UUID.randomUUID().toString());
put(skullOwner, "Properties", properties);
putString(skullOwner,"Id", UUID.randomUUID().toString());
set(nbtTagCompound, "SkullOwner", skullOwner);
put(nbtTagCompound, "SkullOwner", skullOwner);
return CraftItemStack.asBukkitCopy(nmsItem);
}
@ -134,12 +134,12 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
getTileEntities(chunk).values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
getBlockEntities(chunk).values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> getSpawner((TileEntityMobSpawner) tileEntity).m = -1);
ChunkCoordIntPair chunkCoords = getPos(chunk);
setForceLoaded(world, chunkCoords.c, chunkCoords.d, true);
setChunkForced(world, chunkCoords.c, chunkCoords.d, true);
}
return tileEntityChunkLoader;
@ -160,16 +160,16 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
}
if(spawnParticle)
world.a(null, 2001, blockPosition, getCombinedId(getType(world, blockPosition)));
world.a(null, 2001, blockPosition, getId(getBlockState(world, blockPosition)));
for(org.bukkit.Chunk bukkitChunk : chunkLoader.getLoadedChunks()) {
Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
getTileEntities(chunk).values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
getBlockEntities(chunk).values().stream().filter(tileEntity -> tileEntity instanceof TileEntityMobSpawner)
.forEach(tileEntity -> getSpawner((TileEntityMobSpawner) tileEntity).m = 16);
ChunkCoordIntPair chunkCoords = getPos(chunk);
setForceLoaded(world, chunkCoords.c, chunkCoords.d, false);
setChunkForced(world, chunkCoords.c, chunkCoords.d, false);
}
}
@ -179,8 +179,8 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
World world = ((CraftWorld) location.getWorld()).getHandle();
BlockPosition blockPosition = new BlockPosition(location.getX(), location.getY(), location.getZ());
IBlockData blockData = getType(world, blockPosition);
TileEntityMobSpawner mobSpawner = (TileEntityMobSpawner) getTileEntity(world, blockPosition);
IBlockData blockData = getBlockState(world, blockPosition);
TileEntityMobSpawner mobSpawner = (TileEntityMobSpawner) getBlockEntity(world, blockPosition);
if(mobSpawner == null)
return;
@ -202,14 +202,14 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
private boolean removed = false;
TileEntityChunkLoader(ChunkLoader chunkLoader, World world, BlockPosition blockPosition){
super(TileEntityTypes.v, blockPosition, getType(world, blockPosition));
super(TileEntityTypes.v, blockPosition, getBlockState(world, blockPosition));
this.chunkLoader = (WChunkLoader) chunkLoader;
this.ticker = new TileEntityChunkLoaderTicker(this);
a(world);
loaderBlock = getBlock(getType(world, blockPosition));
loaderBlock = getBlock(getBlockState(world, blockPosition));
if(!this.chunkLoader.isInfinite()) {
long timeLeft = chunkLoader.getTimeLeft();
@ -230,12 +230,12 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
List<String> hologramLines = this.chunkLoader.getHologramLines();
double currentY = getY(getPosition(this)) + 1;
double currentY = getY(getBlockPos(this)) + 1;
for(int i = hologramLines.size(); i > 0; i--){
EntityHolograms_v1_18_R2 hologram = new EntityHolograms_v1_18_R2(world,
getX(getPosition(this)) + 0.5, currentY, getZ(getPosition(this)) + 0.5);
getX(getBlockPos(this)) + 0.5, currentY, getZ(getBlockPos(this)) + 0.5);
updateName(hologram, hologramLines.get(i - 1));
addEntity(world, hologram);
addFreshEntity(world, hologram);
currentY += 0.23;
holograms.add(hologram);
}
@ -248,7 +248,7 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
currentTick = 0;
assert this.n != null;
if(chunkLoader.isNotActive() || getBlock(getType(this.n, getPosition(this))) != loaderBlock){
if(chunkLoader.isNotActive() || getBlock(getBlockState(this.n, getBlockPos(this))) != loaderBlock){
chunkLoader.remove();
return;
}
@ -321,12 +321,12 @@ public final class NMSAdapter_v1_18_R2 implements NMSAdapter {
@Override
public BlockPosition c() {
return getPosition(tileEntityChunkLoader);
return getBlockPos(tileEntityChunkLoader);
}
@Override
public String d() {
return TileEntityTypes.a(getTileType(tileEntityChunkLoader)) + "";
return TileEntityTypes.a(getType(tileEntityChunkLoader)) + "";
}
}

View File

@ -12,6 +12,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.ChunkCoordIntPair;
import net.minecraft.world.level.EnumGamemode;
import net.minecraft.world.level.IWorldWriter;
import net.minecraft.world.level.MobSpawnerAbstract;
import net.minecraft.world.level.World;
import net.minecraft.world.level.block.Block;
@ -36,7 +37,7 @@ public final class NMSMappings_v1_18_R2 {
return itemStack.u();
}
public static boolean hasKeyOfType(NBTTagCompound nbtTagCompound, String key, int type) {
public static boolean contains(NBTTagCompound nbtTagCompound, String key, int type) {
return nbtTagCompound.b(key, type);
}
@ -44,7 +45,7 @@ public final class NMSMappings_v1_18_R2 {
return nbtTagCompound.l(key);
}
public static void set(NBTTagCompound nbtTagCompound, String key, NBTBase nbtBase) {
public static void put(NBTTagCompound nbtTagCompound, String key, NBTBase nbtBase) {
nbtTagCompound.a(key, nbtBase);
}
@ -52,7 +53,7 @@ public final class NMSMappings_v1_18_R2 {
return nbtTagCompound.i(key);
}
public static boolean hasKey(NBTTagCompound nbtTagCompound, String key) {
public static boolean contains(NBTTagCompound nbtTagCompound, String key) {
return nbtTagCompound.e(key);
}
@ -60,30 +61,38 @@ public final class NMSMappings_v1_18_R2 {
return nbtTagCompound.p(key);
}
public static void setString(NBTTagCompound nbtTagCompound, String key, String value) {
public static void putString(NBTTagCompound nbtTagCompound, String key, String value) {
nbtTagCompound.a(key, value);
}
public static Map<BlockPosition, TileEntity> getTileEntities(IChunkAccess chunkAccess) {
public static Map<BlockPosition, TileEntity> getBlockEntities(IChunkAccess chunkAccess) {
return chunkAccess.i;
}
public static MobSpawnerAbstract getSpawner(TileEntityMobSpawner tileEntityMobSpawner) {
return tileEntityMobSpawner.d();
}
public static void setForceLoaded(WorldServer worldServer, int chunkX, int chunkZ, boolean load) {
worldServer.a(chunkX, chunkZ, load);
}
public static ChunkCoordIntPair getPos(IChunkAccess chunk) {
return chunk.f();
}
public static int getCombinedId(IBlockData blockData) {
public static MobSpawnerAbstract getSpawner(TileEntityMobSpawner tileEntityMobSpawner) {
return tileEntityMobSpawner.d();
}
public static void setChunkForced(WorldServer worldServer, int chunkX, int chunkZ, boolean load) {
worldServer.a(chunkX, chunkZ, load);
}
public static void addNewPlayer(WorldServer worldServer, EntityPlayer entityPlayer) {
worldServer.c(entityPlayer);
}
public static int getId(IBlockData blockData) {
return Block.i(blockData);
}
public static Block getBlock(IBlockData blockData) {
return blockData.b();
}
public static int getX(BaseBlockPosition baseBlockPosition) {
return baseBlockPosition.u();
}
@ -96,47 +105,39 @@ public final class NMSMappings_v1_18_R2 {
return baseBlockPosition.w();
}
public static IBlockData getType(World world, BlockPosition blockPosition) {
public static IBlockData getBlockState(World world, BlockPosition blockPosition) {
return world.a_(blockPosition);
}
public static TileEntity getTileEntity(World world, BlockPosition blockPosition) {
public static TileEntity getBlockEntity(World world, BlockPosition blockPosition) {
return world.c_(blockPosition);
}
public static Block getBlock(IBlockData blockData) {
return blockData.b();
public static void addFreshEntity(IWorldWriter worldWriter, Entity entity) {
worldWriter.b(entity);
}
public static BlockPosition getPosition(TileEntity tileEntity) {
public static BlockPosition getBlockPos(TileEntity tileEntity) {
return tileEntity.p();
}
public static void addEntity(World world, Entity entity) {
world.b(entity);
}
public static TileEntityTypes<?> getTileType(TileEntity tileEntity) {
public static TileEntityTypes<?> getType(TileEntity tileEntity) {
return tileEntity.u();
}
public static void setGameMode(PlayerInteractManager playerInteractManager, EnumGamemode gamemode) {
public static void setGameModeForPlayer(PlayerInteractManager playerInteractManager, EnumGamemode gamemode) {
SET_GAMEMODE.invoke(playerInteractManager, gamemode, null);
}
public static World getWorld(Entity entity) {
return entity.cA();
return entity.W();
}
public static void setLocation(Entity entity, double x, double y, double z, float yaw, float pitch) {
entity.a(x, y, z, yaw, pitch);
public static void moveTo(Entity entity, double x, double y, double z, float yaw, float pitch) {
entity.b(x, y, z, yaw, pitch);
}
public static void addPlayerJoin(WorldServer worldServer, EntityPlayer entityPlayer) {
worldServer.c(entityPlayer);
}
public static WorldServer getWorldServer(EntityPlayer entityPlayer) {
public static WorldServer getLevel(EntityPlayer entityPlayer) {
return entityPlayer.x();
}