當前位置: 首頁>>代碼示例>>Java>>正文


Java FillBucketEvent.getTarget方法代碼示例

本文整理匯總了Java中net.minecraftforge.event.entity.player.FillBucketEvent.getTarget方法的典型用法代碼示例。如果您正苦於以下問題:Java FillBucketEvent.getTarget方法的具體用法?Java FillBucketEvent.getTarget怎麽用?Java FillBucketEvent.getTarget使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraftforge.event.entity.player.FillBucketEvent的用法示例。


在下文中一共展示了FillBucketEvent.getTarget方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onPlayerUseBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
/**
 * Event listener for bucket using. When you place water or lava with
 * bucket it doesn't considered place block action like with any other
 * types of blocks.
 *
 * So here's my hack for placing water and lava blocks.
 */
@SubscribeEvent
public void onPlayerUseBucket(FillBucketEvent event)
{
    EntityPlayer player = event.getEntityPlayer();
    List<Action> events = CommonProxy.manager.getActions(player);
    RayTraceResult target = event.getTarget();

    if (!player.worldObj.isRemote && events != null && target != null && target.typeOfHit == Type.BLOCK)
    {
        Item bucket = event.getEmptyBucket().getItem();
        BlockPos pos = target.getBlockPos().offset(target.sideHit);

        if (bucket == Items.LAVA_BUCKET)
        {
            this.placeBlock(events, pos, Blocks.FLOWING_LAVA, 0);
        }
        else if (bucket == Items.WATER_BUCKET)
        {
            this.placeBlock(events, pos, Blocks.FLOWING_WATER, 0);
        }
    }
}
 
開發者ID:mchorse,項目名稱:blockbuster,代碼行數:30,代碼來源:ActionHandler.java

示例2: 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());
                }
            }
        }
    }
}
 
開發者ID:TeamPneumatic,項目名稱:pnc-repressurized,代碼行數:20,代碼來源:EventHandlerPneumaticCraft.java

示例3: onFillBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event) {
	if(event.getEntityPlayer().isSneaking()) {
		return;
	}

	if(event.getTarget() == null) {
		return;
	}

	BlockPos pos = event.getTarget().getBlockPos();

	if(!isPartOfTank(event.getWorld(), pos)) {
		return;
	}

	event.setCanceled(true);
}
 
開發者ID:Lordmau5,項目名稱:FFS,代碼行數:19,代碼來源:TankManager.java

示例4: onFillBucket

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
/**
 * Troll user if they attempt to put volcanic lava in a bucket.
 */
@SubscribeEvent(priority = EventPriority.HIGH) 
public static void onFillBucket(FillBucketEvent event)
{
    if(event.getEntityPlayer() != null && !event.getWorld().isRemote)
    {
        RayTraceResult target = event.getTarget();
        if(target != null && target.typeOfHit == RayTraceResult.Type.BLOCK)
        {
            if(target.getBlockPos() != null)
            {
                IBlockState state = event.getWorld().getBlockState(target.getBlockPos());
                if(state.getBlock() instanceof LavaBlock)
                {
                    event.getEntityPlayer().sendMessage(new TextComponentString(DENIALS[ThreadLocalRandom.current().nextInt(DENIALS.length)]));
                    event.setCanceled(true);
                }
            }
        }
    }
}
 
開發者ID:grondag,項目名稱:Hard-Science,代碼行數:24,代碼來源:CommonEventHandler.java

示例5: 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);
		}
	}
}
 
開發者ID:OpenMods,項目名稱:OpenModsLib,代碼行數:24,代碼來源:SingleFluidBucketFillHandler.java

示例6: onBucketUse

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUse(FillBucketEvent event)
{
	if (event.getWorld().isRemote) { return; }

	RayTraceResult target = event.getTarget();

	if (target == null) { return; }	// Nevermind?

	BlockPos pos = target.getBlockPos();

	if (pos == null) { return; }	// Nevermind?

	Main.console("[TERRITORIAL DEALINGS] Bucket used by player " + event.getEntityPlayer().getName() + " at x " + pos.getX() + " / y " + pos.getY() + " / z " + pos.getZ() + ".");

	Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos);

	if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer(), chunk))	// Checks out
	{
		Main.console("[TERRITORIAL DEALINGS] Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("[TERRITORIAL DEALINGS] Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:28,代碼來源:EventListener.java

示例7: onBucketUse

import net.minecraftforge.event.entity.player.FillBucketEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBucketUse(FillBucketEvent event)
{
	if (event.getWorld().isRemote) { return; }	// Not doing this on client side

	RayTraceResult target = event.getTarget();

	if (target == null) { return; }	// Nevermind?

	BlockPos pos = target.getBlockPos();

	if (pos == null) { return; }	// Nevermind?

	Main.console("Bucket used by player " + event.getEntityPlayer().getName() + " (ID " + event.getEntityPlayer().getGameProfile().getId() + ") at x" + pos.getX() + " y" + pos.getY() + " z" + pos.getZ() + ".");

	Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(pos);

	if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk))	// Checks out
	{
		Main.console("Player is allowed to edit this chunk. Doing nothing.");
	}
	else
	{
		Main.console("Player is not allowed to edit this chunk. Cancelling.");
		event.setCanceled(true);	// Not having it
	}
}
 
開發者ID:Domochevsky,項目名稱:minecraft-territorialdealings,代碼行數:28,代碼來源:EventListener.java

示例8: 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);
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:12,代碼來源:SCEventHandler.java

示例9: 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);
}
 
開發者ID:Geforce132,項目名稱:SecurityCraft,代碼行數:12,代碼來源:SCEventHandler.java

示例10: 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);
}
 
開發者ID:TeamDmfMM,項目名稱:Extra-Food,代碼行數:16,代碼來源:BucketHandler.java

示例11: 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);
					}
				}
			}
		}
	}
}
 
開發者ID:OpenMods,項目名稱:OpenModsLib,代碼行數:36,代碼來源:ContainerBucketFillHandler.java

示例12: 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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:45,代碼來源:UniversalBucket.java

示例13: 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);
		}
	}
}
 
開發者ID:Modding-Legacy,項目名稱:Aether-Legacy,代碼行數:66,代碼來源:AetherEventHandler.java


注:本文中的net.minecraftforge.event.entity.player.FillBucketEvent.getTarget方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。