Jump to content

give player effects when enable modules


NqwSqw

Recommended Posts

Hi,

I want to give player effects when i enable my modules but it's doesn't works

package xyz.fusked.m0dules.mods.render;

import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.MobEffects;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import xyz.fusked.values.BooleanValue;
import xyz.fusked.values.IntegerValue;

public class NightVision extends xyz.fusked.m0dules.Module{
	
	public NightVision() {
		super("Night Vision", 0, xyz.fusked.m0dules.Module.Category.RENDER);
	}
	public void onEnable(EntityPlayer player) {
		player.addPotionEffect(new PotionEffect(MobEffects.NIGHT_VISION, -1, 0));
	}
	public void onDisable(EntityPlayer player) {
		player.removePotionEffect(MobEffects.NIGHT_VISION);
	}
}	

 

this is my file where is onEnable :

/*     */ package xyz.fusked.m0dules;
/*     */ 
/*     */ import java.util.ArrayList;
/*     */ import net.minecraft.client.Minecraft;
/*     */ import net.minecraftforge.common.MinecraftForge;
/*     */ import net.minecraftforge.fml.common.FMLCommonHandler;
/*     */ import net.minecraftforge.fml.common.eventhandler.EventBus;
/*     */ import xyz.fusked.utils.Wrapper;
/*     */ import xyz.fusked.values.BooleanValue;

/*     */ import xyz.fusked.values.DoubleValue;
import xyz.fusked.values.IntegerValue;
/*     */ 
/*     */ public abstract class Module
/*     */ {
/*     */   protected Minecraft mc;
/*     */   private String name;
/*     */   private int key;
/*     */   private boolean state;
/*     */   private Category category;
/*     */   private ArrayList<BooleanValue> booleans;
/*     */   private ArrayList<DoubleValue> doubles;
			private ArrayList<IntegerValue> integers;

/*     */   
/*     */   public Module(String name, int key, Category category)
/*     */   {
/*  24 */     this.mc = Wrapper.getMinecraft();
/*  25 */     this.booleans = new ArrayList();
/*  26 */     this.doubles = new ArrayList();
			  this.integers = new ArrayList();

/*  27 */     this.name = name;
/*  28 */     this.key = key;
/*  29 */     this.state = false;
/*  30 */     this.category = category;
/*     */   }
/*     */   
/*     */   public String getName() {
/*  34 */     return this.name;
/*     */   }
/*     */   
/*     */   public void setName(String name) {
/*  38 */     this.name = name;
/*     */   }
/*     */   
/*     */   public void setKey(int key) {
/*  42 */     this.key = key;
/*     */   }
/*     */   
/*     */   public boolean setToggled(boolean toggled) {
/*  46 */     return this.state = toggled;
/*     */   }
/*     */   
/*     */   public boolean getState() {
/*  50 */     return this.state;
/*     */   }
/*     */   
/*     */   public int getKey() {
/*  54 */     return this.key;
/*     */   }
/*     */   
/*     */   public Category getCategory() {
/*  58 */     return this.category;
/*     */   }
/*     */   
/*     */   public ArrayList<BooleanValue> getBooleans() {
/*  62 */     return this.booleans;
/*     */   }
/*     */   
/*     */   public ArrayList<DoubleValue> getDoubles() {
/*  66 */     return this.doubles;
/*     */   }
			public ArrayList<IntegerValue> getIntegers(){
				return this.integers;
			}
/*     */   
/*     */   public void toggle() {
/*  70 */     setState(!this.state);
/*     */   }
/*     */   
/*     */   public void addBoolean(BooleanValue booleans) {
/*  74 */     this.booleans.add(booleans);
/*     */   }
/*     */   
/*     */   public void addDouble(DoubleValue doubles) {
/*  78 */     this.doubles.add(doubles);
/*     */   }
			
			public void addInteger(IntegerValue integers) {
				this.integers.add(integers);
			}


/*     */   
/*     */   public static ArrayList<Module> getCategoryModules(Category cat) {
/*  82 */     ArrayList<Module> modsInCategory = new ArrayList();
/*  83 */     for (Module mod : ModuleManager.getModules()) {
/*  84 */       if (mod.getCategory() == cat) {
/*  85 */         modsInCategory.add(mod);
/*     */       }
/*     */     }
/*  88 */     return modsInCategory;
/*     */   }
/*     */   
/*     */   public static Module getModule(Class<? extends Module> clazz) {
/*  92 */     for (Module mod : ModuleManager.getModules()) {
/*  93 */       if (mod.getClass() == clazz) {
/*  94 */         return mod;
/*     */       }
/*     */     }
/*  97 */     return null;
/*     */   }
/*     */   
/*     */   public void setState(boolean enabled) {
/* 101 */     if (this.state == enabled) {
/* 102 */       return;
/*     */     }
/* 104 */     this.state = enabled;
/* 105 */     if (enabled) {
/* 106 */       MinecraftForge.EVENT_BUS.register(this);
/* 107 */       FMLCommonHandler.instance().bus().register(this);
/* 108 */       onEnable();
/*     */     }
/*     */     else {
/* 111 */       MinecraftForge.EVENT_BUS.unregister(this);
/* 112 */       FMLCommonHandler.instance().bus().unregister(this);
/* 113 */       onDisable();
/*     */     } }
/*     */   
/*     */   public void onEnable() {}
/*     */   
/* 118 */   public static enum Modules {
				Hitbox ; 
/*     */     
/*     */     private Modules() {} }
/*     */   
/* 134 */   public static enum Category { COMBAT, 
/* 135 */     RENDER, 
/* 136 */     OTHER, 
			  PLAYER,
			  BLATANT,
/* 137 */     UTILITY;

/*     */     
/*     */     private Category() {}
/*     */   }
/*     */   
/*     */   public void onDisable() {}
/*     */ }

 

Edited by NqwSqw
Link to comment
Share on other sites

1 hour ago, NqwSqw said:

public void onEnable() {}

This method and this method:

1 hour ago, NqwSqw said:

public void onEnable(EntityPlayer player)

Do not have the same signature, so the latter is not overriding the former.

 

Also, where are you calling onEnable(EntityPlayer player)?

Edited by Draco18s

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

2 hours ago, Draco18s said:

This method and this method:

Do not have the same signature, so the latter is not overriding the former.

 

Also, where are you calling onEnable(EntityPlayer player)?

No I just want to enable a module in my GUI of the mod and when I enable it, it give the mobeffects to the player

Link to comment
Share on other sites

29 minutes ago, NqwSqw said:

No I just want to enable a module in my GUI of the mod and when I enable it, it give the mobeffects to the player

This has nothing to do with what draco said.

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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