Search in sources :

Example 1 with UniversalBucket

use of net.minecraftforge.fluids.UniversalBucket in project RFTools by McJty.

the class SensorTileEntity method checkFluid.

private boolean checkFluid(BlockPos newpos) {
    IBlockState state = getWorld().getBlockState(newpos);
    ItemStack matcher = inventoryHelper.getStackInSlot(0);
    Block block = state.getBlock();
    if (matcher.isEmpty()) {
        if (block instanceof BlockLiquid || block instanceof IFluidBlock) {
            return !block.isAir(state, getWorld(), newpos);
        }
        return false;
    }
    ItemStack stack = block.getItem(getWorld(), newpos, state);
    Item matcherItem = matcher.getItem();
    FluidStack matcherFluidStack = null;
    // }
    if (matcherItem instanceof ItemBucket || matcherItem instanceof UniversalBucket) {
        matcherFluidStack = new FluidBucketWrapper(matcher).getFluid();
        return checkFluid(block, matcherFluidStack, state, newpos);
    }
    return false;
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) FluidBucketWrapper(net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper) Item(net.minecraft.item.Item) IBlockState(net.minecraft.block.state.IBlockState) BlockLiquid(net.minecraft.block.BlockLiquid) FluidStack(net.minecraftforge.fluids.FluidStack) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) Block(net.minecraft.block.Block) IFluidBlock(net.minecraftforge.fluids.IFluidBlock) ItemStack(net.minecraft.item.ItemStack) ItemBucket(net.minecraft.item.ItemBucket)

Example 2 with UniversalBucket

use of net.minecraftforge.fluids.UniversalBucket in project ImmersiveEngineering by BluSunrize.

the class RecipeShapelessIngredient method getRemainingItems.

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
    NonNullList<ItemStack> remains = super.getRemainingItems(inv);
    for (int i = 0; i < remains.size(); i++) {
        ItemStack s = inv.getStackInSlot(i);
        ItemStack remain = remains.get(i);
        if (toolDamageSlot >= 0 && toolDamageSlot < getIngredients().size()) {
            ItemStack tool = ItemStack.EMPTY;
            if (remain.isEmpty() && !s.isEmpty() && getIngredients().get(toolDamageSlot).apply(s))
                tool = s.copy();
            else if (!remain.isEmpty() && getIngredients().get(toolDamageSlot).apply(remain))
                tool = remain;
            if (!tool.isEmpty() && tool.isItemStackDamageable()) {
                tool.setItemDamage(tool.getItemDamage() + 1);
                if (tool.getItemDamage() > tool.getMaxDamage())
                    tool = ItemStack.EMPTY;
                remains.set(i, tool);
            }
        }
        if (!s.isEmpty() && remain.isEmpty() && s.getItem() instanceof UniversalBucket) {
            ItemStack empty = ((UniversalBucket) s.getItem()).getEmpty();
            if (!empty.isEmpty())
                remains.set(i, empty.copy());
        }
    }
    return remains;
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) ItemStack(net.minecraft.item.ItemStack)

Example 3 with UniversalBucket

use of net.minecraftforge.fluids.UniversalBucket in project MinecraftForge by MinecraftForge.

the class ForgeModContainer method preInit.

@Subscribe
public void preInit(FMLPreInitializationEvent evt) {
    CapabilityItemHandler.register();
    CapabilityFluidHandler.register();
    CapabilityAnimation.register();
    CapabilityEnergy.register();
    MinecraftForge.EVENT_BUS.register(MinecraftForge.INTERNAL_HANDLER);
    ForgeChunkManager.captureConfig(evt.getModConfigurationDirectory());
    MinecraftForge.EVENT_BUS.register(this);
    if (!ForgeModContainer.disableVersionCheck) {
        ForgeVersion.startVersionCheck();
    }
    // Add and register the forge universal bucket, if it's enabled
    if (FluidRegistry.isUniversalBucketEnabled()) {
        universalBucket = new UniversalBucket();
        universalBucket.setUnlocalizedName("forge.bucketFilled");
        GameRegistry.register(universalBucket.setRegistryName(ForgeVersion.MOD_ID, "bucketFilled"));
        MinecraftForge.EVENT_BUS.register(universalBucket);
    }
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) Subscribe(com.google.common.eventbus.Subscribe)

Example 4 with UniversalBucket

use of net.minecraftforge.fluids.UniversalBucket in project Wizardry by TeamWizardry.

the class RecipeShapelessFluid method getRemainingItems.

@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
    NonNullList<ItemStack> remains = super.getRemainingItems(inv);
    for (int i = 0; i < remains.size(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        ItemStack remain = remains.get(i);
        if (!stack.isEmpty() && remain.isEmpty() && stack.getItem() instanceof UniversalBucket) {
            ItemStack empty = ((UniversalBucket) stack.getItem()).getEmpty();
            if (!empty.isEmpty())
                remains.set(i, empty.copy());
        }
    }
    return remains;
}
Also used : UniversalBucket(net.minecraftforge.fluids.UniversalBucket) ItemStack(net.minecraft.item.ItemStack)

Aggregations

UniversalBucket (net.minecraftforge.fluids.UniversalBucket)4 ItemStack (net.minecraft.item.ItemStack)3 Subscribe (com.google.common.eventbus.Subscribe)1 Block (net.minecraft.block.Block)1 BlockLiquid (net.minecraft.block.BlockLiquid)1 IBlockState (net.minecraft.block.state.IBlockState)1 Item (net.minecraft.item.Item)1 ItemBucket (net.minecraft.item.ItemBucket)1 FluidStack (net.minecraftforge.fluids.FluidStack)1 IFluidBlock (net.minecraftforge.fluids.IFluidBlock)1 FluidBucketWrapper (net.minecraftforge.fluids.capability.wrappers.FluidBucketWrapper)1