-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
public ItemStack getCurrentEquippedItem() { return this.inventory.getCurrentItem(); } public ItemStack getHeldItem() { return this.inventory.getCurrentItem(); } @SideOnly(Side.CLIENT) public ItemStack getItemInUse() { return this.itemInUse; } Funny - 1st two are same, doesn't matter which you use, I'd expect one of them to be deprecated soon (hopefully, this is confusing, indeed). As to getItemInUse - it can/is used only client side when you hold right-click with item. the itemInUse field will be set to item held and used by client side for animation most likely (e.g: bow-pulling)
-
http://images-cdn.9gag.com/photo/arpnqKB_700b.jpg[/img] Aaaanyway... (mind that my life and everything I say is a joke) I will just point out everything bad: 1. 2. @SubscribeEvent public void playerTick(PlayerTickEvent event) { boolean hasItem = event.player.inventory.hasItem(ModItems.DnaZeusInfused); This piece of code is almost as ridiculus as building a bike with square "wheels" just to realize that round ones were invented thousands of years ago. If you are planning on making an item that gives effects when inside inventory and/or held in hand - use the right method! Item#onUpdate(...) is called whenever item is inside your inventory. To check if it's held you can simply do heldStack==stackFromOnUpdateMethod. 3. For the love of god - keep some order when making chain if-statements. 1st check the logical side! Then do creative checks and then everything else. 4. More @SubscribeEvent for same event = worse the design. One mod should only subscribe to an event once, there is no logical point of doing it twice. Also - look again at point "1" and "2". 5. removeAllModifiers(); Focus on "All" keyword. You certainly DON'T want to use this method, just because. 6. Finally (writing this 3rd time): You either ALTER BASE value, or ADD/REMOVE MODIFIER. Every attribute has a BASE value that is set DIRECTLY from given Entity.class. This value (if not changed from outside) will most certainly be SAME for all entitities of given class for both client and server. Altering BASE value in ANY way will require you to update other client's data, as BASE value is set ONCE and not tracked. If you don't want to handle it on your own (all the updates) - you DO NOT even touch BASE value. Never, ever (not including making your own entity obviously). If you want to go easy way - you do it by ADDING/REMOVING AttributeModifier to given Attribute. Base stays the same, you just add e.g +10 health (meaning entity will have 20+10). In that case - modifiers WILL be auto-synced if set to do so (.setShouldWatch(true)). 6 (edit: because "7" is too mainstream). Why do your potions have "0" time? Fix your code, read vanilla and check out modifiers (plenty of examples in vanilla).
-
In 1.8 armour is treated as layer rendered on top of ModelBiped. I'd look there. You can probably override Renderers that use ModelBiped and make them use custom layers or totally something else (your models). I think it would be possible to just remove layers and add your own (withoout overriding whole renderer) but didn't looked there yet (and i am planning on soon)
-
If you want direct answer: Guis didn't change much since 1.6. All tutorials are close-to-good. Note: I am not talking about containers, those changed much. As to how-to: Best teacher is vanilla itself. For simple Guis (opened by some trigger like keyboard) you can use GuiScreen as base. You simply extend it and open with player.openGui or mc.displayScreen (something like that). EDIT Before you ask again for tut links: There are not many good tutorials for Guis. There is one simple reason - Gui is a very mod-specific thing. Post wat are you planning on adding and we can help more (a lot more).
-
[1.7.10] Integrating Forge Multipart into mod [Help with Gradle]
Ernio replied to Enkey's topic in Modder Support
Problem 1: Duplicate mod error occurs only if you load mod twice. It can (and is) most likely occuring because you put the API into both /mods/ folder and add it as library to project. What you need to do: * When using mod as a library, do NOT put it into /mods/. You can put it ANYWHERE and then only thing you need is to reference it as library. When mod is declared as a library it will be loaded on startup and usable in your code. -
In 1.8 you can no longer (you shouldn't) access GL directly. Everything is made of models that are pre-baked and eventually put together/modified in runtime. Yes. Using .json models is a good way to start working with it. And yes - .json models allows you to make most of stuff you want. If that is not enough - look into Forge's model API (SmartItemModel fer example).
-
Show what you tried, if you can't even think of a way of starting working on this then read "Modder Support" sub-forum description. You can't start modding without most basic knowledge and Minecraft (Forge) is NOT the place to learn it, it's seriously complex. Also - there are plenty of tutorials on google that tell you exacly how to use those methods, even with flight probably.
-
[1.8] Reverting durabilities despite being run on both sides
Ernio replied to Ferrettomato's topic in Modder Support
If by durability you mean itemDamage (or "meta") then yes. While itemDamage field is an integer, it is being saved to memory as short (max 32k). EDIT Also - you should NOT allow client to dictate amount, and if you really need that, then you SHOULD make additional check on server if player can send such amount. -
In 1.8 x/y/z are wrapped into BlockPos - you can just make new BlockPos(x, y, z). Seriously - just look at literally any part of vanilla code, it's everywhere. Same goes for particles - look at e.g TNT primed.
-
1. Make some trigger (e.g GuiButton) 2. Make Packet Client->Server that will ship data (waypoint?) and the nick of player to be send to. 3. Send that packet from trigger from point 1. 4. Server receives packet, in handler - get EntityPlayer from world's player list (note that if you want multiple world support you need to check all worlds and also ship waypoint's world). 5. From server's handler send next packet with data (waypoint) to found-by-name-player (if found). 6. On other client - handler will read waypoint and add it to its own list. Where is the problem? You will need 2 packets, 2 handlers, and some trigger (might be even command). If ther server knows about given's player waypoints - you don't need to send them in client->server packet, but draw them directly from server's data.
-
What "reverse engineering"? There is nothing to do there. If you want to make a plasma gun: 1. Make PlasmaGun extends Item 2. Add onItemRightClick 3. Spawn new entity (in method above, with !world.isRemote to be done server-side): PlasmaBall extends EntityThrowable 4. Boom - you have entity in world. 5. You PlasmaBall can have any modifications you need, I suggest looking at e.g player throwing snowballs. EDIT Btw. what is the point of pasting vanilla code here? In addition - pasted wrong.
-
It might be only me, but I seriosuly don't get what is the ACTUAL problem here. First you say something about health, now you start with even buses. I am lost. Anyway - if you want direct help - make GitHub. Other option is to post all classes regarding problem (with proxies if used). Also note that tick events always have 2 phases - pick one, otherwise code is ran twice. (e.g: event.phase == Phase.END).
-
PlayerEvent.NameFormat is only event that gives you power over this feature. If you want more complex displays you will need RenderWorldLastEvent and render tags on your own. Note to you: As you are Bukkit/Spigot guy - you need to see that Forge is Modding platform, while others are "plugins". Big difference is the fact that forge ships tools that allow you to do almost anything, but has no ver-specific-like-bukkit-ones. If you want to have more fun with "plugins" rather that real modding I suggest SpongeAPI (edit) for Forge. EDIT Diesieben was faster.
-
[1.7.10]I want to use World.setBlock in actionPerformed.
Ernio replied to thepdone's topic in Modder Support
http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-x-1-8-customizing-packet-handling-with or http://www.minecraftforge.net/forum/index.php/topic,20135.0.html -
[1.7] Persistence with IExtendedEntityProperties
Ernio replied to MrRiegel's topic in Modder Support
In simpler words: You are outdated. * IEEP class is cool. * Clonning data is not cool. What you need: IEEP = hold data. EntityConstructing = assign data. PlayerEvent.Clone = clone data on player re-creation (e.g death). Example: @SubscribeEvent public void onPlayerClonning(PlayerEvent.Clone event) { IEEP ieepNew = IEEP.get(event.entityPlayer); IEEP ieepOld = IEEP.get(event.original); ieepNew.setSomething(ieepOld.getSomething()); } Everything else is old "technique" and you don't need it. In case you need synchronization - you might wanna look at FML's PlayerEvent#, like: PlayerRespawnEvent, PlayerChangedDimensionEvent. -
You mean like this? (this is 1.8 ) Note: Each part can have different texture, all their layers (defined by their model "layer") and colors (that also use renderPass). You basically need to bake models for every provided part's texture (register variants and use ModelBakeEvent) and then use them (models) to put up new model in SmartItemModel. Things you should know: * This is really fkn hard! (took me days if not weeks of digging). * Don't expect much help on this field - new model system is still too new. You will need to dig your own "mine". Actual things: The "renderPass" is actually the "tintIndex" of given BakedQuad. When you would make model of some part and make it have multiple layers the tintIndex is derived from "layer0" to "layer4" (vanilla allows 5 layers, but it might have changed). Following this: When you bake part of weapon (let's say blade) you will have e.g 5 BakedQuads for it's front (for each layer) which you can manipulate. Obviously there is also load more of those quads (for all sides and item's back). Anyway - Using SmartItemModel you can grab tintIndex and make new BakedQuads from old ones and change their tintIndex to fit your needs. This is just an integer that you can manipulate.
-
As long as your pipes are one-in and one-out you can simply make "search". Task is simple, can't think of a way to explain it - you just check where is next connected pipe until you reach end. As to what can you do to make it work well: 1. If pipes are TileEntities you can store start/end/whatever in their NBT. I belive above is not the case, so: 2. You are most likely (what I would do) holding pipes rotation in their metadata. You can simplify your "search" based on this, meaning "where the pipe goes next".
-
Everything you do, regarding data, should happen on server and be eventually sent to clients. Yes - potion effects HAVE to be added on server side only. They are handled internally and synchronized to all clients. Note that setting potion time to "1" might cause issues (effect will "blink" or won't even appear - depends if you use START or END tick). Always use 2+ values. As to SharedMonsterAttributes (SMA): SMA is NOT something that is synchronized. Its name, through still bad, kinda tells you what it is - "SHARED". Vanilla sets entity's SMA only ONCE - when entity is being constructed. SMA is set on both server and client side - meaning both client entity and server one will have same SMA that was coded in Entity.class. Changing SMA need to happen on BOTH sides. If you decide to alter it - you need to send packet to all clients that it changed. Also - if you change SMA, let's say health for one player and then someother player sees him (didn't see him before) - you ALSO need to send packet to set its new health. SMA is constant value for both sides and all entities of same type (class).
-
[1.7.10] Need method to autosave server on an interval basis
Ernio replied to Farrendil's topic in Modder Support
There is not a single person on thins forum that would write code for you. 1. Learn how to make mod. 2. Learn how to use Forge Events - particularly ServerTickEvent 3. Use it (event above) to after 15min (18000 ticks counter OR scheluded task without incrementation) to use your backup script. 4. You backup scrip can be even simple java utilizing File.class, BUT if you want to write efficien saver you would need to dig DEEp into MC saving code. Also: script != coding, so if you are asking about scripts - I assume you are not very familliar with Java. Save is a save, backup is backup. One is original copy, second is backup copy of save. I can't explain it clearer. -
[1.7.10] Need method to autosave server on an interval basis
Ernio replied to Farrendil's topic in Modder Support
save != backup Saving happens internally by game itself. Are you looking for mod or a help in coding it? This forum is for second. You can make simple ServerTickEVent that would simply copy world/player data to backup folder. Copying big data will lag server so I recommond designing some checksum hierarchy (and check which chunks/players changed from last backup). -
1.8 make something happen when armor is equipped
Ernio replied to cdainesy's topic in Modder Support
Armour have method onArmorTick - called when you are wearing armour. (inside your armour class, override it). For vanilla armour - indeed - PlayerTickEvent or LivingUpdateEvent, check eq and do stuff. -
Only if you need it. I told you - learn what a proxy is. There are 2 possible ways of launching minecraft - with client.jar and server.jar (refered to as dedic). In your mod you can define 2 classes - server and client proxy. Say you have: @SidedProxy(clientSide = "client.ClientProxy", serverSide = "server.ServerProxy") public static CommonProxy proxy; ServerProxy and ClientProxy would extend abstract CommonProxy. Now - you can call abstract method proxy.somethingAbstract(); That will be overriden by client/server proxy. When you are on client.jar - ClientProxy would be called. When on dedic.jar - server one. Ideally - ALL events that should work for server and client should be in CommonProxy (SP is ALSO a server, but only in mea of logical side, not actual "dedic"). All stuff that is client side goes to ClientProxy. ServerProxy on the other had (since SP also needs server events that are placed in CommonProxy) would be used only for server.jar exclusive features - e.g when you are coding special config files for server only.
-
Learn how to use proxies. Client proxy will fire only on client.jar. Server only for dedicated.jar (your server). You did event registration in ClientProxy - that's why it doesn't exist on server. You need to separate Client events (such as HUD, gui, render) and all other (pickup events) to 2 separate classes and register them accordingly.
-
Both are server/client sided. Post your code and registration. What is "server" for you? Is this logical thread or dedicated server?