TechReborn/src/main/java/techreborn/blocks/BlockRubberLeaves.java

153 lines
4.5 KiB
Java
Raw Normal View History

/*
* 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;
2016-02-20 20:59:09 +01:00
import me.modmuss50.jsonDestroyer.api.IOpaqueBlock;
2016-02-20 01:55:18 +01:00
import me.modmuss50.jsonDestroyer.api.ITexturedBlock;
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;
2016-02-20 01:55:18 +01: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;
import reborncore.RebornCore;
import techreborn.client.TechRebornCreativeTabMisc;
2016-02-20 20:46:18 +01:00
import techreborn.init.ModBlocks;
2016-02-20 01:55:18 +01:00
2016-10-08 21:46:16 +02:00
import java.util.List;
import java.util.Random;
2016-02-20 01:55:18 +01:00
/**
2016-03-07 21:33:08 +01:00
* Created by modmuss50 on 20/02/2016.
2016-02-20 01:55:18 +01:00
*/
2016-10-08 21:46:16 +02:00
public class BlockRubberLeaves extends BlockLeaves implements ITexturedBlock, IOpaqueBlock {
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
setUnlocalizedName("techreborn.rubberleaves");
setCreativeTab(TechRebornCreativeTabMisc.instance);
RebornCore.jsonDestroyer.registerObject(this);
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);
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) {
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;
}
//TODO 1.11: what is this?
2016-11-25 14:25:51 +01:00
// @Override
// protected ItemStack createStackedBlock(IBlockState state) {
// IBlockState newState = state.withProperty(CHECK_DECAY, false).withProperty(DECAYABLE,
// false);
//
// return super.createStackedBlock(newState);
// }
2016-02-20 01:55:18 +01:00
@Override
2016-10-08 21:46:16 +02:00
public String getTextureNameFromState(IBlockState IBlockState, EnumFacing enumFacing) {
2016-02-20 01:55:18 +01:00
return "techreborn:blocks/rubber_leaves";
}
@Override
2016-10-08 21:46:16 +02:00
public int amountOfStates() {
2016-02-20 01:55:18 +01:00
return 4;
}
@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) {
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) {
return Item.getItemFromBlock(ModBlocks.RUBBER_SAPLING);
2016-02-20 20:46:18 +01:00
}
2016-02-20 01:55:18 +01:00
}