Everything posted by Ernio
-
[1.8] Advice on adding a value to air
I'm not into that sort of thing. Not sure Fred is either. http://i.memeful.com/media/post/0MxZxzd_700wa_0.gif[/img] Made my day.
-
[1.8.8] Persistent Log of Player Stats
For stuff like this, you generally want to use IExtendedEntityProperties (IEEP). IEEP allows you to assign data to players and save it to player data file. Note that IEEP is only loaded when player is online, but nothing stands in your way to read player.dat yourself (Java IO and CompressedStreamTools). Also note that Vanilla alredy has some stats (I think it does track e.g blocks mined), just saying. Tutrial on IEEP: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and
-
[1.8][Java] Nashorn vs. Forge vs. Me!
Pretty much what I had in mind at first (make wrappers). I don't know answer to your question, but it would be easy to check, wouldn't it? Thanks for offering your code, I might almost-copy some of it, but I need to add a lot of mod-specific stuff anyway so...
-
[1.8][Java] Nashorn vs. Forge vs. Me!
So basically I wanted to have Nashorn script engine, but its quite annoying that everything typed in .js would have to follow MC/Forge obfuscation. Is there any way to make it look nice? My idea was to wrap everything with interfaces (e.g you don't use EntityLivingBase but IEEP interface and that interface holds shitload of getter methods that return EntityLivingBase's data and/or next wrapped classes). Problem with it would be next shitload of code and issue of not everything be "wrappable" i think. What I am thinking of is write scripts in deobf format and then during loading script somehow replace names with obf ones. Any hints on this would be nice (reseaching process).
-
[1.7.10] How to properly sync entity from server to client [Solved]
Keeping it very short. Facts: 1. Data: - NBT loading/saving is server side. - If you want to have ANY data on client, you need to send it. 2. Existance of entities: - Server knows about all currently loaded entities. - Client knows only about entities (creates them) that server tells it to spawn, simplier: * Client has only one world (in which player is in). * Client has only entities that are visible for given player in this world. 3. When synchronization (of entities) occurs: 3.1. Server tells client to spawn some entitiy that will be mirror of server's one. 3.2. Server changes values and sends them to players that are currently tracking entity. How? Where? (important points) 1. When entity is spawned (spawn packet is sent to client) and it implements IEntityAdditionalSpawnData you can send additional data within spawn packet. 2. There is this thing called EntityTracker, in simple words: it keeps track of which player watches which entity. (or other way around, which entity is watched by which players, those are internals, don't matter) 2.1. Whenever a player starts tracking new entity (meaning his client should be notified about entity's existance) - PlayerEvent.StartTracking event is called. It allows you to send additional data that cannot be placed in spawn packed (e.g for vanilla mobs). 2.2. Whenever something about your data changes you also need to notify clients. You do that with mentioned EntityTracker: EntityTracker et = ((WorldServer) entity.worldObj).getEntityTracker(); // You get EntityTracker of world in which there is entity you want to synchronize et.func_151248_b(entity, SimpleNetworkWrapper#getInstance().getPacketFrom(new SomeDataPacket()); // You need SNW instance, the method might vari between versions. The method itself says "send this packet to everyone who is tracking this "entity". Code above will result in packet about "entity" being sent to all clients (players) that are currently "seeing" it (tracking). Do note that if "entity" is EntityPlayer, the player himself will also be notified (player tracks himself), unless you use other method that is provided in EntityTracker (idk the name). 3. SimpleNetworkWrapper methods - there are things like sendTo(player, packed), etc. Those will be used if you want only specific clients to know stuff about entity. Can be used when data is private. That is all you will need, there are also DataWatchers (for simple data only), but I never liked them, so let's skip them. Setting up network is nothing more than making IMessage and Hanlder + SimpleNetworkWrapper. http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with EDIT Edited, recommeded to re-read. EDIT EDIT For god's sake - UPDATE to 1.8+ ! And then: http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html Also: 1.8 is better with dynamic updating, scheluding takes care of very annoying data-losses if you are working with (very) dynamic synchronizations. (E.g: You send packet, but client doesn't have entity constructed yet, boom - data is lost).
-
[1.7.10] Stop player from moving their head/Stop player moving altogether
It will require client side. In 1.8 - easily done with events. In 1.7.10 I don't think there is one for that, but you can replace Camera entity on game startup and just do your stuff there.
-
Question about Java version for making Forge mods
Short answer is Yes. Java 8 works fine.
-
Concurrent Modification Exception
1. Using "synchronized" kills purpose of having multi-threading (in Minecraft case it would cause Client tick to "wait" for Server tick or other way around, not to mention that it is totally logic-breaking). 2. If you SUPER-NEED to have one Collection for both threads (which is, as alredy mentioned: retarded), you will need... idk... Lock interface (ReentrantReadWriteLock.class). Which again - will break EVERYTHING, since stuff like this is not compatible with Minecraft design. Lock is used to perfom very fast actions while securing from concurrency. 3. MC is not designed to handle synchronization - so DON'T do that! 4. Make those 2 arrays or proxify your code : On MP: - Dedic runs ServerTickEvent on its own array. - Client runs ClientTickEvent on its own array. On SP: - Only ServerTickEvent manipulates array *Which I will AGAIN say - is REALLY bad. Server should not manipulate client stuff and other way around.
-
[1.8+] String -> NBT Parser.
I alredy made design and interpreter which handles loading script and is surprisingly fast (in execution, almost as fast as native). The biggest problem I face is that keywords I provide give power over more common game (and my mod) features, but they can't really interpret everything (obviously). Nashorn might be useful in implementing advanced-level scripts, which is cool Thanks for tip. Btw. If anyone know something about it (Nashorn) - particularly its performance problems (e.g what to not do), feel free to post it.
-
[1.8] TagList in IExtendedEntityProperties
Oh god... I am ashamed that I didn't notice this when I looked earlier today. compound.getTagList(identifier, Constants.NBT.TAG_LIST); Get List of NBTBase objects from "identifier" and "cast" them to "Constants.NBT.TAG_LIST". So yeah - you don't want LIST of LISTS, but LIST of TAGS, which is actually "10", not "9" (Constants.NBT.TAG_LIST). Note the fact: That way you can make e.g: List of strings or List or anything really. (just saying, something that i missed long ago in past).
-
[1.8+] String -> NBT Parser.
Took a glimpse. Looks nice so far. Good to know it exists. I am still as designing stage (of scripting language for my mod) so I have to account for all possibilities - here - reading NBT from cfg (for e.g setting Item's NBT). Thanks man!
-
[1.8+] String -> NBT Parser.
Does anybody know if vanilla has one or maybe there is some public implementation? I am asking about reverse-parsing of NBTBase.toString() (literally read returned string back to NBT). Yes, I know - I can write it, or do in milion other ways, just hate reinventing the wheel.
-
Concurrent Modification Exception
Jesus! CMO appears when you are manipulating contents of collection while they are being in use. Example: One thread is iterating through collection while other thread removes entries. Which is literally what you did. You have 2 arrays shared between client and server event. ClientTick is fired by client thread, server, by server. You need to have separate arrays for each logical side or not allow client to remove stuff. Also note that you should remember about thing called "dedic" where clients don't have server thread.
-
[1.8] Force player look from server side
Well, you are literally teleporting player every tick. That it at least "not very good". Also: You want PlayerTickEvent (PTA), not server one. It fires for every player. Note that Tick events have event.phase - pick one, otherwise code is ran twice. PTA also fires for client side - simple !world.isRemote will suffice. Learn da packets: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with or http://www.minecraftforge.net/forum/index.php/topic,20135.0.html
-
[1.7.10]Cancel block update Event for Farmland Dirt?
Above is your best shot (unless I am missing something). If you would want to dig around have a look at: BlockFarmland#updateTick You could maybe find some place you could hook into, but I don't think there is one, thus - replacing is best shot. Other way would be with ASM - simply inser literally ONE boolean line in BlockFarmland#updateTick that would return method if your condition is true (e.g set by config).
-
Deobfuscating Earlier Mods
I feel like mentioning that difference between 1.2.5 and current, especially 1.8 is SO BIG that updating or even reading old sources will bring none of there: 1. results (impossible to update); 2. knowledge (too outdated). You would be better of rewriting from nothing whole mod based on idea. Seriously, NOTHING is same. From basic stuff like Item, Block, TE, through packeting, data handling like IEEP to rendering which is even different from 1.7.10-1.8.
-
Experience help
You claiming you can do what you want for one skill pretty much convinces me you have no idea what you are doing Anyway, yeah: To store data per-player you need to implement IExtendedEntityProperties (IEEP). Tut: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and Create some mapping (HashMap?) that will hold data about given attributes (like in MCMMO plugin) and then use Forge Events (google it, I am talking about @SubscribeEvent) to keep track of player actions and change values in IEEP's mapping. Then you can use multitude of ways to utilize your attribute map (or whatever you will call it, I am refering to things like "jumping" "attacking" "woodcutting"... etc.). Note: Data in IEEP is NOT synchronized to clients so if you want to display stats in ANY other way than chat messages, you will need IMessages (Packeting). Tut: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with Overally: If you are new to object-oriented programming (and Java), you are screwed If you know your shit, grasping forge ways might take few dozen hours.
-
[SOLVED][1.8] Centering GUI Texture
http://www.minecraftforge.net/forum/index.php/topic,31297.0.html
-
[1.7.10] Creating new dimension
Well, after you setup your dimension you just need to spawn structure in it and always teleport player into it when he joins dimension. To make a dimension be void you just say that during generation - nothing generates, so literally - remove whole generation code and leave empty method. Spawning structure is a matter of having saved big array of blocks (in .java or .zip file (note that NBT can be written to .data files which are kinda of zips) or actually anywhere else) and setting them on by one with triple x/y/z iteration. If you would choose NBT you can read/write to it with CompressedStreamTools.class. About that iteration: Doing it with just one triple-loop would be buggy so I suggest making 2 or even 3. 1st one placing ONLY static blocks, second one placing block with tiles or blocks that need terrain updates, and 3rd one to place terrain-dependent stuff like torches or ladders. Teleporting player is matter of making sure that structure will always spawn on given coords and making player TP into given position. I don't really see the struggle (after you setup your dimension, which is 100% covered by linked tutorial, you even have working sources which you can freely edit).
-
[1.7.10] Creating a ship, boat like (Entity render?)
Currently there are few (outdated?) mods that introduce ships. More currently - theBest108 is developing quite awesome idea of making ships being their own world: http://www.minecraftforge.net/forum/index.php/topic,34903.msg184035.html#msg184035 As to problem: My guess is that you are on 1.8. To track placing blocks you will probably want PlaceEvent and check if there is a match. Then simply spawn new Entity (lookup boats). Entities require Renderer, which should be registered on game startup. If you registered .json model, then you can pull it from registry and render inside Renderer, as to how: MinecraftByExample might be helpful regarding how to work with models at all, but presonally I can't give you direct instructions about Entities, you might want to look at how EntityItem is rendered into world.
-
[1.7.10] Creating new dimension
http://lmgtfy.com/?q=Dimensions+Tutorial Seriously? 1 link. Literally.
-
[SOLVED] [1.7.10] Nested events
If several or one mod uses same event several times, event handlers will honor: 1. Priority (HIGHEST, HIGH, NORMAL, LOW, LOWEST) 2. Order of adding (registering) (and loading is dependent to mod-loading process, so also mod-dependency order) In this order.
-
Finding closest block downwards
Still not sufficient enough. Define "ground". Ground can be world height in given place or ANY block that is below you (which would also count if you were high on floating island or deep down in caves. No, you don't need to use rayTrace, if you just want to check what is below you you take player's pos and iterate down and check what block is on "player.posY - iteration". Now depending on "ground" definition - if ground would be ANY block that's it, but if you want to have ground height then it can get harder. Solutions may include saving world's height in given x/z into chunkData when world is generated.
-
[1.7.10] Shift + Mine Function ? <SOLVED>
You would know if you just looked at ANY tutorial on google... Search Forge Events. You are missing @SubscribeEvent. Event method takes only one argument - Event itself. You pull data only from event. Exacly like you did with event.action... If event is client side you can also use client classes, e.g Minecraft.class#thePlayer.
-
[Request] Documentation for all Forge-provided 1.8 model features
1. Don't do this here. It's forum, everything not pinned will be lost or not really "official" in a long run. 2. See that "Wiki" in forum's header list? If you have time - be my guest and start contributing. That is probably ONLY place that will presist through modders coming and going in future relases. 3. Someone has to start, and trust me - starting is the hardest part. Once there is something - maybe people will realize that it would be much better for everybody if instead of posting everyting 1000 times on this forum, just go and spend some time to write few times longer page on wiki, covering all future cases. Seriously - there is about 50+ same threads regarding one topic, sometimes they can be counted in hundreds. But when you think about it - forum will get quiet without questions, therefore - less "public discoveries" and "community thinking". 4. Official documentation won't help - if you are lazy, even code on plate won't be enough. To find out what can be done in 1.8+, you just need to literally sneak-peak on this forum and read few threads. Then - just look at code. Indeed - some of it is confusing, but then again: covering all cases is impossible, and there will always be questions. 5. I guess that writing post on forum (and debates) with helpful content gives much more satisfaction that just hitting buttons to put info on wiki. Human interaction (through forum) is quite important part of why this community exists, I personally would get bored after some time writing wikis (which I did a lot and still do, not Forge tho), knowing that there is possibility of noone reading it. 6. Finally: There has been a LOT of talking about making "official", more static knowledge base - but it was almost always only talking, most of tutorials are created by singularities and when it comes to creating something bigger - they are left alone to their development and only talk that presists is this forum (and maybe others). If you expect something that will PRESIST, you (in terms of "someone") should be one to start it and keep it going. People will come and go, but there must be this feeling that somebody is there - both creating it and using it. If that is not your (again in terms of "someone" not OP particular) intention, then I am pretty sure that MAIN reason why someone would want that it to make things easier for him (ofc. him will result in whole community, but creating public stuff for own benefit is less noble than creating something for others). Now that this (very inspiring... ) monologue is done - everyone who read it should really consider if they'd be up to actually making something useful and say it. It is NOT a big deal to make few wiki pages and put stuff in there - every forum user has access to editing.
IPS spam blocked by CleanTalk.