Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. "change the scale of a normal/generic item" My answer is exacly what you are looking for. Items DON'T have models. "you will probably want to copy/paste code from vanilla ItemRenderer and add GL scaling" How is this not an answer? Just look at the class, generic items don't have models - they are generated from image (.png) and made thick using GL. Edit: You MIGHT be asking about icon (not model): @Override public void renderItem(IItemRenderer.ItemRenderType type, ItemStack stack, Object... data) { IIcon icon = stack.getItem().getIcon(stack, 0); //And then pass normal ItemRenderer GL operations. Again: Look into vanilla code. }
  2. In most cases Forge makes everything compatible, but I don't think (and don't know really) if rendering is one of them. I think that up to the point you are making something render on top of vanilla model all mods that do the same will work (like 2 differend armour-mods would actually work together when rendering armour parts). But when you are making a Troll Model from Human (Steve) then, well... just think. Only way to keep everything together would be writing an API that you would have to personally hook into other mods, or other way around. And that's what PlayerAPI does (have look at it). I used it a very damn long time ago (like 1.3 or so, and was able to make different player model for Smart Moving mod, but thats super old, before events even existed, before anything regarding advanced rendering existed).
  3. You want to register new renderer for item. @SideOnly(Side.CLIENT) public class MyRenderer implements IItemRenderer Then you will probably want to copy/paste code from vanilla itemRenderer and add GL scaling (smaller ay?) you will also have to change position of rendering... that all in GL. To register item with new renderer: (MUST be in client proxy ofc.) MyRenderer rend = new MyRenderer(); MinecraftForgeClient.registerItemRenderer(MyMod.item, rend);
  4. Yes, use this event. Notice this event has sub-events, Pre and Post. Basically what you want to do is to make some server-side action, that on "do this action" will send packet to all clients to launch RenderPlayerEvent.Pre and cancel standard rendering - you will have to remove parts of body you want to animate, you can also remove whole model and add everything from scratch, and then re-add them in RenderPlayerEvent.Post and animate your way. To store custom values like isDancing boolean use IExtendedEntityProperties (and there operate with packets said before). Unless you want it to be just client side, but then others won't see it.
  5. Yeah, but I have to KNOW the category name, So I would have to store all names in some registry string ay? String: race_list: name,name,name. My exact question would be - can you iterate through list of categories (does forge config have length support?) without caching them first (register like said above)?
  6. Until now I only've seen configs that are injective (Mod asks for value in category and gets it from file). What I want is more of a reader. Mod starts up, goes to Config and reads infinite list of lists of lists... and puts them into memory. Races: Human: Shortdesc: String Longdesc: String SomeValue: int SomeValue2: int Avatar: Shortdesc: String Longdesc: String SomeValue: int SomeValue2: int Poop: ... ... ... Stories: Orphan: ... ... ... Does forge allow reading like this? How would I get list of sub-items in category (eg. all races in "Races") and then all values in each race. Any tuts?
  7. Well... kinda wrong here. player.motionX, player.motionY, player.motionZ are shared values. Changing them on client will actually make them change on server but only till the point the server allows it (if you make it too far, the server will detect you being too fast or something and glitch you back). Since it seems like you are literally writing a bot and want it to be client-side mod I recommend operating on virtual Keyboard that is being controlled by Client-SIDE playerTick event. That will save you some checking for speed and stuff. Useful should be MC Pathfinding classes.
  8. Useful link for IEEP: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and As for packets: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with http://www.minecraftforge.net/forum/index.php/topic,20135.0.html There is some wave of question regarding players/packets since early 1.7 and it seems like those 3 links are always the answer.
  9. Problem with this design is the fact that one can cast spell with writing actual command on chat, but the other could install some client-side mod that allows him to have macros which gives him auto-cast. Consider having Customizable KeyBindings that on press are sending packet that changes value in players IEEP for some ticks (and make --ticks). You could also do it other way around - When KeyBinding is Pressed it sends packet to server, and IF you are holding given item the spell is being cast and redstone is consumed. That would save you --tick and another variable to save per spell. Useful: (About Packets) http://www.minecraftforge.net/forum/index.php?topic=20135.0 http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with (About IEEP) http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and KeyBindings are all over google.
  10. Inventory Icon (ItemIconIndex) is not equal (in terms of renderers) to Item 3d icon (ItemIcon). The itemstack-sensitive version is used to e.g make animated inventory icons (tho it should be made by resourcepacks). Example from my mod: @Override public IIcon getIconIndex(ItemStack stack) { if (stack.getTagCompound() != null) //should be more NBT checks here { return longswordIconStorage.get(stack.getTagCompound().getString("texture")); } return this.itemIcon; } @Override public IIcon getIcon(ItemStack stack, int pass) { if (stack.getTagCompound() != null) //should be more NBT checks here { return longswordIconStorage.get(stack.getTagCompound().getString("texture")); } return this.itemIcon; } Where longswordIconStorage is my Icon registry. And this.itemIcon is my default Icon.
  11. Just so you know - ANY packet system that is NOT based on client-request<->server-response (like opening conatiner/gui, walking into area, being in area, some clicking actions, buttons) will be generating a lot of lags when used in too many 'places'. Let's take example of server-data->client-data (no-request-system): Synchronization of player data! So compare player to TileEntity - one is from 0 to few hundreds (that would be good server), other one (TE) is infinite. Rethink you design: Does your Player need to know what's happening in all TE in WHOLE server world? If not - consider adding entity scanner in your TE, if Entity instanceof Player -> send packet. Does your Player even need that data at all times? Maybe you could make this code from server-data->client-data to client-request<->server-response. Also: "Do you have any tips and tricks on how to make it so it updates every ? ticks?" What you mean? TE is alredy being updated on tick (or not? enlighten me)?
  12. Let's say you have Foo class with Foo(String s) and Foo(int i) in it. If the class is not final (which means it cannot be extended) you can extend it. Let's take class BetterFoo extends Foo. In java this means that BetterFoo will inherit all non-abstract (abstract methods are inherited too but they have no body because they are abstract so you will have to @Override them anyway to add body) methods. Now if you would refere to your object BetterFoo you can use methods from Foo without them present in BetterFoo, becasue you extended that class. Notice if you try to make Foo(int i) or Foo(String s) in your BetterFoo, it won't allow you, thats because they are alredy there (inherited). Thats when you use @Override - adding it to duplicated method in class extending some class will override the superclasse's method. Also - start using StackOverflow, Java Documentation, and Google.
  13. Well, I know I've done it around MC 1.4, could provide code if needed but not in next day or so. Have look at: (Item) public CreativeTabs getCreativeTab() { return this.tabToDisplayOn; } public Item setCreativeTab(CreativeTabs p_77637_1_) { this.tabToDisplayOn = p_77637_1_; return this; } public CreativeTabs[] getCreativeTabs() { return new CreativeTabs[]{ getCreativeTab() }; } Also CreativeTab: public void displayAllReleventItems(List list) Combining those you can make Item that is displayed in few Tabs. Not sure how it works on 1.4+ but I'll probably write it tomorrow (just out of curiosity). There are 2 ways of doing it, hope you'll discover that the better one works (one i used in 1.4). If that one won't work there is a way to cheat all this, but that uses quite lot of memory duplicates and references (for every item in every customtab)
  14. Whats the best/correct way of this action: (example) Clicking 'P' opens CLIENT-Side GUI. Gui should send request to server and receive info. (on button or on open (init()) SERVER-Side is loading /myfolder/quests/quest_name.quest and saves it to HashMap<String, Quest> quests; While I know how to use packets and where to put them (GUI#init() or GUI constructor) I have NO idea where to save received data. Can that be done directly in GUI? (like below) public class GuiQuestLog extends GuiScreen { HashMap<String, Quest> clientSideQuests = new HashMap<String, Quest>(); public GuiQuestLog() {} @Override public void initGui() { buttonList.clear(); packethandler.sendToServer() //sends request to server - its pseudo ofc. super.initGui(); } } After receiving packet, server scans player's logs (his questing history) pulls quests from server-side HashMap<String, Quest> and creates response which contains something like: GuiQuestLog.clientSideQuests.putAll(collection send by server) One more: Do packets exist on integrated server? I mean, do I have to do synchronisation of clientSideQuests with quests separately for singleplayer or they'll still be handled by my packets (alike on dedicated->client)?
  15. I was gonna write same as above but noticed he's (op) trying to setMaxStackSize() on vanilla item, alredy registered in game. @Override is used for extended classes. Anyway - There is probably ton of things you could do to make this work, but since 1.7 I have no idea how to do this without bytecode manipulation, and that is (i presume) too hard for you for now. In the old times I would make class extending ItemSword and set Items.diamond_sword to MyItemSword. This worked fine and was quite compatybile (in your case it would be 100% comp). But since there is new registry system as of 1.7 idk if similar thinking would work. Sry, this is not answer to question, but somewhat extension to it.
  16. You could simply use Reflection and method.setAccessible(true); Then you can access it from any action you want. This probably would be the clearest way. About handling action - you scan for entities around like in attackEntityFrom()
  17. How does WHAT work with bukkit scheluder? What source code? If you are asking about Bukkit-Forge relations, you are probably referring to Cauldron? Needs more explanation...
  18. Blindness at its finest. Corrected by post below.
  19. Well it's all working now, but I see your point, it might be tricky in later updating and overall safety. Only thing pushing me to do this is the fact it is done, and my ExtendedPlayer is saved in different directory. **Can I somehow make ExtendedProps for player be saved in other place? (other than player.dat file) I'll probably make a rewrite (damn you for being right).
  20. What can I say, thank for this diesieben: http://www.minecraftforge.net/forum/index.php?topic=10614.0 Anyway, I managed to pull that off with one cross-mapping: if ((side == Side.CLIENT && !Minecraft.getMinecraft().isIntegratedServerRunning()) || (side == Side.SERVER && MinecraftServer.getServer().isDedicatedServer()) || (side == Side.SERVER && !MinecraftServer.getServer().isDedicatedServer() && Minecraft.getMinecraft().isIntegratedServerRunning())) {} In if statement: 1. Is client thread connected to dedicated server 2. Is dedicated server thread 3. Is integrated server thread Anyway, launching code under this will cleanup map on server AND client if they are separated (dedicated server), and ONLY on server if they are together (integrated), so the client is no longer problem on SP. Only bad thing about my whole layer is fact that it's reloaded when player changes dimension, but I saw that it also happens on IExtendedEntityProperties (documentation: Such as when a player switches dimension {Minecraft re-creates the player entity}) so I am not worried. Yeah, I am stubborn, don't do things like me kids ;p Thanks CLOSED
  21. Short - layer on player. Long: Everytime player appears in game in any form, his entity is wrapped and put inside map. ExtendedPlayer ep = ExtendedPlayer.wrapPlayer(player); public static Map<UUID, ExtendedPlayer> playerMap = new WeakHashMap<UUID, ExtendedPlayer>(); public static ExtendedPlayer wrapPlayer(EntityPlayer player) { if (playerMap.containsKey(player.getUniqueID())) return playerMap.get(player.getUniqueID()); else return new ExtendedPlayer(player); } Map is static and is generated for both client and server. While server gets ALL data for given player from his data files, client just creates ExtendedPlayer object with generic values. After server loads that data, it's sent to client side. Now: As said before when having 2 threads (Client connected to dedicated server) I have 2 Static maps that are working nice and tidy. When I am on SP I have to deal with client being faster than server. I have to make server act before client does (read: cancel client cleanup action IF the server is NOT dedicated) Why use such a layer/map. ExtendedProps are useless when it comes to storing and sharing such data. And without caching it on client side inside my static map packeting system would go nuts (too much data). Ofc. any changes are updated and synchronized (and everythig is still issued on server side), so there is no way to cheat this system.
  22. How can I know if the server, the client is connected to, is dedicated? Not asking about isRemote or Side, because those two say something like this: "This thread is client/server." and "This world belongs to client/server." What I want is client thread to say "I am now connected to dedicated/local server" Why? On client and server I have equivalent class (layer). If client is connecting to dedicated server, both client and server will generate that class and the server will send packets to synchronize data. When client disconnects both client and server will remove that data (ofc. server will first save it to NBT). Problem appears when I am on SP. On SP (local server) there is no network bridge (packeting) between client and server, so the class described before is shared (only one). This makes my mod go crazy when player logs off because: - client is always reacting first - since it's reacting 1st it unloads my class with data. - server is the one responsible for saving data (NBT), and since client was 1st and alredy removed that data, server cannot save it. I need to check on client thread is server is not dedicated and if it's not then not unload my data before server saves it.
  23. Okay so I gotten around with that system and it all would be nice and tidy, but still (also thanks for your help so far): My EntityPlayer's maxHP is influenced by: Level (50 levels), PlayerStats (2 stats), Inventory (12 items), Generics (1-3 extra values, something like race/class), EffectsMap (effects that are currently on player). Now from what I see - I could leave base health to be 20 and do rest by adding Modifiers, but that would leave me with UP TO DOZEN of those (counting situations like all my 12 items give some health buff and player has few health buffs on him). 1. Is having so many Modifiers good? (note: All of them would be marked isSaved = false, because everything from Level to EffectsMap is alredy saved and only loaded on startup) 2. So Attributes are static (not synced) on both client and server, how about Modifiers? Does client know about Modifiers or it just receives final value?
  24. As said above - this is NOT good way of doing this, but hey - "If it works, it ain't stupid" 1. Use HarvestDropsEvent from net.minecraftforge.event.world.BlockEvent 2. Subscribe to it and check if harvester is not null and is player (second is not that much needed). 3. If so, then check currently held item, if item == your item, then start dropping from droplist (which is also in event). 4. Also if you wanna do it this way remember to remove your code from item, because now it'll be in event.
  25. I'll just end my overthinking and ask: How they are synced, how saved and how to edit them? Also same question for custom-made IAttributes. (Till now i didn't think they are entity-specified, but SHARED)
×
×
  • Create New...

Important Information

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