9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-28 11:39:07 +00:00
This commit is contained in:
Daniel Mills
2021-08-06 22:15:11 -04:00
parent a5ef5769b9
commit e9f4c3d0c7
35 changed files with 179 additions and 335 deletions

View File

@@ -572,15 +572,11 @@ public class B {
}
}
try
{
try {
for (String i : Iris.linkOraxen.getItemTypes()) {
bt.add("oraxen:" + i);
}
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@@ -19,11 +19,6 @@
package com.volmit.iris.util.format;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.VolmitSender;
import net.kyori.adventure.text.minimessage.transformation.inbuild.FontTransformation;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.Validate;
@@ -31,8 +26,6 @@ import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import java.awt.color.ColorSpace;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@@ -334,9 +327,10 @@ public enum C {
this(token, code, intCode, false);
}
C( char code, int intCode, boolean isFormat) {
C(char code, int intCode, boolean isFormat) {
this("^", code, intCode, false);
}
C(String token, char code, int intCode, boolean isFormat) {
this.code = code;
this.token = token.equalsIgnoreCase("^") ? "<" + name().toLowerCase(Locale.ROOT) + ">" : token;
@@ -345,37 +339,31 @@ public enum C {
this.toString = new String(new char[]{COLOR_CHAR, code});
}
public static float[] spin(float[] c, int shift)
{
return new float[]{spin(c[0], shift),spinc(c[1], shift),spinc(c[2], shift)};
public static float[] spin(float[] c, int shift) {
return new float[]{spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)};
}
public static float[] spin(float[] c, int a,int b, int d)
{
return new float[]{spin(c[0], a),spinc(c[1], b),spinc(c[2], d)};
public static float[] spin(float[] c, int a, int b, int d) {
return new float[]{spin(c[0], a), spinc(c[1], b), spinc(c[2], d)};
}
public static float spin(float c, int shift)
{
float g = ((((int)Math.floor(c * 360)) + shift) % 360) / 360F;
public static float spin(float c, int shift) {
float g = ((((int) Math.floor(c * 360)) + shift) % 360) / 360F;
return g < 0 ? 1f - g : g;
}
public static float spinc(float c, int shift)
{
float g = ((((int)Math.floor(c * 255)) + shift)) / 255F;
public static float spinc(float c, int shift) {
float g = ((((int) Math.floor(c * 255)) + shift)) / 255F;
return Math.max(0f, Math.min(g, 1f));
}
public static java.awt.Color spin(java.awt.Color c, int h, int s, int b)
{
public static java.awt.Color spin(java.awt.Color c, int h, int s, int b) {
float[] hsb = java.awt.Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
hsb = spin(hsb, h, s, b);
return java.awt.Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
}
public static String spinToHex(C color, int h, int s, int b)
{
public static String spinToHex(C color, int h, int s, int b) {
return "#" + Integer.toHexString(spin(color.awtColor(), h, s, b).getRGB()).substring(2);
}
@@ -384,33 +372,26 @@ public enum C {
StringBuilder b = new StringBuilder();
boolean c = false;
for(char i : msg.toCharArray())
{
if(c)
{
for (char i : msg.toCharArray()) {
if (c) {
c = false;
C o = C.getByChar(i);
if(hrad != 0 || srad != 0 || vrad != 0)
{
if (hrad != 0 || srad != 0 || vrad != 0) {
b.append("<gradient:")
.append(spinToHex(o, hrad, srad, vrad))
.append(":")
.append(spinToHex(o, -hrad, -srad, -vrad))
.append(">");
}
else
{
} else {
b.append(C.getByChar(i).token);
}
continue;
}
if(i == C.COLOR_CHAR)
{
if (i == C.COLOR_CHAR) {
c = true;
continue;
}
@@ -421,8 +402,7 @@ public enum C {
return b.toString();
}
public static String compress(String c)
{
public static String compress(String c) {
return BaseComponent.toLegacyText(TextComponent.fromLegacyText(c));
}
@@ -455,8 +435,7 @@ public enum C {
return chatToHex(this);
}
public java.awt.Color awtColor()
{
public java.awt.Color awtColor() {
return java.awt.Color.decode(hex());
}

View File

@@ -244,16 +244,12 @@ public interface Matter {
/**
* Remove any slices that are empty
*/
default void trimSlices()
{
default void trimSlices() {
Set<Class<?>> drop = null;
for(Class<?> i : getSliceTypes())
{
if(getSlice(i).getCount() == 0)
{
if(drop == null)
{
for (Class<?> i : getSliceTypes()) {
if (getSlice(i).getCount() == 0) {
if (drop == null) {
drop = new KSet<>();
}
@@ -261,10 +257,8 @@ public interface Matter {
}
}
if(drop != null)
{
for(Class<?> i : drop)
{
if (drop != null) {
for (Class<?> i : drop) {
deleteSlice(i);
}
}
@@ -325,16 +319,12 @@ public interface Matter {
while (sliceCount-- > 0) {
String cn = din.readUTF();
try
{
try {
Class<?> type = Class.forName(cn);
MatterSlice<?> slice = matter.createSlice(type, matter);
slice.read(din);
matter.putSlice(type, slice);
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
throw new IOException("Can't read class '" + cn + "' (slice count reverse at " + sliceCount + ")");
}

View File

@@ -19,8 +19,6 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.hunk.Hunk;
@@ -68,7 +67,7 @@ public interface MatterSlice<T> extends Hunk<T> {
return false;
}
iterateSync((a,b,c,t) -> injector.writeMatter(w, t, a+x, b+y, c+z));
iterateSync((a, b, c, t) -> injector.writeMatter(w, t, a + x, b + y, c + z));
return true;
}
@@ -89,8 +88,7 @@ public interface MatterSlice<T> extends Hunk<T> {
for (int k = z; k < z + getDepth(); k++) {
T v = ejector.readMatter(w, i, j, k);
if(v != null)
{
if (v != null) {
set(i - x, j - y, k - z, v);
}
}

View File

@@ -24,26 +24,21 @@ import org.bukkit.Location;
import org.bukkit.block.data.BlockData;
public class WorldMatter {
public static void placeMatter(Matter matter, Location at)
{
if(matter.hasSlice(BlockData.class))
{
public static void placeMatter(Matter matter, Location at) {
if (matter.hasSlice(BlockData.class)) {
matter.slice(BlockData.class).writeInto(at);
}
if(matter.hasSlice(MatterEntityGroup.class))
{
if (matter.hasSlice(MatterEntityGroup.class)) {
matter.slice(MatterEntityGroup.class).writeInto(at);
}
if(matter.hasSlice(MatterTile.class))
{
if (matter.hasSlice(MatterTile.class)) {
matter.slice(MatterTile.class).writeInto(at);
}
}
public static Matter createMatter(String author, Location a, Location b)
{
public static Matter createMatter(String author, Location a, Location b) {
Cuboid c = new Cuboid(a, b);
Matter s = new IrisMatter(c.getSizeX(), c.getSizeY(), c.getSizeZ());
Iris.info(s.getWidth() + " " + s.getHeight() + " " + s.getDepth());

View File

@@ -18,13 +18,15 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.matter.*;
import com.volmit.iris.util.matter.MatterEntity;
import com.volmit.iris.util.matter.MatterEntityGroup;
import com.volmit.iris.util.matter.MatterReader;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Location;
@@ -47,20 +49,17 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
public EntityMatter(int width, int height, int depth) {
super(width, height, depth, MatterEntityGroup.class);
registerWriter(World.class, ((w, d, x, y, z) -> {
for(MatterEntity i : d.getEntities())
{
Location realPosition = new Location(w, x+i.getXOff(), y+i.getYOff(), z+i.getZOff());
for (MatterEntity i : d.getEntities()) {
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
INMS.get().deserializeEntity(i.getEntityData(), realPosition);
}
}));
registerReader(World.class, (w, x, y, z) -> {
IrisPosition pos = new IrisPosition(x,y,z);
IrisPosition pos = new IrisPosition(x, y, z);
KList<Entity> entities = entityCache.get(pos);
MatterEntityGroup g = new MatterEntityGroup();
if(entities != null)
{
for(Entity i : entities)
{
if (entities != null) {
for (Entity i : entities) {
g.getEntities().add(new MatterEntity(
Math.abs(i.getLocation().getX()) - Math.abs(i.getLocation().getBlockX()),
Math.abs(i.getLocation().getY()) - Math.abs(i.getLocation().getBlockY()),
@@ -81,17 +80,17 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
* across every block position, we simply use getNearbyEntities and cache each
* block position with a list of entities within that block, and directly feed
* the reader with the entities we capture.
* @param w the world
* @param x the x offset
* @param y the y offset
* @param z the z offset
*
* @param w the world
* @param x the x offset
* @param y the y offset
* @param z the z offset
* @param <W> the type
* @return true if we read
*/
@Override
public synchronized <W> boolean readFrom(W w, int x, int y, int z) {
if(!(w instanceof World))
{
if (!(w instanceof World)) {
return super.readFrom(w, x, y, z);
}
@@ -103,18 +102,15 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
entityCache = new KMap<>();
for(Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight())))
{
for (Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight()))) {
entityCache.compute(new IrisPosition(i.getLocation()),
(k, v) -> v == null ? new KList<>() : v).add(i);
}
for(IrisPosition i : entityCache.keySet())
{
for (IrisPosition i : entityCache.keySet()) {
MatterEntityGroup g = reader.readMatter(w, i.getX(), i.getY(), i.getZ());
if(g != null)
{
if (g != null) {
set(i.getX() - x, i.getY() - y, i.getZ() - z, g);
}
}
@@ -127,11 +123,10 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
@Override
public void writeNode(MatterEntityGroup b, DataOutputStream dos) throws IOException {
Varint.writeUnsignedVarInt(b.getEntities().size(), dos);
for(MatterEntity i : b.getEntities())
{
dos.writeByte((int)(i.getXOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int)(i.getYOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int)(i.getZOff() * 255) + Byte.MIN_VALUE);
for (MatterEntity i : b.getEntities()) {
dos.writeByte((int) (i.getXOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int) (i.getYOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int) (i.getZOff() * 255) + Byte.MIN_VALUE);
NBTUtil.write(i.getEntityData(), dos, false);
}
}
@@ -141,12 +136,11 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
MatterEntityGroup g = new MatterEntityGroup();
int c = Varint.readUnsignedVarInt(din);
while(c-- > 0)
{
while (c-- > 0) {
g.getEntities().add(new MatterEntity(
((int)din.readByte() - Byte.MIN_VALUE) / 255F,
((int)din.readByte() - Byte.MIN_VALUE) / 255F,
((int)din.readByte() - Byte.MIN_VALUE) / 255F,
((int) din.readByte() - Byte.MIN_VALUE) / 255F,
((int) din.readByte() - Byte.MIN_VALUE) / 255F,
((int) din.readByte() - Byte.MIN_VALUE) / 255F,
(CompoundTag) NBTUtil.read(din, false).getTag()));
}

View File

@@ -19,8 +19,6 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.parallax.ParallaxAccess;
import com.volmit.iris.engine.parallax.ParallaxWorld;
import com.volmit.iris.util.matter.MatterTile;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
@@ -43,12 +41,10 @@ public class TileMatter extends RawMatter<MatterTile> {
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
registerReader(World.class, (w, x, y, z) -> {
Location l = new Location(w, x, y, z);
if(INMS.get().hasTile(l))
{
if (INMS.get().hasTile(l)) {
CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null)
{
if (tag != null) {
return new MatterTile(tag);
}
}

View File

@@ -91,7 +91,7 @@ public abstract class MortarCommand implements ICommand {
b = true;
sender.sendMessage("" + C.GREEN + i.getNode() + " " + "<font:minecraft:uniform>" + (getArgsUsage().trim().isEmpty() ? "" : (C.WHITE + i.getArgsUsage())) + C.GRAY + " - " + i.getDescription());
sender.sendMessage("" + C.GREEN + i.getNode() + " " + "<font:minecraft:uniform>" + (getArgsUsage().trim().isEmpty() ? "" : (C.WHITE + i.getArgsUsage())) + C.GRAY + " - " + i.getDescription());
}
if (!b) {

View File

@@ -23,13 +23,8 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.Adventure;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.transformation.inbuild.GradientTransformation;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -188,24 +183,19 @@ public class VolmitSender implements CommandSender {
@Override
public void sendMessage(String message) {
if(message.contains("<NOMINI>"))
{
if (message.contains("<NOMINI>")) {
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
return;
}
try
{
try {
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
Component c = MiniMessage.get().parse(a);
Iris.audiences.sender(s).sendMessage(c);
}
catch(Throwable e)
{
} catch (Throwable e) {
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
Iris.debug("<NOMINI>Failure to parse " + a);
s.sendMessage(C.translateAlternateColorCodes('&', getTag() + message));

View File

@@ -19,8 +19,7 @@
package com.volmit.iris.util.reflect;
public class ShadeFix {
public static void fix(Class<?> c)
{
public static void fix(Class<?> c) {
c.getCanonicalName();
}
}