本文整理匯總了Java中net.minecraftforge.event.entity.player.FillBucketEvent類的典型用法代碼示例。如果您正苦於以下問題:Java FillBucketEvent類的具體用法?Java FillBucketEvent怎麽用?Java FillBucketEvent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FillBucketEvent類屬於net.minecraftforge.event.entity.player包,在下文中一共展示了FillBucketEvent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
}
}
示例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());
}
}
}
}
}
示例3: onBucketUse
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
public static ActionResult<ItemStack> onBucketUse(EntityPlayer player, World world, ItemStack stack, RayTraceResult target)
{
FillBucketEvent event = new FillBucketEvent(player, stack, world, target);
if (MinecraftForge.EVENT_BUS.post(event)) return new ActionResult<ItemStack>(EnumActionResult.FAIL, stack);
if (event.getResult() == Result.ALLOW)
{
if (player.capabilities.isCreativeMode)
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
if (--stack.stackSize <= 0)
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, event.getFilledBucket());
if (!player.inventory.addItemStackToInventory(event.getFilledBucket()))
player.dropItem(event.getFilledBucket(), false);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
return null;
}
示例4: 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);
}
示例5: 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);
}
}
}
}
}
示例6: onBucketFillAttempt
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBucketFillAttempt(FillBucketEvent event){
if (event.entityPlayer.worldObj.isRemote)
return;
if (!ClaimsList.For(event.entity.worldObj).actionIsTrusted(event.entityPlayer, PermissionsMutex.USE_ITEMS, event.target.func_178782_a().getX(), event.target.func_178782_a().getY(), event.target.func_178782_a().getZ()))
event.setCanceled(true);
else
GriefGuardian._dal.logAction(
(EntityPlayerMP)event.entityPlayer,
Actions.ITEM_USE,
(int)Math.floor(event.entity.posX),
(int)Math.floor(event.entity.posY),
(int)Math.floor(event.entity.posZ),
event.entityPlayer.getCurrentEquippedItem(),
"");
}
示例7: bucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@ForgeSubscribe
/**
* Called by ItemBucket when it tries to fill a bucket
* @param evt
*/
public void bucketFill(FillBucketEvent evt) {
if (evt.current.getItem().equals(Item.bucketEmpty) && evt.target.typeOfHit == EnumMovingObjectType.TILE) {
if (evt.world.canMineBlock(evt.entityPlayer, evt.target.blockX, evt.target.blockY, evt.target.blockZ)) {
if (evt.entityPlayer.canPlayerEdit(evt.target.blockX, evt.target.blockY, evt.target.blockZ, evt.target.sideHit, evt.current)) {
if (evt.world.getBlockId(evt.target.blockX, evt.target.blockY, evt.target.blockZ) == blockID) {
evt.world.setBlockToAir(evt.target.blockX, evt.target.blockY, evt.target.blockZ);
evt.result = new ItemStack(Magitech.instance.magibucket);
evt.setResult(Result.ALLOW);
}
}
}
}
}
示例8: 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);
}
}
}
示例9: checkReloadFromWater
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
private void checkReloadFromWater(ItemStack stack, World world, EntityPlayer player)
{
MovingObjectPosition movingobjectposition = this.getMovingObjectPositionFromPlayer(world, player, true);
FillBucketEvent event = new FillBucketEvent(player, stack, world, movingobjectposition);
if (MinecraftForge.EVENT_BUS.post(event)) { return; }
MovingObjectPosition movObj = this.getMovingObjectPositionFromPlayer(world, player, true);
if (movObj == null) { return; } // Didn't click on anything in particular
else
{
if (movObj.typeOfHit == MovingObjectPosition.MovingObjectType.BLOCK)
{
int x = movObj.blockX;
int y = movObj.blockY;
int z = movObj.blockZ;
if (!world.canMineBlock(player, x, y, z)) { return; } // Not allowed to mine this, getting out of here
if (!player.canPlayerEdit(x, y, z, movObj.sideHit, stack)) { return; } // Not allowed to edit this, getting out of here
Material material = world.getBlock(x, y, z).getMaterial();
int meta = world.getBlockMetadata(x, y, z);
// Is this water?
if (material == Material.water && meta == 0)
{
world.setBlockToAir(x, y, z);
stack.setItemDamage(0);
return;
}
// else, not water
}
// else, didn't click on a block
}
}
示例10: 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
}
}
示例11: 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
}
}
示例12: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent event)
{
MovingObjectPosition pos = event.target;
ItemStack ret = fillBucket(event.world, pos);
if (ret == null)
{
return;
}
event.result = ret;
event.setResult(Result.ALLOW);
}
示例13: onFillBucket
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@SubscribeEvent
public void onFillBucket(FillBucketEvent event)
{
ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();
if(event.getResult() != Result.DENY && itemInHand.getItem() == TFCItems.woodenBucketEmpty)
{
if(event.result != null && event.result.getItem() == BuildCraftEnergy.bucketOil)
{
event.result = new ItemStack(TFPItems.CustomBucketOil);
}
}
}
示例14: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Event.Result.ALLOW);
}
示例15: onBucketFill
import net.minecraftforge.event.entity.player.FillBucketEvent; //導入依賴的package包/類
@SubscribeEvent
public void onBucketFill(FillBucketEvent event) {
ItemStack result = fillCustomBucket(event.world, event.target);
if (result == null)
return;
event.result = result;
event.setResult(Result.ALLOW);
}