本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock.setCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java RightClickBlock.setCanceled方法的具体用法?Java RightClickBlock.setCanceled怎么用?Java RightClickBlock.setCanceled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock
的用法示例。
在下文中一共展示了RightClickBlock.setCanceled方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRightClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
if (event.getWorld().isRemote) { return; }
if (Main.isPlayerInteractionAllowed()) { return; } // Not my business
Main.console("[TERRITORIAL DEALINGS] Block at x " + event.getPos().getX() + " / y " + event.getPos().getY() + " / z " + event.getPos().getZ() + " touched by player " + event.getEntityPlayer().getName() + ".");
Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(event.getPos());
if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer(), chunk)) // Checks out
{
Main.console("[TERRITORIAL DEALINGS] Player is allowed to interact with this chunk. Doing nothing.");
}
else
{
Main.console("[TERRITORIAL DEALINGS] Player is not allowed to interact with this chunk. Cancelling.");
event.setCanceled(true); // Not having it
}
}
示例2: onRightClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event)
{
if (event.getWorld().isRemote) { return; } // Not doing this on client side
if (!Main.shouldCheckInteraction()) { return; } // Not my business
Main.console("Block at x" + event.getPos().getX() + " y" + event.getPos().getY() + " z" + event.getPos().getZ() + " touched by player " + event.getEntityPlayer().getName() +
" (ID " + event.getEntityPlayer().getGameProfile().getId() + ").");
Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(event.getPos());
if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk)) // Checks out
{
Main.console("Player is allowed to interact with this chunk. Doing nothing.");
}
else
{
Main.console("Player is not allowed to interact with this chunk. Cancelling.");
event.setCanceled(true); // Not having it
}
}
示例3: 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);
}
}
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
}
示例10: 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));
}
}
示例11: 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);
}
}
}
示例12: onRightClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event){
if(event.getHand() == EnumHand.MAIN_HAND)
if(!event.getWorld().isRemote){
World world = event.getWorld();
TileEntity tileEntity = world.getTileEntity(event.getPos());
Block block = world.getBlockState(event.getPos()).getBlock();
if(PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.codebreaker) && handleCodebreaking(event)) {
event.setCanceled(true);
return;
}
if(tileEntity != null && tileEntity instanceof CustomizableSCTE && PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.universalBlockModifier)){
event.setCanceled(true);
if(!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())){
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), ClientUtils.localize("item.universalBlockModifier.name"), ClientUtils.localize("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().openGui(SecurityCraft.instance, GuiHandler.CUSTOMIZE_BLOCK, world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
return;
}
if(tileEntity instanceof INameable && ((INameable) tileEntity).canBeNamed() && PlayerUtils.isHoldingItem(event.getEntityPlayer(), Items.NAME_TAG) && event.getEntityPlayer().inventory.getCurrentItem().hasDisplayName()){
event.setCanceled(true);
for(String character : new String[]{"(", ")"})
if(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName().contains(character)) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", ClientUtils.localize("messages.naming.error").replace("#n", event.getEntityPlayer().inventory.getCurrentItem().getDisplayName()).replace("#c", character), TextFormatting.RED);
return;
}
if(((INameable) tileEntity).getCustomName().matches(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName())) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", ClientUtils.localize("messages.naming.alreadyMatches").replace("#n", ((INameable) tileEntity).getCustomName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().inventory.getCurrentItem().stackSize--;
((INameable) tileEntity).setCustomName(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName());
return;
}
if(tileEntity != null && isOwnableBlock(block, tileEntity) && PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.universalBlockRemover)){
event.setCanceled(true);
if(!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())){
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), ClientUtils.localize("item.universalBlockRemover.name"), ClientUtils.localize("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
if(block == SCContent.laserBlock){
world.destroyBlock(event.getPos(), true);
BlockLaserBlock.destroyAdjacentLasers(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
}else{
world.destroyBlock(event.getPos(), true);
world.removeTileEntity(event.getPos());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
}
}
}
}
示例13: onRightClickBlock
import net.minecraftforge.event.entity.player.PlayerInteractEvent.RightClickBlock; //导入方法依赖的package包/类
@SubscribeEvent
public void onRightClickBlock(RightClickBlock event){
if(event.getHand() == EnumHand.MAIN_HAND)
if(!event.getWorld().isRemote){
World world = event.getWorld();
TileEntity tileEntity = world.getTileEntity(event.getPos());
Block block = world.getBlockState(event.getPos()).getBlock();
if(PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.codebreaker) && handleCodebreaking(event)) {
event.setCanceled(true);
return;
}
if(tileEntity != null && tileEntity instanceof CustomizableSCTE && PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.universalBlockModifier)){
event.setCanceled(true);
if(!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())){
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), ClientUtils.localize("item.universalBlockModifier.name"), ClientUtils.localize("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().openGui(SecurityCraft.instance, GuiHandler.CUSTOMIZE_BLOCK, world, event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
return;
}
if(tileEntity instanceof INameable && ((INameable) tileEntity).canBeNamed() && PlayerUtils.isHoldingItem(event.getEntityPlayer(), Items.NAME_TAG) && event.getEntityPlayer().inventory.getCurrentItem().hasDisplayName()){
event.setCanceled(true);
for(String character : new String[]{"(", ")"})
if(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName().contains(character)) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", ClientUtils.localize("messages.naming.error").replace("#n", event.getEntityPlayer().inventory.getCurrentItem().getDisplayName()).replace("#c", character), TextFormatting.RED);
return;
}
if(((INameable) tileEntity).getCustomName().matches(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName())) {
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), "Naming", ClientUtils.localize("messages.naming.alreadyMatches").replace("#n", ((INameable) tileEntity).getCustomName()), TextFormatting.RED);
return;
}
event.getEntityPlayer().inventory.getCurrentItem().shrink(1);
((INameable) tileEntity).setCustomName(event.getEntityPlayer().inventory.getCurrentItem().getDisplayName());
return;
}
if(tileEntity != null && isOwnableBlock(block, tileEntity) && PlayerUtils.isHoldingItem(event.getEntityPlayer(), SCContent.universalBlockRemover)){
event.setCanceled(true);
if(!((IOwnable) tileEntity).getOwner().isOwner(event.getEntityPlayer())){
PlayerUtils.sendMessageToPlayer(event.getEntityPlayer(), ClientUtils.localize("item.universalBlockRemover.name"), ClientUtils.localize("messages.notOwned").replace("#", ((TileEntityOwnable) tileEntity).getOwner().getName()), TextFormatting.RED);
return;
}
if(block == SCContent.laserBlock){
world.destroyBlock(event.getPos(), true);
BlockLaserBlock.destroyAdjacentLasers(event.getWorld(), event.getPos().getX(), event.getPos().getY(), event.getPos().getZ());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
}else{
world.destroyBlock(event.getPos(), true);
world.removeTileEntity(event.getPos());
event.getEntityPlayer().inventory.getCurrentItem().damageItem(1, event.getEntityPlayer());
}
}
}
}