本文整理匯總了Java中net.minecraftforge.event.world.BlockEvent.BreakEvent.getPlayer方法的典型用法代碼示例。如果您正苦於以下問題:Java BreakEvent.getPlayer方法的具體用法?Java BreakEvent.getPlayer怎麽用?Java BreakEvent.getPlayer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraftforge.event.world.BlockEvent.BreakEvent
的用法示例。
在下文中一共展示了BreakEvent.getPlayer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: apply
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@Override
public boolean apply(final BreakEvent evt) {
if(!evt.isCanceled() && (evt.block instanceof MachineVending || evt.block instanceof MachineVendingTop)) {
// Do the check only if player is non-OP
if(!evt.getPlayer().capabilities.isCreativeMode) {
int baseY = evt.y;
if(evt.block instanceof MachineVendingTop)
baseY--;
final TileEntity te = evt.world.getTileEntity(evt.x, baseY, evt.z);
if(te instanceof VendingTileEntity) {
final VendingTileEntity vending = (VendingTileEntity) te;
if(!vending.okToBreak(evt.getPlayer()))
evt.setCanceled(true);
}
}
}
return true;
}
示例2: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent(priority = EventPriority.LOWEST)
public void onBreakEvent(BreakEvent event) {
World world = event.getWorld();
EntityPlayer player = event.getPlayer();
if (player == null) {
return;
}
BlockPos pos = event.getPos();
int level = this.getCurrentLevelTool(player);
if (level <= 0) {
return;
}
Block block = event.getState().getBlock();
int xpDropped = block.getExpDrop(event.getState(), world, pos, 0);
int bonus = xpDropped * XP_PER_LVL * level;
UtilExperience.incrementExp(player, bonus);
// dropExp(world, pos, xpDropped * XP_PER_LVL * level);
}
示例3: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
* tile entity data saved to item stack
*
* @param event
*/
@SubscribeEvent
public static void onBreakEvent(BreakEvent event) {
if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
return;
} // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
TileEntity ent = world.getTileEntity(pos);
if (ent != null && ent instanceof TileEntityWirelessTr) {
TileEntityWirelessTr t = (TileEntityWirelessTr) ent;
ItemStack stack = new ItemStack(state.getBlock());
if (t.getTargetPos() != null)
UtilNBT.setItemStackBlockPos(stack, t.getTargetPos());
// saveTileDataToStack(stack, t);
UtilItemStack.dropItemStackInWorld(world, pos, stack);
}
}
示例4: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
if (event.getPlayer() != null && event.getPlayer().capabilities.isCreativeMode) {
return;
} // dont drop in creative https://github.com/PrinceOfAmber/Cyclic/issues/93
World world = event.getWorld();
BlockPos pos = event.getPos();
IBlockState state = event.getState();
TileEntity ent = world.getTileEntity(pos);
if (ent != null && ent instanceof TileEntityVector) {
TileEntityVector t = (TileEntityVector) ent;
ItemStack stack = new ItemStack(state.getBlock());
saveTileDataToStack(stack, t);
UtilItemStack.dropItemStackInWorld(world, pos, stack);
}
}
示例5: onBlockBreak
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBlockBreak(BreakEvent event){
EntityPlayer player = event.getPlayer();
if (player != null) {
ItemStack stack = player.getHeldItemMainhand();
if (stack != null) {
Item item = stack.getItem();
if (item instanceof grappleBow || item instanceof multiBow) {
event.setCanceled(true);
return;
}
}
}
this.blockbreak(event);
}
示例6: mineOutEverything
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
public void mineOutEverything(int[][] locations, BreakEvent event)
{
EntityPlayer player = event.getPlayer();
ItemStack current = player.getCurrentEquippedItem();
for (int i = 0; i < locations.length; i++)
{
int curX = event.x + locations[i][0];
int curY = event.y + locations[i][1];
int curZ = event.z + locations[i][2];
Block miningBlock = event.world.getBlock(curX, curY, curZ);
int meta = event.world.getBlockMetadata(curX, curY, curZ);
if (canHarvestBlock(player, event.block, miningBlock, meta, curX, curY, curZ))
{
if (!((ItemTool) current.getItem()).onBlockStartBreak(current, curX, curY, curZ, player))
{
mineBlock(event.world, curX, curY, curZ, meta, player, miningBlock);
((ItemTool) current.getItem()).onBlockDestroyed(current, event.world, miningBlock, curX, curY, curZ, player);
player.addExhaustion((float) 0.025);
}
}
}
}
示例7: mineGrass
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
public void mineGrass(int[][] blocks, BreakEvent event)
{
EntityPlayer player = event.getPlayer();
ItemStack current = player.getCurrentEquippedItem();
for (int i = 0; i < blocks.length; i++)
{
Block currentBlock = event.world.getBlock(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
int currentMeta = event.world.getBlockMetadata(event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2]);
if (canHoeHarvest(currentBlock))
{
mineBlock(event.world, event.x + blocks[i][0], event.y + blocks[i][1], event.z + blocks[i][2], currentMeta, player, currentBlock);
current.damageItem(1, player);
if (current.getItemDamage() >= current.getMaxDamage())
{
return;
}
}
}
}
示例8: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
Side side = FMLCommonHandler.instance().getEffectiveSide();
if (side != Side.SERVER) return;
if (event.getPlayer() instanceof EntityPlayerMP) {
EntityPlayerMP thePlayer = (EntityPlayerMP) event.getPlayer();
List<MocapAction> aList = Mocap.instance
.getActionListForPlayer(thePlayer);
if (aList != null) {
MocapAction ma = new MocapAction(
MocapActionTypes.BREAKBLOCK);
ma.xCoord = event.x;
ma.yCoord = event.y;
ma.zCoord = event.z;
aList.add(ma);
}
}
}
示例9: onHarvest
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onHarvest(BreakEvent event) {
if (event.getPlayer() == null) {
return;
}
Province provinceFarmedIn = loadProvince(event.getPlayer().world, event.getPos());
if (provinceFarmedIn == null || provinceFarmedIn.civilization == null) {
return;
}
handleFarmQuest(event.getPlayer(), provinceFarmedIn, event.getState().getBlock(), false);
}
示例10: harvest
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void harvest(BreakEvent event) {
if (!ToroQuestConfiguration.cropsAffectRep) {
return;
}
if (event.getPlayer() == null) {
return;
}
if (isCrop(event.getState().getBlock())) {
BlockPos pos = event.getPos();
adjustPlayerRep(event.getPlayer(), pos.getX() / 16, pos.getZ() / 16, -getFarmRepAmount(event.getWorld().rand));
}
}
示例11: enderPearlTeleport
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void enderPearlTeleport(BreakEvent ev) {
if(ev.getPlayer() == null || ev.getPlayer().isCreative()){
return;
}
if (ev.getState().getBlock() == BlockTeletoryPortal.INSTANCE || ev.getState().getBlock() == BlockLinkedTeletoryPortal.INSTANCE) {
ev.setCanceled(true);
}
}
示例12: onPlayerBreaksBlock
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
/**
* Event listener for Action.BREAK_BLOCK
*/
@SubscribeEvent
public void onPlayerBreaksBlock(BreakEvent event)
{
EntityPlayer player = event.getPlayer();
List<Action> events = CommonProxy.manager.getActions(player);
if (!player.worldObj.isRemote && events != null && player.isCreative())
{
events.add(new BreakBlockAction(event.getPos(), false));
}
}
示例13: mineGooeyBlocks
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void mineGooeyBlocks(BreakEvent event) {
if (processing.get() != null) return;
EntityPlayer p = event.getPlayer();
if (!(p instanceof EntityPlayerMP)) return;
EntityPlayerMP player = (EntityPlayerMP) p;
boolean creative = player.capabilities.isCreativeMode;
ItemStack held = player.getHeldItem();
if (held == null && !creative) return;
MovingObjectPosition mop = getMovingObjectPositionFromPlayer(player.worldObj, player, false);
if (mop == null) return;
for (int slot = 0; slot < 9; slot++) {
ItemStack is = ItemUtil.normalize(player.inventory.getStackInSlot(slot));
if (is == null || is.getItem() != this) continue;
GooData data = GooData.getNullGooData(is, player.worldObj);
if (data == null) continue;
for (int i = 0; i < data.coords.length; i += 3) {
if (eq(data.coords, i, mop.getBlockPos())) {
processing.set(true);
try {
mineSelection(is, data, player.worldObj, mop, player, held);
} finally {
processing.remove();
}
return;
}
}
}
}
示例14: playerBreakBlock
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void playerBreakBlock(BreakEvent event) {
if (event.world.isRemote)
return;
EntityPlayer player = event.getPlayer();
if (isPlayerFake(player))
return;
int fortune = EnchantmentHelper.getFortuneModifier(player);
String name = event.state.getBlock().getUnlocalizedName();
boolean harvest = false;
List<ItemStack> stacks = event.state.getBlock().getDrops(event.world, event.pos, event.state, fortune);
if (stacks.size() == 1) {
ItemStack stack = stacks.get(0);
Item item = stack.getItem();
if (item == null)
;
else if (item instanceof ItemBlock) {
ItemBlock ib = (ItemBlock) item;
Block b = ib.block;
harvest = b != event.state.getBlock();
}
else
harvest = true;
}
else
harvest = stacks.size() != 0;
if (name.startsWith("tile."))
name = name.substring(5);
if (!harvest)
PlayerResearchHelper.progressResearch(player, "block.break." + name, 1, true);
else
PlayerResearchHelper.progressResearch(player, "block.harvest." + name, 1, true);
}
示例15: onBreakEvent
import net.minecraftforge.event.world.BlockEvent.BreakEvent; //導入方法依賴的package包/類
@SubscribeEvent
public void onBreakEvent(BreakEvent event) {
EntityPlayer player = event.getPlayer();
if(CoreClaim.claimManager.checkEventCancel(event.getPlayer(), event.x, event.z)) {
Utils.messageToPlayer(player, EnumChatFormatting.RED + "Oh snap, you are not allowed to break this!");
event.setCanceled(true);
}
}