2022-12-27 10:59:46 -08:00
|
|
|
package net.minecraft.block;
|
|
|
|
|
2023-01-11 20:06:59 -08:00
|
|
|
import java.util.List;
|
2022-12-27 10:59:46 -08:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
2023-01-11 20:06:59 -08:00
|
|
|
import net.minecraft.block.properties.IProperty;
|
2022-12-27 10:59:46 -08:00
|
|
|
import net.minecraft.block.properties.PropertyEnum;
|
|
|
|
import net.minecraft.block.properties.PropertyInteger;
|
|
|
|
import net.minecraft.block.state.BlockState;
|
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.util.BlockPos;
|
|
|
|
import net.minecraft.util.StatCollector;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* This portion of EaglercraftX contains deobfuscated Minecraft 1.8 source code.
|
2023-01-14 07:56:36 -08:00
|
|
|
*
|
2022-12-27 10:59:46 -08:00
|
|
|
* Minecraft 1.8.8 bytecode is (c) 2015 Mojang AB. "Do not distribute!"
|
|
|
|
* Mod Coder Pack v9.18 deobfuscation configs are (c) Copyright by the MCP Team
|
2023-01-14 07:56:36 -08:00
|
|
|
*
|
2023-01-11 20:06:59 -08:00
|
|
|
* EaglercraftX 1.8 patch files are (c) 2022-2023 LAX1DUDE. All Rights Reserved.
|
2023-01-14 07:56:36 -08:00
|
|
|
*
|
2022-12-27 10:59:46 -08:00
|
|
|
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
|
|
|
|
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
|
|
|
|
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
|
|
|
|
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
|
2023-01-14 07:56:36 -08:00
|
|
|
*
|
2022-12-27 10:59:46 -08:00
|
|
|
* NOT FOR COMMERCIAL OR MALICIOUS USE
|
2023-01-14 07:56:36 -08:00
|
|
|
*
|
|
|
|
* (please read the 'LICENSE' file this repo's root directory for more info)
|
|
|
|
*
|
2022-12-27 10:59:46 -08:00
|
|
|
*/
|
|
|
|
public class BlockSapling extends BlockBush implements IGrowable {
|
2023-01-14 07:56:36 -08:00
|
|
|
|
|
|
|
public static PropertyEnum<BlockPlanks.EnumType> TYPE;
|
|
|
|
public static final PropertyInteger STAGE = PropertyInteger.create("stage", 0, 1);
|
|
|
|
|
|
|
|
protected BlockSapling() {
|
|
|
|
this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, BlockPlanks.EnumType.OAK).withProperty(STAGE, Integer.valueOf(0)));
|
|
|
|
float f = 0.4F;
|
|
|
|
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 2.0F, 0.5F + f);
|
|
|
|
this.setCreativeTab(CreativeTabs.tabDecorations);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void bootstrapStates() {
|
|
|
|
TYPE = PropertyEnum.<BlockPlanks.EnumType>create("type", BlockPlanks.EnumType.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Gets the localized name of this block. Used for the
|
|
|
|
* statistics page.
|
|
|
|
*/
|
|
|
|
public String getLocalizedName() {
|
|
|
|
return StatCollector.translateToLocal(this.getUnlocalizedName() + "." + BlockPlanks.EnumType.OAK.getUnlocalizedName() + ".name");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void updateTick(World world, BlockPos blockpos, IBlockState iblockstate, EaglercraftRandom random) {}
|
|
|
|
|
|
|
|
private boolean func_181624_a(World parWorld, BlockPos parBlockPos, int parInt1, int parInt2, BlockPlanks.EnumType parEnumType) {
|
|
|
|
return this.isTypeAt(parWorld, parBlockPos.add(parInt1, 0, parInt2), parEnumType) && this.isTypeAt(parWorld, parBlockPos.add(parInt1 + 1, 0, parInt2), parEnumType) && this.isTypeAt(parWorld, parBlockPos.add(parInt1, 0, parInt2 + 1), parEnumType) && this.isTypeAt(parWorld, parBlockPos.add(parInt1 + 1, 0, parInt2 + 1), parEnumType);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Check whether the given BlockPos has a Sapling of the given
|
|
|
|
* type
|
|
|
|
*/
|
|
|
|
public boolean isTypeAt(World worldIn, BlockPos pos, BlockPlanks.EnumType type) {
|
|
|
|
IBlockState iblockstate = worldIn.getBlockState(pos);
|
|
|
|
return iblockstate.getBlock() == this && iblockstate.getValue(TYPE) == type;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Gets the metadata of the item this Block can drop. This
|
|
|
|
* method is called when the block gets destroyed. It returns
|
|
|
|
* the metadata of the dropped item based on the old metadata of
|
|
|
|
* the block.
|
|
|
|
*/
|
|
|
|
public int damageDropped(IBlockState iblockstate) {
|
|
|
|
return ((BlockPlanks.EnumType) iblockstate.getValue(TYPE)).getMetadata();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* returns a list of blocks with the same ID, but different meta
|
|
|
|
* (eg: wood returns 4 blocks)
|
|
|
|
*/
|
|
|
|
public void getSubBlocks(Item item, CreativeTabs var2, List<ItemStack> list) {
|
|
|
|
for (BlockPlanks.EnumType blockplanks$enumtype : BlockPlanks.EnumType.values()) {
|
|
|
|
list.add(new ItemStack(item, 1, blockplanks$enumtype.getMetadata()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Whether this IGrowable can grow
|
|
|
|
*/
|
|
|
|
public boolean canGrow(World var1, BlockPos var2, IBlockState var3, boolean var4) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canUseBonemeal(World world, EaglercraftRandom var2, BlockPos var3, IBlockState var4) {
|
|
|
|
return (double) world.rand.nextFloat() < 0.45D;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Convert the given metadata into a BlockState for this Block
|
|
|
|
*/
|
|
|
|
public IBlockState getStateFromMeta(int i) {
|
|
|
|
return this.getDefaultState().withProperty(TYPE, BlockPlanks.EnumType.byMetadata(i & 7)).withProperty(STAGE, Integer.valueOf((i & 8) >> 3));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**+
|
|
|
|
* Convert the BlockState into the correct metadata value
|
|
|
|
*/
|
|
|
|
public int getMetaFromState(IBlockState iblockstate) {
|
|
|
|
int i = 0;
|
|
|
|
i = i | ((BlockPlanks.EnumType) iblockstate.getValue(TYPE)).getMetadata();
|
|
|
|
i = i | ((Integer) iblockstate.getValue(STAGE)).intValue() << 3;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected BlockState createBlockState() {
|
|
|
|
return new BlockState(this, new IProperty[] { TYPE, STAGE });
|
|
|
|
}
|
|
|
|
}
|