-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
Contemplate: (fixed all bad practices). @Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) { if (!world.isRemote) { NBTTagCompound nbtDataCompund = itemStack.stackTagCompound; if (nbtDataCompund == null) { itemStack.stackTagCompound = new NBTTagCompound(); nbtDataCompund = itemStack.getTagCompound(); } int coolDown = nbtDataCompund.getInteger("coolDown"); if (coolDown > 0) { --coolDown; nbtDataCompund.setInteger("coolDown", coolDown); } } } @SideOnly(Side.CLIENT) public void addInformation(ItemStack itemStack, EntityPlayer player, List dataList, boolean bool) { if (itemStack.getItemDamage() < subItems.length) { dataList.add(subItemsDescriptionsFirstLine[itemStack.getItemDamage()]); dataList.add(subItemsDescriptionsSecondLine[itemStack.getItemDamage()]); dataList.add(subItemsDescriptionsThirdLine[itemStack.getItemDamage()]); } NBTTagCompound nbtDataCompund = itemStack.stackTagCompound; if (nbtDataCompund != null) { int coolDown = nbtDataCompund.getInteger("coolDown"); if (coolDown > 0) { dataList.add(subItemsCoolDownDescriptionsFirstLine[itemStack.getItemDamage()]); dataList.add(subItemsCoolDownDescriptionsSecondLine[itemStack.getItemDamage()]); dataList.add(subItemsCoolDownDescriptionsThirdLine[itemStack.getItemDamage()]); } } } @Override public boolean itemInteractionForEntity(ItemStack itemStack, EntityPlayer entityplayer, EntityLivingBase entity ) { if (!entity.worldObj.isRemote) { NBTTagCompound nbtDataCompund = itemStack.stackTagCompound; if (nbtDataCompund != null) { int coolDown = nbtDataCompund.getInteger("coolDown"); if (coolDown > 0) { return false; } if (coolDown == 0) { if (entity instanceof EntityMob) { if (itemStack.getItemDamage() > 0) { entity.setHealth(0.0F); nbtDataCompund.setInteger("coolDown", 180); entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY +"Soul Absurbed!")); itemStack.damageItem(1, entityplayer); return true; } else { entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "The Magical Stone seems to be full?")); entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "It seems to be useless now.")); entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "I wonder whats inside?")); return true; } } else { entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "Why has this stoped working?")); } } } else { entityplayer.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + "NBT is null, wtf?")); } } return false; } Note: onUpdate() is called ALWAYS when Item is inside player's inventory, thus - NBT can ONLY be null if item was never in player's inventory. EDIT I have one question - do you know what you are doing with this statement: if (itemStack.getItemDamage() > 0) ItemStack's DAMAGE == METADATA. Field is called "int itemDamage;" and can be used to do 2 things - either make sub-items OR make damagable item. Damage == 0 means that ItemStack is NOT damaged. Every incrementation (itemDamage > 0) means that itemStack has been damaged. Item#maxDamage defined maximum damage item can have if you decide to use IteamStack#itemDamage field to describe its damage (NOT metada-sub-item). Think of what you want to archieve there. Have subtypes or have chargeable wand?
-
Item#getColorFromItemStack You can use NBT/metadata to define color. Color is an int.
-
No, no, a coremod is what you SHOULDN'T do. At this point Forge has sooo many hooks (events) that it allows you to do pretty much everything you want. Coremods should be used for stuff out of planet like adding your own bounding-box systems (vanilla only supports boxes) - this cannot be done with only Forge. So, what do you need to change so bad?
-
Depends on what you mean by "directly". If you mean jar - then not really. Otherwise - forge injects all its stuff on game startup using magic (bytecode stuff). As to what you are looking for - you probably want to write core mod, BUT before you make up your mind do tell what you want to change, because it is most likely possible with standard coding (events). Mind that coremods usually break a lot of stuff (not only compatibility-wise). And ofc don't forget you will need some advanced java (pretty much top-notch). As to your requested "list" - you could lookup all changes forge does to code by looking ad .patch files (correct me if I am wrong about extension, not in IDE now). There is a lot of them. P.S. Polak?
-
The most important part is "what version?". 1. Version dependent. 2. It doesn't work like that. Texture registrations should happen oncce per resource reload. Rendering can, on the other hand, be manipulated. But then again - version dependent. 2.*. Your theory is not really correct in terms of minecraft design, but is doable if you code it (obviously), also looping like you said would be too expensive for common blocks.
-
[1.7.10] WHY IS MY ai not working??
Ernio replied to BoonieQuafter-CrAfTeR's topic in Modder Support
Umm... For the 1st time i have to agree with Boonie - what textures? They don't matter. You have ConcurrentModificationException which happens (most likely) when you modify same not synchronized collection (in this case some ArrayList) from 2 different threads. 1. I need more code. 2. Please - save results: (this might even be reason of error): public boolean shouldExecute() { Entity target = theEntity.getAttackTarget(); if (target != null && target.getDistanceSqToEntity(theEntity) > 100.0D) return true; return false; } -
You don't need ASM, god. In Minecraft.class: public EffectRenderer effectRenderer; It is being initialized once on startup, you can easily extend EffectRenderer and write whatever you want there and then in startup event replace vanilla's one. (You will probably need to proxify stuff since there are some Side.CLIENT annotations).
-
http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with Short: http://www.minecraftforge.net/forum/index.php/topic,20135.0.html Really? Idk what you googled.
-
@Override public void onUpdate(ItemStack itemStack, World world, Entity entity, int i, boolean flag) { super.onUpdate(itemStack, world, entity, i, flag); if (!world.isRemote) { NBTTagCompound data = itemStack.stackTagCompound; if (data == null) { itemStack.stackTagCompound = new NBTTagCompound(); data = itemStack.stackTagCompound; } int cd = data.getInteger("cd"); if (cd > 0) { --cd; data.setInteger("cd", cd); } } } This code will try to decrement cooldown to zero whenever it's positive (positive = item has cooldown). It also has lazy initialization and will work like charm (mind I wrote it here and am on 1.8, so might made mistake). Btw. That is one way to do it. There are others - unless you need to have visible (e.g displayed on gui/item description) cooldown you can also use timestamps of last item use. That way you don't have to operate every tick on NBT unless you actually use it.
-
Well, you failed Remove "int cooldown" field from your item class. Operate only on NBT.
-
You can't do that... Item is a singleton. Think of it as "description of what you are holding". The thing you are actually holding is ItemStack, thus - ANYTHING that will be put into Item.class will be shared between all items. You need to save cooldown inside ItemStack's NBT. To learn how to use NBT- google it. A bit of background: http://www.minecraftforge.net/wiki/Creating_NBT_for_items
-
Item's onRightClick happens on both sides. Note that while normal entities should be ALWAYS spawned on server, the partcles (which are also "entities", but special), are CLIENT side only. Do the client-check and spawn them, what is the problem? For example line of code lookup TNT (primed I think) or even BlockFurnace.
-
[1.8] Adding a tag beside the name when equipping armor
Ernio replied to skyfir3's topic in Modder Support
@Subscribe to NameFormat event and return changed name. Mind that name is being generated per-call and the cached. You need to explicitly call player.refreshDisplayName() whenever you want to generate new one. That call should be made from either onArmorUpdate() (if armor is custom) or from PlayerTickEvent (check armor and call renaming if renaming wasn't made). To store info about if "renaming was made" you could use IExtendedEntityProperties, but there are other ways. Note: DO NOT generate name every tick. -
Yes, APIs are usually released in 2 versions: Dev (deobf) and User (obf). Edit: Ok, idk, can't find exact line, gotta wait for big guys. ;P
-
Follow this project: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample (Note: it has all assets) And page: http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html
-
[1.8][SOLVED] What is the best file structure for a mod?
Ernio replied to SuperGeniusZeb's topic in Modder Support
There is no silver lining. Find your own stylr. Improve it with stuff you learn. As to forge-oriented "rules". preInit() should load configs and initialize items/blocks + register them. general rule is - all registry-related stuff goes to preInit(). But wait! There's more! In init() you should do all stuff regarding rendering. That is because since all registering happend in preInit(), it is logical that rendering code needs know who will use given rendering stuff, thus - it happens in init(). In init you would also register recipes and stuff that use registered earlier items/blocks/entities. postInit() is used generally to communicate between mods - e.g "unregister something if some other mod was installed". Can't say much without more direct questions. -
Jesus Christ, Mother's mercy, God save The Queen, Long live The King. I missed "E" symbol. (to be fair I didn't look much). Vanilla 1, Ernio 0...
-
...EntityPlayer#damageEntity(DamageSource damageSrc, float damageAmount) : 1135 - 1138 if (damageAmount < 3.4028235E37F) { this.addStat(StatList.damageTakenStat, Math.round(damageAmount * 10.0F)); } If the damage taken is high enough, you will not receive "damageTaken" statistic? I mean, seriously - why would there be such statement there? Damage taken is damage taken, doesn't matter how much. Is this next "wtf vanilla" stuff? EDIT: Before you start asking: I am heavily modifying damaging/armor systems, need to recreate some vanilla behaviours.
-
It was quite impossible some time ago. Now, there is (temporary) fix: https://github.com/MinecraftForge/MinecraftForge/commit/b175d265b9643faf3408754f6923a8f55f6ee5d3 Seems like something you are asking for.
-
(UNSOLVED) [1.7.10/1.8] Help replacing the in-game HUD?
Ernio replied to Ms_Raven's topic in Modder Support
1. Did you register event? 2. Is it even called? 3. Use syso/debug - very useful. 4. For your rendering - USE PHASE (ALL for example). -
That data will be loaded no matter if you have one or several WSD - that's what it is for. (Edit: I feel retarded, for forgetting that). If you want to load-on-demand you need to write your own saving system. Pretty simple. Make your directory with explosions and save them per-date or something using CompressedStreamTools.
-
I think you might be missunderstanding what WorldSavedData is. Its kinda of like IExtendedEntityProperties. Create ONE WorldSavedData per world that is corresponding to your mod. In that WSD hold a MAP or ARRAY of custom objects that store your "explosions". Use whatever you like to remove those "explosions" from map/array. In WSD#write/readNBT use NBTTagList and create NBT-list with your custom "explosion" objects.
-
[1.7.10] MouseEvent does not fire when inside gui
Ernio replied to IvanTune's topic in Modder Support
From what I remember it won't fire. If you are extending GuiScreen you can override handlerMouseInput and use standard calls like Mouse.getEventDWheel(); For examples lookup vanilla gui code (guis that have scrollings). EDIT Oh, and for vanilla stuff: net.minecraftforge.client.event.GuiScreenEvent.MouseInputEvent.Pre/Post -
Buttons have IDs. this.buttonList.add(new GuiButton(id, x, y, width, height, "NameOrLangLink")); You can: if (guiButton.id == 1) { do }
-
You don't. The old school was to store data in static maps. Not anymore since 1.5 or something around. Now you use (as mentioned before) Clone event. @SubscribeEvent public void onPlayerClonning(PlayerEvent.Clone event) { ExtendedPlayer epNew = ExtendedPlayer.get(event.entityPlayer); ExtendedPlayer epOld = ExtendedPlayer.get(event.original); epOld.copyTo(epNew); // method that copies fields from old to new } For each EntityPlayer (considering you are doing it properly) there is one IEEP instance. Server and client holds different instances for EntityPlayers! PlayerEvent.Clone is SERVER event. It is not fired on client, thus any data on client is lost. You need to send all data from Clone event to given player, preferably at the end of it. In example above I have player.sync() called at the end of #copyTo(player) method.