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);
}
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);
}
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));
}
}
Aggregations