Posted September 23, 20159 yr Hello! I begin developing a Minecraft mod, where you can find lead and uranium ores. When you touch the uranium (after you mine it), it applies poison effect on you, but i want a similar effect, but only with the ores: When I get close, i want it apply poison on player. How to do it? I tried similar things (google), but nothing works. thanks for any help!
September 23, 20159 yr Then, compare block coordinates (blockpos) to player coordinates to figure the distance in X, Y, and Z. Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]
September 24, 20159 yr Author I try to register the event: @EventHandler public void init(FMLInitializationEvent e) { this.proxy.init(e); // the majority of events use the MinecraftForge event bus: MinecraftForge.EVENT_BUS.register(new CheckTick()); } My Code in Player Tick so far: package com.example.examplemod; import com.example.examplemod.blocks.ModBlocks; import net.minecraft.block.Block; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.BlockPos; import net.minecraft.world.World; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent.PlayerTickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; // RenderTick is client side only, so we can place the SideOnly annotation here if we want: @SideOnly(Side.CLIENT) public class CheckTick { //we only need one method here, and you can name it whatever you want, but //I like to name it according to the tick to which I am listening: @SubscribeEvent public void onCheckTick(PlayerTickEvent event, Entity entity, World world) { EntityPlayer player = (EntityPlayer) entity; //now you can do whatever you want during each render tick, such as rotate the player's view Block checkblock=world.getBlockState(new BlockPos(player.posX,player.posY+1,player.posZ)).getBlock(); if (checkblock == ModBlocks.tutorialBlock2){ player.addPotionEffect((new PotionEffect(Potion.poison.getId(), 100, 5))); } } } I try to get the block under the player.Y, and check is that my custom ore. Is this right?
September 24, 20159 yr Author Yes I want to substract, but not thats the main problem. This is instead a big problem: "onCheckTick(PlayerTickEvent event, Entity entity, World world)" I not use it correctly, but not know how to fix
September 24, 20159 yr Author "You get player and world from the event." Yes I see, but i get can't resolve error for player and world. Maybe player is correct like this?: EntityPlayer player = event.player; But it's not working on World world = ewvent.world; Because event.world not existing;
September 25, 20159 yr Author Thanks for your advice, but I think my problem is not related to lack of knowledge of java, but lack of knowledge of modding. I do all the beginner tutorial (from item create to structures), but now I try to do something that I never tried before, and maybe never will, and there is not a single tutorial for this. Not to mention that nearly all tutorial outdated (pre-1.. You help me a lot - and thank you for that
September 25, 20159 yr Author I knew java, but for a really short time, and just because I want develop mod, I not say anithing else. But now I look more into the minecraft classes and find every solution (I not use eclipse too much before too), and now i finish the mod. After all, relly really thanks for your patience and help to finish the mod!
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.