forked from SteamWar/SteamWar
TechHider refactoring, simple Blocktagging
This commit is contained in:
+6
-15
@@ -27,9 +27,7 @@ import net.minecraft.core.SectionPosition;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutBlockChange;
|
||||
import net.minecraft.network.protocol.game.PacketPlayOutMultiBlockChange;
|
||||
import net.minecraft.world.level.block.state.IBlockData;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -38,20 +36,13 @@ public class HullHiderWrapper18 implements HullHiderWrapper {
|
||||
private static final Reflection.MethodInvoker getState = Reflection.getTypedMethod(Reflection.getClass("{obc}.block.data.CraftBlockData"), "getState", IBlockData.class);
|
||||
@Override
|
||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||
List<Object> blockdata = new ArrayList<>(changes.size());
|
||||
Object[] blockdata = new Object[changes.size()];
|
||||
for(int i = 0; i < blockdata.length; i++) {
|
||||
Hull.IntVector change = changes.get(i);
|
||||
blockdata[i] = getState.invoke(Config.world.getBlockData(change.getX(), change.getY(), change.getZ()));
|
||||
}
|
||||
|
||||
changes.removeIf(change -> {
|
||||
BlockData data = Config.world.getBlockData(change.getX(), change.getY(), change.getZ());
|
||||
boolean unchanged = data.getMaterial() == Config.ObfuscateWith || Config.HiddenBlocks.contains(data.getMaterial());
|
||||
if(!unchanged)
|
||||
blockdata.add(getState.invoke(data));
|
||||
return unchanged;
|
||||
});
|
||||
|
||||
if(changes.isEmpty())
|
||||
return null;
|
||||
|
||||
return generateBlockChangePacket(changes, blockdata.toArray());
|
||||
return generateBlockChangePacket(changes, blockdata);
|
||||
}
|
||||
|
||||
private Object generateBlockChangePacket(List<Hull.IntVector> changes, Object[] blockdata) {
|
||||
|
||||
@@ -21,7 +21,6 @@ package de.steamwar.fightsystem.utils;
|
||||
|
||||
import com.comphenix.tinyprotocol.Reflection;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -31,14 +30,6 @@ public class HullHiderWrapper8 implements HullHiderWrapper {
|
||||
private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle");
|
||||
@Override
|
||||
public Object generateBlockChangePacket(List<Hull.IntVector> changes) {
|
||||
changes.removeIf(change -> {
|
||||
Material material = Config.world.getBlockAt(change.getX(), change.getY(), change.getZ()).getType();
|
||||
return material == Config.ObfuscateWith || Config.HiddenBlocks.contains(material);
|
||||
});
|
||||
|
||||
if(changes.isEmpty())
|
||||
return null;
|
||||
|
||||
Hull.IntVector chunk = changes.get(0);
|
||||
chunk = new Hull.IntVector(chunk.getX() >> 4, chunk.getY() >> 4, chunk.getZ() >> 4);
|
||||
int xOffset = 16*chunk.getX();
|
||||
|
||||
@@ -187,9 +187,6 @@ public class Hull {
|
||||
|
||||
for (Map.Entry<IntVector, List<IntVector>> entry : sectionWise.entrySet()) {
|
||||
Object packet = HullHiderWrapper.impl.generateBlockChangePacket(entry.getValue());
|
||||
if(packet == null)
|
||||
continue;
|
||||
|
||||
players.forEach(player -> TinyProtocol.instance.sendPacket(player, packet));
|
||||
}
|
||||
}
|
||||
|
||||
+3
-1
@@ -112,7 +112,9 @@ public class TechHiderWrapper extends StateDependent implements TechHider.Locati
|
||||
public TechHider.State check(Player player, int x, int y, int z) {
|
||||
if(hiddenRegion.computeIfAbsent(player, this::getHiddenRegion).inRegion(x, y, z)) {
|
||||
if(FightSystem.getHullHider().isBlockHidden(player, x, y, z)) {
|
||||
return TechHider.State.HIDE;
|
||||
long pattern = player.getUniqueId().getLeastSignificantBits();
|
||||
int id = ((y&3) << 4) + ((z&3) << 2) + (x&3);
|
||||
return (pattern & (1L << id)) == 0 ? TechHider.State.HIDE : TechHider.State.HIDE_AIR;
|
||||
} else {
|
||||
return TechHider.State.CHECK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user