本文整理匯總了Java中net.minecraftforge.event.entity.player.FillBucketEvent.setFilledBucket方法的典型用法代碼示例。如果您正苦於以下問題:Java FillBucketEvent.setFilledBucket方法的具體用法?Java FillBucketEvent.setFilledBucket怎麽用?Java FillBucketEvent.setFilledBucket使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.entity.player.FillBucketEvent
的用法示例。
在下文中一共展示了FillBucketEvent.setFilledBucket方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onFillBucket
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event) {
RayTraceResult rtr = event.getTarget();
if (rtr != null) {
Block b = event.getWorld().getBlockState(rtr.getBlockPos()).getBlock();
if (b instanceof IFluidBlock) {
Fluid fluid = ((IFluidBlock) b).getFluid();
ItemStack filled = FluidUtil.getFilledBucket(new FluidStack(fluid, 1000));
if (!filled.isEmpty()) {
event.setFilledBucket(FluidUtil.getFilledBucket(new FluidStack(fluid, 1000)));
event.getWorld().setBlockToAir(rtr.getBlockPos());
event.setResult(Result.ALLOW);
if (TileEntityRefinery.isInputFluidValid(fluid, 4) && event.getEntityPlayer() instanceof EntityPlayerMP) {
AdvancementTriggers.OIL_BUCKET.trigger((EntityPlayerMP) event.getEntityPlayer());
}
}
}
}
}
示例2: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.HIGH)
public void onBucketFill(FillBucketEvent evt) {
if (evt.getResult() != Result.DEFAULT) return;
if (evt.getEmptyBucket().getItem() != EMPTY_BUCKET) return;
final RayTraceResult target = evt.getTarget();
if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) return;
final TileEntity te = evt.getWorld().getTileEntity(target.getBlockPos());
if (te == null) return;
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit)) {
final IFluidHandler source = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit);
final FluidStack drained = source.drain(containedFluid, false);
if (containedFluid.isFluidStackIdentical(drained)) {
source.drain(containedFluid, true);
evt.setFilledBucket(filledBucket.copy());
evt.setResult(Result.ALLOW);
}
}
}
示例3: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
if (event.getEntityPlayer() != null) {
Biome biome = event.getWorld().getBiomeForCoordsBody(event.getTarget().getBlockPos());
if (biome == Biomes.OCEAN || biome == Biomes.DEEP_OCEAN || biome == Biomes.FROZEN_OCEAN) {
event.setResult(Event.Result.ALLOW);
event.setFilledBucket(new ItemStack(PLItems.saltWaterBucket));
}
}
}
示例4: onBucketUsed
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUsed(FillBucketEvent event){
if(event.getTarget() == null)
return;
ItemStack result = fillBucket(event.getWorld(), event.getTarget().getBlockPos());
if(result == null)
return;
event.setFilledBucket(result);
event.setResult(Result.ALLOW);
}
示例5: onBucketUsed
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUsed(FillBucketEvent event){
if(event.getTarget() == null)
return;
ItemStack result = fillBucket(event.getWorld(), event.getTarget().getBlockPos());
if(result == ItemStack.EMPTY)
return;
event.setFilledBucket(result);
event.setResult(Result.ALLOW);
}
示例6: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
if (event.getTarget() == null) {
return;
}
ItemStack result = fillCustomBucket(event.getWorld(), event.getTarget());
if (result == null)
return;
event.setFilledBucket(result);
event.setResult(Result.ALLOW);
}
示例7: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent evt) {
if (evt.getResult() != Result.DEFAULT) return;
if (evt.getEmptyBucket().getItem() != EMPTY_BUCKET) return;
final RayTraceResult target = evt.getTarget();
if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK) return;
final TileEntity te = evt.getWorld().getTileEntity(target.getBlockPos());
if (te == null) return;
if (!canFill(evt.getWorld(), target.getBlockPos(), te)) { return; }
if (te.hasCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit)) {
final IFluidHandler source = te.getCapability(CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY, target.sideHit);
final FluidStack fluidInContainer = source.drain(Fluid.BUCKET_VOLUME, false);
if (fluidInContainer != null) {
final ItemStack filledBucket = getFilledBucket(fluidInContainer);
if (!filledBucket.isEmpty()) {
final IFluidHandlerItem container = FluidUtil.getFluidHandler(filledBucket);
if (container != null) {
final FluidStack fluidInBucket = container.drain(Integer.MAX_VALUE, false);
if (fluidInBucket != null && fluidInBucket.isFluidStackIdentical(source.drain(fluidInBucket, false))) {
source.drain(fluidInBucket, true);
evt.setFilledBucket(filledBucket.copy());
evt.setResult(Result.ALLOW);
}
}
}
}
}
}
示例8: onFillBucket
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOW) // low priority so other mods can handle their stuff first
public void onFillBucket(FillBucketEvent event)
{
if (event.getResult() != Event.Result.DEFAULT)
{
// event was already handled
return;
}
// not for us to handle
ItemStack emptyBucket = event.getEmptyBucket();
if (emptyBucket == null ||
!emptyBucket.isItemEqual(getEmpty()) ||
(isNbtSensitive() && ItemStack.areItemStackTagsEqual(emptyBucket, getEmpty())))
{
return;
}
// needs to target a block
RayTraceResult target = event.getTarget();
if (target == null || target.typeOfHit != RayTraceResult.Type.BLOCK)
{
return;
}
World world = event.getWorld();
BlockPos pos = target.getBlockPos();
ItemStack singleBucket = emptyBucket.copy();
singleBucket.stackSize = 1;
ItemStack filledBucket = FluidUtil.tryPickUpFluid(singleBucket, event.getEntityPlayer(), world, pos, target.sideHit);
if (filledBucket != null)
{
event.setResult(Event.Result.ALLOW);
event.setFilledBucket(filledBucket);
}
else
{
// cancel event, otherwise the vanilla minecraft ItemBucket would
// convert it into a water/lava bucket depending on the blocks material
event.setCanceled(true);
}
}
示例9: onFillBucket
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event)
{
ItemStack stack = event.getEmptyBucket();
if (stack == null)
{
return;
}
World worldObj = event.getWorld();
RayTraceResult target = event.getTarget();
EntityPlayer player = event.getEntityPlayer();
boolean isWater = (!AetherConfig.activateOnlyWithSkyroot() && stack.getItem() == Items.WATER_BUCKET) || stack.getItem() == ItemsAether.skyroot_bucket && stack.getMetadata() == 1;
boolean isLava = stack.getItem() == Items.LAVA_BUCKET;
boolean validDimension = (player.dimension == 0 || player.dimension == AetherConfig.getAetherDimensionID());
if (target != null && target.typeOfHit == Type.BLOCK && validDimension)
{
BlockPos hitPos = target.getBlockPos().offset(target.sideHit);
if (isWater)
{
if (((BlockAetherPortal) BlocksAether.aether_portal).trySpawnPortal(worldObj, hitPos))
{
if (!player.capabilities.isCreativeMode)
{
if (stack.getItem() == ItemsAether.skyroot_bucket || stack.getItemDamage() == 1)
{
event.setFilledBucket(new ItemStack(ItemsAether.skyroot_bucket));
}
if (stack.getItem() == Items.WATER_BUCKET)
{
event.setFilledBucket(new ItemStack(Items.BUCKET));
}
}
event.setResult(Result.ALLOW);
}
}
if (isLava && player.dimension == AetherConfig.getAetherDimensionID())
{
if (player.capabilities.isCreativeMode && player.isSneaking())
{
return;
}
if (worldObj.isAirBlock(hitPos))
{
worldObj.setBlockState(hitPos, BlocksAether.aerogel.getDefaultState());
if (!player.capabilities.isCreativeMode)
{
event.setFilledBucket(new ItemStack(Items.BUCKET));
}
}
event.setResult(Result.ALLOW);
}
}
}