Jump to content

Armour Potion Effects


ashtonr12

Recommended Posts

This is my current ServerTickHandler file;

 

package ashtonsmod.common;

 

import java.util.EnumSet;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.potion.Potion;

import net.minecraft.potion.PotionEffect;

import cpw.mods.fml.common.ITickHandler;

import cpw.mods.fml.common.TickType;

 

public class ServerTickHandler implements ITickHandler {

 

private void onPlayerTick(EntityPlayer player) {

if (player.getCurrentItemOrArmor(4) != null ) {

ItemStack helmet = player.getCurrentItemOrArmor(4);

ItemStack chest = player.getCurrentItemOrArmor(3);

ItemStack legs = player.getCurrentItemOrArmor(2);

 

if (helmet.getItem() == ashtonsmod.ObsidianHelmet ) {

player.addPotionEffect((new PotionEffect(Potion.moveSlowdown.getId(), 25, 1)));

 

}

}

if(player.getCurrentItemOrArmor(1) != null){

ItemStack boots = player.getCurrentItemOrArmor(1);

if(boots.getItem() == ashtonsmod.ObsidianBoots){

player.addPotionEffect((new PotionEffect(Potion.moveSlowdown.getId(), 25, 1)));

}}

if(player.getCurrentItemOrArmor(2) != null){

ItemStack legs = player.getCurrentItemOrArmor(2);

if(legs.getItem() == ashtonsmod.ObsidianLegs){

player.addPotionEffect((new PotionEffect(Potion.moveSlowdown.getId(), 25, 1)));

}}

 

if(player.getCurrentItemOrArmor(3) != null){

ItemStack plate = player.getCurrentItemOrArmor(3);

if(plate.getItem() == ashtonsmod.ObsidianPlate){

player.addPotionEffect((new PotionEffect(Potion.moveSlowdown.getId(), 25, 1)));

}}}

 

 

 

@Override

public void tickStart(EnumSet<TickType> type, Object... tickData)

{

  if (type.equals(EnumSet.of(TickType.PLAYER)))

  {

    onPlayerTick((EntityPlayer)tickData[0]);

  }

}

 

@Override

public EnumSet<TickType> ticks()

{

  return EnumSet.of(TickType.PLAYER, TickType.SERVER);

}

 

@Override

public void tickEnd(EnumSet<TickType> type, Object... tickData) {

}

 

 

@Override

public String getLabel() {

return null;

}

 

}

 

 

This currently says that if i put on obsidian armour (helmet or plate or boots or legs) it gives me slowness effect, how would i go about making it so that when i put on obsidian armour (helmet and plate and boots and legs) it gives me the potion effect? (ignore any missing } i cut out a small part of code.)

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

anywhat that doesnt work it only gives me the potion effect when i have either the hat or plate on , i would like ti so that if any part of the set is omitted the potion effect no longer activates

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

so that you have to be wearing all four peices of the armour set to get the effect

e.g

 

helmet+plate+legs+boots = potion.moveslowness

plate+Legs+Boots = no potion effect

helmet + legs + plate = no potion effect

boots + plate = no potion effect

 

etc

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

oh right then replace your server tick handler with this

package modding.tutorial;

import java.util.EnumSet;

import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;

import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ServerTickHandler implements ITickHandler {



private void onPlayerTick(EntityPlayer player) {
	if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		ItemStack helmet = player.getCurrentItemOrArmor(4);
		ItemStack plate = player.getCurrentItemOrArmor(3);
		ItemStack legs = player.getCurrentItemOrArmor(2);
		ItemStack boots = player.getCurrentItemOrArmor(1); 

		if (helmet.getItem() == mod_MainClass.TutHelmet && plate.getItem() == mod_MainClass.TutPlate && legs.getItem() == mod_MainClass.TutLegs && boots.getItem() == mod_MainClass.TutBoots) {
			player.addPotionEffect((new PotionEffect(Potion.confusion.getId(), 200, 0)));
		}
	}

}

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData) {
	if (type.equals(EnumSet.of(TickType.PLAYER))) {
		onPlayerTick((EntityPlayer) tickData[0]);

	}

}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
	// TODO Auto-generated method stub

}

@Override
public EnumSet<TickType> ticks() {
	return EnumSet.of(TickType.PLAYER, TickType.SERVER);
}

@Override
public String getLabel() {
	// TODO Auto-generated method stub
	return null;
}

}

My youtube channel for forge tutorials: http://www.youtube.com/user/TheGrovesyProject101?feature=mhee

 

if i helped please press thank you

Link to comment
Share on other sites

This is the modding support forums isnt it? this is not the go away and learm java than come back and ask for help forum, by asking for an example i amtrying to learn new methods and codes. For next time i can use this without you

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

		if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		ItemStack helmet = player.getCurrentItemOrArmor(4);
		ItemStack plate = player.getCurrentItemOrArmor(3);
		ItemStack legs = player.getCurrentItemOrArmor(2);
		ItemStack boots = player.getCurrentItemOrArmor(1); 

		if (helmet.getItem() == mod_MainClass.TutHelmet && plate.getItem() == mod_MainClass.TutPlate && legs.getItem() == mod_MainClass.TutLegs && boots.getItem() == mod_MainClass.TutBoots) {
			player.addPotionEffect((new PotionEffect(Potion.confusion.getId(), 200, 0)));
		}
	}

 

put that in the onArmorTickUpdate method

Link to comment
Share on other sites

this seems to work but it randomly crashes sometimes when i put the Armour set on?

/Edit/

This also seems to make the entire game run slower especially on startup?

Minecraft has crashed!      
      ----------------------      

Minecraft has stopped running because it encountered a problem; Ticking memory connection

A full error report has been saved to C:\Users\John\Desktop\Modding\jars\.\crash-reports\crash-2013-03-09_08.59.14-server.txt - Please include a copy of that file (Not this screen!) if you report this crash to anyone; without it, they will not be able to help fix the crash 



--- BEGIN ERROR REPORT 70386135 --------
Full report at:
C:\Users\John\Desktop\Modding\jars\.\crash-reports\crash-2013-03-09_08.59.14-server.txt
Please show that file to Mojang, NOT just this screen!

Generated 09/03/13 08:59

-- System Details --
Details:
Minecraft Version: 1.4.6
Operating System: Windows 7 (x86) version 6.1
Java Version: 1.6.0_29, Sun Microsystems Inc.
Java VM Version: Java HotSpot(TM) Client VM (mixed mode), Sun Microsystems Inc.
Memory: 895681888 bytes (854 MB) / 1067057152 bytes (1017 MB) up to 1067057152 bytes (1017 MB)
JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M
AABB Pool Size: 3818 (213808 bytes; 0 MB) allocated, 3648 (204288 bytes; 0 MB) used
Suspicious classes: FML and Forge are installed
IntCache: cache: 0, tcache: 1, allocated: 3, tallocated: 61
FML: MCP v7.25 FML v4.6.12.511 Minecraft Forge 6.5.0.471 4 mods loaded, 4 mods active
mcp [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available
FML [Forge Mod Loader] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available
Forge [Minecraft Forge] (coremods) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available
ashtonsmod [Ashton's Mod] (bin) Unloaded->Constructed->Pre-initialized->Initialized->Post-initialized->Available->Available->Available
Profiler Position: N/A (disabled)
Vec3 Pool Size: 1070 (59920 bytes; 0 MB) allocated, 948 (53088 bytes; 0 MB) used
Player Count: 1 / 8; [EntityPlayerMP['Player823'/274, l='New World', x=5.38, y=67.00, z=254.20]]
Type: Integrated Server (map_client.txt)
Is Modded: Definitely; Client brand changed to 'forge,fml'

java.lang.NullPointerException
at ashtonsmod.common.ServerTickHandler.onArmourTick(ServerTickHandler.java:21)
at ashtonsmod.common.ServerTickHandler.tickStart(ServerTickHandler.java:82)
at cpw.mods.fml.common.SingleIntervalHandler.tickStart(SingleIntervalHandler.java:16)
at cpw.mods.fml.common.FMLCommonHandler.tickStart(FMLCommonHandler.java:119)
at cpw.mods.fml.common.FMLCommonHandler.onPlayerPreTick(FMLCommonHandler.java:378)
at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:268)
at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:286)
at net.minecraft.network.NetServerHandler.handleFlying(NetServerHandler.java:310)
at net.minecraft.network.packet.Packet10Flying.processPacket(Packet10Flying.java:51)
at net.minecraft.network.MemoryConnection.processReadPackets(MemoryConnection.java:80)
at net.minecraft.network.NetServerHandler.networkTick(NetServerHandler.java:136)
at net.minecraft.network.NetworkListenThread.networkTick(NetworkListenThread.java:57)
at net.minecraft.server.integrated.IntegratedServerListenThread.networkTick(IntegratedServerListenThread.java:108)
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:702)
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:598)
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:123)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:497)
at net.minecraft.server.ThreadMinecraftServer.run(ThreadMinecraftServer.java:16)
--- END ERROR REPORT 39f34a96 ----------

[code]

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

Did i delete it all? because im still crashing sometimes?

package ashtonsmod.common;

import java.util.EnumSet;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import cpw.mods.fml.common.ITickHandler;
import cpw.mods.fml.common.TickType;

public class ServerTickHandler implements ITickHandler {

private void onArmourTick(EntityPlayer player) {
	 if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		   ItemStack helmet = player.getCurrentItemOrArmor(4);
		   ItemStack plate = player.getCurrentItemOrArmor(3);
		   ItemStack legs = player.getCurrentItemOrArmor(2);
		   ItemStack boots = player.getCurrentItemOrArmor(1); 
		   
		   if (helmet.getItem() == ashtonsmod.ObsidianHelmet && plate.getItem() ==ashtonsmod.ObsidianPlate && legs.getItem() == ashtonsmod.ObsidianLegs && boots.getItem() == ashtonsmod.ObsidianBoots) {
		    player.addPotionEffect((new PotionEffect(Potion.moveSlowdown.getId(), 10, 0)));
		   }}
	 if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		   ItemStack helmet = player.getCurrentItemOrArmor(4);
		   ItemStack plate = player.getCurrentItemOrArmor(3);
		   ItemStack legs = player.getCurrentItemOrArmor(2);
		   ItemStack boots = player.getCurrentItemOrArmor(1); 
		   
		   if (helmet.getItem() == ashtonsmod.LightHelmet && plate.getItem() ==ashtonsmod.LightPlate && legs.getItem() == ashtonsmod.LightLegs && boots.getItem() == ashtonsmod.LightBoots) {
		    player.addPotionEffect((new PotionEffect(Potion.moveSpeed.getId(), 10, 0)));
		   }}
	 if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		   ItemStack helmet = player.getCurrentItemOrArmor(4);
		   
		   if (helmet.getItem() == ashtonsmod.MinersHelmet) {
		    player.addPotionEffect((new PotionEffect(Potion.nightVision.getId(), 10, 0)));
		  }}
	 if (player.getCurrentItemOrArmor(4) != null && player.getCurrentArmor(3) != null && player.getCurrentItemOrArmor(2) != null && player.getCurrentItemOrArmor(1) != null) {
		   ItemStack helmet = player.getCurrentItemOrArmor(4);
		   
		   if (helmet.getItem() == ashtonsmod.DivingHelmet) {
		    player.addPotionEffect((new PotionEffect(Potion.waterBreathing.getId(), 10, 0)));
		   }}}

@Override
public void tickStart(EnumSet<TickType> type, Object... tickData)
{
  if (type.equals(EnumSet.of(TickType.PLAYER)))
  {
    onArmourTick((EntityPlayer)tickData[0]);
  }
}

@Override
public EnumSet<TickType> ticks() 
{
  return EnumSet.of(TickType.PLAYER, TickType.SERVER);
}

@Override
public void tickEnd(EnumSet<TickType> type, Object... tickData) {
}

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

ok, i know i am really rubbish at this?

here is my item class, what do i do with it?

 

package ashtonsmod.common;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraftforge.common.IArmorTextureProvider;

public class ObsidianHelmet extends ItemArmor implements IArmorTextureProvider{

        public ObsidianHelmet(int par1,EnumArmorMaterial par2EnumArmorMaterial, int par3, int par4) {
                super(par1, par2EnumArmorMaterial, par3, par4);
        }
        
        

	@Override
    	public String getTextureFile(){
    		return CommonProxy.items_png;
         }

        public String getArmorTextureFile(ItemStack par1){
                if ( par1.itemID==ashtonsmod.ObsidianHelmet.shiftedIndex|| par1.itemID==ashtonsmod.ObsidianPlate.shiftedIndex||
                                 par1.itemID==ashtonsmod.ObsidianBoots.shiftedIndex){
                        return "/armor/ObsidianArmor_1.png";
                }if(par1.itemID==ashtonsmod.ObsidianLegs.shiftedIndex){
                        return "/armor/ObsidianArmor_2.png";
                }return "/armor/ObsidianArmor_2.png";
        }
}

Use examples, i have aspergers.

Examples make sense to me.

Link to comment
Share on other sites

  • 2 months later...

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



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://drive.google.com/file/d/1M0EG-c5yfRd08DSnE5HVQNCu2v0YtA7A/view?usp=sharing  
    • so im not sure if your still watching this TileEntity but once we loaded a FTB modpack we wanted to run on the server it no longer seems to run. The console opens like normal but we've been sitting here for like a little over an hour and the server screen has not yet opened. Should we just keep waiting at this point?
    • I have now easily fixed the duplication error present, I was just not looking.   I have been working for the past half hour to try and fix another error present, this time with the Creative Mode Tab.   I have changed some things around to get where I am currently. (ModFoods to ModDrinks*) and it cannot find the symbol ".get" at the end of the code. *The custom class you recommended pOutput.accept(ModDrinks.ORANGE_JUICE.get()); I think the point I am at currently is the closest I have to how it should be but because I am not as experienced with java I would not know.  I have also removed ORANGE_JUICE and LEMON_JUICE from the ModFoods class, to avoid confliction. I do hope all this can be fully resolved soon.  
    • [SOLVED]  public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Text event){ Client.hud.draw(); } } As I was playing around a little with the code, i found out about an option to change The RenderGameOverlayEvent.Post to RenderGameOverlayEvent.Text
    • public class HUD { public Minecraft mc = Minecraft.getMinecraft(); public static class ModuleComparator implements Comparator<Module>{ @Override public int compare(Module o1, Module o2) { if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) > Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return -1; } if (Minecraft.getMinecraft().fontRendererObj.getStringWidth(o1.name) < Minecraft.getMinecraft().fontRendererObj.getStringWidth(o2.name)){ return 1; } return 0; } } public void draw(){ ScaledResolution sr = new ScaledResolution(mc); FontRenderer fr = mc.fontRendererObj; Collections.sort(Client.modules, new ModuleComparator()); GlStateManager.pushMatrix(); GlStateManager.translate(4,4,0); GlStateManager.scale(1.5,1.5,1); GlStateManager.translate(-4, -4, 0); fr.drawString("Skyline", 10, 10, -1); GlStateManager.popMatrix(); int count = 0; for (Module m : Client.modules){ if (!m.toggled || m.name.equals("TabGUI")) continue; int offset = count* (fr.FONT_HEIGHT + 6); GL11.glTranslated(0.0f, 0.0f, -1.0f); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 10, offset, sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, 6 + fr.FONT_HEIGHT + offset, -1); Gui.drawRect(sr.getScaledWidth() - fr.getStringWidth(m.name) - 8, offset, sr.getScaledWidth(), 6 + fr.FONT_HEIGHT + offset, 0x90000000); fr.drawString(m.name, sr.getScaledWidth() - fr.getStringWidth(m.name) - 4, offset + 4, -1); count++; } Client.onEvent(new EventRenderGUI()); } } I have just recently stumbled upon this Problem, where the HudRenderer renders the wrong section of the textures and therefore completely destroys the Minecraft Armour and Hunger Bar. I am currently thinking if it is an issue with the DrawRect changing something it shouldn't. But I couldn't find anything about it. (To keep things Clean, the function is Called from another file) public class RenderGUIHandler { @SubscribeEvent public void renderGUI(RenderGameOverlayEvent.Post event){ Client.hud.draw(); } } Any help would be greatly appreciated  
  • Topics

×
×
  • Create New...

Important Information

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