本文整理汇总了Java中net.minecraftforge.common.util.FakePlayerFactory.get方法的典型用法代码示例。如果您正苦于以下问题:Java FakePlayerFactory.get方法的具体用法?Java FakePlayerFactory.get怎么用?Java FakePlayerFactory.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraftforge.common.util.FakePlayerFactory
的用法示例。
在下文中一共展示了FakePlayerFactory.get方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
@Override
public void update() {
super.update();
if (!world.isRemote) {
TileEntityMobSpawner te = getTileEntity();
if(te != null){
MobSpawnerBaseLogic spawnerLogic = te.getSpawnerBaseLogic();
//Only tick the logic if it wasn't ticked already by the TE itself, to prevent double ticking.
if(!Reflections.isActivated(spawnerLogic)){
//Temporarily add a fake player to the world to trick the spawner into thinking there's a player nearby
EntityPlayer fakePlayer = FakePlayerFactory.get((WorldServer)world, FAKE_PLAYER_PROFILE);
fakePlayer.posX = getPos().getX();
fakePlayer.posY = getPos().getY();
fakePlayer.posZ = getPos().getZ();
world.playerEntities.add(fakePlayer);
spawnerLogic.updateSpawner();
world.playerEntities.remove(fakePlayer);
}
}
}
}
示例2: BreakBlock
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public static boolean BreakBlock(World worldObj, BlockPos pos, Entity player) {
IBlockState state = worldObj.getBlockState(pos);
EntityPlayer passedPlayer;
if (player instanceof EntityPlayer) {
passedPlayer = (EntityPlayer) player;
} else {
passedPlayer = FakePlayerFactory.get((WorldServer) worldObj, Reference.gameProfile);
}
BlockEvent.BreakEvent breakEvent = new BlockEvent.BreakEvent(worldObj, pos, state, passedPlayer);
MinecraftForge.EVENT_BUS.post(breakEvent);
if (breakEvent.isCanceled()) {
return false;
}
worldObj.getBlockState(pos).getBlock().dropBlockAsItem(worldObj, pos, state, 0);
// TODO add block break sound
worldObj.setBlockToAir(pos);
return true;
}
示例3: initFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public static WeakReference<FakePlayer> initFakePlayer(WorldServer ws, UUID uname, String blockName) {
GameProfile breakerProfile = new GameProfile(uname, Const.MODID + ".fake_player." + blockName);
WeakReference<FakePlayer> fakePlayer;
try {
fakePlayer = new WeakReference<FakePlayer>(FakePlayerFactory.get(ws, breakerProfile));
}
catch (Exception e) {
ModCyclic.logger.error("Exception thrown trying to create fake player : " + e.getMessage());
fakePlayer = null;
}
if (fakePlayer == null || fakePlayer.get() == null) {
fakePlayer = null;
return null; // trying to get around https://github.com/PrinceOfAmber/Cyclic/issues/113
}
fakePlayer.get().onGround = true;
fakePlayer.get().connection = new NetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.SERVERBOUND), fakePlayer.get()) {
@SuppressWarnings("rawtypes")
@Override
public void sendPacket(Packet packetIn) {}
};
fakePlayer.get().setSilent(true);
return fakePlayer;
}
示例4: getHarvester
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public static FakePlayer getHarvester() {
if (harvester == null) {
harvester = FakePlayerFactory.get(DimensionManager.getWorld(0), new GameProfile(new UUID(656, 123), "meecreps"));
}
// @todo config, make it possible to specify lesser pickaxe in config
harvester.setHeldItem(EnumHand.MAIN_HAND, new ItemStack(Items.DIAMOND_PICKAXE));
return harvester;
}
示例5: getFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public static final FakePlayer getFakePlayer() {
if (player == null) {
player = FakePlayerFactory.get(DimensionManager.getWorld(0), new GameProfile(UUID.randomUUID(), "RoyTheMiner"));
LogUtils.info("Created fake player: " + player.getUniqueID() + " - " + player.getName());
}
return player;
}
示例6: getCrystalMod
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
private static FakePlayer getCrystalMod(WorldServer world)
{
FakePlayer ret = CRYSTALMOD_PLAYER != null ? CRYSTALMOD_PLAYER.get() : null;
if (ret == null)
{
ret = FakePlayerFactory.get(world, CRYSTALMOD);
CRYSTALMOD_PLAYER = new WeakReference<FakePlayer>(ret);
}
return ret;
}
示例7: getFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
@Nonnull
public FakePlayer getFakePlayer(@Nonnull WorldServer world) {
FakePlayer player = fakePlayer.get();
if (player == null) {
player = FakePlayerFactory.get(world, fakePlayerProfile);
fakePlayer = new WeakReference<>(player);
}
return player;
}
示例8: createNewPlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
private static WeakReference<EntityPlayer> createNewPlayer(
final WorldServer world, final int x, final int y, final int z) {
final EntityPlayer player = FakePlayerFactory.get(world, profile);
player.posX = x;
player.posY = y;
player.posZ = z;
return new WeakReference<EntityPlayer>(player);
}
示例9: getPlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
@Nonnull
private FakePlayer getPlayer()
{
if (this.fakePlayer == null)
{
int dim = this.getWorld().provider.getDimension();
this.fakePlayer = FakePlayerFactory.get((WorldServer) this.getWorld(),
new GameProfile(new UUID(dim, dim), Reference.MOD_ID + ":drawbridge"));
}
return this.fakePlayer;
}
示例10: getFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
private EntityPlayer getFakePlayer() {
return FakePlayerFactory.get((WorldServer) getWorld(), new GameProfile(null, "Sentry Turret"));
}
示例11: killNextEntity
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public boolean killNextEntity() {
if (getWorld().isRemote) return false;
if (fakePlayer == null){
fakePlayer = FakePlayerFactory.get((WorldServer) getWorld(), GRINDER);
}
killList = getWorld().getEntitiesWithinAABB(EntityLiving.class, getKillBox());
DamageSource playerSource = DamageSource.causePlayerDamage(fakePlayer);
if (killList.size() > 0) {
for(EntityLiving mob : killList){
boolean riddenByPlayer = mob.getRecursivePassengersByType(EntityPlayer.class).size() > 0;
if (!mob.isDead && mob.deathTime <= 0 && !mob.isEntityInvulnerable(playerSource) && mob.hurtResistantTime == 0 && !riddenByPlayer) {
if (mob instanceof EntityZombie) {
zBlocker.cache.add((EntityZombie) mob);
}
//if (this.attackTool == null) {
//this.attackTool = new ItemStack(Items.DIAMOND_SWORD);
/*final ItemStack enchantsStack = this.enchants.getStack();
if (enchantsStack != null) {
EnchantmentHelper.setEnchantments(EnchantmentHelper.getEnchantments(enchantsStack), this.attackTool);
}*/
//}
/*ItemStack prev = fakePlayer.getHeldItemMainhand();
fakePlayer.setHeldItem(EnumHand.MAIN_HAND, attackTool);
if(prev !=null)fakePlayer.getAttributeMap().removeAttributeModifiers(prev.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
if(attackTool !=null)fakePlayer.getAttributeMap().applyAttributeModifiers(attackTool.getAttributeModifiers(EntityEquipmentSlot.MAINHAND));
//fakePlayer.setPosition(mob.posX, mob.posY, mob.posZ);
float oldHealth = mob.getHealth();
this.fakePlayer.attackTargetEntityWithCurrentItem(mob);
fakePlayer.resetCooldown();
ModLogger.info("Attack2: "+(oldHealth-mob.getHealth()) + " "+fakePlayer.getHeldItemMainhand());
this.fakePlayer.setHeldItem(EnumHand.MAIN_HAND, (ItemStack)null);
*/
mob.attackEntityFrom(playerSource, 50000F);
readyNext = true;
return mob.isDead || mob.getHealth() <= 0;
}
}
}
readyNext = false;
return false;
}
示例12: getFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public static FakePlayer getFakePlayer(World world) {
if (world instanceof WorldServer) {
return FakePlayerFactory.get((WorldServer) world, profile);
} else
return null;
}
示例13: updateEntity
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
public void updateEntity() {
if (worldObj.isRemote) return;
int dim = 3 + getDimensionUpgrades() * 2; // tier 2 is 3 + 2*4 = 11 (11x11xtoBedrock)
int blocksPerTick = getSpeedUpgrades();
if (miningAtX == Integer.MIN_VALUE || miningAtY == Integer.MIN_VALUE || miningAtZ == Integer.MIN_VALUE) {
miningAtX = xCoord - dim / 2;
miningAtY = yCoord - 1;
miningAtZ = zCoord - dim / 2;
}
if (fp == null && worldObj instanceof WorldServer) {
fp = FakePlayerFactory.get((WorldServer) worldObj, new GameProfile(UUID.randomUUID(), "[EnderAmmunition]"));
}
if (miningAtY <= 1) return;
// TODO: energy consumption (taking eff and unbrk in account)
Map<Enchantment, Integer> enchantmentMap = getEnchantmentMap();
boolean silk = enchantmentMap.containsKey(Enchantment.silkTouch);
int fortune = enchantmentMap.containsKey(Enchantment.fortune) ? enchantmentMap.get(Enchantment.fortune) : 0;
int efficiencyDivider = enchantmentMap.containsKey(Enchantment.efficiency) ? enchantmentMap.get(Enchantment.efficiency) + 1 : 1;
int energyConsumption = RF_PER_BLOCK / efficiencyDivider;
if (storage.getEnergyStored() < energyConsumption * blocksPerTick) return;
TileEntity inventory = getInventoryAround();
boolean removeBulk = hasRemoveBulkUpgrade();
while (blocksPerTick >= 0) {
miningAtX++;
//miningAtZ++;
if (miningAtX >= xCoord + dim / 2) {
miningAtX = xCoord - dim / 2;
miningAtZ++;
}
if (miningAtZ >= zCoord + dim / 2) {
miningAtZ = zCoord - dim / 2;
miningAtY--;
}
Block blockToMine = worldObj.getBlock(miningAtX, miningAtY, miningAtZ);
// skip air (like caves) + skip unminable blocks
if (blockToMine == Blocks.air || blockToMine.getBlockHardness(worldObj, miningAtX, miningAtY, miningAtZ) < 0) {
continue;
}
List<ItemStack> drops = removeBlock(fp, worldObj, miningAtX, miningAtY, miningAtZ, fortune, silk);
if (drops == null) {
continue;
} else {
storage.extractEnergy(energyConsumption, false);
}
if (removeBulk) {
List<ItemStack> clearedDrops = Lists.newArrayList();
for (ItemStack d : drops) {
boolean remove = false;
for (ItemStack b : bulkItems) {
if (b.getItem() == d.getItem() && b.getItemDamage() == d.getItemDamage()) {
remove = true;
break;
}
}
if (!remove)
clearedDrops.add(d);
}
drops = clearedDrops;
}
if (inventory == null) {
dropAway(drops);
} else {
List<ItemStack> leftover = tryToInsertToInventory(drops, inventory);
if (leftover != null) dropAway(leftover);
}
sendParticlePacket();
blocksPerTick--;
}
}
示例14: getFakePlayer
import net.minecraftforge.common.util.FakePlayerFactory; //导入方法依赖的package包/类
private EntityPlayer getFakePlayer(){
return FakePlayerFactory.get((WorldServer)worldObj, new GameProfile(null, "Sentry Turret"));
}