Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Izzy Axel

Forge Modder
  • Joined

  • Last visited

Everything posted by Izzy Axel

  1. So doing: if(!Minecraft.getMinecraft().theWorld.isRemote) would be correct then?
  2. Ok, well I'm unsure of a few things now. One, how am I going to get a world object that contains the correct instance inside the client proxy, two, am I just making a new void method inside the proxy for this, or what? Third, I don't know how to make the packet do things, I don't know where to put that code or how to check for the packet and its contents. Fourth, I'm using NBT because I've never heard of IExtendedEntityProperties and obviously then, don't know what it is or how to use it.
  3. Ok, I've gotten this far, but I'm unclear on where I need to be handling the message, and what I need to be doing there that relates to the gating on the talisman, and I'm not sure if this is the right way to be sending the packet. Main IMessage/IMessageHandler Flight Talisman
  4. Please don't tell me I need packets again, I never got them to work (or even compile) the last time I tried to use them... >_> I tried this: Flight Talisman but then it doesn't function at all in SSP. And thanks, that worked.
  5. Ok I reworked the functionality, but now I'm checking for space being held, which I'm doing with if(Keyboard.isKeyDown(Keyboard.KEY_SPACE)) This is giving a noClassDefFoundError on org.lwjgl.input.Keyboard when I try to put it in my inventory on a server. What's going on here, and how do I fix it? Second question is, this is a raw input, how do I gate this with checks of whether the player is in the esc menu, inventory screen, or chat menu?
  6. Yeah, I figured that out last night, now I'm doing a null check that creates the tags inside both onCreated and at the beginning of onUpdate/PlayerTickEvent.
  7. Ok, I'm trying to do NBT tags, but it seems that onCreated isn't being evaluated before onUpdate or hasEffect, because I'm getting NPEs on things in both, how do I fix this? public class ItemAirTalisman extends ItemArtifact { public ItemAirTalisman(CreativeTabs tab) { super(); setUnlocalizedName("airTalisman"); setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5)); setCreativeTab(tab); setMaxStackSize(1); setMaxDamage(512); } @Override public void onCreated(ItemStack stack, World world, EntityPlayer player) { if(stack.stackTagCompound == null) stack.setTagCompound(new NBTTagCompound()); stack.stackTagCompound.setInteger("Damage", 0); stack.stackTagCompound.setBoolean("Active", false); } @SideOnly(Side.CLIENT) @Override public boolean hasEffect(ItemStack stack) { return stack.stackTagCompound.getBoolean("Active"); } @Override public void onUpdate(ItemStack stack, World world, Entity player, int slot, boolean p_77663_5_) { if(player.isInWater() && stack.getTagCompound().getInteger("Damage") < 510) { stack.stackTagCompound.setBoolean("Active", true); stack.stackTagCompound.setInteger("Damage", stack.getTagCompound().getInteger("Damage") + 1); player.setAir(1000); } else if(stack.getTagCompound().getInteger("Damage") == 511 || !player.isInWater()) stack.stackTagCompound.setBoolean("Active", false); if(!stack.stackTagCompound.getBoolean("Active")) stack.stackTagCompound.setInteger("Damage", stack.getTagCompound().getInteger("Damage") - 1); if(stack.getTagCompound().getInteger("Damage") > 511) stack.stackTagCompound.setInteger("Damage", 511); } } (code unrelated, tried this on a simpler class to learn first)
  8. It's an item that, when activated, allows you to fly for a bit, but it doesn't need to be held once its activated to work. I'm using the durability for the timer. The main issue right now is when on a server, right clicking after it's been activated refills the durability completely and deactivates it, instead of just deactivating it, and the fall damage code doesn't work. Both work on SSP. public class ItemFlightTalisman extends ItemArtifact { ItemStack iStack = new ItemStack(this); boolean recharging = false; boolean using = false; boolean active = false; int buffer = 0; public ItemFlightTalisman(CreativeTabs tab) { super(); setUnlocalizedName("flightTalisman"); setTextureName(Reference.MODID + ":" + getUnlocalizedName().substring(5)); setCreativeTab(tab); setMaxDamage(401); setMaxStackSize(1); } @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if(world.isRemote) if(!active && stack.getItemDamage() == 0) { player.capabilities.allowFlying = true; player.capabilities.isFlying = true; active = true; } else if(active) { player.capabilities.allowFlying = false; player.capabilities.isFlying = false; active = false; } if(!world.isRemote) if(active) world.playSoundAtEntity(player, "random.orb", 0.3F, 0.85F); else if(!active && !recharging) { recharging = true; world.playSoundAtEntity(player, "random.orb", 0.3F, 0.725F); } return stack; } @SideOnly(Side.CLIENT) @Override public boolean hasEffect(ItemStack stack) { return active; } @SubscribeEvent(receiveCanceled=true) public void playerTick(PlayerTickEvent event) { if(event.player.capabilities.isFlying && active) buffer = 1; if(buffer == 1 && active && event.player.worldObj.isRemote) { event.player.fallDistance = 0.0F; if(event.player.onGround) buffer = 0; } if(active) { iStack.setItemDamage(iStack.getItemDamage() + 2); using = true; } else if(!active) using = false; if(!using && iStack.getItemDamage() > 0) iStack.setItemDamage(iStack.getItemDamage() - 1); if(iStack.getItemDamage() == 0) recharging = false; if(iStack.getItemDamage() == 400) { active = false; event.player.capabilities.isFlying = false; event.player.capabilities.allowFlying = false; if(!event.player.worldObj.isRemote) event.player.worldObj.playSoundAtEntity(event.player, "random.orb", 0.3F, 0.725F); } if(iStack.getItemDamage() > 400) iStack.setItemDamage(400); } }
  9. onUpdate in an item class. The item works anywhere in your inventory, so I need the specific instance.
  10. Problem with that is, it's not passing in the instance of the affected stack, which I need to get to manipulate the durability, so is there any way to get both EntityPlayer and the stack without having to split the code up and use constant janky checks and timing between playerTickEvent and onUpdate?
  11. Capabilities isn't a member of Entity, what do I need to do to get the EntityPlayer instance of the relevant player inside onUpdate()? I tried this: EntityPlayer playerEnt = (EntityPlayer)player; But this may or may not cause some wonky behavior with the rest of the code for this item that isn't present in SSP. Edit: It's on a server that everything goes to hell.
  12. That doesn't work either. Edit: It turns out it was something unrelated getting in the way. I'll have to use a combination of both of those though.
  13. That's what I already tried, it just leaves you floating until you double tap spacebar again.
  14. I couldn't find the code on how switching gamemode does this, but I'm using player.capabilities.allowFlying to give flight, however when the duration of the item runs out, the player doesn't drop if they're flying when it happens, so how do you do force them out of flight?
  15. I figured the reflection out shortly after posting that last reply, but it turns out I never needed it.
  16. Ok, so then I'd need to change the constructor to SendParticles(int message) instead of SendParticles(String message), then how should I alter the fromBytes and toBytes methods to work with these changes, readVarInt? If so, what would the maxSize be? public class SendParticles implements IMessage { private int index; public SendParticles(int index) { this.index = index; } @Override public void fromBytes(ByteBuf buf) { index = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, index); } public static class Handler implements IMessageHandler<SendParticles, IMessage> { @Override public IMessage onMessage(SendParticles message, MessageContext ctx) { Artifice.comProxy.doParticles(message); /*WorldClient clientInst = Minecraft.getMinecraft().theWorld; Entity ent = clientInst.getEntityByID(Integer.parseInt(message.toString())); if (message.equals("helmet")) { clientInst.spawnParticle("suspend", ent.posX, ent.posY, ent.posZ, 0.0D, 0.0D, 0.0D); } if (message.equals("chestplate")) { clientInst.spawnParticle("suspend", ent.posX, ent.posY + 0.6D, ent.posZ, 1.0D, 1.0D, 1.0D); } if(message.equals("leggings")) { clientInst.spawnParticle("suspend", ent.posX, ent.posY + 0.4D, ent.posZ, 1.0D, 1.0D, 1.0D); } if(message.equals("boots")) { clientInst.spawnParticle("suspend", ent.posX, ent.posY + 0.2D, ent.posZ, 1.0D, 1.0D, 1.0D); }*/ return null; } } } Edit: Additionally, it's erroring on func_151247_a, and says to change it to func_151248_b, then that errors and says to change it back to func_151247_a. What do I want to do here?
  17. What am I supposed to be doing for "YourPacket"? Packet from net.minecraft.network.Packet is abstract, so what am I using here?
  18. @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { WorldServer overworldInst = MinecraftServer.getServer().worldServers[0]; if (overworldInst.isDaytime()) { if (player.onGround && player instanceof EntityLivingBase) { if(entity.onGround && entity instanceof EntityLivingBase) { Vec3 playerLook = player.getLookVec(); entity.motionX = 0.0D; entity.motionY = 1.0D; entity.motionZ = 0.0D; player.setVelocity((playerLook.xCoord * 0.5) * -1.0D, 0.0D, (playerLook.zCoord * 0.5) * -1.0D); stack.damageItem(5, player); return true; } else { Vec3 playerLook = player.getLookVec(); entity.motionX = playerLook.xCoord * 2; entity.motionY = 0.0D; entity.motionZ = playerLook.zCoord * 2; stack.damageItem(1, player); return true; } } else { return false; } } else { return false; } } There we go That hits like a sword while jumping or at night, and does the special actions while on the ground during the day.
  19. Alright, and one other thing about swords that's not being obvious to me right now: what do I have to do to make it damage entities normally at night? Currently it does nothing at night.
  20. This is on a sword by the way, not armor. And ugh how did I miss that method, I went through the autocomplete list like 6 times...well, onGround + motion works, thanks! Also I derped, you can't have the isRemote check in here because you need to affect the position of entities on the server. With that check in, the entities just snap back to where they originally were when their position on the server is re-evaluated. @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { WorldServer overworldInst = MinecraftServer.getServer().worldServers[0]; if (overworldInst.isDaytime()) { if (player.onGround && player instanceof EntityLivingBase) { if(entity.onGround && entity instanceof EntityLivingBase) { entity.motionX = 0.0D; entity.motionY = 0.8D; entity.motionZ = 0.0D; player.jump(); stack.damageItem(5, player); } else { Vec3 playerLook = player.getLookVec(); entity.motionX = playerLook.xCoord * 2; entity.motionY = 0.0D; entity.motionZ = playerLook.zCoord * 2; stack.damageItem(1, player); } } } return true; } However, the damaging of the stack is buggy, when the durability runs out, it plays the break noise, but resets the damage to full. If you try to break a block with it, the "new" sword disappears.
  21. Ok, well, inverting isRemote breaks it; the player no longer is affected, and the mobs being airborne still isn't detected.
  22. Is there any workaround for getting if an entity is in the air, or falling? @Override public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) { if (entity.worldObj.isRemote && entity.worldObj != null && entity.worldObj.isDaytime()) { stack.damageItem(5, player); if(!entity.isAirBorne) { System.out.println("grounded"); entity.setVelocity(0.0D, 1.0D, 0.0D); player.setVelocity(0.0D, 1.0D, 0.0D); } else { System.out.println("airborne"); entity.setVelocity(0.0D, -1.0D, 0.0D); } } return true; } This always prints "grounded" and adds more positive velocity to both.
  23. I'm kind of lost right now, how can I handle the packet in the proxy if its not implementing IMessage, and doesn't have all the rest of the packet handling class inside it? I haven't had to use proxies yet either so I don't know if I'm missing things in it that I'd need. And, I couldn't find anything suitable in WorldServer.
  24. Alright, am I doing this right? Now, I'm not sure how to spawn the particles inside the conditionals inside the packets receiver, or if that's not where I do it, then where? Additionally, when I try to specify the entity to send the packets to, I can't seem to find anything that returns EntityLivingBase in event? MithrilArmorParticles public class MithrilArmorParticles { @SubscribeEvent public void spawnArmorParticles(LivingHurtEvent event) { EntityLivingBase entity = event.entityLiving; if(event.entityLiving.worldObj.isRemote && !event.entityLiving.worldObj.isDaytime()) { for (int i = 1; i < 4; i++) { Item entArmor = entity.getEquipmentInSlot(i).getItem(); if(entArmor instanceof ItemMithrilHelmet) Artifice.networkWrapper.sendTo("helmet", event.entityLiving); //this is EntityPlayerMP, takes EntityLivingBase, how do? if(entArmor instanceof ItemMithrilChestplate) Artifice.networkWrapper.sendTo("chestplate", event.entityLiving); //this is EntityPlayerMP, takes EntityLivingBase, how do? if(entArmor instanceof ItemMithrilLeggings) Artifice.networkWrapper.sendTo("leggings", event.entityLiving); //this is EntityPlayerMP, takes EntityLivingBase, how do? if(entArmor instanceof ItemMithrilBoots) Artifice.networkWrapper.sendTo("boots", event.entityLiving); //this is EntityPlayerMP, takes EntityLivingBase, how do? } } } } SendMParticles public class SendMParticles implements IMessage { private String text; public SendMParticles() { } public SendMParticles(String text) { this.text = text; } @Override public void fromBytes(ByteBuf buf) { text = ByteBufUtils.readUTF8String(buf); } @Override public void toBytes(ByteBuf buf) { ByteBufUtils.writeUTF8String(buf, text); } public static class Handler implements IMessageHandler<SendMParticles, IMessage> { @Override public IMessage onMessage(SendMParticles message, MessageContext ctx) { System.out.println(String.format("Received %s from %s", message.text, ctx.getServerHandler().playerEntity.getDisplayName())); if (message.equals("helmet")) { event.entityLiving.worldObj.spawnParticle("suspend", entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D); //how do now? } if (message.equals("chestplate")) { event.entityLiving.worldObj.spawnParticle("suspend", entity.posX, entity.posY + 0.6D, entity.posZ, 1.0D, 1.0D, 1.0D); //how do now? } if(message.equals("leggings")) { event.entityLiving.worldObj.spawnParticle("suspend", entity.posX, entity.posY + 0.4D, entity.posZ, 1.0D, 1.0D, 1.0D); //how do now? } if(message.equals("boots")) { event.entityLiving.worldObj.spawnParticle("suspend", entity.posX, entity.posY + 0.2D, entity.posZ, 1.0D, 1.0D, 1.0D); //how do now? } return null; } } } main class @Mod(modid = Reference.MODID, name = Reference.NAME, version = Reference.VERSION) public class Artifice { public static SimpleNetworkWrapper networkWrapper; @EventHandler public void preinit(FMLPreInitializationEvent event) { networkWrapper = NetworkRegistry.INSTANCE.newSimpleChannel("SendMParticles"); networkWrapper.registerMessage(SendMParticles.Handler.class, SendMParticles.class, 0, Side.CLIENT); MithrilArmorParticles MiArPa = new MithrilArmorParticles(); MinecraftForge.EVENT_BUS.register(MiArPa); } }
  25. I have no idea how to do that. I'm using LivingHurtEvent because it's what shieldbug1 suggested. What event should I be subscribing to if LivingHurtEvent is server sided?

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.