Jump to content

Recommended Posts

Posted

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.

Posted

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.

Posted

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.

Posted

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

Posted

i am not a great modder sorry, :P so how would i make it so that all four armour pieces have to be equipped to activate the potion effect

Use examples, i have aspergers.

Examples make sense to me.

Posted

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.

Posted

		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

Posted

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.

Posted

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.

Posted

it still seems to crash when i have a full Armour set on and i take of the plate, any other armors are fine?

Use examples, i have aspergers.

Examples make sense to me.

Posted

I am confused i though i was meant to put that code in my server tick file?

as when i put it in my armour class it doesnt do anything?

Use examples, i have aspergers.

Examples make sense to me.

Posted

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.

Posted

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

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

your supposed to put the method in your armor file. don't use a tick handler for that.

  • 2 months later...
Posted

I have the same "Take chestplate off and the game crashes bug". How did you fix this? This will help me alot! Thanks!

 

EDIT: Nevermind I fiddled around and got it to work :) !

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.