Skip to content

Commit

Permalink
Finish leaf fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruling-0 committed Jan 20, 2025
1 parent 1abe1f2 commit 19821a8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 37 deletions.
11 changes: 6 additions & 5 deletions src/main/java/mods/natura/blocks/trees/NLeaves.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ public void registerBlockIcons(IIconRegister iconRegister) {
}
}

@Override
public int getDamageValue(World worldIn, int x, int y, int z) {
return worldIn.getBlockMetadata(x, y, z) & 3;
}

/**
* 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
Expand All @@ -122,13 +127,9 @@ public void getSubBlocks(Item par1, CreativeTabs par2CreativeTabs, List par3List
par3List.add(new ItemStack(par1, 1, 2));
}

public int getDamageValue(World par1World, int par2, int par3, int par4) {
return this.damageDropped(par1World.getBlockMetadata(par2, par3, par4)) % 3;
}

@Override
public int getLightOpacity(IBlockAccess world, int x, int y, int z) {
if (world.getBlockMetadata(x, y, z) % 4 == 0) {
if ((world.getBlockMetadata(x, y, z) & 3) == 0) {
return 255;
}
return super.getLightOpacity(world, x, y, z);
Expand Down
20 changes: 13 additions & 7 deletions src/main/java/mods/natura/blocks/trees/NLeavesDark.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,27 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, in
}

@Override
public Item getItemDropped(int metadata, Random random, int fortune) {
if (metadata % 4 == 2) return NContent.potashApple;
public Item getItemDropped(int meta, Random random, int fortune) {
if ((meta & 3) == 2) return NContent.potashApple;
return Item.getItemFromBlock(NContent.floraSapling);
}

@Override
public int damageDropped(int par1) {
if (par1 % 4 == 2) return 0;
if (par1 % 4 == 3) return 7;
return 6;
public int damageDropped(int meta) {
meta = meta & 3;
switch (meta) {
case 2:
return 0;
case 3:
return 7;
default:
return 6;
}
}

@Override
public int quantityDropped(int meta, int fortune, Random random) {
if (meta % 4 == 2) return 1;
if ((meta & 3) == 2) return 1;
return quantityDroppedWithBonus(fortune, random);
}

Expand Down
34 changes: 14 additions & 20 deletions src/main/java/mods/natura/blocks/trees/NLeavesNocolor.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,22 +51,17 @@ public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, in
return 16777215;
}

public int damageDropped(int meta) {
if (meta % 4 == 3) return 4;
return (meta & 3) + 3;
}

@Override
public Item getItemDropped(int meta, Random random, int fortune) {
if (meta % 4 == 3) return Item.getItemFromBlock(NContent.rareSapling);
if ((meta & 3) == 3) return Item.getItemFromBlock(NContent.rareSapling);
return Item.getItemFromBlock(NContent.floraSapling);
}

@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune);
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int meta, int fortune) {
ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, meta, fortune);

if (metadata % 4 == 2) {
if ((meta & 3) == 2) {
if (fortune > 3 || Natura.random.nextInt(40 - fortune * 10) == 0) {
ret.add(new ItemStack(Items.redstone));
}
Expand All @@ -75,27 +70,26 @@ public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metad
return ret;
}

@Override
public int damageDropped(int meta) {
if ((meta & 3) == 3) return 4;
return super.damageDropped(meta) + 3;
}

@Override
public int getFlammability(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 1 || metadata == 2) return 0;
int meta = world.getBlockMetadata(x, y, z) & 3;
if (meta == 1 || meta == 2) return 0;
return Blocks.fire.getFlammability(this);
}

@Override
public int getFireSpreadSpeed(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 1 || metadata == 2) return 0;
int meta = world.getBlockMetadata(x, y, z) & 3;
if (meta == 1 || meta == 2) return 0;
return Blocks.fire.getEncouragement(this);
}

@Override
public boolean isFlammable(IBlockAccess world, int x, int y, int z, ForgeDirection face) {
int metadata = world.getBlockMetadata(x, y, z);
if (metadata == 1 || metadata == 2) return false;
return getFlammability(world, x, y, z, face) > 0;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ public OverworldLeavesItem(Block i) {
setHasSubtypes(true);
}

/*
* @Override public String getUnlocalizedName (ItemStack itemstack) { int i =
* MathHelper.clamp_int(itemstack.getItemDamage(), 0, 3); return (new
* StringBuilder()).append("block.leaves.").append(blockType[i]).toString(); }
*/
@Override
public int getMetadata(int meta) {
return meta | 4;
}

@Override
@SideOnly(Side.CLIENT)
Expand Down

0 comments on commit 19821a8

Please sign in to comment.