Skip to content

Instantly share code, notes, and snippets.

@StillManic
Created August 11, 2015 17:42
Show Gist options
  • Save StillManic/640849535008e1ab26f6 to your computer and use it in GitHub Desktop.
Save StillManic/640849535008e1ab26f6 to your computer and use it in GitHub Desktop.
public class CoasterPack {
public enum Type {
FOLDER, ZIP
}
private Type type;
private String name;
private ZipFile zipFile;
// private HashMap<String, BlockTrack> tracks = new HashMap<>();
private HashMap<String, CoasterStyle> styles = Maps.newHashMap();
public CoasterPack(Type type, String name, ZipFile zipFile) {
this.type = type;
this.name = name;
this.zipFile = zipFile;
//TODO: lang files?
}
public String getName() {
return this.name;
}
public Type getType() {
return this.type;
}
public String getDirectory() {
return RC2.packsDir + "\\";
// return Reference.RELATIVE_PACKS_DIR + name + "/";
}
public InputStream getInputStream(String path) throws IOException {
switch (type) {
case FOLDER:
File file = new File(getDirectory() + path);
if (!file.isFile()) return null;
return FileUtils.openInputStream(file);
case ZIP:
if (zipFile != null) {
ZipEntry entry = zipFile.getEntry(path);
return entry == null ? null : zipFile.getInputStream(entry);
}
default: throw new IOException("Unknown pack type: " + type);
}
}
public void registerStyles() {
RC2.logger.info("Registering Styles");
CoasterStyle style = null;
OBJModel model = null;
String styleName = "";
for (File packs : FileUtils.getFile(this.getDirectory()).listFiles()) {
for (File file : FileUtils.getFile(packs.getPath() + "/coasters/").listFiles()) {
styleName = file.getName();
RC2.logger.info(styleName);
for (File file1 : file.listFiles()) {
RC2.logger.info(file1.getName());
if (file1.getName().equals("style.json")) {
try {
style = JsonParser.GSON.fromJson(new InputStreamReader(new FileInputStream(file1)), CoasterStyle.class);
style.setJsonLocation(new ResourceLocation(RC2.MODID + ":" + file1.getPath()));
style.setModelLocation(new ResourceLocation(RC2.MODID + ":" + file1.getPath().substring(0, file1.getPath().length() - "style.json".length()) + "model.obj"));
} catch (IOException e) {
e.printStackTrace();
}
} else if (file1.getName().equals("model.obj")) {
// model = new OBJModel(new FileInputStream(file1), file.getPath());
// style.setModelLocation(new ResourceLocation(RC2.MODID + ":" + file1.getPath()));
// model = (OBJModel) OBJLoader.instance.loadModel(new ResourceLocation(RC2.MODID + ":" + file1.getPath()));
model = (OBJModel) OBJLoader.instance.loadModel(new ResourceLocation(RC2.MODID + ":" + file1.getPath().substring(file1.getPath().indexOf("packs"), file1.getPath().length())));
}
}
}
}
RC2.logger.info("Style null: " + Boolean.toString(style == null));
RC2.logger.info("Model null: " + Boolean.toString(model == null));
if (style != null) {
if (model != null) {
style.setModel(model);
StyleRegistry.INSTANCE.register(styleName.isEmpty() ? style.getName() : styleName, style, model);
} else {
StyleRegistry.INSTANCE.register(styleName.isEmpty() ? style.getName() : styleName, style);
}
this.styles.put(styleName.isEmpty() ? style.getName() : styleName, style);
}
}
public HashMap<String, CoasterStyle> getStyles() {
return this.styles;
}
}
public class CoasterStyle {
private final String name;
private final CategoryEnum category;
private final List<String> pieces = Lists.newArrayList();
private final List<String> trainCars = Lists.newArrayList();
private ResourceLocation jsonLocation;
private ResourceLocation modelLocation;
private OBJModel model;
public CoasterStyle(String name, CategoryEnum category, List<String> pieces, List<String> trainCars) {
this.name = name;
this.category = category;
this.pieces.addAll(pieces);
this.trainCars.addAll(trainCars);
}
public String getName() {
return this.name;
}
public String getDisplayName() {
StringBuilder builder = new StringBuilder();
Lists.newArrayList(this.name.split("_")).forEach(s -> builder.append(s.toUpperCase() + " "));
builder.deleteCharAt(builder.length() - 1);
return builder.toString();
}
public void setJsonLocation(ResourceLocation location) {
this.jsonLocation = jsonLocation;
}
public ResourceLocation getJsonLocation() {
return this.jsonLocation;
// return new ResourceLocation(Reference.RELATIVE_PACKS_DIR + "coasters/" + this.name + "/style.json");
// return new ResourceLocation(RC2.MODID.toLowerCase() + ":" + "coasters/" + this.name + "/style.json");
}
public void setModelLocation(ResourceLocation location) {
this.modelLocation = location;
}
public ResourceLocation getModelLocation() {
return this.modelLocation;
// return new ResourceLocation(Reference.RELATIVE_PACKS_DIR + "coasters/" + this.name + "/model.obj");
// return new ResourceLocation(RC2.MODID.toLowerCase() + ":" + "coasters/" + this.name + "/model.obj");
}
public CategoryEnum getCategory() {
return this.category;
}
public List<String> getPieces() {
return this.pieces;
}
public List<String> getTrainCars() {
return this.trainCars;
}
// public Material getBlockMaterial() {
// switch (this.category) {
// case STEEL:
// case WATER: //TODO: custom material?
// case INVERTED: return Material.iron;
// case WOODEN: return Material.wood;
// case MISC:
// default: return Material.rock;
// }
// }
public void registerBlock() {
RC2Blocks.trackMap.put(this.category, new BlockTrack(this));
GameRegistry.registerBlock(RC2Blocks.trackMap.get(this.category), ItemTrack.class, RC2Blocks.trackMap.get(this.category).getUnlocalizedName());
// GameRegistry.registerTileEntity(TileEntityTrack.class, RC2Blocks.trackMap.get(this.category).getUnlocalizedName());
// switch (this.category) {
// case STEEL:
// RC2Blocks.track_steel = new BlockTrack(Material.iron, "steel");
// GameRegistry.registerBlock(RC2Blocks.track_steel, ItemTrack.class, RC2Blocks.track_steel.getUnlocalizedName());
// GameRegistry.registerTileEntity(TileEntityTrack.class, RC2Blocks.track_steel.getUnlocalizedName());
// break;
// case WOODEN:
// RC2Blocks.track_wood = new BlockTrack(Material.wood, "wooden");
// GameRegistry.registerBlock()
// }
}
// public void registerBlocks() {
// for (String s : this.pieces) {
// BlockTrack track = new BlockTrack(this, s);
//// track.setBlockTextureName(this.model.getMaterialLibrary().getGroups().get(s).get)
// GameRegistry.registerBlock(track, ItemTrack.class, track.getUnlocalizedName());
// GameRegistry.registerTileEntity(TileEntityTrack.class, track.getUnlocalizedName());
// }
// }
// public void registerItemTrackRenderer() {
// if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) {
// for (String s : this.pieces) {
// BlockTrack track = GameRegistry.findBlock()
// }
// }
// }
public void setModel(OBJModel model) {
this.model = model;
}
public OBJModel getModel() {
return this.model;
}
}
Connected to the target VM, address: '127.0.0.1:53988', transport: 'socket'
[10:41:09] [main/INFO]: username: [email protected]
[10:41:09] [main/INFO]: Extra: []
[10:41:09] [main/INFO]: Password found, attempting login
[10:41:09] [main/INFO]: Logging in with username & password
[10:41:11] [main/INFO]: Login Succesful!
[10:41:11] [main/INFO]: Running with arguments: [--userProperties, [{"name":"twitch_access_token","value":"fnpsih9tsgq7wgs04619cbzxwfu024d"}], --assetsDir, C:/Users/Gerald/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --userType, mojang, --accessToken, {REDACTED}, --version, 1.8, --uuid, 1487d900d7a847b494cf0cd5ddf9160e, --username, shadekiller666, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]
[10:41:11] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[10:41:11] [main/INFO]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker
[10:41:11] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker
[10:41:11] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker
[10:41:11] [main/INFO]: Forge Mod Loader version 8.99.205.1502 for Minecraft 1.8 loading
[10:41:11] [main/INFO]: Java is Java HotSpot(TM) 64-Bit Server VM, version 1.8.0_45, running on Windows 8.1:amd64:6.3, installed at C:\Program Files\Java\jdk1.8.0_45\jre
[10:41:11] [main/INFO]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation
[10:41:11] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker
[10:41:11] [main/INFO]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin
[10:41:11] [main/INFO]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin
[10:41:11] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:41:11] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[10:41:11] [main/INFO]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[10:41:11] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:41:11] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker
[10:41:11] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[10:41:11] [main/ERROR]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!
[10:41:13] [main/ERROR]: FML appears to be missing any signature data. This is not a good thing
[10:41:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper
[10:41:13] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker
[10:41:14] [main/INFO]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker
[10:41:14] [main/INFO]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker
[10:41:14] [main/INFO]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker
[10:41:14] [main/INFO]: Launching wrapped minecraft {net.minecraft.client.main.Main}
[10:41:16] [Client thread/INFO]: Setting user: shadekiller666
[10:41:19] [Client thread/INFO]: LWJGL Version: 2.9.1
[10:41:19] [Client thread/INFO]: [net.minecraftforge.fml.client.SplashProgress:start:235]: ---- Minecraft Crash Report ----
// My bad.
Time: 8/11/15 10:41 AM
Description: Loading screen debug info
This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_45, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 856700816 bytes (817 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML:
Loaded coremods (and transformers):
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1062.1002' Renderer: 'AMD Radeon HD 7800 Series'
[10:41:19] [Client thread/INFO]: Attempting early MinecraftForge initialization
[10:41:19] [Client thread/INFO]: MinecraftForge v11.14.3.1502 Initialized
[10:41:19] [Client thread/INFO]: Replaced 204 ore recipies
[10:41:19] [Client thread/INFO]: Completed early MinecraftForge initialization
[10:41:20] [Client thread/INFO]: Found 0 mods from the command line. Injecting into mod discoverer
[10:41:20] [Client thread/INFO]: Searching C:\Users\Gerald\Documents\GitHub\Rollercoaster2\run\mods for mods
[10:41:24] [Client thread/INFO]: Forge Mod Loader has identified 4 mods to load
[10:41:24] [Client thread/INFO]: Attempting connection with missing mods [mcp, FML, Forge, rc2] at CLIENT
[10:41:24] [Client thread/INFO]: Attempting connection with missing mods [mcp, FML, Forge, rc2] at SERVER
[10:41:24] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:§4§lRollercoaster 2
[10:41:24] [Client thread/INFO]: Processing ObjectHolder annotations
[10:41:24] [Client thread/INFO]: Found 384 ObjectHolder annotations
[10:41:24] [Client thread/INFO]: Identifying ItemStackHolder annotations
[10:41:24] [Client thread/INFO]: Found 0 ItemStackHolder annotations
[10:41:24] [Client thread/INFO]: Configured a dormant chunk cache size of 0
[10:41:24] [Client thread/INFO]: Registering pack: default
[10:41:25] [Client thread/INFO]: Applying holder lookups
[10:41:25] [Client thread/INFO]: Holder lookups applied
[10:41:25] [Client thread/INFO]: Injecting itemstacks
[10:41:25] [Client thread/INFO]: Itemstack injection complete
[10:41:25] [Sound Library Loader/INFO]: Starting up SoundSystem...
[10:41:25] [Thread-9/INFO]: Initializing LWJGL OpenAL
[10:41:25] [Thread-9/INFO]: (The LWJGL binding of OpenAL. For more information, see http://www.lwjgl.org)
[10:41:25] [Thread-9/INFO]: OpenAL initialized.
[10:41:25] [Sound Library Loader/INFO]: Sound engine started
[10:41:26] [Twitch authenticator/ERROR]: Given twitch access token is invalid
[10:41:28] [Client thread/INFO]: Max texture size: 16384
[10:41:28] [Client thread/INFO]: Created: 16x16 textures-atlas
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:item.rc2.hammer#inventory not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:tile.rc2.entrance#normal not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:tile.rc2.entrance#inventory not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:item.rc2.themePark#inventory not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:item.rc2.goldenScoop#inventory not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:item.rc2.scoop#inventory not found
[10:41:29] [Client thread/ERROR]: Model definition for location rc2:item.rc2.cone#inventory not found
[10:41:29] [Client thread/INFO]: Registering pack: default
[10:41:29] [Client thread/ERROR]: A coaster pack has already been registered with name default
[10:41:29] [Client thread/INFO]: Registering Styles
[10:41:29] [Client thread/INFO]: test_coaster
[10:41:29] [Client thread/INFO]: model.mtl
[10:41:29] [Client thread/INFO]: model.obj
[10:41:29] [Client thread/INFO]: style.json
[10:41:29] [Client thread/INFO]: Style null: false
[10:41:29] [Client thread/INFO]: Model null: false
[10:41:29] [Client thread/INFO]: Style registered: test_coaster
[10:41:29] [Client thread/ERROR]: Caught an exception during block registration
java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418) ~[?:1.8.0_45]
at java.util.ArrayList.set(ArrayList.java:446) ~[?:1.8.0_45]
at net.minecraft.util.ObjectIntIdentityMap.put(ObjectIntIdentityMap.java:25) ~[ObjectIntIdentityMap.class:?]
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:840) ~[GameData.class:?]
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:802) ~[GameData.class:?]
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:220) [GameRegistry.class:?]
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:188) [GameRegistry.class:?]
at rcteam.rc2.rollercoaster.CoasterStyle.registerBlock(CoasterStyle.java:87) [CoasterStyle.class:?]
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$null$9(StyleRegistry.java:89) [StyleRegistry.class:?]
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$12/526566451.accept(Unknown Source) [StyleRegistry.class:?]
at java.util.HashMap.forEach(HashMap.java:1280) [?:1.8.0_45]
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$registerBlocks$10(StyleRegistry.java:89) [StyleRegistry.class:?]
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$11/1912710034.accept(Unknown Source) [StyleRegistry.class:?]
at java.util.Map.forEach(Map.java:630) [?:1.8.0_45]
at rcteam.rc2.rollercoaster.StyleRegistry.registerBlocks(StyleRegistry.java:89) [StyleRegistry.class:?]
at rcteam.rc2.RC2.init(RC2.java:105) [RC2.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) [FMLModContainer.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) [LoadController.class:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) [LoadController.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) [guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) [guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) [guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:316) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:529) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
[10:41:29] [Client thread/ERROR]: Fatal errors were detected during the transition from INITIALIZATION to POSTINITIALIZATION. Loading cannot continue
[10:41:29] [Client thread/ERROR]:
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1502.jar)
UCHI Forge{11.14.3.1502} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1502.jar)
UCHE rc2{v0.1} [§4§lRollercoaster 2] (Rollercoaster2)
[10:41:29] [Client thread/ERROR]: The following problems were captured during this phase
[10:41:29] [Client thread/ERROR]: Caught exception from rc2
net.minecraftforge.fml.common.LoaderException: java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:231) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:188) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at rcteam.rc2.rollercoaster.CoasterStyle.registerBlock(CoasterStyle.java:87) ~[Rollercoaster2/:?]
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$null$9(StyleRegistry.java:89) ~[Rollercoaster2/:?]
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$12/526566451.accept(Unknown Source) ~[?:?]
at java.util.HashMap.forEach(HashMap.java:1280) ~[?:1.8.0_45]
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$registerBlocks$10(StyleRegistry.java:89) ~[Rollercoaster2/:?]
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$11/1912710034.accept(Unknown Source) ~[?:?]
at java.util.Map.forEach(Map.java:630) ~[?:1.8.0_45]
at rcteam.rc2.rollercoaster.StyleRegistry.registerBlocks(StyleRegistry.java:89) ~[Rollercoaster2/:?]
at rcteam.rc2.RC2.init(RC2.java:105) ~[Rollercoaster2/:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) ~[guava-17.0.jar:?]
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) ~[guava-17.0.jar:?]
at com.google.common.eventbus.EventBus.post(EventBus.java:275) ~[guava-17.0.jar:?]
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119) [LoadController.class:?]
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731) [Loader.class:?]
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:316) [FMLClientHandler.class:?]
at net.minecraft.client.Minecraft.startGame(Minecraft.java:529) [Minecraft.class:?]
at net.minecraft.client.Minecraft.run(Minecraft.java:356) [Minecraft.class:?]
at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_45]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_45]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_45]
at java.lang.reflect.Method.invoke(Method.java:497) ~[?:1.8.0_45]
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) [start/:?]
at GradleStart.main(Unknown Source) [start/:?]
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418) ~[?:1.8.0_45]
at java.util.ArrayList.set(ArrayList.java:446) ~[?:1.8.0_45]
at net.minecraft.util.ObjectIntIdentityMap.put(ObjectIntIdentityMap.java:25) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:840) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:802) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:220) ~[forgeSrc-1.8-11.14.3.1502.jar:?]
... 49 more
[10:41:29] [Client thread/INFO]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: ---- Minecraft Crash Report ----
// I blame Dinnerbone.
Time: 8/11/15 10:41 AM
Description: There was a severe problem during mod loading that has caused the game to fail
net.minecraftforge.fml.common.LoaderException: java.lang.ArrayIndexOutOfBoundsException: -1
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:231)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:188)
at rcteam.rc2.rollercoaster.CoasterStyle.registerBlock(CoasterStyle.java:87)
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$null$9(StyleRegistry.java:89)
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$12/526566451.accept(Unknown Source)
at java.util.HashMap.forEach(HashMap.java:1280)
at rcteam.rc2.rollercoaster.StyleRegistry.lambda$registerBlocks$10(StyleRegistry.java:89)
at rcteam.rc2.rollercoaster.StyleRegistry$$Lambda$11/1912710034.accept(Unknown Source)
at java.util.Map.forEach(Map.java:630)
at rcteam.rc2.rollercoaster.StyleRegistry.registerBlocks(StyleRegistry.java:89)
at rcteam.rc2.RC2.init(RC2.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)
at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)
at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)
at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)
at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)
at com.google.common.eventbus.EventBus.post(EventBus.java:275)
at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)
at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:731)
at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:316)
at net.minecraft.client.Minecraft.startGame(Minecraft.java:529)
at net.minecraft.client.Minecraft.run(Minecraft.java:356)
at net.minecraft.client.main.Main.main(Main.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)
at GradleStart.main(Unknown Source)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
at java.util.ArrayList.elementData(ArrayList.java:418)
at java.util.ArrayList.set(ArrayList.java:446)
at net.minecraft.util.ObjectIntIdentityMap.put(ObjectIntIdentityMap.java:25)
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:840)
at net.minecraftforge.fml.common.registry.GameData.registerBlock(GameData.java:802)
at net.minecraftforge.fml.common.registry.GameRegistry.registerBlock(GameRegistry.java:220)
... 49 more
A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------
-- System Details --
Details:
Minecraft Version: 1.8
Operating System: Windows 8.1 (amd64) version 6.3
Java Version: 1.8.0_45, Oracle Corporation
Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation
Memory: 802138008 bytes (764 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0
FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1502 4 mods loaded, 4 mods active
States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored
UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar)
UCHI FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1502.jar)
UCHI Forge{11.14.3.1502} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1502.jar)
UCHE rc2{v0.1} [§4§lRollercoaster 2] (Rollercoaster2)
Loaded coremods (and transformers):
GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13399 Compatibility Profile Context 15.200.1062.1002' Renderer: 'AMD Radeon HD 7800 Series'
[10:41:29] [Client thread/INFO]: [net.minecraft.init.Bootstrap:printToSYSOUT:663]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\Gerald\Documents\GitHub\Rollercoaster2\run\.\crash-reports\crash-2015-08-11_10.41.29-client.txt
Disconnected from the target VM, address: '127.0.0.1:53988', transport: 'socket'
AL lib: (EE) alc_cleanup: 1 device not closed
Java HotSpot(TM) 64-Bit Server VM warning: Using incremental CMS is deprecated and will likely be removed in a future release
Process finished with exit code -1
public class FileManager implements IResourceManagerReloadListener {
private static Map<String, CoasterPack> packRegistry = new HashMap<>();
public static CoasterPack readPack(File file) {
CoasterPack.Type type;
String name;
ZipFile zipFile = null;
if (file.isDirectory()) {
name = file.getName();
type = CoasterPack.Type.FOLDER;
} else if (file.getName().endsWith(".zip")) {
name = file.getName().substring(0, file.getName().length() - 4);
type = CoasterPack.Type.ZIP;
try {
zipFile = new ZipFile(file);
} catch (IOException e) {
RC2.logger.error("Could not read zip file {} :\n", file.getName(), e);
}
} else {
RC2.logger.error("Skipping {}, not a valid coaster pack file.", file.getName());
return null;
}
CoasterPack pack = new CoasterPack(type, name, zipFile);
packRegistry.put(name, pack);
return pack;
}
public static Map<String, CoasterPack> getPackRegistry() {
return packRegistry;
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
//TODO!
// FMLClientHandler.instance().getResourcePackFor(RC2.MODID).
}
}
@Mod(modid = RC2.MODID, name = RC2.NAME, version = RC2.VERSION)
public class RC2 {
public static final String MODID = "rc2";
public static final String NAME = "Roller Coaster 2";
public static final String VERSION = "v0.1";
public static HashMap<String, CoasterPack> packs = new HashMap<>();
@Instance
public static RC2 instance;
@SidedProxy(clientSide="rcteam.rc2.proxy.ClientProxy", serverSide="rcteam.rc2.proxy.CommonProxy")
public static CommonProxy proxy;
public static String srcDir;
public static String packsDir;
public static Logger logger;
public static CreativeTabs tab;
public static final PacketPipeline packetPipeline = new PacketPipeline();
@EventHandler
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit();
srcDir = event.getSourceFile().getAbsolutePath();
packsDir = srcDir + "\\assets\\" + MODID + "\\packs\\";
logger = LogManager.getLogger(NAME);
tab = new CreativeTabs(NAME) {
@Override
@SideOnly(Side.CLIENT)
public Item getTabIconItem() {
return null;
}
@Override
@SideOnly(Side.CLIENT)
public ItemStack getIconItemStack() {
return new ItemStack(RC2Items.hammer);
}
};
if (event.getSide() == Side.CLIENT) {
readPackFolder();
}
// readPackFolder();
// getListPacks().stream().forEach(CoasterPack::registerStyles);
// StyleRegistry.INSTANCE.registerBlocks();
RC2Items.preInit();
RC2Blocks.preInit();
}
@EventHandler
public void init(FMLInitializationEvent event) {
packetPipeline.initalise();
readPackFolder();
getListPacks().stream().forEach(CoasterPack::registerStyles);
StyleRegistry.INSTANCE.registerBlocks();
proxy.init();
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
}
@EventHandler
public void postInit(FMLPostInitializationEvent event) {
packetPipeline.postInitialise();
}
@EventHandler
public void serverStarting(FMLServerStartingEvent event) {
((CommandHandler) event.getServer().getCommandManager()).registerCommand(new GiveThemeParkCommand());
// event.registerServerCommand(new GiveThemeParkCommand());
}
public static void readPackFolder() {
// logger.info("reading pack folder");
// logger.info(srcDir + "\\assets\\rc2\\packs\\");
File packsFolder = new File(packsDir);
for (File pack : packsFolder.listFiles()) {
CoasterPack coasterPack = FileManager.readPack(pack);
if (coasterPack != null) register(coasterPack);
}
}
public static Collection<CoasterPack> getListPacks() {
return packs.values();
}
public static void register(CoasterPack pack) {
logger.info("Registering pack: " + pack.getName());
if (packs.get(pack.getName()) == null) RC2.packs.put(pack.getName(), pack);
else logger.error("A coaster pack has already been registered with name {}", pack.getName());
}
public static CoasterPack getPack(String name) {
return packs.get(name);
}
public static CoasterPack getPackContainingStyle(CoasterStyle style) {
return packs.values().stream().filter(pack -> pack.getStyles().containsKey(style.getName())).findFirst().get();
}
}
public class StyleRegistry {
public static StyleRegistry INSTANCE = new StyleRegistry();
private Map<CategoryEnum, Map<String, CoasterStyle>> registry = Maps.newEnumMap(CategoryEnum.class);
private Map<CategoryEnum, Map<String, OBJModel>> modelRegistry = Maps.newEnumMap(CategoryEnum.class);
private StyleRegistry() {
Lists.newArrayList(CategoryEnum.values()).forEach(categoryEnum -> this.registry.put(categoryEnum, Maps.newHashMap()));
Lists.newArrayList(CategoryEnum.values()).forEach(categoryEnum -> this.modelRegistry.put(categoryEnum, Maps.newHashMap()));
}
public Map<CategoryEnum, Map<String, CoasterStyle>> getRegistry() {
return this.registry;
}
public Map<CategoryEnum, Map<String, OBJModel>> getModelRegistry() {
return this.modelRegistry;
}
public void register(CoasterStyle style) {
this.register(style.getName(), style, null);
}
public void register(CoasterStyle style, OBJModel obj) {
this.register(style.getName(), style, obj);
}
public void register(String name, CoasterStyle style) {
this.register(name, style, null);
}
@SuppressWarnings("unchecked")
public void register(String name, CoasterStyle style, OBJModel obj) {
if (style != null) {
this.registry.get(style.getCategory()).put(name, style);
this.modelRegistry.get(style.getCategory()).put(name, obj);
RC2.logger.info(String.format("Style registered: %s", name));
}
}
public boolean replaceStyleInRegistry(String name, CoasterStyle replacement) {
if (!name.equals(replacement.getName()) || !hasNameBeenRegistered(name)) return false;
registry.values().stream().filter(stringCoasterStyleMap -> stringCoasterStyleMap.containsKey(name)).findAny().get().replace(name, replacement);
return true;
}
public boolean replaceModelInRegistry(String name, OBJModel replacement) {
if (!hasNameBeenRegistered(name)) return false;
modelRegistry.values().stream().filter(stringFileMap -> stringFileMap.containsKey(name)).findAny().get().replace(name, replacement);
return true;
}
public Map<String, CoasterStyle> getStylesFromCategory(CategoryEnum category) {
return registry.get(category);
}
public Map<String, OBJModel> getModelsFromCategory(CategoryEnum category) {
return modelRegistry.get(category);
}
public boolean hasNameBeenRegistered(String name) {
return registry.values().stream().anyMatch(stringCoasterStyleMap -> stringCoasterStyleMap.containsKey(name)) || modelRegistry.values().stream().anyMatch(stringFileMap -> stringFileMap.containsKey(name));
}
public CoasterStyle getStyleByName(String name) {
return hasNameBeenRegistered(name) ? registry.values().stream().filter(stringCoasterStyleMap -> stringCoasterStyleMap.containsKey(name)).findFirst().get().get(name) : null;
}
public OBJModel getModelByName(String name) {
return hasNameBeenRegistered(name) ? modelRegistry.values().stream().filter(stringFileMap -> stringFileMap.containsKey(name)).findFirst().get().get(name) : null;
}
public void registerBlocks() { //TODO: can we get away with only registering 1 BlockTrack?
this.registry.forEach((categoryEnum1, stringCoasterStyleMap) -> stringCoasterStyleMap.forEach((s, style) -> style.registerBlock()));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment