use of com.mcmoddev.lib.registry.recipe.ICrusherRecipe in project BaseMetals by MinecraftModDevelopmentMods.
the class ItemMMDCrackHammer method onBlockDestroyed.
@Override
public boolean onBlockDestroyed(final ItemStack tool, final World world, final IBlockState target, final BlockPos coord, final EntityLivingBase player) {
if (!world.isRemote && this.canHarvestBlock(target)) {
IBlockState bs = world.getBlockState(coord);
ICrusherRecipe recipe = getCrusherRecipe(bs);
if (recipe != null) {
ItemStack output = recipe.getOutput().copy();
world.setBlockToAir(coord);
if (output != null) {
int num = output.getCount();
output.setCount(1);
for (int i = 0; i < num; i++) {
world.spawnEntity(new EntityItem(world, coord.getX() + 0.5, coord.getY() + 0.5, coord.getZ() + 0.5, output.copy()));
}
}
}
}
return super.onBlockDestroyed(tool, world, target, coord, player);
}
use of com.mcmoddev.lib.registry.recipe.ICrusherRecipe in project BaseMetals by MinecraftModDevelopmentMods.
the class ModelDataFix method crusherRecipeRegistryFix.
@SubscribeEvent
public static void crusherRecipeRegistryFix(RegistryEvent.MissingMappings<ICrusherRecipe> ev) {
ev.getAllMappings().stream().filter(mapping -> mapping.key.getNamespace().equalsIgnoreCase(MMDLib.MODID)).forEach(mapping -> {
ResourceLocation remap = new ResourceLocation(BaseMetals.MODID, mapping.key.getPath());
ICrusherRecipe recipeRemap = CrusherRecipeRegistry.getInstance().getRegistry().getValue(remap);
if (recipeRemap != null) {
mapping.remap(recipeRemap);
}
});
}
use of com.mcmoddev.lib.registry.recipe.ICrusherRecipe in project BaseMetals by MinecraftModDevelopmentMods.
the class ItemMMDCrackHammer method onItemUse.
@Override
public EnumActionResult onItemUse(final EntityPlayer player, final World w, final BlockPos coord, final EnumHand hand, final EnumFacing facing, final float partialX, final float partialY, final float partialZ) {
final ItemStack item = player.getHeldItemMainhand();
if (facing != EnumFacing.UP) {
return EnumActionResult.PASS;
}
/*List<EntityItem> entities = */
AxisAlignedBB boundingBox = new AxisAlignedBB(coord.getX(), coord.getY() + 1, coord.getZ(), coord.getX() + 1, coord.getY() + 2, coord.getZ() + 1);
List<EntityItem> entities = w.getEntitiesWithinAABB(EntityItem.class, boundingBox).stream().filter(elem -> (elem.getItem() != null)).filter(elem -> (CrusherRecipeRegistry.getRecipeForInputItem(elem.getItem()) != null)).collect(Collectors.toList());
if (!entities.isEmpty()) {
ItemStack targetItem = entities.get(0).getItem();
ICrusherRecipe recipe = CrusherRecipeRegistry.getRecipeForInputItem(targetItem);
if (hardnessCheck(targetItem)) {
return EnumActionResult.PASS;
}
maybeDoCrack(recipe, targetItem, item, entities.get(0), player, w);
w.playSound(player, coord, SoundEvents.BLOCK_GRAVEL_BREAK, SoundCategory.BLOCKS, 0.5F, 0.5F + (itemRand.nextFloat() * 0.3F));
return EnumActionResult.SUCCESS;
}
return EnumActionResult.PASS;
}
Aggregations