Jump to content

killer380

Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by killer380

  1. Was taking a peek in the Item class to get a method, and I noticed this unnamed method. public float func_150893_a(ItemStack p_150893_1_, Block p_150893_2_){ return 1.0F; } I just updated to the recommended build of 1.7.10 Anyone know what it might do?
  2. Hmmm alright... Well i got the rendering based on NBT working. Turns out the getIcon method is accessed constantly so i stuck some things in there and got it to change the textures. Unfortunately new problem When I right click to add a item to the block it changes the texture for ALL of the blocks. So they are all affected. Im really not sure how to make them separate.
  3. Hi, I was just wondering how I could get a block to reset its icons? I want it so that when the player right clicks with a certain item it will change texture to show that item. I am not sure how I can get the block to re-render since it only renders once on startup. I heard of a TESR but i dont want it to be constantly rendering every tick. Just when a action happens. Anyone know how I could do that? This is what i have for the block info. package com.MagicandMisc.block; import java.util.ArrayList; import net.minecraft.block.Block; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.client.renderer.texture.IIconRegister; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.IIcon; import net.minecraft.world.World; import com.MagicandMisc.item.ItemManager; import com.MagicandMisc.lib.StringLibrary; import com.MagicandMisc.tileentity.TileEntityIce; public class MysticalIce extends Block { boolean hasAlloy[] = new boolean[3];{ for(int i=0;i<3;i++){ hasAlloy[i] = false; } } public IIcon Side0; public IIcon Side1; public IIcon Side2; public IIcon Side3; public IIcon Side4; public IIcon Side5; public int colors = 0; protected MysticalIce(Material p_i45394_1_) { super(p_i45394_1_); // TODO Auto-generated constructor stub } @Override public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune){ ArrayList<ItemStack> drops = new ArrayList<ItemStack>(); TileEntityIce ice = new TileEntityIce(); hasAlloy = ice.alloyInfo(); if(hasAlloy[0]){ drops.add(new ItemStack(ItemManager.lime_alloy_ingot,1)); } if(hasAlloy[1]){ drops.add(new ItemStack(ItemManager.magenta_alloy_ingot,1)); } if(hasAlloy[2]){ drops.add(new ItemStack(ItemManager.orange_alloy_ingot,1)); } boolean alloy[] = {false,false,false}; ice.getGems(alloy, world); drops.add(new ItemStack(BlockManager.mystical_ice,1)); System.out.println("Drops:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); return drops; } @Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { ItemStack held = player.getHeldItem(); Item item; if(held == null){ item = Items.apple; } else{ item = held.getItem(); } if(item == ItemManager.lime_alloy_ingot && !hasAlloy[0]){ hasAlloy[0] = true; if(held.stackSize == 1){ player.setItemInUse(null, 0); } else{ held.stackSize = held.stackSize-1; player.setItemInUse(held, 0); } } if(item == ItemManager.magenta_alloy_ingot && !hasAlloy[1]){ hasAlloy[1] = true; if(held.stackSize == 1){ player.setItemInUse(null, 0); } else{ held.stackSize = held.stackSize-1; player.setItemInUse(held, 0); } } if(item == ItemManager.orange_alloy_ingot && !hasAlloy[2]){ hasAlloy[2] = true; if(held.stackSize == 1){ player.setItemInUse(null, 0); } else{ held.stackSize = held.stackSize-1; player.setItemInUse(held, 0); } } TileEntityIce ice = new TileEntityIce(); ice.getGems(hasAlloy, world); return true; } public boolean hasTileEntity(int metadata) { return true; } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityIce(); } @Override public void registerBlockIcons(IIconRegister icon) { /* What I'm trying to do here is to use the method of ^2 so * I can have a unique image for each combination without a * ton of if statements */ TileEntityIce ice = new TileEntityIce(); hasAlloy = ice.alloyInfo(); if(hasAlloy[0]){ colors += 2; } if(hasAlloy[1]){ colors += 4; } if(hasAlloy[2]){ colors += 8; } System.out.println(colors); Side0 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+"tb"); Side1 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+"tb"); Side2 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+colors); Side3 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+colors); Side4 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+colors); Side5 = icon.registerIcon(StringLibrary.MODID+":"+"mystical_ice_"+colors); } @Override public IIcon getIcon(int side, int metadata) { switch(side){ case 0: return Side0; case 1: return Side1; case 2: return Side2; case 3: return Side3; case 4: return Side4; case 5: return Side5; default: return Side0; } } } This is the code for my TileEntity in the block. I tried using notifyBlockChange but I'm unsure what that actually does. package com.MagicandMisc.tileentity; import net.minecraft.block.material.Material; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.World; import com.MagicandMisc.block.BlockManager; import com.MagicandMisc.block.MysticalIce; public class TileEntityIce extends TileEntity { static boolean hasAlloy[] = new boolean[3]; public void getGems(boolean[] alloy, World world){ for(int i=0;i<3;i++){ hasAlloy[i] = alloy[i]; } System.out.println("Alloys:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); world.notifyBlockChange(xCoord, yCoord, zCoord, BlockManager.mystical_ice); world.markBlockRangeForRenderUpdate(xCoord, yCoord, zCoord, xCoord, yCoord, zCoord); System.out.println("Alloys2:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); } @Override public void writeToNBT(NBTTagCompound nbt){ super.writeToNBT(nbt); System.out.println("Write:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); nbt.setBoolean("Lime", hasAlloy[0]); nbt.setBoolean("Magenta", hasAlloy[1]); nbt.setBoolean("Orange", hasAlloy[2]); } @Override public void readFromNBT(NBTTagCompound nbt){ super.readFromNBT(nbt); hasAlloy[0] = nbt.getBoolean("Lime"); hasAlloy[1] = nbt.getBoolean("Magenta"); hasAlloy[2] = nbt.getBoolean("Orange"); System.out.println("Read:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); } public boolean[] alloyInfo(){ System.out.println("Send:"+ hasAlloy[0] + hasAlloy[1]+hasAlloy[2]); return hasAlloy; } }
×
×
  • Create New...

Important Information

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