Jump to content

Taji34

Forge Modder
  • Posts

    147
  • Joined

  • Last visited

Posts posted by Taji34

  1. Well ofc. you can (ASM in runtime, which is NOT Forge), BUT stuff like "Borderless Window" - This is going like VERY deep into most basic classes. And "Default resolution" - what is that? Window can be resized, GUIs have scaling? I mean - what do you want more?

     

    Also - there alredy is fullscreen mode.

    The stuff I need to add to is in minecraft.java, which I'm assuming is off limits as far as changes go, and yes, I do want more. I want to be able to play "Fullscreen" and be able to alt-tab away, or go to a second monitor and not have minecraft freak out.

     

    -snip-

    Sorry. Let me rephrase my previous statement. It is highly recommend not to edit base files. But I agree with the fact that changing the windows into border less would be hard and if you do do it would probably be a very hacky method and not clean at all.

    Well it's actually relatively simple. Just add System.setProperty("org.lwjgl.opengl.Window.undecorated","true"); and change the window to not be re-sizable (the re-sizable part is mainly just for windows, as from research it seems the first part does the trick on Mac and Linux, while windows leaves a border since it is still re-sizable). The default resolution Default Window Size (See explaination at bottom) is the solution to the making the window not re-sizable. I would also, in this mode, need to center the minecraft window to the center of the screen, rather than the upper right corner. Then of course I would add menu options or a config file to change all of these things.

     

    I would not be removing anything from the file or modifying existing code, just adding two or three lines to the minecraft.java file, and the rest would be through forge. Is this not advisable? If not, thank you for the help.

     

    EDIT: Explaination: I realized that Defaut Resolution was not the best wording. I would not be changing how minecraft rendered anything, what I meant to get across was a default window size, so that you could specify how big you wanted the window to be, since it would not be re-sizable. This is so I can make the window fill my screen if I want, or I can make it a 800x500 window on my screen if I want. Hopefully that makes sense.

  2. Any one? I can think of a work around using events, but I'd like to use the interface given to me. I found that if I either use 0 (nothing blocked) or 1 (everything blocked), it works and I can even use conditionals to switch between the two Absorb Ratios. The second I seem to use decimal numbers or more than one conditional check, it just defaults to leather mode. I don't think it's a sync issue with the server and client NBT data because it's printing out the correct mode from the server. Any ideas on anything it could be? Even if my code looks fine?

  3. So I'm creating a custom set of armor using ISpecialArmor. I've made it so that it should change what the AbsorbRatio is based on an NBT tag, However it's not working. Here's one of the classes:

    EnerginiumArmorHelmet.java

     

    package com.taji34.troncraft.items;
    
    import java.util.List;
    
    import org.lwjgl.input.Keyboard;
    
    import com.taji34.troncraft.Troncraft;
    import com.taji34.troncraft.packetHandlers.TajiMessage;
    import com.taji34.troncraft.proxies.ClientProxy;
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemArmor;
    import net.minecraft.item.ItemArmor.ArmorMaterial;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.ChatStyle;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.EnumChatFormatting;
    import net.minecraft.world.World;
    import net.minecraftforge.common.ISpecialArmor;
    
    public class EnerginiumArmorHelmet extends ItemArmor implements ISpecialArmor{
    
    public int armorType = 0;
    
    public EnerginiumArmorHelmet(){
    	super(Troncraft.dummyMaterial, 0, 0);
    	setCreativeTab(CreativeTabs.tabMisc);
    	setMaxStackSize(1);
    	setTextureName("troncraft:energiniumarmorhelmet");
    	setUnlocalizedName("energiniumarmorhelmet");
    }
    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
    {
        return "troncraft:textures/armor/energinium_layer_1.png";
    }
    public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
    {
    	if (itemStack.stackTagCompound == null){
    		list.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + "Hold helmet and Press " + Keyboard.getKeyName(ClientProxy.keyBindings[0].getKeyCode()) + " to bind");
    	}
    	else
    	{
    		String owner = itemStack.stackTagCompound.getString("Owner");
    		int durabilityLeft = itemStack.stackTagCompound.getInteger("Durability Left");
    		String level = itemStack.stackTagCompound.getString("Level");
    		list.add("Owner: " + owner);
    		switch(level){
        		case "Leather":
        			list.add( "Level: " + EnumChatFormatting.DARK_GREEN + level);
        			break;
        		case "Chain":
        			list.add( "Level: " + EnumChatFormatting.GRAY + level); // not accessible currently
        			break;
        		case "Iron":
        			list.add("Level: " + EnumChatFormatting.WHITE + level);
        			break;
        		case "Gold":
        			list.add( "Level: " + EnumChatFormatting.YELLOW + level);
        			break;
        		case "Diamond":
        			list.add( "Level: " + EnumChatFormatting.AQUA + level);
        			break;
    		}
    		list.add(EnumChatFormatting.BLUE + "Durability Left: " + durabilityLeft);
    	}
    }
        public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
        {
        	if (stack.stackTagCompound == null)
        	{
            		ChatComponentText message = new ChatComponentText("This helmet is not bound to you");
        			ChatStyle formatting = new ChatStyle();
        			formatting.setColor(EnumChatFormatting.RED);
        			formatting.setItalic(true);
        			message.setChatStyle(formatting);
        			if ((!world.isRemote))
        			{
        				player.addChatMessage(message);
        			}
        	} else {
        			if(player.getCommandSenderName().equals(stack.stackTagCompound.getString("Owner"))){
    		        int i = 3;
    		        ItemStack itemstack1 = player.getCurrentArmor(i);
    
    		        if (itemstack1 == null)
    		        {
    		            player.setCurrentItemOrArmor(i + 1, stack.copy());  //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players.
    	            	stack.stackSize = 0;
    	        	}
        			}
        	}
            return stack;
        }
        
        public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
        {
        	if(stack.stackTagCompound != null){
        	if(entity instanceof EntityPlayer){
        		EntityPlayer player = (EntityPlayer) entity;
        		if(player.getCommandSenderName().equalsIgnoreCase(stack.stackTagCompound.getString("Owner"))){
        			return this.armorType == armorType;
        		}
        	}
        	}
        	return false;
        }
        public int getDamageReductionAmount(ItemStack stack)
        {
        	int answer = 0;
        	switch(stack.stackTagCompound.getString("Level")){
        		case "Leather":
        			answer = ArmorMaterial.CLOTH.getDamageReductionAmount(this.armorType);
        			//System.out.println("here1");
        			break;
        		case "Chain":
        			answer = ArmorMaterial.CHAIN.getDamageReductionAmount(this.armorType);
        			//System.out.println("here2");
        			break;
        		case "Iron":
        			answer = ArmorMaterial.IRON.getDamageReductionAmount(this.armorType);
        			//System.out.println("here3");
        			break;
        		case "Gold":
        			answer = ArmorMaterial.GOLD.getDamageReductionAmount(this.armorType);
        			//System.out.println("here4");
        			break;
        		case "Diamond":
        			answer = ArmorMaterial.DIAMOND.getDamageReductionAmount(this.armorType);
        			//System.out.println("here5");
        			break;
        		default:
        			answer = 0;
        			break;
        	}
        	return answer;
        }
    
    @Override
    public ArmorProperties getProperties(EntityLivingBase player,
    		ItemStack armor, DamageSource source, double damage, int slot) {
    	// TODO Auto-generated method stub
    	System.out.println(.04*this.getDamageReductionAmount(armor));
    	return new ArmorProperties(1,.04*this.getDamageReductionAmount(armor), 11);
    }
    
    @Override
    public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
    	// TODO Auto-generated method stub
    	return this.getDamageReductionAmount(armor);
    }
    
    @Override
    public void damageArmor(EntityLivingBase entity, ItemStack stack,
    		DamageSource source, int damage, int slot) {
    	stack.stackTagCompound.setInteger("Durability Left", stack.stackTagCompound.getInteger("Durability Left")-1);
    
    }
    

     

    That's just one piece of the armor, but they all follow the same method of calculating the AbsorbRatio. The problem is that the armor only blocks the amount of damage that it should when in leather mode, even if it's been changed to diamond mode. What makes me even more confused is that the println I have before it returns the ArmorProperties prints out the correct ratio for the mode, it just doesn't seem to use it. Any ideas?

  4. So, it wasn't working in first person because of something I forgot, but it is staying opaque in the inventory, which it shouldn't be, here is way your debugger prints out:

    GL_VERTEX_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Vertex array enable)
    GL_NORMAL_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Normal array enable)
    GL_COLOR_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (RGBA color array enable)
    GL_INDEX_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Color-index array enable)
    GL_TEXTURE_COORD_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Texture coordinate array enable)
    GL_EDGE_FLAG_ARRAY:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Edge flag array enable)
    GL_NORMALIZE:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Current normal normalization on/off)
    GL_FOG:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if fog enabled)
    GL_LIGHTING:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if lighting is enabled)
    GL_COLOR_MATERIAL:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if color tracking is enabled)
    GL_LIGHT0:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 0 enabled)
    GL_LIGHT1:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 1 enabled)
    GL_LIGHT2:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 2 enabled)
    GL_LIGHT3:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 3 enabled)
    GL_LIGHT4:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 4 enabled)
    GL_LIGHT5:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 5 enabled)
    GL_LIGHT6:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 6 enabled)
    GL_LIGHT7:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if light 7 enabled)
    GL_POINT_SMOOTH:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Point antialiasing on)
    GL_LINE_SMOOTH:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Line antialiasing on)
    GL_LINE_STIPPLE:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Line stipple enable)
    GL_CULL_FACE:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon culling enabled)
    GL_POLYGON_SMOOTH:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon antialiasing on)
    GL_POLYGON_OFFSET_POINT:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon offset enable for GL_POINT mode rasterization)
    GL_POLYGON_OFFSET_LINE:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon offset enable for GL_LINE mode rasterization)
    GL_POLYGON_OFFSET_FILL:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon offset enable for GL_FILL mode rasterization)
    GL_POLYGON_STIPPLE:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Polygon stipple enable)
    GL_TEXTURE_1D:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if 1-D texturing enabled )
    GL_TEXTURE_2D:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if 2-D texturing enabled )
    GL_TEXTURE_GEN_S:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Texgen enabled (x is S, T, R, or Q))
    GL_TEXTURE_GEN_T:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Texgen enabled (x is S, T, R, or Q))
    GL_TEXTURE_GEN_R:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Texgen enabled (x is S, T, R, or Q))
    GL_TEXTURE_GEN_Q:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Texgen enabled (x is S, T, R, or Q))
    GL_SCISSOR_TEST:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Scissoring enabled)
    GL_ALPHA_TEST:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Alpha test enabled)
    GL_STENCIL_TEST:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Stenciling enabled)
    GL_DEPTH_TEST:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Depth buffer enabled)
    GL_BLEND:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Blending enabled)
    GL_DITHER:true[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Dithering enabled)
    GL_INDEX_LOGIC_OP:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (Color index logical operation enabled)
    GL_COLOR_LOGIC_OP:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (RGBA color logical operation enabled)
    GL_AUTO_NORMAL:false[20:57:00] [Client thread/INFO] [sTDOUT]: [com.taji34.troncraft.OpenGLdebugging:dumpAllIsEnabled:294]:  (True if automatic normal generation enabled)

    It stays opaque even with a texture that has an alpha channel of .5, any ideas?

     

     

  5. Well, I'm trying multiple renderPasses, here's my full code for rendering one side of the item:

    tess.setNormal(0, 0, 1);
    		for (int i = 0; i < iconParts; ++i)
    		{
    			tess.startDrawingQuads();
    			if (i == 0)
    			{
    				tess.setColorOpaque_I(color[i]);
    			}
    			else
    			{
    				GL11.glEnable(GL11.GL_BLEND);
    				GL11.glDepthMask(false);
    				GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    				if (item.stackTagCompound != null)
    				{
    					double usesLeft = item.stackTagCompound.getInteger("Uses Left");
    					double totalUses = item.stackTagCompound.getInteger("Total Uses");
    					double percentageLeft = usesLeft/totalUses;
    					int alphaLevel = (int) Math.round(255*percentageLeft);
    					tess.setColorRGBA_I(color[i], alphaLevel);
    				}
    			}
    			tess.addVertexWithUV(0, 0, 0, xMax[i], yMax[i]);
    			tess.addVertexWithUV(1, 0, 0, xMin[i], yMax[i]);
    			tess.addVertexWithUV(1, 1, 0, xMin[i], yMin[i]);
    			tess.addVertexWithUV(0, 1, 0, xMax[i], yMin[i]);
    			tess.draw();
    		}

    I don't think it's getting set back to opaque.....

  6. I'm trying to have an Item where part of it renders with transparency, but it continues to render opaque no matter what. This is the snippet of code I'm using to set the color:

    if (i == 0)
    			{
    				tess.setColorOpaque_I(color[i]);
    			}
    			else
    			{
    				GL11.glEnable(GL11.GL_BLEND);
    				GL11.glDepthMask(false);
    				GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    				if (item.stackTagCompound != null)
    				{
    					double usesLeft = item.stackTagCompound.getInteger("Uses Left");
    					double totalUses = item.stackTagCompound.getInteger("Total Uses");
    					double percentageLeft = usesLeft/totalUses;
    					int alphaLevel = (int) Math.round(255*percentageLeft);
    					tess.setColorRGBA_I(color[i], alphaLevel);
    				}
    			}

    Am I missing some OpenGL flags or is something not in the right order?

  7. Not too familiar with armor, but there has to be more than just one class (registration, rendering, etc...). Does it render with null texture or not at all? Could you post these classes and a log in case there are any errors that could lead to a solution?

     

    I figured it out. So, for getArmorTexture() to get called, the armor must extend ItemArmor, not just Item. I was using Item because I didn't want to use an armor material, but in the end I just made a dummy material for the armor and now it's displaying!

  8. Hey, I'm making custom armor for my mod and I can't get my armor to render on the player. Here is my code:

     

    EnerginiumArmorHelmet.java:

     

    package com.taji34.troncraft.items;
    
    import java.util.List;
    
    import org.lwjgl.input.Keyboard;
    
    import com.taji34.troncraft.Troncraft;
    import com.taji34.troncraft.packetHandlers.TajiMessage;
    
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.Entity;
    import net.minecraft.entity.EntityLiving;
    import net.minecraft.entity.EntityLivingBase;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.init.Blocks;
    import net.minecraft.init.Items;
    import net.minecraft.item.Item;
    import net.minecraft.item.ItemArmor.ArmorMaterial;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.util.ChatComponentText;
    import net.minecraft.util.ChatStyle;
    import net.minecraft.util.DamageSource;
    import net.minecraft.util.EnumChatFormatting;
    import net.minecraft.world.World;
    import net.minecraftforge.common.ISpecialArmor;
    
    public class EnerginiumArmorHelmet extends Item implements ISpecialArmor{
    
    public int armorType = 0;
    
    public EnerginiumArmorHelmet(){
    	setCreativeTab(CreativeTabs.tabMisc);
    	setMaxStackSize(1);
    	setTextureName("troncraft:energiniumarmorhelmet");
    	setUnlocalizedName("energiniumarmorhelmet");
    }
    @Override
    public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type)
    {
        return "troncraft:textures/armor/energinium_layer_1.png";
    }
    public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4)
    {
    	if (itemStack.stackTagCompound == null){
    		list.add(EnumChatFormatting.GRAY + "" + EnumChatFormatting.ITALIC + "Shift Right-Click to Bond");
    	}
    	else
    	{
    		String owner = itemStack.stackTagCompound.getString("Owner");
    		int durabilityLeft = itemStack.stackTagCompound.getInteger("Durability Left");
    		String level = itemStack.stackTagCompound.getString("Level");
    		list.add("Owner: " + owner);
    		list.add(EnumChatFormatting.GREEN + "Level: " + level);
    		list.add(EnumChatFormatting.BLUE + "Durability Left: " + durabilityLeft);
    	}
    }
        public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
        {
        	if (stack.stackTagCompound == null)
        	{
        		if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
        		{
        			stack.stackTagCompound = new NBTTagCompound();
        			stack.stackTagCompound.setString("Owner", player.getDisplayName());
        			stack.stackTagCompound.setString("Level", "Leather");
        			stack.stackTagCompound.setInteger("Total Durability", 55);
        			stack.stackTagCompound.setInteger("Durability Left", 55);
        			Troncraft.network.sendToServer(new TajiMessage(stack.stackTagCompound));
        		} else {
            		ChatComponentText message = new ChatComponentText("This helmet is not bound to you");
        			ChatStyle formatting = new ChatStyle();
        			formatting.setColor(EnumChatFormatting.RED);
        			formatting.setItalic(true);
        			message.setChatStyle(formatting);
        			if ((!world.isRemote))
        			{
        				player.addChatMessage(message);
        			}
        		}
        	} else {
        		if(player.capabilities.isCreativeMode){
        			if(Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
            		{
            			stack.stackTagCompound.setString("Owner", player.getDisplayName());
            			Troncraft.network.sendToServer(new TajiMessage(stack.stackTagCompound));
            		}
        		} else {
        			if(player.getCommandSenderName().equals(stack.stackTagCompound.getString("Owner"))){
    		        int i = 3;
    		        ItemStack itemstack1 = player.getCurrentArmor(i);
    
    		        if (itemstack1 == null)
    		        {
    		            player.setCurrentItemOrArmor(i + 1, stack.copy());  //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players.
    	            	stack.stackSize = 0;
    	        	}
        			}
        		}
        	}
            return stack;
        }
        
        public boolean isValidArmor(ItemStack stack, int armorType, Entity entity)
        {
        	if(stack.stackTagCompound != null){
        	if(entity instanceof EntityPlayer){
        		EntityPlayer player = (EntityPlayer) entity;
        		if(player.getCommandSenderName().equalsIgnoreCase(stack.stackTagCompound.getString("Owner"))){
        			return this.armorType == armorType;
        		}
        	}
        	}
        	return false;
        }
        public int getDamageReductionAmount(ItemStack stack)
        {
        	int answer = 0;
        	switch(stack.stackTagCompound.getString("Level")){
        		case "Leather":
        			answer = ArmorMaterial.CLOTH.getDamageReductionAmount(this.armorType);
        			break;
        		case "Chain":
        			answer = ArmorMaterial.CHAIN.getDamageReductionAmount(this.armorType);
        			break;
        		case "Iron":
        			answer = ArmorMaterial.IRON.getDamageReductionAmount(this.armorType);
        			break;
        		case "Gold":
        			answer = ArmorMaterial.GOLD.getDamageReductionAmount(this.armorType);
        			break;
        		case "Diamond":
        			answer = ArmorMaterial.DIAMOND.getDamageReductionAmount(this.armorType);
        			break;
        		default:
        			answer = 0;
        			break;
        	}
        	return answer;
        }
    
    @Override
    public ArmorProperties getProperties(EntityLivingBase player,
    		ItemStack armor, DamageSource source, double damage, int slot) {
    	// TODO Auto-generated method stub
    	return new ArmorProperties(1,.04*this.getDamageReductionAmount(armor), 11);
    }
    
    @Override
    public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
    	// TODO Auto-generated method stub
    	return this.getDamageReductionAmount(armor);
    }
    
    @Override
    public void damageArmor(EntityLivingBase entity, ItemStack stack,
    		DamageSource source, int damage, int slot) {
    	stack.stackTagCompound.setInteger("Durability Left", stack.stackTagCompound.getInteger("Durability Left")-1);
    
    }
    
    }
    

     

     

    energinium_layer_1.png is in src/main/resources/assets/troncraft/textures/armor

     

    Any ideas?

  9. Note that that's not all of it. Basically anything that has @SideOnly(Side.CLIENT) is definitely client only. But there might be classes which reference @SideOnly classes but don't have @SideOnly themselves, these would only work on the client as well.

     

    Thanks, That all makes sense, I'll make sure I keep an eye out for stuff like that.

     

    Basically:

     

    Remember to run the game as a client/server pair through Eclipse.  Use the dropdown arrow on the "run" button to see the options.  Run both, connect to the local server with the client, wait for something to explode.

     

    Wow, why did I never think of that...anyway thanks for the tip! Stuff already exploded so I've got fixing to do. Thank you guys for all the help, I really appreciate being able to talk to more experienced modders to help me understand forge more.

  10. Usually anything that has to do with visuals or sound can only happen on the client. So rendering, textures and well, sound.

    The other way round (only on the dedicated server) is rare. Haven't had it happen to me yet.

    Alright, so just so I understand correctly, I should only be registering things with sound and visuals on the client?

  11. So I understand why we make the proxies, to differentiate between an integrated server and dedicated server, but in what cases would I want to do something different based on that fact? I guess my mod is too basic to need them, but I'd like to know when to use them in the future. Thanks!

  12. So I have an entity which has a saved itemstack as a value. I want to save it between world unload and load event but it doesn't seem to be working. Currently this is what my writeEntityToNBT and readEntityFromNBT are:

     

    writeEntityToNBT:

    public void writeEntityToNBT(NBTTagCompound tag){
    	super.writeEntityToNBT(tag);
    	System.out.println("Written to NBT");
    	drop.writeToNBT(tag);
    	System.out.println(tag);
    }
    

     

    readEntityFromNBT:

    public void readEntityFromNBT(NBTTagCompound tag){
    	super.readEntityFromNBT(tag);
    	System.out.println("Read from NBT");
    }
    

     

    when the write method is called, everything works. However when the read method seems to never be called once i add the "drop.writetoNBT(tag)" line to the write method. I noticed the console prints

     

    [16:02:08] [server thread/WARN]: Skipping Entity with id 4097s
    

     

    which is the id of the itemstack that was saved in the write method. Any ideas why this happens?

     

×
×
  • Create New...

Important Information

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