@Override public void loadCraftingRecipes(ItemStack result) { if (Utils.isFluidBlock(result)) { super.loadCraftingRecipes(result); } if (Config.handlerFluidRegistry) { for (Fluid fluid : this.getFluids()) { CachedFluidRegistryRecipe crecipe = new CachedFluidRegistryRecipe(fluid); if (crecipe.filledContainer != null && crecipe.filledContainer.contains(result)) { crecipe.setPermutation(crecipe.filledContainer, result); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (Utils.areStacksSameTypeCraftingSafe(data.filledContainer, result)) { crecipe.setPermutation(crecipe.emptyContainer, data.emptyContainer); } } this.arecipes.add(crecipe); } } } }
@Override public void loadUsageRecipes(ItemStack ingredient) { super.loadUsageRecipes(ingredient); if (Config.handlerFluidRegistry) { for (Fluid fluid : this.getFluids()) { CachedFluidRegistryRecipe crecipe = new CachedFluidRegistryRecipe(fluid); if (crecipe.emptyContainer != null && crecipe.emptyContainer.contains(ingredient)) { crecipe.setPermutation(crecipe.emptyContainer, ingredient); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (Utils.areStacksSameTypeCraftingSafe(data.emptyContainer, ingredient)) { crecipe.setPermutation(crecipe.filledContainer, data.filledContainer); } } this.arecipes.add(crecipe); } } } }
@Override public List<ItemStack> getInputs() { List<ItemStack> ret = new ArrayList<ItemStack>(); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); } ret.add(IC2Items.getItem("fluid_cell", fluid.getName())); return ret; }
@Override public void preInit(FMLPreInitializationEvent event) { playerHandler = new AsteroidsPlayerHandler(); MinecraftForge.EVENT_BUS.register(playerHandler); FMLCommonHandler.instance().bus().register(playerHandler); AsteroidsEventHandler eventHandler = new AsteroidsEventHandler(); MinecraftForge.EVENT_BUS.register(eventHandler); FMLCommonHandler.instance().bus().register(eventHandler); RecipeSorter.register("galacticraftmars:canisterRecipe", CanisterRecipes.class, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless"); AsteroidsModule.fluidMethaneGas = registerFluid("methane", 1, 11, 295, true); AsteroidsModule.fluidAtmosphericGases = registerFluid("atmosphericgases", 1, 13, 295, true); AsteroidsModule.fluidLiquidMethane = registerFluid("liquidmethane", 450, 120, 109, false); //Data source for liquid methane: http://science.nasa.gov/science-news/science-at-nasa/2005/25feb_titan2/ AsteroidsModule.fluidLiquidOxygen = registerFluid("liquidoxygen", 1141, 140, 90, false); AsteroidsModule.fluidOxygenGas = registerFluid("oxygen", 1, 13, 295, true); AsteroidsModule.fluidLiquidNitrogen = registerFluid("liquidnitrogen", 808, 130, 90, false); AsteroidsModule.fluidNitrogenGas = registerFluid("nitrogen", 1, 12, 295, true); registerFluid("carbondioxide", 2, 20, 295, true); registerFluid("hydrogen", 1, 1, 295, true); registerFluid("argon", 1, 4, 295, true); AsteroidsModule.fluidLiquidArgon = registerFluid("liquidargon", 900, 100, 87, false); registerFluid("helium", 1, 1, 295, true); //AsteroidsModule.fluidCO2Gas = FluidRegistry.getFluid("carbondioxide"); AsteroidBlocks.initBlocks(); AsteroidBlocks.registerBlocks(); AsteroidBlocks.setHarvestLevels(); AsteroidBlocks.oreDictRegistration(); AsteroidsItems.initItems(); FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(AsteroidsModule.fluidMethaneGas, 1000), new ItemStack(AsteroidsItems.methaneCanister, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY))); FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(AsteroidsModule.fluidLiquidOxygen, 1000), new ItemStack(AsteroidsItems.canisterLOX, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY))); FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(AsteroidsModule.fluidLiquidNitrogen, 1000), new ItemStack(AsteroidsItems.canisterLN2, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY))); }
@EventHandler public void preInit(FMLPreInitializationEvent event) { isPlanetsLoaded = Loader.isModLoaded(Constants.MOD_ID_PLANETS); GCCoreUtil.nextID = 0; MinecraftForge.EVENT_BUS.register(new EventHandlerGC()); handler = new GCPlayerHandler(); MinecraftForge.EVENT_BUS.register(handler); FMLCommonHandler.instance().bus().register(handler); GalacticraftCore.proxy.preInit(event); ConnectionPacket.bus = NetworkRegistry.INSTANCE.newEventDrivenChannel(ConnectionPacket.CHANNEL); ConnectionPacket.bus.register(new ConnectionPacket()); ConfigManagerCore.initialize(new File(event.getModConfigurationDirectory(), GalacticraftCore.CONFIG_FILE)); EnergyConfigHandler.setDefaultValues(new File(event.getModConfigurationDirectory(), GalacticraftCore.POWER_CONFIG_FILE)); ChunkLoadingCallback.loadConfig(new File(event.getModConfigurationDirectory(), GalacticraftCore.CHUNKLOADER_CONFIG_FILE)); this.registerOilandFuel(); if (Loader.isModLoaded("PlayerAPI")) { ServerPlayerAPI.register(Constants.MOD_ID_CORE, GCPlayerBaseMP.class); } GCBlocks.initBlocks(); GCItems.initItems(); //Allow canisters to be filled from other mods' tanks containing fuel / oil fluids FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(GalacticraftCore.fluidFuel, 1000), new ItemStack(GCItems.fuelCanister, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY))); FluidContainerRegistry.registerFluidContainer(new FluidContainerData(new FluidStack(GalacticraftCore.fluidOil, 1000), new ItemStack(GCItems.oilCanister, 1, 1), new ItemStack(GCItems.oilCanister, 1, ItemCanisterGeneric.EMPTY))); }
@Override public boolean matches(ItemFilter filter, Object[] data, int dataIndex, SlotType type) { if(!(data[dataIndex] instanceof FluidStack) || (type != slotType && ( type != SlotType.ANY_SLOT || slotType == SlotType.DISPLAY_SLOT || slotType == SlotType.HIDDEN_SLOT))) { return false; } FluidStack stack = (FluidStack)data[dataIndex]; if(filter.matches(stack)) { return true; } else { for(FluidContainerData liquidData: FluidContainerRegistry.getRegisteredFluidContainerData()) { if(stack.isFluidEqual(liquidData.fluid) && filter.matches(liquidData.filledContainer)) { return true; } } return false; } }
@Override public List<ItemStack> getInputs() { List<ItemStack> ret = new ArrayList<ItemStack>(); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.fluid.getFluid() == fluid) ret.add(data.filledContainer); } return ret; }
private void setContainerItems(Fluid fluid) { List<ItemStack> emptyContainers = new ArrayList<ItemStack>(); List<ItemStack> filledContainers = new ArrayList<ItemStack>(); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.fluid.getFluid() == fluid) { emptyContainers.add(data.emptyContainer); filledContainers.add(data.filledContainer); } } if (!emptyContainers.isEmpty() && !filledContainers.isEmpty()) { this.emptyContainer = new PositionedStack(emptyContainers, 71, 43); this.filledContainer = new PositionedStack(filledContainers, 112, 43); } }
@Override public void prepare() { guiClass = Utils.getClass("forestry.factory.gui.GuiBottler"); for (FluidContainerData container : FluidContainerRegistry.getRegisteredFluidContainerData()) { MachineBottler.Recipe recipe = MachineBottler.RecipeManager.findMatchingRecipe(container.fluid, container.emptyContainer); if (recipe != null) { recipes.add(recipe); } } }
@Override public List<ItemStack> getInputs() { List<ItemStack> ret = new ArrayList<ItemStack>(); for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.fluid.getFluid() == fluid) { ret.add(data.filledContainer); } } return ret; }
/** * Called upon block activation (right click on the block.) */ public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer ep, int side, float par7, float par8, float par9) { TileEntityMagiCrucible mag = (TileEntityMagiCrucible) world.getBlockTileEntity(x, y, z); ItemStack itemstack = ep.inventory.getCurrentItem(); if (world.isRemote) { if (!FluidContainerRegistry.isEmptyContainer(itemstack)) { mag.showAmount(); } return true; } else { if (FluidContainerRegistry.isEmptyContainer(itemstack)) { // TODO - Fill Container for (FluidContainerData data : FluidContainerRegistry.getRegisteredFluidContainerData()) { if (data.emptyContainer != null && itemstack.isItemEqual(data.emptyContainer)) { if (data.fluid != null && data.fluid.isFluidEqual(mag.getTankInfo(null)[0].fluid)) { if (mag.getTankInfo(null)[0].fluid.amount >= data.fluid.amount) { ItemStack result = data.filledContainer.copy(); mag.getTankInfo(null)[0].fluid.amount -= data.fluid.amount; if (--itemstack.stackSize <= 0) { ep.inventory.mainInventory[ep.inventory.currentItem] = result; return true; } if (!ep.inventory.addItemStackToInventory(result)) { ep.dropPlayerItem(result); } } } } } } } return true; }
public static boolean storesFluid(ItemStack itemstack) { if (itemstack.getItem() instanceof IFluidContainerItem) { return true; } for (FluidContainerData f : getFluidData()) { if (Item.getIdFromItem(f.filledContainer.getItem()) == Item.getIdFromItem(itemstack.getItem()) && f.filledContainer.getItemDamage() == itemstack.getItemDamage()) { return true; } } return false; }
public static List<ItemStack> getStoringItemStacks(int fluidID) { List<ItemStack> data = new ArrayList<ItemStack>(); for (FluidContainerData f : getFluidData()) { if (f.fluid.fluidID == fluidID) { data.add(f.filledContainer); } } return data; }
public FluidFactoryProduct registerFluid(UnregisteredFluid fluidData) throws IllegalArgumentException { // Pass the data object into the product to activate it, creates needed data structures inside it based on data supplied. FluidFactoryProduct fluidProduct = new FluidFactoryProduct( fluidData ); // Check to make sure we have not added this item before. if (! isValidFluidID( fluidProduct.getFluidName() )) { throw new IllegalArgumentException( "Duplicate FluidFactoryProduct '" + fluidProduct.getFluidName() + "' was added. Execution halted!" ); } // Debugging! ModLoader.log().info( "[FluidFactory]Registering fluid: " + fluidProduct.getFluidName() ); // Actually register the fluid with the product listing. registeredFluids.put( fluidProduct.getFluidName(), fluidProduct ); // Register the fluid with Minecraft/Forge. GameRegistry.registerBlock( fluidProduct.getFluidBlock(), ItemBlockTooltip.class, fluidProduct.getFluidName() ); // Only register container item and call backs if they are enabled. if (fluidData.hasFluidContainerItem()) { // Register fluid container item. GameRegistry.registerItem( fluidProduct.getFluidContainer(), fluidProduct.getFluidContainerName() ); // Register our class as a valid container for our fluid. FluidContainerRegistry.registerFluidContainer( new FluidContainerData( FluidRegistry.getFluidStack( fluidProduct.getFluidName(), FluidContainerRegistry.BUCKET_VOLUME ), new ItemStack( fluidProduct.getFluidContainer() ), new ItemStack( Item.bucketEmpty ) ) ); // Hook event in forge for filling a bucket with liquid. MinecraftForge.EVENT_BUS.register( fluidProduct.getFluidContainer() ); } // Register custom rendering for GUI's. ForgeMod.proxy.registerRenderingHandler( fluidProduct.getFluidID() ); return fluidProduct; }
public static void init() { FluidContainerRegistry.registerFluidContainer(new FluidContainerData(FluidRegistry.getFluidStack("energizedwater", FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(ModItems.energizedWaterBucket), FluidContainerRegistry.EMPTY_BUCKET)); }
public FluidGuessHandler(Class<?> parent) { super(parent); for (FluidContainerData data : FluidUtil.getFluidData()) { this.itemstacks.add(data.filledContainer); } }
public static FluidContainerData[] getFluidData() { return FluidContainerRegistry.getRegisteredFluidContainerData(); }
@EventHandler public void postInit(FMLPostInitializationEvent event) { //Show a message when the Sugar+ Mod is in the 'postInit' phase and if debug messages are enabled if(this.enableDebugMessages) { LogHelper.info(String.format("Register liquid chocolate bucket as fluid container! (PostInit phase)")); } //Register the liquid chocolate bucket as a fluid container FluidContainerRegistry.registerFluidContainer(new FluidContainerData(FluidRegistry.getFluidStack(liquidChocolateFluid.getName(), FluidContainerRegistry.BUCKET_VOLUME), new ItemStack(liquidChocolateBucket), new ItemStack(Items.bucket))); }