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

@ -56,7 +56,6 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue; import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue; import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib; import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences; import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer; import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -73,7 +72,7 @@ import org.bukkit.plugin.Plugin;
import java.io.*; import java.io.*;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
import java.net.URL; import java.net.URL;
import java.util.*; import java.util.Date;
@SuppressWarnings("CanBeFinal") @SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener { public class Iris extends VolmitPlugin implements Listener {
@ -443,13 +442,9 @@ public class Iris extends VolmitPlugin implements Listener {
try { try {
sender.sendMessage(string); sender.sendMessage(string);
} catch (Throwable ignored) { } catch (Throwable ignored) {
try try {
{
System.out.println(string); System.out.println(string);
} } catch (Throwable ignored1) {
catch(Throwable ignored1)
{
} }
} }

View File

@ -28,7 +28,6 @@ import com.volmit.iris.engine.object.objects.IrisDirection;
import com.volmit.iris.engine.object.objects.IrisObject; import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.format.Form; import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.Consumer2; import com.volmit.iris.util.function.Consumer2;
import com.volmit.iris.util.io.Converter; import com.volmit.iris.util.io.Converter;
@ -42,8 +41,6 @@ import com.volmit.iris.util.nbt.tag.IntTag;
import com.volmit.iris.util.nbt.tag.ListTag; import com.volmit.iris.util.nbt.tag.ListTag;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import net.kyori.adventure.text.minimessage.parser.Token;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Jigsaw; import org.bukkit.block.data.type.Jigsaw;

View File

@ -1,6 +1,5 @@
package com.volmit.iris.core; package com.volmit.iris.core;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -15,13 +14,13 @@ public class DolphinManager implements Listener {
* Note: This results in odd dolphin behaviour, but it's the best we can do. * Note: This results in odd dolphin behaviour, but it's the best we can do.
*/ */
@EventHandler @EventHandler
public void on(PlayerInteractEntityEvent event){ public void on(PlayerInteractEntityEvent event) {
if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())){ if (!IrisToolbelt.isIrisWorld(event.getPlayer().getWorld())) {
return; return;
} }
Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType(); Material hand = event.getPlayer().getInventory().getItem(event.getHand()).getType();
if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))){ if (event.getRightClicked().getType().equals(EntityType.DOLPHIN) && (hand.equals(Material.TROPICAL_FISH) || hand.equals(Material.PUFFERFISH) || hand.equals(Material.COD) || hand.equals(Material.SALMON))) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -14,8 +14,8 @@ public class VillagerManager implements Listener {
* Replace or disable villager trade add event to prevent explorer map * Replace or disable villager trade add event to prevent explorer map
*/ */
@EventHandler @EventHandler
public void on(VillagerAcquireTradeEvent event){ public void on(VillagerAcquireTradeEvent event) {
if (!IrisToolbelt.isIrisWorld((event.getEntity().getWorld()))){ if (!IrisToolbelt.isIrisWorld((event.getEntity().getWorld()))) {
return; return;
} }
@ -26,13 +26,13 @@ public class VillagerManager implements Listener {
IrisVillagerOverride override = IrisToolbelt.access(event.getEntity().getWorld()).getCompound().getRootDimension().getPatchCartographers(); IrisVillagerOverride override = IrisToolbelt.access(event.getEntity().getWorld()).getCompound().getRootDimension().getPatchCartographers();
if (override.isDisableTrade()){ if (override.isDisableTrade()) {
event.setCancelled(true); event.setCancelled(true);
Iris.debug("Cancelled cartographer trade @ " + event.getEntity().getLocation()); Iris.debug("Cancelled cartographer trade @ " + event.getEntity().getLocation());
return; return;
} }
if (override.getValidItems() == null){ if (override.getValidItems() == null) {
event.setCancelled(true); event.setCancelled(true);
Iris.debug("Cancelled cartographer trade because no override items are valid @ " + event.getEntity().getLocation()); Iris.debug("Cancelled cartographer trade because no override items are valid @ " + event.getEntity().getLocation());
return; return;

View File

@ -26,14 +26,12 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter; import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.WorldMatter; import com.volmit.iris.util.matter.WorldMatter;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J; import com.volmit.iris.util.scheduling.J;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -68,8 +66,7 @@ public class WandManager implements Listener {
} }
public void tick(Player p) { public void tick(Player p) {
try try {
{
try { try {
if (isWand(p.getInventory().getItemInMainHand())) { if (isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p.getInventory().getItemInMainHand()); Location[] d = getCuboid(p.getInventory().getItemInMainHand());
@ -78,10 +75,7 @@ public class WandManager implements Listener {
} catch (Throwable e) { } catch (Throwable e) {
Iris.reportError(e); Iris.reportError(e);
} }
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }

View File

@ -39,8 +39,7 @@ public class CommandIrisAura extends MortarCommand {
@Override @Override
public boolean handle(VolmitSender sender, String[] args) { public boolean handle(VolmitSender sender, String[] args) {
try try {
{
int h = Integer.parseInt(args[0]); int h = Integer.parseInt(args[0]);
int s = Integer.parseInt(args[1]); int s = Integer.parseInt(args[1]);
int b = Integer.parseInt(args[2]); int b = Integer.parseInt(args[2]);
@ -49,10 +48,7 @@ public class CommandIrisAura extends MortarCommand {
IrisSettings.get().getGeneral().setSpinb(b); IrisSettings.get().getGeneral().setSpinb(b);
IrisSettings.get().forceSave(); IrisSettings.get().forceSave();
sender.sendMessage("<rainbow>Aura Spins updated to " + h + " " + s + " " + b); sender.sendMessage("<rainbow>Aura Spins updated to " + h + " " + s + " " + b);
} } catch (Throwable b) {
catch(Throwable b)
{
sender.sendMessage(getArgsUsage()); sender.sendMessage(getArgsUsage());
} }

View File

@ -19,7 +19,6 @@
package com.volmit.iris.core.command; package com.volmit.iris.core.command;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisToolbelt; import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.IrisEngine; import com.volmit.iris.engine.IrisEngine;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings; import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager; import com.volmit.iris.core.WandManager;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter; import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.plugin.MortarCommand; import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;

View File

@ -60,27 +60,23 @@ public class CommandIrisStudioUpdate extends MortarCommand {
return true; return true;
} }
for(String i : args) for (String i : args) {
{ if (i.equals("--rewrite-objects")) {
if(i.equals("--rewrite-objects"))
{
IrisData data = new IrisData(Iris.proj.getWorkspaceFolder(args[0])); IrisData data = new IrisData(Iris.proj.getWorkspaceFolder(args[0]));
int t = data.getObjectLoader().getPossibleKeys().length; int t = data.getObjectLoader().getPossibleKeys().length;
ChronoLatch cl = new ChronoLatch(250, false); ChronoLatch cl = new ChronoLatch(250, false);
MultiBurst bx = new MultiBurst("Object Rewriter",Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors()); MultiBurst bx = new MultiBurst("Object Rewriter", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors());
BurstExecutor b = bx.burst(); BurstExecutor b = bx.burst();
int g = 0; int g = 0;
for(String f : data.getObjectLoader().getPossibleKeys()) for (String f : data.getObjectLoader().getPossibleKeys()) {
{
int finalG1 = g; int finalG1 = g;
b.queue(() -> { b.queue(() -> {
if(cl.flip()) if (cl.flip()) {
{
Iris.info("Rewriting: " + Form.f(t - finalG1) + " Objects Left"); Iris.info("Rewriting: " + Form.f(t - finalG1) + " Objects Left");
} }
File ff = data.getObjectLoader().findFile(f); File ff = data.getObjectLoader().findFile(f);
IrisObject oo = new IrisObject(0,0,0); IrisObject oo = new IrisObject(0, 0, 0);
try { try {
oo.read(ff); oo.read(ff);
} catch (Throwable e) { } catch (Throwable e) {
@ -88,8 +84,7 @@ public class CommandIrisStudioUpdate extends MortarCommand {
return; return;
} }
if(oo == null) if (oo == null) {
{
Iris.error("FAILER TO READ: " + f); Iris.error("FAILER TO READ: " + f);
return; return;
} }

View File

@ -31,11 +31,13 @@ public class MythicMobsLink {
/** /**
* Spawn a mythic mob at this location * Spawn a mythic mob at this location
*
* @param mob The mob * @param mob The mob
* @param location The location * @param location The location
* @return The mob, or null if it can't be spawned * @return The mob, or null if it can't be spawned
*/ */
public @Nullable Entity spawnMob(String mob, Location location) { public @Nullable
Entity spawnMob(String mob, Location location) {
if (!isEnabled()) return null; if (!isEnabled()) return null;
if (spawnMobFunction != null) { if (spawnMobFunction != null) {
@ -72,7 +74,7 @@ public class MythicMobsLink {
return mobs; return mobs;
} }
if(isEnabled()) { if (isEnabled()) {
try { try {
Class<?> mythicMobClass = Class.forName("io.lumine.xikage.mythicmobs.MythicMobs"); Class<?> mythicMobClass = Class.forName("io.lumine.xikage.mythicmobs.MythicMobs");

View File

@ -18,11 +18,7 @@
package com.volmit.iris.core.link; package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.OraxenItems; import io.th0rgal.oraxen.items.OraxenItems;
import io.th0rgal.oraxen.mechanics.Mechanic; import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.MechanicFactory; import io.th0rgal.oraxen.mechanics.MechanicFactory;
@ -33,7 +29,6 @@ import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic
import io.th0rgal.oraxen.utils.Utils; import io.th0rgal.oraxen.utils.Utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing; import org.bukkit.block.data.MultipleFacing;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
@ -49,40 +44,32 @@ public class OraxenLink {
} }
public BlockData getBlockDataFor(String id) { public BlockData getBlockDataFor(String id) {
if(!supported()) if (!supported()) {
{
return null; return null;
} }
MechanicFactory f = getFactory(id); MechanicFactory f = getFactory(id);
if(f == null) if (f == null) {
{
return null; return null;
} }
Mechanic m = f.getMechanic(id); Mechanic m = f.getMechanic(id);
// TODO: Why isnt there a simple getBlockData() function? // TODO: Why isnt there a simple getBlockData() function?
if(m.getFactory() instanceof NoteBlockMechanicFactory) if (m.getFactory() instanceof NoteBlockMechanicFactory) {
{
return ((NoteBlockMechanicFactory) m.getFactory()).createNoteBlockData(id); return ((NoteBlockMechanicFactory) m.getFactory()).createNoteBlockData(id);
} } else if (m.getFactory() instanceof BlockMechanicFactory) {
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
else if(m.getFactory() instanceof BlockMechanicFactory) Utils.setBlockFacing(newBlockData, ((BlockMechanic) m).getCustomVariation());
{
MultipleFacing newBlockData = (MultipleFacing)Bukkit.createBlockData(Material.MUSHROOM_STEM);
Utils.setBlockFacing(newBlockData, ((BlockMechanic)m).getCustomVariation());
return newBlockData; return newBlockData;
} }
return null; return null;
} }
public MechanicFactory getFactory(String id) public MechanicFactory getFactory(String id) {
{ if (!supported()) {
if(!supported())
{
return null; return null;
} }
@ -91,10 +78,8 @@ public class OraxenLink {
f.setAccessible(true); f.setAccessible(true);
Map<String, MechanicFactory> map = (Map<String, MechanicFactory>) f.get(null); Map<String, MechanicFactory> map = (Map<String, MechanicFactory>) f.get(null);
for(MechanicFactory i : map.values()) for (MechanicFactory i : map.values()) {
{ if (i.getItems().contains(id)) {
if(i.getItems().contains(id))
{
return i; return i;
} }
} }
@ -106,17 +91,14 @@ public class OraxenLink {
} }
public String[] getItemTypes() { public String[] getItemTypes() {
if(!supported()) if (!supported()) {
{
return EMPTY; return EMPTY;
} }
KList<String> v = new KList<>(); KList<String> v = new KList<>();
for(String i : OraxenItems.getItemNames()) for (String i : OraxenItems.getItemNames()) {
{ if (getBlockDataFor(i) != null) {
if(getBlockDataFor(i) != null)
{
v.add(i); v.add(i);
} }
} }

View File

@ -23,7 +23,6 @@ import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.WorldCreator; import org.bukkit.WorldCreator;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.block.TileState;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;

View File

@ -23,14 +23,17 @@ import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.util.collection.KMap; import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.nbt.io.NBTUtil; import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.tag.CompoundTag; import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.IntTag;
import net.minecraft.core.BlockPosition; import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry; import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryWritable; import net.minecraft.core.IRegistryWritable;
import net.minecraft.nbt.*; import net.minecraft.nbt.NBTCompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.resources.MinecraftKey; import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.WorldServer; import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.biome.BiomeBase; import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.entity.TileEntity; import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData; import net.minecraft.world.level.block.state.IBlockData;
@ -44,7 +47,6 @@ import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer; import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld; import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity; import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import net.minecraft.world.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
@ -74,15 +76,14 @@ public class NMSBinding17_1 implements INMSBinding {
@Override @Override
public boolean hasTile(Location l) { public boolean hasTile(Location l) {
return ((CraftWorld)l.getWorld()).getHandle().getTileEntity(new BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null; return ((CraftWorld) l.getWorld()).getHandle().getTileEntity(new BlockPosition(l.getBlockX(), l.getBlockY(), l.getBlockZ()), false) != null;
} }
@Override @Override
public CompoundTag serializeTile(Location location) { public CompoundTag serializeTile(Location location) {
TileEntity e = ((CraftWorld)location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true); TileEntity e = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
if(e == null) if (e == null) {
{
return null; return null;
} }
@ -95,12 +96,11 @@ public class NMSBinding17_1 implements INMSBinding {
public void deserializeTile(CompoundTag s, Location newPosition) { public void deserializeTile(CompoundTag s, Location newPosition) {
NBTTagCompound c = convert(s); NBTTagCompound c = convert(s);
if(c != null) if (c != null) {
{
int x = newPosition.getBlockX(); int x = newPosition.getBlockX();
int y = newPosition.getBlockY(); int y = newPosition.getBlockY();
int z = newPosition.getBlockZ(); int z = newPosition.getBlockZ();
WorldServer w = ((CraftWorld)newPosition.getWorld()).getHandle(); WorldServer w = ((CraftWorld) newPosition.getWorld()).getHandle();
Chunk ch = w.getChunkAt(x >> 4, z >> 4); Chunk ch = w.getChunkAt(x >> 4, z >> 4);
ChunkSection sect = ch.getSections()[y >> 4]; ChunkSection sect = ch.getSections()[y >> 4];
IBlockData block = sect.getBlocks().a(x & 15, y & 15, z & 15); IBlockData block = sect.getBlocks().a(x & 15, y & 15, z & 15);
@ -109,8 +109,7 @@ public class NMSBinding17_1 implements INMSBinding {
} }
} }
private NBTTagCompound convert(CompoundTag tag) private NBTTagCompound convert(CompoundTag tag) {
{
try { try {
ByteArrayOutputStream boas = new ByteArrayOutputStream(); ByteArrayOutputStream boas = new ByteArrayOutputStream();
NBTUtil.write(tag, boas, false); NBTUtil.write(tag, boas, false);
@ -118,18 +117,14 @@ public class NMSBinding17_1 implements INMSBinding {
NBTTagCompound c = NBTCompressedStreamTools.a((DataInput) din); NBTTagCompound c = NBTCompressedStreamTools.a((DataInput) din);
din.close(); din.close();
return c; return c;
} } catch (Throwable e) {
catch(Throwable e)
{
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
private CompoundTag convert(NBTTagCompound tag) private CompoundTag convert(NBTTagCompound tag) {
{
try { try {
ByteArrayOutputStream boas = new ByteArrayOutputStream(); ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(boas); DataOutputStream dos = new DataOutputStream(boas);
@ -145,7 +140,7 @@ public class NMSBinding17_1 implements INMSBinding {
@Override @Override
public CompoundTag serializeEntity(org.bukkit.entity.Entity be) { public CompoundTag serializeEntity(org.bukkit.entity.Entity be) {
Entity entity = ((CraftEntity)be).getHandle(); Entity entity = ((CraftEntity) be).getHandle();
NBTTagCompound tag = new NBTTagCompound(); NBTTagCompound tag = new NBTTagCompound();
entity.save(tag); entity.save(tag);
CompoundTag t = convert(tag); CompoundTag t = convert(tag);
@ -165,7 +160,7 @@ public class NMSBinding17_1 implements INMSBinding {
pos.a(2, NBTTagDouble.a(newPosition.getZ())); pos.a(2, NBTTagDouble.a(newPosition.getZ()));
tag.set("Pos", pos); tag.set("Pos", pos);
org.bukkit.entity.Entity be = newPosition.getWorld().spawnEntity(newPosition, type); org.bukkit.entity.Entity be = newPosition.getWorld().spawnEntity(newPosition, type);
((CraftEntity)be).getHandle().load(tag); ((CraftEntity) be).getHandle().load(tag);
return be; return be;
} }

View File

@ -28,9 +28,6 @@ import com.volmit.iris.util.data.B;
import com.volmit.iris.util.json.JSONArray; import com.volmit.iris.util.json.JSONArray;
import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.json.JSONObject;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.awt.*; import java.awt.*;
@ -225,11 +222,10 @@ public class SchemaBuilder {
prop.put("$ref", "#/definitions/" + key); prop.put("$ref", "#/definitions/" + key);
description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)"); description.add(SYMBOL_TYPE__N + " Must be a valid Item Type (use ctrl+space for auto complete!)");
} else if(k.isAnnotationPresent(RegistryListSpecialEntity.class)) { } else if (k.isAnnotationPresent(RegistryListSpecialEntity.class)) {
String key = "enum-reg-specialentity"; String key = "enum-reg-specialentity";
if(!definitions.containsKey(key)) if (!definitions.containsKey(key)) {
{
JSONObject j = new JSONObject(); JSONObject j = new JSONObject();
KList<String> list = new KList<>(); KList<String> list = new KList<>();
list.addAll(Iris.linkMythicMobs.getMythicMobTypes().stream().map(s -> "MythicMobs:" + s).collect(Collectors.toList())); list.addAll(Iris.linkMythicMobs.getMythicMobTypes().stream().map(s -> "MythicMobs:" + s).collect(Collectors.toList()));
@ -540,7 +536,7 @@ public class SchemaBuilder {
return "number"; return "number";
} }
if (c.equals(boolean.class)||c.equals(Boolean.class)) { if (c.equals(boolean.class) || c.equals(Boolean.class)) {
return "boolean"; return "boolean";
} }
@ -570,7 +566,7 @@ public class SchemaBuilder {
} }
// suppress warnings on bukkit classes // suppress warnings on bukkit classes
if (r.getDeclaringClass().getName().startsWith("org.bukkit.")){ if (r.getDeclaringClass().getName().startsWith("org.bukkit.")) {
return "Bukkit package classes and enums have no descriptions"; return "Bukkit package classes and enums have no descriptions";
} }

View File

@ -18,7 +18,6 @@
package com.volmit.iris.core.wand; package com.volmit.iris.core.wand;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.Cuboid; import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.M; import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
@ -33,23 +32,18 @@ public class WandSelection {
private final Cuboid c; private final Cuboid c;
private final Player p; private final Player p;
public WandSelection(Cuboid c, Player p) public WandSelection(Cuboid c, Player p) {
{
this.c = c; this.c = c;
this.p = p; this.p = p;
} }
public void draw() public void draw() {
{
double accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(c.getCenter())); double accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(c.getCenter()));
double dist = M.lerp(0.125, 3.5, accuracy); double dist = M.lerp(0.125, 3.5, accuracy);
for(double i = c.getLowerX()-1; i < c.getUpperX()+1; i+=0.25) for (double i = c.getLowerX() - 1; i < c.getUpperX() + 1; i += 0.25) {
{ for (double j = c.getLowerY() - 1; j < c.getUpperY() + 1; j += 0.25) {
for(double j = c.getLowerY()-1; j < c.getUpperY()+1; j+=0.25) for (double k = c.getLowerZ() - 1; k < c.getUpperZ() + 1; k += 0.25) {
{
for(double k = c.getLowerZ()-1; k < c.getUpperZ()+1; k+=0.25)
{
boolean ii = i == c.getLowerX() || i == c.getUpperX(); boolean ii = i == c.getLowerX() || i == c.getUpperX();
boolean jj = j == c.getLowerY() || j == c.getUpperY(); boolean jj = j == c.getLowerY() || j == c.getUpperY();
boolean kk = k == c.getLowerZ() || k == c.getUpperZ(); boolean kk = k == c.getLowerZ() || k == c.getUpperZ();
@ -85,28 +79,23 @@ public class WandSelection {
accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(a)); accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(a));
dist = M.lerp(0.125, 3.5, accuracy); dist = M.lerp(0.125, 3.5, accuracy);
if(M.r(M.min(dist*5, 0.9D) * 0.995)) if (M.r(M.min(dist * 5, 0.9D) * 0.995)) {
{
continue; continue;
} }
if(ii && jj) if (ii && jj) {
{
a.add(0, 0, RNG.r.d(-0.3, 0.3)); a.add(0, 0, RNG.r.d(-0.3, 0.3));
} }
if(kk && jj) if (kk && jj) {
{
a.add(RNG.r.d(-0.3, 0.3), 0, 0); a.add(RNG.r.d(-0.3, 0.3), 0, 0);
} }
if(ii && kk) if (ii && kk) {
{
a.add(0, RNG.r.d(-0.3, 0.3), 0); a.add(0, RNG.r.d(-0.3, 0.3), 0);
} }
if(p.getLocation().distanceSquared(a) < 256 * 256) if (p.getLocation().distanceSquared(a) < 256 * 256) {
{
Color color = Color.getHSBColor((float) (0.5f + (Math.sin((i + j + k + (p.getTicksLived() / 2f)) / (20f)) / 2)), 1, 1); Color color = Color.getHSBColor((float) (0.5f + (Math.sin((i + j + k + (p.getTicksLived() / 2f)) / (20f)) / 2)), 1, 1);
int r = color.getRed(); int r = color.getRed();
int g = color.getGreen(); int g = color.getGreen();
@ -115,7 +104,7 @@ public class WandSelection {
p.spawnParticle(Particle.REDSTONE, a.getX(), a.getY(), a.getZ(), p.spawnParticle(Particle.REDSTONE, a.getX(), a.getY(), a.getZ(),
1, 0, 0, 0, 0, 1, 0, 0, 0, 0,
new Particle.DustOptions(org.bukkit.Color.fromRGB(r, g, b), new Particle.DustOptions(org.bukkit.Color.fromRGB(r, g, b),
(float) dist*3f)); (float) dist * 3f));
} }
} }
} }

View File

@ -87,13 +87,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
looper = new Looper() { looper = new Looper() {
@Override @Override
protected long loop() { protected long loop() {
if(M.ms() < charge) if (M.ms() < charge) {
{
energy += 70; energy += 70;
} }
if(cln.flip()) if (cln.flip()) {
{
engine.getEngineData().cleanup(getEngine()); engine.getEngineData().cleanup(getEngine());
} }
@ -207,14 +205,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
.collect(Collectors.toList())) .collect(Collectors.toList()))
.popRandom(RNG.r); .popRandom(RNG.r);
if(v != null && v.getReferenceSpawner() != null) if (v != null && v.getReferenceSpawner() != null) {
{
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk(); int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
for (Entity i : c.getEntities()) { for (Entity i : c.getEntities()) {
if (i instanceof LivingEntity) { if (i instanceof LivingEntity) {
if(-maxEntCount <= 0) if (-maxEntCount <= 0) {
{
return; return;
} }
} }
@ -228,36 +224,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
private void spawn(Chunk c, IrisEntitySpawn i) { private void spawn(Chunk c, IrisEntitySpawn i) {
boolean allow = true; boolean allow = true;
if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
{
allow = false; allow = false;
IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX(), c.getZ()); IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX(), c.getZ());
IrisEngineSpawnerCooldown sc = null; IrisEngineSpawnerCooldown sc = null;
for(IrisEngineSpawnerCooldown j : cd.getCooldowns()) for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
{ if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey()))
{
sc = j; sc = j;
break; break;
} }
} }
if(sc == null) if (sc == null) {
{
sc = new IrisEngineSpawnerCooldown(); sc = new IrisEngineSpawnerCooldown();
sc.setSpawner(i.getReferenceSpawner().getLoadKey()); sc.setSpawner(i.getReferenceSpawner().getLoadKey());
cd.getCooldowns().add(sc); cd.getCooldowns().add(sc);
} }
if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
{
sc.spawn(getEngine()); sc.spawn(getEngine());
allow = true; allow = true;
} }
} }
if(allow) if (allow) {
{
int s = i.spawn(getEngine(), c, RNG.r); int s = i.spawn(getEngine(), c, RNG.r);
actuallySpawned += s; actuallySpawned += s;
if (s > 0) { if (s > 0) {

View File

@ -21,9 +21,7 @@ package com.volmit.iris.engine.object.annotations;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.Target; import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD; import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME; import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME) @Retention(RUNTIME)

View File

@ -149,10 +149,8 @@ public class IrisBlockData extends IrisRegistrant {
}); });
} }
private String keyify(String dat) private String keyify(String dat) {
{ if (dat.contains(":")) {
if(dat.contains(":"))
{
return dat; return dat;
} }

View File

@ -34,7 +34,6 @@ import com.volmit.iris.engine.object.carve.IrisCaveFluid;
import com.volmit.iris.engine.object.carve.IrisCaveLayer; import com.volmit.iris.engine.object.carve.IrisCaveLayer;
import com.volmit.iris.engine.object.carve.IrisCaverns; import com.volmit.iris.engine.object.carve.IrisCaverns;
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator; import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional; import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.engine.object.feature.IrisFeaturePotential; import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure; import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure;
@ -47,6 +46,7 @@ import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
import com.volmit.iris.engine.object.regional.IrisRegion; import com.volmit.iris.engine.object.regional.IrisRegion;
import com.volmit.iris.engine.object.spawners.IrisSpawner; import com.volmit.iris.engine.object.spawners.IrisSpawner;
import com.volmit.iris.engine.object.trees.IrisTreeSettings; import com.volmit.iris.engine.object.trees.IrisTreeSettings;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.DataProvider; import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.io.IO; import com.volmit.iris.util.io.IO;

View File

@ -28,14 +28,11 @@ public class IrisEngineChunkData {
private long chunk; private long chunk;
private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>(); private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>();
public void cleanup(Engine engine) public void cleanup(Engine engine) {
{ for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
for(IrisEngineSpawnerCooldown i : getCooldowns().copy())
{
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner()); IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if(sp == null || i.canSpawn(sp.getMaximumRate())) if (sp == null || i.canSpawn(sp.getMaximumRate())) {
{
getCooldowns().remove(i); getCooldowns().remove(i);
} }
} }

View File

@ -20,7 +20,6 @@ package com.volmit.iris.engine.object.engine;
import com.volmit.iris.engine.data.cache.Cache; import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine; import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.meta.IrisEnchantment;
import com.volmit.iris.engine.object.spawners.IrisSpawner; import com.volmit.iris.engine.object.spawners.IrisSpawner;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import lombok.Data; import lombok.Data;
@ -31,20 +30,16 @@ public class IrisEngineData {
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>(); private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
private KList<IrisEngineChunkData> chunks = new KList<>(); private KList<IrisEngineChunkData> chunks = new KList<>();
public void removeChunk(int x, int z) public void removeChunk(int x, int z) {
{
long k = Cache.key(x, z); long k = Cache.key(x, z);
chunks.removeWhere((i) -> i.getChunk() == k); chunks.removeWhere((i) -> i.getChunk() == k);
} }
public IrisEngineChunkData getChunk(int x, int z) public IrisEngineChunkData getChunk(int x, int z) {
{
long k = Cache.key(x, z); long k = Cache.key(x, z);
for(IrisEngineChunkData i : chunks) for (IrisEngineChunkData i : chunks) {
{ if (i.getChunk() == k) {
if(i.getChunk() == k)
{
return i; return i;
} }
} }
@ -56,22 +51,18 @@ public class IrisEngineData {
} }
public void cleanup(Engine engine) { public void cleanup(Engine engine) {
for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
{
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner()); IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if(sp == null || i.canSpawn(sp.getMaximumRate())) if (sp == null || i.canSpawn(sp.getMaximumRate())) {
{
getSpawnerCooldowns().remove(i); getSpawnerCooldowns().remove(i);
} }
} }
for(IrisEngineChunkData i : chunks.copy()) for (IrisEngineChunkData i : chunks.copy()) {
{
i.cleanup(engine); i.cleanup(engine);
if(i.isEmpty()) if (i.isEmpty()) {
{
getChunks().remove(i); getChunks().remove(i);
} }
} }

View File

@ -348,8 +348,7 @@ public class IrisObject extends IrisRegistrant {
} }
public void write(File file) throws IOException { public void write(File file) throws IOException {
if(file == null) if (file == null) {
{
return; return;
} }

View File

@ -44,7 +44,7 @@ public class IrisVillagerOverride {
.setMinTrades(3) .setMinTrades(3)
.setMaxTrades(5)); .setMaxTrades(5));
public KList<IrisVillagerTrade> getValidItems(){ public KList<IrisVillagerTrade> getValidItems() {
KList<IrisVillagerTrade> valid = new KList<>(); KList<IrisVillagerTrade> valid = new KList<>();
getItems().stream().filter(IrisVillagerTrade::isValidItems).forEach(valid::add); getItems().stream().filter(IrisVillagerTrade::isValidItems).forEach(valid::add);
return valid.size() == 0 ? null : valid; return valid.size() == 0 ? null : valid;

View File

@ -4,9 +4,7 @@ package com.volmit.iris.engine.object.villager;
import com.volmit.iris.Iris; import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.annotations.*; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG; import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.S;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -58,7 +56,7 @@ public class IrisVillagerTrade {
* mintrades > 0, maxtrades > 0, maxtrades > mintrades, and<br> * mintrades > 0, maxtrades > 0, maxtrades > mintrades, and<br>
* ingredient 1, (if defined ingredient 2) and the result are valid items * ingredient 1, (if defined ingredient 2) and the result are valid items
*/ */
public boolean isValidItems(){ public boolean isValidItems() {
KList<String> warnings = new KList<>(); KList<String> warnings = new KList<>();
if (ingredient1 == null) { if (ingredient1 == null) {
warnings.add("Ingredient 1 is null"); warnings.add("Ingredient 1 is null");
@ -80,15 +78,15 @@ public class IrisVillagerTrade {
warnings.add("More minimal than maximal trades"); warnings.add("More minimal than maximal trades");
} }
if (ingredient1 != null && !ingredient1.getType().isItem()){ if (ingredient1 != null && !ingredient1.getType().isItem()) {
warnings.add("Ingredient 1 is not an item"); warnings.add("Ingredient 1 is not an item");
} }
if (ingredient2 != null && !ingredient2.getType().isItem()){ if (ingredient2 != null && !ingredient2.getType().isItem()) {
warnings.add("Ingredient 2 is not an item"); warnings.add("Ingredient 2 is not an item");
} }
if (result != null && !result.getType().isItem()){ if (result != null && !result.getType().isItem()) {
warnings.add("Result is not an item"); warnings.add("Result is not an item");
} }
@ -103,10 +101,11 @@ public class IrisVillagerTrade {
/** /**
* Get the ingredients * Get the ingredients
*
* @return The list of 1 or 2 ingredients (depending on if ing2 is null) * @return The list of 1 or 2 ingredients (depending on if ing2 is null)
*/ */
public List<ItemStack> getIngredients() { public List<ItemStack> getIngredients() {
if (!isValidItems()){ if (!isValidItems()) {
return null; return null;
} }
return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2); return ingredient2 == null ? new KList<>(ingredient1) : new KList<>(ingredient1, ingredient2);
@ -122,7 +121,7 @@ public class IrisVillagerTrade {
/** /**
* @return the trade as a merchant recipe * @return the trade as a merchant recipe
*/ */
public MerchantRecipe convert(){ public MerchantRecipe convert() {
MerchantRecipe recipe = new MerchantRecipe(getResult(), getAmount()); MerchantRecipe recipe = new MerchantRecipe(getResult(), getAmount());
recipe.setIngredients(getIngredients()); recipe.setIngredients(getIngredients());
return recipe; return recipe;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -19,8 +19,6 @@
package com.volmit.iris.util.matter.slices; package com.volmit.iris.util.matter.slices;
import com.volmit.iris.core.nms.INMS; 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.MatterTile;
import com.volmit.iris.util.matter.Sliced; import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil; 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)))); 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) -> { registerReader(World.class, (w, x, y, z) -> {
Location l = new Location(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); CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null) if (tag != null) {
{
return new MatterTile(tag); return new MatterTile(tag);
} }
} }

View File

@ -23,13 +23,8 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C; import com.volmit.iris.util.format.C;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; 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.Component;
import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.transformation.inbuild.GradientTransformation;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -188,22 +183,17 @@ public class VolmitSender implements CommandSender {
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
if(message.contains("<NOMINI>")) if (message.contains("<NOMINI>")) {
{
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", "")); s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
return; return;
} }
try try {
{
String t = C.translateAlternateColorCodes('&', getTag() + message); 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); Component c = MiniMessage.get().parse(a);
Iris.audiences.sender(s).sendMessage(c); Iris.audiences.sender(s).sendMessage(c);
} } catch (Throwable e) {
catch(Throwable e)
{
String t = C.translateAlternateColorCodes('&', getTag() + message); 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());

View File

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