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


Java RightClickBlock.getItemStack方法代码示例

本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock.getItemStack方法的典型用法代码示例。如果您正苦于以下问题:Java RightClickBlock.getItemStack方法的具体用法?Java RightClickBlock.getItemStack怎么用?Java RightClickBlock.getItemStack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock的用法示例。


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

示例1: checkBlockBannedEvent

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void checkBlockBannedEvent(RightClickBlock event)
{
	EntityPlayer player = event.getEntityPlayer();
	ItemStack currentStack = event.getItemStack();

	if (player.dimension == AetherConfig.getAetherDimensionID())
	{
		if (currentStack != null && (currentStack.getItem() == Items.FLINT_AND_STEEL || currentStack.getItem() == Item.getItemFromBlock(Blocks.TORCH) || currentStack.getItem() == Items.FIRE_CHARGE))
		{
			for (int i = 0; i < 10; ++i)
			{
				event.getWorld().spawnParticle(EnumParticleTypes.SMOKE_LARGE, event.getHitVec().xCoord, event.getHitVec().yCoord, event.getHitVec().zCoord, 0.0D, 0.0D, 0.0D, new int [] {});
			}

			event.setCanceled(true);

		}
		else if (event.getWorld().getBlockState(event.getPos()).getBlock() == Blocks.BED)
		{
			event.setCanceled(true);
		}
	}
}
 
开发者ID:Modding-Legacy,项目名称:Aether-Legacy,代码行数:25,代码来源:AetherEventHandler.java

示例2: rightClick

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
/** Makes portals if config. */
@SubscribeEvent
public void rightClick(RightClickBlock event) {

    EntityPlayer player = event.getEntityPlayer();
    World world = event.getWorld();
    ItemStack stack = event.getItemStack();
    Item item = stack.getItem();
    BlockPos pos = event.getPos();
    
    if (GeoConfig.compatibility.portals && item == GeoItems.FIREOPAL &&
            world instanceof WorldServer) {

        new Teleporter((WorldServer) world).makePortal(player);
        stack.shrink(1);
    }
    
    if (GeoConfig.compatibility.portals && item == GeoItems.AMETHYST) {
        
        Items.ENDER_EYE.onItemUse(player, world, pos,
                event.getHand(), event.getFace(), 0, 0, 0);
    }
}
 
开发者ID:JayAvery,项目名称:geomastery,代码行数:24,代码来源:BlockEvents.java

示例3: rightClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void rightClickBlock(RightClickBlock event) {
	if (event.getEntityPlayer().getEntityData().hasKey("renderViewCamera") && event.getItemStack() == null
			&& event.getSide().isClient() && event.getHand().equals(EnumHand.MAIN_HAND)) {
		System.out.println("RightClickBlock,HandType=" + event.getHand());
		ActiveTripod(Minecraft.getMinecraft().thePlayer.getName(),
				((EntityTripod) event.getWorld()
						.getEntityByID(event.getEntityPlayer().getEntityData().getInteger("renderViewCamera")))
								.getDelay());
		event.setCanceled(true);
	}
}
 
开发者ID:PorPit,项目名称:MineCamera,代码行数:14,代码来源:EventLoader.java

示例4: handleClickOnSnowable

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGH)
public void handleClickOnSnowable(RightClickBlock e) {
  if (e.getItemStack() == null || e.getItemStack().getItem() != Item.getItemFromBlock(Blocks.SNOW_LAYER))
    return;
    
  BlockPos pos = e.getPos().up();
  BlockPos posUnder = e.getPos();
  
  boolean result = handleClick(pos, posUnder, e.getWorld());
  if (result)
    e.setCanceled(result);
}
 
开发者ID:Reoseah,项目名称:shifted-snow,代码行数:13,代码来源:ModEventHandler.java

示例5: handleClickAtSnowableSide

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void handleClickAtSnowableSide(RightClickBlock e) {
  if (e.getItemStack() == null || e.getItemStack().getItem() != Item.getItemFromBlock(Blocks.SNOW_LAYER))
    return;
    
  BlockPos pos = e.getPos().offset(e.getFace()).up();
  BlockPos posUnder = e.getPos().offset(e.getFace());
  
  boolean result = handleClick(pos, posUnder, e.getWorld());
  if (result)
    e.setCanceled(result);
}
 
开发者ID:Reoseah,项目名称:shifted-snow,代码行数:13,代码来源:ModEventHandler.java

示例6: handleClickUnderSnowable

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void handleClickUnderSnowable(RightClickBlock e) {
  if (e.getItemStack() == null || e.getItemStack().getItem() != Item.getItemFromBlock(Blocks.SNOW_LAYER))
    return;
    
  BlockPos pos = e.getPos().up(2);
  BlockPos posUnder = e.getPos().up();
  
  boolean result = handleClick(pos, posUnder, e.getWorld());
  if (result)
    e.setCanceled(result);
}
 
开发者ID:Reoseah,项目名称:shifted-snow,代码行数:13,代码来源:ModEventHandler.java

示例7: handleClickOnSnow

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void handleClickOnSnow(RightClickBlock e) {
  if (e.getItemStack() == null || e.getItemStack().getItem() != Item.getItemFromBlock(Blocks.SNOW_LAYER))
    return;
    
  BlockPos pos = e.getPos();
  BlockPos posUnder = e.getPos().down();
  
  boolean result = handleClick(pos, posUnder, e.getWorld());
  if (result)
    e.setCanceled(result);
}
 
开发者ID:Reoseah,项目名称:shifted-snow,代码行数:13,代码来源:ModEventHandler.java

示例8: onRightClickBlock

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
/**
 * This event is fired on both sides whenever the player right clicks while targeting a block. This event controls which of {@link net.minecraft.block.Block#onBlockActivated} and/or
 * {@link net.minecraft.item.Item#onItemUse} will be called after {@link net.minecraft.item.Item#onItemUseFirst} is called. Canceling the event will cause none of the above three to be called. There
 * are various results to this event, see the getters below. Note that handling things differently on the client vs server may cause desynchronizations!
 */
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event) {
  //instanceof ItemBlockScaffolding 
  if (event.getItemStack() != null && event.getItemStack().getItem() == this && event.getEntityPlayer().isSneaking()) {
    EnumFacing opp = event.getFace().getOpposite();
    BlockPos dest = UtilWorld.nextReplaceableInDirection(event.getWorld(), event.getPos(), opp, 16, this.getBlock());
    this.onItemUse(event.getEntityPlayer(), event.getWorld(), dest, event.getHand(), opp, 0, 0, 0);
    event.setCanceled(true);
  }
}
 
开发者ID:PrinceOfAmber,项目名称:Cyclic,代码行数:16,代码来源:ItemBlockScaffolding.java

示例9: interact

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void interact(RightClickBlock event) {
    if(event.getSide() != Side.SERVER) return;

    World world = event.getWorld();
    BlockPos pos = event.getPos();

    IBlockState state = world.getBlockState(pos);
    if(state == null) return;
    if(!(state.getBlock() instanceof IRitualCore)) return;
    IRitualCore core = (IRitualCore)state.getBlock();
    pos = core.getRitualCorePosition(world, pos, state);
    if(!core.isRitualCore(world, pos, state)) return;

    ItemStack stack = event.getItemStack();
    if(stack == null) return;
    Item item = stack.getItem();
    if(item == Items.STICK) {

    } else if(item instanceof IWand) {

    } else {
        return;
    }

    event.setCanceled(true);
    event.setUseBlock(Result.DENY);

    List<EntityRitual> rituals = world.getEntitiesWithinAABB(EntityRitual.class, new AxisAlignedBB(pos));
    for(int i = 0; i < rituals.size(); i++) {
        RitualRecipeContainer c = rituals.get(i).getContainer();
        if(c != null && c.world == world && c.pos.equals(pos)) return; // There is already a ritual running here
    }

    IRitual ritual = findRitual(core, world, pos);
    if(ritual == null) return;

    Map<String, List<IInventory>> inventories = ritual.getInventories(core, world, pos);
    if(inventories.isEmpty()) return;
    HashBiMap<String, IRitualRecipe> recipes = RITUALS_RECIPES.get(ritual);
    IRitualRecipe recipe = findRitualRecipe(ritual, recipes.values(), inventories);
    if(recipe == null) return;

    int ticks = recipe.getDuration(ritual);
    if(ticks == -1) ticks = ritual.getDuration(recipe, core, world, pos);

    RitualRecipeContainer container = ritual.createContainer(recipe, core, world, pos, ticks, inventories, Side.SERVER);

    if(container != null) {
        world.spawnEntityInWorld(new EntityRitual(world, container));
    }
}
 
开发者ID:ExoMagica,项目名称:ExoMagica,代码行数:53,代码来源:RitualHandler.java

示例10: useFlintAndSteel

import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void useFlintAndSteel(RightClickBlock event) {
	if (event.getItemStack() == null || event.getItemStack().getItem() != Items.FLINT_AND_STEEL) {
		return;
	}

	BlockPos pos = event.getPos();

	int par4 = pos.getX();
	int par5 = pos.getY();
	int par6 = pos.getZ();

	int par7;

	if (event.getFace() == null) {
		par7 = 0;
	} else {
		par7 = event.getFace().getIndex();
	}

	if (par7 == 0) {
		par5--;
	}
	if (par7 == 1) {
		par5++;
	}
	if (par7 == 2) {
		par6--;
	}
	if (par7 == 3) {
		par6++;
	}
	if (par7 == 4) {
		par4--;
	}
	if (par7 == 5) {
		par4++;
	}

	Block i1 = getBlock(event.getWorld(), par4, par5, par6);
	if (i1 == Blocks.AIR) {
		boolean created = BlockTeletoryPortal.INSTANCE.trySpawnPortal(event.getWorld(), new BlockPos(par4, par5, par6));
		if (created) {
			event.setCanceled(true);
		}
	}
}
 
开发者ID:ToroCraft,项目名称:TeleToro,代码行数:48,代码来源:Teletory.java


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