mirror of
https://github.com/GTNewHorizons/ForgeMultipart.git
synced 2026-11-26 23:13:07 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b0e99024d | ||
|
|
a1db9a100e | ||
|
|
3c42abd7ac | ||
|
|
f3a0ab0568 | ||
|
|
a0af5e19cf | ||
|
|
3f27188181 | ||
|
|
4fc6b9cff2 | ||
|
|
ef67761bc3 | ||
|
|
d50ec43d76 |
No files matched your search
@@ -27,3 +27,4 @@ whitelist.json
|
|||||||
*.iws
|
*.iws
|
||||||
src/main/resources/mixins.*.json
|
src/main/resources/mixins.*.json
|
||||||
*.bat
|
*.bat
|
||||||
|
layout.json
|
||||||
+5
-3
@@ -1,7 +1,9 @@
|
|||||||
// Add your dependencies here
|
// Add your dependencies here
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta43:dev")
|
implementation("com.github.GTNewHorizons:CodeChickenCore:1.4.7:dev")
|
||||||
|
compileOnly("com.github.GTNewHorizons:Angelica:1.0.0-beta62:dev")
|
||||||
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.7.18-GTNH:dev")
|
devOnlyNonPublishable("com.github.GTNewHorizons:NotEnoughItems:2.8.20-GTNH:dev") {
|
||||||
|
exclude group: 'com.github.GTNewHorizons', module: 'CodeChickenCore'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+6
-4
@@ -14,7 +14,7 @@ modId = ForgeMultipart
|
|||||||
modGroup = codechicken
|
modGroup = codechicken
|
||||||
|
|
||||||
# Whether to use modGroup as the maven publishing group.
|
# Whether to use modGroup as the maven publishing group.
|
||||||
# Due to a history of using JitPack, the default is com.github.GTNewHorizons for all mods.
|
# When false, com.github.GTNewHorizons is used.
|
||||||
useModGroupForPublishing = false
|
useModGroupForPublishing = false
|
||||||
|
|
||||||
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
# Updates your build.gradle and settings.gradle automatically whenever an update is available.
|
||||||
@@ -96,13 +96,15 @@ usesMixinDebug = false
|
|||||||
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
# Specify the location of your implementation of IMixinConfigPlugin. Leave it empty otherwise.
|
||||||
mixinPlugin =
|
mixinPlugin =
|
||||||
|
|
||||||
# Specify the package that contains all of your Mixins. You may only place Mixins in this package or the build will fail!
|
# Specify the package that contains all of your Mixins. The package must exist or
|
||||||
|
# the build will fail. If you have a package property defined in your mixins.<modid>.json,
|
||||||
|
# it must match with this or the build will fail.
|
||||||
mixinsPackage =
|
mixinsPackage =
|
||||||
|
|
||||||
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
# Specify the core mod entry class if you use a core mod. This class must implement IFMLLoadingPlugin!
|
||||||
# This parameter is for legacy compatibility only
|
# This parameter is for legacy compatibility only
|
||||||
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
# Example value: (coreModClass = asm.FMLPlugin) + (modGroup = com.myname.mymodid) -> com.myname.mymodid.asm.FMLPlugin
|
||||||
coreModClass = core.launch.DepLoader
|
coreModClass =
|
||||||
|
|
||||||
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
# If your project is only a consolidation of mixins or a core mod and does NOT contain a 'normal' mod ( = some class
|
||||||
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
# that is annotated with @Mod) you want this to be true. When in doubt: leave it on false!
|
||||||
@@ -151,7 +153,7 @@ modrinthProjectId =
|
|||||||
# type can be one of [project, version],
|
# type can be one of [project, version],
|
||||||
# and the name is the Modrinth project or version slug/id of the other mod.
|
# and the name is the Modrinth project or version slug/id of the other mod.
|
||||||
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
# Example: required-project:fplib;optional-project:gasstation;incompatible-project:gregtech
|
||||||
# Note: GTNH Mixins is automatically set as a required dependency if usesMixins = true
|
# Note: UniMixins is automatically set as a required dependency if usesMixins = true.
|
||||||
modrinthRelations =
|
modrinthRelations =
|
||||||
|
|
||||||
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
# Publishing to CurseForge requires you to set the CURSEFORGE_TOKEN environment variable to one of your CurseForge API tokens.
|
||||||
|
|||||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -206,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ pluginManagement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.31'
|
id 'com.gtnewhorizons.gtnhsettingsconvention' version '1.0.46'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
"repo": "https://github.com/GTNewHorizons/CodeChickenLib/releases/download/1.2.0/",
|
|
||||||
"file": "CodeChickenLib-1.2.0.jar",
|
|
||||||
"dev": "CodeChickenLib-1.2.0-dev.jar",
|
|
||||||
"class": "codechicken.lib.asm.ASMHelper",
|
|
||||||
"coreLib": true
|
|
||||||
}
|
|
||||||
@@ -1,639 +0,0 @@
|
|||||||
package codechicken.core.launch;
|
|
||||||
|
|
||||||
import static java.awt.Component.LEFT_ALIGNMENT;
|
|
||||||
|
|
||||||
import java.awt.Desktop;
|
|
||||||
import java.awt.Dialog.ModalityType;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.GraphicsEnvironment;
|
|
||||||
import java.awt.event.WindowAdapter;
|
|
||||||
import java.awt.event.WindowEvent;
|
|
||||||
import java.beans.PropertyChangeEvent;
|
|
||||||
import java.beans.PropertyChangeListener;
|
|
||||||
import java.io.Closeable;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.InterruptedIOException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.nio.ByteBuffer;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.regex.PatternSyntaxException;
|
|
||||||
import java.util.zip.ZipEntry;
|
|
||||||
import java.util.zip.ZipFile;
|
|
||||||
|
|
||||||
import javax.swing.Box;
|
|
||||||
import javax.swing.JDialog;
|
|
||||||
import javax.swing.JEditorPane;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import javax.swing.JProgressBar;
|
|
||||||
import javax.swing.WindowConstants;
|
|
||||||
import javax.swing.event.HyperlinkEvent;
|
|
||||||
import javax.swing.event.HyperlinkListener;
|
|
||||||
|
|
||||||
import net.minecraft.launchwrapper.LaunchClassLoader;
|
|
||||||
|
|
||||||
import com.google.gson.JsonElement;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
|
|
||||||
import cpw.mods.fml.common.versioning.ComparableVersion;
|
|
||||||
import cpw.mods.fml.relauncher.FMLInjectionData;
|
|
||||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
|
||||||
import cpw.mods.fml.relauncher.IFMLCallHook;
|
|
||||||
import cpw.mods.fml.relauncher.IFMLLoadingPlugin;
|
|
||||||
import sun.misc.URLClassPath;
|
|
||||||
import sun.net.util.URLUtil;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* For autodownloading stuff. This is really unoriginal, mostly ripped off FML, credits to cpw.
|
|
||||||
*/
|
|
||||||
public class DepLoader implements IFMLLoadingPlugin, IFMLCallHook {
|
|
||||||
|
|
||||||
private static ByteBuffer downloadBuffer = ByteBuffer.allocateDirect(1 << 23);
|
|
||||||
private static final String owner = "CB's DepLoader";
|
|
||||||
private static DepLoadInst inst;
|
|
||||||
|
|
||||||
public interface IDownloadDisplay {
|
|
||||||
|
|
||||||
void resetProgress(int sizeGuess);
|
|
||||||
|
|
||||||
void setPokeThread(Thread currentThread);
|
|
||||||
|
|
||||||
void updateProgress(int fullLength);
|
|
||||||
|
|
||||||
boolean shouldStopIt();
|
|
||||||
|
|
||||||
void updateProgressString(String string, Object... data);
|
|
||||||
|
|
||||||
Object makeDialog();
|
|
||||||
|
|
||||||
void showErrorDialog(String name, String url);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("serial")
|
|
||||||
public static class Downloader extends JOptionPane implements IDownloadDisplay {
|
|
||||||
|
|
||||||
private JDialog container;
|
|
||||||
private JLabel currentActivity;
|
|
||||||
private JProgressBar progress;
|
|
||||||
boolean stopIt;
|
|
||||||
Thread pokeThread;
|
|
||||||
|
|
||||||
private Box makeProgressPanel() {
|
|
||||||
Box box = Box.createVerticalBox();
|
|
||||||
box.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
||||||
JLabel welcomeLabel = new JLabel(
|
|
||||||
"<html><b><font size='+1'>" + owner
|
|
||||||
+ " is setting up your minecraft environment</font></b></html>");
|
|
||||||
box.add(welcomeLabel);
|
|
||||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
|
||||||
welcomeLabel = new JLabel(
|
|
||||||
"<html>Please wait, " + owner + " has some tasks to do before you can play</html>");
|
|
||||||
welcomeLabel.setAlignmentY(LEFT_ALIGNMENT);
|
|
||||||
box.add(welcomeLabel);
|
|
||||||
box.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
||||||
currentActivity = new JLabel("Currently doing ...");
|
|
||||||
box.add(currentActivity);
|
|
||||||
box.add(Box.createRigidArea(new Dimension(0, 10)));
|
|
||||||
progress = new JProgressBar(0, 100);
|
|
||||||
progress.setStringPainted(true);
|
|
||||||
box.add(progress);
|
|
||||||
box.add(Box.createRigidArea(new Dimension(0, 30)));
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JDialog makeDialog() {
|
|
||||||
if (container != null) return container;
|
|
||||||
|
|
||||||
setMessageType(JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
setMessage(makeProgressPanel());
|
|
||||||
setOptions(new Object[] { "Stop" });
|
|
||||||
addPropertyChangeListener(new PropertyChangeListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void propertyChange(PropertyChangeEvent evt) {
|
|
||||||
if (evt.getSource() == Downloader.this && evt.getPropertyName() == VALUE_PROPERTY) {
|
|
||||||
requestClose("This will stop minecraft from launching\nAre you sure you want to do this?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
container = new JDialog(null, "Hello", ModalityType.MODELESS);
|
|
||||||
container.setResizable(false);
|
|
||||||
container.setLocationRelativeTo(null);
|
|
||||||
container.add(this);
|
|
||||||
this.updateUI();
|
|
||||||
container.pack();
|
|
||||||
container.setMinimumSize(container.getPreferredSize());
|
|
||||||
container.setVisible(true);
|
|
||||||
container.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
|
|
||||||
container.addWindowListener(new WindowAdapter() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void windowClosing(WindowEvent e) {
|
|
||||||
requestClose(
|
|
||||||
"Closing this window will stop minecraft from launching\nAre you sure you wish to do this?");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return container;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void requestClose(String message) {
|
|
||||||
int shouldClose = JOptionPane.showConfirmDialog(
|
|
||||||
container,
|
|
||||||
message,
|
|
||||||
"Are you sure you want to stop?",
|
|
||||||
JOptionPane.YES_NO_OPTION,
|
|
||||||
JOptionPane.WARNING_MESSAGE);
|
|
||||||
if (shouldClose == JOptionPane.YES_OPTION) container.dispose();
|
|
||||||
|
|
||||||
stopIt = true;
|
|
||||||
if (pokeThread != null) pokeThread.interrupt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgressString(String progressUpdate, Object... data) {
|
|
||||||
// FMLLog.finest(progressUpdate, data);
|
|
||||||
if (currentActivity != null) currentActivity.setText(String.format(progressUpdate, data));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetProgress(int sizeGuess) {
|
|
||||||
if (progress != null) progress.getModel().setRangeProperties(0, 0, 0, sizeGuess, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgress(int fullLength) {
|
|
||||||
if (progress != null) progress.getModel().setValue(fullLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPokeThread(Thread currentThread) {
|
|
||||||
this.pokeThread = currentThread;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldStopIt() {
|
|
||||||
return stopIt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showErrorDialog(String name, String url) {
|
|
||||||
JEditorPane ep = new JEditorPane(
|
|
||||||
"text/html",
|
|
||||||
"<html>" + owner
|
|
||||||
+ " was unable to download required library "
|
|
||||||
+ name
|
|
||||||
+ "<br>Check your internet connection and try restarting or download it manually from"
|
|
||||||
+ "<br><a href=\""
|
|
||||||
+ url
|
|
||||||
+ "\">"
|
|
||||||
+ url
|
|
||||||
+ "</a> and put it in your mods folder"
|
|
||||||
+ "</html>");
|
|
||||||
|
|
||||||
ep.setEditable(false);
|
|
||||||
ep.setOpaque(false);
|
|
||||||
ep.addHyperlinkListener(new HyperlinkListener() {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void hyperlinkUpdate(HyperlinkEvent event) {
|
|
||||||
try {
|
|
||||||
if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
|
|
||||||
Desktop.getDesktop().browse(event.getURL().toURI());
|
|
||||||
} catch (Exception e) {}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DummyDownloader implements IDownloadDisplay {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void resetProgress(int sizeGuess) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPokeThread(Thread currentThread) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgress(int fullLength) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean shouldStopIt() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateProgressString(String string, Object... data) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object makeDialog() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showErrorDialog(String name, String url) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class VersionedFile {
|
|
||||||
|
|
||||||
public final Pattern pattern;
|
|
||||||
public final String filename;
|
|
||||||
public final ComparableVersion version;
|
|
||||||
public final String name;
|
|
||||||
|
|
||||||
public VersionedFile(String filename, Pattern pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
this.filename = filename;
|
|
||||||
Matcher m = pattern.matcher(filename);
|
|
||||||
if (m.matches()) {
|
|
||||||
name = m.group(1);
|
|
||||||
version = new ComparableVersion(m.group(2));
|
|
||||||
} else {
|
|
||||||
name = null;
|
|
||||||
version = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean matches() {
|
|
||||||
return name != null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Dependency {
|
|
||||||
|
|
||||||
public String url;
|
|
||||||
public VersionedFile file;
|
|
||||||
|
|
||||||
public String existing;
|
|
||||||
/**
|
|
||||||
* Flag set to add this dep to the classpath immediately because it is required for a coremod.
|
|
||||||
*/
|
|
||||||
public boolean coreLib;
|
|
||||||
|
|
||||||
public Dependency(String url, VersionedFile file, boolean coreLib) {
|
|
||||||
this.url = url;
|
|
||||||
this.file = file;
|
|
||||||
this.coreLib = coreLib;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class DepLoadInst {
|
|
||||||
|
|
||||||
private File modsDir;
|
|
||||||
private File v_modsDir;
|
|
||||||
private IDownloadDisplay downloadMonitor;
|
|
||||||
private JDialog popupWindow;
|
|
||||||
|
|
||||||
private Map<String, Dependency> depMap = new HashMap<String, Dependency>();
|
|
||||||
private HashSet<String> depSet = new HashSet<String>();
|
|
||||||
|
|
||||||
public DepLoadInst() {
|
|
||||||
String mcVer = (String) FMLInjectionData.data()[4];
|
|
||||||
File mcDir = (File) FMLInjectionData.data()[6];
|
|
||||||
|
|
||||||
modsDir = new File(mcDir, "mods");
|
|
||||||
v_modsDir = new File(mcDir, "mods/" + mcVer);
|
|
||||||
if (!v_modsDir.exists()) v_modsDir.mkdirs();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addClasspath(String name) {
|
|
||||||
try {
|
|
||||||
((LaunchClassLoader) DepLoader.class.getClassLoader())
|
|
||||||
.addURL(new File(v_modsDir, name).toURI().toURL());
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void deleteMod(File mod) {
|
|
||||||
if (mod.delete()) return;
|
|
||||||
|
|
||||||
try {
|
|
||||||
ClassLoader cl = DepLoader.class.getClassLoader();
|
|
||||||
URL url = mod.toURI().toURL();
|
|
||||||
Field f_ucp = URLClassLoader.class.getDeclaredField("ucp");
|
|
||||||
Field f_loaders = URLClassPath.class.getDeclaredField("loaders");
|
|
||||||
Field f_lmap = URLClassPath.class.getDeclaredField("lmap");
|
|
||||||
f_ucp.setAccessible(true);
|
|
||||||
f_loaders.setAccessible(true);
|
|
||||||
f_lmap.setAccessible(true);
|
|
||||||
|
|
||||||
URLClassPath ucp = (URLClassPath) f_ucp.get(cl);
|
|
||||||
Closeable loader = ((Map<String, Closeable>) f_lmap.get(ucp)).remove(URLUtil.urlNoFragString(url));
|
|
||||||
if (loader != null) {
|
|
||||||
loader.close();
|
|
||||||
((List<?>) f_loaders.get(ucp)).remove(loader);
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!mod.delete()) {
|
|
||||||
mod.deleteOnExit();
|
|
||||||
String msg = owner + " was unable to delete file "
|
|
||||||
+ mod.getPath()
|
|
||||||
+ " the game will now try to delete it on exit. If this dialog appears again, delete it manually.";
|
|
||||||
System.err.println(msg);
|
|
||||||
if (!GraphicsEnvironment.isHeadless())
|
|
||||||
JOptionPane.showMessageDialog(null, msg, "An update error has occured", JOptionPane.ERROR_MESSAGE);
|
|
||||||
|
|
||||||
System.exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void download(Dependency dep) {
|
|
||||||
popupWindow = (JDialog) downloadMonitor.makeDialog();
|
|
||||||
File libFile = new File(v_modsDir, dep.file.filename);
|
|
||||||
try {
|
|
||||||
URL libDownload = new URL(dep.url + '/' + dep.file.filename);
|
|
||||||
downloadMonitor.updateProgressString("Downloading file %s", libDownload.toString());
|
|
||||||
System.out.format("Downloading file %s\n", libDownload.toString());
|
|
||||||
URLConnection connection = libDownload.openConnection();
|
|
||||||
connection.setConnectTimeout(5000);
|
|
||||||
connection.setReadTimeout(5000);
|
|
||||||
connection.setRequestProperty("User-Agent", "" + owner + " Downloader");
|
|
||||||
int sizeGuess = connection.getContentLength();
|
|
||||||
download(connection.getInputStream(), sizeGuess, libFile);
|
|
||||||
downloadMonitor.updateProgressString("Download complete");
|
|
||||||
System.out.println("Download complete");
|
|
||||||
|
|
||||||
scanDepInfo(libFile);
|
|
||||||
} catch (Exception e) {
|
|
||||||
libFile.delete();
|
|
||||||
if (downloadMonitor.shouldStopIt()) {
|
|
||||||
System.err.println("You have stopped the downloading operation before it could complete");
|
|
||||||
System.exit(1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
downloadMonitor.showErrorDialog(dep.file.filename, dep.url + '/' + dep.file.filename);
|
|
||||||
throw new RuntimeException("A download error occured", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void download(InputStream is, int sizeGuess, File target) throws Exception {
|
|
||||||
if (sizeGuess > downloadBuffer.capacity()) throw new Exception(
|
|
||||||
String.format(
|
|
||||||
"The file %s is too large to be downloaded by " + owner + " - the download is invalid",
|
|
||||||
target.getName()));
|
|
||||||
|
|
||||||
downloadBuffer.clear();
|
|
||||||
|
|
||||||
int bytesRead, fullLength = 0;
|
|
||||||
|
|
||||||
downloadMonitor.resetProgress(sizeGuess);
|
|
||||||
try {
|
|
||||||
downloadMonitor.setPokeThread(Thread.currentThread());
|
|
||||||
byte[] smallBuffer = new byte[1024];
|
|
||||||
while ((bytesRead = is.read(smallBuffer)) >= 0) {
|
|
||||||
downloadBuffer.put(smallBuffer, 0, bytesRead);
|
|
||||||
fullLength += bytesRead;
|
|
||||||
if (downloadMonitor.shouldStopIt()) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
downloadMonitor.updateProgress(fullLength);
|
|
||||||
}
|
|
||||||
is.close();
|
|
||||||
downloadMonitor.setPokeThread(null);
|
|
||||||
downloadBuffer.limit(fullLength);
|
|
||||||
downloadBuffer.position(0);
|
|
||||||
} catch (InterruptedIOException e) {
|
|
||||||
// We were interrupted by the stop button. We're stopping now.. clear interruption flag.
|
|
||||||
Thread.interrupted();
|
|
||||||
throw new Exception("Stop");
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
/*
|
|
||||||
* String cksum = generateChecksum(downloadBuffer); if (cksum.equals(validationHash)) {
|
|
||||||
*/
|
|
||||||
if (!target.exists()) target.createNewFile();
|
|
||||||
|
|
||||||
downloadBuffer.position(0);
|
|
||||||
FileOutputStream fos = new FileOutputStream(target);
|
|
||||||
fos.getChannel().write(downloadBuffer);
|
|
||||||
fos.close();
|
|
||||||
/*
|
|
||||||
* } else { throw new RuntimeException(String.
|
|
||||||
* format("The downloaded file %s has an invalid checksum %s (expecting %s). The download did not succeed correctly and the file has been deleted. Please try launching again."
|
|
||||||
* , target.getName(), cksum, validationHash)); }
|
|
||||||
*/
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private String checkExisting(Dependency dep) {
|
|
||||||
for (File f : modsDir.listFiles()) {
|
|
||||||
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
|
|
||||||
if (!vfile.matches() || !vfile.name.equals(dep.file.name)) continue;
|
|
||||||
|
|
||||||
if (f.renameTo(new File(v_modsDir, f.getName()))) continue;
|
|
||||||
|
|
||||||
deleteMod(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (File f : v_modsDir.listFiles()) {
|
|
||||||
VersionedFile vfile = new VersionedFile(f.getName(), dep.file.pattern);
|
|
||||||
if (!vfile.matches() || !vfile.name.equals(dep.file.name)) continue;
|
|
||||||
|
|
||||||
int cmp = vfile.version.compareTo(dep.file.version);
|
|
||||||
if (cmp < 0) {
|
|
||||||
System.out.println("Deleted old version " + f.getName());
|
|
||||||
deleteMod(f);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (cmp > 0) {
|
|
||||||
System.err.println(
|
|
||||||
"Warning: version of " + dep.file.name
|
|
||||||
+ ", "
|
|
||||||
+ vfile.version
|
|
||||||
+ " is newer than request "
|
|
||||||
+ dep.file.version);
|
|
||||||
return f.getName();
|
|
||||||
}
|
|
||||||
return f.getName(); // found dependency
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void load() {
|
|
||||||
scanDepInfos();
|
|
||||||
if (depMap.isEmpty()) return;
|
|
||||||
|
|
||||||
loadDeps();
|
|
||||||
activateDeps();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void activateDeps() {
|
|
||||||
for (Dependency dep : depMap.values()) if (dep.coreLib) addClasspath(dep.existing);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadDeps() {
|
|
||||||
downloadMonitor = FMLLaunchHandler.side().isClient() ? new Downloader() : new DummyDownloader();
|
|
||||||
try {
|
|
||||||
while (!depSet.isEmpty()) {
|
|
||||||
Iterator<String> it = depSet.iterator();
|
|
||||||
Dependency dep = depMap.get(it.next());
|
|
||||||
it.remove();
|
|
||||||
load(dep);
|
|
||||||
}
|
|
||||||
} finally {
|
|
||||||
if (popupWindow != null) {
|
|
||||||
popupWindow.setVisible(false);
|
|
||||||
popupWindow.dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void load(Dependency dep) {
|
|
||||||
dep.existing = checkExisting(dep);
|
|
||||||
if (dep.existing == null) // download dep
|
|
||||||
{
|
|
||||||
download(dep);
|
|
||||||
dep.existing = dep.file.filename;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<File> modFiles() {
|
|
||||||
List<File> list = new LinkedList<File>();
|
|
||||||
list.addAll(Arrays.asList(modsDir.listFiles()));
|
|
||||||
list.addAll(Arrays.asList(v_modsDir.listFiles()));
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scanDepInfos() {
|
|
||||||
for (File file : modFiles()) {
|
|
||||||
if (!file.getName().endsWith(".jar") && !file.getName().endsWith(".zip")) continue;
|
|
||||||
|
|
||||||
scanDepInfo(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scanDepInfo(File file) {
|
|
||||||
try {
|
|
||||||
ZipFile zip = new ZipFile(file);
|
|
||||||
ZipEntry e = zip.getEntry("dependancies.info");
|
|
||||||
if (e == null) e = zip.getEntry("dependencies.info");
|
|
||||||
if (e != null) loadJSon(zip.getInputStream(e));
|
|
||||||
zip.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.err.println("Failed to load dependencies.info from " + file.getName() + " as JSON");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadJSon(InputStream input) throws IOException {
|
|
||||||
InputStreamReader reader = new InputStreamReader(input);
|
|
||||||
JsonElement root = new JsonParser().parse(reader);
|
|
||||||
if (root.isJsonArray()) loadJSonArr(root);
|
|
||||||
else loadJson(root.getAsJsonObject());
|
|
||||||
reader.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadJSonArr(JsonElement root) throws IOException {
|
|
||||||
for (JsonElement node : root.getAsJsonArray()) loadJson(node.getAsJsonObject());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void loadJson(JsonObject node) throws IOException {
|
|
||||||
boolean obfuscated = ((LaunchClassLoader) DepLoader.class.getClassLoader())
|
|
||||||
.getClassBytes("net.minecraft.world.World") == null;
|
|
||||||
|
|
||||||
String testClass = node.get("class").getAsString();
|
|
||||||
if (DepLoader.class.getResource("/" + testClass.replace('.', '/') + ".class") != null) return;
|
|
||||||
|
|
||||||
String repo = node.get("repo").getAsString();
|
|
||||||
String filename = node.get("file").getAsString();
|
|
||||||
if (!obfuscated && node.has("dev")) filename = node.get("dev").getAsString();
|
|
||||||
|
|
||||||
boolean coreLib = node.has("coreLib") && node.get("coreLib").getAsBoolean();
|
|
||||||
|
|
||||||
Pattern pattern = null;
|
|
||||||
try {
|
|
||||||
if (node.has("pattern")) pattern = Pattern.compile(node.get("pattern").getAsString());
|
|
||||||
} catch (PatternSyntaxException e) {
|
|
||||||
System.err.println("Invalid filename pattern: " + node.get("pattern"));
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (pattern == null) pattern = Pattern.compile("(\\w+).*?([\\d\\.]+)[-\\w]*\\.[^\\d]+");
|
|
||||||
|
|
||||||
VersionedFile file = new VersionedFile(filename, pattern);
|
|
||||||
if (!file.matches()) throw new RuntimeException("Invalid filename format for dependency: " + filename);
|
|
||||||
|
|
||||||
addDep(new Dependency(repo, file, coreLib));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void addDep(Dependency newDep) {
|
|
||||||
if (mergeNew(depMap.get(newDep.file.name), newDep)) {
|
|
||||||
depMap.put(newDep.file.name, newDep);
|
|
||||||
depSet.add(newDep.file.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean mergeNew(Dependency oldDep, Dependency newDep) {
|
|
||||||
if (oldDep == null) return true;
|
|
||||||
|
|
||||||
Dependency newest = newDep.file.version.compareTo(oldDep.file.version) > 0 ? newDep : oldDep;
|
|
||||||
newest.coreLib = newDep.coreLib || oldDep.coreLib;
|
|
||||||
|
|
||||||
return newest == newDep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void load() {
|
|
||||||
if (inst == null) {
|
|
||||||
inst = new DepLoadInst();
|
|
||||||
inst.load();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getASMTransformerClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getModContainerClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSetupClass() {
|
|
||||||
return getClass().getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void injectData(Map<String, Object> data) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Void call() {
|
|
||||||
load();
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getAccessTransformerClass() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -60,7 +60,7 @@ object MaterialRenderHelper {
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
def render() = {
|
def render(): Unit = {
|
||||||
builder.render()
|
builder.render()
|
||||||
if (MicroblockMod.angelicaCompat != null)
|
if (MicroblockMod.angelicaCompat != null)
|
||||||
MicroblockMod.angelicaCompat.resetShaderMaterialOverride()
|
MicroblockMod.angelicaCompat.resetShaderMaterialOverride()
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ import scala.collection.JavaConversions._
|
|||||||
modid = "ForgeMicroblock",
|
modid = "ForgeMicroblock",
|
||||||
name = "Forge Microblocks",
|
name = "Forge Microblocks",
|
||||||
acceptedMinecraftVersions = "[1.7.10]",
|
acceptedMinecraftVersions = "[1.7.10]",
|
||||||
dependencies = "required-after:ForgeMultipart",
|
dependencies =
|
||||||
|
"required-after:CodeChickenCore@[1.4.3,);required-after:ForgeMultipart",
|
||||||
version = Tags.VERSION,
|
version = Tags.VERSION,
|
||||||
modLanguage = "scala"
|
modLanguage = "scala"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -305,10 +305,7 @@ class BlockMultipart extends Block(Material.rock) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override def getLightValue(world: IBlockAccess, x: Int, y: Int, z: Int): Int =
|
override def getLightValue(world: IBlockAccess, x: Int, y: Int, z: Int): Int =
|
||||||
getTile(world, x, y, z) match {
|
world.getBlockMetadata(x, y, z)
|
||||||
case null => 0
|
|
||||||
case tile => tile.getLightValue
|
|
||||||
}
|
|
||||||
|
|
||||||
override def randomDisplayTick(
|
override def randomDisplayTick(
|
||||||
world: World,
|
world: World,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ object MultipartRenderer
|
|||||||
f: Float
|
f: Float
|
||||||
) {
|
) {
|
||||||
val tmpart = t.asInstanceOf[TileMultipartClient]
|
val tmpart = t.asInstanceOf[TileMultipartClient]
|
||||||
if (tmpart.partList.isEmpty)
|
if (tmpart.partList.isEmpty | !tmpart.hasDynamicParts)
|
||||||
return
|
return
|
||||||
|
|
||||||
val state = CCRenderState.instance
|
val state = CCRenderState.instance
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
package codechicken.multipart
|
package codechicken.multipart
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity
|
import net.minecraft.tileentity.TileEntity
|
||||||
|
|
||||||
import scala.collection.mutable.ListBuffer
|
import scala.collection.mutable.ListBuffer
|
||||||
import codechicken.lib.packet.PacketCustom
|
import codechicken.lib.packet.PacketCustom
|
||||||
import codechicken.lib.vec.{Cuboid6, BlockCoord, Vector3}
|
import codechicken.lib.vec.{BlockCoord, Cuboid6, Vector3}
|
||||||
import net.minecraft.world.World
|
import net.minecraft.world.World
|
||||||
|
|
||||||
import java.util.List
|
import java.util.List
|
||||||
import net.minecraft.nbt.NBTTagCompound
|
import net.minecraft.nbt.NBTTagCompound
|
||||||
import codechicken.lib.data.MCDataOutput
|
import codechicken.lib.data.MCDataOutput
|
||||||
@@ -15,16 +17,20 @@ import codechicken.multipart.handler.{
|
|||||||
}
|
}
|
||||||
import net.minecraft.item.ItemStack
|
import net.minecraft.item.ItemStack
|
||||||
import net.minecraft.nbt.NBTTagList
|
import net.minecraft.nbt.NBTTagList
|
||||||
|
|
||||||
import java.util.Random
|
import java.util.Random
|
||||||
import net.minecraft.entity.item.EntityItem
|
import net.minecraft.entity.item.EntityItem
|
||||||
import net.minecraft.entity.player.EntityPlayer
|
import net.minecraft.entity.player.EntityPlayer
|
||||||
import net.minecraft.entity.Entity
|
import net.minecraft.entity.Entity
|
||||||
|
|
||||||
import scala.collection.JavaConversions._
|
import scala.collection.JavaConversions._
|
||||||
import java.util.Collection
|
import java.util.Collection
|
||||||
import codechicken.lib.raytracer.ExtendedMOP
|
import codechicken.lib.raytracer.ExtendedMOP
|
||||||
import net.minecraft.util.Vec3
|
import net.minecraft.util.{AxisAlignedBB, Vec3}
|
||||||
|
|
||||||
import java.lang.Iterable
|
import java.lang.Iterable
|
||||||
import codechicken.lib.world.IChunkLoadTile
|
import codechicken.lib.world.IChunkLoadTile
|
||||||
|
import net.minecraft.block.Block
|
||||||
|
|
||||||
class TileMultipart extends TileEntity with IChunkLoadTile {
|
class TileMultipart extends TileEntity with IChunkLoadTile {
|
||||||
|
|
||||||
@@ -34,6 +40,8 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
|
|
||||||
private var doesTick = false
|
private var doesTick = false
|
||||||
|
|
||||||
|
private var cachedLightValue: Int = 0
|
||||||
|
|
||||||
private[multipart] def from(that: TileMultipart) {
|
private[multipart] def from(that: TileMultipart) {
|
||||||
copyFrom(that)
|
copyFrom(that)
|
||||||
loadFrom(that)
|
loadFrom(that)
|
||||||
@@ -162,7 +170,51 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
*/
|
*/
|
||||||
def getWeakChanges = false
|
def getWeakChanges = false
|
||||||
|
|
||||||
def getLightValue = partList.view.map(_.getLightValue).max
|
def getLightValue: Int = cachedLightValue
|
||||||
|
|
||||||
|
override def shouldRefresh(
|
||||||
|
oldBlock: Block,
|
||||||
|
newBlock: Block,
|
||||||
|
oldMeta: Int,
|
||||||
|
newMeta: Int,
|
||||||
|
world: World,
|
||||||
|
x: Int,
|
||||||
|
y: Int,
|
||||||
|
z: Int
|
||||||
|
): Boolean = {
|
||||||
|
oldBlock != newBlock
|
||||||
|
}
|
||||||
|
|
||||||
|
private def updateLight(): Unit = {
|
||||||
|
if (partList.isEmpty) {
|
||||||
|
cachedLightValue = 0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var max = 0
|
||||||
|
val it = partList.iterator
|
||||||
|
while (it.hasNext) {
|
||||||
|
val l = it.next().getLightValue
|
||||||
|
if (l > max) max = l
|
||||||
|
}
|
||||||
|
cachedLightValue = max
|
||||||
|
|
||||||
|
if (
|
||||||
|
worldObj != null && worldObj.getBlockMetadata(
|
||||||
|
xCoord,
|
||||||
|
yCoord,
|
||||||
|
zCoord
|
||||||
|
) != cachedLightValue
|
||||||
|
) {
|
||||||
|
worldObj.setBlockMetadataWithNotify(
|
||||||
|
xCoord,
|
||||||
|
yCoord,
|
||||||
|
zCoord,
|
||||||
|
cachedLightValue,
|
||||||
|
3
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
def getExplosionResistance(entity: Entity) =
|
def getExplosionResistance(entity: Entity) =
|
||||||
partList.view.map(_.explosionResistance(entity)).max
|
partList.view.map(_.explosionResistance(entity)).max
|
||||||
@@ -284,6 +336,10 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
bindPart(part)
|
bindPart(part)
|
||||||
part.bind(this)
|
part.bind(this)
|
||||||
|
|
||||||
|
if (part.getLightValue > cachedLightValue) {
|
||||||
|
cachedLightValue = part.getLightValue
|
||||||
|
}
|
||||||
|
|
||||||
if (!doesTick && part.doesTick)
|
if (!doesTick && part.doesTick)
|
||||||
setTicking(true)
|
setTicking(true)
|
||||||
}
|
}
|
||||||
@@ -326,6 +382,8 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
if (r < 0)
|
if (r < 0)
|
||||||
throw new IllegalArgumentException("Tried to remove a non-existant part")
|
throw new IllegalArgumentException("Tried to remove a non-existant part")
|
||||||
|
|
||||||
|
val removedLightValue = part.getLightValue
|
||||||
|
|
||||||
part.preRemove()
|
part.preRemove()
|
||||||
partList = partList.filterNot(_ == part)
|
partList = partList.filterNot(_ == part)
|
||||||
|
|
||||||
@@ -336,6 +394,10 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
part.onRemoved()
|
part.onRemoved()
|
||||||
part.tile = null
|
part.tile = null
|
||||||
|
|
||||||
|
if (removedLightValue == cachedLightValue && removedLightValue > 0) {
|
||||||
|
updateLight()
|
||||||
|
}
|
||||||
|
|
||||||
if (partList.isEmpty) {
|
if (partList.isEmpty) {
|
||||||
worldObj.setBlockToAir(xCoord, yCoord, zCoord)
|
worldObj.setBlockToAir(xCoord, yCoord, zCoord)
|
||||||
} else {
|
} else {
|
||||||
@@ -357,6 +419,9 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
private[multipart] def loadParts(parts: scala.Iterable[TMultiPart]) {
|
private[multipart] def loadParts(parts: scala.Iterable[TMultiPart]) {
|
||||||
clearParts()
|
clearParts()
|
||||||
parts.foreach(p => addPart_do(p))
|
parts.foreach(p => addPart_do(p))
|
||||||
|
|
||||||
|
updateLight()
|
||||||
|
|
||||||
if (worldObj != null) {
|
if (worldObj != null) {
|
||||||
if (worldObj.isRemote)
|
if (worldObj.isRemote)
|
||||||
operate(_.onWorldJoin())
|
operate(_.onWorldJoin())
|
||||||
@@ -369,6 +434,7 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
*/
|
*/
|
||||||
def clearParts() {
|
def clearParts() {
|
||||||
partList = Seq()
|
partList = Seq()
|
||||||
|
cachedLightValue = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Writes the description of this tile, and all parts composing it, to packet
|
/** Writes the description of this tile, and all parts composing it, to packet
|
||||||
@@ -449,24 +515,108 @@ class TileMultipart extends TileEntity with IChunkLoadTile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
trait TileMultipartClient extends TileMultipart {
|
trait TileMultipartClient extends TileMultipart {
|
||||||
def renderStatic(pos: Vector3, pass: Int) =
|
private var cachedRenderBounds: AxisAlignedBB = null
|
||||||
partList.foldLeft(false)((r, part) => part.renderStatic(pos, pass) || r)
|
private var staticCache: Array[TMultiPart] = null
|
||||||
|
private var dynamicCache: Array[TMultiPart] = null
|
||||||
|
|
||||||
|
var hasDynamicParts: Boolean = false
|
||||||
|
|
||||||
|
def updateRenderCache() {
|
||||||
|
if (partList != null) {
|
||||||
|
val (dynamic, static) = partList.partition(_.doesTick)
|
||||||
|
val sArr = static.toArray
|
||||||
|
val dArr = dynamic.toArray
|
||||||
|
|
||||||
|
var c: Cuboid6 = null
|
||||||
|
var i = 0
|
||||||
|
val allParts = sArr ++ dArr
|
||||||
|
while (i < allParts.length) {
|
||||||
|
val b = allParts(i).getRenderBounds
|
||||||
|
if (c == null) c = b.copy
|
||||||
|
else c.enclose(b)
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c == null) c = Cuboid6.full
|
||||||
|
|
||||||
|
c.add(Vector3.fromTileEntity(this))
|
||||||
|
cachedRenderBounds = c.toAABB
|
||||||
|
staticCache = sArr
|
||||||
|
dynamicCache = dArr
|
||||||
|
hasDynamicParts = dArr.length > 0
|
||||||
|
} else {
|
||||||
|
staticCache = Array.empty
|
||||||
|
dynamicCache = Array.empty
|
||||||
|
hasDynamicParts = false
|
||||||
|
cachedRenderBounds = AxisAlignedBB.getBoundingBox(
|
||||||
|
xCoord,
|
||||||
|
yCoord,
|
||||||
|
zCoord,
|
||||||
|
xCoord + 1,
|
||||||
|
yCoord + 1,
|
||||||
|
zCoord + 1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def renderStatic(pos: Vector3, pass: Int) = {
|
||||||
|
if (staticCache == null) updateRenderCache()
|
||||||
|
var rendered = false
|
||||||
|
|
||||||
|
val statics = staticCache
|
||||||
|
if (statics != null) {
|
||||||
|
var i = 0
|
||||||
|
val len = statics.length
|
||||||
|
while (i < len) {
|
||||||
|
if (statics(i) != null && statics(i).renderStatic(pos, pass))
|
||||||
|
rendered = true
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val dynamics = dynamicCache
|
||||||
|
if (dynamics != null) {
|
||||||
|
var i = 0
|
||||||
|
val len = dynamics.length
|
||||||
|
while (i < len) {
|
||||||
|
if (dynamics(i) != null && dynamics(i).renderStatic(pos, pass))
|
||||||
|
rendered = true
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rendered
|
||||||
|
}
|
||||||
|
|
||||||
def renderDynamic(pos: Vector3, frame: Float, pass: Int) {
|
def renderDynamic(pos: Vector3, frame: Float, pass: Int) {
|
||||||
partList.foreach(part => part.renderDynamic(pos, frame, pass: Int))
|
if (!hasDynamicParts) return
|
||||||
|
|
||||||
|
val dynamics = dynamicCache
|
||||||
|
if (dynamics != null) {
|
||||||
|
var i = 0
|
||||||
|
val len = dynamics.length
|
||||||
|
while (i < len) {
|
||||||
|
if (dynamics(i) != null) dynamics(i).renderDynamic(pos, frame, pass)
|
||||||
|
i += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def randomDisplayTick(random: Random) {}
|
def randomDisplayTick(random: Random) {}
|
||||||
|
|
||||||
override def shouldRenderInPass(pass: Int) = {
|
override def shouldRenderInPass(pass: Int) = {
|
||||||
MultipartRenderer.pass = pass
|
MultipartRenderer.pass = pass
|
||||||
true
|
if (staticCache == null) updateRenderCache()
|
||||||
|
hasDynamicParts
|
||||||
}
|
}
|
||||||
|
|
||||||
override def getRenderBoundingBox = {
|
override def getRenderBoundingBox = {
|
||||||
val c = Cuboid6.full.copy
|
if (cachedRenderBounds == null) updateRenderCache()
|
||||||
partList.foreach(part => c.enclose(part.getRenderBounds))
|
cachedRenderBounds
|
||||||
c.add(Vector3.fromTileEntity(this)).toAABB
|
}
|
||||||
|
|
||||||
|
override def markRender(): Unit = {
|
||||||
|
super.markRender()
|
||||||
|
updateRenderCache()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,8 +30,11 @@ object MultipartEventHandler {
|
|||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
def worldUnLoad(event: WorldEvent.Unload) {
|
def worldUnLoad(event: WorldEvent.Unload) {
|
||||||
MultipartSPH.onWorldUnload(event.world)
|
MultipartSPH.onWorldUnload(event.world)
|
||||||
if (event.world.isRemote)
|
if (event.world.isRemote) {
|
||||||
TileCache.clear()
|
TileCache.clear()
|
||||||
|
} else {
|
||||||
|
MultipartSaveLoad.loadingWorld = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SubscribeEvent
|
@SubscribeEvent
|
||||||
|
|||||||
@@ -82,7 +82,11 @@ object MultipartCPH extends MultipartPH with IClientPacketHandler {
|
|||||||
for (i <- 0 until num)
|
for (i <- 0 until num)
|
||||||
TileMultipart.handleDescPacket(
|
TileMultipart.handleDescPacket(
|
||||||
world,
|
world,
|
||||||
indexInChunk(cc, packet.readShort),
|
new BlockCoord(
|
||||||
|
packet.readByte + (cc.chunkXPos << 4),
|
||||||
|
packet.readInt,
|
||||||
|
packet.readByte + (cc.chunkZPos << 4)
|
||||||
|
),
|
||||||
packet
|
packet
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -220,7 +224,9 @@ object MultipartSPH
|
|||||||
while (it.hasNext) {
|
while (it.hasNext) {
|
||||||
val tile = it.next
|
val tile = it.next
|
||||||
if (tile.isInstanceOf[TileMultipart]) {
|
if (tile.isInstanceOf[TileMultipart]) {
|
||||||
s.writeShort(indexInChunk(new BlockCoord(tile)))
|
s.writeByte(tile.xCoord & 0xf)
|
||||||
|
s.writeInt(tile.yCoord)
|
||||||
|
s.writeByte(tile.zCoord & 0xf)
|
||||||
tile.asInstanceOf[TileMultipart].writeDesc(s)
|
tile.asInstanceOf[TileMultipart].writeDesc(s)
|
||||||
num += 1
|
num += 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user