Everything posted by Tschallacka
-
null values in PlayerInteractEvent after a values filled interact event
no, this fires within if(!event.world.isRemote)
-
[Solved]Is there an event thats fired when the tick is done?
Thanks Jabelar, the ServerTickEvent was just the one I needed. I didnt realise it would fire twice. Thanks :-)
-
[Solved]Is there an event thats fired when the tick is done?
I was wondering if there is an event in forge that gets fired when all other events are done and the tick is ready and will wait until its time for the next tick?
-
null values in PlayerInteractEvent after a values filled interact event
Every time I use an item I get the normal PlayerInteractEvent and immedeatly another playerinteract event that has blockpos 0 0 0, facing null and it really serves no purpose except its annoying to have to account for it. A simple check with if(pos.getY() != 0) suffices, but it got me wondering why its even in there or what the purpose of this "null" event is? I traced it back to MinecraftServer.java at line 726 with public void updateTimeLightAndEntities() { this.theProfiler.startSection("jobs"); Queue queue = this.futureTaskQueue; synchronized (this.futureTaskQueue) { while (!this.futureTaskQueue.isEmpty()) { try { /*----->*/ net.minecraftforge.fml.common.FMLCommonHandler.callFuture(((FutureTask)this.futureTaskQueue.poll())); } catch (Throwable throwable2) { logger.fatal(throwable2); } } } I decided to purposely throw a wrench in the works to find it. So to recap, i'm merely curious why this one is there. it has all set to null basically with no reference to the originating thing that causes the event to be fired.
-
BlockEvents
yea, I was afraid you might say that. oh well, the complicated path it is then.
-
BlockEvents
Currently there is BlockEvent.PlaceEvent but it doesn't fire when lava is placed. I'd like an event that is fired ALWAYS when a block is replaced by an another block. Wether it be air by air, air by lava, grass by flowing_lava, air by falling gravel i'd like to be able to see /monitor what has happened. In this event i'd like an optional playerEntity when its present, like when a lava bucket is used. Currently I have to resort to getNearestPlayer() which might not always be accurate when a block is placed behind another player(in the case of lava of water for example) Currently i'm using a mix of PlayerUseItemEvent, NeighborNotifyEvent and the BlockPlaced event, but it gets really messy. What i'd prefer is an event that gets called upon setBlockState and prefably has a tie in with a player that caused it. Wether it be a fallingsand entity, tileentity, player wielding a bucket placing water/scooping water, an enderman picking up a block, it would be nice to be able to catch that event and assertain the source. I've had a peek around the source and I realise this may be impossible because setBlockState has no tie-ins to entities and getting the correct responsible entity might be hard/impossible. I'd also be happy if the NeighborNotifyEvent has a boolean appearedInSetBlock so you can filter that instead of having to make your own list to check if it has been there yet. that would save a lot of effort/cpu time too.
-
[1.8][solved-ish, bug, fix-ish in thread] GameRegistry.findblock returning null?
Figured out how to submit a bug ish ;-) http://www.minecraftforge.net/forum/index.php/topic,29993.0.html for those who just want to stay in the findBlock flow, I made this method. Tweak as you see fit /** * Tries to approach all legit ways to get a block from the game registry * but will go hackish when needed to to get the desired result. * @param modid String The modname * @param blockname String the block name * @return Blocks.air on not finding anything or the desired block. */ public static Block findBlock(String modid,String blockname) { Block find = GameRegistry.findBlock(modid,blockname); // legit way fails? if(find == null) { String searchkey = modid+":"+blockname; // Lets fire up the reflection... // You might want to put the map somewhere so you // don't have to reflect every time. saves a lot of cpu time. Class x = GameData.class; try { Method method = x.getDeclaredMethod("getMain"); method.setAccessible(true); GameData gamedata = (GameData)method.invoke(null); // and I mean saving the below list b FMLControlledNamespacedRegistry<Block> b = gamedata.getBlockRegistry(); // lets be gracious and give it a chance to find it this way if(b.containsKey(searchkey)) { find = b.getObject(searchkey); } else { // take a wild stab. returns air if nothing found find = b.getObject(searchkey); if(find != Blocks.air) { WhoTookMyCookies.log.warn("Chest found: "+GameRegistry.findUniqueIdentifierFor(b.getObject("minecraft:chest")).name); } else { if(!searchkey.equals("minecraft:air")) { // this is where we go and cry. // you can choose to leave find air which it is at this point // or set it to null... } } } } catch(Exception ex) { // your error handling here } } return find; }
-
[1.8]GameRegistry.findblock returns null
I use forge 8.0.76.1375 for Minecraft 1.8 When I try to use GameRegistry.findBlock("minecraft","chest"); it returns null; So I wrote this little testing code to see where it goes wrong. And it goes wrong in the containsKey method of the FMLControlledNamespacedRegistry I'm not sure why it won't find the map, but I did find some hits on stackoverflow that if a map is altered after its initialised the hashCode checks may fail in the buckets allowing for an "early" nothing found return. Maybe that helps a bit finding out why this thing does what it does. The testing code I used: Block chest = GameRegistry.findBlock("minecraft","chest"); WhoTookMyCookies.log.warn("Trying to do it how it should:" + chest); if(chest == null) { WhoTookMyCookies.log.warn("Failed to find it the legit way."); Class x = GameData.class; try { Method method = x.getDeclaredMethod("getMain"); method.setAccessible(true); GameData gamedata = (GameData)method.invoke(null); FMLControlledNamespacedRegistry<Block> b = gamedata.getBlockRegistry(); WhoTookMyCookies.log.warn("All keys currently in the registry. the minecraft:chest is actually in there. " + b.getKeys()); WhoTookMyCookies.log.warn("Testing for a false object that should not exist. should return air: " + b.getObject("minecraft:chestxxx")); WhoTookMyCookies.log.warn("Testing if chest exists with containsKey"); if(b.containsKey("minecraft:chest")) { WhoTookMyCookies.log.warn("registry.containsKey returned true on minecraft:chest"); } else { WhoTookMyCookies.log.warn("registry.containsKey returned false on minecraft:chest continue the hackish way"); WhoTookMyCookies.log.warn("Testing containsKey on the list itself by getting it and testing if its not air"); chest = b.getObject("minecraft:chest"); if(chest != Blocks.air) { WhoTookMyCookies.log.warn("Chest found: "+GameRegistry.findUniqueIdentifierFor(b.getObject("minecraft:chest")).name); } else { WhoTookMyCookies.log.warn("chest not found... this is the time to cry :`("); } } } catch(Exception ex) { ex.printStackTrace(); } if(this.item!=null) { BlocksBroken.restore(item, event.world); this.item = null; } } The complete latest log file. You can find the output of the above code at the end.
-
[1.8][solved-ish, bug, fix-ish in thread] GameRegistry.findblock returning null?
For those interested I found out the error occurs in the containsKey method. that always returns false. to get an object out of it though, you can use this. Class gdClass = GameData.class; try { Method method = gdClass.getDeclaredMethod("getMain"); method.setAccessible(true); GameData gamedata = (GameData)method.invoke(null); FMLControlledNamespacedRegistry<Block> b = gamedata.getBlockRegistry(); Loggingthingy.log.warn(b.getKeys());// All the keys are there... Block found = b.getObject("minecraft:chest"); if(found != Blocks.air) {// maybe add a check if you want an air block... // Do something with found, whatever.. } } catch(Exception ex) { ex.printStackTrace(); } Now, to figure out where to submit a bug report....
-
[1.8][solved-ish, bug, fix-ish in thread] GameRegistry.findblock returning null?
if I look at the logs the chest does get added, which the unique id implies to by giving back the name and modid. [17:55:18] [Client thread/TRACE] [FML/]: Registry add: minecraft:chest 54 net.minecraft.block.BlockChest@1f440e7 (req. id 54) so it is in the registry, but the findblock doesnt find it in the minecraft:chest combo. Going to try to open up by reflection the class now to see whats going on...
-
[1.8][solved-ish, bug, fix-ish in thread] GameRegistry.findblock returning null?
When I do block = GameRegistry.findBlock("minecraft", "chest"); it returns null. For all I can see in the GameData class is that it should work. Getting the UniqueIdentifier from a blockstate works perfectly so they are in there.. Yet they don't match when I try to get the block later. Does anyone have a workaround for it?
-
[1.7.10] mob spawns in custom structure.
So, i have this custum structure in my mod, the entropy temple. It registers the bounding boxes and all and i have hooked into the same spawning event that fetches the spawnlist from the nether fortress. I also implemented the same check if the mob is on the correct type of block, then add withers and blazes to the List As far as i can test it all works good under forge, but on my server that runs on cauldron it suddenly loads blazes and withers all over the place outside of the temples until i restart the server. Does anyone know if this is a cauldron thing? As far as i can check in the forge source the list with possible creatures gets deleted and rebuilt for every block where a spawn is happening. If its a cauldron thing i can just say yay, free withers heh.
-
Remove Anvil cost for Item
The cost is saved in nbt data of the item. Just echo out the nbtbase after naming it to see what the value is named. Then test for that value in the item update call and change it.
-
Server event that server is shutting down
okay, Is there any way to "pause" the shutting down until my mod has finished it's thing and then continue the shutting down?
-
[1.8] .obj file models in 1.8?
I already have a .obj model importer for the 1.7.10 system that imports .obj into the normal special renderer for blocks instead of the tileentityspecialrenderer. The only thing I can't figure out is how to get the rotation done because I dont have access to the open gl instance there to do the rotation for me because it's done outside of the gl scope. And I don't know if the current model rendering supports the same tweaks, I still have to look into that.
-
Translated JsonToNbt
Can't find a quick manual so okay. I really dont have time for this to figure out. I already lost an hour deciphering this, I have only precious time in my off hours work to get some modding done. I already shared it here. So it can be found by people who want it. But at this point in time im not spending my time on feeding it into the bot. I only have limited hours to work on my mods and I have so much to get done in the next two months. So if a volunteer wants to feed it into the bot, be my guest. I want to spend my time otherwise. My apologies if this is selfish.
-
Translated JsonToNbt
Heya, I translated JsonToNBt to something meaningful for my own purposes, thought i'd share it here. Maybe it helps with the deobfuscation of that piece of code. package tschallacka.whotookmycookies.nbt; import com.google.common.base.Splitter; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import java.util.Iterator; import java.util.Stack; import java.util.regex.Pattern; import net.minecraft.nbt.NBTBase; import net.minecraft.nbt.NBTException; import net.minecraft.nbt.NBTTagByte; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagDouble; import net.minecraft.nbt.NBTTagFloat; import net.minecraft.nbt.NBTTagInt; import net.minecraft.nbt.NBTTagIntArray; import net.minecraft.nbt.NBTTagList; import net.minecraft.nbt.NBTTagLong; import net.minecraft.nbt.NBTTagShort; import net.minecraft.nbt.NBTTagString; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; public class JSONtoNBT { private static final Logger logger = LogManager.getLogger(); private static final Pattern isIntegerOrStringArray = Pattern.compile("\\[[-+\\d|,\\s]+\\]"); private static final String __OBFID = "CL_00001232"; /** * Get a compound tag from json string * @param input JSON String input * @return NBTTagCompound with the correct values * @throws NBTException */ public static NBTTagCompound getCompoundTagFromString(String input) throws NBTException { input = input.trim(); // if the item starts with a { it's a compound object if (!input.startsWith("{")) { throw new NBTException("Invalid tag encountered, expected \'{\' as first char."); } else if (checkNumberOfTopTags(input) != 1) { throw new NBTException("Encountered multiple top tags, only one expected"); } else { return (NBTTagCompound)toJSONCompound("tag", input).getNBTValue(); } } static int checkNumberOfTopTags(String checkThis) throws NBTException { int encountered = 0; boolean flag = false; Stack stack = new Stack(); for (int i = 0; i < checkThis.length(); ++i) { char c0 = checkThis.charAt(i); //char 34 = " if (c0 == 34) { if (isValidJSONString(checkThis, i)) { if (!flag) { throw new NBTException("Illegal use of \\\": " + checkThis); } } else { flag = !flag; } } else if (!flag) { // 123 = { // 91 = [ if (c0 != 123 && c0 != 91) { // 123 = { // 125 = } if (c0 == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) { throw new NBTException("Unbalanced curly brackets {}: " + checkThis); } // 91 = [ // 93 = [ if (c0 == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) { throw new NBTException("Unbalanced square brackets []: " + checkThis); } } else { if (stack.isEmpty()) { ++encountered; } stack.push(Character.valueOf(c0)); } } } if (flag) { throw new NBTException("Unbalanced quotation: " + checkThis); } else if (!stack.isEmpty()) { throw new NBTException("Unbalanced brackets: " + checkThis); } else { if (encountered == 0 && !checkThis.isEmpty()) { encountered = 1; } return encountered; } } /** * Takes any number of elements array but will only use the first two elements of the array. * Will throw an ArrayIndexIsOutOfBounds exception when an array < 2 elements is supplied * @param arrayInputString Element at first index is name of object. Element at second index is contents * @return JSONtoNBT.Any * @throws NBTException, ArrayIndexOutOfBoundsException */ static JSONtoNBT.Any toJSONCompound(String ... arrayInputString) throws NBTException { return toJSONCompound(arrayInputString[0], arrayInputString[1]); } static JSONtoNBT.Any toJSONCompound(String name, String contents) throws NBTException { contents = contents.trim(); String subContents; boolean flag; char character; if (contents.startsWith("{")) { contents = contents.substring(1, contents.length() - 1); JSONtoNBT.Compound compound; for (compound = new JSONtoNBT.Compound(name); contents.length() > 0; contents = contents.substring(subContents.length() + 1)) { subContents = getValueFromJSONTag(contents, true); if (subContents.length() > 0) { flag = false; compound.arrayList.add(getJSONCompound(subContents, flag)); } if (contents.length() < subContents.length() + 1) { break; } character = contents.charAt(subContents.length()); // 44 = " // 123 = { // 125 = } // 91 = [ // 93 = ] if (character != 44 && character != 123 && character != 125 && character != 91 && character != 93) { throw new NBTException("Unexpected token \'" + character + "\' at: " + contents.substring(subContents.length())); } } return compound; } else if (contents.startsWith("[") && !isIntegerOrStringArray.matcher(contents).matches()) { contents = contents.substring(1, contents.length() - 1); JSONtoNBT.List list; for (list = new JSONtoNBT.List(name); contents.length() > 0; contents = contents.substring(subContents.length() + 1)) { subContents = getValueFromJSONTag(contents, false); if (subContents.length() > 0) { flag = true; list.arrayList.add(getJSONCompound(subContents, flag)); } if (contents.length() < subContents.length() + 1) { break; } character = contents.charAt(subContents.length()); if (character != 44 && character != 123 && character != 125 && character != 91 && character != 93) { throw new NBTException("Unexpected token \'" + character + "\' at: " + contents.substring(subContents.length())); } } return list; } else { return new JSONtoNBT.Primitive(name, contents); } } /** * Takes the string and returns the Compound key => value pair * @param parseThis The string to retrieve the values from * @param errorMode Should we throw exceptions or not * @return JSONtoNBTAny key => value compound * @throws NBTException */ private static JSONtoNBT.Any getJSONCompound(String parseThis, boolean errorMode) throws NBTException { String s1 = getKeyFromString(parseThis, errorMode); String s2 = getValueFromString(parseThis, errorMode); return toJSONCompound(new String[] {s1, s2}); } /** * Gets the value from a JSON string * @param searchThis The string to search for first colon * @param errorMode Will throw exceptions if true, none if set to false * @return String Value * @throws NBTException on invalid JSON && errorModeSilent is set to true */ private static String getValueFromJSONTag(String searchThis, boolean errorMode) throws NBTException { int locationOfColon = findCharacter(searchThis, ':'); int locationOfComma = findCharacter(searchThis, ','); if (errorMode) { if (locationOfColon == -1) { throw new NBTException("Unable to locate name/value separator for string: " + searchThis); } if (locationOfComma != -1 && locationOfComma < locationOfColon) { throw new NBTException("Name error at: " + searchThis); } } else if (locationOfColon == -1 || locationOfColon > locationOfComma) { locationOfColon = -1; } return getValueToKey(searchThis, locationOfColon); } private static String getValueToKey(String parseThis, int startPos) throws NBTException { Stack stack = new Stack(); int j = startPos + 1; boolean flag = false; boolean flag1 = false; boolean flag2 = false; for (int k = 0; j < parseThis.length(); ++j) { char character = parseThis.charAt(j); // 34 = " if (character == 34) { if (isValidJSONString(parseThis, j)) { if (!flag) { throw new NBTException("Illegal use of \\\": " + parseThis); } } else { flag = !flag; if (flag && !flag2) { flag1 = true; } if (!flag) { k = j; } } } else if (!flag) { if (character != 123 && character != 91) { // 123 = { // 125 = } if (character == 125 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 123)) { throw new NBTException("Unbalanced curly brackets {}: " + parseThis); } // 91 = [ // 93 = ] if (character == 93 && (stack.isEmpty() || ((Character)stack.pop()).charValue() != 91)) { throw new NBTException("Unbalanced square brackets []: " + parseThis); } // 44 = , if (character == 44 && stack.isEmpty()) { return parseThis.substring(0, j); } } else { stack.push(Character.valueOf(character)); } } if (!Character.isWhitespace(character)) { if (!flag && flag1 && k != j) { return parseThis.substring(0, k + 1); } flag2 = true; } } return parseThis.substring(0, j); } /** * Returns "" if it doesn't contain a key or contains a list/compound * @param parseThis The string to find the key from * @param errorMode Throws Exception if false when no key is found. * @return String key if found or string empty if not found * @throws NBTException */ private static String getKeyFromString(String parseThis, boolean errorMode) throws NBTException { if (errorMode) { parseThis = parseThis.trim(); if (parseThis.startsWith("{") || parseThis.startsWith("[")) { return ""; } } int i = findCharacter(parseThis, ':'); if (i == -1) { if (errorMode) { return ""; } else { throw new NBTException("Unable to locate name/value separator for string: " + parseThis); } } else { return parseThis.substring(0, i).trim(); } } /** * Gets the value of the string. * @param parseThis The string to retrieve the value from * @param errorMode if set to false it will throw an error if it can't find a valid value location * @return String value str * @throws NBTException */ private static String getValueFromString(String parseThis, boolean errorMode) throws NBTException { if (errorMode) { parseThis = parseThis.trim(); if (parseThis.startsWith("{") || parseThis.startsWith("[")) { return parseThis; } } int i = findCharacter(parseThis, ':'); if (i == -1) { if (errorMode) { return parseThis; } else { throw new NBTException("Unable to locate name/value separator for string: " + parseThis); } } else { return parseThis.substring(i + 1).trim(); } } private static int findCharacter(String input, char characterToFind) { int i = 0; for (boolean flag = true; i < input.length(); ++i) { char character = input.charAt(i); // 34 = " if (character == 34) { if (!isValidJSONString(input, i)) { flag = !flag;// good heavens... why not a break? } } else if (flag) { if (character == characterToFind) { return i; } if (character == 123 || character == 91) { return -1; } } } return -1; } private static boolean isValidJSONString(String parseThis, int locationToStart) { //92 = \ return locationToStart > 0 && parseThis.charAt(locationToStart - 1) == 92 && !isValidJSONString(parseThis, locationToStart - 1); } abstract static class Any { protected String key; private static final String __OBFID = "CL_00001233"; public abstract NBTBase getNBTValue(); } static class Compound extends JSONtoNBT.Any { protected java.util.List arrayList = Lists.newArrayList(); private static final String __OBFID = "CL_00001234"; public Compound(String p_i45137_1_) { this.key = p_i45137_1_; } public NBTBase getNBTValue() { NBTTagCompound nbttagcompound = new NBTTagCompound(); Iterator iterator = this.arrayList.iterator(); while (iterator.hasNext()) { JSONtoNBT.Any any = (JSONtoNBT.Any)iterator.next(); nbttagcompound.setTag(any.key, any.getNBTValue()); } return nbttagcompound; } } static class List extends JSONtoNBT.Any { protected java.util.List arrayList = Lists.newArrayList(); private static final String __OBFID = "CL_00001235"; public List(String keyValue) { this.key = keyValue; } public NBTBase getNBTValue() { NBTTagList nbttaglist = new NBTTagList(); Iterator iterator = this.arrayList.iterator(); while (iterator.hasNext()) { JSONtoNBT.Any any = (JSONtoNBT.Any)iterator.next(); nbttaglist.appendTag(any.getNBTValue()); } return nbttaglist; } } static class Primitive extends JSONtoNBT.Any { private static final Pattern DOUBLE = Pattern.compile("[-+]?[0-9]*\\.?[0-9]+[d|D]"); private static final Pattern FLOAT = Pattern.compile("[-+]?[0-9]*\\.?[0-9]+[f|F]"); private static final Pattern BYTE = Pattern.compile("[-+]?[0-9]+[b|B]"); private static final Pattern LONG = Pattern.compile("[-+]?[0-9]+[l|L]"); private static final Pattern STRING = Pattern.compile("[-+]?[0-9]+[s|S]"); private static final Pattern INTEGER = Pattern.compile("[-+]?[0-9]+"); private static final Pattern SECRETDOUBLE = Pattern.compile("[-+]?[0-9]*\\.?[0-9]+"); private static final Splitter COMMASPLITTER = Splitter.on(',').omitEmptyStrings(); protected String value; private static final String __OBFID = "CL_00001236"; public Primitive(String key, String value) { this.key = key; this.value = value; } public NBTBase getNBTValue() { try { if (DOUBLE.matcher(this.value).matches()) { return new NBTTagDouble(Double.parseDouble(this.value.substring(0, this.value.length() - 1))); } if (FLOAT.matcher(this.value).matches()) { return new NBTTagFloat(Float.parseFloat(this.value.substring(0, this.value.length() - 1))); } if (BYTE.matcher(this.value).matches()) { return new NBTTagByte(Byte.parseByte(this.value.substring(0, this.value.length() - 1))); } if (LONG.matcher(this.value).matches()) { return new NBTTagLong(Long.parseLong(this.value.substring(0, this.value.length() - 1))); } if (STRING.matcher(this.value).matches()) { return new NBTTagShort(Short.parseShort(this.value.substring(0, this.value.length() - 1))); } if (INTEGER.matcher(this.value).matches()) { return new NBTTagInt(Integer.parseInt(this.value)); } if (SECRETDOUBLE.matcher(this.value).matches()) { return new NBTTagDouble(Double.parseDouble(this.value)); } if (this.value.equalsIgnoreCase("true") || this.value.equalsIgnoreCase("false")) { return new NBTTagByte((byte)(Boolean.parseBoolean(this.value) ? 1 : 0)); } } catch (NumberFormatException numberformatexception1) { this.value = this.value.replaceAll("\\\\\"", "\""); return new NBTTagString(this.value); } if (this.value.startsWith("[") && this.value.endsWith("]")) { String s = this.value.substring(1, this.value.length() - 1); String[] astring = (String[])Iterables.toArray(COMMASPLITTER.split(s), String.class); try { int[] aint = new int[astring.length]; for (int j = 0; j < astring.length; ++j) { aint[j] = Integer.parseInt(astring[j].trim()); } return new NBTTagIntArray(aint); } catch (NumberFormatException numberformatexception) { return new NBTTagString(this.value); } } else { if (this.value.startsWith("\"") && this.value.endsWith("\"")) { this.value = this.value.substring(1, this.value.length() - 1); } this.value = this.value.replaceAll("\\\\\"", "\""); StringBuilder stringbuilder = new StringBuilder(); for (int i = 0; i < this.value.length(); ++i) { if (i < this.value.length() - 1 && this.value.charAt(i) == 92 && this.value.charAt(i + 1) == 92) { stringbuilder.append('\\'); ++i; } else { stringbuilder.append(this.value.charAt(i)); } } return new NBTTagString(stringbuilder.toString()); } } } }
-
Server event that server is shutting down
Really simple question but I cant seem to find the answer. When I search it all I find is gazillions of crash reports. So basically, is there an event that gets fired when the server has gotten an interrupt?
-
[1.8] Help needed with gradle and shadowJar
For a 1.8 mod i'm making I need to use sqlite Now I have found a nice standalone jar https://bitbucket.org/xerial/sqlite-jdbc/downloads(the 1.8.6 one, the 1.8.7 is bugged on unix) I spent a long time with http://www.minecraftforge.net/forum/index.php?topic=18864.0 and fiddling around with a build.gradle and now i'm at a point where I actually have the sqlite jar included in my mod jar, and forge starts up with it(took me long enough to get this far, 2 hours at least) But then, the feeling of triumph faded... net.minecraft.launchwrapper.Launch.main(Launch.java:28) Caused by: java.lang.NoClassDefFoundError: org/sqlite/core/NativeDB Darn, the references dont line up anymore. So I'm guessing i'm missing a shadowjar reference somewhere where its supposed to rewrite my classes to reference the new classpaths, only I cant figure out which option to enable in my build.gradle to set shadow jar to rewrite my jar. My current build.grade buildscript { repositories { mavenCentral() maven { name = "forge" url = "http://files.minecraftforge.net/maven" } maven { name = "sonatype" url = "https://oss.sonatype.org/content/repositories/snapshots/" } maven { name = "shadow" url "https://plugins.gradle.org/m2/" } } dependencies { classpath 'net.minecraftforge.gradle:ForgeGradle:1.2-SNAPSHOT' classpath "com.github.jengelman.gradle.plugins:shadow:1.2.1" } } apply plugin: 'java' // or 'groovy'. Must be explicitly applied apply plugin: 'com.github.johnrengelman.shadow' shadowJar { relocate 'org.sqlite','tschallacka.whotookmycookies.org.sqlite' } apply plugin: 'forge' version = "0.0.0.1" group= "tschallacka.whotookmycookies.WhoTookMyCookies" // http://maven.apache.org/guides/mini/guide-naming-conventions.html archivesBaseName = "WhoTookMyCookies" minecraft { version = "1.8-11.14.1.1375" runDir = "eclipse" // the mappings can be changed at any time, and must be in the following format. // snapshot_YYYYMMDD snapshot are built nightly. // stable_# stables are built at the discretion of the MCP team. // Use non-default mappings at your own risk. they may not allways work. // simply re-run your setup task after changing the mappings to update your workspace. mappings = "snapshot_20141130" } processResources { // this will ensure that this task is redone when the versions change. inputs.property "version", project.version inputs.property "mcversion", project.minecraft.version // replace stuff in mcmod.info, nothing else from(sourceSets.main.resources.srcDirs) { include 'mcmod.info' // replace version and mcversion expand 'version':project.version, 'mcversion':project.minecraft.version } // copy everything else, thats not the mcmod.info from(sourceSets.main.resources.srcDirs) { exclude 'mcmod.info' } } // Include external libs in compilation and jar configurations { external compile.extendsFrom external } dependencies { // you may put jars on which you depend on in ./libs // or you may define them like so.. //compile "some.group:artifact:version:classifier" //compile "some.group:artifact:version" // real examples //compile 'com.mod-buildcraft:buildcraft:6.0.8:dev' // adds buildcraft to the dev env //compile 'com.googlecode.efficient-java-matrix-library:ejml:0.24' // adds ejml to the dev env // for more info... // http://www.gradle.org/docs/current/userguide/artifact_dependencies_tutorial.html // http://www.gradle.org/docs/current/userguide/dependency_management.html } jar { from { configurations.external.collect { it.isDirectory() ? it : zipTree(it) } } } // Let Shadow do its thing build.dependsOn shadowJar Anyone here have experience with shadowJar and how to set it up so it rewrites my classes to reference the correct classes? Also, how can I tell it to overwrite my obfuscated classes instead of the deobfuscated classes. Because it does its magic on the deobfuscated classes. The mod file(it crashes on the dirt printing, comment that out to get the noclassdeffound error) package tschallacka.whotookmycookies; import net.minecraft.init.Blocks; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLInitializationEvent; import java.sql.*; @Mod(modid = WhoTookMyCookies.MODID, version = WhoTookMyCookies.VERSION) public class WhoTookMyCookies { public static final String MODID = "WhoTookMyCookies"; public static final String VERSION = "0.0.0.1"; @EventHandler public void init(FMLInitializationEvent event) { // some example code System.out.println("DIRT BLOCK >> "+Blocks.dirt.getUnlocalizedName()); Connection c = null; try { Class.forName("org.sqlite.JDBC"); c = DriverManager.getConnection("jdbc:sqlite:test.db"); } catch ( Exception e ) { System.err.println( e.getClass().getName() + ": " + e.getMessage() ); System.exit(0); } System.out.println("Opened database successfully"); } }
-
[1.7.10]Entity Rendering Problem
I have 3 walking ghosts when you are drunk in my 1.7.10 magiccookies mod. The hop, dance and move to the player. You need to spawn them with if(world.isRemote)// means is client Then you need to hook into a tick event that ticks every client tick to steer the entities. Also make sure your client isnt set to peaceful. You need to manually give them commands what to do. stuff like pathfinding etc... doesnt work. you need to manually write the code what they should do. You need to sever all links to the server, because the server will mark them as invalid and kill them off, so dont call any methods that do server updates(like onupdate, hitplayer etc...) just do things like movearm, crouch, etc... all the clientside stuff. As soon as something expects server input it sees its not valid, and it kills itself.
-
[1.8] [SOLVED] TintIndex: Anyone gotten it to do anything useful?
I believe its for biome colouring. Like leaves and grass changing colour in different biomes. So you would set tint index to true and and implement the change color upon biome thing. If 1.8 still supports custom block renderers you could patch in a shader there that shades the vertexes to the color you want.
-
[1.8] how do you store nbttags in a block ??
you need to attach a tileentity to your block. The tile entity can store NBT tags(and do other fun stuff). http://www.orangetutorial.com/tile-entity/#sthash.A0mSVOdk.dpbs
-
[1.8] writing json to create an structure what library is avaliable ???
I use linux too. Java is platform independant.(granted a few caveats with external libaries, but thats all) I have nothing special in my main class. The .getClass() method is available in every class, in every method. I just like to put outside pointers starting at a logical place. You can call ANYWHERE in your code getClass().getResource('/assets/modmercenario/extructuras/structure.json'); Move the doors to the last of your json file. Doors need a block to stand on or they will break. Doors, torches, itemframes, grass, ladders, all need to come as last. The only thing that comes to my mind is... does forge make a jar when you open the test client or does it load files from disc? I can see some issues from that. You might want to modify it that if you are on test server you load from disc.
-
[1.8] writing json to create an structure what library is avaliable ???
I use json because its a standard, and it is interexchangeable with other applications without them needing a custom parser. Also if you look at my json you see i save mod and blocknames and metadata. I just define them once so i save the file space so parsing will be faster. No use having 2000 times MagicCookies BlockDarkstone if i can replace it with a shorter id. And there is always room for fills. Air within chambers, walls, walkways. A series of short fills of 2-3 blocks is faster than singular placement of each block.
-
[1.7.10] [SOLVED] Get all blocks in virtual pyramid.
Entities can be a pain yea. Is it only living entities? Try worldObj.getEntitiesWithinAABB(Boundingbox) That way only entities within the bounding box are selected.
IPS spam blocked by CleanTalk.