Posted September 15, 20196 yr I'm trying to create a poisonous atmosphere in my custom dimension. The code is meant to give the player poison when they are in my dimension and they aren't wearing a gas mask. I can't tell why my code doesn't work. I tried added a println line in there but it didn't show up which probably means that the code isn't being called but I don't know why. Quote package com.jonispatented.moarmor.world.dimension.overrun; import com.jonispatented.moarmor.init.ModItems; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.potion.PotionEffect; import net.minecraft.world.World; import net.minecraft.world.WorldProvider; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; public class PoisonAir { @SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { final EntityPlayer player = event.player; if(player.inventory.armorItemInSlot(3).getItem() != ModItems.GAS_MASK) { if(player.dimension == 2) { player.addPotionEffect(new PotionEffect(MobEffects.POISON, 1, 1, false, false)); } } } }
September 15, 20196 yr Just now, JonIsPatented said: which probably means that the code isn't being called but I don't know why. Did you register an instance of event handler class(Poison Air) to MinecraftForge.EVENT_BUS? VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 15, 20196 yr Author No. I can't figure out how, after trying multiple ways listed on the internet. Either I'm not doing it right, or it doesn't fix it. How would you recommend I go about it?
September 15, 20196 yr 4 minutes ago, JonIsPatented said: How would you recommend I go about it? Read this. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 15, 20196 yr Author Just now, Animefan8888 said: Read this. That's what I read. And Jabelar's tutorial. I think I'm doing it wrong.
September 15, 20196 yr Just now, JonIsPatented said: That's what I read. And Jabelar's tutorial. I think I'm doing it wrong. Show what you have. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 15, 20196 yr Author 1 minute ago, Animefan8888 said: Show what you have. I've tried adding the annotation to the class like this: Quote @Mod.EventBusSubscriber public class PoisonAir { @SubscribeEvent public void playerTick(TickEvent.PlayerTickEvent event) { final EntityPlayer player = event.player; if(player.inventory.armorItemInSlot(3).getItem() != ModItems.GAS_MASK) { if(player.dimension == 2) { player.addPotionEffect(new PotionEffect(MobEffects.POISON, 1, 1, false, false)); } } } } Then I tried adding that line from the tutorial into the main class: Quote @EventHandler public static void PreInit(FMLPreInitializationEvent event) { GameRegistry.registerWorldGenerator(new ModWorldGen(), 3); DimensionInit.registerDimensions(); GameRegistry.registerWorldGenerator(new GenerateCustomStructures(), 3); MinecraftForge.EVENT_BUS.register(PoisonAir.class); } Then I tried something else in my registry handler but I forgot exactly what it was because I deleted all three of those changes after they didn't work.
September 15, 20196 yr 2 minutes ago, JonIsPatented said: Then I tried something else in my registry handler but I forgot exactly what it was because I deleted all three of those changes after they didn't work Both of those ways to require your method playerTick to be a static method. VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect. Forge and vanilla BlockState generator.
September 15, 20196 yr Author Just now, Animefan8888 said: Both of those ways to require your method playerTick to be a static method. Ok thank you I got it working.
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.