本文整理匯總了Java中net.minecraftforge.common.util.FakePlayer類的典型用法代碼示例。如果您正苦於以下問題:Java FakePlayer類的具體用法?Java FakePlayer怎麽用?Java FakePlayer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
FakePlayer類屬於net.minecraftforge.common.util包,在下文中一共展示了FakePlayer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: work
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<BlockPos> blockPos = BlockUtils.getBlockPosInAABB(getWorkingArea());
boolean needsToIncrease = true;
if (pointer >= blockPos.size()) pointer = 0;
if (pointer < blockPos.size()) {
BlockPos pos = blockPos.get(pointer);
if (!this.world.isAirBlock(pos)) {
ItemStack stack = getFirstItem();
if (!stack.isEmpty()) {
FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
if (ItemDye.applyBonemeal(stack, this.world, pos, player, EnumHand.MAIN_HAND))
needsToIncrease = false;
}
}
} else {
pointer = 0;
}
if (needsToIncrease) ++pointer;
return 1;
}
示例2: work
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
List<BlockPos> blockPosList = BlockUtils.getBlockPosInAABB(getWorkingArea());
for (BlockPos pos : blockPosList) {
if (this.world.isAirBlock(pos)) {
ItemStack stack = getFirstStackHasBlock();
if (stack.isEmpty()) return 0;
if (this.world.isAirBlock(pos)) {
FakePlayer player = IndustrialForegoing.getFakePlayer(this.world);
player.setHeldItem(EnumHand.MAIN_HAND, stack);
EnumActionResult result = ForgeHooks.onPlaceItemIntoWorld(stack, player, world, pos, EnumFacing.UP, 0, 0, 0, EnumHand.MAIN_HAND);
return result == EnumActionResult.SUCCESS ? 1 : 0;
}
}
}
return 0;
}
示例3: work
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@Override
public float work() {
if (WorkUtils.isDisabled(this.getBlockType())) return 0;
AxisAlignedBB area = getWorkingArea();
List<EntityLiving> mobs = this.getWorld().getEntitiesWithinAABB(EntityLiving.class, area);
if (mobs.size() == 0) return 0;
FakePlayer player = IndustrialForegoing.getFakePlayer(world);
AtomicBoolean hasWorked = new AtomicBoolean(false);
mobs.stream().filter(entityLiving -> !hasAddon() || (!(entityLiving instanceof EntityAgeable) || !entityLiving.isChild())).forEach(entityLiving -> {
entityLiving.attackEntityFrom(DamageSource.causePlayerDamage(player), Integer.MAX_VALUE);
hasWorked.set(true);
});
List<EntityItem> items = this.getWorld().getEntitiesWithinAABB(EntityItem.class, area);
for (EntityItem item : items) {
if (!item.getItem().isEmpty()) {
ItemHandlerHelper.insertItem(outItems, item.getItem(), false);
item.setDead();
}
}
return hasWorked.get() ? 1 : 0;
}
示例4: callBlockBreakEvent
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
public static BlockBreakEvent callBlockBreakEvent(net.minecraft.world.World world, int x, int y, int z, net.minecraft.block.Block block, int blockMetadata, net.minecraft.entity.player.EntityPlayerMP player)
{
org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(x, y, z);
org.bukkit.event.block.BlockBreakEvent blockBreakEvent = new org.bukkit.event.block.BlockBreakEvent(bukkitBlock, ((EntityPlayerMP)player).getBukkitEntity());
EntityPlayerMP playermp = (EntityPlayerMP)player;
if (!(playermp instanceof FakePlayer))
{
if (!(playermp.theItemInWorldManager.getGameType().isAdventure() && !playermp.isCurrentToolAdventureModeExempt(x, y, z)) && !(playermp.theItemInWorldManager.getGameType().isCreative() && playermp.getHeldItem() != null && playermp.getHeldItem().getItem() instanceof ItemSword))
{
int exp = 0;
if (!(block == null || !player.canHarvestBlock(block) || // Handle empty block or player unable to break block scenario
block.canSilkHarvest(world, player, x, y, z, blockMetadata) && EnchantmentHelper.getSilkTouchModifier(player))) // If the block is being silk harvested, the exp dropped is 0
{
int meta = block.getDamageValue(world, x, y, z);
int bonusLevel = EnchantmentHelper.getFortuneModifier(player);
exp = block.getExpDrop(world, meta, bonusLevel);
}
blockBreakEvent.setExpToDrop(exp);
}
else blockBreakEvent.setCancelled(true);
}
world.getServer().getPluginManager().callEvent(blockBreakEvent);
return blockBreakEvent;
}
示例5: isFakePlayer
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
private boolean isFakePlayer(Entity entity) {
if (!(entity instanceof EntityPlayer)) {
return false;
}
if (entity instanceof FakePlayer) {
return true;
}
// If this returns false it is still possible we have a fake player. Try to find the player in the list of online players
PlayerList playerList = DimensionManager.getWorld(0).getMinecraftServer().getPlayerList();
EntityPlayerMP playerByUUID = playerList.getPlayerByUUID(((EntityPlayer) entity).getGameProfile().getId());
if (playerByUUID == null) {
// The player isn't online. Then it can't be real
return true;
}
// The player is in the list. But is it this player?
return entity != playerByUUID;
}
示例6: onLivingDropsEvent
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@SubscribeEvent
public static void onLivingDropsEvent(LivingDropsEvent event) {
if (ConfigHandler.dropMoney && !(event.getEntityLiving() instanceof EntityPlayer) && event.getEntityLiving() instanceof IMob && event.getEntityLiving().getEntityWorld().isRemote == false) {
if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityPlayer && !(event.getSource().getTrueSource() instanceof FakePlayer)) {
CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
return;
}
if (event.getSource().getTrueSource() != null && event.getSource().getTrueSource() != null && event.getSource().getTrueSource() instanceof EntityArrow) {
EntityArrow arrow = (EntityArrow) event.getSource().getTrueSource();
if (arrow.shootingEntity instanceof EntityPlayer && !(arrow.shootingEntity instanceof FakePlayer)) {
CurrencyUtils.dropMoneyAmount(event.getEntityLiving().getMaxHealth() / ConfigHandler.mobDivisionValue, event.getEntityLiving().getEntityWorld(), event.getEntityLiving().posX, event.getEntityLiving().posY, event.getEntityLiving().posZ);
return;
}
}
}
}
示例7: registerCapability
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@SubscribeEvent
public static void registerCapability(AttachCapabilitiesEvent<Entity> event) {
Entity obj = event.getObject();
if (obj instanceof EntityPlayer && !(obj instanceof FakePlayer)) {
EntityPlayer player = (EntityPlayer) obj;
AbstractPlayerDamageModel damageModel;
if (player.world.isRemote)
damageModel = FirstAid.activeDamageConfig == null ? PlayerDamageModel.createTemp() : PlayerDamageModel.create();
else {
FirstAid.activeDamageConfig = FirstAidConfig.damageSystem;
FirstAid.activeHealingConfig = FirstAidConfig.externalHealing;
FirstAid.scaleMaxHealth = FirstAidConfig.scaleMaxHealth;
damageModel = PlayerDamageModel.create();
}
event.addCapability(CapProvider.IDENTIFIER, new CapProvider(player, damageModel));
//replace the data manager with our wrapper to grab absorption
player.dataManager = new DataManagerWrapper(player, player.dataManager);
}
}
示例8: entityHurtEvent
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@SubscribeEvent
public void entityHurtEvent(LivingHurtEvent event) {
if (!EtFuturum.enableDmgIndicator)
return;
int amount = MathHelper.floor_float(Math.min(event.entityLiving.getHealth(), event.ammount) / 2F);
if (amount <= 0)
return;
// If the attacker is a player spawn the hearts aligned and facing it
if (event.source instanceof EntityDamageSource) {
EntityDamageSource src = (EntityDamageSource) event.source;
Entity attacker = src.getSourceOfDamage();
if (attacker instanceof EntityPlayer && !(attacker instanceof FakePlayer)) {
EntityPlayer player = (EntityPlayer) attacker;
Vec3 look = player.getLookVec();
look.rotateAroundY((float) Math.PI / 2);
for (int i = 0; i < amount; i++) {
double x = event.entityLiving.posX - amount * 0.35 * look.xCoord / 2 + i * 0.35 * look.xCoord;
double y = event.entityLiving.posY + 1.5 + event.entityLiving.worldObj.rand.nextGaussian() * 0.05;
double z = event.entityLiving.posZ - amount * 0.35 * look.zCoord / 2 + i * 0.35 * look.zCoord;
EtFuturum.networkWrapper.sendToAllAround(new BlackHeartParticlesMessage(x, y, z), new TargetPoint(player.worldObj.provider.dimensionId, x, y, z, 64));
}
}
}
}
示例9: checkSetTarget
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@SubscribeEvent
public void checkSetTarget(LivingSetAttackTargetEvent event) {
if (event.getTarget() == null)
return;
if (!(event.getTarget() instanceof EntityPlayer) || event.getTarget() instanceof FakePlayer)
return;
if (!(event.getEntity() instanceof EntityLiving))
return;
EntityPlayer player = (EntityPlayer)event.getTarget();
EntityLiving ent = (EntityLiving)event.getEntity();
boolean flag = player.inventory.armorInventory[2] != null && player.inventory.armorInventory[2].getItem() == UCItems.poncho && NBTUtils.getInt(player.inventory.armorInventory[2], ItemGeneric.TAG_UPGRADE, -1) == 10;
if (flag && ent.isNonBoss() && !(ent instanceof EntityGuardian || ent instanceof EntityShulker))
{
ent.setAttackTarget(null);
ent.setRevengeTarget(null);
}
}
示例10: onUpdate
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@Override
public void onUpdate(ItemStack stack, World world, Entity entity, int itemSlot, boolean isSelected) {
if (stack.getItemDamage() != 20)
return;
if (!(entity instanceof EntityPlayer) || (entity instanceof FakePlayer))
return;
if (itemSlot < ((EntityPlayer)entity).inventory.getHotbarSize()) {
List<EntityLiving> entities = entity.worldObj.getEntitiesWithinAABB(EntityLiving.class, new AxisAlignedBB(entity.getPosition().add(-range, -range, -range), entity.getPosition().add(range, range, range)));
for (EntityLiving ent : entities) {
List<EntityAITaskEntry> entries = new ArrayList(ent.tasks.taskEntries);
entries.addAll(new ArrayList(ent.targetTasks.taskEntries));
for (EntityAITaskEntry entry : entries) {
if (entry.action instanceof EntityAIAttackRangedBow) {
makeSkellyShootSlower((EntityAIAttackRangedBow)entry.action);
}
}
if (ent instanceof EntityCreeper)
ReflectionHelper.setPrivateValue(EntityCreeper.class, (EntityCreeper)ent, 60, this.FUSETIME);
}
}
}
示例11: PlantSapling
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
private void PlantSapling(World world, BlockPos blockPos, BlockPos originPos) {
Set<ItemStack> leafDrop = new HashSet<>();
BlockPos plantPos1 = new BlockPos(originPos.getX() - 1, originPos.getY(), originPos.getZ() - 1);
int counter = 0;
while (leafDrop.isEmpty() && counter <= 100) {
NonNullList<ItemStack> tmpList = NonNullList.create();
world.getBlockState(blockPos).getBlock().getDrops(tmpList, world, blockPos, world.getBlockState(blockPos), 3);
leafDrop.addAll(tmpList);
counter++;
}
if (leafDrop.isEmpty()) {
return;
}
FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer) world);
fakePlayer.setHeldItem(EnumHand.MAIN_HAND, leafDrop.iterator().next());
for (ItemStack itemStack : leafDrop) {
itemStack.onItemUse(fakePlayer, world, plantPos1, EnumHand.MAIN_HAND, EnumFacing.NORTH, 0, 0, 0);
}
}
示例12: doPlayerLastHit
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
public boolean doPlayerLastHit(final World world, final Entity target, final TileEntity tile) {
final FakePlayer fakePlayer = FakePlayerFactory.getMinecraft((WorldServer)world);
try {
final ItemStack stack = this.swordStack.copy();
if (tile instanceof TileEntityEnchantedSpike) {
stack.setTagCompound(((TileEntityEnchantedSpike)tile).getEnchantmentTagList());
}
fakePlayer.setCurrentItemOrArmor(0, stack);
boolean b = target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f);
fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null);
b |= target.attackEntityFrom(DamageSource.causePlayerDamage((EntityPlayer)fakePlayer), 400.0f);
b |= target.attackEntityFrom(DamageSource.cactus, 400.0f);
return b;
}
finally {
fakePlayer.setCurrentItemOrArmor(0, (ItemStack)null);
}
}
示例13: addPlayerHeads
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
public void addPlayerHeads(PlayerDropsEvent event){
EntityPlayer player = event.getEntityPlayer();
DamageSource source = event.getSource();
Entity attacker = source.getSourceOfDamage();
if(Config.playerHeadType == ItemDropType.NONE)return;
if(player == null || player.getEntityWorld() == null)return;
int rand = player.getEntityWorld().rand.nextInt(Math.max(Config.playerHeadDropChance / fixLooting(event.getLootingLevel()), 1));
if(Config.playerHeadDropChance < 0 || rand !=0)
return;
if(Config.playerHeadType == ItemDropType.KILLED){
if(attacker == null || !(attacker instanceof EntityPlayer) || attacker instanceof FakePlayer)
return;
}
ItemStack skull = PlayerUtil.createPlayerHead(player);
event.getDrops().add(ItemUtil.dropFromPlayer(player, skull, true));
}
示例14: onUpdate
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@Override
public void onUpdate(ItemStack tool, World world, Entity entity, int itemSlot, boolean isSelected) {
if (entity instanceof FakePlayer || entity.world.isRemote) {
return;
}
if (entity.ticksExisted % TICK_PER_STAT > 0) {
return;
}
NBTTagCompound tag = TagUtil.getExtraTag(tool);
Utils.GeneralNBTData data = Utils.GeneralNBTData.read(tag);
data.radius += random.nextFloat() * 0.5f;
if (data.radius >= 1) {
TagUtil.setEnchantEffect(tool, true);
}
data.write(tag);
TagUtil.setExtraTag(tool, tag);
}
示例15: onLivingAttackCallback
import net.minecraftforge.common.util.FakePlayer; //導入依賴的package包/類
@SubscribeEvent(priority = EventPriority.BOTTOM)
public void onLivingAttackCallback(LivingAttackEvent event) {
if (Always.isServer()) {
EntityLivingBase living = event.getEntityLiving(), attacker = event.getSource().getTrueSource() instanceof EntityLivingBase ?
(EntityLivingBase) event.getSource().getTrueSource() : null;
if (isEquipmented(living) && !(living instanceof EntityPlayer && ((EntityPlayer) living).isCreative())) {
living.getCombatTracker().lastDamageTime = living.ticksExisted;
if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(-1), (EntityPlayerMP) living);
}
if (attacker != null && isEquipmented(attacker)) {
attacker.setLastAttackedEntity(living);
if (living instanceof EntityPlayerMP && !(living instanceof FakePlayer))
AlchemyNetworkHandler.network_wrapper.sendTo(new MessageGuardCallback(living.getEntityId()), (EntityPlayerMP) attacker);
}
}
}