Jump to content

metaBlocks whit custom setBounds based on metadata Howyou doit ??<SOLVED>


perromercenary00

Recommended Posts

Good days

 

 

I'm new to modding and I been experimenting with meta blocks

 

 

I have this Metablock with 6 subBlocks  and want each subBlock to have different Bounds.

 

so far and done so is to place the bounds in the constructor creating a public variable with the metadata

then defines the bounds whit a if else chain,  works but the limits of the subBlocks get mixed and change wen i put a new block on the world.

 

then i place the bounds if else in

public iicon getIcon (int side, int meta) using the meta value for the icons

i get the same trouble that whith the contructor.

 

copy the method from the Block wall.class and put there the if else meta ending whith the same results

 

 

 

//##################################################################

@SideOnly(Side.CLIENT)

public IIcon getIcon(int side, int meta) {

 

Meta=meta;

 

  //System.out.println("Block bounds meta="+Meta);

  //                    x  y  z  x    y    z

  //this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F); //full block

  if (Meta==0){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}

  if (Meta==1){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}

 

  if (Meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}

  if (Meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}

 

  if (Meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}

  if (Meta==5){this.setBlockBounds(0F,0.5F,0F,0.5F,1.0F,1.0F);}

 

  if (Meta >5){this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F);}

 

 

//System.out.println("side="+side+" meta="+meta);

 

        int tex=(meta*6)+(side);

 

//System.out.println("side="+side+" meta="+meta+" tex="+tex);

if (tex < icons.length ){return icons[tex];}

                    else{return icons[0];}

 

} // fin de IIcon getIcon

 

//##################################################################

 

 

public void setBlockBoundsBasedOnState (IBlockAccess p_149719_1_, p_149719_2_ int, int p_149719_3_, int p_149719_4_){

  //System.out.println("Block bounds meta="+Meta);

  //                    x  y  z  x    y    z

  //this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F); //full block

  if (Meta==0){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}

  if (Meta==1){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}

 

  if (Meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}

  if (Meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}

 

  if (Meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}

  if (Meta==5){this.setBlockBounds(0F,0.5F,0F,0.5F,1.0F,1.0F);}

 

  if (Meta >5){this.setBlockBounds(0F,0F,0F,1.0F,1.0F,1.0F);}

 

}

//##################################################################

 

 

 

Link to comment
Share on other sites

There's also setBlockBoundsBasedOnState, which has the entire point of returning different bounds based on metadata.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

@Draco: Nope. Check where it's called from.

 

My bad.  I'd only remembered seeing the function before and its javadoc ("Updates the blocks bounds based on its current state. Args: world, x, y, z")

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

ñaaa

 

 

i been triying before the

public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)

 

the trouble whit tath metod is,  well there is no metadata data in the parameters entry so a have to generated or take it from other method like

public IIcon getIcon(int side, int meta) {

but hass the same trouble like when i put it in getIcon

 

i must put this if else metada bounds cicle in the method who generates the metadata data and that is 

 

 

//##############################################################

 

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase steve, ItemStack p_149689_6_){

 

int meta=util.meta(world, steve);

System.out.println("util.meta(world, steve)="+meta);

    //x

if (meta==5){this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5

if (meta==4){this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4

    //y

if (meta==1){this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1

if (meta==0){this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0

    //z

if (meta==2){this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2

if (meta==3){this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3

 

world.setBlock(x, y, z, modBlocks.puertaMercenaria , meta, 4);

 

}

//##############################################################

 

and Nop it dont fix the issue  when i put a block in the world all the metablocks change bounds ending exactly the same

 

actualy i think this dont gona work  I'll gonna end up creating 6 different metablocks each with a different setbounds and a very long piece of code to define their behavior

 

 

 

Link to comment
Share on other sites

Well, that's MCP javadocs :P

 

MCP or not, its misleading. :|

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

The cake is a lie,

 

Nop This time the Cake knows the true

in the cake class i found like diesieben says using world.getBlockMetadata(x,y,z); to get the meta direct

here a video

 

 

 

the block is the one whith oak texture

there is some weirdiness whit the icons in hotbar they start to change but for now i dont care

now is more easy to get done the rest of the code im gona do dat in a few days.

 

 

public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)

{

    int l = world.getBlockMetadata(x,y,z);

 

    System.out.println("//#################  ################ meta2="+l);

   

    if (l==0){ this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0

   

    else if (l==1){ this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1

   

    else if (l==2){ this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2

    else if (l==3){ this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3

   

    else if (l==4){ this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4

    else if (l==5){ this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5

 

    else { this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,1.0F);}//full blocke

 

}

 

 

 

// all the code for the block

 

 

package mercenary00.mercenarymod.blocks;

 

import java.util.List;

import mercenary00.mercenarymod.items.ItemBlockMultiBlock;

import mercenary00.mercenarymod.Mercenary;

import net.minecraft.block.Block;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.Item;

import net.minecraft.item.ItemStack;

import net.minecraft.item.ItemStack;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.IIcon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import cpw.mods.fml.common.registry.GameRegistry;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import mercenary00.mercenarymod.utilidades.util;

import mercenary00.mercenarymod.blocks.puertaMercenaria;

 

//################################################################################################################

public class puertaMercenaria extends Block{

 

private int maxMeta = 6;

IIcon[] icons = new IIcon[36];

private final String name = "puertamercenaria";

 

 

//################################################################################################################

public  puertaMercenaria() {

    super(Material.rock);

        setBlockName(Mercenary.MODID + "_" + name);

//        setCreativeTab(CreativeTabs.tabBlock);

     

        this.setHardness(4.0F);

        this.setResistance(6.0F);

        this.setStepSound(soundTypeWood);

   

        GameRegistry.registerBlock(this, ItemBlockMultiBlock.class, name);

 

}//fin del contructor

 

 

//################################################################################################################

@Override

public void registerBlockIcons(IIconRegister iconRegister) {

 

    for(int ic = 0; ic < icons.length; ic++) {

        icons[ic] = iconRegister.registerIcon(Mercenary.MODID + ":"+"puertas/" + name + ic);

    }

}

 

//################################################################################################################

@SideOnly(Side.CLIENT)

public IIcon getIcon(int side, int meta) {

 

int tex=(meta*6)+(side);

if (tex < icons.length ){return icons[tex];}

else{return icons[0];}

} // fin de IIcon getIcon

 

 

//################################################################################################################

@Override

public int damageDropped(int meta) {

    return meta;

}

 

//################################################################################################################

 

@SuppressWarnings({ "unchecked", "rawtypes" })

@Override

  public void getSubBlocks(Item item, CreativeTabs creativeTabs, List list) {

 

      for(int i = 0; i < maxMeta; i++){

 

          list.add(new ItemStack(item, 1, i));

      }

  }

 

 

//################################################################################################################

//@Override

public int getMetadata(int meta) {

    return meta;

}

 

//################################################################################################################

public boolean isOpaqueCube()

{

    return false;

}

 

//################################################################################################################

/**

* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)

*/

public boolean renderAsNormalBlock()

{

    return false;

}

 

//################################################################################################################

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase steve, ItemStack p_149689_6_){

 

int meta=util.meta(world, steve);

System.out.println("util.meta(world, steve)="+meta);

 

world.setBlock(x, y, z, modBlocks.puertaMercenaria , meta, 4);

}

//################################################################################################################

 

public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z)

{

    int l = world.getBlockMetadata(x,y,z);

 

    System.out.println("//#################  ################ meta2="+l);

   

    if (l==0){ this.setBlockBounds(0F,0.5F,0F, 1.0F,1.0F,1.0F);}//cara 0

   

    else if (l==1){ this.setBlockBounds(0F,0F,0F, 1.0F,0.5F,1.0F);}//cara 1

   

    else if (l==2){ this.setBlockBounds(0F,0F,0.5F, 1.0F,1.0F,1.0F);}//cara 2

    else if (l==3){ this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,0.5F);}//cara 3

   

    else if (l==4){ this.setBlockBounds(0.5F,0F,0F,1.0F,1.0F,1.0F);}//cara 4

    else if (l==5){ this.setBlockBounds(0.0F,0F,0F,0.5F,1.0F,1.0F);}//cara 5

 

    else { this.setBlockBounds(0F,0F,0F, 1.0F,1.0F,1.0F);}//full blocke

 

}

 

//################################################################################################################

 

 

 

}

Link to comment
Share on other sites

The cake is a lie,

 

Nop This time the Cake knows the true

in the cake class i found like diesieben says using world.getBlockMetadata(x,y,z); to get the meta direct

here a video

 

 

 

the block is the one whith oak texture

there is some weirdiness whit the icons in hotbar they start to change but for now i dont care

now is more easy to get done the rest of the code im gona do dat in a few days.

 

-snip-

 

Use getCollisionBoundingBoxFromPool and getSelectedBoundingBoxFromPool.

 

You're still using setBlockBoundsBasedOnState...

Also use http://gist.github.com to post your code, it's 1. far more readable and 2. doesn't clutter the thread.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

Link to comment
Share on other sites

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • no this one https://pastebin.com/5uMxHeWf
    • I am in such a mess. I have lost over 4.7m due to a scammer... It started as bank wires and then bitcoin. it is hard to imagine but it is true and can send any proof, then I tried to use a couple of recovery companies and was as well. Graphic design has been more than just a hobby for me since high school—it has become a thriving career. Starting in my parents' garage, I eventually expanded to my office, running a successful graphic design business. However, like many, I faced the need to diversify my investments due to inflation. This led me to invest 60.16 in Bitcoin, a decision that paid off handsomely as my investment grew to 4.7m over time. This financial windfall allowed me to upgrade my equipment and take on more ambitious projects, furthering the growth of my business. Unfortunately, my excitement was abruptly cut short when I fell victim to a hacking incident. Malware infected my computer, giving hackers access to my Bitcoin wallet. The devastation of potentially losing all my hard-earned savings and plans weighed heavily on me. At this dire moment, a fellow designer suggested Linux Cyber Security Company as a potential solution. Desperate for a lifeline, I reached out to them, hoping for a miracle. The response from Linux Cyber Security Company was prompt, incredibly professional, and effective. Their team quickly traced the hacker’s activities and recovered most of my funds, alleviating a significant amount of stress and uncertainty. Beyond the recovery, they took the time to educate me on essential practices to secure my Bitcoin holdings better. They emphasized using antivirus software to prevent malware infections, avoiding suspicious downloads, and the added security provided by hardware wallets. This experience served as a critical wake-up call for me. It highlighted the vulnerabilities inherent in digital assets and underscored the importance of robust security measures. Thanks to the guidance and expertise of Linux Cyber Security Company, I now feel more equipped to protect my digital assets proactively. Their insights have empowered me to implement stronger security protocols in my business operations and personal finances alike. With my Bitcoin funds securely recovered and a newfound understanding of digital security best practices, I am more confident in navigating future challenges. This journey has reinforced my commitment to safeguarding my hard-earned assets and leveraging technology responsibly. I am optimistic about the growth opportunities ahead, creatively in graphic design and prudently in investment strategies. In conclusion, while the hacking incident was a setback, it ultimately became a catalyst for enhancing my digital security awareness and resilience. I am grateful to Linux Cyber Security Company for their expertise and support during a challenging time, enabling me to continue pursuing my passion for graphic design with renewed confidence and financial stability. Contact a professional company I am sure they can help you with your case too, Website [www.linuxcybersecurity.com Email the team; info@)(linuxcybersecurity.com
    • https://pastebin.com/B2HnBZTa
    • it was easy villager mate, thanks ill see how to do it without that mod! thanks
  • Topics

×
×
  • Create New...

Important Information

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