Jump to content

CustomStairs extends BlockStairs


Zenim

Recommended Posts

Hi All

Trying to learn how to make a MC Mod so have been following a few youtub clips.

Have been following Kevin M Modding Minecraft 1.8 with Forge - Pt 3 - New Blocks and Items.

 

I am trying to use his method to make new stairs block but getting stuck.

 

Code

 

public class CustomStairs extends BlockStairs

{

private Item dropsOnHarvest;

private int dropamountmax = 1;

private int maxharvestEXP = 0;

 

public CustomStairs(Material material, String name, float hardness, float resistance, CreativeTabs creativetab, HarvestToolEnum harvesttool, HarvestLevelEnum harvestlevel, IBlockState IBlockState)

{

super(IBlockState);

 

this.setUnlocalizedName(name);

this.setHardness(hardness);

this.setResistance(resistance);

this.setStepSound(soundTypePiston);

this.setCreativeTab(creativetab);

this.setHarvestLevel(harvesttool, harvestlevel);

 

GameRegistry.registerBlock(this, name);

 

this.dropsOnHarvest = Item.getItemFromBlock(this);

}

 

 

In the Pane Blocks video he has "super(material, false);" but that was not working so i got no errors when i changed the statement to  "super(IBlockState);".

But when i run this minecrafte will not load up keeps crashing.

 

Code below. In CustomStairs.java

 

public CustomStairs(Material material, String name, float hardness, float resistance, CreativeTabs creativetab, HarvestToolEnum harvesttool, HarvestLevelEnum harvestlevel, IBlockState IBlockState)

    {

        super(IBlockState); 

 

 

In CommonProxy.java

 

 

Main.mossy_stonebrick = new CustomStairs(Material.rock, "mossy_stonebrick", 3.0F, 5.0F, CreativeTabs.tabBlock, CustomStairs.HarvestToolEnum.PICKAXE, CustomStairs.HarvestLevelEnum.STONE, null); 

 

 

 

I am a NOOB at this Modding thing so was guessing the super(IBlockState) and null statements.

 

I have tried to follow the other tutorials and from post here but they are confusing as there is many ways to do the same thing.

 

If someone could help I would very much appreciate it

 

Zen

 

Link to comment
Share on other sites

---- Minecraft Crash Report ----

 

 

---- Minecraft Crash Report ----

// Hey, that tickles! Hehehe!

 

Time: 20/06/15 4:35 AM

Description: Initializing game

 

java.lang.NullPointerException: Initializing game

at net.minecraft.block.BlockStairs.<init>(BlockStairs.java:44)

at com.zenim.zenmod.CustomStairs.<init>(CustomStairs.java:30)

at com.zenim.zenmod.CommonProxy.init(CommonProxy.java:23)

at com.zenim.zenmod.ClientProxy.init(ClientProxy.java:18)

at com.zenim.zenmod.Main.init(Main.java:41)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:710)

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:315)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:528)

at net.minecraft.client.Minecraft.run(Minecraft.java:356)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.block.BlockStairs.<init>(BlockStairs.java:44)

at com.zenim.zenmod.CustomStairs.<init>(CustomStairs.java:30)

at com.zenim.zenmod.CommonProxy.init(CommonProxy.java:23)

at com.zenim.zenmod.ClientProxy.init(ClientProxy.java:18)

at com.zenim.zenmod.Main.init(Main.java:41)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraftforge.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:537)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.sendEventToModContainer(LoadController.java:212)

at net.minecraftforge.fml.common.LoadController.propogateStateMessage(LoadController.java:190)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74)

at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47)

at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322)

at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304)

at com.google.common.eventbus.EventBus.post(EventBus.java:275)

at net.minecraftforge.fml.common.LoadController.distributeStateMessage(LoadController.java:119)

at net.minecraftforge.fml.common.Loader.initializeMods(Loader.java:710)

at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:315)

at net.minecraft.client.Minecraft.startGame(Minecraft.java:528)

 

-- Initialization --

Details:

Stacktrace:

at net.minecraft.client.Minecraft.run(Minecraft.java:356)

at net.minecraft.client.main.Main.main(Main.java:117)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)

at java.lang.reflect.Method.invoke(Unknown Source)

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

at net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source)

at GradleStart.main(Unknown Source)

 

-- System Details --

Details:

Minecraft Version: 1.8

Operating System: Windows 8.1 (amd64) version 6.3

Java Version: 1.8.0_45, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 728273752 bytes (694 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB)

JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML: MCP v9.10 FML v8.0.99.99 Minecraft Forge 11.14.3.1446 4 mods loaded, 4 mods active

mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) Unloaded->Constructed->Pre-initialized->Initialized

FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized

Forge{11.14.3.1446} [Minecraft Forge] (forgeSrc-1.8-11.14.3.1446.jar) Unloaded->Constructed->Pre-initialized->Initialized

zenmod{1.0} [zenmod] (bin) Unloaded->Constructed->Pre-initialized->Errored

Loaded coremods (and transformers):

GL info: ' Vendor: 'Intel' Version: '4.2.0 - Build 10.18.10.3496' Renderer: 'Intel® HD Graphics 4600'

Launched Version: 1.8

LWJGL: 2.9.1

OpenGL: Intel® HD Graphics 4600 GL version 4.2.0 - Build 10.18.10.3496, Intel

GL Caps: Using GL 1.3 multitexturing.

Using GL 1.3 texture combiners.

Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.

Shaders are available because OpenGL 2.1 is supported.

VBOs are available because OpenGL 1.5 is supported.

 

Using VBOs: No

Is Modded: Definitely; Client brand changed to 'fml,forge'

Type: Client (map_client.txt)

Resource Packs: []

Current Language: English (US)

Profiler Position: N/A (disabled)

 

Link to comment
Share on other sites

Of course it crashes, because you just pass null as the "model block", the block that the stairs should imitate. You need to pass something there.

Thanks for pointing that out.

I look into it more.

I just don't know enough yet as to what to out in.

Zen

Link to comment
Share on other sites

If it helps, here is the source code for BlockStairs.java:

 

 

package net.minecraft.block;

 

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import java.util.List;

import java.util.Random;

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

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.Icon;

import net.minecraft.util.MathHelper;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.Vec3;

import net.minecraft.world.Explosion;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

 

public class BlockStairs extends Block

{

    private static final int[][] field_72159_a = new int[][] {{2, 6}, {3, 7}, {2, 3}, {6, 7}, {0, 4}, {1, 5}, {0, 1}, {4, 5}};

 

    /** The block that is used as model for the stair. */

    private final Block modelBlock;

    private final int modelBlockMetadata;

    private boolean field_72156_cr;

    private int field_72160_cs;

 

    protected BlockStairs(int par1, Block par2Block, int par3)

    {

        super(par1, par2Block.blockMaterial);

        this.modelBlock = par2Block;

        this.modelBlockMetadata = par3;

        this.setHardness(par2Block.blockHardness);

        this.setResistance(par2Block.blockResistance / 3.0F);

        this.setStepSound(par2Block.stepSound);

        this.setLightOpacity(255);

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

 

    /**

    * Updates the blocks bounds based on its current state. Args: world, x, y, z

    */

    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        if (this.field_72156_cr)

        {

            this.setBlockBounds(0.5F * (float)(this.field_72160_cs % 2), 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F * (float)(this.field_72160_cs / 4 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 2 % 2), 0.5F + 0.5F * (float)(this.field_72160_cs / 4 % 2));

        }

        else

        {

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

        }

    }

 

    /**

    * Is this block (a) opaque and (b) a full 1m cube?  This determines whether or not to render the shared face of two

    * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.

    */

    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;

    }

 

    /**

    * The type of render function that is called for this block

    */

    public int getRenderType()

    {

        return 10;

    }

 

    public void func_82541_d(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);

 

        if ((l & 4) != 0)

        {

            this.setBlockBounds(0.0F, 0.5F, 0.0F, 1.0F, 1.0F, 1.0F);

        }

        else

        {

            this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);

        }

    }

 

    /**

    * Checks if supplied ID is one of a BlockStairs

    */

    public static boolean isBlockStairsID(int par0)

    {

        return par0 > 0 && Block.blocksList[par0] instanceof BlockStairs;

    }

 

    /**

    * returns true if the given block is a stairs block and is in the given direction of par5.  Parameters are

    * IBlockAccess, x, y, z, direction

    */

    private boolean isBlockStairsDirection(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)

    {

        int i1 = par1IBlockAccess.getBlockId(par2, par3, par4);

        return isBlockStairsID(i1) && par1IBlockAccess.getBlockMetadata(par2, par3, par4) == par5;

    }

 

    public boolean func_82542_g(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);

        int i1 = l & 3;

        float f = 0.5F;

        float f1 = 1.0F;

 

        if ((l & 4) != 0)

        {

            f = 0.0F;

            f1 = 0.5F;

        }

 

        float f2 = 0.0F;

        float f3 = 1.0F;

        float f4 = 0.0F;

        float f5 = 0.5F;

        boolean flag = true;

        int j1;

        int k1;

        int l1;

 

        if (i1 == 0)

        {

            f2 = 0.5F;

            f5 = 1.0F;

            j1 = par1IBlockAccess.getBlockId(par2 + 1, par3, par4);

            k1 = par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 3 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 + 1, l))

                {

                    f5 = 0.5F;

                    flag = false;

                }

                else if (l1 == 2 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 - 1, l))

                {

                    f4 = 0.5F;

                    flag = false;

                }

            }

        }

        else if (i1 == 1)

        {

            f3 = 0.5F;

            f5 = 1.0F;

            j1 = par1IBlockAccess.getBlockId(par2 - 1, par3, par4);

            k1 = par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 3 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 + 1, l))

                {

                    f5 = 0.5F;

                    flag = false;

                }

                else if (l1 == 2 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 - 1, l))

                {

                    f4 = 0.5F;

                    flag = false;

                }

            }

        }

        else if (i1 == 2)

        {

            f4 = 0.5F;

            f5 = 1.0F;

            j1 = par1IBlockAccess.getBlockId(par2, par3, par4 + 1);

            k1 = par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 1 && !this.isBlockStairsDirection(par1IBlockAccess, par2 + 1, par3, par4, l))

                {

                    f3 = 0.5F;

                    flag = false;

                }

                else if (l1 == 0 && !this.isBlockStairsDirection(par1IBlockAccess, par2 - 1, par3, par4, l))

                {

                    f2 = 0.5F;

                    flag = false;

                }

            }

        }

        else if (i1 == 3)

        {

            j1 = par1IBlockAccess.getBlockId(par2, par3, par4 - 1);

            k1 = par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 1 && !this.isBlockStairsDirection(par1IBlockAccess, par2 + 1, par3, par4, l))

                {

                    f3 = 0.5F;

                    flag = false;

                }

                else if (l1 == 0 && !this.isBlockStairsDirection(par1IBlockAccess, par2 - 1, par3, par4, l))

                {

                    f2 = 0.5F;

                    flag = false;

                }

            }

        }

 

        this.setBlockBounds(f2, f, f4, f3, f1, f5);

        return flag;

    }

 

    public boolean func_82544_h(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        int l = par1IBlockAccess.getBlockMetadata(par2, par3, par4);

        int i1 = l & 3;

        float f = 0.5F;

        float f1 = 1.0F;

 

        if ((l & 4) != 0)

        {

            f = 0.0F;

            f1 = 0.5F;

        }

 

        float f2 = 0.0F;

        float f3 = 0.5F;

        float f4 = 0.5F;

        float f5 = 1.0F;

        boolean flag = false;

        int j1;

        int k1;

        int l1;

 

        if (i1 == 0)

        {

            j1 = par1IBlockAccess.getBlockId(par2 - 1, par3, par4);

            k1 = par1IBlockAccess.getBlockMetadata(par2 - 1, par3, par4);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 3 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 - 1, l))

                {

                    f4 = 0.0F;

                    f5 = 0.5F;

                    flag = true;

                }

                else if (l1 == 2 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 + 1, l))

                {

                    f4 = 0.5F;

                    f5 = 1.0F;

                    flag = true;

                }

            }

        }

        else if (i1 == 1)

        {

            j1 = par1IBlockAccess.getBlockId(par2 + 1, par3, par4);

            k1 = par1IBlockAccess.getBlockMetadata(par2 + 1, par3, par4);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                f2 = 0.5F;

                f3 = 1.0F;

                l1 = k1 & 3;

 

                if (l1 == 3 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 - 1, l))

                {

                    f4 = 0.0F;

                    f5 = 0.5F;

                    flag = true;

                }

                else if (l1 == 2 && !this.isBlockStairsDirection(par1IBlockAccess, par2, par3, par4 + 1, l))

                {

                    f4 = 0.5F;

                    f5 = 1.0F;

                    flag = true;

                }

            }

        }

        else if (i1 == 2)

        {

            j1 = par1IBlockAccess.getBlockId(par2, par3, par4 - 1);

            k1 = par1IBlockAccess.getBlockMetadata(par2, par3, par4 - 1);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                f4 = 0.0F;

                f5 = 0.5F;

                l1 = k1 & 3;

 

                if (l1 == 1 && !this.isBlockStairsDirection(par1IBlockAccess, par2 - 1, par3, par4, l))

                {

                    flag = true;

                }

                else if (l1 == 0 && !this.isBlockStairsDirection(par1IBlockAccess, par2 + 1, par3, par4, l))

                {

                    f2 = 0.5F;

                    f3 = 1.0F;

                    flag = true;

                }

            }

        }

        else if (i1 == 3)

        {

            j1 = par1IBlockAccess.getBlockId(par2, par3, par4 + 1);

            k1 = par1IBlockAccess.getBlockMetadata(par2, par3, par4 + 1);

 

            if (isBlockStairsID(j1) && (l & 4) == (k1 & 4))

            {

                l1 = k1 & 3;

 

                if (l1 == 1 && !this.isBlockStairsDirection(par1IBlockAccess, par2 - 1, par3, par4, l))

                {

                    flag = true;

                }

                else if (l1 == 0 && !this.isBlockStairsDirection(par1IBlockAccess, par2 + 1, par3, par4, l))

                {

                    f2 = 0.5F;

                    f3 = 1.0F;

                    flag = true;

                }

            }

        }

 

        if (flag)

        {

            this.setBlockBounds(f2, f, f4, f3, f1, f5);

        }

 

        return flag;

    }

 

    /**

    * Adds all intersecting collision boxes to a list. (Be sure to only add boxes to the list if they intersect the

    * mask.) Parameters: World, X, Y, Z, mask, list, colliding entity

    */

    public void addCollisionBoxesToList(World par1World, int par2, int par3, int par4, AxisAlignedBB par5AxisAlignedBB, List par6List, Entity par7Entity)

    {

        this.func_82541_d(par1World, par2, par3, par4);

        super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);

        boolean flag = this.func_82542_g(par1World, par2, par3, par4);

        super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);

 

        if (flag && this.func_82544_h(par1World, par2, par3, par4))

        {

            super.addCollisionBoxesToList(par1World, par2, par3, par4, par5AxisAlignedBB, par6List, par7Entity);

        }

 

        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);

    }

 

    /**

    * Called when the block is clicked by a player. Args: x, y, z, entityPlayer

    */

    public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer)

    {

        this.modelBlock.onBlockClicked(par1World, par2, par3, par4, par5EntityPlayer);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * A randomly called display update to be able to add particles or other items for display

    */

    public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        this.modelBlock.randomDisplayTick(par1World, par2, par3, par4, par5Random);

    }

 

    /**

    * Called right before the block is destroyed by a player.  Args: world, x, y, z, metaData

    */

    public void onBlockDestroyedByPlayer(World par1World, int par2, int par3, int par4, int par5)

    {

        this.modelBlock.onBlockDestroyedByPlayer(par1World, par2, par3, par4, par5);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Goes straight to getLightBrightnessForSkyBlocks for Blocks, does some fancy computing for Fluids

    */

    public int getMixedBrightnessForBlock(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        return this.modelBlock.getMixedBrightnessForBlock(par1IBlockAccess, par2, par3, par4);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * How bright to render this block based on the light its receiving. Args: iBlockAccess, x, y, z

    */

    public float getBlockBrightness(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)

    {

        return this.modelBlock.getBlockBrightness(par1IBlockAccess, par2, par3, par4);

    }

 

    /**

    * Returns how much this block can resist explosions from the passed in entity.

    */

    public float getExplosionResistance(Entity par1Entity)

    {

        return this.modelBlock.getExplosionResistance(par1Entity);

    }

 

    /**

    * How many world ticks before ticking

    */

    public int tickRate(World par1World)

    {

        return this.modelBlock.tickRate(par1World);

    }

 

    /**

    * Can add to the passed in vector for a movement vector to be applied to the entity. Args: x, y, z, entity, vec3d

    */

    public void velocityToAddToEntity(World par1World, int par2, int par3, int par4, Entity par5Entity, Vec3 par6Vec3)

    {

        this.modelBlock.velocityToAddToEntity(par1World, par2, par3, par4, par5Entity, par6Vec3);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Returns which pass should this block be rendered on. 0 for solids and 1 for alpha

    */

    public int getRenderBlockPass()

    {

        return this.modelBlock.getRenderBlockPass();

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * From the specified side and block metadata retrieves the blocks texture. Args: side, metadata

    */

    public Icon getIcon(int par1, int par2)

    {

        return this.modelBlock.getIcon(par1, this.modelBlockMetadata);

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * Returns the bounding box of the wired rectangular prism to render.

    */

    public AxisAlignedBB getSelectedBoundingBoxFromPool(World par1World, int par2, int par3, int par4)

    {

        return this.modelBlock.getSelectedBoundingBoxFromPool(par1World, par2, par3, par4);

    }

 

    /**

    * Returns if this block is collidable (only used by Fire). Args: x, y, z

    */

    public boolean isCollidable()

    {

        return this.modelBlock.isCollidable();

    }

 

    /**

    * Returns whether this block is collideable based on the arguments passed in \n@param par1 block metaData \n@param

    * par2 whether the player right-clicked while holding a boat

    */

    public boolean canCollideCheck(int par1, boolean par2)

    {

        return this.modelBlock.canCollideCheck(par1, par2);

    }

 

    /**

    * Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z

    */

    public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)

    {

        return this.modelBlock.canPlaceBlockAt(par1World, par2, par3, par4);

    }

 

    /**

    * Called whenever the block is added into the world. Args: world, x, y, z

    */

    public void onBlockAdded(World par1World, int par2, int par3, int par4)

    {

        this.onNeighborBlockChange(par1World, par2, par3, par4, 0);

        this.modelBlock.onBlockAdded(par1World, par2, par3, par4);

    }

 

    /**

    * Called on server worlds only when the block has been replaced by a different block ID, or the same block with a

    * different metadata value, but before the new metadata value is set. Args: World, x, y, z, old block ID, old

    * metadata

    */

    public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6)

    {

        this.modelBlock.breakBlock(par1World, par2, par3, par4, par5, par6);

    }

 

    /**

    * Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity

    */

    public void onEntityWalking(World par1World, int par2, int par3, int par4, Entity par5Entity)

    {

        this.modelBlock.onEntityWalking(par1World, par2, par3, par4, par5Entity);

    }

 

    /**

    * Ticks the block if it's been scheduled

    */

    public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random)

    {

        this.modelBlock.updateTick(par1World, par2, par3, par4, par5Random);

    }

 

    /**

    * Called upon block activation (right click on the block.)

    */

    public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)

    {

        return this.modelBlock.onBlockActivated(par1World, par2, par3, par4, par5EntityPlayer, 0, 0.0F, 0.0F, 0.0F);

    }

 

    /**

    * Called upon the block being destroyed by an explosion

    */

    public void onBlockDestroyedByExplosion(World par1World, int par2, int par3, int par4, Explosion par5Explosion)

    {

        this.modelBlock.onBlockDestroyedByExplosion(par1World, par2, par3, par4, par5Explosion);

    }

 

    /**

    * Called when the block is placed in the world.

    */

    public void onBlockPlacedBy(World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack)

    {

        int l = MathHelper.floor_double((double)(par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

        int i1 = par1World.getBlockMetadata(par2, par3, par4) & 4;

 

        if (l == 0)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 2 | i1, 2);

        }

 

        if (l == 1)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 1 | i1, 2);

        }

 

        if (l == 2)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 3 | i1, 2);

        }

 

        if (l == 3)

        {

            par1World.setBlockMetadataWithNotify(par2, par3, par4, 0 | i1, 2);

        }

    }

 

    /**

    * Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata

    */

    public int onBlockPlaced(World par1World, int par2, int par3, int par4, int par5, float par6, float par7, float par8, int par9)

    {

        return par5 != 0 && (par5 == 1 || (double)par7 <= 0.5D) ? par9 : par9 | 4;

    }

 

    /**

    * Ray traces through the blocks collision from start vector to end vector returning a ray trace hit. Args: world,

    * x, y, z, startVec, endVec

    */

    public MovingObjectPosition collisionRayTrace(World par1World, int par2, int par3, int par4, Vec3 par5Vec3, Vec3 par6Vec3)

    {

        MovingObjectPosition[] amovingobjectposition = new MovingObjectPosition[8];

        int l = par1World.getBlockMetadata(par2, par3, par4);

        int i1 = l & 3;

        boolean flag = (l & 4) == 4;

        int[] aint = field_72159_a[i1 + (flag ? 4 : 0)];

        this.field_72156_cr = true;

        int j1;

        int k1;

        int l1;

 

        for (int i2 = 0; i2 < 8; ++i2)

        {

            this.field_72160_cs = i2;

            int[] aint1 = aint;

            j1 = aint.length;

 

            for (k1 = 0; k1 < j1; ++k1)

            {

                l1 = aint1[k1];

 

                if (l1 == i2)

                {

                    ;

                }

            }

 

            amovingobjectposition[i2] = super.collisionRayTrace(par1World, par2, par3, par4, par5Vec3, par6Vec3);

        }

 

        int[] aint2 = aint;

        int j2 = aint.length;

 

        for (j1 = 0; j1 < j2; ++j1)

        {

            k1 = aint2[j1];

            amovingobjectposition[k1] = null;

        }

 

        MovingObjectPosition movingobjectposition = null;

        double d0 = 0.0D;

        MovingObjectPosition[] amovingobjectposition1 = amovingobjectposition;

        l1 = amovingobjectposition.length;

 

        for (int k2 = 0; k2 < l1; ++k2)

        {

            MovingObjectPosition movingobjectposition1 = amovingobjectposition1[k2];

 

            if (movingobjectposition1 != null)

            {

                double d1 = movingobjectposition1.hitVec.squareDistanceTo(par6Vec3);

 

                if (d1 > d0)

                {

                    movingobjectposition = movingobjectposition1;

                    d0 = d1;

                }

            }

        }

 

        return movingobjectposition;

    }

 

    @SideOnly(Side.CLIENT)

 

    /**

    * When this method is called, your block should register all the icons it needs with the given IconRegister. This

    * is the only chance you get to register icons.

    */

    public void registerIcons(IconRegister par1IconRegister) {}

}

 

 

I AM NOT a Java Expert! Please don't treat me like one.

 

Also, has anyone seen a loose pig around here? He got out this morning and maybe hiding in the inspect element page...

 

My IQ is 148

Link to comment
Share on other sites

Interesting I get something different when I look up that class.

 

 

package net.minecraft.block;

 

import java.util.Arrays;

import java.util.List;

import java.util.Random;

import net.minecraft.block.material.MapColor;

import net.minecraft.block.properties.IProperty;

import net.minecraft.block.properties.PropertyDirection;

import net.minecraft.block.properties.PropertyEnum;

import net.minecraft.block.state.BlockState;

import net.minecraft.block.state.IBlockState;

import net.minecraft.creativetab.CreativeTabs;

import net.minecraft.entity.Entity;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.init.Blocks;

import net.minecraft.util.AxisAlignedBB;

import net.minecraft.util.BlockPos;

import net.minecraft.util.EnumFacing;

import net.minecraft.util.EnumWorldBlockLayer;

import net.minecraft.util.IStringSerializable;

import net.minecraft.util.MovingObjectPosition;

import net.minecraft.util.Vec3;

import net.minecraft.world.Explosion;

import net.minecraft.world.IBlockAccess;

import net.minecraft.world.World;

import net.minecraftforge.fml.relauncher.Side;

import net.minecraftforge.fml.relauncher.SideOnly;

 

public class BlockStairs extends Block

{

    public static final PropertyDirection FACING = PropertyDirection.create("facing", EnumFacing.Plane.HORIZONTAL);

    public static final PropertyEnum HALF = PropertyEnum.create("half", BlockStairs.EnumHalf.class);

    public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockStairs.EnumShape.class);

    private static final int[][] field_150150_a = new int[][] {{4, 5}, {5, 7}, {6, 7}, {4, 6}, {0, 1}, {1, 3}, {2, 3}, {0, 2}};

    private final Block modelBlock;

    private final IBlockState modelState;

    private boolean hasRaytraced;

    private int rayTracePass;

    private static final String __OBFID = "CL_00000314";

 

    protected BlockStairs(IBlockState modelState)

    {

        super(modelState.getBlock().blockMaterial);

        this.setDefaultState(this.blockState.getBaseState().withProperty(FACING, EnumFacing.NORTH).withProperty(HALF, BlockStairs.EnumHalf.BOTTOM).withProperty(SHAPE, BlockStairs.EnumShape.STRAIGHT));

        this.modelBlock = modelState.getBlock();

        this.modelState = modelState;

        this.setHardness(this.modelBlock.blockHardness);

        this.setResistance(this.modelBlock.blockResistance / 3.0F);

        this.setStepSound(this.modelBlock.stepSound);

        this.setLightOpacity(255);

        this.setCreativeTab(CreativeTabs.tabBlock);

    }

 

 

Thanks Give me more to look at.

Zen

Link to comment
Share on other sites

I forgot to say that class is for 1.6.4, so I only have access to 1.6.4 things. Just message me if you need any source code!

 

 

My BAD, I forgot to mention I am working in 1.8.

But your post dose help me as I now realise that some of the code I have been looking from other post must be from other versions of MC.

 

Thanks

Zen

 

Link to comment
Share on other sites

  • 2 weeks later...

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.