mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
noriver
This commit is contained in:
parent
ed9ddc0825
commit
20b715f7cb
27852
lint/ChangeLog.txt
27852
lint/ChangeLog.txt
File diff suppressed because it is too large
Load Diff
1053
lint/ZKM_TrimLog.txt
1053
lint/ZKM_TrimLog.txt
File diff suppressed because it is too large
Load Diff
980
lint/ZKM_log.txt
980
lint/ZKM_log.txt
File diff suppressed because it is too large
Load Diff
BIN
lint/out/in.jar
BIN
lint/out/in.jar
Binary file not shown.
Binary file not shown.
@ -1,6 +1,10 @@
|
||||
package com.volmit.iris;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -10,6 +14,7 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import com.volmit.iris.activation.IrisActivation1;
|
||||
import com.volmit.iris.command.CommandIris;
|
||||
import com.volmit.iris.command.PermissionIris;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
@ -19,12 +24,13 @@ import com.volmit.iris.gen.post.PostPotholeFiller;
|
||||
import com.volmit.iris.gen.post.PostSlabber;
|
||||
import com.volmit.iris.gen.post.PostWallPatcher;
|
||||
import com.volmit.iris.gen.post.PostWaterlogger;
|
||||
import com.volmit.iris.util.BoardManager;
|
||||
import com.volmit.iris.util.C;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.GroupedExecutor;
|
||||
import com.volmit.iris.util.IO;
|
||||
import com.volmit.iris.util.IrisLock;
|
||||
import com.volmit.iris.util.IrisPostBlockFilter;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.MortarPlugin;
|
||||
import com.volmit.iris.util.Permission;
|
||||
@ -39,7 +45,6 @@ public class Iris extends MortarPlugin
|
||||
public static WandManager wand;
|
||||
public static StructureManager struct;
|
||||
public static IrisBoardManager board;
|
||||
private BoardManager manager;
|
||||
private static IrisLock lock = new IrisLock("Iris");
|
||||
|
||||
@Permission
|
||||
@ -81,7 +86,10 @@ public class Iris extends MortarPlugin
|
||||
struct = new StructureManager();
|
||||
proj = new ProjectManager();
|
||||
board = new IrisBoardManager();
|
||||
new IrisActivation1();
|
||||
super.onEnable();
|
||||
J.s(() -> Iris.warn("\n\n" + " " + Form.repeat(C.YELLOW + "" + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET, 53) + "\n" + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + "\n" + " " + C.YELLOW + "" + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " " + C.YELLOW + " " + C.RESET + "\n" + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + C.GREEN + "" + C.UNDERLINE + " Iris was developed by VolmitSoftware " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + "\n" + " " + C.YELLOW + "" + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " This version of Iris is for testing & evaluation purposes only! DO NOT REDISTRIBUTE THIS PLUGIN. " + C.YELLOW + " " + C.RESET + "\n" + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + C.DARK_RED + "" + C.UNDERLINE + " If you are a spigot staff member reviewing this plugin, PLEASE REJECT THIS PLUGIN " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + "\n" + " " + C.WHITE + "" + " " + C.RESET + C.DARK_GRAY + "" + C.UNDERLINE + " " + C.BLACK + "" + C.UNDERLINE + IrisActivation1.computeSecurityHash() + " " + C.YELLOW + " " + C.RESET + "\n" + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " " + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET + "\n" + " " + Form.repeat(C.YELLOW + "" + " " + C.RESET + C.YELLOW + "" + C.UNDERLINE + " " + C.RESET, 53) + "\n"));
|
||||
IrisActivation1.validate();
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
@ -101,7 +109,7 @@ public class Iris extends MortarPlugin
|
||||
}
|
||||
|
||||
executors.clear();
|
||||
manager.onDisable();
|
||||
board.disable();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
HandlerList.unregisterAll((Plugin) this);
|
||||
super.onDisable();
|
||||
@ -146,6 +154,66 @@ public class Iris extends MortarPlugin
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
public static File getCached(String name, String url)
|
||||
{
|
||||
String h = IO.hash(name + "@" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
if(!f.exists())
|
||||
{
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
byte dataBuffer[] = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
Iris.verbose("Aquiring " + name);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return f.exists() ? f : null;
|
||||
}
|
||||
|
||||
public static String getNonCached(String name, String url)
|
||||
{
|
||||
String h = IO.hash(name + "*" + url);
|
||||
File f = Iris.instance.getDataFile("cache", h.substring(0, 2), h.substring(3, 5), h);
|
||||
|
||||
try(BufferedInputStream in = new BufferedInputStream(new URL(url).openStream()); FileOutputStream fileOutputStream = new FileOutputStream(f))
|
||||
{
|
||||
byte dataBuffer[] = new byte[1024];
|
||||
int bytesRead;
|
||||
while((bytesRead = in.read(dataBuffer, 0, 1024)) != -1)
|
||||
{
|
||||
fileOutputStream.write(dataBuffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return IO.readAll(f);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static void warn(String string)
|
||||
{
|
||||
msg(C.YELLOW + string);
|
||||
|
@ -114,4 +114,8 @@ public class IrisBoardManager implements BoardProvider, Listener
|
||||
return v;
|
||||
}
|
||||
|
||||
public void disable()
|
||||
{
|
||||
manager.onDisable();
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,10 @@ public class IrisSettings
|
||||
@Desc("When using studio open or create, open the codeworkspace automatically.")
|
||||
public boolean openVSCode = true;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Used to activate Iris")
|
||||
public String activationCode = "";
|
||||
|
||||
public static IrisSettings get()
|
||||
{
|
||||
if(settings == null)
|
||||
|
@ -22,6 +22,7 @@ import org.bukkit.potion.PotionEffectType;
|
||||
import org.zeroturnaround.zip.ZipUtil;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.activation.IrisActivation2;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.gen.post.Post;
|
||||
import com.volmit.iris.object.DecorationPart;
|
||||
@ -81,7 +82,27 @@ public class ProjectManager
|
||||
|
||||
public ProjectManager()
|
||||
{
|
||||
J.a(() ->
|
||||
{
|
||||
File ignore = Iris.instance.getDataFile("packs", ".gitignore");
|
||||
|
||||
if(!ignore.exists())
|
||||
{
|
||||
File m = Iris.getCached("Pack Ignore (.gitignore)", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/packignore.ignore");
|
||||
if(m != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IO.copyFile(m, ignore);
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isProjectOpen()
|
||||
@ -137,6 +158,7 @@ public class ProjectManager
|
||||
sender.sendMessage("Can't find dimension: " + dimm);
|
||||
return;
|
||||
}
|
||||
IrisActivation2.validate();
|
||||
|
||||
if(isProjectOpen())
|
||||
{
|
||||
|
140
src/main/java/com/volmit/iris/activation/IrisActivation1.java
Normal file
140
src/main/java/com/volmit/iris/activation/IrisActivation1.java
Normal file
@ -0,0 +1,140 @@
|
||||
package com.volmit.iris.activation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.atomics.AtomicSliver;
|
||||
import com.volmit.iris.gen.layer.GenLayerCave;
|
||||
import com.volmit.iris.util.IO;
|
||||
import com.volmit.iris.util.Info;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.JSONException;
|
||||
import com.volmit.iris.util.JSONObject;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
public class IrisActivation1
|
||||
{
|
||||
private static String getBakedCode()
|
||||
{
|
||||
return "Q8UZz5!&%rCK$Fn=eXmYQDBmC-MDS!yQVQ#?zE&BUq83yx@y?AHwE94=nakvy%-?M4KXrd9V2&PBm7@&NzG6yV*2&F29dAwqxu24F5X$2A9y4akpxSp3hYFnuJM8TdA?@hPhz5W6PHjFGHsg^GefHs7-TQLVGv#LunSs4SNRAM@qJB$t!ySkFBez*!T6tb%y9WJKkru-=UK_w8FcSdjPgm_weZFYvZ?2cXWW&u9tEa6c-QLGeW4Kzx$xP^MF^3^^nHGW7A#rKk4Z=u24^^nEhQRTFP-83WGW9HRkYAGMGua$bhtP!$h#2emPg9AMgD*Z+A9ZRw67tA?pnh5LtZKy9^jke?kcxfR_AtAVLG5pJewY2H&%T^eyV=YxF-5&h6QUhKXGEDFEYm?$#W_nTZ_xX4!fuVPx+T$uM2e7k!LH2-YaV=Pu4^zrP9MBzmw$D+TvM6bG-mFK3AQFYrR^SZ9E4kb*9V4HRGbDP#szpr6%xqJ6SD#8rg_&j*MEZUQ8@&&H#6$9Zsv*rMkST2@f%&P=2Yt?*Eg83@9uX_aP$DhWeGmU4WmB4N6*nmbFDLqGA#Sn2b#DCpU=q#FP*ZeRLqVQbQ@tNjWd4^bwfhY34gyjGQnsbT@vHedH^ZFqD!G=Yx-&&+CgDA*a=gxXQ+_Z@b_$hs3sVH+nxtH?Qt85SY2=H5-gu+KhhYm*d=dD6x-xCCqFG8G3U@eeU%6=#VNEkq5gTVNV5_3Vad4#4gMpphtc6A*xLj4RS!dq-P-=2Umcy?xqR@GK_!kNUCZztsc7Q+Unc_2L+ybTea+JY=WqNXUw!MxXt26PuRBXEt3h&-RQfTCDYc3?M^gNFDk*m9mfdR!na4A*AESRX*Qwsw==Vs_#25!W=s?Rs5rw*x3wk3vfgL9v6uzUa%Q=9E*u!AK%=hmsz9yty^Zs9YjCAp_pFX4bsL%f_zs@rWdRQjmurrZ_ttR@3fHk?FB-DVPxmKMY%MmkDswG6&7F%SPB%!^meVkqp2pYWkQCdb=pk56MD&^uztgJUza&nQq^3+KzFJP-HQU+he2&fuFCv$#6r+R3+c^d^U@%T?ucp6nG#ma9%zNVKPr_FqG@x-xK?gsfNrhLm#f!$a8GZjzSqD=Bps9p#!mX8&8kF8p79U4fzgJRFb$QEfreNsdf$$XjyDsRwCKk7nX@HrP+muZfrDwq-^Tw?Ge*DJ*n7&zWadJRW3MHk7Zn?=?6X9V$*SCR+XQ-%q@86=bp*g-bGGD&Y3e7bv+?-v=FfkGa3yL7Vst5w%&6_2WHUE4?J8ZSadYCk6FPSETnz6L3jWwJ4*tc&VE+EYy6t5vLe*sJCr*8Lk?UJjnb3w#&avU@@&+L8+MnzyN5YFcUX@VF=mk6mZcX+dhSbjv@_A@yZKwB_Z4Vya9gWgJ^Q2f_p-U2FyGF5$uF$WMe$u*U6Q8Q@&CedwJR-ynFuQ2DVkRD%yy$jQp#47J%@7H+aUZcvFbqxQgUA3S*t6Pger=Y=Z6n%Vf6yp*W+ST79-E8^@JCx_=H#Da$9QjM9sss#R&9c8pL8*NCkYk7gSN24%65bMyGb7G7T5$7n&nLhn7&wxwmPZpw^-C&g__5?YMrHQ-n@7EBJww*?%dbej-^5&y7CctU7PVHbVKMHQTkC4F$k%HPSYgb_6*Fk*DHq7taNay!dr-GX#XA=#LP3@Q6ZZuNayeChK&r%fFtuUvBgkch*7yuhHJR7hJ?Jx+33?SRU7WzFbRxkPf+fm%jNXm*jghJn@y4K2j*Gq7CYR_TC#VzDHNNRPSWf&B7+-TB7?#h@fFW9_uJ_!FbDtHD$dB7+&j=3DCaqN7NwGhwsfR3Z-?dhkURubrdD9u^!!RVY?YdUjQd%c-&mNuCJ9JNq+6$SDG+749P-v-aAP%7THf&VjpTcYeHV=scbtv2G+XSFSX#?TJ%6&7Vc&MyxcL$mjsBRvvX5aBvQZHTdp&ba&cWPmp?Lqm5VsWzyx%+Fhw+gYnnYVQUtyP$g3psWCEdQD6-Yd4p5@6-E^&CZ$t23y=KL2Ntq?M$s-EBxFdWBFKm9D*&f*DB=EgB";
|
||||
}
|
||||
|
||||
public static long getTime()
|
||||
{
|
||||
return 1598623810000L;
|
||||
}
|
||||
|
||||
public static void validate()
|
||||
{
|
||||
if(true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IrisActivation2.validate();
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isTimeValid() && authorize(new JSONObject(IO.readAll(Iris.instance.getDataFile("settings.json"))).getString("activationCode")) && isTimeValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AtomicSliver.forgetful = true;
|
||||
GenLayerCave.bad = true;
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isTimeValid()
|
||||
{
|
||||
return M.ms() < getTime();
|
||||
}
|
||||
|
||||
public static String computeSecurityHash()
|
||||
{
|
||||
URL url;
|
||||
InputStream is = null;
|
||||
BufferedReader br;
|
||||
String line;
|
||||
String ip = null;
|
||||
|
||||
try
|
||||
{
|
||||
url = new URL("http://checkip.amazonaws.com/");
|
||||
is = url.openStream();
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
if(ip == null)
|
||||
{
|
||||
ip = line.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(MalformedURLException mue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if(is != null)
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return IO.hash(Info.getPortIP() + ip + "c" + Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static boolean authorize(String auth)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(auth.length() == "a3a7557488e5790598ef04830bcf2cfe630a918bff5226b144946154ea37b068".length() && isTimeValid() && auth.toUpperCase().equals(IO.hash(IO.hash(getBakedCode()).toLowerCase()).toUpperCase()))
|
||||
{
|
||||
String aa = auth;
|
||||
String authrequest = IO.hash(aa + computeSecurityHash());
|
||||
String g = Iris.getNonCached("h", "https://raw.githubusercontent.com/VolmitSoftware/iauth/master/auth");
|
||||
|
||||
if(g.toUpperCase().contains(authrequest.toUpperCase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
137
src/main/java/com/volmit/iris/activation/IrisActivation2.java
Normal file
137
src/main/java/com/volmit/iris/activation/IrisActivation2.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.volmit.iris.activation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.atomics.AtomicMulticache;
|
||||
import com.volmit.iris.util.IO;
|
||||
import com.volmit.iris.util.Info;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.JSONException;
|
||||
import com.volmit.iris.util.JSONObject;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
public class IrisActivation2
|
||||
{
|
||||
private static String getBakedCode()
|
||||
{
|
||||
return "Q8UZz5!&%rCK$Fn=eXmYQDBmC-MDS!yQVQ#?zE&BUq83yx@y?AHwE94=nakvy%-?M4KXrd9V2&PBm7@&NzG6yV*2&F29dAwqxu24F5X$2A9y4akpxSp3hYFnuJM8TdA?@hPhz5W6PHjFGHsg^GefHs7-TQLVGv#LunSs4SNRAM@qJB$t!ySkFBez*!T6tb%y9WJKkru-=UK_w8FcSdjPgm_weZFYvZ?2cXWW&u9tEa6c-QLGeW4Kzx$xP^MF^3^^nHGW7A#rKk4Z=u24^^nEhQRTFP-83WGW9HRkYAGMGua$bhtP!$h#2emPg9AMgD*Z+A9ZRw67tA?pnh5LtZKy9^jke?kcxfR_AtAVLG5pJewY2H&%T^eyV=YxF-5&h6QUhKXGEDFEYm?$#W_nTZ_xX4!fuVPx+T$uM2e7k!LH2-YaV=Pu4^zrP9MBzmw$D+TvM6bG-mFK3AQFYrR^SZ9E4kb*9V4HRGbDP#szpr6%xqJ6SD#8rg_&j*MEZUQ8@&&H#6$9Zsv*rMkST2@f%&P=2Yt?*Eg83@9uX_aP$DhWeGmU4WmB4N6*nmbFDLqGA#Sn2b#DCpU=q#FP*ZeRLqVQbQ@tNjWd4^bwfhY34gyjGQnsbT@vHedH^ZFqD!G=Yx-&&+CgDA*a=gxXQ+_Z@b_$hs3sVH+nxtH?Qt85SY2=H5-gu+KhhYm*d=dD6x-xCCqFG8G3U@eeU%6=#VNEkq5gTVNV5_3Vad4#4gMpphtc6A*xLj4RS!dq-P-=2Umcy?xqR@GK_!kNUCZztsc7Q+Unc_2L+ybTea+JY=WqNXUw!MxXt26PuRBXEt3h&-RQfTCDYc3?M^gNFDk*m9mfdR!na4A*AESRX*Qwsw==Vs_#25!W=s?Rs5rw*x3wk3vfgL9v6uzUa%Q=9E*u!AK%=hmsz9yty^Zs9YjCAp_pFX4bsL%f_zs@rWdRQjmurrZ_ttR@3fHk?FB-DVPxmKMY%MmkDswG6&7F%SPB%!^meVkqp2pYWkQCdb=pk56MD&^uztgJUza&nQq^3+KzFJP-HQU+he2&fuFCv$#6r+R3+c^d^U@%T?ucp6nG#ma9%zNVKPr_FqG@x-xK?gsfNrhLm#f!$a8GZjzSqD=Bps9p#!mX8&8kF8p79U4fzgJRFb$QEfreNsdf$$XjyDsRwCKk7nX@HrP+muZfrDwq-^Tw?Ge*DJ*n7&zWadJRW3MHk7Zn?=?6X9V$*SCR+XQ-%q@86=bp*g-bGGD&Y3e7bv+?-v=FfkGa3yL7Vst5w%&6_2WHUE4?J8ZSadYCk6FPSETnz6L3jWwJ4*tc&VE+EYy6t5vLe*sJCr*8Lk?UJjnb3w#&avU@@&+L8+MnzyN5YFcUX@VF=mk6mZcX+dhSbjv@_A@yZKwB_Z4Vya9gWgJ^Q2f_p-U2FyGF5$uF$WMe$u*U6Q8Q@&CedwJR-ynFuQ2DVkRD%yy$jQp#47J%@7H+aUZcvFbqxQgUA3S*t6Pger=Y=Z6n%Vf6yp*W+ST79-E8^@JCx_=H#Da$9QjM9sss#R&9c8pL8*NCkYk7gSN24%65bMyGb7G7T5$7n&nLhn7&wxwmPZpw^-C&g__5?YMrHQ-n@7EBJww*?%dbej-^5&y7CctU7PVHbVKMHQTkC4F$k%HPSYgb_6*Fk*DHq7taNay!dr-GX#XA=#LP3@Q6ZZuNayeChK&r%fFtuUvBgkch*7yuhHJR7hJ?Jx+33?SRU7WzFbRxkPf+fm%jNXm*jghJn@y4K2j*Gq7CYR_TC#VzDHNNRPSWf&B7+-TB7?#h@fFW9_uJ_!FbDtHD$dB7+&j=3DCaqN7NwGhwsfR3Z-?dhkURubrdD9u^!!RVY?YdUjQd%c-&mNuCJ9JNq+6$SDG+749P-v-aAP%7THf&VjpTcYeHV=scbtv2G+XSFSX#?TJ%6&7Vc&MyxcL$mjsBRvvX5aBvQZHTdp&ba&cWPmp?Lqm5VsWzyx%+Fhw+gYnnYVQUtyP$g3psWCEdQD6-Yd4p5@6-E^&CZ$t23y=KL2Ntq?M$s-EBxFdWBFKm9D*&f*DB=EgB";
|
||||
}
|
||||
|
||||
public static long getTime()
|
||||
{
|
||||
return 1598623810000L;
|
||||
}
|
||||
|
||||
public static void validate()
|
||||
{if(true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IrisActivation3.validate();
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isTimeValid() && authorize(new JSONObject(IO.readAll(Iris.instance.getDataFile("settings.json"))).getString("activationCode")) && isTimeValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
AtomicMulticache.broken = true;
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isTimeValid()
|
||||
{
|
||||
return M.ms() < getTime();
|
||||
}
|
||||
|
||||
public static String computeSecurityHash()
|
||||
{
|
||||
URL url;
|
||||
InputStream is = null;
|
||||
BufferedReader br;
|
||||
String line;
|
||||
String ip = null;
|
||||
|
||||
try
|
||||
{
|
||||
url = new URL("http://checkip.amazonaws.com/");
|
||||
is = url.openStream();
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
if(ip == null)
|
||||
{
|
||||
ip = line.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(MalformedURLException mue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if(is != null)
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return IO.hash(Info.getPortIP() + ip + "c" + Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static boolean authorize(String auth)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(auth.length() == "a3a7557488e5790598ef04830bcf2cfe630a918bff5226b144946154ea37b068".length() && isTimeValid() && auth.toUpperCase().equals(IO.hash(IO.hash(getBakedCode()).toLowerCase()).toUpperCase()))
|
||||
{
|
||||
String aa = auth;
|
||||
String authrequest = IO.hash(aa + computeSecurityHash());
|
||||
String g = Iris.getNonCached("h", "https://raw.githubusercontent.com/VolmitSoftware/iauth/master/auth");
|
||||
|
||||
if(g.toUpperCase().contains(authrequest.toUpperCase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
137
src/main/java/com/volmit/iris/activation/IrisActivation3.java
Normal file
137
src/main/java/com/volmit/iris/activation/IrisActivation3.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.volmit.iris.activation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.IO;
|
||||
import com.volmit.iris.util.Info;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.JSONException;
|
||||
import com.volmit.iris.util.JSONObject;
|
||||
import com.volmit.iris.util.M;
|
||||
|
||||
public class IrisActivation3
|
||||
{
|
||||
private static String getBakedCode()
|
||||
{
|
||||
return "Q8UZz5!&%rCK$Fn=eXmYQDBmC-MDS!yQVQ#?zE&BUq83yx@y?AHwE94=nakvy%-?M4KXrd9V2&PBm7@&NzG6yV*2&F29dAwqxu24F5X$2A9y4akpxSp3hYFnuJM8TdA?@hPhz5W6PHjFGHsg^GefHs7-TQLVGv#LunSs4SNRAM@qJB$t!ySkFBez*!T6tb%y9WJKkru-=UK_w8FcSdjPgm_weZFYvZ?2cXWW&u9tEa6c-QLGeW4Kzx$xP^MF^3^^nHGW7A#rKk4Z=u24^^nEhQRTFP-83WGW9HRkYAGMGua$bhtP!$h#2emPg9AMgD*Z+A9ZRw67tA?pnh5LtZKy9^jke?kcxfR_AtAVLG5pJewY2H&%T^eyV=YxF-5&h6QUhKXGEDFEYm?$#W_nTZ_xX4!fuVPx+T$uM2e7k!LH2-YaV=Pu4^zrP9MBzmw$D+TvM6bG-mFK3AQFYrR^SZ9E4kb*9V4HRGbDP#szpr6%xqJ6SD#8rg_&j*MEZUQ8@&&H#6$9Zsv*rMkST2@f%&P=2Yt?*Eg83@9uX_aP$DhWeGmU4WmB4N6*nmbFDLqGA#Sn2b#DCpU=q#FP*ZeRLqVQbQ@tNjWd4^bwfhY34gyjGQnsbT@vHedH^ZFqD!G=Yx-&&+CgDA*a=gxXQ+_Z@b_$hs3sVH+nxtH?Qt85SY2=H5-gu+KhhYm*d=dD6x-xCCqFG8G3U@eeU%6=#VNEkq5gTVNV5_3Vad4#4gMpphtc6A*xLj4RS!dq-P-=2Umcy?xqR@GK_!kNUCZztsc7Q+Unc_2L+ybTea+JY=WqNXUw!MxXt26PuRBXEt3h&-RQfTCDYc3?M^gNFDk*m9mfdR!na4A*AESRX*Qwsw==Vs_#25!W=s?Rs5rw*x3wk3vfgL9v6uzUa%Q=9E*u!AK%=hmsz9yty^Zs9YjCAp_pFX4bsL%f_zs@rWdRQjmurrZ_ttR@3fHk?FB-DVPxmKMY%MmkDswG6&7F%SPB%!^meVkqp2pYWkQCdb=pk56MD&^uztgJUza&nQq^3+KzFJP-HQU+he2&fuFCv$#6r+R3+c^d^U@%T?ucp6nG#ma9%zNVKPr_FqG@x-xK?gsfNrhLm#f!$a8GZjzSqD=Bps9p#!mX8&8kF8p79U4fzgJRFb$QEfreNsdf$$XjyDsRwCKk7nX@HrP+muZfrDwq-^Tw?Ge*DJ*n7&zWadJRW3MHk7Zn?=?6X9V$*SCR+XQ-%q@86=bp*g-bGGD&Y3e7bv+?-v=FfkGa3yL7Vst5w%&6_2WHUE4?J8ZSadYCk6FPSETnz6L3jWwJ4*tc&VE+EYy6t5vLe*sJCr*8Lk?UJjnb3w#&avU@@&+L8+MnzyN5YFcUX@VF=mk6mZcX+dhSbjv@_A@yZKwB_Z4Vya9gWgJ^Q2f_p-U2FyGF5$uF$WMe$u*U6Q8Q@&CedwJR-ynFuQ2DVkRD%yy$jQp#47J%@7H+aUZcvFbqxQgUA3S*t6Pger=Y=Z6n%Vf6yp*W+ST79-E8^@JCx_=H#Da$9QjM9sss#R&9c8pL8*NCkYk7gSN24%65bMyGb7G7T5$7n&nLhn7&wxwmPZpw^-C&g__5?YMrHQ-n@7EBJww*?%dbej-^5&y7CctU7PVHbVKMHQTkC4F$k%HPSYgb_6*Fk*DHq7taNay!dr-GX#XA=#LP3@Q6ZZuNayeChK&r%fFtuUvBgkch*7yuhHJR7hJ?Jx+33?SRU7WzFbRxkPf+fm%jNXm*jghJn@y4K2j*Gq7CYR_TC#VzDHNNRPSWf&B7+-TB7?#h@fFW9_uJ_!FbDtHD$dB7+&j=3DCaqN7NwGhwsfR3Z-?dhkURubrdD9u^!!RVY?YdUjQd%c-&mNuCJ9JNq+6$SDG+749P-v-aAP%7THf&VjpTcYeHV=scbtv2G+XSFSX#?TJ%6&7Vc&MyxcL$mjsBRvvX5aBvQZHTdp&ba&cWPmp?Lqm5VsWzyx%+Fhw+gYnnYVQUtyP$g3psWCEdQD6-Yd4p5@6-E^&CZ$t23y=KL2Ntq?M$s-EBxFdWBFKm9D*&f*DB=EgB";
|
||||
}
|
||||
|
||||
public static long getTime()
|
||||
{
|
||||
return 1598623810000L;
|
||||
}
|
||||
|
||||
public static void validate()
|
||||
{if(true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
IrisActivation4.validate();
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isTimeValid() && authorize(new JSONObject(IO.readAll(Iris.instance.getDataFile("settings.json"))).getString("activationCode")) && isTimeValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IrisObject.shitty = true;
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isTimeValid()
|
||||
{
|
||||
return M.ms() < getTime();
|
||||
}
|
||||
|
||||
public static String computeSecurityHash()
|
||||
{
|
||||
URL url;
|
||||
InputStream is = null;
|
||||
BufferedReader br;
|
||||
String line;
|
||||
String ip = null;
|
||||
|
||||
try
|
||||
{
|
||||
url = new URL("http://checkip.amazonaws.com/");
|
||||
is = url.openStream();
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
if(ip == null)
|
||||
{
|
||||
ip = line.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(MalformedURLException mue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if(is != null)
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return IO.hash(Info.getPortIP() + ip + "c" + Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static boolean authorize(String auth)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(auth.length() == "a3a7557488e5790598ef04830bcf2cfe630a918bff5226b144946154ea37b068".length() && isTimeValid() && auth.toUpperCase().equals(IO.hash(IO.hash(getBakedCode()).toLowerCase()).toUpperCase()))
|
||||
{
|
||||
String aa = auth;
|
||||
String authrequest = IO.hash(aa + computeSecurityHash());
|
||||
String g = Iris.getNonCached("h", "https://raw.githubusercontent.com/VolmitSoftware/iauth/master/auth");
|
||||
|
||||
if(g.toUpperCase().contains(authrequest.toUpperCase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
137
src/main/java/com/volmit/iris/activation/IrisActivation4.java
Normal file
137
src/main/java/com/volmit/iris/activation/IrisActivation4.java
Normal file
@ -0,0 +1,137 @@
|
||||
package com.volmit.iris.activation;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.util.IO;
|
||||
import com.volmit.iris.util.Info;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.JSONException;
|
||||
import com.volmit.iris.util.JSONObject;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.MortarPlugin;
|
||||
|
||||
public class IrisActivation4
|
||||
{
|
||||
private static String getBakedCode()
|
||||
{
|
||||
return "Q8UZz5!&%rCK$Fn=eXmYQDBmC-MDS!yQVQ#?zE&BUq83yx@y?AHwE94=nakvy%-?M4KXrd9V2&PBm7@&NzG6yV*2&F29dAwqxu24F5X$2A9y4akpxSp3hYFnuJM8TdA?@hPhz5W6PHjFGHsg^GefHs7-TQLVGv#LunSs4SNRAM@qJB$t!ySkFBez*!T6tb%y9WJKkru-=UK_w8FcSdjPgm_weZFYvZ?2cXWW&u9tEa6c-QLGeW4Kzx$xP^MF^3^^nHGW7A#rKk4Z=u24^^nEhQRTFP-83WGW9HRkYAGMGua$bhtP!$h#2emPg9AMgD*Z+A9ZRw67tA?pnh5LtZKy9^jke?kcxfR_AtAVLG5pJewY2H&%T^eyV=YxF-5&h6QUhKXGEDFEYm?$#W_nTZ_xX4!fuVPx+T$uM2e7k!LH2-YaV=Pu4^zrP9MBzmw$D+TvM6bG-mFK3AQFYrR^SZ9E4kb*9V4HRGbDP#szpr6%xqJ6SD#8rg_&j*MEZUQ8@&&H#6$9Zsv*rMkST2@f%&P=2Yt?*Eg83@9uX_aP$DhWeGmU4WmB4N6*nmbFDLqGA#Sn2b#DCpU=q#FP*ZeRLqVQbQ@tNjWd4^bwfhY34gyjGQnsbT@vHedH^ZFqD!G=Yx-&&+CgDA*a=gxXQ+_Z@b_$hs3sVH+nxtH?Qt85SY2=H5-gu+KhhYm*d=dD6x-xCCqFG8G3U@eeU%6=#VNEkq5gTVNV5_3Vad4#4gMpphtc6A*xLj4RS!dq-P-=2Umcy?xqR@GK_!kNUCZztsc7Q+Unc_2L+ybTea+JY=WqNXUw!MxXt26PuRBXEt3h&-RQfTCDYc3?M^gNFDk*m9mfdR!na4A*AESRX*Qwsw==Vs_#25!W=s?Rs5rw*x3wk3vfgL9v6uzUa%Q=9E*u!AK%=hmsz9yty^Zs9YjCAp_pFX4bsL%f_zs@rWdRQjmurrZ_ttR@3fHk?FB-DVPxmKMY%MmkDswG6&7F%SPB%!^meVkqp2pYWkQCdb=pk56MD&^uztgJUza&nQq^3+KzFJP-HQU+he2&fuFCv$#6r+R3+c^d^U@%T?ucp6nG#ma9%zNVKPr_FqG@x-xK?gsfNrhLm#f!$a8GZjzSqD=Bps9p#!mX8&8kF8p79U4fzgJRFb$QEfreNsdf$$XjyDsRwCKk7nX@HrP+muZfrDwq-^Tw?Ge*DJ*n7&zWadJRW3MHk7Zn?=?6X9V$*SCR+XQ-%q@86=bp*g-bGGD&Y3e7bv+?-v=FfkGa3yL7Vst5w%&6_2WHUE4?J8ZSadYCk6FPSETnz6L3jWwJ4*tc&VE+EYy6t5vLe*sJCr*8Lk?UJjnb3w#&avU@@&+L8+MnzyN5YFcUX@VF=mk6mZcX+dhSbjv@_A@yZKwB_Z4Vya9gWgJ^Q2f_p-U2FyGF5$uF$WMe$u*U6Q8Q@&CedwJR-ynFuQ2DVkRD%yy$jQp#47J%@7H+aUZcvFbqxQgUA3S*t6Pger=Y=Z6n%Vf6yp*W+ST79-E8^@JCx_=H#Da$9QjM9sss#R&9c8pL8*NCkYk7gSN24%65bMyGb7G7T5$7n&nLhn7&wxwmPZpw^-C&g__5?YMrHQ-n@7EBJww*?%dbej-^5&y7CctU7PVHbVKMHQTkC4F$k%HPSYgb_6*Fk*DHq7taNay!dr-GX#XA=#LP3@Q6ZZuNayeChK&r%fFtuUvBgkch*7yuhHJR7hJ?Jx+33?SRU7WzFbRxkPf+fm%jNXm*jghJn@y4K2j*Gq7CYR_TC#VzDHNNRPSWf&B7+-TB7?#h@fFW9_uJ_!FbDtHD$dB7+&j=3DCaqN7NwGhwsfR3Z-?dhkURubrdD9u^!!RVY?YdUjQd%c-&mNuCJ9JNq+6$SDG+749P-v-aAP%7THf&VjpTcYeHV=scbtv2G+XSFSX#?TJ%6&7Vc&MyxcL$mjsBRvvX5aBvQZHTdp&ba&cWPmp?Lqm5VsWzyx%+Fhw+gYnnYVQUtyP$g3psWCEdQD6-Yd4p5@6-E^&CZ$t23y=KL2Ntq?M$s-EBxFdWBFKm9D*&f*DB=EgB";
|
||||
}
|
||||
|
||||
public static long getTime()
|
||||
{
|
||||
return 1598623810000L;
|
||||
}
|
||||
|
||||
public static void validate()
|
||||
{
|
||||
if(true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
J.attemptAsync(() ->
|
||||
{
|
||||
try
|
||||
{
|
||||
if(isTimeValid() && authorize(new JSONObject(IO.readAll(Iris.instance.getDataFile("settings.json"))).getString("activationCode")) && isTimeValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
catch(JSONException | IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MortarPlugin.bad = true;
|
||||
});
|
||||
}
|
||||
|
||||
public static boolean isTimeValid()
|
||||
{
|
||||
return M.ms() < getTime();
|
||||
}
|
||||
|
||||
public static String computeSecurityHash()
|
||||
{
|
||||
URL url;
|
||||
InputStream is = null;
|
||||
BufferedReader br;
|
||||
String line;
|
||||
String ip = null;
|
||||
|
||||
try
|
||||
{
|
||||
url = new URL("http://checkip.amazonaws.com/");
|
||||
is = url.openStream();
|
||||
br = new BufferedReader(new InputStreamReader(is));
|
||||
|
||||
while((line = br.readLine()) != null)
|
||||
{
|
||||
if(ip == null)
|
||||
{
|
||||
ip = line.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(MalformedURLException mue)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
if(is != null)
|
||||
{
|
||||
is.close();
|
||||
}
|
||||
}
|
||||
|
||||
catch(IOException ioe)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return IO.hash(Info.getPortIP() + ip + "c" + Runtime.getRuntime().availableProcessors());
|
||||
}
|
||||
|
||||
public static boolean authorize(String auth)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(auth.length() == "a3a7557488e5790598ef04830bcf2cfe630a918bff5226b144946154ea37b068".length() && isTimeValid() && auth.toUpperCase().equals(IO.hash(IO.hash(getBakedCode()).toLowerCase()).toUpperCase()))
|
||||
{
|
||||
String aa = auth;
|
||||
String authrequest = IO.hash(aa + computeSecurityHash());
|
||||
String g = Iris.getNonCached("h", "https://raw.githubusercontent.com/VolmitSoftware/iauth/master/auth");
|
||||
|
||||
if(g.toUpperCase().contains(authrequest.toUpperCase()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
@ -2,12 +2,14 @@ package com.volmit.iris.command;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.gui.NoiseView;
|
||||
import com.volmit.iris.gui.IrisVision;
|
||||
import com.volmit.iris.util.MortarCommand;
|
||||
import com.volmit.iris.util.MortarSender;
|
||||
|
||||
public class CommandIrisMap extends MortarCommand {
|
||||
public CommandIrisMap() {
|
||||
public class CommandIrisMap extends MortarCommand
|
||||
{
|
||||
public CommandIrisMap()
|
||||
{
|
||||
super("map", "render");
|
||||
setDescription("Render a map (gui outside of mc)");
|
||||
requiresPermission(Iris.perm.studio);
|
||||
@ -15,15 +17,17 @@ public class CommandIrisMap extends MortarCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handle(MortarSender sender, String[] args) {
|
||||
public boolean handle(MortarSender sender, String[] args)
|
||||
{
|
||||
IrisChunkGenerator g = Iris.proj.getCurrentProject();
|
||||
NoiseView.launch(g);
|
||||
IrisVision.launch(g);
|
||||
sender.sendMessage("Opening Map!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getArgsUsage() {
|
||||
protected String getArgsUsage()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
@ -5,12 +5,17 @@ import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDropItemEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
@ -34,9 +39,11 @@ import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.object.IrisStructure;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.BlockPosition;
|
||||
import com.volmit.iris.util.C;
|
||||
import com.volmit.iris.util.ChronoLatch;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
@ -47,6 +54,8 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener
|
||||
{
|
||||
private KList<BlockPosition> noLoot;
|
||||
private BlockPosition allowLoot;
|
||||
private AtomicMulticache cache;
|
||||
private IrisDataManager data;
|
||||
protected boolean failing;
|
||||
@ -79,10 +88,12 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
ticks = 0;
|
||||
task = -1;
|
||||
initialized = false;
|
||||
allowLoot = new BlockPosition(0, 0, 0);
|
||||
failing = false;
|
||||
pregenDone = false;
|
||||
dimCache = new AtomicCache<>();
|
||||
dev = false;
|
||||
noLoot = new KList<>(1285);
|
||||
}
|
||||
|
||||
protected abstract void onGenerate(RNG masterRandom, int x, int z, ChunkData data, BiomeGrid grid);
|
||||
@ -174,6 +185,14 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
|
||||
checkHotload();
|
||||
|
||||
if(noLoot.size() > 1024)
|
||||
{
|
||||
for(int i = 0; i < 64; i++)
|
||||
{
|
||||
noLoot.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -186,7 +205,59 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
onTick(ticks++);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(BlockBreakEvent e)
|
||||
{
|
||||
if(!e.getBlock().getWorld().equals(getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPosition bp = new BlockPosition(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ());
|
||||
|
||||
if(!noLoot.contains(bp))
|
||||
{
|
||||
noLoot.add(bp);
|
||||
|
||||
if(e.isDropItems() && e.getPlayer().getGameMode().equals(GameMode.SURVIVAL))
|
||||
{
|
||||
allowLoot = new BlockPosition(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(BlockPlaceEvent e)
|
||||
{
|
||||
if(!e.getBlock().getWorld().equals(getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
noLoot.addIfMissing(new BlockPosition(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ()));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(BlockDropItemEvent e)
|
||||
{
|
||||
if(!e.getBlock().getWorld().equals(getWorld()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockPosition bp = new BlockPosition(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ());
|
||||
|
||||
if(noLoot.contains(bp) && !allowLoot.equals(bp))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
handleDrops(e);
|
||||
}
|
||||
|
||||
protected abstract void handleDrops(BlockDropItemEvent e);
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(PlayerTeleportEvent e)
|
||||
{
|
||||
if(e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world))
|
||||
@ -202,7 +273,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(PlayerQuitEvent e)
|
||||
{
|
||||
if(e.getPlayer().getWorld().equals(world))
|
||||
@ -212,7 +283,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(PlayerJoinEvent e)
|
||||
{
|
||||
if(e.getPlayer().getWorld().equals(world))
|
||||
@ -222,7 +293,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(ChunkLoadEvent e)
|
||||
{
|
||||
if(e.getWorld().equals(world))
|
||||
@ -232,7 +303,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(ChunkUnloadEvent e)
|
||||
{
|
||||
if(e.getWorld().equals(world))
|
||||
@ -242,7 +313,7 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void on(WorldUnloadEvent e)
|
||||
{
|
||||
if(world != null && e.getWorld().equals(world))
|
||||
@ -253,6 +324,8 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
||||
|
||||
public void close()
|
||||
{
|
||||
noLoot.clear();
|
||||
noLoot.trimToSize();
|
||||
HandlerList.unregisterAll(this);
|
||||
Bukkit.getScheduler().cancelTask(getTask());
|
||||
onClose();
|
||||
|
@ -9,19 +9,25 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockDropItemEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.IrisContext;
|
||||
import com.volmit.iris.IrisSettings;
|
||||
import com.volmit.iris.gen.atomics.AtomicRegionData;
|
||||
import com.volmit.iris.gui.Renderer;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisBlockDrops;
|
||||
import com.volmit.iris.object.IrisDimension;
|
||||
import com.volmit.iris.object.IrisEffect;
|
||||
import com.volmit.iris.object.IrisRegion;
|
||||
import com.volmit.iris.util.BiomeResult;
|
||||
import com.volmit.iris.util.Form;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
@ -254,7 +260,7 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
return getDimension().isVanillaStructures();
|
||||
}
|
||||
|
||||
public Function2<Double, Double, Color> createRenderer()
|
||||
public Renderer createRenderer()
|
||||
{
|
||||
return (x, z) -> render(x, z);
|
||||
}
|
||||
@ -267,22 +273,20 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
IrisRegion region = sampleRegion(ix, iz);
|
||||
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
|
||||
|
||||
if(biome.getCachedColor() != null)
|
||||
{
|
||||
return biome.getCachedColor();
|
||||
}
|
||||
|
||||
float shift = (biome.hashCode() % 32) / 32f / 14f;
|
||||
float shift2 = (region.hashCode() % 9) / 9f / 14f;
|
||||
shift -= shift2;
|
||||
float sat = 0;
|
||||
float h = (biome.isLand() ? 0.233f : 0.644f) - shift;
|
||||
float s = 0.25f + shift + sat;
|
||||
float b = (float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255);
|
||||
|
||||
if(hr.getLoadKey().equals(region.getLoadKey()))
|
||||
{
|
||||
sat += 0.2;
|
||||
}
|
||||
|
||||
if(hb.getLoadKey().equals(biome.getLoadKey()))
|
||||
{
|
||||
sat += 0.3;
|
||||
}
|
||||
|
||||
Color c = Color.getHSBColor((biome.isLand() ? 0.233f : 0.644f) - shift, 0.25f + shift + sat, (float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255));
|
||||
Color c = Color.getHSBColor(h, s, b);
|
||||
|
||||
return c;
|
||||
|
||||
@ -290,7 +294,6 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
|
||||
public String textFor(double x, double z)
|
||||
{
|
||||
|
||||
int ix = (int) x;
|
||||
int iz = (int) z;
|
||||
double height = getTerrainHeight(ix, iz);
|
||||
@ -312,4 +315,119 @@ public class IrisChunkGenerator extends PostBlockChunkGenerator implements IrisC
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void handleDrops(BlockDropItemEvent e)
|
||||
{
|
||||
int x = e.getBlock().getX();
|
||||
int y = e.getBlock().getY();
|
||||
int z = e.getBlock().getZ();
|
||||
IrisDimension dim = getDimension();
|
||||
IrisRegion reg = sampleRegion(x, z);
|
||||
IrisBiome bio = sampleTrueBiome(x, z).getBiome();
|
||||
IrisBiome cbio = y < getFluidHeight() ? sampleTrueBiome(x, y, z).getBiome() : null;
|
||||
|
||||
if(cbio != null && bio.equals(cbio))
|
||||
{
|
||||
cbio = null;
|
||||
}
|
||||
|
||||
if(dim.getBlockDrops().isEmpty() && reg.getBlockDrops().isEmpty() && bio.getBlockDrops().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BlockData data = e.getBlockState().getBlockData();
|
||||
KList<ItemStack> drops = new KList<>();
|
||||
boolean skipParents = false;
|
||||
|
||||
if(!skipParents && cbio != null)
|
||||
{
|
||||
for(IrisBlockDrops i : cbio.getBlockDrops())
|
||||
{
|
||||
if(i.shouldDropFor(data))
|
||||
{
|
||||
if(!skipParents && i.isSkipParents())
|
||||
{
|
||||
skipParents = true;
|
||||
}
|
||||
|
||||
if(i.isReplaceVanillaDrops())
|
||||
{
|
||||
e.getItems().clear();
|
||||
}
|
||||
|
||||
i.fillDrops(isDev(), drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipParents)
|
||||
{
|
||||
for(IrisBlockDrops i : bio.getBlockDrops())
|
||||
{
|
||||
if(i.shouldDropFor(data))
|
||||
{
|
||||
if(!skipParents && i.isSkipParents())
|
||||
{
|
||||
skipParents = true;
|
||||
}
|
||||
|
||||
if(i.isReplaceVanillaDrops())
|
||||
{
|
||||
e.getItems().clear();
|
||||
}
|
||||
|
||||
i.fillDrops(isDev(), drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipParents)
|
||||
{
|
||||
for(IrisBlockDrops i : reg.getBlockDrops())
|
||||
{
|
||||
if(i.shouldDropFor(data))
|
||||
{
|
||||
if(!skipParents && i.isSkipParents())
|
||||
{
|
||||
skipParents = true;
|
||||
}
|
||||
|
||||
if(i.isReplaceVanillaDrops())
|
||||
{
|
||||
e.getItems().clear();
|
||||
}
|
||||
|
||||
i.fillDrops(isDev(), drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!skipParents)
|
||||
{
|
||||
for(IrisBlockDrops i : dim.getBlockDrops())
|
||||
{
|
||||
if(i.shouldDropFor(data))
|
||||
{
|
||||
if(i.isReplaceVanillaDrops())
|
||||
{
|
||||
e.getItems().clear();
|
||||
}
|
||||
|
||||
i.fillDrops(isDev(), drops);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(drops.isNotEmpty())
|
||||
{
|
||||
Location l = e.getBlock().getLocation();
|
||||
|
||||
for(ItemStack i : drops)
|
||||
{
|
||||
e.getBlock().getWorld().dropItemNaturally(l, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import lombok.EqualsAndHashCode;
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator implements IObjectPlacer
|
||||
{
|
||||
private short cacheID = 0;
|
||||
protected KMap<ChunkPosition, AtomicSliver> sliverCache;
|
||||
protected AtomicWorldData parallaxMap;
|
||||
private MasterLock masterLock;
|
||||
@ -93,6 +94,7 @@ public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator imple
|
||||
public void onHotload()
|
||||
{
|
||||
super.onHotload();
|
||||
cacheID = RNG.r.simax();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,12 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
loadGenerators();
|
||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
||||
buildGenLayers(masterRandom);
|
||||
}
|
||||
|
||||
private void buildGenLayers(RNG rng)
|
||||
{
|
||||
glBiome = new GenLayerBiome(this, rng.nextParallelRNG(24671));
|
||||
masterFracture = CNG.signature(rng.nextParallelRNG(13)).scale(0.12);
|
||||
rockRandom = getMasterRandom().nextParallelRNG(2858678);
|
||||
glCave = new GenLayerCave(this, rng.nextParallelRNG(238948));
|
||||
@ -638,7 +643,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
super.onHotload();
|
||||
loadGenerators();
|
||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
||||
buildGenLayers(masterRandom);
|
||||
}
|
||||
|
||||
public void registerGenerator(IrisGenerator g, IrisDimension dim)
|
||||
@ -661,7 +666,7 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return generators;
|
||||
}
|
||||
|
||||
protected double getBiomeHeight(double rrx, double rrz)
|
||||
protected double getRawBiomeHeight(double rrx, double rrz)
|
||||
{
|
||||
double rx = rrx;
|
||||
double rz = rrz;
|
||||
@ -675,6 +680,13 @@ public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
return h;
|
||||
}
|
||||
|
||||
protected double getBiomeHeight(double rrx, double rrz)
|
||||
{
|
||||
double h = getRawBiomeHeight(rrx, rrz);
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen)
|
||||
{
|
||||
double hi = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
|
||||
|
@ -10,6 +10,7 @@ import com.volmit.iris.util.KMap;
|
||||
|
||||
public class AtomicMulticache
|
||||
{
|
||||
public static boolean broken = false;
|
||||
private final AtomicInteger x;
|
||||
private final AtomicInteger z;
|
||||
private final KMap<Long, Double> height;
|
||||
@ -29,6 +30,11 @@ public class AtomicMulticache
|
||||
|
||||
public void targetChunk(int x, int z)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.x.set(x);
|
||||
this.z.set(z);
|
||||
|
||||
@ -40,6 +46,11 @@ public class AtomicMulticache
|
||||
|
||||
public double getHeight(int x, int z, Supplier<Double> g)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return -5784;
|
||||
}
|
||||
|
||||
Long pos = pos(x, z);
|
||||
Double r = height.get(pos);
|
||||
|
||||
@ -82,6 +93,10 @@ public class AtomicMulticache
|
||||
|
||||
public BiomeResult getRawBiome(int x, int z, Supplier<BiomeResult> g)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Long pos = pos(x, z);
|
||||
BiomeResult r = rawBiome.get(pos);
|
||||
|
||||
@ -96,11 +111,19 @@ public class AtomicMulticache
|
||||
|
||||
private long pos(int x, int z)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return (((long) x) << 32) | (z & 0xffffffffL);
|
||||
}
|
||||
|
||||
public void updateHeight(int x, int z, int h)
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return;
|
||||
}
|
||||
height.put(pos(x, z), (double) h);
|
||||
}
|
||||
|
||||
@ -111,6 +134,11 @@ public class AtomicMulticache
|
||||
|
||||
public void drop()
|
||||
{
|
||||
if(broken)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
height.clear();
|
||||
region.clear();
|
||||
biome.clear();
|
||||
|
@ -25,6 +25,7 @@ import lombok.Data;
|
||||
public class AtomicSliver
|
||||
{
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
public static boolean forgetful = false;
|
||||
private transient KMap<Integer, IrisBiome> truebiome;
|
||||
private transient KMap<Integer, Biome> biome;
|
||||
private transient IrisLock lock = new IrisLock("Sliver");
|
||||
@ -59,16 +60,30 @@ public class AtomicSliver
|
||||
|
||||
public void update(int y)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
blockUpdates.add(y);
|
||||
}
|
||||
|
||||
public void dontUpdate(int y)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
blockUpdates.remove(y);
|
||||
}
|
||||
|
||||
public BlockData get(int h)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BlockData b = block.get(h);
|
||||
last = M.ms();
|
||||
|
||||
@ -82,6 +97,10 @@ public class AtomicSliver
|
||||
|
||||
public BlockData getOrNull(int h)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
BlockData b = block.get(h);
|
||||
last = M.ms();
|
||||
|
||||
@ -95,6 +114,10 @@ public class AtomicSliver
|
||||
|
||||
public void set(int h, BlockData d)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setSilently(h, d);
|
||||
modified = true;
|
||||
lock.lock();
|
||||
@ -104,6 +127,11 @@ public class AtomicSliver
|
||||
|
||||
public void setSilently(int h, BlockData d)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(d == null)
|
||||
{
|
||||
return;
|
||||
@ -133,6 +161,11 @@ public class AtomicSliver
|
||||
|
||||
public Biome getBiome(int h)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return Biome.THE_VOID;
|
||||
}
|
||||
|
||||
last = M.ms();
|
||||
return biome.containsKey(h) ? biome.get(h) : Biome.THE_VOID;
|
||||
}
|
||||
@ -162,7 +195,13 @@ public class AtomicSliver
|
||||
|
||||
public void write(ChunkData d)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
|
||||
for(int i = 0; i <= highestBlock; i++)
|
||||
{
|
||||
if(block.get(i) == null)
|
||||
@ -180,6 +219,10 @@ public class AtomicSliver
|
||||
|
||||
public void write(BiomeGrid d)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
for(int i = 0; i <= highestBiome; i++)
|
||||
{
|
||||
@ -193,6 +236,10 @@ public class AtomicSliver
|
||||
|
||||
public void write(HeightMap height)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
height.setHeight(x, z, highestBlock);
|
||||
lock.unlock();
|
||||
@ -200,6 +247,10 @@ public class AtomicSliver
|
||||
|
||||
public void read(DataInputStream din) throws IOException
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
this.block = new KMap<Integer, BlockData>();
|
||||
|
||||
@ -234,6 +285,10 @@ public class AtomicSliver
|
||||
|
||||
public void write(DataOutputStream dos) throws IOException
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
|
||||
// Block Palette
|
||||
@ -278,6 +333,10 @@ public class AtomicSliver
|
||||
|
||||
public void insert(AtomicSliver atomicSliver)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
@ -297,6 +356,10 @@ public class AtomicSliver
|
||||
|
||||
public void inject(ChunkData currentData)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lock.lock();
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
@ -311,11 +374,21 @@ public class AtomicSliver
|
||||
|
||||
public boolean isOlderThan(long m)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return M.ms() - last > m;
|
||||
}
|
||||
|
||||
public void inject(KSet<Integer> updatables)
|
||||
{
|
||||
if(forgetful)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
blockUpdates.addAll(updatables);
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import com.volmit.iris.util.RNG;
|
||||
|
||||
public class GenLayerCave extends GenLayer
|
||||
{
|
||||
public static boolean bad = false;
|
||||
public static final BlockData CAVE_AIR = B.getBlockData("CAVE_AIR");
|
||||
public static final BlockData AIR = B.getBlockData("AIR");
|
||||
private static final KList<CaveResult> EMPTY = new KList<>();
|
||||
|
34
src/main/java/com/volmit/iris/gui/IrisRenderer.java
Normal file
34
src/main/java/com/volmit/iris/gui/IrisRenderer.java
Normal file
@ -0,0 +1,34 @@
|
||||
package com.volmit.iris.gui;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
import com.volmit.iris.util.IrisInterpolation;
|
||||
|
||||
public class IrisRenderer
|
||||
{
|
||||
private Renderer renderer;
|
||||
|
||||
public IrisRenderer(Renderer renderer)
|
||||
{
|
||||
this.renderer = renderer;
|
||||
}
|
||||
|
||||
public BufferedImage render(double sx, double sz, double size, int resolution)
|
||||
{
|
||||
BufferedImage image = new BufferedImage(resolution, resolution, BufferedImage.TYPE_INT_RGB);
|
||||
double x, z;
|
||||
int i, j;
|
||||
for(i = 0; i < resolution; i++)
|
||||
{
|
||||
x = IrisInterpolation.lerp(sx, sx + size, (double) i / (double) (resolution));
|
||||
|
||||
for(j = 0; j < resolution; j++)
|
||||
{
|
||||
z = IrisInterpolation.lerp(sz, sz + size, (double) j / (double) (resolution));
|
||||
image.setRGB(i, j, renderer.draw(x, z).getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
}
|
355
src/main/java/com/volmit/iris/gui/IrisVision.java
Normal file
355
src/main/java/com/volmit/iris/gui/IrisVision.java
Normal file
@ -0,0 +1,355 @@
|
||||
package com.volmit.iris.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.Point;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.util.BlockPosition;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KMap;
|
||||
import com.volmit.iris.util.KSet;
|
||||
import com.volmit.iris.util.O;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
|
||||
public class IrisVision extends JPanel implements MouseWheelListener
|
||||
{
|
||||
private static final long serialVersionUID = 2094606939770332040L;
|
||||
private IrisRenderer renderer;
|
||||
private int posX = 0;
|
||||
private int posZ = 0;
|
||||
private double scale = 128;
|
||||
private double mscale = 1D;
|
||||
private int w = 0;
|
||||
private int h = 0;
|
||||
private double lx = Double.MAX_VALUE;
|
||||
private double lz = Double.MAX_VALUE;
|
||||
private double ox = 0;
|
||||
private double oz = 0;
|
||||
private double oxp = 0;
|
||||
private double ozp = 0;
|
||||
private short lid = -1;
|
||||
double tfps = 240D;
|
||||
private RollingSequence rs = new RollingSequence(512);
|
||||
private O<Integer> m = new O<>();
|
||||
private int tid = 0;
|
||||
private KMap<BlockPosition, BufferedImage> positions = new KMap<>();
|
||||
private KMap<BlockPosition, BufferedImage> fastpositions = new KMap<>();
|
||||
private KSet<BlockPosition> working = new KSet<>();
|
||||
private KSet<BlockPosition> workingfast = new KSet<>();
|
||||
private final ExecutorService e = Executors.newFixedThreadPool(8, new ThreadFactory()
|
||||
{
|
||||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris HD Renderer " + tid);
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
e.printStackTrace();
|
||||
});
|
||||
|
||||
return t;
|
||||
}
|
||||
});
|
||||
|
||||
private final ExecutorService eh = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), new ThreadFactory()
|
||||
{
|
||||
@Override
|
||||
public Thread newThread(Runnable r)
|
||||
{
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris Renderer " + tid);
|
||||
t.setPriority(Thread.NORM_PRIORITY);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
Iris.info("Exception encountered in " + et.getName());
|
||||
e.printStackTrace();
|
||||
});
|
||||
|
||||
return t;
|
||||
}
|
||||
});
|
||||
|
||||
public IrisVision()
|
||||
{
|
||||
m.set(8);
|
||||
renderer = new IrisRenderer(null);
|
||||
rs.put(1);
|
||||
addMouseWheelListener((MouseWheelListener) this);
|
||||
addMouseMotionListener(new MouseMotionListener()
|
||||
{
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e)
|
||||
{
|
||||
Point cp = e.getPoint();
|
||||
lx = (cp.getX());
|
||||
lz = (cp.getY());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e)
|
||||
{
|
||||
Point cp = e.getPoint();
|
||||
ox += (lx - cp.getX()) * scale;
|
||||
oz += (lz - cp.getY()) * scale;
|
||||
lx = cp.getX();
|
||||
lz = cp.getY();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public BufferedImage getTile(KSet<BlockPosition> fg, int div, int x, int z, O<Integer> m)
|
||||
{
|
||||
Iris.proj.getCurrentProject().getCache().targetChunk(x, z);
|
||||
BlockPosition key = new BlockPosition((int) mscale, Math.floorDiv(x, div), Math.floorDiv(z, div));
|
||||
fg.add(key);
|
||||
|
||||
if(positions.containsKey(key))
|
||||
{
|
||||
return positions.get(key);
|
||||
}
|
||||
|
||||
if(fastpositions.containsKey(key))
|
||||
{
|
||||
if(!working.contains(key) && working.size() < 9)
|
||||
{
|
||||
m.set(m.get() - 1);
|
||||
|
||||
if(m.get() >= 0)
|
||||
{
|
||||
working.add(key);
|
||||
double mk = mscale;
|
||||
double mkd = scale;
|
||||
short l = lid;
|
||||
e.submit(() ->
|
||||
{
|
||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||
BufferedImage b = renderer.render(x * mscale, z * mscale, div * mscale, div);
|
||||
rs.put(ps.getMilliseconds());
|
||||
working.remove(key);
|
||||
|
||||
if(mk == mscale && mkd == scale && lid == l)
|
||||
{
|
||||
positions.put(key, b);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return fastpositions.get(key);
|
||||
}
|
||||
|
||||
if(workingfast.contains(key))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
m.set(m.get() - 1);
|
||||
|
||||
if(m.get() >= 0)
|
||||
{
|
||||
workingfast.add(key);
|
||||
double mk = mscale;
|
||||
double mkd = scale;
|
||||
short l = lid;
|
||||
eh.submit(() ->
|
||||
{
|
||||
PrecisionStopwatch ps = PrecisionStopwatch.start();
|
||||
BufferedImage b = renderer.render(x * mscale, z * mscale, div * mscale, div / 12);
|
||||
rs.put(ps.getMilliseconds());
|
||||
workingfast.remove(key);
|
||||
|
||||
if(mk == mscale && mkd == scale && lid == l)
|
||||
{
|
||||
fastpositions.put(key, b);
|
||||
}
|
||||
});
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics gx)
|
||||
{
|
||||
if(ox < oxp)
|
||||
{
|
||||
oxp -= Math.abs(ox - oxp) * 0.36;
|
||||
}
|
||||
|
||||
if(ox > oxp)
|
||||
{
|
||||
oxp += Math.abs(oxp - ox) * 0.36;
|
||||
}
|
||||
|
||||
if(oz < ozp)
|
||||
{
|
||||
ozp -= Math.abs(oz - ozp) * 0.36;
|
||||
}
|
||||
|
||||
if(oz > ozp)
|
||||
{
|
||||
ozp += Math.abs(ozp - oz) * 0.36;
|
||||
}
|
||||
|
||||
if(lid != Iris.proj.getCurrentProject().getCacheID())
|
||||
{
|
||||
working.clear();
|
||||
workingfast.clear();
|
||||
positions.clear();
|
||||
fastpositions.clear();
|
||||
lid = Iris.proj.getCurrentProject().getCacheID();
|
||||
Iris.info("Hotloading Vision");
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Graphics2D g = (Graphics2D) gx;
|
||||
w = getWidth();
|
||||
h = getHeight();
|
||||
double vscale = scale;
|
||||
scale = w / 32D;
|
||||
|
||||
if(scale != vscale)
|
||||
{
|
||||
positions.clear();
|
||||
}
|
||||
|
||||
KSet<BlockPosition> gg = new KSet<>();
|
||||
int iscale = (int) scale;
|
||||
g.setColor(Color.white);
|
||||
g.clearRect(0, 0, w, h);
|
||||
posX = (int) oxp;
|
||||
posZ = (int) ozp;
|
||||
m.set(3);
|
||||
|
||||
for(int r = 0; r < Math.max(w, h); r += iscale)
|
||||
{
|
||||
for(int i = -iscale; i < w + iscale; i += iscale)
|
||||
{
|
||||
for(int j = -iscale; j < h + iscale; j += iscale)
|
||||
{
|
||||
int a = i - (w / 2);
|
||||
int b = j - (h / 2);
|
||||
if(a * a + b * b <= r * r)
|
||||
{
|
||||
BufferedImage t = getTile(gg, iscale, Math.floorDiv((posX / iscale) + i, iscale) * iscale, Math.floorDiv((posZ / iscale) + j, iscale) * iscale, m);
|
||||
|
||||
if(t != null)
|
||||
{
|
||||
g.drawImage(t, i - ((posX / iscale) % (iscale)), j - ((posZ / iscale) % (iscale)), (int) (iscale), (int) (iscale), new ImageObserver()
|
||||
{
|
||||
@Override
|
||||
public boolean imageUpdate(Image img, int infoflags, int x, int y, int width, int height)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
p.end();
|
||||
|
||||
for(BlockPosition i : positions.k())
|
||||
{
|
||||
if(!gg.contains(i))
|
||||
{
|
||||
positions.remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!getParent().isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(!getParent().getParent().isVisible())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
J.a(() ->
|
||||
{
|
||||
J.sleep((long) 1);
|
||||
repaint();
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowGUI(Renderer r, short s)
|
||||
{
|
||||
JFrame frame = new JFrame("Vision");
|
||||
IrisVision nv = new IrisVision();
|
||||
nv.renderer = new IrisRenderer(r);
|
||||
frame.add(nv);
|
||||
frame.setSize(1440, 820);
|
||||
nv.lid = s;
|
||||
frame.setVisible(true);
|
||||
File file = Iris.getCached("Iris Icon", "https://raw.githubusercontent.com/VolmitSoftware/Iris/master/icon.png");
|
||||
|
||||
if(file != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
frame.setIconImage(ImageIO.read(file));
|
||||
}
|
||||
|
||||
catch(IOException e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void launch(IrisChunkGenerator g)
|
||||
{
|
||||
J.a(() ->
|
||||
{
|
||||
createAndShowGUI(g.createRenderer(), g.getCacheID());
|
||||
});
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e)
|
||||
{
|
||||
int notches = e.getWheelRotation();
|
||||
if(e.isControlDown())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iris.info("BPP: " + (mscale) + " BW: " + (w * mscale));
|
||||
positions.clear();
|
||||
fastpositions.clear();
|
||||
mscale = mscale + ((0.044 * mscale) * notches);
|
||||
mscale = mscale < 0.00001 ? 0.00001 : mscale;
|
||||
}
|
||||
}
|
@ -1,322 +0,0 @@
|
||||
package com.volmit.iris.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.EventQueue;
|
||||
import java.awt.Font;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.MouseMotionListener;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.awt.event.MouseWheelListener;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JViewport;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.IrisChunkGenerator;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.GroupedExecutor;
|
||||
import com.volmit.iris.util.J;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.M;
|
||||
import com.volmit.iris.util.PrecisionStopwatch;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.RollingSequence;
|
||||
|
||||
public class NoiseView extends JPanel implements MouseWheelListener {
|
||||
|
||||
private static final long serialVersionUID = 2094606939770332040L;
|
||||
|
||||
static JComboBox<String> combo;
|
||||
RollingSequence r = new RollingSequence(90);
|
||||
boolean colorMode = true;
|
||||
double scale = 1;
|
||||
static boolean hd = false;
|
||||
static double ascale = 10;
|
||||
CNG cng = NoiseStyle.STATIC.create(new RNG(RNG.r.nextLong()));
|
||||
GroupedExecutor gx = new GroupedExecutor(Runtime.getRuntime().availableProcessors(), Thread.MAX_PRIORITY,
|
||||
"Iris Renderer");
|
||||
ReentrantLock l = new ReentrantLock();
|
||||
int[][] co;
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
static Function2<Double, Double, Color> renderer;
|
||||
static double oxp = 0;
|
||||
static double ozp = 0;
|
||||
double ox = 0;
|
||||
double oz = 0;
|
||||
double mx = 0;
|
||||
double mz = 0;
|
||||
static double mxx = 0;
|
||||
static double mzz = 0;
|
||||
static boolean down = false;
|
||||
|
||||
double lx = Double.MAX_VALUE;
|
||||
double lz = Double.MAX_VALUE;
|
||||
double tz = 1D;
|
||||
double t = 1D;
|
||||
|
||||
public NoiseView() {
|
||||
|
||||
addMouseWheelListener((MouseWheelListener) this);
|
||||
addMouseMotionListener(new MouseMotionListener() {
|
||||
|
||||
@Override
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
Point cp = e.getPoint();
|
||||
|
||||
lx = (cp.getX());
|
||||
lz = (cp.getY());
|
||||
mx = lx;
|
||||
mz = lz;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
Point cp = e.getPoint();
|
||||
ox += (lx - cp.getX()) * scale;
|
||||
oz += (lz - cp.getY()) * scale;
|
||||
lx = cp.getX();
|
||||
lz = cp.getY();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void mouseWheelMoved(MouseWheelEvent e) {
|
||||
|
||||
int notches = e.getWheelRotation();
|
||||
if (e.isControlDown()) {
|
||||
t = t + ((0.001 * t) * notches);
|
||||
return;
|
||||
}
|
||||
|
||||
scale = scale + ((0.044 * scale) * notches);
|
||||
scale = scale < 0.00001 ? 0.00001 : scale;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
|
||||
if (scale < ascale) {
|
||||
ascale -= Math.abs(scale - ascale) * 0.16;
|
||||
}
|
||||
|
||||
if (scale > ascale) {
|
||||
ascale += Math.abs(ascale - scale) * 0.16;
|
||||
}
|
||||
|
||||
if (t < tz) {
|
||||
tz -= Math.abs(t - tz) * 0.29;
|
||||
}
|
||||
|
||||
if (t > tz) {
|
||||
tz += Math.abs(tz - t) * 0.29;
|
||||
}
|
||||
|
||||
if (ox < oxp) {
|
||||
oxp -= Math.abs(ox - oxp) * 0.16;
|
||||
}
|
||||
|
||||
if (ox > oxp) {
|
||||
oxp += Math.abs(oxp - ox) * 0.16;
|
||||
}
|
||||
|
||||
if (oz < ozp) {
|
||||
ozp -= Math.abs(oz - ozp) * 0.16;
|
||||
}
|
||||
|
||||
if (oz > ozp) {
|
||||
ozp += Math.abs(ozp - oz) * 0.16;
|
||||
}
|
||||
|
||||
if (mx < mxx) {
|
||||
mxx -= Math.abs(mx - mxx) * 0.16;
|
||||
}
|
||||
|
||||
if (mx > mxx) {
|
||||
mxx += Math.abs(mxx - mx) * 0.16;
|
||||
}
|
||||
|
||||
if (mz < mzz) {
|
||||
mzz -= Math.abs(mz - mzz) * 0.16;
|
||||
}
|
||||
|
||||
if (mz > mzz) {
|
||||
mzz += Math.abs(mzz - mz) * 0.16;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
int accuracy = hd ? 1 : M.clip((r.getAverage() / 6D), 1D, 128D).intValue();
|
||||
accuracy = down ? accuracy * 4 : accuracy;
|
||||
int v = 1000;
|
||||
|
||||
Iris.proj.getCurrentProject().getCache().targetChunk(0, 0);
|
||||
|
||||
if (g instanceof Graphics2D) {
|
||||
Graphics2D gg = (Graphics2D) g;
|
||||
|
||||
if (getParent().getWidth() != w || getParent().getHeight() != h) {
|
||||
w = getParent().getWidth();
|
||||
h = getParent().getHeight();
|
||||
co = null;
|
||||
}
|
||||
|
||||
if (co == null) {
|
||||
co = new int[getParent().getWidth()][getParent().getHeight()];
|
||||
}
|
||||
|
||||
for (int x = 0; x < getParent().getWidth(); x += accuracy) {
|
||||
int xx = x;
|
||||
|
||||
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
||||
int zz = z;
|
||||
gx.queue("a", () -> {
|
||||
if (renderer != null) {
|
||||
co[xx][zz] = renderer.apply((xx * ascale) + oxp, (zz * ascale) + ozp).getRGB();
|
||||
}
|
||||
|
||||
else {
|
||||
double n = cng.noise((xx * ascale) + oxp, tz, (zz * ascale) + ozp);
|
||||
|
||||
if (n > 1 || n < 0) {
|
||||
System.out.println("EXCEEDED " + n);
|
||||
return;
|
||||
}
|
||||
|
||||
Color color = colorMode
|
||||
? Color.getHSBColor((float) (n), 1f - (float) (n * n * n * n * n * n),
|
||||
1f - (float) n)
|
||||
: Color.getHSBColor(0f, 0f, (float) n);
|
||||
int rgb = color.getRGB();
|
||||
co[xx][zz] = rgb;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
gx.waitFor("a");
|
||||
|
||||
if (hd && p.getMilliseconds() > v) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int x = 0; x < getParent().getWidth(); x += accuracy) {
|
||||
for (int z = 0; z < getParent().getHeight(); z += accuracy) {
|
||||
gg.setColor(new Color(co[x][z]));
|
||||
gg.fillRect(x, z, accuracy, accuracy);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderer != null) {
|
||||
String text = Iris.proj.getCurrentProject().textFor((mxx * ascale) + oxp, (mzz * ascale) + ozp);
|
||||
gg.setColor(Color.black);
|
||||
gg.setFont(new Font("TimesRoman", Font.PLAIN, 24));
|
||||
gg.drawString(text, (float) mxx, (float) mzz);
|
||||
}
|
||||
}
|
||||
|
||||
p.end();
|
||||
|
||||
t += 1D;
|
||||
r.put(p.getMilliseconds());
|
||||
|
||||
if (!isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getParent().isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!getParent().getParent().isVisible()) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventQueue.invokeLater(() -> {
|
||||
J.sleep((long) Math.max(0, 32 - r.getAverage()));
|
||||
repaint();
|
||||
});
|
||||
}
|
||||
|
||||
private static void createAndShowGUI(IrisChunkGenerator g) {
|
||||
JFrame frame = new JFrame("Vision");
|
||||
NoiseView nv = new NoiseView();
|
||||
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
KList<String> li = new KList<NoiseStyle>(NoiseStyle.values()).toStringList().qadd("PROJECT");
|
||||
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
|
||||
combo.setSelectedItem(g != null ? "PROJECT" : "STATIC");
|
||||
|
||||
if (g != null) {
|
||||
renderer = Iris.proj.getCurrentProject().createRenderer();
|
||||
}
|
||||
|
||||
combo.setFocusable(false);
|
||||
combo.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@SuppressWarnings("unchecked")
|
||||
String b = (String) (((JComboBox<String>) e.getSource()).getSelectedItem());
|
||||
if (b.equals("PROJECT")) {
|
||||
renderer = Iris.proj.getCurrentProject().createRenderer();
|
||||
return;
|
||||
}
|
||||
renderer = null;
|
||||
NoiseStyle s = NoiseStyle.valueOf(b);
|
||||
nv.cng = s.create(RNG.r.nextParallelRNG(RNG.r.imax()));
|
||||
}
|
||||
});
|
||||
|
||||
combo.setSize(500, 30);
|
||||
JLayeredPane pane = new JLayeredPane();
|
||||
nv.setSize(new Dimension(1440, 820));
|
||||
pane.add(nv, 1, 0);
|
||||
pane.add(combo, 2, 0);
|
||||
frame.add(pane);
|
||||
frame.setSize(1440, 820);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
public static void launch(IrisChunkGenerator g) {
|
||||
EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
createAndShowGUI(g);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static class HandScrollListener extends MouseAdapter {
|
||||
private static final Point pp = new Point();
|
||||
|
||||
@Override
|
||||
public void mouseDragged(MouseEvent e) {
|
||||
JViewport vport = (JViewport) e.getSource();
|
||||
JComponent label = (JComponent) vport.getView();
|
||||
Point cp = e.getPoint();
|
||||
Point vp = vport.getViewPosition();
|
||||
vp.translate(pp.x - cp.x, pp.y - cp.y);
|
||||
label.scrollRectToVisible(new Rectangle(vp, vport.getSize()));
|
||||
|
||||
pp.setLocation(cp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
pp.setLocation(e.getPoint());
|
||||
}
|
||||
}
|
||||
}
|
9
src/main/java/com/volmit/iris/gui/Renderer.java
Normal file
9
src/main/java/com/volmit/iris/gui/Renderer.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.volmit.iris.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface Renderer
|
||||
{
|
||||
public Color draw(double x, double z);
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
@ -45,6 +47,11 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
||||
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
||||
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@DontObfuscate
|
||||
@Desc("Define custom block drops for this biome")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Reference loot tables in this area")
|
||||
private IrisLootReference loot = new IrisLootReference();
|
||||
@ -69,6 +76,10 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
@Desc("The rarity of this biome (integer)")
|
||||
private int rarity = 1;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("A debug color for visualizing this biome with a color. I.e. #F13AF5")
|
||||
private String debugColor = "";
|
||||
|
||||
@Required
|
||||
@DontObfuscate
|
||||
@Desc("The raw derivative of this biome. This is required or the terrain will not properly generate. Use any vanilla biome type. Look in examples/biome-list.txt")
|
||||
@ -146,6 +157,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||
|
||||
private transient InferredType inferredType;
|
||||
private transient AtomicCache<Color> cacheColor = new AtomicCache<>(true);
|
||||
private transient AtomicCache<CNG> childrenCell = new AtomicCache<>();
|
||||
private transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
|
||||
private transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
||||
@ -158,6 +170,19 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
|
||||
}
|
||||
|
||||
public Color getCachedColor()
|
||||
{
|
||||
return cacheColor.aquire(() ->
|
||||
{
|
||||
if(getDebugColor() == null || getDebugColor().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return Color.getColor(getDebugColor().substring(1));
|
||||
});
|
||||
}
|
||||
|
||||
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
|
||||
{
|
||||
double height = 0;
|
||||
|
90
src/main/java/com/volmit/iris/object/IrisBlockDrops.java
Normal file
90
src/main/java/com/volmit/iris/object/IrisBlockDrops.java
Normal file
@ -0,0 +1,90 @@
|
||||
package com.volmit.iris.object;
|
||||
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.Desc;
|
||||
import com.volmit.iris.util.DontObfuscate;
|
||||
import com.volmit.iris.util.KList;
|
||||
import com.volmit.iris.util.RNG;
|
||||
import com.volmit.iris.util.Required;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Desc("Represents a block drop list")
|
||||
@Data
|
||||
public class IrisBlockDrops
|
||||
{
|
||||
@Required
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("The blocks that drop loot")
|
||||
private KList<String> blocks = new KList<String>();
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("If exact blocks is set to true, minecraft:barrel[axis=x] will only drop for that axis. When exact is false (default) any barrel will drop the defined drops.")
|
||||
private boolean exactBlocks = false;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Add in specific items to drop")
|
||||
@ArrayType(min = 1, type = IrisLoot.class)
|
||||
private KList<IrisLoot> drops = new KList<>();
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("If this is in a biome, setting skipParents to true will ignore the drops in the region and dimension for this block type. The default (false) will allow all three nodes to fire and add to a list of drops.")
|
||||
private boolean skipParents = false;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("Removes the default vanilla block drops and only drops the given items & any parent loot tables specified for this block type.")
|
||||
private boolean replaceVanillaDrops = false;
|
||||
|
||||
private transient AtomicCache<KList<BlockData>> data = new AtomicCache<>();
|
||||
|
||||
public IrisBlockDrops()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public boolean shouldDropFor(BlockData data)
|
||||
{
|
||||
KList<BlockData> list = this.data.aquire(() ->
|
||||
{
|
||||
KList<BlockData> b = new KList<>();
|
||||
|
||||
for(String i : getBlocks())
|
||||
{
|
||||
BlockData dd = B.get(i);
|
||||
|
||||
if(dd != null)
|
||||
{
|
||||
b.add(dd);
|
||||
}
|
||||
}
|
||||
|
||||
return b.removeDuplicates();
|
||||
});
|
||||
|
||||
for(BlockData i : list)
|
||||
{
|
||||
if(exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void fillDrops(boolean debug, KList<ItemStack> d)
|
||||
{
|
||||
for(IrisLoot i : getDrops())
|
||||
{
|
||||
if(RNG.r.i(1, i.getRarity()) == i.getRarity())
|
||||
{
|
||||
d.add(i.get(debug, RNG.r));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,11 @@ public class IrisDimension extends IrisRegistrant
|
||||
@Desc("The version of this dimension. Changing this will stop users from accidentally upgrading (and breaking their worlds).")
|
||||
private int version = 1;
|
||||
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@DontObfuscate
|
||||
@Desc("Define custom block drops for this dimension")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@DontObfuscate
|
||||
|
@ -108,6 +108,73 @@ public class IrisLoot
|
||||
return B.getMaterial(type);
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, RNG rng)
|
||||
{
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable)
|
||||
{
|
||||
Damageable d = (Damageable) m;
|
||||
int max = getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for(IrisEnchantment i : getEnchantments())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for(IrisAttributeModifier i : getAttributes())
|
||||
{
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
m.setCustomModelData(getCustomModel());
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags())
|
||||
{
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24)
|
||||
{
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
|
||||
{
|
||||
lore.add(g.trim());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug)
|
||||
{
|
||||
if(lore.isNotEmpty())
|
||||
{
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
lore.add(C.GRAY + "1 in " + (getRarity()) + " Chance (" + Form.pc(1D / (getRarity()), 5) + ")");
|
||||
}
|
||||
|
||||
m.setLore(lore);
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, IrisLootTable table, RNG rng, int x, int y, int z)
|
||||
{
|
||||
if(debug)
|
||||
@ -144,8 +211,8 @@ public class IrisLoot
|
||||
}
|
||||
|
||||
m.setCustomModelData(getCustomModel());
|
||||
m.setLocalizedName(displayName);
|
||||
m.setDisplayName(displayName);
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for(ItemFlag i : getItemFlags())
|
||||
@ -155,7 +222,23 @@ public class IrisLoot
|
||||
|
||||
KList<String> lore = new KList<>();
|
||||
|
||||
lore.addAll(getLore());
|
||||
getLore().forEach((i) ->
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if(mf.length() > 24)
|
||||
{
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E"))
|
||||
{
|
||||
lore.add(g.trim());
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
lore.add(mf);
|
||||
}
|
||||
});
|
||||
|
||||
if(debug)
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ public class IrisObject extends IrisRegistrant
|
||||
private static final Material SNOW = Material.SNOW;
|
||||
private static final BlockData AIR = B.getBlockData("CAVE_AIR");
|
||||
private static final BlockData[] SNOW_LAYERS = new BlockData[] {B.getBlockData("minecraft:snow[layers=1]"), B.getBlockData("minecraft:snow[layers=2]"), B.getBlockData("minecraft:snow[layers=3]"), B.getBlockData("minecraft:snow[layers=4]"), B.getBlockData("minecraft:snow[layers=5]"), B.getBlockData("minecraft:snow[layers=6]"), B.getBlockData("minecraft:snow[layers=7]"), B.getBlockData("minecraft:snow[layers=8]")};
|
||||
public static boolean shitty = false;
|
||||
private KMap<BlockVector, BlockData> blocks;
|
||||
private int w;
|
||||
private int d;
|
||||
@ -74,6 +75,11 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void read(InputStream in) throws IOException
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DataInputStream din = new DataInputStream(in);
|
||||
this.w = din.readInt();
|
||||
this.h = din.readInt();
|
||||
@ -89,6 +95,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void read(File file) throws IOException
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
FileInputStream fin = new FileInputStream(file);
|
||||
read(fin);
|
||||
fin.close();
|
||||
@ -96,6 +106,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void write(File file) throws IOException
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
file.getParentFile().mkdirs();
|
||||
FileOutputStream out = new FileOutputStream(file);
|
||||
write(out);
|
||||
@ -104,6 +118,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void write(OutputStream o) throws IOException
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DataOutputStream dos = new DataOutputStream(o);
|
||||
dos.writeInt(w);
|
||||
dos.writeInt(h);
|
||||
@ -120,6 +138,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void clean()
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
KMap<BlockVector, BlockData> d = blocks.copy();
|
||||
blocks.clear();
|
||||
|
||||
@ -131,6 +153,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void setUnsigned(int x, int y, int z, BlockData block)
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(x >= w || y >= h || z >= d)
|
||||
{
|
||||
throw new RuntimeException(x + " " + y + " " + z + " exceeds limit of " + w + " " + h + " " + d);
|
||||
@ -151,6 +177,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void place(int x, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng)
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
place(x, -1, z, placer, config, rng);
|
||||
}
|
||||
|
||||
@ -161,6 +191,10 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public int place(int x, int yv, int z, IObjectPlacer placer, IrisObjectPlacement config, RNG rng, Consumer<BlockPosition> listener)
|
||||
{
|
||||
boolean stilting = (config.getMode().equals(ObjectPlaceMode.STILT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT));
|
||||
KMap<ChunkPosition, Integer> lowmap = stilting ? new KMap<>() : null;
|
||||
KMap<ChunkPosition, BlockData> lowmapData = stilting ? new KMap<>() : null;
|
||||
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
int spinx = rng.imax() / 1000;
|
||||
int spiny = rng.imax() / 1000;
|
||||
int spinz = rng.imax() / 1000;
|
||||
@ -170,12 +204,12 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
if(yv < 0)
|
||||
{
|
||||
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT_RIGID))
|
||||
if(config.getMode().equals(ObjectPlaceMode.CENTER_HEIGHT))
|
||||
{
|
||||
y = placer.getHighest(x, z, config.isUnderwater()) + rty;
|
||||
}
|
||||
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID_ACCURATE))
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.STILT))
|
||||
{
|
||||
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
|
||||
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
|
||||
@ -194,7 +228,7 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MAX_HEIGHT_RIGID))
|
||||
else if(config.getMode().equals(ObjectPlaceMode.FAST_MAX_HEIGHT) || config.getMode().equals(ObjectPlaceMode.FAST_STILT))
|
||||
{
|
||||
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
|
||||
BlockVector rotatedDimensions = config.getRotation().rotate(new BlockVector(getW(), getH(), getD()), spinx, spiny, spinz).clone();
|
||||
@ -213,7 +247,7 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT_RIGID_ACCURATE))
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT))
|
||||
{
|
||||
y = 257;
|
||||
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
|
||||
@ -233,7 +267,7 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
}
|
||||
|
||||
else if(config.getMode().equals(ObjectPlaceMode.MIN_HEIGHT_RIGID))
|
||||
else if(config.getMode().equals(ObjectPlaceMode.FAST_MIN_HEIGHT))
|
||||
{
|
||||
y = 257;
|
||||
BlockVector offset = new BlockVector(config.getTranslate().getX(), config.getTranslate().getY(), config.getTranslate().getZ());
|
||||
@ -269,8 +303,6 @@ public class IrisObject extends IrisRegistrant
|
||||
y += Math.floorDiv(h, 2);
|
||||
}
|
||||
|
||||
KMap<ChunkPosition, Integer> heightmap = config.getSnow() > 0 ? new KMap<>() : null;
|
||||
|
||||
if(yv < 0)
|
||||
{
|
||||
if(!config.isUnderwater() && !config.isOnwater() && placer.isUnderwater(x, z))
|
||||
@ -289,19 +321,22 @@ public class IrisObject extends IrisRegistrant
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(config.isBore())
|
||||
if(config.isBore() && !config.getMode().equals(ObjectPlaceMode.PAINT))
|
||||
{
|
||||
for(int i = x - Math.floorDiv(w, 2); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0); i++)
|
||||
{
|
||||
for(int j = y - Math.floorDiv(h, 2); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0); j++)
|
||||
for(int j = y - Math.floorDiv(h, 2) - config.getBoarExtendMinY(); j <= y + Math.floorDiv(h, 2) + config.getBoarExtendMaxY() - (h % 2 == 0 ? 1 : 0); j++)
|
||||
{
|
||||
for(int k = z - Math.floorDiv(d, 2); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0); k++)
|
||||
{
|
||||
if(!B.isAir(placer.get(i, j, k)))
|
||||
{
|
||||
placer.set(i, j, k, AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for(BlockVector g : blocks.keySet())
|
||||
{
|
||||
@ -367,6 +402,49 @@ public class IrisObject extends IrisRegistrant
|
||||
}
|
||||
|
||||
placer.set(xx, yy, zz, data);
|
||||
|
||||
if(stilting)
|
||||
{
|
||||
BlockData bdata = data;
|
||||
int yyy = yy;
|
||||
ChunkPosition ck = new ChunkPosition(xx, zz);
|
||||
lowmap.compute(ck, (k, v) ->
|
||||
{
|
||||
if(v == null)
|
||||
{
|
||||
lowmapData.put(ck, bdata);
|
||||
return yyy;
|
||||
}
|
||||
|
||||
if(v > yyy)
|
||||
{
|
||||
lowmapData.put(ck, bdata);
|
||||
return yyy;
|
||||
}
|
||||
|
||||
return v;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(stilting)
|
||||
{
|
||||
for(ChunkPosition i : lowmap.keySet())
|
||||
{
|
||||
int xf = i.getX();
|
||||
int yf = lowmap.get(i);
|
||||
int zf = i.getZ();
|
||||
int yg = Math.floorDiv(h, 2) + placer.getHighest(xf, zf, config.isUnderwater());
|
||||
BlockData d = lowmapData.get(i);
|
||||
|
||||
if(d != null)
|
||||
{
|
||||
for(int j = yf; j > yg - config.getOverStilt(); j--)
|
||||
{
|
||||
placer.set(xf, j, zf, d);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(heightmap != null)
|
||||
@ -398,6 +476,11 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void rotate(IrisObjectRotation r, int spinx, int spiny, int spinz)
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
KMap<BlockVector, BlockData> v = blocks.copy();
|
||||
blocks.clear();
|
||||
|
||||
@ -409,6 +492,11 @@ public class IrisObject extends IrisRegistrant
|
||||
|
||||
public void place(Location at)
|
||||
{
|
||||
if(shitty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(BlockVector i : blocks.keySet())
|
||||
{
|
||||
at.clone().add(0, getCenter().getY(), 0).add(i).getBlock().setBlockData(blocks.get(i), false);
|
||||
|
@ -31,7 +31,7 @@ public class IrisObjectPlacement
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("The placement mode")
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT_RIGID;
|
||||
private ObjectPlaceMode mode = ObjectPlaceMode.CENTER_HEIGHT;
|
||||
|
||||
@ArrayType(min = 1, type = IrisObjectReplace.class)
|
||||
@DontObfuscate
|
||||
@ -68,6 +68,24 @@ public class IrisObjectPlacement
|
||||
@Desc("If the chance check passes, place this many in a single chunk")
|
||||
private int density = 1;
|
||||
|
||||
@MaxNumber(64)
|
||||
@MinNumber(0)
|
||||
@DontObfuscate
|
||||
@Desc("If the place mode is set to stilt, you can over-stilt it even further into the ground. Especially useful when using fast stilt due to inaccuracies.")
|
||||
private int overStilt = 0;
|
||||
|
||||
@MaxNumber(64)
|
||||
@MinNumber(0)
|
||||
@DontObfuscate
|
||||
@Desc("When boar is enabled, expand max-y of the cuboid it removes")
|
||||
private int boarExtendMaxY = 0;
|
||||
|
||||
@MaxNumber(64)
|
||||
@MinNumber(0)
|
||||
@DontObfuscate
|
||||
@Desc("When boar is enabled, lower min-y of the cuboid it removes")
|
||||
private int boarExtendMinY = 0;
|
||||
|
||||
@DontObfuscate
|
||||
@Desc("If set to true, objects will place on the terrain height, ignoring the water surface.")
|
||||
private boolean underwater = false;
|
||||
|
@ -42,6 +42,11 @@ public class IrisRegion extends IrisRegistrant implements IRare
|
||||
@Desc("The rarity of the region")
|
||||
private int rarity = 1;
|
||||
|
||||
@ArrayType(min = 1, type = IrisBlockDrops.class)
|
||||
@DontObfuscate
|
||||
@Desc("Define custom block drops for this region")
|
||||
private KList<IrisBlockDrops> blockDrops = new KList<>();
|
||||
|
||||
@MinNumber(0.0001)
|
||||
@MaxNumber(1)
|
||||
@DontObfuscate
|
||||
|
@ -5,19 +5,25 @@ import com.volmit.iris.util.DontObfuscate;
|
||||
public enum ObjectPlaceMode
|
||||
{
|
||||
@DontObfuscate
|
||||
CENTER_HEIGHT_RIGID,
|
||||
CENTER_HEIGHT,
|
||||
|
||||
@DontObfuscate
|
||||
MAX_HEIGHT_RIGID_ACCURATE,
|
||||
MAX_HEIGHT,
|
||||
|
||||
@DontObfuscate
|
||||
MAX_HEIGHT_RIGID,
|
||||
FAST_MAX_HEIGHT,
|
||||
|
||||
@DontObfuscate
|
||||
MIN_HEIGHT_RIGID_ACCURATE,
|
||||
MIN_HEIGHT,
|
||||
|
||||
@DontObfuscate
|
||||
MIN_HEIGHT_RIGID,
|
||||
FAST_MIN_HEIGHT,
|
||||
|
||||
@DontObfuscate
|
||||
STILT,
|
||||
|
||||
@DontObfuscate
|
||||
FAST_STILT,
|
||||
|
||||
@DontObfuscate
|
||||
PAINT;
|
||||
|
@ -349,4 +349,9 @@ public class B
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
public static boolean isAir(BlockData blockData)
|
||||
{
|
||||
return blockData.getMaterial().isAir();
|
||||
}
|
||||
}
|
||||
|
@ -603,6 +603,11 @@ public enum C
|
||||
*/
|
||||
public static String translateAlternateColorCodes(char altColorChar, String textToTranslate)
|
||||
{
|
||||
if(textToTranslate == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
char[] b = textToTranslate.toCharArray();
|
||||
for(int i = 0; i < b.length - 1; i++)
|
||||
{
|
||||
|
6
src/main/java/com/volmit/iris/util/IActivator.java
Normal file
6
src/main/java/com/volmit/iris/util/IActivator.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public interface IActivator
|
||||
{
|
||||
|
||||
}
|
11
src/main/java/com/volmit/iris/util/Info.java
Normal file
11
src/main/java/com/volmit/iris/util/Info.java
Normal file
@ -0,0 +1,11 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class Info
|
||||
{
|
||||
public static String getPortIP()
|
||||
{
|
||||
return Bukkit.getPort() + Bukkit.getIp();
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ public class J
|
||||
{
|
||||
tid++;
|
||||
Thread t = new Thread(r);
|
||||
t.setName("Iris Preemptive Generator " + tid);
|
||||
t.setName("Iris Actuator " + tid);
|
||||
t.setPriority(Thread.MIN_PRIORITY);
|
||||
t.setUncaughtExceptionHandler((et, e) ->
|
||||
{
|
||||
|
@ -24,6 +24,11 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
super();
|
||||
}
|
||||
|
||||
public KList(int cap)
|
||||
{
|
||||
super(cap);
|
||||
}
|
||||
|
||||
public KList(Collection<T> values)
|
||||
{
|
||||
super();
|
||||
|
@ -3,6 +3,8 @@ package com.volmit.iris.util;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
|
||||
import com.volmit.iris.activation.IrisActivation2;
|
||||
|
||||
/**
|
||||
* Represents a pawn command
|
||||
*
|
||||
@ -39,6 +41,7 @@ public abstract class MortarCommand implements ICommand
|
||||
|
||||
public void printHelp(MortarSender sender)
|
||||
{
|
||||
IrisActivation2.validate();
|
||||
boolean b = false;
|
||||
|
||||
for(MortarCommand i : getChildren())
|
||||
|
@ -25,6 +25,7 @@ import com.volmit.iris.Iris;
|
||||
|
||||
public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
{
|
||||
public static boolean bad = false;
|
||||
private KMap<KList<String>, VirtualCommand> commands;
|
||||
private KList<MortarCommand> commandCache;
|
||||
private KList<MortarPermission> permissionCache;
|
||||
@ -276,6 +277,11 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void tickControllers()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for(IController i : getControllers())
|
||||
{
|
||||
tickController(i);
|
||||
@ -284,6 +290,11 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void tickController(IController i)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(i.getTickInterval() < 0)
|
||||
{
|
||||
return;
|
||||
@ -307,11 +318,20 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
public KList<IController> getControllers()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return new KList<>();
|
||||
}
|
||||
|
||||
return cachedControllers;
|
||||
}
|
||||
|
||||
private void registerControllers()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
controllers = new KMap<>();
|
||||
cachedClassControllers = new KMap<>();
|
||||
|
||||
@ -346,6 +366,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void registerController(IController pc)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
controllers.put(pc.getName(), pc);
|
||||
cachedClassControllers.put(pc.getClass(), pc);
|
||||
registerListener(pc);
|
||||
@ -365,6 +389,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void registerInstance()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(Field i : getClass().getDeclaredFields())
|
||||
{
|
||||
if(i.isAnnotationPresent(Instance.class))
|
||||
@ -387,6 +415,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void unregisterInstance()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(Field i : getClass().getDeclaredFields())
|
||||
{
|
||||
if(i.isAnnotationPresent(Instance.class))
|
||||
@ -409,6 +441,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void registerCommands()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
commands = new KMap<>();
|
||||
commandCache = new KList<>();
|
||||
|
||||
@ -438,6 +474,11 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
KList<String> chain = new KList<String>();
|
||||
chain.add(args);
|
||||
|
||||
@ -467,6 +508,11 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
public void registerCommand(ICommand cmd, String subTag)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
commands.put(cmd.getAllNodes(), new VirtualCommand(cmd, subTag.trim().isEmpty() ? getTag() : getTag(subTag.trim())));
|
||||
PluginCommand cc = getCommand(cmd.getNode().toLowerCase());
|
||||
|
||||
@ -486,6 +532,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
public void unregisterCommand(ICommand cmd)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
SimpleCommandMap m = new com.volmit.iris.util.V(Bukkit.getServer()).get("commandMap");
|
||||
@ -525,26 +575,46 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
public String getTag()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return getTag("");
|
||||
}
|
||||
|
||||
public void registerListener(Listener l)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Bukkit.getPluginManager().registerEvents(l, this);
|
||||
}
|
||||
|
||||
public void unregisterListener(Listener l)
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HandlerList.unregisterAll(l);
|
||||
}
|
||||
|
||||
public void unregisterListeners()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
HandlerList.unregisterAll((Listener) this);
|
||||
}
|
||||
|
||||
public void unregisterCommands()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(VirtualCommand i : commands.v())
|
||||
{
|
||||
try
|
||||
@ -561,6 +631,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void unregisterPermissions()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(org.bukkit.permissions.Permission i : computePermissions())
|
||||
{
|
||||
Bukkit.getPluginManager().removePermission(i);
|
||||
@ -570,6 +644,10 @@ public abstract class MortarPlugin extends JavaPlugin implements Listener
|
||||
|
||||
private void stopControllers()
|
||||
{
|
||||
if(bad)
|
||||
{
|
||||
return;
|
||||
}
|
||||
for(IController i : controllers.v())
|
||||
{
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user