Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. 1st glance - rendering goes to init() not preInit(). Try that. Other than that - make sure your renderers are not breaking class parenting. If above won't work, code would be nice.
  2. If this is what you are asking then above should be correct. I could quote Diesieben if i could find it. So from client to server you need to split and put it back together on your own.
  3. Balkon's Weapon Mod. Just to note out: I've never actually tested this stuff ouside of what is done by BWM. This code: https://github.com/Ckathode/balkons-weaponmod/blob/e223e96333734dcaff737a05482f5ce3b6eee968/src/main/java/ckathode/weaponmod/WMClientEventHandler.java Very clearly IS ClientEvent (even class name says so), that's why I wrote "What I am certain of is that BWM is running this on CLIENT only". And yeah, I found the code responsible: PlayerControllerMP#attackEntity sends C02PacketUseEntity which is then processed on server: if (entity != null) { boolean flag = this.playerEntity.canEntityBeSeen(entity); double d0 = 36.0D; if (!flag) { d0 = 9.0D; } if (this.playerEntity.getDistanceSqToEntity(entity) < d0) { So max reach is 3/6.0D. Altering this any further would require you (someone) to either use ASM and override value, make new attackPacket as coolAlias sugested OR override whole NetHandlerPlayServer.class which would be shocking easy since it's Interface (overkill). EDIT: You were faster jabelar I don't know why I didn't get notification.
  4. Also little note: you have little flaw/dead code in your tutorial: IExtendedReach ieri; if (itemstack != null) { if (itemstack.getItem() instanceof IExtendedReach) { ieri = (IExtendedReach) itemstack.getItem(); } else if (itemstack.getItem() instanceof IExtendedReach) { ieri = (IExtendedReach) itemstack.getItem(); } else { ieri = null; } Both else if and else is totally useless. As to problem: What I am certain of is that BWM is running this on CLIENT only - yet it works on server. I'll also probably look into code. And for now - maybe someone else knows
  5. Funny - I am doing (almost) exacly same thing (Allowing players to make their own model). And in this case - yeah, I wrote my wrapper for packets. Just cache stuff use checksums and everything should work nice.
  6. Extending reach was on my todo list for some time (after I finish other stuff) and I'll be there soon. I always planned to look into BWM but looking at it now - could someone explain to me not how, but WHY calculating reach and making attack on client works with server? What I mean - if doing whole thing in client event and just telling server to do it (attack) works, wouldn't that mean that you can write client mod that will extend your reach to e.g 10 blocks? Why does the server allow such reach-change if it goes from client? EDIT: My guess is there is some auto-correcting thing where server allows values up to some point, because if there is not, the above would be true, and that is just ridiculus for me.
  7. Packets from server to client are being automatically split into partial packets if you excess normal packet size. From client to server they are not so you would have to write your own wrapper. I've heard that opening new connection (thread) between client and server can cause problems (sometimes). Heard it long ago, never actually tested because I jumped straight into packets. I am sending .jar files (skills) from server to client on connection (using checksums to check cached jars) and I classLoad them dinamically after they finish downloading - no problems with that so far. Using packets and dynamic classLoading I managed to send code, resources, models, even music.
  8. Seriously man? I LITERALLY gave you WORKING code.
  9. I think I know: If the problem is not in event (if you have problem, this MUST work): @SubscribeEvent public void onEntityTick(LivingUpdateEvent event) { if (event.entityLiving instanceof EntityPlayer) { System.out.println("WORKS"); Then the problem is in potions. I've never really read the code responsible for updateing potion, but I know that setting time to 1 will get you nowhere. Set Potion tick time to >= 2.
  10. Not really possible, how/where are you registering it, show full code.
  11. if (event.type == ElementType.ALL) EDIT Also (just noticed) PICK PHASE: RenderGameOverlayEvent.Pre RenderGameOverlayEvent.Post
  12. RenderGameOverlayEvent has phases (or types, i don't remember). If you don't define phase (with if statememnt) your code will be executed about 12 or 13 times: for FOOD, HEALTH, etc. You need to draw in only one ("ALL" maybe). As to your bug - it might be fontrenderer binding ASCII textures. Picking one phase (ALL) should fix it. If not - you need to rebind texture WIDGETS (or ICONS, whatever, you know what I mean).
  13. @EventHandler public void preLoad(FMLPreInitializationEvent event) { proxy.registerPre(); } public class CommonProxy { @SideOnly(Side.CLIENT) public KeyHandler keyHandler; //will exist only on client.jar public void registerPre() {} // Empty, you will override it on clientProxy } public class ClientProxy extends CommonProxy { @Override public void registerPre() { keyHandler = new KeyHandler(); // this is keyHandler from superclass. FMLCommonHandler.instance().bus().register(keyHandler); //You register it only if you are running client.jar } } The to reference it: public void someMethod() { MainMod.proxy.keyHandler } On dedic.jar this will crash since CommonProxy doesn't have this field, but you don't use in on server, do you? On client.jar you will get keyHandler from ClientProxy.
  14. Few facts: 1. You can't do this: EntityLivingBase mob =(EntityLivingBase) movingobjectposition.entityHit; Without first checking if that movingobjectposition is Living. if (movingobjectposition.entityHit instanceof EntityLivingBase) { ((EntityLivingBase) movingobjectposition).doStuff(); } 2. That is NOT how you deal damage, mionecraft has DamageSources for a reason, it even has alredy made armour piercing sources and poison. entityLiving.attackEntityFrom(DamageSource.XXX, float); Look at DamageSources - you can use e.g DamageSource.starve to deal absolute damage, but that is not way to go, since if you die it will display you died of hunger. You can make your own DamagSource which will .setDamageIsAbsolute(); or .setDamageBypassesArmor() 3. To add poison you will need: (example) entityLiving.addPotionEffect(new PotionEffect(Potion.poison.id, 50));
  15. This is not really a bug, just for the record - it was like that since forever, it is ClientTick, not world, nor anything else, also I am myself using this event also since forever and I do same if statement that you are doing in order to make world decrement some integer within server (WorldTick is only (unless something changes lateely) called from Server thread on server worlds, I needed to tick also on client world). Just sharing experience.
  16. In scale from BAD to GOOD you are at UGLY. (I just really hope someone gets reference). What you are doing will not work outside dev and is simply overkill. List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); Use this code. Then simply: defaultResourcePacks.add(new IResourcePack()) // your class that implements it. // Example: new RaceResourcePack(new File("C:/Users/You/.../.../.minecraft/SUK2/Resources/RacesResources.zip") The implementation: public class RaceResourcePack extends FileResourcePack There is simply NO way that calling this in FMLInitializationEvent will not work. (with refreshing resources). If your rsc won't be found using above mistake is in assets. Edit: I'll look deeper, soon.
  17. Rendering, textures ALWAYS goes in/after init(). It's a good practice, even if preInit() works fine. Try that.
  18. I assumed you did that, did you? You have to realod mc resources after ANY changes in resource list. Thats what MC does (and why you get lag for few sec) after you load rsc-pack in ResourcePack menu. I don't remember exact method but something like: Minecraft.getMinecraft().reloadResources() Corrected: Minecraft.getMinecraft().refreshResources(); Edit: I am blindly guessing solutions. If above is not the case, you will need to post code - Git would be nice.
  19. Uhm. In most cases you will want to make new class extending GuiScreen. Override initGui() to add buttons and initialize other sub-gui stuff (like lists for example). Then in drawScreen you will need to draw those buttons and other parts you want. Use actionPerformed to track button-clicks. mouseClicked is good to track some more customized mouse actions - e.g moving lists. There are a lot of other stuff, but that is mostly it. You can open GUI using player.openGui or mc.displayGuiScreen(gui) - second one is CLIENT ONLY. Remember that initGui() is called on every rescaling and that you need to pull values like width/height of screen from super-class.
  20. This is not really how design works. The domain is literally named by assets themself. Let say you want to load customResource.zip which contains: assets.domain.textures.gui.someGui.png After adding this IResource into default list (accessed by reflection) the domain is "domain". In other words - the domain is literally first filename after assets/'here'.
  21. This is totally wrong, do: 1. Make KeyBinding for your key. Subscribe to InputEvent.KeyInputEvent and check wether key was pressed and/or unpressed. 1.1. On key pressed: set som boolean to true and send packet FROM client TO server that key is pressed (true). 1.2. On key unpressed send another packet - false (from client To server) that will tell server that you stopped holding it. 2. Make PlayerTickEvent ONLY (and ONLY) check your boolean on server side, since server will now know that you pressed button (this true/false) you can make if on that boolean and operate on server-side. 2.1. Do your stuff. Notes: Save that boolean per-player, so inside ExtendedPlayer (IEEP class).
  22. Wrong forum. Update your forge. Check if all mods work for this version.
  23. If you would make GOOD design, the client would be only a mirror of server shop, so only thing you would neex was an index. Let's say you open shop, server loads all ItemStacks that this shop can sell and puts them into some ItemStack[]. Those stacks would be sent to client with corresponding ID: @Override public void toBytes(ByteBuf buffer) { for (some for loop that would write all possible itemstacks, index++) { buffer.writeInt(index); PacketBuffer pb = new PacketBuffer(buffer); pb.writeItemStackToBuffer(this.stack); } } You get the idea. On client you would have mirror of what server has and inside packet that should say "buy this item" you would only have to send the ID of button you pressed ("buy") and index of slot. Otherwise - you can always use pb.writeItemStackToBuffer(this.stack); and do this other way around. I am presenting how it would be smart. That's probably similar to what villagers do (I think).
×
×
  • Create New...

Important Information

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