Jump to content

KnaxelBaby

Members
  • Posts

    7
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

KnaxelBaby's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. how would i store TileEntity data
  2. i didnt read much of the post tbh but i found youre using a method called "onRightClickItem" and i would use this one ? public boolean onItemUse(ItemStack is, EntityPlayer eplayer, World world, BlockPos pos, EnumFacing facing, float f1, float f2, float f3) { return false; }
  3. here it is package knaxelbaby.modcore.blocks; import java.util.ArrayList; import knaxelbaby.modcore.Reference; import knaxelbaby.modcore.blocks.access.RWBlockJarInteractable; import knaxelbaby.modcore.models.Mason_Jar_0; import knaxelbaby.modcore.models.Mason_Jar_1; import knaxelbaby.modcore.models.Mason_Jar_2; import knaxelbaby.modcore.models.Mason_Jar_3; import knaxelbaby.modcore.models.Mason_Jar_4; import knaxelbaby.modcore.models.Mason_Jar_5; import knaxelbaby.modcore.models.Mason_Jar_6; import knaxelbaby.modcore.models.Mason_Jar_7; import knaxelbaby.modcore.models.Mason_Jar_8; import knaxelbaby.modcore.models.Mason_Jar_Empty; import knaxelbaby.modcore.models.Mason_Jar_Model; import knaxelbaby.modcore.tileentities.TileEntityJar; import net.minecraft.block.BlockContainer; import net.minecraft.block.material.Material; import net.minecraft.block.properties.IProperty; import net.minecraft.block.properties.PropertyInteger; import net.minecraft.block.state.BlockState; import net.minecraft.block.state.IBlockState; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.BlockPos; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class RWBlockJar extends BlockContainer implements RWBlockJarInteractable { public static final PropertyInteger AMOUNT =PropertyInteger.create("amount", 0, 9); public static final PropertyInteger SPECIES =PropertyInteger.create("amount", 0, 9); private ArrayList<Mason_Jar_Model> models = new ArrayList<Mason_Jar_Model>(); private Mason_Jar_0 jar0 = new Mason_Jar_0(); private Mason_Jar_1 jar1 = new Mason_Jar_1(); private Mason_Jar_2 jar2 = new Mason_Jar_2(); private Mason_Jar_3 jar3 = new Mason_Jar_3(); private Mason_Jar_4 jar4 = new Mason_Jar_4(); private Mason_Jar_5 jar5 = new Mason_Jar_5(); private Mason_Jar_6 jar6 = new Mason_Jar_6(); private Mason_Jar_7 jar7 = new Mason_Jar_7(); private Mason_Jar_8 jar8 = new Mason_Jar_8(); private Mason_Jar_Empty jare = new Mason_Jar_Empty(); private ResourceLocation texture = new ResourceLocation(Reference.MODID, "textures/custom/Mason_Jar.png"); public RWBlockJar(Material mat) { super(mat); setDefaultState(this.getDefaultState().withProperty(AMOUNT, Integer.valueOf(0)).withProperty(SPECIES, Integer.valueOf(0))); models.add(jare); models.add(jar0); models.add(jar1); models.add(jar2); models.add(jar3); models.add(jar4); models.add(jar5); models.add(jar6); models.add(jar7); models.add(jar8); } public TileEntity createNewTileEntity(World world, int arg) { return new TileEntityJar(); } public int getRenderType() { return -1; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public IBlockState getStateFromMeta(int meta) { return getDefaultState().withProperty(AMOUNT, Integer.valueOf( meta & 0x3)).withProperty(SPECIES, Integer.valueOf(( meta & 0xF) >> 2)); } public int getMetaFromState(IBlockState state) { int i = 0; i |= ((Integer)state.getValue(AMOUNT)).intValue(); i |= ((Integer)state.getValue(SPECIES)).intValue() << 2; System.out.println(i); return i; } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { AMOUNT, SPECIES}); } public ResourceLocation getTextureLocation() { return texture; } public void setCurrentModel(World world, BlockPos pos, int i) { IBlockState state = ((IBlockState) world.getBlockState(pos)); int meta = getMetaFromState(state); world.setBlockState(pos, state.withProperty(AMOUNT, Integer.valueOf(i))); } public boolean isFull(World world, BlockPos pos) { return (((Integer) world.getBlockState(pos).getValue(AMOUNT)).intValue() == 9); } public Mason_Jar_Model getCurrentModel(World world, BlockPos pos) { return models.get(((Integer) world.getBlockState(pos).getValue(AMOUNT)).intValue()); } public int getCurrentModelIndex(World world, BlockPos pos) { return ((Integer)world.getBlockState(pos).getValue(AMOUNT)).intValue(); } public boolean isEmpty(World world, BlockPos pos) { return (((Integer) world.getBlockState(pos).getValue(AMOUNT)).intValue() == 0); } @Override public int getSpecies(World world, BlockPos pos) { return ((Integer)world.getBlockState(pos).getValue(SPECIES)).intValue(); } @Override public void setSpecies(World world, BlockPos pos, int i) { world.setBlockState(pos, world.getBlockState(pos).withProperty(SPECIES, i)); } } heres the interactable that lets me access certain methods package knaxelbaby.modcore.blocks.access; import knaxelbaby.modcore.models.Mason_Jar_Model; import net.minecraft.util.BlockPos; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public abstract interface RWBlockJarInteractable { public abstract void setCurrentModel(World world, BlockPos pos, int i); public abstract boolean isFull(World world, BlockPos pos); public abstract Mason_Jar_Model getCurrentModel(World world, BlockPos pos); public abstract int getCurrentModelIndex(World world, BlockPos pos); public abstract ResourceLocation getTextureLocation(); public abstract boolean isEmpty(World worldObj, BlockPos pos); public abstract int getSpecies(World world, BlockPos pos); public abstract void setSpecies(World world,BlockPos pos, int i); } and the renderer class package knaxelbaby.modcore.renderers; import java.util.ArrayList; import knaxelbaby.modcore.Reference; import knaxelbaby.modcore.blocks.access.RWBlockJarInteractable; import knaxelbaby.modcore.blocks.access.RWPieceUsable; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; public class RendererJar extends TileEntitySpecialRenderer { public RendererJar() { } public void renderTileEntityAt(TileEntity entity, double x, double y, double z, float angle, int i) { GL11.glPushMatrix(); GL11.glTranslatef((float) (x + .5), (float) (y + 1.5), (float) (z + .5)); GL11.glRotatef(180, 0, 0, 1F); RWBlockJarInteractable usable = ((RWBlockJarInteractable) entity.getWorld() .getBlockState(entity.getPos()).getBlock()); ResourceLocation res = usable.getTextureLocation(); this.bindTexture(res); GL11.glPushMatrix(); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); usable.getCurrentModel(entity.getWorld(), entity.getPos()).render( 0.0625F); GL11.glPopMatrix(); GL11.glPopMatrix(); } }
  4. this is what the method getMetaFromState is returning 0 5 10 15 20 21 30 31 40 45
  5. i wouldnt have posted if using the same code worked....
  6. Well i understand that, but i need two meta datas essentially, the anvil has directional data and damage. how can i do something similar. public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL); public static final PropertyInteger DAMAGE = PropertyInteger.create("damage", 0, 2);
  7. Hello forge community while i was developing my first forge mod for minecraft 1.8 i ran into an issue with my knowledge on minecrafts property and meta data system. I have a jar with a custom model that changes depending on the amount of the substance put into the jar. this property name is AMOUNT but i also want another property for the type of the substance being put in (there are two) this property i would like to be called SPECIES (its a plant). I was looking how minecraft does this for the anvil (is has a directional property and a damage property) and they used this code here to get the meta and state public IBlockState getStateFromMeta(int p_getStateFromMeta_1_) { return getDefaultState().withProperty(FACING, EnumFacing.getHorizontal(p_getStateFromMeta_1_ & 0x3)).withProperty(DAMAGE, Integer.valueOf((p_getStateFromMeta_1_ & 0xF) >> 2)); } public int getMetaFromState(IBlockState p_getMetaFromState_1_) { int i = 0; i |= ((EnumFacing)p_getMetaFromState_1_.getValue(FACING)).getHorizontalIndex(); i |= ((Integer)p_getMetaFromState_1_.getValue(DAMAGE)).intValue() << 2; return i; } protected BlockState createBlockState() { return new BlockState(this, new IProperty[] { FACING, DAMAGE }); } Theyre using bitwis operators and i was wondering how i could implement the same idea to my mod thank you
×
×
  • Create New...

Important Information

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