2017-02-23 13:29:43 +01:00
|
|
|
/*
|
|
|
|
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
|
|
|
*
|
|
|
|
* Copyright (c) 2017 TechReborn
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
* SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
2016-02-20 01:55:18 +01:00
|
|
|
package techreborn.blocks;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockLeaves;
|
|
|
|
import net.minecraft.block.BlockPlanks;
|
|
|
|
import net.minecraft.block.properties.IProperty;
|
2016-03-13 17:08:30 +01:00
|
|
|
import net.minecraft.block.state.BlockStateContainer;
|
2016-02-20 01:55:18 +01:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
|
|
|
import net.minecraft.init.Blocks;
|
2016-02-20 20:46:18 +01:00
|
|
|
import net.minecraft.item.Item;
|
2016-02-20 01:55:18 +01:00
|
|
|
import net.minecraft.item.ItemStack;
|
2016-03-13 19:38:41 +01:00
|
|
|
import net.minecraft.util.BlockRenderLayer;
|
2017-06-20 23:13:47 +02:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2016-03-15 09:13:05 +01:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-02-20 01:55:18 +01:00
|
|
|
import net.minecraft.world.IBlockAccess;
|
|
|
|
import net.minecraftforge.fml.relauncher.Side;
|
|
|
|
import net.minecraftforge.fml.relauncher.SideOnly;
|
2017-06-14 17:56:09 +02:00
|
|
|
import prospector.shootingstar.ShootingStar;
|
|
|
|
import prospector.shootingstar.model.ModelCompound;
|
2016-02-20 01:55:18 +01:00
|
|
|
import techreborn.client.TechRebornCreativeTabMisc;
|
2016-02-20 20:46:18 +01:00
|
|
|
import techreborn.init.ModBlocks;
|
2017-06-14 17:56:09 +02:00
|
|
|
import techreborn.lib.ModInfo;
|
2016-02-20 01:55:18 +01:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
import java.util.List;
|
|
|
|
import java.util.Random;
|
|
|
|
|
2017-06-14 01:49:52 +02:00
|
|
|
public class BlockRubberLeaves extends BlockLeaves {
|
2016-02-20 01:55:18 +01:00
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public BlockRubberLeaves() {
|
2016-07-19 06:37:02 +02:00
|
|
|
super();
|
2016-02-20 01:55:18 +01:00
|
|
|
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
2016-04-03 15:34:39 +02:00
|
|
|
this.setDefaultState(this.getDefaultState().withProperty(CHECK_DECAY, true)
|
2016-10-08 21:46:16 +02:00
|
|
|
.withProperty(DECAYABLE, true));
|
|
|
|
Blocks.FIRE.setFireInfo(this, 30, 60);
|
2017-06-16 16:32:11 +02:00
|
|
|
ShootingStar.registerModel(new ModelCompound(ModInfo.MOD_ID, this, CHECK_DECAY, DECAYABLE));
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public BlockPlanks.EnumType getWoodType(int meta) {
|
2016-02-20 01:55:18 +01:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public List<ItemStack> onSheared(ItemStack item, IBlockAccess world, BlockPos pos, int fortune) {
|
2016-04-03 15:34:39 +02:00
|
|
|
List<ItemStack> list = new java.util.ArrayList<>();
|
2016-02-20 01:55:18 +01:00
|
|
|
list.add(new ItemStack(this, 1, 0));
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public BlockRenderLayer getBlockLayer() {
|
2016-04-23 14:05:39 +02:00
|
|
|
return BlockRenderLayer.CUTOUT_MIPPED;
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public boolean isOpaqueCube(IBlockState state) {
|
2016-04-23 14:05:39 +02:00
|
|
|
return false;
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
2016-10-08 21:46:16 +02:00
|
|
|
public boolean isFullCube() {
|
2016-02-20 20:46:18 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2016-02-20 01:55:18 +01:00
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
protected BlockStateContainer createBlockState() {
|
2016-03-25 10:47:34 +01:00
|
|
|
return new BlockStateContainer(this, new IProperty[] { CHECK_DECAY, DECAYABLE });
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public IBlockState getStateFromMeta(int meta) {
|
2016-04-03 15:34:39 +02:00
|
|
|
return this.getDefaultState().withProperty(DECAYABLE, (meta & 1) == 0)
|
2016-10-08 21:46:16 +02:00
|
|
|
.withProperty(CHECK_DECAY, (meta & 2) > 0);
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|
2016-03-25 10:47:34 +01:00
|
|
|
|
2016-02-20 01:55:18 +01:00
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public int getMetaFromState(IBlockState state) {
|
2016-02-20 01:55:18 +01:00
|
|
|
int meta = 0;
|
2016-10-08 21:46:16 +02:00
|
|
|
if (!(Boolean) state.getValue(DECAYABLE)) {
|
2016-02-20 01:55:18 +01:00
|
|
|
meta |= 1;
|
|
|
|
}
|
2016-10-08 21:46:16 +02:00
|
|
|
if ((Boolean) state.getValue(CHECK_DECAY)) {
|
2016-02-20 01:55:18 +01:00
|
|
|
meta |= 2;
|
|
|
|
}
|
|
|
|
return meta;
|
|
|
|
}
|
2016-02-20 11:58:58 +01:00
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-10-08 21:46:16 +02:00
|
|
|
public int getBlockColor() {
|
2016-02-20 11:58:58 +01:00
|
|
|
return 16777215;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-10-08 21:46:16 +02:00
|
|
|
public int getRenderColor(IBlockState state) {
|
2016-02-20 11:58:58 +01:00
|
|
|
return 16777215;
|
|
|
|
}
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2016-10-08 21:46:16 +02:00
|
|
|
public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass) {
|
2016-02-20 11:58:58 +01:00
|
|
|
return 16777215;
|
|
|
|
}
|
2016-02-20 20:46:18 +01:00
|
|
|
|
|
|
|
@Override
|
2016-10-08 21:46:16 +02:00
|
|
|
public Item getItemDropped(IBlockState state, Random rand, int fortune) {
|
2017-01-01 08:29:32 +01:00
|
|
|
return Item.getItemFromBlock(ModBlocks.RUBBER_SAPLING);
|
2016-02-20 20:46:18 +01:00
|
|
|
}
|
2017-06-20 23:13:47 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
|
|
|
|
return true;
|
|
|
|
}
|
2016-02-20 01:55:18 +01:00
|
|
|
}
|