Everything posted by ketchup_god
-
[1.15.2] Can't use attackEntityFrom to fully kill player
Ah of course, somehow didn’t notice. Thanks for the help, I’ll try it out.
-
[1.15.2] Can't use attackEntityFrom to fully kill player
@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.
-
[1.15.2] Can't use attackEntityFrom to fully kill player
Yeah, it's definitely there
-
[1.15.2] Can't use attackEntityFrom to fully kill player
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.
-
[1.15.2] Can't use attackEntityFrom to fully kill player
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?
-
[1.15.2] Can't use attackEntityFrom to fully kill player
@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
-
[1.15.2] Can't use attackEntityFrom to fully kill player
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?
-
[1.15.2] [SOLVED] How would you play the totem of undying animation with other items?
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.
-
[1.15.2] [SOLVED] How would you play the totem of undying animation with other items?
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?
-
[1.15.2] [SOLVED] How do you use clearMatchingItems?
Thanks, I went through it again and fixed it up. It's working fine now.
-
[1.15.2] [SOLVED] How do you use clearMatchingItems?
(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?
-
[1.13.2] How to detect when a certain item is dropped?
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"); } }
-
[1.13.2] How to detect when a certain item is dropped?
Thanks for the quick reply, I will try it out!
-
[1.13.2] How to detect when a certain item is dropped?
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!
- [Deleted]
-
[1.13.2] Trying to make a custom potion effect
Thanks, it worked! I'll make sure to start learning some Java. Thanks for all your help.
-
[1.13.2] Trying to make a custom potion effect
Alright, one last question concerning forge methods. In my CustomPotion class, I have this to get the GUI icon: Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation(examplemod.modid + "textures/gui/potion_effects.png")); Eclipse keeps on telling me that getMinecraft() isn't a method for Minecraft. I'm pretty sure this is an issue with the outdated tutorial, so is there a way to do this in the current version? Thanks again for your help.
-
[1.13.2] Trying to make a custom potion effect
Thanks for your quick reply! As a matter of fact, I have been trying to use a 1.12 tutorial. However, I always encounter errors that I can't fix. For example, in my PotionInit class, I have public static final PotionEffect Restlessness = new CustomPotion() so I created a new class called CustomPotion and wrote public static CustomPotion(String name, boolean isBadPotion, int colour, int iconIndexX, int iconIndexY) { super(isBadPotion, colour); setPotionName("effect." + name); setIconIndex(iconIndexX, iconIndexY); setRegistryName(new ResourceLocation(examplemod.modid + ":" + name)); } However, eclipse gives me an error on PotionInit saying that I need to add values to the CustomPotion() constructor. When I apply the quick fix, eclipse gives me this: public static final PotionEffect Restlessness = new CustomPotion(null, null, 0, 0, 0) I'm wondering if this is what you were talking about in your reply about the static initializers. Is there a fix to my issue, or am I doing something wrong?
-
[1.13.2] Trying to make a custom potion effect
I'm still a beginner modder, so I've been watching some tutorials on modding and I've decided to make a custom potion effect. I've scoured the internet trying to find a working tutorial, read the docs, and looked through the forums, but I still can't find anything that will help. Most of it is all in 1.12 and I can't find anything in 1.13. Please help!
IPS spam blocked by CleanTalk.