Skip to content

Commit

Permalink
Added support for 1.16.4
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDutchMC committed Nov 7, 2020
1 parent 7dae9eb commit ffa5495
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Spigot_1_16_R3/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apply plugin: 'java'
dependencies {
compileOnly 'org.spigotmc:spigot:1.16.4-R0.1-SNAPSHOT'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package nl.thedutchmc.harotorch.commands.torchSubCmds;

import java.util.ArrayList;
import java.util.List;

import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_16_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;

import net.minecraft.server.v1_16_R3.EntityMagmaCube;
import net.minecraft.server.v1_16_R3.EntityPlayer;
import net.minecraft.server.v1_16_R3.EntityTypes;
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_16_R3.PacketPlayOutEntityMetadata;
import net.minecraft.server.v1_16_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_16_R3.PlayerConnection;
import net.minecraft.server.v1_16_R3.World;

public class Highlight_1_16_r3 {

public static List<Integer> spawnHighlight(Player p, List<Location> locations) {

List<Integer> result = new ArrayList<>();

EntityPlayer ep = ((CraftPlayer) p).getHandle();
PlayerConnection conn = ep.playerConnection;

for(Location loc : locations) {

World nmsWorld = ((CraftWorld) loc.getWorld()).getHandle();

EntityMagmaCube nmsEntity = new EntityMagmaCube(EntityTypes.MAGMA_CUBE, nmsWorld);

nmsEntity.setInvisible(false);
nmsEntity.collides = false; //Colllision
nmsEntity.setFlag(6, true); //Glowing
nmsEntity.setFlag(5, true); //Invisibility
nmsEntity.setSize(2, true); //Set the size of the magma cube to be a full block
nmsEntity.setLocation(loc.getBlockX() + 0.5D, loc.getBlockY(), loc.getBlockZ() + 0.5D, 0f, 0f);

PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(nmsEntity);
PacketPlayOutEntityMetadata metaPacket = new PacketPlayOutEntityMetadata(nmsEntity.getId(), nmsEntity.getDataWatcher(), true);

conn.sendPacket(spawnPacket);
conn.sendPacket(metaPacket);

result.add(nmsEntity.getId());
}

return result;
}

public static void killHighlighted(List<Integer> ids, Player p) {

EntityPlayer ep = ((CraftPlayer) p).getHandle();
PlayerConnection conn = ep.playerConnection;

for(int id : ids) {
PacketPlayOutEntityDestroy killPacket = new PacketPlayOutEntityDestroy(id);

conn.sendPacket(killPacket);
}
}
}
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ dependencies {
compile group: 'commons-io', name: 'commons-io', version: '2.6'

compile project('Spigot_1_16_R2')
compile project('Spigot_1_16_R3')

}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
pluginVersion = 2.1.3
pluginVersion = 2.1.4
pluginGroup = nl.thedutchmc.harotorch
pluginName = HaroTorch
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

rootProject.name = 'HaroTorch'
include ':Spigot_1_16_R2'
include ':Spigot_1_16_R3'
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static boolean highlight(CommandSender sender, String[] args, HaroTorch p

switch(HaroTorch.NMS_VERSION) {
case "v1_16_R2": returnedIds = Highlight_1_16_r2.spawnHighlight(p, nearbyTorches); break;
case "v1_16_R3": returnedIds = Highlight_1_16_r3.spawnHighlight(p, nearbyTorches); break;
default:
String msg = LangHandler.activeLang.getLangMessages().get("highlightVersionNotSupported").replaceAll("%NMS_VERSION%", HaroTorch.NMS_VERSION);
p.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + msg);
Expand All @@ -39,7 +40,8 @@ public void run() {

switch(HaroTorch.NMS_VERSION) {
case "v1_16_R2": Highlight_1_16_r2.killHighlighted(returnedIds, p); break;

case "v1_16_R3": Highlight_1_16_r3.killHighlighted(returnedIds, p); break;

}

p.sendMessage(HaroTorch.getMessagePrefix() + ChatColor.GOLD + LangHandler.activeLang.getLangMessages().get("endingHighlight"));
Expand Down

0 comments on commit ffa5495

Please sign in to comment.