本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.isCreative方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.isCreative方法的具体用法?Java EntityPlayer.isCreative怎么用?Java EntityPlayer.isCreative使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.isCreative方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removedByPlayer
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean removedByPlayer(IBlockState state, World world, BlockPos pos, EntityPlayer player, boolean willHarvest) {
if (player.isCreative()) {
if (!world.isRemote) {
// Drop any contained items here (but don't drop the block itself as an item; this is creative mode)
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityBase) {
NonNullList<ItemStack> drops = NonNullList.create();
((TileEntityBase) te).getAllDrops(drops);
drops.forEach(stack -> PneumaticCraftUtils.dropItemOnGround(stack, world, pos.getX(), pos.getY(), pos.getZ()));
}
}
return super.removedByPlayer(state, world, pos, player, false);
} else {
// This delays harvesting until after getDrops() is called, giving getDrops() a chance to serialize any TE
// data onto the itemstack. harvestBlock() must also be overridden to remove the block (see below)
return willHarvest || super.removedByPlayer(state, world, pos, player, false);
}
}
示例2: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
boolean isReplacing = worldIn.getBlockState(pos).getBlock().equals(ModBlocks.ritual_glyphs) && worldIn.getBlockState(pos).getValue(BlockCircleGlyph.TYPE) != GlyphType.GOLDEN;
if (!worldIn.isRemote && (facing == EnumFacing.UP && ModBlocks.ritual_glyphs.canPlaceBlockAt(worldIn, pos.up()) || isReplacing)) {
ItemStack chalk = player.getHeldItem(hand);
if (!chalk.hasTagCompound()) {
chalk.setTagCompound(new NBTTagCompound());
chalk.getTagCompound().setInteger("usesLeft", MAX_USES);
}
int type = chalk.getItemDamage();
if (!player.isCreative()) {
int usesLeft = chalk.getTagCompound().getInteger("usesLeft") - 1;
chalk.getTagCompound().setInteger("usesLeft", usesLeft);
if (usesLeft < 1) chalk.setCount(0);
}
IBlockState state = ModBlocks.ritual_glyphs.getExtendedState(ModBlocks.ritual_glyphs.getDefaultState(), worldIn, pos);
state = state.withProperty(BlockCircleGlyph.FACING, EnumFacing.HORIZONTALS[(int) (Math.random() * 4)]);
state = state.withProperty(BlockCircleGlyph.TYPE, BlockCircleGlyph.GlyphType.values()[type]);
worldIn.setBlockState(isReplacing ? pos : pos.up(), state, 2);
worldIn.playSound(null, pos, WitchSoundEvents.CHALK_SCRIBBLE, SoundCategory.BLOCKS, 0.5f, 1f + 0.5f * player.getRNG().nextFloat());
}
return super.onItemUse(player, worldIn, pos, hand, facing, hitX, hitY, hitZ);
}
示例3: processInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
if (!(player.getHeldItemMainhand() != null
&& player.getHeldItemMainhand().getItem() instanceof ItemMonsterPlacerPlus)
&& (this.getOwner() == player || this.getAttackTarget() == null || this.friendly) && this.isEntityAlive() && !this.isTrading()
&& !this.isChild() && !player.isSneaking()) {
if (this.world.isRemote && player.getTeam() == null
&& ((this.getCapability(TF2weapons.WEAPONS_CAP, null).state & 1) == 0 || this.friendly)
&& !player.isCreative())
ClientProxy.displayScreenConfirm("Choose a team to interact",
"Visit the Mann Co. Store located in a village");
if (!this.world.isRemote && (TF2Util.isOnSameTeam(this, player) || player.isCreative())
&& (this.tradeOffers == null || !this.tradeOffers.isEmpty())) {
this.setCustomer(player);
FMLNetworkHandler.openGui(player, TF2weapons.instance, 4, world, this.getEntityId(), 0, 0);
}
player.addStat(StatList.TALKED_TO_VILLAGER);
return true;
} else
return super.processInteract(player, hand);
}
示例4: processInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
if (!(player.getHeldItemMainhand() != null
&& player.getHeldItemMainhand().getItem() instanceof ItemMonsterPlacerPlus)
&& this.getAttackTarget() == null && this.isEntityAlive() && !this.isTrading() && !this.isChild()
&& !player.isSneaking()) {
if (this.world.isRemote && player.getTeam() == null && !player.isCreative())
ClientProxy.displayScreenJoinTeam();
else if (!this.world.isRemote && (player.getTeam() != null || player.isCreative())
&& (this.tradeOffers == null || !this.tradeOffers.isEmpty())) {
this.setCustomer(player);
player.displayVillagerTradeGui(this);
}
player.addStat(StatList.TALKED_TO_VILLAGER);
return true;
} else
return super.processInteract(player, hand);
}
示例5: onItemUse
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if(!worldIn.isRemote && player.isCreative() && worldIn.getMinecraftServer().getPlayerList().canSendCommands(player.getGameProfile())) {
IBlockState clicked = worldIn.getBlockState(pos);
Block block = clicked.getBlock();
if(block.equals(BlocksMM.blockController)) {
PlayerStructureSelectionHelper.finalizeSelection(clicked.getValue(BlockController.FACING), worldIn, pos, player);
PlayerStructureSelectionHelper.purgeSelection(player);
PlayerStructureSelectionHelper.sendSelection(player);
} else {
PlayerStructureSelectionHelper.toggleInSelection(player, pos);
PlayerStructureSelectionHelper.sendSelection(player);
}
}
return EnumActionResult.SUCCESS;
}
示例6: onStarted
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onStarted(EntityPlayer player, IRitualHandler tile, World world, BlockPos pos, NBTTagCompound data) {
ItemStack chalk = player.getHeldItemOffhand();
data.setInteger("chalkType", chalk.getMetadata());
if (!player.isCreative()) {
int usesLeft = chalk.getTagCompound().getInteger("usesLeft") - coords.size();
chalk.getTagCompound().setInteger("usesLeft", usesLeft);
if (usesLeft < 1)
chalk.setCount(0);
}
player.setHeldItem(EnumHand.OFF_HAND, chalk);
}
示例7: isValid
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean isValid(EntityPlayer player, World world, BlockPos pos, List<ItemStack> recipe) {
for (int[] rc : coords) {
BlockPos pos2 = pos.add(rc[0], 0, rc[1]);
if (!world.isAirBlock(pos2) && !world.getBlockState(pos2).getBlock().isReplaceable(world, pos2) && world.getBlockState(pos2).getBlock() != ModBlocks.ritual_glyphs)
return false;
}
return player.getHeldItemOffhand().getItem() == ModItems.ritual_chalk && player.getHeldItemOffhand().getMetadata() != 1 && (player.isCreative() || player.getHeldItemOffhand().getTagCompound().getInteger("usesLeft") >= coords.size());
}
示例8: canPlayerSilkHarvestChest
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean canPlayerSilkHarvestChest(TileEntity te, EntityPlayer player) {
if (!Mods.IRONCHESTS.isLoaded()) {
return false;
}
BlockPos pos = te.getPos();
Block block = te.getWorld() == null ? null : te.getWorld().getBlockState(pos).getBlock();
return te != null && block != null && isIronChest(block) && player != null && player.getHeldItemMainhand() != null && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0 && !player.isCreative();
}
示例9: onItemUseFirst
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
if (!world.isRemote) {
ItemStack held = player.getHeldItem(hand);
if (player.isSneaking())
return EnumActionResult.PASS;
if (held != ItemStack.EMPTY && held.getItem() instanceof ItemUpgrade) {
if (held.getMetadata() == 0) {
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockDisplacer)
if (!state.getValue(BlockDisplacer.FILTER)) {
state = state.withProperty(BlockDisplacer.FILTER, true);
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileDisplacer) {
if (!((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
((TileDisplacer) world.getTileEntity(pos)).setHasFilter(true);
((TileDisplacer) world.getTileEntity(pos)).markDirty();
PacketHandler.sendToAll(new PacketDisplacerSync(((TileDisplacer) world.getTileEntity(pos)), true));
}
}
}
world.setBlockState(pos, state, 3);
world.notifyBlockUpdate(pos, state, state, 3);
if (!player.isCreative())
player.getHeldItem(hand).splitStack(1);
}
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
示例10: onBlockActivated
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
if (!world.isRemote) {
ItemStack held = player.getHeldItem(hand);
if (player.isSneaking()) {
if (state.getValue(FILTER) && ((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
state = state.withProperty(FILTER, false);
world.setBlockState(pos, state);
if (world.getTileEntity(pos) != null && world.getTileEntity(pos) instanceof TileDisplacer) {
((TileDisplacer) world.getTileEntity(pos)).setHasFilter(false);
((TileDisplacer) world.getTileEntity(pos)).markDirty();
PacketHandler.sendToAll(new PacketDisplacerSync(((TileDisplacer) world.getTileEntity(pos)), false));
if (!player.isCreative())
InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), new ItemStack(SimpleTubes.proxy.itemUpgrade, 1, 0));
}
}
return true;
} else {
if (!(held.getItem() instanceof ItemUpgrade) || held == ItemStack.EMPTY) {
if (((TileDisplacer) world.getTileEntity(pos)).hasFilter()) {
player.openGui(SimpleTubes.instance, 0, world, pos.getX(), pos.getY(), pos.getZ());
return true;
}
}
}
}
return true;
}
示例11: onItemRightClick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn,
EnumHand hand) {
ItemStack itemStackIn = playerIn.getHeldItem(hand);
ItemStack backpack = getBackpack(playerIn);
if (!backpack.isEmpty() && (backpack.getTagCompound().getFloat("Rage") >= 1 || playerIn.isCreative())) {
playerIn.setActiveHand(hand);
if (TF2Util.getTeamForDisplay(playerIn) == 1)
playerIn.playSound(ItemFromData.getSound(backpack, PropertyType.HORN_BLU_SOUND), 0.8f, 1f);
else
playerIn.playSound(ItemFromData.getSound(backpack, PropertyType.HORN_RED_SOUND), 0.8f, 1f);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, itemStackIn);
}
return new ActionResult<ItemStack>(EnumActionResult.FAIL, itemStackIn);
}
示例12: onArmorTick
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void onArmorTick(World world, final EntityPlayer player, ItemStack itemStack) {
if (!world.isRemote) {
if (player.ticksExisted % 20 == 0) {
float heal = TF2Attribute.getModifier("Health Regen", itemStack, 0, player);
if(heal > 0) {
int lastHitTime = player.ticksExisted - player.getEntityData().getInteger("lasthit");
if (lastHitTime >= 120)
player.heal(heal);
else if(lastHitTime >= 60)
player.heal(TF2Util.lerp(heal, heal/4f, (lastHitTime-60)/60f));
else
player.heal(heal/4f);
}
}
if (player.ticksExisted % 5 == 0 && itemStack.getTagCompound().getBoolean("Active")) {
itemStack.getTagCompound().setFloat("Rage",
Math.max(0,
itemStack.getTagCompound().getFloat("Rage")
- 1 / (TF2Attribute.getModifier("Buff Duration", itemStack,
getData(itemStack).getInt(PropertyType.DURATION), player) - 20)));
if (itemStack.getTagCompound().getFloat("Rage") <= 0)
itemStack.getTagCompound().setBoolean("Active", false);
for (EntityLivingBase living : world.getEntitiesWithinAABB(EntityLivingBase.class,
player.getEntityBoundingBox().grow(10, 10, 10), new Predicate<EntityLivingBase>() {
@Override
public boolean apply(EntityLivingBase input) {
// TODO Auto-generated method stub
return TF2Util.isOnSameTeam(player, input);
}
}))
living.addPotionEffect(new PotionEffect(this.getBuff(itemStack), 25));
}
if (player.isCreative())
itemStack.getTagCompound().setFloat("Rage", 1);
}
}
示例13: onLeftClickEntity
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
if(!player.isCreative()) return super.onLeftClickEntity(stack, player, entity);
if(entity instanceof EntityLivingBase) ((EntityLivingBase)entity).onDeath(DamageSource.causePlayerDamage(player));
entity.setDead(); // bypasses all invulerabilities
return false; // bypass the damaging mechanic
}
示例14: canTakeStack
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Return whether this slot's stack can be taken from this slot.
*/
@Override
public boolean canTakeStack(EntityPlayer playerIn) {
ItemStack itemstack = this.getStack();
return itemstack != ItemStack.EMPTY && !playerIn.isCreative() ? false : super.canTakeStack(playerIn);
}
示例15: canPlayerSilkHarvestChest
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public static boolean canPlayerSilkHarvestChest(TileEntity te, EntityPlayer player) {
BlockPos pos = te.getPos();
Block block = te.getWorld() == null ? null : te.getWorld().getBlockState(pos).getBlock();
return te != null && block != null && ChestUtils.isVanillaChest(block, false) && player != null && player.getHeldItemMainhand() != null && EnchantmentHelper.getEnchantmentLevel(Enchantments.SILK_TOUCH, player.getHeldItemMainhand()) > 0 && !player.isCreative();
}