Jump to content

Yagoki

Members
  • Posts

    290
  • Joined

  • Last visited

Everything posted by Yagoki

  1. I'm guessing I have to register this somewhere... can't find where that's done that in the questology code. I can see the class, but not how they let the game know that this needs to be included when they save the game. Sorry for being a bit slow to get all this.
  2. Can't find anything under that name I'll carry on looking for something similar. Just out of curiosity, do you know of any opensource mods on git hub or something which add save data like this? would probably speed up the process a bit.
  3. OK thanks I'll have a play around with that and see what I come up with.
  4. I'm working on a warp system for my mod and need to be able to save the location, channel/frequency and dimension of all the "nodes" in the system. What I need to know is how to add this save data to the world or create a custom file to save these to. It would also be nice if this could be done in a way which the player can not mess with too easily.
  5. if you want to do this with the item you can do @Override public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10) { if(!par3World.isRemote && par1World.getBlockID(par4, par5, par6) == myBlock.blockID) { par3World.setBlock(par4, par5, par6, myOtherBlock.blockID); } return super.onItemUse(par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10); } if you want this in the block, similarly you can do: @Override public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9) { if(par5EntityPlayer.getHeldItem().itemID == myItem.itemID) { par5EntityPlayer.getHeldItem().stackSize -= 1; //only if you want to use the item when you do this. if(par1World.isRemote) { par1World.setBlock(par2, par3, par4, myBlock.blockID); } } return super.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9); } EDIT: This could cause some funky stuff with containers so make sure you think of a way to handle the inventory when you do this, Not going to do that for you, as it would take me too long and I've got stuff to do for my mod.
  6. This is correct. In my mod I do something similar, I found the following to be a fairly good way of handling my config if it helps you: (if you don't understand what's going on just say) Item constructor. public ItemBase(int id, String localName, String dispName) { super(Config.getItem(id, localName)); setUnlocalizedName(localName); setCreativeTab(Tabs.tabMTechWorld); subTypes.put(0, new String[]{localName, dispName}); GameRegistry.registerItem(this, localName); LanguageRegistry.addName(this, dispName); } and handling my config package mtech.common; import net.minecraftforge.common.Configuration; public class Config { public static boolean keepSand = true; public static Configuration config; public static int getBlock(int defaultId, String name) { return config.getBlock(name, defaultId).getInt(); } public static int getItem(int defaultId, String name) { return config.getItem(name, defaultId + 256).getInt() - 256; } public static boolean generateOre(String name) { return config.get(Configuration.CATEGORY_GENERAL, "generate_" + name, true).getBoolean(true); } public static void doInitialConfig(Configuration conf) { config = conf; config.load(); } } Main mod file: @PreInit public static void preInit(FMLPreInitializationEvent evt) { Config.doInitialConfig(new Configuration(evt.getSuggestedConfigurationFile())); Blocks.addBlocks(); Items.addItems(); Config.config.save(); Recipies.addRecipies(); GameRegistry.registerWorldGenerator(new WorldGen()); NetworkRegistry.instance().registerGuiHandler(instance, new MyGuiHandler()); }
  7. Trust me, I very much do not need to, The block has no, and needs no container. I was submitting this as an example to the topic starter on how to do this properly. A container is only needed when the block ether stores items or has inventory slots (e.g. a chest or anvil). If the block does not need this, there is no requirement for the container, so null can be passed to the server GUI element. If this didn't work, then my GUI wouldn't work which I can assure you it does.
  8. you should have some methods like the following: to open the GUI you should have something like this: @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { TileEntity tileEntity = world.getBlockTileEntity(x, y, z); if (tileEntity == null || player.isSneaking()) { return false; } player.openGui(MTech.instance, 0, world, x, y, z); return true; } GUI handler: should be something like this: https://github.com/Yagoki/MTech/blob/master/MTech/mtech/handler/gui/MyGuiHandler.java The get server GUI element returns false due to the fact none of my blocks have a container (no inventory slots). Also in your main mod file (with all the annotations) make sure there is something lie this line in one of the init methods NetworkRegistry.instance().registerGuiHandler(instance, new MyGuiHandler()); all of my source code is on github(https://github.com/Yagoki/MTech/) if you want to look through it if you still can't figure it out. (also if you still cant figure it out, there is a tutorial on the wiki which is still quite good, if you can get on there, i seem to be having some trouble with that at the moment). If you get stuck with anything else just say (once you've given it a good shot trying to solve it yourself) Hope all that's useful to you
  9. Hi guys, Managed to get my proximity detector working with my gui, but i have a small bug at the moment which i'm not too sure about. The debug lines i added to my code to see what it was doing are saying that the variable is not being reset in the client. This doesn't appear to be having any real effect but i don't like the idea that it's there and would rater fix it so it doesn't break anything in the future, also i've got a feeling it's the reason there's a small amount of flickering in the texture when the field is toggled off. the console output making me think this: //first loaded 2013-05-22 16:36:15 [iNFO] [sTDOUT] null+ANALOG+|true 2013-05-22 16:36:15 [iNFO] [sTDOUT] null+ANALOG+|false //PLAYERS field activated 2013-05-22 16:36:23 [iNFO] [sTDOUT] null+PLAYERS+ANALOG+|false 2013-05-22 16:36:23 [iNFO] [sTDOUT] null+PLAYERS+ANALOG+|true //PLAYERS field deactivated 2013-05-22 16:23:38 [iNFO] [sTDOUT] null+PLAYERS+ANALOG+|true 2013-05-22 16:23:38 [iNFO] [sTDOUT] null+ANALOG+|false the true and false bits are the output from worldObj.isRemote in the tileentity the null at the start exists due to how i load the data from the nbt, don't think it should be causing any problems and the fix is simple enough, just an extra if statement to see if the field exists in the nbt before trying to add anything to the set. block code:https://github.com/Yagoki/MTech/blob/master/MTech/mtech/block/BlockProximityDetector.java tileentity code:https://github.com/Yagoki/MTech/blob/master/MTech/mtech/tileentity/TileEntityProximityDetector.java gui code: https://github.com/Yagoki/MTech/blob/master/MTech/mtech/client/gui/GuiProximityDetector.java packet handler code: https://github.com/Yagoki/MTech/blob/master/MTech/mtech/handler/packet/MyPacketHandler.java if you need anymore of my code it's all on there, and should all be the latest push. [EDIT] fixed it, the problem was i was the list on the client wasn't removing stuff, fixed it by adding a method to clear the Set before it is updated in the onDataPacket method in the tileentity
  10. just another small question, what do i need to send packets for (and how do i do/handle this properly)? I'm trying to do it so that the range, and detection types in my proximity detector can be changed, so do i need to send a packet each time one of these buttons is pressed, and also how do i send and use the data on the button? also, where is the id for the gui defined? in the following line form your code it is called, but i can't see where it is created or how to know what it will be. par5EntityPlayer.openGui(Interlock.instance, 2, world, x, y, z); [EDIT] Also, can i see how you registered your package handlers and channels, doing it in the same way as the wiki tutorial gave me a crash saying that the channel name was incorrect or something.
  11. This is my first time trying to make a gui, and i'm not quite sure how to go about it. I want to add a gui to my proximity detector so that the range and functions can be changed. I've already set up the fields i feel will be necessary in the TileEntity, which is currently working as expected. I tried looking through the tutorial on the wiki which didn't really help with what i want to do (as far as i could tell) and didn't explain it in a way which made it so i could understand everything which was going on. I need buttons so that i can change the entity types it will detect, and also the range on the detector. If somebody could walk me through the basics of this that would be great
  12. again not too sure about this one, just trying to be helpful. try calling the writeToNBT(NBTTagCompound) method in the TileEntity, as it adds this par1NBTTagCompound.setString("EntityId", this.getEntityNameToSpawn()); to the tagCompound. I'm guessing that's what you're looking for. Looking further through the code before i post this, you can call func_98049_a().getEntityNameToSpawn() from the TileEntityMobSpawner which will return the mobID... I think
  13. Not sure if this would work, but there is the following method which could be used to get the NBTTags and such when the block starts to be broken. This could be a bit of a work around if you don't want to use asm, as you may be able to save the tile entity from the parameters given, then give the player the item when the block is broken. no tested it though as don't have too much time to play about with these things at the moment /** * Called before a block is broken. Return true to prevent default block harvesting. * * Note: In SMP, this is called on both client and server sides! * * @param itemstack The current ItemStack * @param X The X Position * @param Y The X Position * @param Z The X Position * @param player The Player that is wielding the item * @return True to prevent harvesting, false to continue as normal */ public boolean onBlockStartBreak(ItemStack itemstack, int X, int Y, int Z, EntityPlayer player) { return false; } my thinking is that you could use player.worldObj.getBlockTileEntity(X, Y, Z) to save the tile-entity before it is broken, then assign the data to an item in the onBlockDestroyed method, which would then get spawned in the world. Of cause you would have to check that the block is a spawner or whatever, and remove the data from the item if the player stops breaking the block. let me know if this helps (again i've not tried this, but to me it looks possible like this)
  14. What minecraft version are you using? the suggestion form the error is that your minecraft version does not match that of the one expected by FML. check that your MC version is 1.5.2 (i.e. all your jars and such are from 1.5.2) and possibly update your forge to the latest, as the one you are using appears to be the earliest build for 1.5.2, and forge updates often (get the latest from here http://files.minecraftforge.net/)
  15. Thanks for replying, turns out the problem was me putting my source in the wrong location in the src folder being too thick to realize that that was wrong. Sorry for wasting your time, but thank you for trying to help as it caused me to realize my error when looking through/for the things you asked for.
  16. I'm trying to get an early release of my mod done and keep having errors when running the getchangedsrc. The mod runs fine in eclipse, and i have no errors in my source. When i run getchangedsrc it says "cannot find server m5ds" then doesn't output anything, I've tried re installing my mcp which didn't do anything and tried looking around google but couldn't find anything useful. I've also tried running "recompile" which said cannot find server source so didn't do anything, and "reobf" which got as far as saying extracting files, then said cannot find server md5s and didn't output anything. any advice as to what to try next?
  17. I have a basic tile entity set up, and want to be able to make it so that the texture on it changes to that of an adjacent block or a block it is clicked with, though i'm not quite sure how to handle this. I tried looking through the code for mffs, as i guessed the force field blocks were doing something like this but couldn't make heads or tales of it. I'm going to carry on looking through it and probably analyze it a bit more, but i was wandering if anyone on here could give me some advice, or other places to look. Thanks in advance.
  18. on the tick handler I don't think the problem is with the client. The client shows the player flying fine until the server sends its "idea" of the player to the client when events such as damage happen occur, as these happen on the server. (at least that's how i understand it, i've not looked into it too far so i could be wrong). I will try what you said and probably ad some debug lines to see if i can figure out why it's acting weirdly. [EDIT] well that worked! Thanks, even though it wasn't my problem... haha. if someone could explain to me why that was necessary that would be super.
  19. I thought of that (see my first reply to this topic), but that doesn't remove the ability once the armor has been removed, so doesn't really have the desired effect. Does work better than my method though, so if a workaround for this exists then use this. (but the if(!world.isRemote) is not required as both the client and server need to know the player can fly for it to work properly) [EDIT] a possible work around would exist if multiple pieces of armor were being worn, as you could check the armor inventory before enabling the flight, and then deactivate if a piece is missing, however i'm not sure how this would respond on death or some more peculiar case when all the pieces are removed simultaneously
  20. finally got to a point where i could do some testing on this. I got it to work pretty much first time so nut sure what you're doing wrong, Here's my code: (just make sure you understand what it's doing, far too many people just copy and paste without thinking about it) Main file @Mod(modid="TestMod", name="TestMod", version = "0.0.0") @NetworkMod(serverSideRequired=false, clientSideRequired=true) public class TestMod { @Instance("Testmod") public static TestMod instance; @SidedProxy(clientSide="mods.testmod.code.client.ClientProxy", serverSide="mods.testmod.code.common.CommonProxy") public static CommonProxy proxy; @PreInit public static void preInit(FMLPreInitializationEvent evt) { } public static Item modHat; @Init public static void init(FMLInitializationEvent evt) { modHat = new ItemModArmor(9001, ItemModArmor.ModArmor, 0, 0) .setCreativeTab(CreativeTabs.tabCombat).setUnlocalizedName("modHat"); LanguageRegistry.addName(modHat, "Mod Hat"); proxy.registerHandlers(); } @PostInit public static void postInit(FMLPostInitializationEvent evt) { } } ItemModArmor public class ItemModArmor extends ItemArmor { public static final EnumArmorMaterial ModArmor = EnumHelper .addArmorMaterial("ModArmor", 9001, new int[]{1,2,3,4}, 42); public ItemModArmor(int par1, EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) { super(par1, par2EnumArmorMaterial, par3, par4); } } PlayerTickHandler public class PlayerTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { playerTick((EntityPlayer)tickData[0]); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } @Override public String getLabel() { return "My_Tick_Handler"; } private void playerTick(EntityPlayer player) { if (player.inventory.armorInventory[3] != null) { if (player.inventory.armorInventory[3].getItem() instanceof ItemModArmor) { player.capabilities.allowFlying = true; } } else if (!player.capabilities.isCreativeMode) { player.capabilities.allowFlying = false; } player.fallDistance = 0F; // does not seem to be working not worked out why yet. } } Proxys public class CommonProxy { public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.SERVER); } } public class ClientProxy extends CommonProxy { @Override public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.CLIENT); } } Think that's all of it, didn't bother with textures but the flying works. if you figure out the fall damage tell me how [EDIT] upon further testing it seems that this method is not working 100% correctly, as it seems that there is some desynchronization between the client and server, meaning that when the player takes damage he will move back to where the server thinks they are. Not sure how to fix this atm but i'll get back to you
  21. How so? can i see your relevant code (Main mod file, proxies...) [EDIT] have you tried editing the number in the item[] for the armor inventory, i wasn't definite that 0 was correct for the helmet, so that could be the problem
  22. Not tried this in 1.5.x yet, but in 1.4.7 you could call "player.capabilities.allowFlying = true;" in the on armor update method for the armor, this does have the draw back of not being deactivated when it is removed, so alternatively you can create a player tick handler as follows: import java.util.EnumSet; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class PlayerTickHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { playerTick((EntityPlayer) tickData[0]); } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { // TODO Auto-generated method stub } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } @Override public String getLabel() { return "My Tick Handler"; } private void playerTick(EntityPlayer player) { //think 0 is helmet, haven't got the setup to try this yet player.capabilities.allowFlying = (player.inventory.armorInventory[0] == myHelmet || player.capabilities.isCreativeMode); } } then reference this in your common proxy as import mtech.code.handler.tick.PlayerTickHandler; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; public class CommonProxy { public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.SERVER); } } and in the client proxy as import mtech.code.handler.tick.PlayerTickHandler; import cpw.mods.fml.common.registry.TickRegistry; import cpw.mods.fml.relauncher.Side; public class ClientProxy { public void registerHandlers() { TickRegistry.registerTickHandler(new PlayerTickHandler(), Side.CLIENT); } } finally in your main mod file (the one with all the annotations (@)) call proxy.registerHandlers(); hope i helped
  23. In the past i've done things like this. I did it in a player tick handler though, as at the time i couldn't get the tick handlers to work. You can do something like this: import java.util.EnumSet; import org.lwjgl.input.Keyboard; import net.minecraft.entity.player.EntityPlayer; import cpw.mods.fml.common.ITickHandler; import cpw.mods.fml.common.TickType; public class MyPlayerHandler implements ITickHandler { @Override public void tickStart(EnumSet<TickType> type, Object... tickData) { playerTick((EntityPlayer)tickData[0]); } private boolean hasJumped = false; private void playerTick(EntityPlayer player) { if(Keyboard.isKeyDown(Keyboard.KEY_SPACE) && (player.isJumping || player.isAirBorne) && player.motionY < 0.07 && !hasJumped) //Waaaaaay more checks than necessary { //checks for armour/abilities... player.addVelocity(0, 0.1, 0); hasJumped = true; } if(!player.isAirBorne) hasJumped = false; } @Override public void tickEnd(EnumSet<TickType> type, Object... tickData) { } @Override public EnumSet<TickType> ticks() { return EnumSet.of(TickType.PLAYER); } @Override public String getLabel() { return "MyPlayerHandler"; } } Register that in the common and client proxys using TickRegistry.registerTickHandler(new MyPlayerHandler(), /*Side.SERVER in common proxy and Side.CLIENT in client proxy*/); One thing to remember when you're working with speeds in minecraft is that the speed is m/tick which means they tend to be fairly small (normally <0.1) Also, tapping into vanilla key bindings (at least how i was doing it) caused the original ones to break, guessing that's why you used B, so this works if you want to use space not tested in 1.5, but worked in 1.4.7
  24. Looking at the stack trace the error is in the tool material. Not sure what the error is though as it all looks fine to me, but it could be that the variables haven't initialized for whatever reason (i.e. it seems that the EnumToolMaterial is null so the max damage can not be found, if the case was that it was set up incorrectly then the value would most likely be 0). My suggestion would be to declare your items and enums as final and see what happens. P.S. I'd suggest, for the sake of neatness and readability, that the variables are moved to a separate class and done something like the following: package mods.mtech.code.item; import net.minecraft.item.Item; public class Items { public static int itemAluminium_id, itemAzurite_id, itemCalcite_id, itemCopper_id, itemLead_id, itemMalachite_id, itemPyrite_id, itemTin_id, itemTitanium_id, itemTungsten_id; public static Item itemAluminium, itemAzurite, itemCalcite, itemCopper, itemLead, itemMalachite, itemPyrite, itemTin, itemTitanium, itemTungsten; public static void addItems() { itemAluminium = new ItemOre(itemAluminium_id, "ingotAluminium", "Aluminium Ingot"); itemAzurite = new ItemOre(itemAzurite_id, "crystalAzurite", ""); itemCalcite = new ItemOre(itemCalcite_id, "ingot", " Ingot"); itemCopper = new ItemOre(itemCopper_id, "ingot", " Ingot"); itemLead = new ItemOre(itemLead_id, "ingot", " Ingot"); itemMalachite = new ItemOre(itemMalachite_id, "ingot", " Ingot"); itemPyrite = new ItemOre(itemPyrite_id, "ingot", " Ingot"); itemTin = new ItemOre(itemTin_id, "ingot", " Ingot"); itemTitanium = new ItemOre(itemTitanium_id, "ingot", " Ingot"); itemTungsten= new ItemOre(itemTungsten_id, "ingot", " Ingot"); } } This allows you to find the errors easier and know when your variables have been initialized. call the addItems() method from your method labeled with @PreInit or @Init also my id's are assigned prior to this using config, so they are initialized you just can't see it here
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.