- 32
- 0
Вообщем я сделал свой полублок и озадачился тем, почему у меня при щелчке колёсиком берётся каменный полублок, а не мой. Порывшись в коде понял, что это прописано в blockslab. В результате я создал свой blockslab и попытался его изменить, так, что бы блок, который берется в инвентарь получался из главного файла мода, но почему то теперь в инвентарь вообще ничего не попадает... Вот код:
Код:
Colorblocks_cl_sl_1_1 = new BlockCustomClaySlab(Colorblocks_cl_bl_1_1, false).setBlockName("Colorblocks_cl_sl_1_1").setBlockTextureName("colorclay:1_1");
GameRegistry.registerBlock(Colorblocks_cl_sl_1_1, "Colorblocks_cl_sl_1_1 ");
Код:
package net.ColorBlocks.blocks;
import lordguard.mods.colorblocks.ColorBlocks;
import cpw.mods.fml.common.registry.GameRegistry;
import net.ColorBlocks.customblocks.CustomBlockSlab;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
public class BlockCustomClaySlab extends CustomBlockSlab {
public BlockCustomClaySlab(Block rdt_1_rdt, boolean trd_1_trd) {
super(rdt_1_rdt, false, Material.rock);
this.setCreativeTab(ColorBlocks.ColorBlocksTab_ClayBlocks);
this.setHardness(15F);
this.setHarvestLevel("pickaxe", 3);
this.setLightLevel(0F);
this.setBlockUnbreakable();
this.useNeighborBrightness = true;
}
@Override
public String func_150002_b(int p_150002_1_) {
return null;
}
}
Код:
package net.ColorBlocks.customblocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import java.util.Random;
import lordguard.mods.colorblocks.ColorBlocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Facing;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public abstract class CustomBlockSlab extends Block
{
protected final boolean field_150004_a;
private static final String __OBFID = "CL_00000253";
private final Block rdt_1_rdt;
public CustomBlockSlab(Block rdt_1_rdt, boolean p_i45410_1_, Material p_i45410_2_)
{
super(p_i45410_2_);
this.field_150004_a = p_i45410_1_;
if (p_i45410_1_)
{
this.opaque = true;
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
this.setLightOpacity(255);
this.rdt_1_rdt = rdt_1_rdt;
}
/**
* Updates the blocks bounds based on its current state. Args: world, x, y, z
*/
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_)
{
if (this.field_150004_a)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
boolean flag = (p_149719_1_.getBlockMetadata(p_149719_2_, p_149719_3_, p_149719_4_) & 8) != 0;
if (flag)
{
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);
}
}
}
/**
* Sets the block's bounds for rendering it as an item
*/
public void setBlockBoundsForItemRender()
{
if (this.field_150004_a)
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
else
{
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
}
}
/**
* 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 p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
{
this.setBlockBoundsBasedOnState(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_);
super.addCollisionBoxesToList(p_149743_1_, p_149743_2_, p_149743_3_, p_149743_4_, p_149743_5_, p_149743_6_, p_149743_7_);
}
/**
* 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 this.field_150004_a;
}
/**
* Called when a block is placed using its ItemBlock. Args: World, X, Y, Z, side, hitX, hitY, hitZ, block metadata
*/
public int onBlockPlaced(World p_149660_1_, int p_149660_2_, int p_149660_3_, int p_149660_4_, int p_149660_5_, float p_149660_6_, float p_149660_7_, float p_149660_8_, int p_149660_9_)
{
return this.field_150004_a ? p_149660_9_ : (p_149660_5_ != 0 && (p_149660_5_ == 1 || (double)p_149660_7_ <= 0.5D) ? p_149660_9_ : p_149660_9_ | 8);
}
/**
* Returns the quantity of items to drop on block destruction.
*/
public int quantityDropped(Random p_149745_1_)
{
return this.field_150004_a ? 2 : 1;
}
/**
* Determines the damage on the item the block drops. Used in cloth and wood.
*/
public int damageDropped(int p_149692_1_)
{
return p_149692_1_ & 7;
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return this.field_150004_a;
}
/**
* Returns true if the given side of this block type should be rendered, if the adjacent block is at the given
* coordinates. Args: blockAccess, x, y, z, side
*/
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess p_149646_1_, int p_149646_2_, int p_149646_3_, int p_149646_4_, int p_149646_5_)
{
if (this.field_150004_a)
{
return super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_);
}
else if (p_149646_5_ != 1 && p_149646_5_ != 0 && !super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_))
{
return false;
}
else
{
int i1 = p_149646_2_ + Facing.offsetsXForSide[Facing.oppositeSide[p_149646_5_]];
int j1 = p_149646_3_ + Facing.offsetsYForSide[Facing.oppositeSide[p_149646_5_]];
int k1 = p_149646_4_ + Facing.offsetsZForSide[Facing.oppositeSide[p_149646_5_]];
boolean flag = (p_149646_1_.getBlockMetadata(i1, j1, k1) & 8) != 0;
return flag ? (p_149646_5_ == 0 ? true : (p_149646_5_ == 1 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & 8) == 0)) : (p_149646_5_ == 1 ? true : (p_149646_5_ == 0 && super.shouldSideBeRendered(p_149646_1_, p_149646_2_, p_149646_3_, p_149646_4_, p_149646_5_) ? true : !func_150003_a(p_149646_1_.getBlock(p_149646_2_, p_149646_3_, p_149646_4_)) || (p_149646_1_.getBlockMetadata(p_149646_2_, p_149646_3_, p_149646_4_) & 8) != 0));
}
}
@SideOnly(Side.CLIENT)
private static boolean func_150003_a(Block p_150003_0_)
{
return p_150003_0_ == ColorBlocks.Colorblocks_cl_bl_6_21 || p_150003_0_ == ColorBlocks.Colorblocks_cl_bl_14_21;
}
public abstract String func_150002_b(int p_150002_1_);
/**
* Get the block's damage value (for use with pick block).
*/
public int getDamageValue(World p_149643_1_, int p_149643_2_, int p_149643_3_, int p_149643_4_)
{
return super.getDamageValue(p_149643_1_, p_149643_2_, p_149643_3_, p_149643_4_) & 7;
}
/**
* Gets an item for the block being called on. Args: world, x, y, z
*/
@SideOnly(Side.CLIENT)
public Item getItem(World p_149694_1_, int p_149694_2_, int p_149694_3_, int p_149694_4_)
{
return func_150003_a(this) ? Item.getItemFromBlock(this) : (this == ColorBlocks.Colorblocks_cl_bl_6_21 ? Item.getItemFromBlock(ColorBlocks.Colorblocks_cl_bl_6_21) : (this == ColorBlocks.Colorblocks_cl_bl_14_21 ? Item.getItemFromBlock(ColorBlocks.Colorblocks_cl_bl_14_21) : Item.getItemFromBlock(rdt_1_rdt)));
}
}