
mnn
Members-
Posts
298 -
Joined
-
Last visited
Everything posted by mnn
-
not this way, in a same loop (the for) you'd test a block to figure out if its class is what you want. similar code to this one should do the trick: for(int i=0; i<Block.blocksList.length; i++){ Block current = Block.blocksList[i]; if(current != null){ if("stone".equals(current.getBlockName())){ // found block by its name (stone) }else{ String className = current.getClass().getCanonicalName(); if (className.equals("net.minecraft.block.BlockGrass")) { //found a block by its class name (grass) } } } }
-
adding a field in EntityPlayer but without modify it
mnn replied to legendaire45's topic in Modder Support
you could try the EntityJoinWorldEvent approach (if you're talking about datawatchers). the NBT tag alone would suffice if only a server needs access to those data in a player. -
here's some working code, take a look (pay attention to the highlighted stuff): https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/client/ClientProxy.java#L51 https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/common/CommonProxy.java#L9 https://github.com/mnn/jaffas/blob/master/src/minecraft/monnef/jaffas/food/mod_jaffas_food.java#L415 you should be able modify your code to do it same way .
-
adding a field in EntityPlayer but without modify it
mnn replied to legendaire45's topic in Modder Support
persistent NBT tag wouldn't suffice? -
I somewhere read that when creating a recipe you can pass it an enchanted item as a result and it should work. EDIT: Yep, it works. Sample code: ItemStack hoe = new ItemStack(hoeJaffarrol); hoe.addEnchantment(Enchantment.fortune, 2); // << hoe.addEnchantment(Enchantment.unbreaking, 2); // << GameRegistry.addRecipe(hoe, "JJL", "LS ", " S ", 'J', jaffarrol, 'S', Item.stick, 'L', limsew);
-
you cannot call an addArmor on a server side (server doesn't need to know how to render armor, hence the @SideOnly(CLIENT) annotation), your item creation seems odd. also it's a bad practice to use hard-coded IDs of blocks/items, it should be read from a config.
-
definitely not a source of the problem. I'm using this code and it's working fine (it has no SideOnly annotation): @Override public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { if (info != null) par3List.add(info); } ----- if you'd want to add tags and use them for showing text I'd done it like this (in a real version there would be more checks present): public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List par3List, boolean par4) { par3List.add(par1ItemStack.getTagCompound().getString("myTitle")); } and NBT would be set in drop event of a monster (if you're generating drops from mobs than you can easily add a tag to generated ItemStack). don't know about trades, haven't done anything with villagers, but I'd expect that you'll be creating your items for them as well.
-
I heard that on really low level world-gen is not possible to work with higher block IDs (but I haven't done it myselft so it might not be true). you could move your blocks for world-gen to lower IDs (<256). if you're using forge config you can obtain lower IDs by calling getTerrainBlock method instead of getBlock.
-
I'm pretty sure you shouldn't be using scheduleBlockUpdateFromLoad . It's not clear from your question, the block is working on a server side? If you're calling scheduleBlockUpdate in updateTick it should be. You're asking us, how to synchronize inner state of block? Well, without TileEntity the block is synchronized automatically, only data it can hold is one number - metadata (automatically as long as you're changing it with "notify" version of method, e.g. setBlockMetadataWithNotify ). If you want to have saved more than 4bits then you have to implement TE and possibly synchronize both sides using TE packets. one thead with this topic can be found here - http://www.minecraftforge.net/forum/index.php/topic,6261.msg33322.html#msg33322 . EDIT: the "notify" methods notify neighbours of the block, it should work even without them.
-
if the block can be uniquely identified by its class name, you can get and compare it like this: String className = testedBlock.getClass().getCanonicalName(); if (className.equals("net.minecraft.block.BlockGrass")) { //found grass! } it is possible that the mod's block is not setting its name, because there's ItemBlock handling this block (block name is mainly used for getting title for user). you probably could look at all items searching for ones named after block you're looking for. after getting this item you'd simply cast it to ItemBlock and use getBlockID . remarks: cache your findings, do NOT search IDs more than once (probably in/from your @init method) after MC started mark your mod to load after mods which blocks you're using
-
by its name or class. lets say you're looking for a block named "stone", you'd just iterate over all blocks and look if it's the one you want. for(int i=0; i<Block.blocksList.length; i++){ Block current = Block.blocksList[i]; if(current != null && "stone".equals(current.getBlockName())){ // found block } } I wrote you the easy way, use Loader.isModLoaded to check if the mod is present. If you need just IDs I don't see any reason why use reflection, also it might be illegal without consent of mod developer.
-
problem persists. I looked closely at the clean FF and I discovered that the cloudflare's javascript is crashing on a different error: Timestamp: 05/03/2013 10:28:20 Error: SecurityError: The operation is insecure. Source File: http://ajax.cloudflare.com/cdn-cgi/nexp/abv=4114775854/cloudflare.min.js Line: 20 No one else using FF is having these problems?
-
in the posted example I synchronize fields "rotation" and "type". markBlockForUpdate forces server to send update to a client; onDataPacket is fired when client recieves synchronization packet from server, client gets data from unpacked tag from packet and saves it to its TE (=synchronize it); getDescriptionPacket is called on a server-side when TE on client needs to be synchronized, so server here puts data to NBT tag and that packs into a packet.
-
in your GUI actionPerformed method: I would move packet code to a helper class, but the main problem is, GUI is opened only on a client-side so it's pointless to have there "if (side == Side.SERVER)". I can't see where you are setting newly selected value from GUI to TE on a client. You don't synchronize TEs, it's probably responsible for the problem you're describing. But I might overlooked something, there's tons of code... EDIT: ehm, looking at posts, I already write you how to synchronize TE O_0. http://www.minecraftforge.net/forum/index.php/topic,6261.msg33322.html#msg33322
-
It's entirely possible that's my fault, my english is not great. On a server side you can use NBT and the persistent tag. It's not common to hold data only on a client side. Usually this kind of things is done like this: client wants to change a mode, sends packet to a server, server changes mode sends updating packet to the client, client changes mode. This way you can at any moment access mode on a server and when using NBT in a player entity it's automaticly saved. If you want to save your class on a client you can use the java serialization and save it to the config folder, or serialize your class manualy using forge config class, or use separate NBTs and serialize it to file (haven't done that, but it's possible). I'm not in a modding for a long time, imho this should be answered by someone more experienced...
-
yep, reflection. when I first saw that in C# I was quite stunned . For performance reasons I'd done setting access stuff only after datawatcher creation (in contructor of your entity?) and also the Method instance could be cached in your entity. But I might be wrong, don't have many experience with Java reflection. (But on the other hand, those changes shouldn't break anything.)
-
I'm not sure I understand what you want. Your mod is being executed on a client side as well, you can check where you're running using e.g. FMLCommonHandler or proxy. For holding data you just create some fields in your mod's class and use them. Is it that simple or you're want something more? Saving stuff on a client side is also possible, simple example is the config file (more complex stuff you would probably have to write on your own, I don't know about anything in forge/fml that would allow this type of thing. java's serialization is not bad, you could use that. or simple property file). Synchronization of not many data could be done via datawatchers, but they're quite limited and also your mod could conflict with other mods. Custom packets are the best way imho.
-
I'd use reflection to access the HashMap and insert my values. Something similar to this maybe: Field f = PotionHelper.class.getDeclaredField("potionRequirements"); f.setAccessible(true); HashMap myPotionRequirements = (HashMap) f.get(null); //add stuff to myPotionRequirements variable
-
not setting a title does not cuase a crash (tested). the error java.lang.NoClassDefFoundError: net/minecraft/creativetab/CreativeTabs cannot be interpreted many ways. it surely looks like obfuscation didn't happen...
-
it's your entity, you can modify its datawatcher's getWatchedObject flags to be public in entity constructor. but invoking method via reflection won't be cheap . using transformer in this case seems a bit like overkill, I'd go with that custom fixed point decimal type. PS: I was wrong, invoking method via reflection is actually (after some time) same as doing it the native way . http://stackoverflow.com/a/414823/1017211
-
did you grab reobfuscated classes (reobf directory)?
-
example of TE synchronization: https://github.com/mnn/jaffas/blob/59b59f01a1f2f6b21b0dc87e5a15e6761a3f3f19/src/minecraft/monnef/jaffas/food/block/TileEntityPie.java#L117
-
this awaits me too. after browsing through NEI api I'm not really eager to start working on it - api seems a bit too complex. some tutorial or example plugin (simple mod, not whole NEI) would be useful, unfortunately I haven't seen one.
-
that's the items, but with blocks it doesn't seem to be that easy. Maybe using "getSubBlocks" (but I don't know what par2CreativeTabs actually means - will it be always just block's tab or will this method be called for every tab?). Cannot be done using sub blocks, it's only called on assigned tab and search tab. Maybe messing with ItemBlock would it solve, but it seems like a bit ugly solution.