Everything posted by Ernio
-
[1.8] Obfuscation, files 'n stuff.
I need to have readable (not obf) names in standard (user) session so that I can write .txt scripts using them. Sadly that was not really possible with obfuscation so I made some wrappers for common code. After writing shitload of wrappers and almost-copied classes (e.g NBT) just to get "readable" names of methods/fields/classes during game, I got angry and decided to go other way. Why not write scripts in deobf format and then just translate it on-run. Sure, will take extra time and might even catch me off-guard with translation (but that is for me to deal with), but still - much prettier thing to do. Question: Does user-environment provide file with code translations? If not - Would shipping them within be reasonable? Where do I get them again? (idr directory).
-
[1.7.10]how to disable the Armor and hungerbar?
As to canceling "realities" of hunger bar and armor: You can replace player's FoodStats (and set them to do nothing/return default modifiers) in EntityJoinWorldEvent or ConstructingEvent. Extend FoodStats and replace player's field. As to armor - you can use PlayerTickEvent to remove armors from slots (player.inventory). If you would want other approach - Use LivingHurtEvent to cancel armor's modifiers on dealt damage.
-
[1.8] [SOLVED] Item added to inventory disappearing on world load
There should be similar method "setPositionAndUpdate" . Look into vanilla, you should find it.
-
[1.8] [SOLVED] Item added to inventory disappearing on world load
Lol, yeah, I'd probably try to reduce the indentation a few levels, for one This is what happens when you get back to "micro-optimization-is-bullshit-java" after finishing algorithmics project in savage C (notice how hard I tried to declare fields in smallest scopes and other mad shit and I didn't even do that well thing well - #sleepy)... Worthless code. And yeah - main point was to use world.isRemote (which he OP didn't in main post).
-
[1.8] [SOLVED] Item added to inventory disappearing on world load
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (!worldIn.isRemote) // run on server { TeleporterTileEntity t = (TeleporterTileEntity) worldIn.getTileEntity(pos); if (t != null) { ItemStack stack = playerIn.getCurrentEquippedItem(); if (stack != null && stack.getItem() == EnderScience.card) // you don't need separate items, but if you do... well, you can replace ItemStack like you did before, just do it on server. { NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { nbt = new NBTTagCompound(); stack.setTagCompound(nbt); } if (!nbt.getBoolean("punch")) // has NBT, but not punched, so punch { nbt.setBoolean("punched", true); nbt.setInteger("x", pos.getX()); nbt.setInteger("y", pos.getY()); nbt.setInteger("z", pos.getZ()); System.out.println("[Ender Science]: Teleporter coordinates: " + pos.getX() + " / " + pos.getY() + " / " + pos.getZ()); } else // punched, teleport { t.teleport(playerIn, worldIn, nbt.getInteger("x"), nbt.getInteger("y"), nbt.getInteger("z")); // change it to 3-arg coords. } } } } return true; } Ahh... this can be done nicer....
-
[1.8.9] Keep an item in the inventory on player death [Solved]
As I am myself not sure right now which combination will cover all cases, I will throw all, hopefully, helpful things: 1. LivingDeathEvent // Forge 2. PlayerEvent.Clone // Forge 3. PlayerEvent.PlayerRespawnEvent // FML 4. PlayerDropsEvent // Forge In any case - you will use 4. to make item not drop from player. Few ways: * Use 1. to save ItemStack to probably IExtendedEntityProperties and 3. to restore it. * Use 2. to clone ItemStack directly from old to new entity, BUT then it might get buggy since it fires in different kind of situations and only when you actually click respawn button (tho I am unsure). * It might be possible that forge handles that for you and allows you to presist items if they were removed from drop list in 4. - but you have to check it yourself. Basically - test this shit for it to suit your needs.
-
[UNSOLVED] How Do I Open A Large Chest Gui?
Well... Anyway: Look at calls: Block -> onActivated -> player.openGui(id = 0) -> No matter what, open "new ContainerDirtChest" on SERVER and "new GuiDirtChest" on CLIENT. You need to actually open proper container on server and then proper one on client (for gui to use).
-
[UNSOLVED] How Do I Open A Large Chest Gui?
Did you just seriously copied vanilla code and pasted it here saying "my code"? At least decipher that shit or noone's gonna help you. To open different container/gui you just need to check around block if it touches another chest-block. If it does you can open large one. Well, that is one way to do it. You can really open it anyway you want.
-
[1.7.10] Problem syncing NBT tag compound between client and server
I am very happy today (exams), so may I suggest my assistance in solving your problem via Skype? I really feel like coding some shit before I restart my own works Skype: ernio333
-
[1.8.8] How to make the player's hunger drain faster?
Or put it in player's IEEP if you need separate timer.
-
[1.8.9] Create texture/model from NBT
Well, you need to look more. I don't think anyone could provide better (full) tutorial on this right now. Show what you tried (and yes, learning this can take few hours and code-digging).
-
How to set + get the slot in players inventory that the current ItemStack is in?
I think this is everybody here now: (no offense intended) [Edit: Removed image. Sorry Ernio, but that was a step too far]
-
How to set + get the slot in players inventory that the current ItemStack is in?
int rand = worldIn.rand.nextInt(36); ItemStack someItem = player.inventory.mainInventory[rand]; player.inventory.mainInventory[rand] = itemstack; player.inventory.mainInventory[itemSlot] = someItem; I am learning for tomorrow exam - everything is (much) more fun than that ;_; Idk how it will work in client/server manners. EDIT Btw. I just LOVE how everyone else is trying their best to help OP without shooting themselves in head Lolololol EDIT Ah, yes indeed (post below)
-
How to set + get the slot in players inventory that the current ItemStack is in?
Nope. Its casting, not instanceof. You mean "rethink your life!" Why not? public void onUpdate(ItemStack itemstack, World worldIn, Entity entity, int itemSlot, boolean isSelected) { if (entity instanceof EntityPlayer) { EntityPlayer player = (EntityPlayer) entity; ItemStack old = itemstack; for (int i = 0; i < 36; ++i) { if (player.inventory.mainInventory[i] == itemstack) player.inventory.mainInventory[i] = null; // removes itemstack from inventory. } // At this point, your inventory doesn't have your itemstack anymore and "old" holds last reference to it. // What are you trying to do next is mystery to me. } } WHAT EXACLY are your trying to do?
-
[1.8.9] Create texture/model from NBT
ISmartItemModel Return different quads based on ItemStack's NBT. Quands can be generated manually or by MC model system (e.g by simply making model be loaded on game startup from .json file).
-
How to set + get the slot in players inventory that the current ItemStack is in?
ItemStack doesn't know where it is. It just is. If in inventory, inventory knows tho. player.inventory.mainInventory - array of 36 player slots, you can iterate through them, check if there is an item and replace/move it. Or are we talking about other inventories? IInventory has getStackInSlot(index) or you can return whole array if you want and do same as above.
-
[1.8]Tile Entity storage not synced server side?[SOLVED]
Umm... great, let's take "unknown" x/y/z and ask for TE. I belive not defined BlockPos has x/y/z = 0/0/0 so yeah...
-
[1.8.9] "Universal" Entity
Think about it, you are trying to render "entity" as "otherEntity". Logically - you need your renderer to use fields of "otherEntity". For example: @Override public void doRender(EntitySpectral entity, double x, double y, double z, float entityYaw, float partialTicks) { entity.getRender(renderManager).doRender(entity.otherEntity, x, y, z, entityYaw, partialTicks); // entity.otherEntity, you should also use "otherEntity" values everywhere else. }
-
[1.8] check if full Armor is worn (SOLVED)
I don't think anyone noted: TickEvents are ran twice. Use if(event.phase == Phase.START) to pick ONE. Otherwise code runs twice.
-
1.7.10 Some Questions about a global Data Structure+unique Manager on the Server
WorldSaveData (WSD). It allows you to save NBT to world. You can manually load NBT, put it in manager and then distribute it to client via packets. Saving and loading WSD happens on demand. If you would need additional hooks look at forge events (World events probably).
-
[1.8.9] Adding Additional Mods to Dev Environment
If you need to run FULL mod in dev, you will need dev-release (not obfuscated) or source code (search for mod's git repo). If you only need some reference you might wanna search for mod's API (if it has one).
-
[1.8] Custom Layer Render Problem
Are you getting "id" field from message passed to receive method? Post full code.
-
[1.8] Custom Layer Render Problem
Nope. Every entity has entityId. It is always the same on client and server (server sets client's entityId on spawn). You need to send packet from server to client with: player.entityId, itemStack, slotId. On client you read them, world.getEntityById(message.entityId) and then set player's client side inventory to received itemStack in some slotId.
-
[1.8.9] Updating 1.7 to 1.8.9
Hell yeah. OP - look at the damn code, its very easy to find stuff and examples. world.setBlockState(pos, blockInstance.getDefaultState().withProperty(possibly some properties)); // Note that this is example of usage. Read how to work with IBS.
-
[SOLVED] Custom GUI crashes game
IGuiHandler must return Container on server and Gui on client. You are returning containers on both. For example: Server: new ContainerFood() Client: new GuiFood(newContainerFood()) // you probably want this to be inside constructor.
IPS spam blocked by CleanTalk.