本文整理汇总了Java中net.minecraftforge.fluids.FluidTank类的典型用法代码示例。如果您正苦于以下问题:Java FluidTank类的具体用法?Java FluidTank怎么用?Java FluidTank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FluidTank类属于net.minecraftforge.fluids包,在下文中一共展示了FluidTank类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: render
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public void render(TileEntityKeroseneLamp te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
FluidTank tank = te.getTank();
if (tank.getFluidAmount() == 0) return;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
AxisAlignedBB bounds = getRenderBounds(tank);
PneumaticCraftUtils.renderFluid(tank.getFluid().getFluid(), bounds);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
}
示例2: render
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public void render(TileEntityLiquidHopper te, double x, double y, double z, float partialTicks, int destroyStage, float alpha) {
FluidTank tank = te.getTank();
if (tank.getFluidAmount() == 0) return;
GlStateManager.pushMatrix();
GlStateManager.translate(x, y, z);
GlStateManager.enableBlend();
GlStateManager.disableAlpha();
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
doRotate(te.getInputDirection());
AxisAlignedBB bounds = getRenderBounds(te.getInputDirection(), tank);
PneumaticCraftUtils.renderFluid(tank.getFluid().getFluid(), bounds);
GlStateManager.disableBlend();
GlStateManager.enableAlpha();
GlStateManager.popMatrix();
}
示例3: serializeTank
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
/**
* Serialize some tank data onto an ItemStack. Useful to preserve tile entity tank data when breaking
* the block.
*
* @param tank the fluid tank
* @param stack the itemstack to save to
* @param tagName name of the tag in the itemstack's NBT to store the tank data
*/
public static void serializeTank(FluidTank tank, ItemStack stack, String tagName) {
if (tank.getFluidAmount() > 0) {
if (!stack.hasTagCompound()) {
stack.setTagCompound(new NBTTagCompound());
}
NBTTagCompound tag = stack.getTagCompound();
if (!tag.hasKey(SAVED_TANKS, Constants.NBT.TAG_COMPOUND)) {
tag.setTag(SAVED_TANKS, new NBTTagCompound());
}
NBTTagCompound subTag = tag.getCompoundTag(SAVED_TANKS);
NBTTagCompound tankTag = new NBTTagCompound();
tank.writeToNBT(tankTag);
subTag.setTag(tagName, tankTag);
}
}
示例4: writeToNBT
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setTag("filters", filters.serializeNBT());
NBTTagList tagList = new NBTTagList();
for (int i = 0; i < fluidFilters.length; i++) {
FluidTank filter = fluidFilters[i];
if (filter.getFluid() != null) {
NBTTagCompound t = new NBTTagCompound();
t.setInteger("index", i);
filter.writeToNBT(t);
tagList.appendTag(t);
}
}
tag.setTag("fluidFilters", tagList);
tag.setBoolean("invisible", invisible);
}
示例5: test_extractFluidsFromTanks
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Test
public void test_extractFluidsFromTanks()
{
FluidTank tank1 = new FluidTank(FluidRegistry.WATER, 1000, 10000);
FluidTank tank2 = new FluidTank(FluidRegistry.LAVA, 1000, 10000);
ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2),
Lists.newArrayList(FluidRegistry.getFluidStack("water", 400),
FluidRegistry.getFluidStack("lava", 300)));
assertEquals(600, tank1.getFluidAmount());
assertEquals(700, tank2.getFluidAmount());
ItemHelper.extractFluidsFromTanks(Lists.newArrayList(tank1, tank2),
Lists.newArrayList(FluidRegistry.getFluidStack("lava", 400),
FluidRegistry.getFluidStack("water", 300)));
assertEquals(300, tank1.getFluidAmount());
assertEquals(300, tank2.getFluidAmount());
}
示例6: apply
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
/** Applies the recipe to the storage provided, determining whether or not the output should be produced. Optionally
* consumes the items.
*/
public boolean apply(FluidTank tank, IItemHandler inventory, boolean consume) {
if (consume && !apply(tank, inventory, false)) return false; //Always dry-run before destructive ops
if (tank.getFluid()==null) return false;
//Next line shouldn't happen but it pays to plan for the impossible
if (tank.getFluid().getFluid() != FluidRegistry.WATER) return false;
if (tank.getFluidAmount()<water) return false;
FluidStack fluidExtracted = tank.drainInternal(water, consume);
if (fluidExtracted.amount<water) return false;
int remaining = count;
for(int i=0; i<inventory.getSlots(); i++) {
ItemStack stack = inventory.getStackInSlot(i);
if (stack.isEmpty()) continue;
if (item.apply(stack)) {
ItemStack extracted = inventory.extractItem(i, remaining, !consume);
if (extracted.isEmpty()) continue;
remaining -= extracted.getCount();
}
}
return remaining<=0;
}
示例7: onBlockActivated
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote) {
TileEntity te = worldIn.getTileEntity(pos);
if(te != null && te instanceof TileFluidTank) {
ItemStack activeHand = playerIn.getHeldItem(hand);
if(!activeHand.isEmpty() && FluidUtil.getFluidHandler(activeHand) != null) {
FluidTank ft = ((TileFluidTank) te).getTank();
boolean canFillPrev = ft.canFill();
boolean canDrainPrev = ft.canDrain();
ft.setCanFill(true);
ft.setCanDrain(true);
try {
FluidUtil.interactWithFluidHandler(playerIn, hand, ft);
} finally {
ft.setCanFill(canFillPrev);
ft.setCanDrain(canDrainPrev);
}
return true;
}
playerIn.openGui(ModularMachinery.MODID, CommonProxy.GuiType.TANK_INVENTORY.ordinal(), worldIn, pos.getX(), pos.getY(), pos.getZ());
}
}
return true;
}
示例8: readFluidTank
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
public static FluidTank readFluidTank(ByteBuf buffer) throws IOException
{
int capacity = buffer.readInt();
int fluidID = buffer.readInt();
FluidTank fluidTank = new FluidTank(capacity);
int amount = buffer.readInt();
if (fluidID == -1)
{
fluidTank.setFluid(null);
}
else
{
Fluid fluid = FluidRegistry.getFluid(fluidID);
fluidTank.setFluid(new FluidStack(fluid, amount));
}
return fluidTank;
}
示例9: onBlockPlacedBy
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase entity, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, entity, stack);
TileEntity tile = world.getTileEntity(pos);
if(tile !=null && tile instanceof TileEntityTank){
TileEntityTank tank = (TileEntityTank) tile;
FluidTank tankSaved = null;
if(stack.hasTagCompound()){
NBTTagCompound nbt = stack.getTagCompound().copy();
tankSaved = ItemBlockTank.loadTank(nbt);
}
if(tankSaved !=null){
tank.tank.setFluid(tankSaved.getFluid());
BlockUtil.markBlockForUpdate(world, pos);
}
if(tank.creative){
BlockUtil.markBlockForUpdate(world, pos);
}
}
}
示例10: fill
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
public int fill(FluidStack resource, boolean doFill) {
if (ItemStackTools.getStackSize(container) != 1) {
return 0;
}
FluidTank tank = loadTank(container);
if(tank == null)return 0;
boolean infi = container.getMetadata() == TankType.CREATIVE.getMeta();
if(infi){
FluidStack resourceCreative = resource.copy();
resourceCreative.amount = tank.getCapacity();
tank.fill(resourceCreative, doFill);
saveTank(container, tank);
return 1;
}
int ret = tank.fill(resource, doFill);
saveTank(container, tank);
return ret;
}
示例11: drain
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Override
@Nullable
public FluidStack drain(FluidStack resource, boolean doDrain) {
if (ItemStackTools.getStackSize(container) != 1) {
return null;
}
FluidTank tank = loadTank(container);
if(tank == null)return null;
boolean infi = container.getMetadata() == TankType.CREATIVE.getMeta();
if(infi){
return resource.copy();
}
FluidStack ret = tank.drain(resource, doDrain);
saveTank(container, tank);
return ret;
}
示例12: getRenderBounds
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
private AxisAlignedBB getRenderBounds(EnumFacing rotation, FluidTank tank) {
switch (rotation) {
case UP: return TankRenderHelper.getRenderBounds(tank, TANK_BOUNDS_UP);
case DOWN: return TankRenderHelper.getRenderBounds(tank, TANK_BOUNDS_DOWN);
default: return TankRenderHelper.getRenderBounds(tank, TANK_BOUNDS_HORIZ);
}
}
示例13: getSyncedFieldForField
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
private static SyncedField getSyncedFieldForField(Field field, Object te) {
if (int.class.isAssignableFrom(field.getType())) return new SyncedInt(te, field);
if (float.class.isAssignableFrom(field.getType())) return new SyncedFloat(te, field);
if (double.class.isAssignableFrom(field.getType())) return new SyncedDouble(te, field);
if (boolean.class.isAssignableFrom(field.getType())) return new SyncedBoolean(te, field);
if (String.class.isAssignableFrom(field.getType())) return new SyncedString(te, field);
if (field.getType().isEnum()) return new SyncedEnum(te, field);
if (ItemStack.class.isAssignableFrom(field.getType())) return new SyncedItemStack(te, field);
if (FluidTank.class.isAssignableFrom(field.getType())) return new SyncedFluidTank(te, field);
if (ItemStackHandler.class.isAssignableFrom(field.getType())) return new SyncedItemStackHandler(te, field);
return null;
}
示例14: addInformation
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> curInfo, ITooltipFlag flag) {
if (stack.hasTagCompound() && stack.getTagCompound().hasKey(PneumaticCraftUtils.SAVED_TANKS, Constants.NBT.TAG_COMPOUND)) {
NBTTagCompound tag = stack.getTagCompound().getCompoundTag(PneumaticCraftUtils.SAVED_TANKS);
for (String s : tag.getKeySet()) {
NBTTagCompound tankTag = tag.getCompoundTag(s);
FluidTank tank = new FluidTank(tankTag.getInteger("Amount"));
tank.readFromNBT(tankTag);
FluidStack fluidStack = tank.getFluid();
if (fluidStack != null && fluidStack.amount > 0) {
curInfo.add(fluidStack.getFluid().getLocalizedName(fluidStack) + ": " + fluidStack.amount + "mB");
}
}
}
if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
TileEntity te = createTileEntity(world, getDefaultState());
if (te instanceof TileEntityPneumaticBase) {
float pressure = ((TileEntityPneumaticBase) te).dangerPressure;
curInfo.add(TextFormatting.YELLOW + I18n.format("gui.tooltip.maxPressure", pressure));
}
}
String info = "gui.tab.info." + stack.getUnlocalizedName();
String translatedInfo = I18n.format(info);
if (!translatedInfo.equals(info)) {
if (PneumaticCraftRepressurized.proxy.isSneakingInGui()) {
translatedInfo = TextFormatting.AQUA + translatedInfo.substring(2);
if (!Loader.isModLoaded(ModIds.IGWMOD))
translatedInfo += " \\n \\n" + I18n.format("gui.tab.info.assistIGW");
curInfo.addAll(PneumaticCraftUtils.convertStringIntoList(translatedInfo, 40));
} else {
curInfo.add(TextFormatting.AQUA + I18n.format("gui.tooltip.sneakForInfo"));
}
}
}
示例15: getDroppedStack
import net.minecraftforge.fluids.FluidTank; //导入依赖的package包/类
@Nonnull
default ItemStack getDroppedStack(Block b) {
ItemStack stack = new ItemStack(Item.getItemFromBlock(b));
for (Map.Entry<String,FluidTank> entry : getSerializableTanks().entrySet()) {
PneumaticCraftUtils.serializeTank(entry.getValue(), stack, entry.getKey());
}
return stack;
}