Search in sources :

Example 1 with PackingRecipe

use of betterwithaddons.crafting.recipes.PackingRecipe in project BetterWithAddons by DaedalusGame.

the class HardcorePackingHandler method hardcorePackingCompress.

@SubscribeEvent
public void hardcorePackingCompress(TickEvent.WorldTickEvent event) {
    if (event.world == null || event.world.isRemote)
        return;
    HashSet<TileEntityPiston> toIterate = new HashSet<>(activePistons);
    HashSet<TileEntityPiston> toRemove = new HashSet<>();
    for (TileEntityPiston piston : toIterate) {
        World world = piston.getWorld();
        toRemove.add(piston);
        if (world != null && !world.isRemote && piston != null && piston.isExtending()) {
            BlockPos pos = piston.getPos();
            EnumFacing facing = piston.getFacing();
            BlockPos shovePos = piston.getPos();
            IBlockState shoveState = piston.getPistonState();
            BlockPos compressPos = shovePos.offset(facing);
            IBlockState compressState = world.getBlockState(compressPos);
            if (isEmpty(world, compressPos, compressState) && isSurrounded(world, compressPos, facing.getOpposite())) {
                AxisAlignedBB blockMask = new AxisAlignedBB(shovePos).union(new AxisAlignedBB(compressPos));
                List<EntityItem> items = world.getEntitiesWithinAABB(EntityItem.class, blockMask);
                PackingRecipe recipe = CraftingManagerPacking.getInstance().getMostValidRecipe(compressState, items);
                if (recipe != null && recipe.consumeIngredients(items)) {
                    world.setBlockState(compressPos, recipe.getOutput(compressState, items));
                }
            }
        }
    }
    activePistons.removeAll(toRemove);
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TileEntityPiston(net.minecraft.tileentity.TileEntityPiston) PackingRecipe(betterwithaddons.crafting.recipes.PackingRecipe) IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) EntityItem(net.minecraft.entity.item.EntityItem) HashSet(java.util.HashSet) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 2 with PackingRecipe

use of betterwithaddons.crafting.recipes.PackingRecipe in project BetterWithAddons by DaedalusGame.

the class CraftingManagerPacking method addRecipe.

public void addRecipe(IBlockState output, ItemStack jeiOutput, Ingredient input) {
    PackingRecipe recipe = createRecipe(output, input);
    recipe.setJeiOutput(jeiOutput);
    recipes.add(recipe);
}
Also used : PackingRecipe(betterwithaddons.crafting.recipes.PackingRecipe)

Example 3 with PackingRecipe

use of betterwithaddons.crafting.recipes.PackingRecipe in project BetterWithAddons by DaedalusGame.

the class Packing method add.

@ZenMethod
public static void add(IItemStack output, IIngredient input) {
    ItemStack stack = CraftTweakerMC.getItemStack(output);
    if (stack.getItem() instanceof ItemBlock) {
        Block block = ((ItemBlock) stack.getItem()).getBlock();
        PackingRecipe r = new PackingRecipe(new IngredientCraftTweaker(input), block.getStateFromMeta(stack.getMetadata()));
        r.setJeiOutput(stack);
        CraftTweaker.LATE_ACTIONS.add(new Add(r));
    }
}
Also used : PackingRecipe(betterwithaddons.crafting.recipes.PackingRecipe) Block(net.minecraft.block.Block) ItemBlock(net.minecraft.item.ItemBlock) IngredientCraftTweaker(betterwithaddons.util.IngredientCraftTweaker) ItemStack(net.minecraft.item.ItemStack) IItemStack(crafttweaker.api.item.IItemStack) ItemBlock(net.minecraft.item.ItemBlock) ZenMethod(stanhebben.zenscript.annotations.ZenMethod)

Aggregations

PackingRecipe (betterwithaddons.crafting.recipes.PackingRecipe)3 IngredientCraftTweaker (betterwithaddons.util.IngredientCraftTweaker)1 IItemStack (crafttweaker.api.item.IItemStack)1 HashSet (java.util.HashSet)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityItem (net.minecraft.entity.item.EntityItem)1 ItemBlock (net.minecraft.item.ItemBlock)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntityPiston (net.minecraft.tileentity.TileEntityPiston)1 EnumFacing (net.minecraft.util.EnumFacing)1 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)1 BlockPos (net.minecraft.util.math.BlockPos)1 World (net.minecraft.world.World)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 ZenMethod (stanhebben.zenscript.annotations.ZenMethod)1