当前位置: 首页>>代码示例>>Java>>正文


Java LiquidContainerData类代码示例

本文整理汇总了Java中net.minecraftforge.liquids.LiquidContainerData的典型用法代码示例。如果您正苦于以下问题:Java LiquidContainerData类的具体用法?Java LiquidContainerData怎么用?Java LiquidContainerData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LiquidContainerData类属于net.minecraftforge.liquids包,在下文中一共展示了LiquidContainerData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateServerSide

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public void updateServerSide() {

	// Can/capsule input/output needs to be handled here.
	if (inventoryStacks[canSlot] != null) {

		LiquidContainerData container = LiquidHelper.getEmptyContainer(inventoryStacks[canSlot],
				new LiquidStack(productTank.liquidId, productTank.quantity, productTank.liquidMeta));
		if (container != null) {
			inventoryStacks[outputSlot] = bottleIntoContainer(inventoryStacks[canSlot], inventoryStacks[outputSlot], container, productTank);
			if (inventoryStacks[canSlot].stackSize <= 0) {
				inventoryStacks[canSlot] = null;
			}
		}

	}

	if (tile.worldObj.getWorldTime() % 20 * 10 != 0)
		return;

	checkRecipe();
	if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
		setErrorState(EnumErrorCode.OK);
	}

}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:27,代码来源:MachineSqueezer.java

示例2: addItem

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
/**
 * Stacks from top to bottom go into the box slot. Stacks from the sides into the crafting matrix.
 */
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {

	// / Liquid container
	LiquidContainerData container = LiquidHelper.getLiquidContainer(stack);
	if (container != null && RecipeManager.isResourceLiquid(container.stillLiquid))
		return inventory.addStack(stack, SLOT_CAN_INPUT, 1, false, doAdd);

	// / We only try to add other resources if we have a recipe set
	if (currentRecipe != null) {
		// Store ingredients
		if (currentRecipe.isIngredient(stack))
			return inventory.addStack(stack, SLOT_INVENTORY_1, SLOT_INVENTORY_COUNT, false, doAdd);
	}

	// / Store boxes
	if (RecipeManager.isBox(stack))
		return inventory.addStack(stack, SLOT_BOX, 1, false, doAdd);

	return 0;

}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:26,代码来源:MachineCarpenter.java

示例3: updateServerSide

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public void updateServerSide() {
	// Check if we have suitable items waiting in the item slot
	if (inventoryStacks[SLOT_CAN] != null) {
		LiquidContainerData container = LiquidHelper.getLiquidContainer(inventoryStacks[SLOT_CAN]);
		if (container != null && RecipeManager.isInput(container.stillLiquid)) {

			inventoryStacks[SLOT_CAN] = StackUtils.replenishByContainer(tile, inventoryStacks[SLOT_CAN], container, resourceTank);
			if (inventoryStacks[SLOT_CAN].stackSize <= 0) {
				inventoryStacks[SLOT_CAN] = null;
			}
		}
	}

	if (tile.worldObj.getWorldTime() % 20 * 10 != 0)
		return;

	checkRecipe();
	if (getErrorState() == EnumErrorCode.NORECIPE && currentRecipe != null) {
		setErrorState(EnumErrorCode.OK);
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:23,代码来源:MachineBottler.java

示例4: hasWork

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public boolean hasWork() {
	// Always send redstone signal if we are in the process of bottling
	if (fillingTime > 0)
		return true;

	// Otherwise only if we have sufficient raw materials for a new bottling
	// process
	if (inventoryStacks[SLOT_RESOURCE] == null)
		return false;

	LiquidContainerData container = LiquidHelper.getEmptyContainer(inventoryStacks[SLOT_RESOURCE], new LiquidStack(Block.waterStill, 1));
	if (container == null)
		return false;
	if (resourceTank.quantity < container.stillLiquid.amount)
		return false;

	return true;
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:20,代码来源:MachineRaintank.java

示例5: replenishByContainer

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
public static ItemStack replenishByContainer(TileForestry tile, ItemStack inventoryStack, LiquidContainerData container, TankSlot tank) {
	if (container == null)
		return inventoryStack;

	if (tank.fill(container.stillLiquid, false) >= container.stillLiquid.amount) {
		tank.fill(container.stillLiquid, true);
		if (container.filled != null && container.filled.getItem().hasContainerItem()) {
			inventoryStack = container.container.copy();
		} else {
			inventoryStack.stackSize--;
		}
		tile.sendNetworkUpdate();
	}

	return inventoryStack;
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:17,代码来源:StackUtils.java

示例6: injectLiquidContainer

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
public static void injectLiquidContainer(LiquidContainerData container, ItemStack remnant, int chance) {
	LiquidContainerRegistry.registerLiquid(container);

	if (RecipeManagers.squeezerManager != null) {
		if (!container.container.getItem().hasContainerItem())
			if (remnant != null) {
				RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { container.filled }, container.stillLiquid, remnant, chance);
			} else {
				RecipeManagers.squeezerManager.addRecipe(10, new ItemStack[] { container.filled }, container.stillLiquid);
			}
	}

	if (RecipeManagers.bottlerManager != null) {
		RecipeManagers.bottlerManager.addRecipe(5, container.stillLiquid, container.container, container.filled);
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:17,代码来源:LiquidHelper.java

示例7: bottleIntoContainer

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
protected ItemStack bottleIntoContainer(ItemStack canStack, ItemStack outputStack, LiquidContainerData container, TankSlot tank) {
	if (tank.quantity < container.stillLiquid.amount)
		return outputStack;
	if (canStack.stackSize <= 0)
		return outputStack;
	if (outputStack != null && !outputStack.isItemEqual(container.filled))
		return outputStack;
	if (outputStack != null && outputStack.stackSize >= outputStack.getMaxStackSize())
		return outputStack;

	tank.quantity -= container.stillLiquid.amount;
	canStack.stackSize--;

	if (outputStack == null) {
		outputStack = container.filled.copy();
	} else {
		outputStack.stackSize++;
	}

	return outputStack;
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:22,代码来源:Machine.java

示例8: initLiquids

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
private void initLiquids() {
	try {
		oilStill = (Block) Class.forName("buildcraft.BuildCraftEnergy").getField("oilStill").get(null);
		oilMoving = (Block) Class.forName("buildcraft.BuildCraftEnergy").getField("oilMoving").get(null);
		fuel = (Item) Class.forName("buildcraft.BuildCraftEnergy").getField("fuel").get(null);
	} catch (Exception ex) {
		Proxies.log.fine("Oil or fuel not found.");
		return;
	}

	LiquidHelper.injectWaxContainer(new LiquidContainerData(new LiquidStack(oilStill, Defaults.BUCKET_VOLUME), new ItemStack(ForestryItem.waxCapsuleOil),
			new ItemStack(ForestryItem.waxCapsule)));
	LiquidHelper.injectWaxContainer(new LiquidContainerData(new LiquidStack(fuel, Defaults.BUCKET_VOLUME), new ItemStack(ForestryItem.waxCapsuleFuel),
			new ItemStack(ForestryItem.waxCapsule)));
	LiquidHelper.injectRefractoryContainer(new LiquidContainerData(new LiquidStack(oilStill, Defaults.BUCKET_VOLUME), new ItemStack(
			ForestryItem.refractoryOil), new ItemStack(ForestryItem.refractoryEmpty)));
	LiquidHelper.injectRefractoryContainer(new LiquidContainerData(new LiquidStack(fuel, Defaults.BUCKET_VOLUME),
			new ItemStack(ForestryItem.refractoryFuel), new ItemStack(ForestryItem.refractoryEmpty)));
	LiquidHelper.injectTinContainer(new LiquidContainerData(new LiquidStack(oilStill, Defaults.BUCKET_VOLUME), new ItemStack(ForestryItem.canOil),
			new ItemStack(ForestryItem.canEmpty)));
	LiquidHelper.injectTinContainer(new LiquidContainerData(new LiquidStack(fuel, Defaults.BUCKET_VOLUME), new ItemStack(ForestryItem.canFuel),
			new ItemStack(ForestryItem.canEmpty)));

}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:25,代码来源:PluginBuildCraft.java

示例9: initLiquidContainers

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
private void initLiquidContainers() {
	emptyCell = Items.getItem("cell");
	lavaCell = Items.getItem("lavaCell");
	waterCell = Items.getItem("waterCell");
	if (emptyCell == null || lavaCell == null || waterCell == null) {
		Proxies.log.fine("Any of the following IC2 items could not be found: empty cell, water cell, lava cell. Skipped adding IC2 liquid containers.");
		return;
	}

	LiquidHelper.injectTinContainer(new LiquidContainerData(new LiquidStack(Block.lavaStill, Defaults.BUCKET_VOLUME), lavaCell, emptyCell));
	LiquidHelper.injectTinContainer(new LiquidContainerData(new LiquidStack(Block.waterStill, Defaults.BUCKET_VOLUME), waterCell, emptyCell));
	Proxies.common
			.addRecipe(new ItemStack(ForestryBlock.soil, 8, 1),
					new Object[] { "#Y#", "YXY", "#Y#", Character.valueOf('#'), Block.dirt, Character.valueOf('X'), waterCell, Character.valueOf('Y'),
							Block.sand });

	// Add extra recipes
	RecipeManagers.bottlerManager.addRecipe(5, new LiquidStack(Block.waterStill, Defaults.BUCKET_VOLUME), emptyCell, waterCell);
	RecipeManagers.bottlerManager.addRecipe(5, new LiquidStack(Block.lavaStill, Defaults.BUCKET_VOLUME), emptyCell, lavaCell);
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:21,代码来源:PluginIC2.java

示例10: updateServerSide

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
protected void updateServerSide() {
	super.updateServerSide();
	
	if(!isMaster())
		return;
	
	if(worldObj.isRaining()) {
		if(hydrationDelay > 0)
			hydrationDelay--;
		else
			ticksSinceRainfall = 0;
	} else {
		hydrationDelay = DELAY_HYDRATION;
		if(ticksSinceRainfall < Integer.MAX_VALUE)
			ticksSinceRainfall++;
	}
	
	if (worldObj.getWorldTime() % 20 * 10 != 0)
		return;

	// Check if we have suitable items waiting in the item slot
	if (inventory.getStackInSlot(SLOT_CAN) != null) {
		LiquidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(SLOT_CAN));
		if (container != null && container.stillLiquid.itemID == Block.waterStill.blockID) {

			inventory.setInventorySlotContents(SLOT_CAN, StackUtils.replenishByContainer(this, inventory.getStackInSlot(SLOT_CAN), container, liquidTank));
			if (inventory.getStackInSlot(SLOT_CAN).stackSize <= 0) {
				inventory.setInventorySlotContents(SLOT_CAN, null);
			}
		}
	}

}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:35,代码来源:TileFarmPlain.java

示例11: addItem

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
	int inventory;

	LiquidContainerData container = LiquidHelper.getLiquidContainer(stack);
	if (container != null && RecipeManager.isInput(container.stillLiquid)) {
		inventory = SLOT_INPUT;
	} else if (LiquidHelper.isEmptyContainer(stack)) {
		inventory = SLOT_CAN;
	} else
		return 0;

	if (inventoryStacks[inventory] == null) {
		if (doAdd) {
			inventoryStacks[inventory] = stack.copy();
		}
		return stack.stackSize;
	}

	if (!inventoryStacks[inventory].isItemEqual(stack))
		return 0;

	int space = inventoryStacks[inventory].getMaxStackSize() - inventoryStacks[inventory].stackSize;
	if (space <= 0)
		return 0;

	if (doAdd) {
		inventoryStacks[inventory].stackSize += stack.stackSize;
	}

	return Math.min(space, stack.stackSize);
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:33,代码来源:MachineStill.java

示例12: doWork

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public boolean doWork() {
	if (!Proxies.common.isSimulating(tile.worldObj))
		return false;

	// Try to add product from previous cycle if still available
	if (productPending != null)
		if (tryProductAdd(productPending.filled.copy(), true)) {
			productPending = null;
			return true;
		} else
			return false;

	if (fillingTime > 0) {
		fillingTime--;
		if (fillingTime <= 0)
			if (usedEmpty != null) {
				LiquidContainerData container = LiquidHelper.getEmptyContainer(usedEmpty, new LiquidStack(Block.waterStill, 1));
				if (container != null && !tryProductAdd(container.filled.copy(), true)) {
					productPending = container;
				}
			}
		return true;
	} else if (tryStart(true))
		return true;
	else {
		usedEmpty = null;
		return false;
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:31,代码来源:MachineRaintank.java

示例13: tryStart

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
private boolean tryStart(boolean doStart) {

		// Nothing to do if no empty cans are available
		if (inventoryStacks[SLOT_RESOURCE] == null)
			return false;
		if (inventoryStacks[SLOT_RESOURCE].stackSize <= 0)
			return false;

		LiquidContainerData container = LiquidHelper.getEmptyContainer(inventoryStacks[SLOT_RESOURCE], new LiquidStack(Block.waterStill, 1));
		if (container == null)
			return false;

		// Nothing to do if the output slot is full or occupied by a wrong item
		// stack
		if (!tryProductAdd(container.filled, false))
			return false;

		// Nothing to do if not enough liquid is available
		if (resourceTank.quantity < container.stillLiquid.amount)
			return false;

		// Let's fill a can
		if (doStart) {
			resourceTank.quantity -= container.stillLiquid.amount;
			if (resourceTank.quantity < 0) {
				resourceTank.quantity = 0;
			}
			decrStackSize(SLOT_RESOURCE, 1);
			fillingTime = this.fillingTotalTime = Defaults.RAINTANK_FILLING_TIME;
			usedEmpty = container.container;
		}

		return true;
	}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:35,代码来源:MachineRaintank.java

示例14: addItem

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public int addItem(ItemStack stack, boolean doAdd, ForgeDirection from) {
	// We only accept empty water containers
	LiquidContainerData container = LiquidHelper.getEmptyContainer(stack, new LiquidStack(Block.waterStill, 1));
	if (container == null)
		return 0;

	if (inventoryStacks[SLOT_RESOURCE] == null) {
		if (doAdd) {
			inventoryStacks[SLOT_RESOURCE] = stack.copy();
		}
		return stack.stackSize;
	}

	if (inventoryStacks[SLOT_RESOURCE].stackSize >= inventoryStacks[SLOT_RESOURCE].getMaxStackSize())
		return 0;
	if (!inventoryStacks[SLOT_RESOURCE].isItemEqual(stack))
		return 0;

	// Determine available space
	int space = getInventoryStackLimit() - inventoryStacks[SLOT_RESOURCE].stackSize;
	if (space >= stack.stackSize) {
		if (doAdd) {
			inventoryStacks[SLOT_RESOURCE].stackSize += stack.stackSize;
		}
		return stack.stackSize;
	} else {
		if (doAdd) {
			inventoryStacks[SLOT_RESOURCE].stackSize = getInventoryStackLimit();
			stack.stackSize -= space;
		}
		return space;
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:35,代码来源:MachineRaintank.java

示例15: updateServerSide

import net.minecraftforge.liquids.LiquidContainerData; //导入依赖的package包/类
@Override
public void updateServerSide() {

	super.updateServerSide();

	// Check if we have suitable items waiting in the item slot
	if (inventory.getStackInSlot(0) != null) {

		LiquidContainerData container = LiquidHelper.getLiquidContainer(inventory.getStackInSlot(0));
		if (container != null) {

			TankSlot tank = null;

			if (container.stillLiquid.isLiquidEqual(new LiquidStack(Block.lavaStill.blockID, 1)))
				tank = heatingTank;
			else if (FuelManager.bronzeEngineFuel.containsKey(container.stillLiquid.asItemStack()))
				tank = fuelTank;

			if (tank != null) {
				inventory.setInventorySlotContents(0, replenishByContainer(inventory.getStackInSlot(0), container, tank));
				if (inventory.getStackInSlot(0).stackSize <= 0) {
					inventory.setInventorySlotContents(0, null);
				}
			}
		}
	}

	if (worldObj.getWorldTime() % 20 * 10 != 0)
		return;

	if (getHeatLevel() <= 0.2 && heatingTank.quantity <= 0) {
		setErrorState(EnumErrorCode.NOHEAT);
	} else if (burnTime <= 0 && fuelTank.quantity <= 0) {
		setErrorState(EnumErrorCode.NOFUEL);
	} else {
		setErrorState(EnumErrorCode.OK);
	}
}
 
开发者ID:ForestryMC,项目名称:ForestryLegacy,代码行数:39,代码来源:EngineBronze.java


注:本文中的net.minecraftforge.liquids.LiquidContainerData类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。