Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. http://new4.fjcdn.com/pictures/Calm+your+tits_428fdc_4406892.jpg[/img] I have no clue what is wrong but: 1. Mark your mod client only (Look insice @Mod annotation). 2. "Doesn't work" - you mean event is not called or it doesn't pass some if statement? Please place print inside event, export it and look into MC logs.
  2. If you only want to set block to air - you only need to call exacly that method and ONLY on server. Other methods are not what you may think.
  3. This should be called on server. Idk if you even should touch notify stuff.
  4. The forum's new syntax highlighter is trying to syntax highlight your comments. Well, that is obvious "d18" So then other question, is there something like [.code=java][./code] or something. Whoa... I didn't know =" " adds title:
  5. Something like this, idk wrote it in post: for (BlockPos pos : BlockPos.getAllInBox(blockPos.down(3).east(3), blockPos.up(3).west(3))) { IBlockState state = world.getBlockState(pos); if (state.getBlock() == WATER && state.getValue(BlockLiquid.LEVEL) == 0) do something and eventually call break if needed. } Source is either 0 or 15. or something, idk.
  6. // Assumed variable: "blockPos" double Grid = (blockPos.getDistance(x+_x, y, z+_z)); // double "Grid" will be equal to distance from "blockPos" to coords of your choice "x+_x, y, z+_z" - where idk what are those variables. Also - this has nothing to do with line below so idk why you even posted it. boolean IsSource = (world.getBlockState(blockPos).isFullBlock()); // you will get state at "blockPos" (x/y/z) and check if block is full. Idk if full block means that it is source of water - if you want to check for source you need to get META from STATE and check if it is source (meta=0 i think). P.S - what's up with this "bold" code formatting
  7. This is kinda like: "That thing doesn't do the thing I want it to. I don't understand the thing that is supposed to make that other thing do its thing". In other words - you are too vague and we are not gonna write method for you. You got one of best explanation of IBlockState there is - what do you not understand? * x,y,z is now BlockPos - wrapped x,y,z * You don't separately ask world about Block or Metadata at given x,y,z - you ask it about state which is wrapper for both block and metadata. * Metadata is no longer integer 0-15 (it is, but only in serialization), but is represented by properties inside said state. Those properties can be whatever you want, you can have plenty of them, it's just that given x,y,z can still only hold 16 bits of data (said serialization metadata). What is so hard?
  8. Simple answer: This is impossible. Longer answer: ItemStacks can be in World (EntityItem) or in Inventory (Entities' including players' or TileEntities' like chest and other). Aside from that - all of above can be loaded or unloaded from world. Notes: It is possible to parially keep track of stuff - but NEVER fully (because e.g if other mod would add ItemStack somewhere without you knowing, your whole system fails). Knowing above you could ask less demanding (from MC) stuff. Anything comes to you mind?
  9. If you would look at other Block's methods you'll see there are also deprecations. In 1.9 (or 1.9.4) Mojang apparently decided that @Deprecated will be used to mark methods as "internal" ones. Yes - this is miss-use of annotation, so also yes - don't worry about that (tho it's annoying). Deprecated for Blocks (and maybe few other things) means that given method can ever only be called by internals (so basically aside from @Overriding it you shouldn't ever call it) - or at least - this is what some of us come up with.
  10. Java (or programming) basics: "break" keyword in loop.
  11. If you copy code that you can't understand you shouldn't be doing it. If you don't know Java/Math (because this is only reason you could not understand GUIs, eventually GL which is also covered by google) - modding is not for you. Please post your code and describe what is not working and what you don't understand (and btw. it took me days to write similar-to-achivement gui skill map, well more advanced, so just saying - don't expect it to be easy).
  12. http://lmgtfy.com/?q=java+tutorial Literally 1st link. Prerequisites: * English language * Idk... Some math knowledge and intelligence? * Tenacity
  13. Write it as registry name + metadata. You can eventually serialize TileEntity if such exists at x/y/z. As for registry names - you could go with block IDs but mind that those are assigned per-world so your save would have to be for specific world and no other use outside it. If you have a large amount of blocks to serialize you can make local dictionary - make registry name have prive ID inside your NBT structure and then all blocks saved would use that dictionary reference to deserialize.
  14. 1. Read my caption. 2. Update. 3. Post your code. Problem: You are not respecting input data such as stack type and size and probably not checking output - that tutorial was lame if it didn't cover it. Lookup TileEntityFurnace for reference.
  15. Some stuff (1st point in this case, maybe others) if you didn't already catch it: http://www.minecraftforge.net/forum/index.php/topic,39341.msg207122.html#msg207122
  16. * What went wrong: Execution failed for task ':recompileMc'. > Unable to find a javac compiler; com.sun.tools.javac.Main is not on the classpath. Perhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre1.8.0_92" Seriously, people - how do you live through your every day? This is like direct answer to your question - you don't have compiler. javac is shipped wtih JDK, you have only JRE.
  17. 1. Read my caption. 2. Update to 1.9+ or you'll get close to none support. 3. Go to official Java tutorials - they are really good, study some java before modding. 4. Now back to MC - few things you need to know, some are in official docs (same link), but most importantly: http://mcforge.readthedocs.org/en/latest/concepts/sides/ 5. Particles are client-only, you basically need to grab a block and make it spawn particles on client whenever block is in cave (if i understood correctly). 6. I recommend looking up BlockFurnace - it has a method #randomDisplayTick (naming might vary) - it basically is used to spawn flame particles. You want to override same method for your block (don't forget annotations). 7. For checking "if cave" - this is quite dynamic problem that has no good answer. How do you know block is in cave? Cave can be deep underground or inside mountain. Cave can have a hole in ceiling, tho it would still be underground - how would you define it that is a cave? There are few things to check: Skylight - that doesn't define if it is cave or room. Depth (y coord) - well, there is a mountain problem. Blocks around - you can check against surrounding blocks if they naturally spawn underground - like stone, ores, gravel (but the what about dirt?) Scanning - scanning surrounding is generally considered very expensive. It has n^3 (box) checks so anything further than dozen or so becomes expensive. Happy for you - particles are client side and whole method #randomDisplayTick is also client only so whole process would go on client thread/side. basically you would have to write some dynamic algorithm that would know if the block is inside a "room". Combine them all and you can somehow define "cave". Point of interest (I don't remember if applies to 1.7): When in cave there is a special "cave" music - try tracking down how MC knows about caves, apply similar checks (I think it probably checks some stuff I mentioned).
  18. Like seriosuly - look at vanilla source. Please ask less general questions. General answer: GuiScreen with hella lot of rendering math and scrollable map (with objects placed onto it) - this is literally definition of GuiAchivements in vanilla. Insta edit: dammit d7
  19. We don't want .jar, we need source (git would be nice). You are probably using some dependency wizardy (I assume that since you have hella lot of other mods, if they are not dependency, please remove them for testing) or @SideOnly/Proxy where you are not supposed to, or some reflection magic. Seriosuly, there are plenty possibilities.
  20. I can't say I see what you say you do: Generally - Entity is on server and client so you have to resize it on both sides. And yeah - setSize should work (as long as you call it on both sides). You will want to do that from onUpdate() and make it so that Entity can't be moved and it "hovers" above ground. To do the hovering you won't be using bounding box (since you want box itself to hover) but you will be cancelling gravity. Since laser entity is bound to Block that emits it you can easily get Y of given block and in onUpdate() method cancel falling if (entity.posY <= block.posY + 0.5D) - well, something like this. But then I need to point out - if this is supposed to be an "entity laser" - you shouldn't be doing it like this. Unless you have some special reason for it, I'd do it more like: * Place TileEntity with all data (such as colors and direction) that uses custom renderer that basically renders given beam and all that. * Since it is TileEntity you can use onUpdate() to do ray-trace in direction the laser is going. Boom - you can limit range and you can gather all "hits" (entity or block) in given direction.
  21. I am not sure what you want, please elaborate. My interpretation: you want you little box to be inside laser (not fall) or you want it to expand in length (the box) with the laser itself (so it covers whole beam). So which one is it, or other?
  22. The methods are reserved for containers and are fired when you actually shift-click stuff. It basically is written separately for each possible container to respect all slots of all inventories displayed in given container (one container can display many inventories - e.g: player's, chest's, crafting grid's, on and on...). You can't just call those methods. They kinda work like this: "Oh, you shift clicked stack in some inventory at some index." -> "Lemme transfer that stack to the other inventory for you." -> *Iterates through other inventory* -> *Fills-up non-full stacks of same type* -> *Is something is left, places it in 1st possible slot - respecting design*. Those methods are always written (for specific stack) to do transfering (from inv to inv), if you would want to sort all stacks so that you will get nicely stacked (sorted) ItemStacks in one inventory - that would look totally differently. So yeah - you need to write your method.
  23. Version? In 1.9+ you have MobSpawnerBaseLogic, where magic happens: private boolean isActivated() { BlockPos blockpos = this.getSpawnerPosition(); return this.getSpawnerWorld().isAnyPlayerWithinRangeAt((double)blockpos.getX() + 0.5D, (double)blockpos.getY() + 0.5D, (double)blockpos.getZ() + 0.5D, (double)this.activatingRangeFromPlayer); } #isActivated and World#isAnyPlayerWithinRangeAt are say - untouchable. Conclusion is that you ineed will need to simulate EntityPlayer for it to work nice OR you can replace all mob spawners' logic with you own extension of MobSpawnerBaseLogic with #updateSpawner overriden to do proper checks (not only players). Simulating EntityPlayer was always pain in the ass, especially when you would (in this case) HAVE TO place it in World#playerEntities. This would become quite a nightmare because 1st - "fake" player would have to be "NOT_SPECTATING" (for spawners to even work) and that would cause a lot of not-wanted oucomes. Said that - the only real solution for me would be applying custom MobSpawnerBaseLogic to all mob spawners. Since there are only 2 extensions to that class - for block and for minecart, whole replacement would be limited to not-hard stuff. Now how to do such replacement is quite tricky. For me - only viable approach is injecting with ASM and that would even allow you to simply add hook in #isActivated method itself. Without ASM you could try to Reflect and replace TileEntityMobSpawner#spawnerLogic whenever TileEntity appears. Now this is also tricky - whenever TileEntity would be added to world, yo uwould have to check agains type (if mob spawner) and replace field. Following this logic - only thing left is to know how to catch loading TileEntity to world. I can have few guesses - use ChunkDataEvent.Load to scan and replace logic of loaded spawners, but idk if TileEnntities are alredy placed at the time of loading chunk (+ it would be server only replacement, which actually wouldn't bother you since your logic can be server only). Other idea would include maybe using WorldTickEvent to gather World#tickableTileEntities - check against mob spawners and reflacet/replace their logic. Or you could even simulate spawning logic without even using TileEntityMobSpawner#spawnerLogic. Your choice. I said my piece, rest is for you (or others with ideas).
  24. Yup, that is right. Few rules: 1. Data manipulation must always happen on server. 2. Gui is client-only! 3. In every case of guis that are supposed to edit something - you will ALWAYS send a packet. General design: * Gui action (e.g buton click) * Client packet to server * Server handles packet (note: thread safety) * Server checks agains requirements (if it is legal for player to do such edit) * Server modifies given ItemStack and client gets update. 4. Now here is a big note: (which you probably know) Whenever there is ItemStack on display (in gui) - there is also Container which handles syncing ItemStacks' visible in-container positions. When ItemStack would get edited on server without notifying - client will stay with old data (that's why it would get updated once you actually move it). Logically - after editing ItemStack on server (from mentioned packet) you will need to notify change. You pretty much do that manually (by sending packet server -> client wth update of stack at given slot in current container which can be accessed from player instance) or you could probably use some internal thing - lookup Container code such as transferStackInSlot and other (which I think does those). 5. Now - you may ask - "If I do it (change) on client-only, why it sometimes gets saved?" - well, if nothing changed since I was hanving fun with it - just change your game mode (creative game mode allows bi-directional ItemStack updates) - that is if nothing changed.
×
×
  • Create New...

Important Information

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