diff --git a/.github/actions/setup_project_workspace/action.yml b/.github/actions/setup_project_workspace/action.yml
index d395375a..a5757f8f 100644
--- a/.github/actions/setup_project_workspace/action.yml
+++ b/.github/actions/setup_project_workspace/action.yml
@@ -19,5 +19,5 @@ runs:
- uses: SpraxDev/Action-SpigotMC@v4
with:
- versions: 1.18.2, 1.19
+ versions: 1.18.1, 1.18.2, 1.19
remapped: true
diff --git a/NMS/NMS-v1_18_R1/pom.xml b/NMS/NMS-v1_18_R1/pom.xml
index 54fa5105..8f3e522d 100644
--- a/NMS/NMS-v1_18_R1/pom.xml
+++ b/NMS/NMS-v1_18_R1/pom.xml
@@ -13,6 +13,44 @@
17
+
+
+ net.md-5
+ specialsource-maven-plugin
+ 1.2.4
+
+
+
+ remap-obf
+ package
+
+ remap
+
+
+
+ org.spigotmc:minecraft-server:${nms.ver}:txt:maps-mojang
+ true
+ org.spigotmc:spigot:${nms.ver}:jar:remapped-mojang
+ true
+ remapped-obf
+
+
+
+
+ remap-spigot
+ package
+
+ remap
+
+
+
+ ${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
+ org.spigotmc:minecraft-server:${nms.ver}:csrg:maps-spigot
+ org.spigotmc:spigot:${nms.ver}:jar:remapped-obf
+
+
+
+
@@ -26,6 +64,8 @@
17
17
+
+ 1.18.1-R0.1-SNAPSHOT
SongodaCore-NMS-v1_18_R1
@@ -35,7 +75,8 @@
org.spigotmc
spigot
- 1.18
+ ${nms.ver}
+ remapped-mojang
provided
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilCore.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilCore.java
index 2977fb8b..460e6710 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilCore.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilCore.java
@@ -1,7 +1,7 @@
package com.songoda.core.nms.v1_18_R1.anvil;
import com.songoda.core.nms.anvil.CustomAnvil;
-import net.minecraft.server.level.EntityPlayer;
+import net.minecraft.server.level.ServerPlayer;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.entity.Player;
import org.bukkit.inventory.InventoryHolder;
@@ -9,13 +9,13 @@ import org.bukkit.inventory.InventoryHolder;
public class AnvilCore implements com.songoda.core.nms.anvil.AnvilCore {
@Override
public CustomAnvil createAnvil(Player player) {
- EntityPlayer p = ((CraftPlayer) player).getHandle();
- return new AnvilView(p.nextContainerCounter(), p, null);
+ return createAnvil(player, null);
}
@Override
public CustomAnvil createAnvil(Player player, InventoryHolder holder) {
- EntityPlayer p = ((CraftPlayer) player).getHandle();
- return new AnvilView(p.nextContainerCounter(), p, holder);
+ ServerPlayer serverPlayer = ((CraftPlayer) player).getHandle();
+
+ return new AnvilView(serverPlayer.nextContainerCounter(), serverPlayer, holder);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilInventoryCustom.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilInventoryCustom.java
index a6a1f079..8a9334bd 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilInventoryCustom.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilInventoryCustom.java
@@ -1,7 +1,7 @@
package com.songoda.core.nms.v1_18_R1.anvil;
-import net.minecraft.world.IInventory;
-import net.minecraft.world.inventory.ContainerAnvil;
+import net.minecraft.world.Container;
+import net.minecraft.world.inventory.AnvilMenu;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryAnvil;
import org.bukkit.inventory.InventoryHolder;
@@ -9,7 +9,7 @@ import org.bukkit.inventory.InventoryHolder;
public class AnvilInventoryCustom extends CraftInventoryAnvil {
final InventoryHolder holder;
- public AnvilInventoryCustom(InventoryHolder holder, Location location, IInventory inventory, IInventory resultInventory, ContainerAnvil container) {
+ public AnvilInventoryCustom(InventoryHolder holder, Location location, Container inventory, Container resultInventory, AnvilMenu container) {
super(location, inventory, resultInventory, container);
this.holder = holder;
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilView.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilView.java
index 30fb8661..acb81136 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilView.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/anvil/AnvilView.java
@@ -2,17 +2,17 @@ package com.songoda.core.nms.v1_18_R1.anvil;
import com.songoda.core.nms.anvil.CustomAnvil;
import com.songoda.core.nms.anvil.methods.AnvilTextChange;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.network.chat.ChatMessage;
-import net.minecraft.network.protocol.game.PacketPlayOutOpenWindow;
-import net.minecraft.server.level.EntityPlayer;
-import net.minecraft.world.IInventory;
-import net.minecraft.world.entity.player.EntityHuman;
-import net.minecraft.world.inventory.Container;
-import net.minecraft.world.inventory.ContainerAccess;
-import net.minecraft.world.inventory.ContainerAnvil;
-import net.minecraft.world.inventory.ContainerAnvilAbstract;
-import net.minecraft.world.inventory.Containers;
+import net.minecraft.core.BlockPos;
+import net.minecraft.network.chat.TranslatableComponent;
+import net.minecraft.network.protocol.game.ClientboundOpenScreenPacket;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.Container;
+import net.minecraft.world.entity.player.Player;
+import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.inventory.AnvilMenu;
+import net.minecraft.world.inventory.ContainerLevelAccess;
+import net.minecraft.world.inventory.ItemCombinerMenu;
+import net.minecraft.world.inventory.MenuType;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftInventoryView;
import org.bukkit.inventory.Inventory;
@@ -23,8 +23,8 @@ import java.lang.reflect.Field;
import java.util.logging.Level;
import java.util.logging.Logger;
-public class AnvilView extends ContainerAnvil implements CustomAnvil {
- private final EntityPlayer entity;
+public class AnvilView extends AnvilMenu implements CustomAnvil {
+ private final ServerPlayer entity;
private final Inventory inventory;
private String customTitle = "Repairing";
private int cost = -1;
@@ -38,13 +38,13 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
static {
try {
- mc_ContainerAnvil_repairInventory = ContainerAnvilAbstract.class.getDeclaredField("p");
+ mc_ContainerAnvil_repairInventory = ItemCombinerMenu.class.getDeclaredField("p");
mc_ContainerAnvil_repairInventory.setAccessible(true);
- mc_ContainerAnvil_resultInventory = ContainerAnvilAbstract.class.getDeclaredField("o");
+ mc_ContainerAnvil_resultInventory = ItemCombinerMenu.class.getDeclaredField("o");
mc_ContainerAnvil_resultInventory.setAccessible(true);
- mc_ContainerAnvil_bukkitEntity = ContainerAnvil.class.getDeclaredField("bukkitEntity");
+ mc_ContainerAnvil_bukkitEntity = AnvilMenu.class.getDeclaredField("bukkitEntity");
mc_ContainerAnvil_bukkitEntity.setAccessible(true);
} catch (Exception ex) {
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
@@ -56,17 +56,17 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
static {
try {
- mc_Container_title = Container.class.getDeclaredField("title");
+ mc_Container_title = AbstractContainerMenu.class.getDeclaredField("title");
mc_Container_title.setAccessible(true);
} catch (Exception ex) {
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Setup Error", ex);
}
}
- public AnvilView(int id, EntityPlayer entity, InventoryHolder holder) {
- super(entity.nextContainerCounter(), entity.fq(), ContainerAccess.a(entity.t, new BlockPosition(0, 0, 0)));
+ public AnvilView(int id, ServerPlayer entity, InventoryHolder holder) {
+ super(entity.nextContainerCounter(), entity.getInventory(), ContainerLevelAccess.create(entity.level, new BlockPos(0, 0, 0)));
- this.setTitle(new ChatMessage(customTitle != null ? customTitle : ""));
+ this.setTitle(new TranslatableComponent(customTitle != null ? customTitle : ""));
this.checkReachable = false;
this.entity = entity;
@@ -77,12 +77,12 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
}
}
- public CraftInventoryView getBukkitView(EntityHuman player, InventoryHolder holder) {
+ public CraftInventoryView getBukkitView(Player player, InventoryHolder holder) {
try {
AnvilInventoryCustom craftInventory = new AnvilInventoryCustom(holder,
- new Location(entity.t.getWorld(), 0, 0, 0),
- (IInventory) mc_ContainerAnvil_repairInventory.get(this),
- (IInventory) mc_ContainerAnvil_resultInventory.get(this), this);
+ new Location(entity.level.getWorld(), 0, 0, 0),
+ (Container) mc_ContainerAnvil_repairInventory.get(this),
+ (Container) mc_ContainerAnvil_resultInventory.get(this), this);
CraftInventoryView view = new CraftInventoryView(player.getBukkitEntity(), craftInventory, this);
mc_ContainerAnvil_bukkitEntity.set(this, view);
@@ -95,13 +95,13 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
}
@Override
- public boolean a(EntityHuman entityhuman) {
+ public boolean stillValid(Player entityHuman) {
return canUse;
}
@Override
- public void e() {
- super.e();
+ public void broadcastFullState() {
+ super.broadcastFullState();
if (cost >= 0) {
this.setLevelCost(cost);
@@ -112,17 +112,17 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
@Override
public void update() {
- e();
+ broadcastFullState();
}
@Override
public String getRenameText() {
- return this.v;
+ return this.itemName;
}
@Override
public void setRenameText(String text) {
- this.a(text);
+ this.setItemName(text);
}
@Override
@@ -140,7 +140,7 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
this.customTitle = title;
try {
- mc_Container_title.set(this, new ChatMessage(customTitle != null ? customTitle : ""));
+ mc_Container_title.set(this, new TranslatableComponent(customTitle != null ? customTitle : ""));
} catch (Exception ex) {
Logger.getLogger(AnvilView.class.getName()).log(Level.SEVERE, "Anvil Error", ex);
}
@@ -203,12 +203,12 @@ public class AnvilView extends ContainerAnvil implements CustomAnvil {
@Override
public void open() {
// Send the packet
- entity.b.a(new PacketPlayOutOpenWindow(j, Containers.h, new ChatMessage(customTitle != null ? customTitle : "")));
+ entity.connection.send(new ClientboundOpenScreenPacket(super.containerId, MenuType.ANVIL, new TranslatableComponent(customTitle != null ? customTitle : "")));
// Set their active container to this anvil
- entity.bW = this;
+ entity.containerMenu = this;
// Add the slot listener
- entity.a(entity.bW);
+ entity.initMenu(entity.containerMenu);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/entity/NMSPlayerImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/entity/NMSPlayerImpl.java
index ac3699e6..85c1ba9b 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/entity/NMSPlayerImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/entity/NMSPlayerImpl.java
@@ -8,6 +8,6 @@ import org.bukkit.entity.Player;
public class NMSPlayerImpl implements NMSPlayer {
@Override
public void sendPacket(Player p, Object packet) {
- ((CraftPlayer) p).getHandle().b.a((Packet>) packet);
+ ((CraftPlayer) p).getHandle().connection.send((Packet>) packet);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCompoundImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCompoundImpl.java
index f552cd0f..487691ca 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCompoundImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCompoundImpl.java
@@ -2,98 +2,96 @@ package com.songoda.core.nms.v1_18_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTObject;
-import net.minecraft.nbt.NBTCompressedStreamTools;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.nbt.NbtIo;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
-import java.io.OutputStream;
import java.util.Set;
import java.util.UUID;
public class NBTCompoundImpl implements NBTCompound {
- protected NBTTagCompound compound;
+ protected CompoundTag compound;
- protected NBTCompoundImpl(NBTTagCompound compound) {
+ protected NBTCompoundImpl(CompoundTag compound) {
this.compound = compound;
}
public NBTCompoundImpl() {
- this.compound = new NBTTagCompound();
+ this.compound = new CompoundTag();
}
@Override
public NBTCompound set(String tag, String s) {
- compound.a(tag, s);
+ compound.putString(tag, s);
return this;
}
@Override
public NBTCompound set(String tag, boolean b) {
- compound.a(tag, b);
+ compound.putBoolean(tag, b);
return this;
}
@Override
public NBTCompound set(String tag, int i) {
- compound.a(tag, i);
+ compound.putInt(tag, i);
return this;
}
@Override
public NBTCompound set(String tag, double i) {
- compound.a(tag, i);
+ compound.putDouble(tag, i);
return this;
}
@Override
public NBTCompound set(String tag, long l) {
- compound.a(tag, l);
+ compound.putLong(tag, l);
return this;
}
@Override
public NBTCompound set(String tag, short s) {
- compound.a(tag, s);
+ compound.putShort(tag, s);
return this;
}
@Override
public NBTCompound set(String tag, byte b) {
- compound.a(tag, b);
+ compound.putByte(tag, b);
return this;
}
@Override
public NBTCompound set(String tag, int[] i) {
- compound.a(tag, i);
+ compound.putIntArray(tag, i);
return this;
}
@Override
public NBTCompound set(String tag, byte[] b) {
- compound.a(tag, b);
+ compound.putByteArray(tag, b);
return this;
}
@Override
public NBTCompound set(String tag, UUID u) {
- compound.a(tag, u);
+ compound.putUUID(tag, u);
return this;
}
@Override
public NBTCompound remove(String tag) {
- compound.r(tag);
+ compound.remove(tag);
return this;
}
@Override
public boolean has(String tag) {
- return compound.e(tag);
+ return compound.contains(tag);
}
@Override
@@ -152,19 +150,19 @@ public class NBTCompoundImpl implements NBTCompound {
return getNBTObject(tag).asCompound();
}
- NBTTagCompound newCompound = new NBTTagCompound();
- compound.a(tag, newCompound);
+ CompoundTag newCompound = new CompoundTag();
+ compound.put(tag, newCompound);
return new NBTCompoundImpl(newCompound);
}
@Override
public Set getKeys() {
- return compound.d();
+ return compound.getAllKeys();
}
@Override
public Set getKeys(String tag) {
- return compound.p(tag).d();
+ return compound.getCompound(tag).getAllKeys();
}
@Override
@@ -172,13 +170,13 @@ public class NBTCompoundImpl implements NBTCompound {
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
ObjectOutputStream dataOutput = new ObjectOutputStream(outputStream)) {
addExtras();
- NBTTagCompound compound = this.compound.g();
+ CompoundTag compound = this.compound.copy();
for (String exclusion : exclusions) {
- compound.r(exclusion);
+ compound.remove(exclusion);
}
- NBTCompressedStreamTools.a(compound, (OutputStream) dataOutput);
+ NbtIo.writeCompressed(compound, dataOutput);
return outputStream.toByteArray();
} catch (Exception ex) {
@@ -192,7 +190,7 @@ public class NBTCompoundImpl implements NBTCompound {
public void deSerialize(byte[] serialized) {
try (ByteArrayInputStream inputStream = new ByteArrayInputStream(serialized);
ObjectInputStream dataInput = new ObjectInputStream(inputStream)) {
- compound = NBTCompressedStreamTools.a((InputStream) dataInput);
+ compound = NbtIo.readCompressed(dataInput);
} catch (Exception ex) {
ex.printStackTrace();
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCoreImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCoreImpl.java
index a1cf48fe..e90e944d 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCoreImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTCoreImpl.java
@@ -3,7 +3,7 @@ package com.songoda.core.nms.v1_18_R1.nbt;
import com.songoda.core.nms.nbt.NBTCore;
import com.songoda.core.nms.nbt.NBTEntity;
import com.songoda.core.nms.nbt.NBTItem;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
import org.bukkit.entity.Entity;
@@ -25,14 +25,14 @@ public class NBTCoreImpl implements NBTCore {
@Override
public NBTEntity of(Entity entity) {
net.minecraft.world.entity.Entity nmsEntity = ((CraftEntity) entity).getHandle();
- NBTTagCompound nbt = new NBTTagCompound();
- nmsEntity.f(nbt);
+ CompoundTag nbt = new CompoundTag();
+ nmsEntity.saveWithoutId(nbt);
return new NBTEntityImpl(nbt, nmsEntity);
}
@Override
public NBTEntity newEntity() {
- return new NBTEntityImpl(new NBTTagCompound(), null);
+ return new NBTEntityImpl(new CompoundTag(), null);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTEntityImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTEntityImpl.java
index c8d7faee..4693f8fa 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTEntityImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTEntityImpl.java
@@ -1,12 +1,12 @@
package com.songoda.core.nms.v1_18_R1.nbt;
import com.songoda.core.nms.nbt.NBTEntity;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.core.IRegistry;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.core.BlockPos;
+import net.minecraft.core.Registry;
+import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityTypes;
-import net.minecraft.world.entity.EnumMobSpawn;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.MobSpawnType;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
@@ -15,7 +15,7 @@ import java.util.Optional;
public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
private Entity nmsEntity;
- public NBTEntityImpl(NBTTagCompound entityNBT, Entity nmsEntity) {
+ public NBTEntityImpl(CompoundTag entityNBT, Entity nmsEntity) {
super(entityNBT);
this.nmsEntity = nmsEntity;
@@ -25,23 +25,23 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
public org.bukkit.entity.Entity spawn(Location location) {
String entityType = getNBTObject("entity_type").asString();
- Optional> optionalEntity = EntityTypes.a(entityType);
+ Optional> optionalEntity = EntityType.byString(entityType);
if (optionalEntity.isPresent()) {
assert location.getWorld() != null;
- Entity spawned = optionalEntity.get().a(
+ Entity spawned = optionalEntity.get().spawn(
((CraftWorld) location.getWorld()).getHandle(),
compound,
null,
null,
- new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()),
- EnumMobSpawn.n,
+ new BlockPos(location.getBlockX(), location.getBlockY(), location.getBlockZ()),
+ MobSpawnType.COMMAND,
true,
false
);
if (spawned != null) {
- spawned.g(compound);
+ spawned.load(compound);
org.bukkit.entity.Entity entity = spawned.getBukkitEntity();
entity.teleport(location);
nmsEntity = spawned;
@@ -55,12 +55,12 @@ public class NBTEntityImpl extends NBTCompoundImpl implements NBTEntity {
@Override
public org.bukkit.entity.Entity reSpawn(Location location) {
- nmsEntity.ah();
+ nmsEntity.discard();
return spawn(location);
}
@Override
public void addExtras() {
- compound.a("entity_type", IRegistry.Z.b(nmsEntity.ad()).toString());
+ compound.putString("entity_type", Registry.ENTITY_TYPE.getKey(nmsEntity.getType()).toString());
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTItemImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTItemImpl.java
index e375b6bb..237f074b 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTItemImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTItemImpl.java
@@ -1,22 +1,22 @@
package com.songoda.core.nms.v1_18_R1.nbt;
import com.songoda.core.nms.nbt.NBTItem;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.world.item.ItemStack;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
-import org.bukkit.inventory.ItemStack;
public class NBTItemImpl extends NBTCompoundImpl implements NBTItem {
- private final net.minecraft.world.item.ItemStack nmsItem;
+ private final ItemStack nmsItem;
- public NBTItemImpl(net.minecraft.world.item.ItemStack nmsItem) {
- super(nmsItem != null && nmsItem.r() ? nmsItem.s() : new NBTTagCompound());
+ public NBTItemImpl(ItemStack nmsItem) {
+ super(nmsItem != null && nmsItem.hasTag() ? nmsItem.getTag() : new CompoundTag());
this.nmsItem = nmsItem;
}
- public ItemStack finish() {
+ public org.bukkit.inventory.ItemStack finish() {
if (nmsItem == null) {
- return CraftItemStack.asBukkitCopy(net.minecraft.world.item.ItemStack.a(compound));
+ return CraftItemStack.asBukkitCopy(ItemStack.of(compound));
}
return CraftItemStack.asBukkitCopy(nmsItem);
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTObjectImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTObjectImpl.java
index f1038700..69897c8a 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTObjectImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/nbt/NBTObjectImpl.java
@@ -2,71 +2,71 @@ package com.songoda.core.nms.v1_18_R1.nbt;
import com.songoda.core.nms.nbt.NBTCompound;
import com.songoda.core.nms.nbt.NBTObject;
-import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.CompoundTag;
import java.util.Set;
public class NBTObjectImpl implements NBTObject {
- private final NBTTagCompound compound;
+ private final CompoundTag compound;
private final String tag;
- public NBTObjectImpl(NBTTagCompound compound, String tag) {
+ public NBTObjectImpl(CompoundTag compound, String tag) {
this.compound = compound;
this.tag = tag;
}
@Override
public String asString() {
- return compound.l(tag);
+ return compound.getString(tag);
}
@Override
public boolean asBoolean() {
- return compound.q(tag);
+ return compound.getBoolean(tag);
}
@Override
public int asInt() {
- return compound.h(tag);
+ return compound.getInt(tag);
}
@Override
public double asDouble() {
- return compound.k(tag);
+ return compound.getDouble(tag);
}
@Override
public long asLong() {
- return compound.i(tag);
+ return compound.getLong(tag);
}
@Override
public short asShort() {
- return compound.g(tag);
+ return compound.getShort(tag);
}
@Override
public byte asByte() {
- return compound.f(tag);
+ return compound.getByte(tag);
}
@Override
public int[] asIntArray() {
- return compound.n(tag);
+ return compound.getIntArray(tag);
}
@Override
public byte[] asByteArray() {
- return compound.m(tag);
+ return compound.getByteArray(tag);
}
@Override
public NBTCompound asCompound() {
- return new NBTCompoundImpl(compound.p(tag));
+ return new NBTCompoundImpl(compound.getCompound(tag));
}
@Override
public Set getKeys() {
- return compound.d();
+ return compound.getAllKeys();
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/NmsWorldBorderImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/NmsWorldBorderImpl.java
index 0035226c..00ff135e 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/NmsWorldBorderImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/NmsWorldBorderImpl.java
@@ -25,15 +25,15 @@ public class NmsWorldBorderImpl implements NmsWorldBorder {
WorldBorder worldBorder = new WorldBorder();
worldBorder.world = ((CraftWorld) center.getWorld()).getHandle();
- worldBorder.c(center.getX(), center.getZ()); // setCenter
- worldBorder.a(size); // setSize
- worldBorder.b(0); // setWarningTime
- worldBorder.c(0); // setWarningDistance
+ worldBorder.setCenter(center.getX(), center.getZ());
+ worldBorder.setSize(size);
+ worldBorder.setWarningTime(0);
+ worldBorder.setWarningBlocks(0);
if (color == BorderColor.GREEN) {
- worldBorder.a(size - 0.1D, size, Long.MAX_VALUE); // transitionSizeBetween
+ worldBorder.lerpSizeBetween(size - 0.1D, size, Long.MAX_VALUE);
} else if (color == BorderColor.RED) {
- worldBorder.a(size, size - 1.0D, Long.MAX_VALUE); // transitionSizeBetween
+ worldBorder.lerpSizeBetween(size, size - 1.0D, Long.MAX_VALUE);
}
this.nmsPlayer.sendPacket(player, new ClientboundInitializeBorderPacket(worldBorder));
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SItemStackImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SItemStackImpl.java
index 120a1239..c835137a 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SItemStackImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SItemStackImpl.java
@@ -1,10 +1,10 @@
package com.songoda.core.nms.v1_18_R1.world;
import com.songoda.core.nms.world.SItemStack;
-import net.minecraft.core.particles.ParticleParamItem;
-import net.minecraft.core.particles.Particles;
-import net.minecraft.server.level.EntityPlayer;
-import net.minecraft.world.phys.Vec3D;
+import net.minecraft.core.particles.ItemParticleOption;
+import net.minecraft.core.particles.ParticleTypes;
+import net.minecraft.server.level.ServerPlayer;
+import net.minecraft.world.phys.Vec3;
import org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer;
import org.bukkit.craftbukkit.v1_18_R1.inventory.CraftItemStack;
import org.bukkit.entity.Player;
@@ -19,21 +19,21 @@ public class SItemStackImpl implements SItemStack {
@Override
public void breakItem(Player player, int amount) {
- EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
+ ServerPlayer entityPlayer = ((CraftPlayer) player).getHandle();
for (int i = 0; i < amount; ++i) {
- Vec3D vec3d = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
- vec3d = vec3d.a(-entityPlayer.dn() * 0.017453292F);
- vec3d = vec3d.b(-entityPlayer.dm() * 0.017453292F);
+ Vec3 vec3d = new Vec3(((double) random.nextFloat() - 0.5D) * 0.1D, Math.random() * 0.1D + 0.1D, 0.0D);
+ vec3d = vec3d.xRot(-entityPlayer.getXRot() * 0.017453292F);
+ vec3d = vec3d.yRot(-entityPlayer.getYRot() * 0.017453292F);
double d0 = (double) (-random.nextFloat()) * 0.6D - 0.3D;
- Vec3D vec3d1 = new Vec3D(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
- vec3d1 = vec3d1.a(-entityPlayer.dn() * 0.017453292F);
- vec3d1 = vec3d1.b(-entityPlayer.dm() * 0.017453292F);
- vec3d1 = vec3d1.b(entityPlayer.dc(), entityPlayer.dg(), entityPlayer.di());
+ Vec3 vec3d1 = new Vec3(((double) random.nextFloat() - 0.5D) * 0.3D, d0, 0.6D);
+ vec3d1 = vec3d1.xRot(-entityPlayer.getXRot() * 0.017453292F);
+ vec3d1 = vec3d1.yRot(-entityPlayer.getYRot() * 0.017453292F);
+ vec3d1 = vec3d1.add(entityPlayer.getX(), entityPlayer.getEyeY(), entityPlayer.getZ());
- entityPlayer.t.a(new ParticleParamItem(Particles.J, CraftItemStack.asNMSCopy(item)), vec3d1.b, vec3d1.c, vec3d1.d, vec3d.b, vec3d.c + 0.05D, vec3d.d);
+ entityPlayer.level.addParticle(new ItemParticleOption(ParticleTypes.ITEM, CraftItemStack.asNMSCopy(item)), vec3d1.x, vec3d1.y, vec3d1.z, vec3d.x, vec3d.y + 0.05D, vec3d.z);
}
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SSpawnerImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SSpawnerImpl.java
index 74751f56..68199a52 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SSpawnerImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SSpawnerImpl.java
@@ -4,15 +4,14 @@ import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.CompatibleParticleHandler;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SpawnedEntity;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.server.level.WorldServer;
-import net.minecraft.world.DifficultyDamageScaler;
+import net.minecraft.core.BlockPos;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityInsentient;
-import net.minecraft.world.entity.EntityTypes;
-import net.minecraft.world.entity.EnumMobSpawn;
-import net.minecraft.world.level.MobSpawnerData;
+import net.minecraft.world.entity.Mob;
+import net.minecraft.world.entity.MobSpawnType;
+import net.minecraft.world.level.SpawnData;
import org.bukkit.Location;
import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
@@ -37,35 +36,35 @@ public class SSpawnerImpl implements SSpawner {
}
@Override
- public LivingEntity spawnEntity(EntityType type, String particleType, SpawnedEntity spawned,
- Set canSpawnOn) {
- MobSpawnerData data = new MobSpawnerData();
- NBTTagCompound compound = data.a();
+ public LivingEntity spawnEntity(EntityType type, String particleType, SpawnedEntity spawned, Set canSpawnOn) {
+ SpawnData data = new SpawnData();
+ CompoundTag compound = data.getEntityToSpawn();
- String name = type.name().toLowerCase().replace("snowman", "snow_golem")
+ String name = type.name().toLowerCase()
+ .replace("snowman", "snow_golem")
.replace("mushroom_cow", "mooshroom");
- compound.a("id", "minecraft:" + name);
+ compound.putString("id", "minecraft:" + name);
short spawnRange = 4;
for (int i = 0; i < 50; i++) {
assert spawnerLocation.getWorld() != null;
- WorldServer world = ((CraftWorld) spawnerLocation.getWorld()).getHandle();
+ ServerLevel world = ((CraftWorld) spawnerLocation.getWorld()).getHandle();
- Random random = world.r_();
+ Random random = world.getRandom();
double x = spawnerLocation.getX() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
double y = spawnerLocation.getY() + random.nextInt(3) - 1;
double z = spawnerLocation.getZ() + (random.nextDouble() - random.nextDouble()) * (double) spawnRange + 0.5D;
- Optional optionalEntity = EntityTypes.a(compound, world);
+ Optional optionalEntity = net.minecraft.world.entity.EntityType.create(compound, world);
if (optionalEntity.isEmpty()) continue;
Entity entity = optionalEntity.get();
- entity.e(x, y, z);
+ entity.setPos(x, y, z);
- BlockPosition position = entity.cW();
- DifficultyDamageScaler damageScaler = world.d_(position);
+ BlockPos position = entity.blockPosition();
+ DifficultyInstance damageScaler = world.getCurrentDifficultyAt(position);
- if (!(entity instanceof EntityInsentient entityInsentient)) {
+ if (!(entity instanceof Mob entityInsentient)) {
continue;
}
@@ -75,7 +74,7 @@ public class SSpawnerImpl implements SSpawner {
continue;
}
- entityInsentient.a(world, damageScaler, EnumMobSpawn.c, null, null);
+ entityInsentient.finalizeSpawn(world, damageScaler, MobSpawnType.SPAWNER, null, null);
LivingEntity craftEntity = (LivingEntity) entity.getBukkitEntity();
@@ -103,9 +102,8 @@ public class SSpawnerImpl implements SSpawner {
return null;
}
- private boolean canSpawn(WorldServer world, EntityInsentient entityInsentient, Location location,
- Set canSpawnOn) {
- if (!world.a(entityInsentient, entityInsentient.cw())) {
+ private boolean canSpawn(ServerLevel world, Mob entityInsentient, Location location, Set canSpawnOn) {
+ if (!world.noCollision(entityInsentient, entityInsentient.getBoundingBox())) {
return false;
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SWorldImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SWorldImpl.java
index df18b4b8..c23b094b 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SWorldImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/SWorldImpl.java
@@ -1,10 +1,10 @@
package com.songoda.core.nms.v1_18_R1.world;
import com.songoda.core.nms.world.SWorld;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.server.level.WorldServer;
-import net.minecraft.world.level.block.state.IBlockData;
-import net.minecraft.world.level.chunk.Chunk;
+import net.minecraft.core.BlockPos;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.entity.LevelEntityGetter;
import org.bukkit.Material;
import org.bukkit.World;
@@ -26,10 +26,10 @@ public class SWorldImpl implements SWorld {
public List getLivingEntities() {
List result = new ArrayList<>();
- WorldServer worldServer = ((CraftWorld) this.world).getHandle();
- LevelEntityGetter entities = worldServer.P.d();
+ ServerLevel worldServer = ((CraftWorld) this.world).getHandle();
+ LevelEntityGetter entities = worldServer.entityManager.getEntityGetter();
- entities.a().forEach((mcEnt) -> {
+ entities.getAll().forEach((mcEnt) -> {
org.bukkit.entity.Entity bukkitEntity = mcEnt.getBukkitEntity();
if (bukkitEntity instanceof LivingEntity && bukkitEntity.isValid()) {
@@ -42,10 +42,10 @@ public class SWorldImpl implements SWorld {
@Override
public void setBlockFast(int x, int y, int z, Material material) {
- WorldServer serverLevel = ((CraftWorld) this.world).getHandle();
- Chunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
- IBlockData blockState = ((CraftBlockData) material.createBlockData()).getState();
+ ServerLevel serverLevel = ((CraftWorld) this.world).getHandle();
+ LevelChunk levelChunk = serverLevel.getChunkIfLoaded(x >> 4, z >> 4);
+ BlockState blockState = ((CraftBlockData) material.createBlockData()).getState();
- levelChunk.a(new BlockPosition(x & 0xF, y, z & 0xF), blockState, true);
+ levelChunk.setBlockState(new BlockPos(x & 0xF, y, z & 0xF), blockState, true);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/WorldCoreImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/WorldCoreImpl.java
index f952cec1..e97f3671 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/WorldCoreImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/WorldCoreImpl.java
@@ -7,16 +7,16 @@ import com.songoda.core.nms.world.SItemStack;
import com.songoda.core.nms.world.SSpawner;
import com.songoda.core.nms.world.SWorld;
import com.songoda.core.nms.world.WorldCore;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.server.level.WorldServer;
-import net.minecraft.util.profiling.GameProfilerFiller;
-import net.minecraft.world.level.ChunkCoordIntPair;
-import net.minecraft.world.level.MobSpawnerAbstract;
+import net.minecraft.core.BlockPos;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.util.profiling.ProfilerFiller;
+import net.minecraft.world.level.BaseSpawner;
+import net.minecraft.world.level.ChunkPos;
import net.minecraft.world.level.block.Block;
-import net.minecraft.world.level.block.state.IBlockData;
-import net.minecraft.world.level.chunk.Chunk;
-import net.minecraft.world.level.chunk.ChunkSection;
-import net.minecraft.world.level.material.Fluid;
+import net.minecraft.world.level.block.state.BlockState;
+import net.minecraft.world.level.chunk.LevelChunk;
+import net.minecraft.world.level.chunk.LevelChunkSection;
+import net.minecraft.world.level.material.FluidState;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.block.CreatureSpawner;
@@ -53,61 +53,61 @@ public class WorldCoreImpl implements WorldCore {
public BBaseSpawner getBaseSpawner(CreatureSpawner spawner) throws NoSuchFieldException, IllegalAccessException {
Object cTileEntity = ReflectionUtils.getFieldValue(spawner, "tileEntity");
- return new BBaseSpawnerImpl(spawner, (MobSpawnerAbstract) ReflectionUtils.getFieldValue(cTileEntity, "a"));
+ return new BBaseSpawnerImpl(spawner, (BaseSpawner) ReflectionUtils.getFieldValue(cTileEntity, "a"));
}
/**
- * Method is based on {@link WorldServer#a(Chunk, int)}.
+ * Method is based on {@link ServerLevel#tickChunk(LevelChunk, int)}.
*/
@Override
public void randomTickChunk(org.bukkit.Chunk bukkitChunk, int tickAmount) {
- Chunk chunk = ((CraftChunk) bukkitChunk).getHandle();
- WorldServer world = chunk.q;
+ LevelChunk chunk = ((CraftChunk) bukkitChunk).getHandle();
+ ServerLevel world = chunk.q;
- ChunkCoordIntPair chunkcoordintpair = chunk.f();
- int j = chunkcoordintpair.d();
- int k = chunkcoordintpair.e();
+ ChunkPos chunkcoordintpair = chunk.getPos();
+ int j = chunkcoordintpair.getMinBlockX();
+ int k = chunkcoordintpair.getMinBlockZ();
- GameProfilerFiller gameprofilerfiller = world.ab();
- gameprofilerfiller.b("tickBlocks");
+ ProfilerFiller gameprofilerfiller = world.getProfiler();
+ gameprofilerfiller.popPush("tickBlocks");
if (tickAmount > 0) {
- ChunkSection[] achunksection = chunk.d();
+ LevelChunkSection[] achunksection = chunk.getSections();
int l = achunksection.length;
- for (ChunkSection chunksection : achunksection) {
- if (chunksection.d()) {
- int j1 = chunksection.g();
+ for (LevelChunkSection chunksection : achunksection) {
+ if (chunksection.isRandomlyTicking()) {
+ int j1 = chunksection.bottomBlockY();
for (int k1 = 0; k1 < tickAmount; ++k1) {
- BlockPosition blockposition2 = world.a(j, j1, k, 15);
- gameprofilerfiller.a("randomTick");
- IBlockData iblockdata1 = chunksection.a(blockposition2.u() - j, blockposition2.v() - j1, blockposition2.w() - k);
- if (iblockdata1.o()) {
- iblockdata1.b(world, blockposition2, world.w);
+ BlockPos blockposition2 = world.getBlockRandomPos(j, j1, k, 15);
+ gameprofilerfiller.push("randomTick");
+ BlockState iblockdata1 = chunksection.getBlockState(blockposition2.getX() - j, blockposition2.getY() - j1, blockposition2.getZ() - k);
+ if (iblockdata1.isRandomlyTicking()) {
+ iblockdata1.randomTick(world, blockposition2, world.random);
}
- Fluid fluid = iblockdata1.n();
- if (fluid.f()) {
- fluid.b(world, blockposition2, world.w);
+ FluidState fluid = iblockdata1.getFluidState();
+ if (fluid.isRandomlyTicking()) {
+ fluid.randomTick(world, blockposition2, world.random);
}
- gameprofilerfiller.c();
+ gameprofilerfiller.pop();
}
}
}
}
- gameprofilerfiller.c();
+ gameprofilerfiller.pop();
}
@Override
public void updateAdjacentComparators(@NotNull Location loc) {
Objects.requireNonNull(loc.getWorld());
- WorldServer serverLevel = ((CraftWorld) loc.getWorld()).getHandle();
- BlockPosition blockPos = new BlockPosition(loc.getX(), loc.getY(), loc.getZ());
- Block nmsBlock = ((CraftBlock) loc.getBlock()).getNMS().b();
+ ServerLevel serverLevel = ((CraftWorld) loc.getWorld()).getHandle();
+ BlockPos blockPos = new BlockPos(loc.getX(), loc.getY(), loc.getZ());
+ Block nmsBlock = ((CraftBlock) loc.getBlock()).getNMS().getBlock();
- serverLevel.c(blockPos, nmsBlock);
+ serverLevel.updateNeighbourForOutputSignal(blockPos, nmsBlock);
}
}
diff --git a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/spawner/BBaseSpawnerImpl.java b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/spawner/BBaseSpawnerImpl.java
index b4128844..626e5368 100644
--- a/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/spawner/BBaseSpawnerImpl.java
+++ b/NMS/NMS-v1_18_R1/src/main/java/com/songoda/core/nms/v1_18_R1/world/spawner/BBaseSpawnerImpl.java
@@ -1,21 +1,21 @@
package com.songoda.core.nms.v1_18_R1.world.spawner;
import com.songoda.core.nms.world.BBaseSpawner;
-import net.minecraft.core.BlockPosition;
-import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.nbt.NBTTagList;
-import net.minecraft.server.level.WorldServer;
-import net.minecraft.world.EnumDifficulty;
+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.Difficulty;
import net.minecraft.world.entity.Entity;
-import net.minecraft.world.entity.EntityInsentient;
-import net.minecraft.world.entity.EntityPositionTypes;
-import net.minecraft.world.entity.EntityTypes;
-import net.minecraft.world.entity.EnumMobSpawn;
-import net.minecraft.world.level.EnumSkyBlock;
-import net.minecraft.world.level.MobSpawnerAbstract;
-import net.minecraft.world.level.MobSpawnerData;
-import net.minecraft.world.level.World;
-import net.minecraft.world.phys.AxisAlignedBB;
+import net.minecraft.world.entity.EntityType;
+import net.minecraft.world.entity.Mob;
+import net.minecraft.world.entity.MobSpawnType;
+import net.minecraft.world.entity.SpawnPlacements;
+import net.minecraft.world.level.BaseSpawner;
+import net.minecraft.world.level.Level;
+import net.minecraft.world.level.LightLayer;
+import net.minecraft.world.level.SpawnData;
+import net.minecraft.world.phys.AABB;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.craftbukkit.v1_18_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_18_R1.block.CraftCreatureSpawner;
@@ -27,40 +27,45 @@ import java.util.Random;
public class BBaseSpawnerImpl implements BBaseSpawner {
private final CreatureSpawner bukkitSpawner;
- private final MobSpawnerAbstract spawner;
+ private final BaseSpawner spawner;
- private static final Random spawnerFieldO = new Random(); // Field o in MobSpawnerAbstract is private - We use one random for *all* our spawners (should be fine, right?)
+ private static final Random spawnerFieldO = new Random(); // Field random in BaseSpawner is private - We use one random for *all* our spawners (should be fine, right?)
- public BBaseSpawnerImpl(CreatureSpawner bukkitSpawner, MobSpawnerAbstract spawner) {
+ public BBaseSpawnerImpl(CreatureSpawner bukkitSpawner, BaseSpawner spawner) {
this.bukkitSpawner = bukkitSpawner;
this.spawner = spawner;
}
/**
- * This method is based on {@link MobSpawnerAbstract#b(World, BlockPosition)}.
+ * This method is based on {@link BaseSpawner#isNearPlayer(Level, BlockPos)}.
*/
@SuppressWarnings("JavadocReference")
@Override
public boolean isNearPlayer() {
- BlockPosition bPos = getBlockPosition();
+ BlockPos bPos = getBlockPosition();
- return getWorld().a((double) bPos.u() + 0.5D, (double) bPos.v() + 0.5D, (double) bPos.w() + 0.5D, this.spawner.m);
+ return getWorld().hasNearbyAlivePlayer(
+ (double) bPos.getX() + 0.5D,
+ (double) bPos.getY() + 0.5D,
+ (double) bPos.getZ() + 0.5D,
+ this.spawner.requiredPlayerRange
+ );
}
/**
- * This method is based on {@link MobSpawnerAbstract#a(WorldServer, BlockPosition)}.
+ * This method is based on {@link BaseSpawner#serverTick(ServerLevel, BlockPos)}.
*/
@Override
public void tick() {
- WorldServer world = getWorld();
- BlockPosition bPos = getBlockPosition();
+ ServerLevel world = getWorld();
+ BlockPos bPos = getBlockPosition();
- if (this.spawner.c == -1) {
+ if (this.spawner.spawnDelay == -1) {
this.delay(world, bPos);
}
- if (this.spawner.c > 0) {
- --this.spawner.c;
+ if (this.spawner.spawnDelay > 0) {
+ --this.spawner.spawnDelay;
return;
}
@@ -68,44 +73,45 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
int i = 0;
while (true) {
- if (i >= this.spawner.j) {
+ if (i >= this.spawner.spawnCount) {
if (flag) {
this.delay(world, bPos);
}
break;
}
- NBTTagCompound nbttagcompound = this.spawner.e.a();
- Optional> optional = EntityTypes.a(nbttagcompound);
+ CompoundTag nbttagcompound = this.spawner.nextSpawnData.getEntityToSpawn();
+ Optional> optional = EntityType.by(nbttagcompound);
if (optional.isEmpty()) {
this.delay(world, bPos);
return;
}
- NBTTagList nbttaglist = nbttagcompound.c("Pos", 6);
+ ListTag nbttaglist = nbttagcompound.getList("Pos", 6);
int j = nbttaglist.size();
- double d0 = j >= 1 ? nbttaglist.h(0) : (double) bPos.u() + (world.w.nextDouble() - world.w.nextDouble()) * (double) this.spawner.n + 0.5D;
- double d1 = j >= 2 ? nbttaglist.h(1) : (double) (bPos.v() + world.w.nextInt(3) - 1);
- double d2 = j >= 3 ? nbttaglist.h(2) : (double) bPos.w() + (world.w.nextDouble() - world.w.nextDouble()) * (double) this.spawner.n + 0.5D;
- if (world.b(optional.get().a(d0, d1, d2))) {
+ double d0 = j >= 1 ? nbttaglist.getDouble(0) : (double) bPos.getX() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawner.spawnRange + 0.5D;
+ double d1 = j >= 2 ? nbttaglist.getDouble(1) : (double) (bPos.getY() + world.random.nextInt(3) - 1);
+ double d2 = j >= 3 ? nbttaglist.getDouble(2) : (double) bPos.getZ() + (world.random.nextDouble() - world.random.nextDouble()) * (double) this.spawner.spawnRange + 0.5D;
+ if (world.noCollision(optional.get().getAABB(d0, d1, d2))) {
label128:
{
- BlockPosition blockposition1 = new BlockPosition(d0, d1, d2);
- if (this.spawner.e.b().isPresent()) {
- if (!optional.get().f().d() && world.af() == EnumDifficulty.a) {
+ BlockPos blockposition1 = new BlockPos(d0, d1, d2);
+ if (this.spawner.nextSpawnData.getCustomSpawnRules().isPresent()) {
+ if (!optional.get().getCategory().isFriendly() && world.getDifficulty() == Difficulty.PEACEFUL) {
break label128;
}
- MobSpawnerData.a mobspawnerdata_a = this.spawner.e.b().get();
- if (!mobspawnerdata_a.a().a(world.a(EnumSkyBlock.b, blockposition1)) || !mobspawnerdata_a.b().a(world.a(EnumSkyBlock.a, blockposition1))) {
+ SpawnData.CustomSpawnRules mobspawnerdata_a = this.spawner.nextSpawnData.getCustomSpawnRules().get();
+ if (!mobspawnerdata_a.blockLightLimit().isValueInRange(world.getBrightness(LightLayer.BLOCK, blockposition1)) ||
+ !mobspawnerdata_a.skyLightLimit().isValueInRange(world.getBrightness(LightLayer.SKY, blockposition1))) {
break label128;
}
- } else if (!EntityPositionTypes.a((EntityTypes>) optional.get(), world, EnumMobSpawn.c, blockposition1, world.r_())) {
+ } else if (!SpawnPlacements.checkSpawnRules(optional.get(), world, MobSpawnType.SPAWNER, blockposition1, world.getRandom())) {
break label128;
}
- Entity entity = EntityTypes.a(nbttagcompound, world, (entity1) -> {
- entity1.b(d0, d1, d2, entity1.dm(), entity1.dn());
+ Entity entity = EntityType.loadEntityRecursive(nbttagcompound, world, (entity1) -> {
+ entity1.moveTo(d0, d1, d2, entity1.getYRot(), entity1.getXRot());
return entity1;
});
if (entity == null) {
@@ -113,35 +119,35 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
return;
}
- int k = world.a(entity.getClass(), (new AxisAlignedBB(bPos.u(), bPos.v(), bPos.w(), bPos.u() + 1, bPos.v() + 1, bPos.w() + 1)).g(this.spawner.n)).size();
- if (k >= this.spawner.l) {
+ int k = world.getEntitiesOfClass(entity.getClass(), (new AABB(bPos.getX(), bPos.getY(), bPos.getZ(), bPos.getX() + 1, bPos.getY() + 1, bPos.getZ() + 1)).inflate(this.spawner.spawnRange)).size();
+ if (k >= this.spawner.maxNearbyEntities) {
this.delay(world, bPos);
return;
}
- entity.b(entity.dc(), entity.de(), entity.di(), world.w.nextFloat() * 360.0F, 0.0F);
- if (entity instanceof EntityInsentient entityinsentient) {
- if (this.spawner.e.b().isEmpty() && !entityinsentient.a(world, EnumMobSpawn.c) || !entityinsentient.a(world)) {
+ entity.moveTo(entity.getX(), entity.getY(), entity.getZ(), world.random.nextFloat() * 360.0F, 0.0F);
+ if (entity instanceof Mob entityInsentient) {
+ if (this.spawner.nextSpawnData.getCustomSpawnRules().isEmpty() && !entityInsentient.checkSpawnRules(world, MobSpawnType.SPAWNER) || !entityInsentient.checkSpawnObstruction(world)) {
break label128;
}
- if (this.spawner.e.a().e() == 1 && this.spawner.e.a().b("id", 8)) {
- ((EntityInsentient) entity).a(world, world.d_(entity.cW()), EnumMobSpawn.c, null, null);
+ if (this.spawner.nextSpawnData.getEntityToSpawn().size() == 1 && this.spawner.nextSpawnData.getEntityToSpawn().contains("id", 8)) {
+ ((Mob) entity).finalizeSpawn(world, world.getCurrentDifficultyAt(entity.blockPosition()), MobSpawnType.SPAWNER, null, null);
}
- if (entityinsentient.t.spigotConfig.nerfSpawnerMobs) {
- entityinsentient.aware = false;
+ if (entityInsentient.level.spigotConfig.nerfSpawnerMobs) {
+ entityInsentient.aware = false;
}
}
if (CraftEventFactory.callSpawnerSpawnEvent(entity, bPos).isCancelled()) {
- Entity vehicle = entity.cN();
+ Entity vehicle = entity.getVehicle();
if (vehicle != null) {
- vehicle.ah();
+ vehicle.discard();
}
- for (Entity passenger : entity.cJ()) {
- passenger.ah();
+ for (Entity passenger : entity.getIndirectPassengers()) {
+ passenger.discard();
}
} else {
if (!world.tryAddFreshEntityWithPassengers(entity, CreatureSpawnEvent.SpawnReason.SPAWNER)) {
@@ -149,9 +155,9 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
return;
}
- world.c(2004, bPos, 0);
- if (entity instanceof EntityInsentient) {
- ((EntityInsentient) entity).L();
+ world.levelEvent(2004, bPos, 0);
+ if (entity instanceof Mob) {
+ ((Mob) entity).spawnAnim();
}
flag = true;
@@ -164,27 +170,25 @@ public class BBaseSpawnerImpl implements BBaseSpawner {
}
/**
- * This method is based on {@link MobSpawnerAbstract#c(World, BlockPosition)}.
+ * This method is based on {@link BaseSpawner#delay(Level, BlockPos)}.
*/
@SuppressWarnings("JavadocReference")
- private void delay(WorldServer world, BlockPosition bPos) {
- if (this.spawner.i <= this.spawner.h) {
- this.spawner.c = this.spawner.h;
+ private void delay(ServerLevel world, BlockPos bPos) {
+ if (this.spawner.maxSpawnDelay <= this.spawner.minSpawnDelay) {
+ this.spawner.spawnDelay = this.spawner.minSpawnDelay;
} else {
- this.spawner.c = this.spawner.h + spawnerFieldO.nextInt(this.spawner.i - this.spawner.h);
+ this.spawner.spawnDelay = this.spawner.minSpawnDelay + spawnerFieldO.nextInt(this.spawner.maxSpawnDelay - this.spawner.minSpawnDelay);
}
- this.spawner.d.b(spawnerFieldO).ifPresent((weightedentry_b) -> {
- this.spawner.a(world, bPos, weightedentry_b.b());
- });
- this.spawner.a(world, bPos, 1);
+ this.spawner.spawnPotentials.getRandom(spawnerFieldO).ifPresent((weightedentry_b) -> this.spawner.setNextSpawnData(world, bPos, weightedentry_b.getData()));
+ this.spawner.broadcastEvent(world, bPos, 1);
}
- private WorldServer getWorld() {
+ private ServerLevel getWorld() {
return ((CraftWorld) this.bukkitSpawner.getWorld()).getHandle();
}
- private BlockPosition getBlockPosition() {
+ private BlockPos getBlockPosition() {
return ((CraftCreatureSpawner) this.bukkitSpawner).getPosition();
}
}
diff --git a/NMS/NMS-v1_18_R2/src/main/java/com/songoda/core/nms/v1_18_R2/world/SSpawnerImpl.java b/NMS/NMS-v1_18_R2/src/main/java/com/songoda/core/nms/v1_18_R2/world/SSpawnerImpl.java
index 5af38e9c..495dbfa6 100644
--- a/NMS/NMS-v1_18_R2/src/main/java/com/songoda/core/nms/v1_18_R2/world/SSpawnerImpl.java
+++ b/NMS/NMS-v1_18_R2/src/main/java/com/songoda/core/nms/v1_18_R2/world/SSpawnerImpl.java
@@ -40,7 +40,8 @@ public class SSpawnerImpl implements SSpawner {
SpawnData data = new SpawnData();
CompoundTag compound = data.getEntityToSpawn();
- String name = type.name().toLowerCase().replace("snowman", "snow_golem")
+ String name = type.name().toLowerCase()
+ .replace("snowman", "snow_golem")
.replace("mushroom_cow", "mooshroom");
compound.putString("id", "minecraft:" + name);