Jump to content

ketchup_god

Members
  • Posts

    19
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

ketchup_god's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Ah of course, somehow didn’t notice. Thanks for the help, I’ll try it out.
  2. @Mod.EventBusSubscriber(modid = BadMinecraftFeatures.MOD_ID, bus = Bus.FORGE, value = Dist.CLIENT) public class OnPlayerDamage { @SuppressWarnings("resource") @SubscribeEvent public static void onPlayerDamage(LivingDamageEvent event) throws InterruptedException { Entity entity = event.getEntity(); if (!entity.world.isRemote()) { if (entity instanceof PlayerEntity) { Item MainItem = ((PlayerEntity) entity).getHeldItemMainhand().getItem(); if (MainItem == ItemInit.totem_of_dying) { double x = entity.getPosX(); double y = entity.getPosY(); double z = entity.getPosZ(); ((PlayerEntity) entity).inventory.deleteStack(((PlayerEntity) entity).getHeldItemMainhand()); //Minecraft.getInstance().gameRenderer.displayItemActivation(new ItemStack(ItemInit.totem_of_dying, 1)); entity.world.playSound( x, y, z, SoundEvents.ITEM_TOTEM_USE, SoundCategory.MASTER, 1.0F, 1.0F, false); entity.attackEntityFrom(CustomDamageSources.TotemDamage, 100); //Minecraft.getInstance().particles.addParticleEmitter(entity, ParticleTypes.TOTEM_OF_UNDYING); } } } else { return; } } } I did multiple tests with removing some parts of the code, and every time it worked fine in singleplayer but just didn't run in multiplayer. The items were initialized and everything, it's just that the event didn't run.
  3. I set up a server to test the mod after adding the World#isRemote test and compiled the mod. I could connect to the server fine and everything worked, but the LivingDamageEvent just wouldn't run.
  4. Alright, I'm guessing I need to send a packet to the server or do something along those lines because those methods are all serverside, right?
  5. @Mod.EventBusSubscriber(modid = BadMinecraftFeatures.MOD_ID, bus = Bus.FORGE, value = Dist.CLIENT) public class OnPlayerDamage { @SuppressWarnings("resource") @SubscribeEvent public static void onPlayerDamage(LivingDamageEvent event) throws InterruptedException { World world = Minecraft.getInstance().world; Entity entity = event.getEntity(); if (entity instanceof PlayerEntity) { Item MainItem = ((PlayerEntity) entity).getHeldItemMainhand().getItem(); if (MainItem == ItemInit.totem_of_dying) { double x = entity.getPosX(); double y = entity.getPosY(); double z = entity.getPosZ(); ((PlayerEntity) entity).inventory.deleteStack(((PlayerEntity) entity).getHeldItemMainhand()); Minecraft.getInstance().gameRenderer.displayItemActivation(new ItemStack(ItemInit.totem_of_dying, 1)); world.playSound( x, y, z, SoundEvents.ITEM_TOTEM_USE, SoundCategory.MASTER, 1.0F, 1.0F, false); entity.attackEntityFrom(CustomDamageSources.TotemDamage, 100); for (int i = 0; i < 5; i++) { Minecraft.getInstance().particles.addParticleEmitter(entity, ParticleTypes.TOTEM_OF_UNDYING); TimeUnit.MILLISECONDS.sleep(100); } } } } } Here's the code. I haven't set up a git repo yet, will in the future
  6. I am trying to make it so that when the player takes any damage, they instantly die with a custom death message. To display message, I needed to use attackEntityFrom(CustomDamageSource, 100). However, what happens is when the player is "killed" the death message appears and the player dies but you can see the player still has full health, and when the player is damaged again another death message is shown. I'm guessing this is because attackEntityFrom makes the game think the player is dead, but when they get damaged again the game realizes and then actually kills the player. Is there a way to avoid this and kill the player with a custom death message?
  7. Thanks for the reply, all this packet stuff is new to me and I'd like to see how to use them. Do you have any resources or places where I could learn how to use these because I've looked for documentation and resources but all I found was the link in my original post.
  8. I'd like to play the totem animation with a custom item. I've found this (https://www.minecraftforge.net/forum/topic/74941-solved-use-totems-animation/) answer, but I'm not sure how to implement EntityRenderer#displayItemActivation into my code. How would I go about playing this animation with a custom item?
  9. Thanks, I went through it again and fixed it up. It's working fine now.
  10. (I'm used to coding with other languages but Java is kind of new for me) I'm trying to create a totem of undying-ish item that gets used upon death. Everything is working, except I can't remove the item using clearMatchingItems. On the docs (https://skmedix.github.io/ForgeJavaDocs/javadoc/forge/1.9.4-12.17.0.2051/net/minecraft/entity/player/InventoryPlayer.html#clearMatchingItems-net.minecraft.item.Item-int-int-net.minecraft.nbt.NBTTagCompound-) it says that the method needs an item, a metadata, and an int, but in my IDE (Eclipse) it says I need a predicate <itemstack> instead of an item (maybe the docs I'm looking at are outdated). My question is, how am I supposed to use predicate with Itemstack, and if I need a metadata how I would use it?
  11. Okay, so how do you do that exactly? I have been trying to make it work for a while now, and it still won't do anything. Here's my current code to tell the player when they drop anything @Mod(Reference.MODID) public class DroppedItem { @SubscribeEvent public void onItemTossEvent(ItemTossEvent itemTossEvent) { Minecraft.getInstance().player.sendChatMessage("you dropped something"); } }
  12. I am trying to test if a certain item has been dropped. I am aware of the ItemTossEvent event, but I'm not really sure how to use it. Any help would be appreciated!
  13. [Deleted]
×
×
  • Create New...

Important Information

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