Last active
August 26, 2019 01:14
-
-
Save alcatrazEscapee/d86148ba3d9af480c810da482fc8102d to your computer and use it in GitHub Desktop.
Fix spacing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Nullable | |
IBlockState findSlabVariant(World world, BlockPos pos, IBlockState stateIn) | |
{ | |
ItemStack stackIn = stateIn.getBlock().getPickBlock(stateIn, null, world, pos, null); | |
if (!stackIn.isEmpty()) | |
{ | |
// Slab inventory shape | |
InventoryCrafting craftMatrix = new InventoryCraftingEmpty(); | |
// todo: figure out which index positions match to a slab pattern | |
for (int index : SLAB_INDEXES) | |
{ | |
craftMatrix.setInventorySlotContents(index, stackIn.copy()); | |
} | |
for (IRecipe recipe : ForgeRegistries.RECIPES.getValuesCollection()) | |
{ | |
if (recipe.matches(craftMatrix, world)) | |
{ | |
// Found matching recipe, try and extract a slab block | |
ItemStack stackOut = recipe.getCraftingResult(craftMatrix); | |
if (stackOut.getItem() instanceof ItemBlock) | |
{ | |
Block blockOut = ((ItemBlock) stackOut.getItem()).getBlock(); | |
if (blockOut instanceof BlockSlab) | |
{ | |
return blockOut.getDefaultState(); | |
} | |
} | |
// Don't continue searching recipes | |
return null; | |
} | |
} | |
} | |
return null; | |
} | |
@Nullable | |
IBlockState findStairVariant(World world, BlockPos pos, IBlockState stateIn) | |
{ | |
ItemStack stackIn = stateIn.getBlock().getPickBlock(stateIn, null, world, pos, null); | |
if (!stackIn.isEmpty()) | |
{ | |
// Slab inventory shape | |
InventoryCrafting craftMatrix = new InventoryCraftingEmpty(); | |
// todo: figure out which index positions match to a stair pattern | |
for (int index : STAIR_INDEXES) | |
{ | |
craftMatrix.setInventorySlotContents(index, stackIn.copy()); | |
} | |
for (IRecipe recipe : ForgeRegistries.RECIPES.getValuesCollection()) | |
{ | |
if (recipe.matches(craftMatrix, world)) | |
{ | |
// Found matching recipe, try and extract a slab block | |
ItemStack stackOut = recipe.getCraftingResult(craftMatrix); | |
if (stackOut.getItem() instanceof ItemBlock) | |
{ | |
Block blockOut = ((ItemBlock) stackOut.getItem()).getBlock(); | |
if (blockOut instanceof BlockStairs) | |
{ | |
return blockOut.getDefaultState(); | |
} | |
} | |
return null; | |
} | |
} | |
} | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment