本文整理汇总了Java中net.minecraftforge.event.entity.player.PlayerInteractEvent.getResult方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerInteractEvent.getResult方法的具体用法?Java PlayerInteractEvent.getResult怎么用?Java PlayerInteractEvent.getResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.event.entity.player.PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent.getResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBlockPlaced
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onBlockPlaced(PlayerInteractEvent event)
{
if (event.entityPlayer.worldObj.isRemote)
return;
ItemStack itemInHand = event.entityPlayer.getCurrentEquippedItem();
if(itemInHand == null)
return;
if(event.action == Action.RIGHT_CLICK_BLOCK && event.getResult() != Result.DENY)
{
if(Loader.isModLoaded("Steamcraft"))
{
if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.boiler) && ConfigSettings.FSPBoilerWaterFix)
{
event.setCanceled(true);
handleBlockPlacement(event.entityPlayer, event.entityLiving, event.world, TFPBlocks.tweakedboiler, event.x, event.y, event.z, event.face);
}
else if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(SteamcraftBlocks.flashBoiler) && ConfigSettings.FSPFlashBoilerWaterFix)
{
event.setCanceled(true);
switch(event.face)
{
case 0: PlaceBlock(event.entityLiving, event.world, event.x, event.y - 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
case 1: PlaceBlock(event.entityLiving, event.world, event.x, event.y + 1, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
case 2: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z - 1, TFPBlocks.tweakedFlashBoiler, 0); break;
case 3: PlaceBlock(event.entityLiving, event.world, event.x, event.y, event.z + 1, TFPBlocks.tweakedFlashBoiler, 0); break;
case 4: PlaceBlock(event.entityLiving, event.world, event.x - 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
case 5: PlaceBlock(event.entityLiving, event.world, event.x + 1, event.y, event.z, TFPBlocks.tweakedFlashBoiler, 0); break;
default: break;
}
if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
event.entityPlayer.setCurrentItemOrArmor(0, null);
else
event.entityPlayer.getCurrentEquippedItem().stackSize--;
}
}
if(event.entityPlayer.getCurrentEquippedItem().getItem() == Item.getItemFromBlock(Blocks.chest))
{
event.setCanceled(true);
if(event.entityPlayer.getCurrentEquippedItem().stackSize == 1)
event.entityPlayer.setCurrentItemOrArmor(0, null);
else
event.entityPlayer.getCurrentEquippedItem().stackSize--;
}
}
}
示例2: onPlayerTriesToPlaceBucket
import net.minecraftforge.event.entity.player.PlayerInteractEvent; //导入方法依赖的package包/类
@SubscribeEvent
public void onPlayerTriesToPlaceBucket(PlayerInteractEvent e) {
if (e.action != PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK)
return;
if (e.entityPlayer.dimension != IaSFlags.dim_nyx_id || !e.entityPlayer.capabilities.isCreativeMode)
return;
if (e.entityPlayer.getEquipmentInSlot(0) == null)
return;
final Item itid = e.entityPlayer.getEquipmentInSlot(0).getItem();
if (itid == Items.lava_bucket || itid == Items.water_bucket) {
e.getResult();
if (e.action != Action.RIGHT_CLICK_BLOCK)
return;
int x = e.x;
int y = e.y;
int z = e.z;
switch (e.face) {
case 0:
--y;
break;
case 1:
++y;
break;
case 2:
--z;
break;
case 3:
++z;
break;
case 4:
--x;
break;
case 5:
++x;
break;
default:
break;
}
e.useItem = Result.DENY;
e.entityPlayer.setCurrentItemOrArmor(0, new ItemStack(Items.bucket));
if (itid == Items.lava_bucket) {
e.entityPlayer.worldObj.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, "random.fizz", 0.5F, 2.6F
+ (e.entityPlayer.worldObj.rand.nextFloat() - e.entityPlayer.worldObj.rand.nextFloat()) * 0.8F);
e.entityPlayer.worldObj.setBlock(x, y, z, Blocks.obsidian, 0, 0x2);
} else if (itid == Items.water_bucket) {
e.entityPlayer.worldObj.setBlock(x, y, z, Blocks.ice, 0, 0x2);
}
}
}