Jump to content

Samalot

Members
  • Posts

    23
  • Joined

  • Last visited

Everything posted by Samalot

  1. Sorry for the bump, but I was away on holiday for the last week. To answer your question, the area in the image where the 25 slots and search bar are. One of the balances of the image is off, but I can't figure out why or how to fix it.
  2. I'm going to have to bump this Still have not found an answer.
  3. I would have thought this would have been quite a simple problem to find the answer to online, but after a couple hours of searching... I can't find a single thing. Image: Upon drawing multiple textures, the shading of the later does not match the source file. Code: I am presuming I just need to refresh something in the frontrenderer? or GL11? But I can't find (or figure out) what. Any idea? Thanks in advance.
  4. I feel like I am being a moron... is the location that each Slot is drawn in a custom GUI determined from the custom container? I have dug through the source code and the only mention of coordinates I can find about drawing the slots is from the container class. With that being said: What exactly are the coordinates measured in? I presume pixels, but where from - the origin? In the GUI class, it is possible to reference width and height, so that you can draw each box relative to the screen size... however, if you aren't drawing the slots relative to this, there isn't much point Is there a way to draw slots onto a gui respective to the size of the clients screen? Essentially, I have multiple GUI components that have different widths/heights and would like them all (and their corresponding slot spaces) to be in the centre of the clients screen. This is easy for the GUI components (width / height), but I cant figure out how to achieve it with slots. Thanks in advance. From CustomContainer (extends Container.class) From Container.class: From Slot.class:
  5. Somehow it is now working: current code: I can see Zero difference between that and what I had before
  6. I am having trouble loading in images to a JSON model, the files are there, but they are not loading. I get the following error: error Here is the JSON file: Here is a screenshot of the current situation (I know it is called 'bd1.png' when it should be 'bd' this is not the problem, I have since switched it back - it was from a debug attempt.) As you can see in the screenshot in exhibit (A) - 'un.png' does not load BUT 'bn.png' does. As you can see in exhibit (B) - both the code for 'un' and 'bn' are exactly the same (except for the file name) - the path to the image area is the same As you can see in the screenshot in exhibit © - All the files are there, so they should not be 'missing' If you replace all of the rendering images with 'bn' the shapes do load - so it is not like the elements are incorrect, just the loading of the textures I have no idea what to do, any help would be greatly appreciated! Thanks, Sam EDIT #1: When I delete all the images from the directory I get the following error: Is there a reason why the images would be split into two blocks like that? they correspond with the textures that fail to load..
  7. Would I be incorrect in saying that MrCrayFish's program restricts you to 16x16x16? I'll have an other look at it, thanks!
  8. I am creating a vending machine, which I would like to have a model that extends two blocks high. I am fairly sure I understand how the JSON block model works - here is my potential code: I would like to map this image onto the model: But - I get this rendering error: From what I understand, this is likely due to 'UV' extending 0-16, but I need my textures to have more detail than 16x16 pixels and would ideally like to avoid having to split the model up into 100 different cubes. Is there a way to achieve what I desire? Have I (like usual) completely missed the obvious? Thanks for your time, Sam
  9. I removed the restriction and received an error, seems I interpreted it wrong! Thanks for the help. The reason I cannot just use the onUpdate method is that the item has to also work from inside a 'token pouch'. (I could always just write a bunch of if statements inside of the pouch code, but I thought this approach might be cleaner.) EDIT: Error = "java.lang.NoClassDefFoundError: net/minecraft/client/multiplayer/WorldClient"
  10. That certainly would make things a lot easier! I came to this conclusion since the server was throwing errors when I tried to remove it. Ill do some digging...
  11. So, this is more of a brainstorm - I have some general idea about how I could accomplish some implementation of this. However, I am always keen to hear what people think and if they have any better/more sophisticated methods! Item: A token which applies the swiftness potion buff when in close proximity (4 blocks) from a Mob. player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 50, 1)); Issues: The event I was going to use onPlayerUpdate(PlayerTickEvent event) is @SideOnly(Side.CLIENT) My initial thought would be to just do the logic client-side and send a flag to the server (via a packet?) to apply the potion effect? Or, maybe have an event which runs server-side? I can't seem to find a 'tick event' from the forge bus, but some research shows there may be one on the FML Bus (however most of this info is from around 2012, so it could be out-dated). So my real question is - Do you think this is the right approach? Is sending a packet potentially tens of times every tick an issue? Or is there some other way I have completely missed? Thanks in advance! Edit: Upon reflection, I realise that the title is pretty poor - my apologies.
  12. Thanks for all of that! (and for being patient, I get the impression there must be 10 people like my asking similar questions each day) I'll have a read through the recourses you linked! As, for why I don't just check the players inventory each time - ill start doing that now! The issues was that these tokens are not just stored in the players inventory, but in other inventories too - such as a token pouch! (however, the more I think about it, the more I realise it is a non-issue)
  13. From what I understand, certain blocks of code (in my case - onEntityGetHurt event) should be run on the server only and vise versa. You essentially have the code for the server/client in one and control access with @Side or Remote world. But how does the client interact with the server? - I am aware of packets, but have been avoiding them somewhat. Is a packet sent over the web? from the client's pc to the server? I chose to share information between Client/Server sections of code using NBT data stored on the player. Here is my problem I have a mod: Adds a suite of tokens to the game. Tokens provide a passive effect to the player, you just need to have them on your inventory to get the effect. The effects are not necessarily potion effects, for example - prevent block damage from explosions (tapping into the event bus). The game (client and server) has to know which tokens the player currently has - I opted to do this by adding a new NBT Tag to the player for each token: EntityPlayer player = (EntityPlayer) event.entityLiving; /*Get player*/ tags = player.getEntityData(); /*Get tag cloud*/ tags.setBoolean("amplifyingToken", false); /*Create a new tag*/ ... player.writeToNBT(tags); /*Save the tag cloud*/ Every tick (on player update event), the players NBT tags are updated to match the inventory - this is done CLIENT SIDE only. Scan code (for those interested) However, if the server then tries to read the players NBT Data - it does not show the updated version. Is NBT data suitable for sharing information client-to-server? Am I correctly writing and saving the NBT data? - player.writeToNBT(tags); Sorry if this is trivial. If you need more info, please let me know - I am painfully aware how how vague some of this may seem. Thanks in advance!
  14. Thanks! I knew it was going to be something stupid, I do feel small now. I do check code (spent the whole of yesterday digging through Entity just to find that the parameters I needed use are private and hardcoded...). I try to only post on here as a last resort. I was so convinced it was something to do with Server/Client in my event handler. It didn't even cross my mind that there would be two methods for playing sound..
  15. Unless I misunderstood you, I think they must have broke it out. This is what is inside of TickEvent: public static class WorldTickEvent extends TickEvent { public final World world; public WorldTickEvent(Side side, Phase phase, World world) { super(Type.WORLD, side, phase); this.world = world; } } Either way, I tried TickEvent.WorldTickEvent and no dice. I'm paranoid that I am missing something simple. Playing sounds server side is definitely a thing right?...
  16. Hello, I am having trouble getting a sound to play server side. I have looked all over the internet without avail: @SubscribeEvent public void testTest(WorldTickEvent event) { //Word object from event. World world = event.world; if(!world.isRemote) { System.out.println("Server"); event.world.playSound(0, 0, 0, "random.explode", 10.0F, 1.0F, false); } } Here are a few points: The console does NOT print any errors, including 'unable to play sound'. I have tried many different sound files, ones which have worked elsewhere. The console does print 'server', so it is entering the if block The event handler is registered properly, the rest of the event works fine, just not the sound. Furthermore, The 'WorldTickEvent' seems to only yield remote worlds, I had a catch for client worlds but it never entered it. @SubscribeEvent public void testTest(WorldTickEvent event) { //Word object from event. World world = event.world; if(world.isRemote) { System.out.println("Client"); } } Nothing was printed. Thanks in advance, Sam
  17. Hello, this may sound like a basic question, but I would love to hear about how you optimise your mods performance? For example, I may be paranoid, but something about using event handlers that are called every tick does not sit right with me... does firing 10-20 different events cause much lag? even if there is very little to no logic happening every time? I have a 'token' which amplifies the damage you do to mobs and the damage you take from mobs. The only way I could work out how to do this is to subscribe to the 'onEntityGetHurt' event and check if the player is holding the token. This means that the actual logic for the item is in the event handler class and not in the item class. Is this bad? My code works, but sometimes I can't shake the feeling that my solution is... hacky. Essentially my main questions are: Does using events that fire every tick cause much lag? even if you have if statements so it only does something under certain circumstances. Is it bad to have the bulk of item logic in the event handler and not in the corresponding item class? However, I am also interested in hearing any other tips you have? I don't want my mod to cause unnecessary performance drops. Thanks in advance, Sam
  18. EDIT 2: I SOLVED IT!!! (changed the title of the post, so as not to mislead people. The original 'problem' was not the problem at all.. ) The problem was in my eventhandler, I had this: @SubscribeEvent public void openGui(GuiOpenEvent event) { /*No GUI*/ if(event.gui == null) { globalFlag_Token_Pouch_Open = 0; } /*Token Pouch opened*/ else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch")) {globalFlag_Token_Pouch_Open = 1;} } I added @SideOnly(Side.CLIENT) and it works! (well, it doesn't crash..) @SubscribeEvent @SideOnly(Side.CLIENT) public void openGui(GuiOpenEvent event) { /*No GUI*/ if(event.gui == null){globalFlag_Token_Pouch_Open = 0;} /*Token Pouch opened*/ else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch")) {globalFlag_Token_Pouch_Open = 1;} } EDIT: I have narrowed the problem down, it seems that it is my event handler that is causing the issue, NOT the proxies. java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen /*Imports*/ package lazarus.utils.handlers; import lazarus.main.LazarusItems; import lazarus.utils.whispers.AmsollionWhispers; import lazarus.utils.whispers.ImbrasWhispers; import lazarus.utils.whispers.OsmodeusWhispers; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraftforge.client.event.GuiOpenEvent; import net.minecraftforge.event.entity.living.LivingHurtEvent; import net.minecraftforge.event.entity.player.EntityItemPickupEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; /*Main*/ public class LazarusEventHandler { /*---------------------------------------- Global variables ----------------------------------------*/ public static int globalFlag_Token_Pouch_Open = 0; /*---------------------------------------- Listen for guiOpens ----------------------------------------*/ @SubscribeEvent public void openGui(GuiOpenEvent event) { /*No GUI*/ if(event.gui == null) { globalFlag_Token_Pouch_Open = 0; } /*Token Pouch opened*/ else if(event.gui.toString().contains("lazarus.container.token_pouch.GuiTokenPouch")) {globalFlag_Token_Pouch_Open = 1;} } /*---------------------------------------- Listen for item pickup ----------------------------------------*/ @SubscribeEvent public void onItemPickup(EntityItemPickupEvent event){ /*Amsollions Token*/ String whisperTextTemp = ""; boolean trigger = false; if(event.item.getDisplayName().toString().contains("item.item.gilded_token")){whisperTextTemp = AmsollionWhispers.randomWhsiper();trigger = true;} if(event.item.getDisplayName().toString().contains("item.item.waning_token")){whisperTextTemp = OsmodeusWhispers.randomWhsiper();trigger = true;} if(event.item.getDisplayName().toString().contains("item.item.amplifying_token")){whisperTextTemp = ImbrasWhispers.randomWhsiper();trigger = true;} if(trigger) { String whisperText = ""; String[] whisperTextSplit = whisperTextTemp.split(" "); for(String element : whisperTextSplit){whisperText += "§8§o";whisperText += element;whisperText+=" ";} IChatComponent whisper = new ChatComponentText(whisperText); SoundHandler.lazarusPlaySound("mob.wither.idle", 0.1F, 0.1F); event.entityPlayer.addChatMessage(whisper); } } /*---------------------------------------- Listen entity taking damage ----------------------------------------*/ @SubscribeEvent public void onEntityGetHurt(LivingHurtEvent event) { if(event.entity instanceof EntityPlayer) { /*Multiplied damgage taken by the player*/ EntityPlayer player = (EntityPlayer) event.entityLiving; if(player.inventory.hasItem(LazarusItems.amplifying_token)){event.ammount *= 100;} } else if(event.source.getEntity() instanceof EntityPlayer) { /*Multiplied damgage dealt by the player*/ EntityPlayer player = (EntityPlayer) event.source.getEntity(); if(player.inventory.hasItem(LazarusItems.amplifying_token)){event.ammount *= 100;} } } } ----------------------------------------------------------------------------------------------------------------- Original message: ----------------------------------------------------------------------------------------------------------------- Hello, I am making a mod that adds an item with an inventory. I struggled for a while, and still do not completely know what all the code does, however I was able to (following tutorials) make an item that does work in singleplayer! ...However, running a server instance crashes. java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiScreen After doing some digging, I was able to find that despite what the tutorial showed me, I should not be trying to access getClientGuiElement from my CommonProxy I can understand, to some extent, why my code is crashing... but I have zero idea how I can fix it: My common proxy extends IGuiHandler When I try to remove getClientGuiElement from the code, it throws an error As far as I can tell, I have to include getClientGuiElement in my Common proxy or it does not compile, however this is what causes my multiplayer server to crash? Here is my code: (GitHub link to full project - https://github.com/Samalot/Lazarus) item class relevant code: (not relevant, but if someone could explain to me why it is important to check if the player is not sneaking, I would be very thankful!) /*---------------------------------------- On right click ----------------------------------------*/ public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer player) { if (!par2World.isRemote) { if (!player.isSneaking()) { player.openGui(LazarusMain.instance, LazarusMain.GUI_ITEM_INV, player.worldObj, 0, 0, 0); System.out.println(par1ItemStack.getTagCompound()); } else {new InventoryTokenPouch(player.getHeldItem());} } return par1ItemStack; } Common Proxy: /*Main*/ public class CommonProxy implements IGuiHandler{ /*Register the renders*/ public void registerRenders(){} @Override public Object getServerGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { if (guiId == LazarusMain.GUI_ITEM_INV) { return new ContainerTokenPouch(player, player.inventory, new InventoryTokenPouch(player.getHeldItem())); } else { return null; } } @Override public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) { return null; } Client Proxy /*Main*/ public class ClientProxy extends CommonProxy{ /*Register the renders*/ @Override public void registerRenders(){ LazarusItems.registerRenders(); } @Override public Object getClientGuiElement(int guiId, EntityPlayer player, World world, int x, int y, int z) { if (guiId == LazarusMain.GUI_ITEM_INV) { return new GuiTokenPouch(player, player.inventory, new InventoryTokenPouch(player.getHeldItem())); } else { return null; } } } Any help on this matter would be hugely appreciated!
  19. Found a mod that does EXACTLY what I want AND MORE. After slaving away for the past 24 hours trying to make my own mod to do this and getting not very far, it is so good to find a mod that achieves what I thought was going to be impossible. More Player Models - By Noppes http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1291730-more-player-models-2-adds-a-character-creation Lets you choose a skin via URL, and it works SMP... it is exactly what I needed. <3 Noppes, I didnt think I could like your mods any more after CustomNPCs... but this is fantastic.
  20. EDIT: Fixed it I now have a custom render class for the Pig. Now my biggest issue is working out how to use this static render class from a non-static item class
  21. Hey, I have been trying to figure out how to do this for hours, but no luck. I could really do with some help, so I am hoping that putting my problem here might yield some solutions My Mod: An item that when you right click a mob/player, you can choose a new texture for them. I am using: public boolean itemInteractionForEntity(ItemStack par1ItemStack, EntityPlayer Player, EntityLivingBase Target){} in my item class to target the entity. (I also have a JFileChooser set up, and working correctly, to select a file path which I can then pass into RecourseLocation.) So: [*]I have a targeted EntityLivingBase [*]I have a texture file path how can I apply the new texture to the target ? Also: If it is too difficult to make this work for all entities, then it can just be for players. It only needs to update on the players screen, not the target. So, if it is used in SMP and I try to change the skin of a different player, it should only change it in my view and NOT theirs. Thanks for taking the time to read this and I hope somebody can help me out a little Thanks in advance, Sam EDIT: I am not sure how much help my code will be, but if you need it for whatever reason, here it is: note: this is a private/personal mod that wont be published, which is why the directories are static.
  22. First of all, I am sorry if this is in the wrong section. Was not quite sure where it fitted best. I make videos, machinimas, I tend to work alone with my brothers account as the 'actor', which means I am constantly closing the client and changing the skins. It is probably one of the most annoying parts of filming. I am looking for a way to make this easier, I am hoping that there exists a mod already that will let me change how other players look, but I am prepared to code one if I need to. It does not need to change how the player looks on their screen, since I understand if both players dont have the image file, it would be difficult to pull off. So, it only needs to change how the actor looks on the cameraman's client. I did find a 'closet' mod, but it has not been updated since 1.5 Does anyone know of any mod that will help me ? and if not, does anyone have any advice on how to make such a mod ? I have some experience with forge coding, but I am a novice. I should probably mention that I am working in 1.7.2. Thanks in advance!
  23. Hello, I am fairly new to modding, but do have a basic understanding of Java, although my knowledge on Events inst great. I am trying to change the Villager trading option on interaction with an object (Shift right click.) I am struggling to change the trade. From my understanding, of reading every Villager entity file... they have a 'buyinglist' which is their collection of recipes that they are willing to trade. Is there any way I can reset buyinglist so it is empty ? Or does anyone have a better solution to this ? thanks in advance! (Just to clarify, I am not trying to add now trades to the villagers, I just want to refresh/change their trade upon interaction)
×
×
  • Create New...

Important Information

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