-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
From where? To send message you need to just have player instance. For client messages you get it from Minecraf.class, for multiplayer you need to somehow get it (player) - and how to do it depends on where you want to call method from.
-
Bro... this is thing whole Forge bases on - tutorials are everywhere, why waste time here There are tons on events - if asking about examples you gave - yes, for all of them. I'll note out what is needed: 1. Create MyEvents.class that will contain methods with annotation @SubscribeEvent 2. Register that classes instance in preInit. 3. There are several events buses - most is done from Forge's, some from FML (mainly ticking/server events), or other. Example of Forge event: @SubscribeEvent public void onHarvestDrops(HarvestDropsEvent event) { Block block = event.state.getBlock(); if (block == Blocks.iron_ore) { event.drops.clear(); event.drops.add(Items.apple); } } Registration: MinecraftForge.EVENT_BUS.register(new MyEvents()); For FML it would be: FMLCommonHandler.instance().bus().register(new MyFMLEvents()); And yes, one class can have multiple events.
-
http://ak-hdl.buzzfed.com/static/enhanced/webdr06/2013/5/20/15/anigif_enhanced-buzz-27009-1369078145-11.gif[/img] HE'S EVERYWHERE!
-
I have no idea what are you trying to accomplish with those: if (par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.hasItem(Items.wheat_seeds) || par3EntityPlayer.inventory.hasItem(Items.pumpkin_seeds) || par3EntityPlayer.inventory.hasItem(Items.melon_seeds) || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.ironNugget) || par3EntityPlayer.inventory.hasItem(DungeoneeringItems.pyriteDust)) You do not need to do so many checks, and most certainly you don't want to use #hasItem so much. After this loop your "theAmmo" will be the first ItemStack found in hotbar that is instance of your ammo item (apple). If you want item-comprasion: ItemStack theAmmo = null; for (int i = 0; i < 9; i++) { if (player.inventory.mainInventory[i] != null) { Item item = player.inventory.mainInventory[i].getItem(); if (item == Item.apple) { theAmmo = player.inventory.mainInventory[i]; break; //breaks loop } } }
-
I know exacly how to do it, question stands - is there a "nice" hook that would allow me to take control of colorizing stack in term of "ground" operations. Right now mc allows to set RGB of stack using integer (getColorForItemStack), problem with this method is the fact that is applies full-colorization. I'd like to make shading colorization. What I am after: 1. What I want (apply color palette that will care for shades/glows) 2. What MC does (full-colorization). Is there a place I could perform my own direct GL operations that happens AFTER returning model (so NOT inside SmartItemModel)? Obviously per-stack and per-layer (renderPass).
-
I'll just note that I too had this issue (on 1.. In my dev - randomly (but seriously - it was like few times, 0.1% to happen). I don't know why but I always felt like it was internet fault. Whenever that happened (very rare) - I was downloading something and had huge lag, almost couldnt login into game (mojang auth was taking about 10sec). So just saying - it might be forge/mc fault.
-
[1.8] Editing day lenght - can it be unsafe? (+question)
Ernio replied to Ernio's topic in Modder Support
Currently I have about 10min of day and night. RPG games can't go that fast - they simply can't. Imagine going on quest which should can be started only during sunset and you will get one night to complete it - can't do that in few min. I simply need to have more real days. At least 3x lenght. -
[1.8] Editing day lenght - can it be unsafe? (+question)
Ernio replied to Ernio's topic in Modder Support
This is exacly why I don't like vanilla. Me: "Hey guys, how about making it possible to speed up/down game?" Mojang: "Nah, we don't plan on doing it, we'll just HARDCODE shit out of MC!" Me: "But guys? Maybe getter?" Mojang: "HARD. CODE." Me: Problem is that this hardcode is actually in few places. I don't plan on Looking into Void (ASM) - it looks back! Example: if (args[1].equals("day")) { i = 1000; } else if (args[1].equals("night")) { i = 13000; } Because it would be so hard to make "day" be scallable value. Ok, so how do I replace WorldProvider of surface? EDIT I am not dumb, just waiting for maybe better ideas than I see right now: public final WorldProvider provider; I would just reflect shit out of this thing! Safe? -
[1.8] Editing day lenght - can it be unsafe? (+question)
Ernio replied to Ernio's topic in Modder Support
No no, that would split tick into 3, I need to extend their real number - I don't care about comatibility here actually. Is there some static field of ticks in day? I know there was some method which in I saw '24000' - question is, is there a getter I can alter or there is no actual place to 100% override it and I have to make tricks like one you proposed? (I don't know/remember where to look for those values). -
Considering there won't be problems with other mods, can changing day lenght from 20min(24000) to 1 hour (72000) create any unwanted stuff? If someone looked into it - please share exp. Also - where (right now it's just idea, didn't look into it) would I edit that value to be sure it will get edited (no glitches). EDIT: Question: Where does vanilla have utility to calculate ticks into world time? (e.g 24100 would give String "1 day, 5 sec") I am almost sure there is one somewhere, I just have no idea where is it even used (long time since I really player MC outside modding).
-
Just to point out - in your ticking classes there is so much pointless stuff. Please consider using real, forge-provided ticking events. You only waste resources doing it your way. @SubscribeEvent public void onPlayerTick(TickEvent.PlayerTickEvent event) { // do stuff for every player. event.player.doStuff(); }
-
I don't understand what you want.
-
net.minecraftforge.event.world.BlockEvent.PlaceEvent If it's not there, you setup your workspace badly. http://www.minecraftforge.net/forum/index.php/topic,14048.0.html
-
You can't directly replace whole class without using ASM. You can replace registry, but them you will create huge incompatybility. Best way is to utilize events. In your case you might want to use "PlaceEvent". Google on how to use Forge events. Write what exacly do you need for more help.
-
getString("effect") == "Toxic" That is not how you compare strings. == is comprasion of 2 objects. you need to use string.equals() EDIT Also - after decrementing stack's size you need to MANUALLY check if its == 0 and set stack to null (from player.inventory level).
-
Dude, what's the point of all that stuff? private static Set<Integer> KEYS_TO_TRACK = new HashSet<Integer>(); static { KEYS_TO_TRACK.add(Keyboard.KEY_SPACE); } @SideOnly(Side.CLIENT) @SubscribeEvent public void onInputEvent(InputEvent.KeyInputEvent event) { if (KEYS_TO_TRACK.contains(Keyboard.getEventKey())) { PacketDispatcher.sendToServer(new PacketKey(Keyboard.getEventKey(), Keyboard.getEventKeyState())); } } Then on receiver (Handler#onMessage): (server side) IEEP.get(player).setKeyState(message.getKey(), message.getReceivedState()) // where #getKey() is received key integer and #getReceivedState() is state boolean from client. In IEEP: (server-side) private Map<Integer, Boolean> keyMap = new HashMap<Integer, Boolean>(); public void setKeyState(int keyId, boolean state) { this.keyMap.put(keyId, state); } public Boolean getKeyState(int keyId) { return this.keyMap.get(keyId); // can be null } BAM - done and ready! Now you just ask (server-side) player - IEEP#getKeyState(KEY_SPACE) - and you know if the player is RIGHT NOW pressing space-key (on server! yay!). Keyboard.class MIGHT not be available on dedicated.jar so you might have to actually make copy of keys in there - literally copy them to some util class. Done and working.
-
new ItemStack(Items.dye, 1, 4)
-
It should
-
If you want to use static keys (hardcoded keys) - you simply ask Keyboard directly. @SideOnly(Side.CLIENT) @SubscribeEvent public void onInputEvent(InputEvent.KeyInputEvent event) { System.out.println(Keyboard.getEventKey() + " " + Keyboard.getEventKeyState()); } This will give you e.g "17 true" for holding "W" and "17 false" when you stop holding it. You can check directly for true/false and sent that in packet to server: e.g: Dispatcher.sendToServer(new PacketKey(Keyboard.getEventKey(), Keyboard.getEventKeyState())); If you want to let users define keys - you can make KeyBinding: public KeyBinding keyOne = new KeyBinding("keyOne", Keyboard.KEY_X, "key.categories.something"); and then in event - you simply do: keyOne.isPressed() KeyBindings can be changed in game option (are auto-added there).
-
HarvestDropsEvent clear list. OR - If your customBlock: Use: getItemDropped quantityDropped Or: getDrops - for total power over drops (like the event). Return empty list.
-
[1.8] Block and TileEntity Event (receiveClientEvent).
Ernio replied to Ernio's topic in Modder Support
Next part of MC in my head. As I was diggin into code I actually hit this part: I did some debugging: - Printing worldObj.loadedTileEntityList and worldObj.tickableTileEntities sizes() - Checking vanilla/breakpoints - Printing when TE's constructor is called. Results: 1. When shouldRefresh returns true both client and server will construct new TE - yet, that TE will NEVER be added to world's TE lists and will actually be discarded. I belive it is simply making sure that if in this pos there was no TE it would be set (but is not, since there is "old" TE), correct? 2. Sometimes Client constructs 2 TE for one server TE. Probably some synchronization stuff? 3. When shouldRefresh returns false - server STILL constructs new TE, only client doesn't. Now what I want to know is to understand what the author of shouldRefresh docs had in mind saying: /** * Called from Chunk.setBlockIDWithMetadata, determines if this tile entity should be re-created when the ID, or Metadata changes. * Use with caution as this will leave straggler TileEntities, or create conflicts with other TileEntities if not used properly. * * @param world Current world * @param pos Tile's world position * @param oldID The old ID of the block * @param newID The new ID of the block (May be the same) * @return True to remove the old tile entity, false to keep it in tact {and create a new one if the new values specify to} */ "if this tile entity should be re-created" - it doesn't seem to be recreated in any situation :C - when exacly that happens? "old" TE is never replaced by new one (new one is constructed), so what is "recreation" in this case? "this will leave straggler TileEntities" - when? "True to remove the old tile entity, false to keep it in tact" "create a new one if the new values specify to" - what? EDIT Indeed - when that will return false - server's TE is removed, client's one stays! Where exacly is "danger" is bad usage of this method? What can happen (aside client synchronization problems)? Thanks -
IEEP is literally an object assigned to EntityPlayer. Inside object you can hold any data - more object, tons of fields and references. Yes - you choose which data you want to save. Save/load data can be even empty if there is no need to save stuff. And why SHOULD you use EntityPlayer over ANY other self-designed system - it's just much easier to maintain and does everything for you, also - much cleaner code. Offtopic: "couple of days ago in this topic" - I didn't even looked at your nick to be honest. And indeed - you can hold your undo memory inside IEEP. (as long as it's not too big obviously).
-
I am sorry to inform you that that is 100% not true. IEEP can hold ANY data for ANY player on ANY side (server or client). If you don't use IEEP to store per-player data I am 99% sure that you are doing it wrong.
-
https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe03_block_variants