null handling for BasicBlockType.get

(cherry picked from commit 37576936e187e9ba347538bed1cc35765b226c5f)
This commit is contained in:
Xander Victory committed 2017-10-03 09:23:35 +08:00
1 parent 55a036f78a
commit 8446e1e1b4
2 files changed
+8 -2

No files matched your search

@@ -40,6 +40,8 @@ import net.minecraftforge.common.property.IUnlistedProperty;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import javax.annotation.Nullable;
public class BlockStateBasic extends ExtendedBlockState
{
public static final PropertyBool activeProperty = PropertyBool.create("active");
@@ -134,6 +136,7 @@ public class BlockStateBasic extends ExtendedBlockState
isBeaconBase = beaconBase;
}
@Nullable
public static BasicBlockType get(IBlockState state)
{
if(state.getBlock() instanceof BlockBasic)
@@ -144,11 +147,13 @@ public class BlockStateBasic extends ExtendedBlockState
return null;
}
@Nullable
public static BasicBlockType get(ItemStack stack)
{
return get(Block.getBlockFromItem(stack.getItem()), stack.getItemDamage());
}
@Nullable
public static BasicBlockType get(Block block, int meta)
{
if(block instanceof BlockBasic)
@@ -159,6 +164,7 @@ public class BlockStateBasic extends ExtendedBlockState
return null;
}
@Nullable
public static BasicBlockType get(BasicBlock blockType, int metadata)
{
BasicBlockType firstTry = values()[blockType.ordinal() << 4 | metadata];