use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class TeleportTypeAsteroids method onSpaceDimensionChanged.
@Override
public void onSpaceDimensionChanged(World newWorld, EntityPlayerMP player, boolean ridingAutoRocket) {
if (!ridingAutoRocket && player != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
if (stats.getTeleportCooldown() <= 0) {
if (player.capabilities.isFlying) {
player.capabilities.isFlying = false;
}
if (!newWorld.isRemote) {
EntityEntryPod entryPod = new EntityEntryPod(player);
boolean previous = CompatibilityManager.forceLoadChunks((WorldServer) newWorld);
entryPod.forceSpawn = true;
newWorld.spawnEntity(entryPod);
CompatibilityManager.forceLoadChunksEnd((WorldServer) newWorld, previous);
}
stats.setTeleportCooldown(10);
}
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class TeleportTypeAsteroids method getPlayerSpawnLocation.
@Override
public Vector3 getPlayerSpawnLocation(WorldServer world, EntityPlayerMP player) {
if (player != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
int x = MathHelper.floor(stats.getCoordsTeleportedFromX());
int z = MathHelper.floor(stats.getCoordsTeleportedFromZ());
int limit = ConfigManagerCore.otherPlanetWorldBorders - 2;
if (limit > 20) {
if (x > limit) {
z *= limit / x;
x = limit;
} else if (x < -limit) {
z *= -limit / x;
x = -limit;
}
if (z > limit) {
x *= limit / z;
z = limit;
} else if (z < -limit) {
x *= -limit / z;
z = -limit;
}
}
int attemptCount = 0;
// Small pre-generate with a chunk loading radius of 3, to make sure some asteroids get generated
// (if the world is already generated here, this will be very quick)
this.preGenChunks(world, x >> 4, z >> 4);
do {
BlockVec3 bv3 = null;
if (world.provider instanceof WorldProviderAsteroids) {
bv3 = ((WorldProviderAsteroids) world.provider).getClosestAsteroidXZ(x, 0, z, true);
}
if (bv3 != null) {
// Check whether the returned asteroid is too far from the desired entry location in which case, give up
if (bv3.distanceSquared(new BlockVec3(x, 128, z)) > 25600) {
break;
}
if (ConfigManagerCore.enableDebug) {
GCLog.info("Testing asteroid at x" + (bv3.x) + " y" + (bv3.y) + " z" + bv3.z);
}
this.loadChunksAround(bv3.x, bv3.z, 2, world.getChunkProvider());
this.loadChunksAround(bv3.x, bv3.z, -3, world.getChunkProvider());
if (goodAsteroidEntry(world, bv3.x, bv3.y, bv3.z)) {
return new Vector3(bv3.x, 310, bv3.z);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z + 2);
}
if (goodAsteroidEntry(world, bv3.x + 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x + 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z - 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z - 2);
}
if (goodAsteroidEntry(world, bv3.x - 2, bv3.y, bv3.z + 2)) {
return new Vector3(bv3.x - 2, 310, bv3.z + 2);
}
// Failed to find an asteroid even though there should be one there
if (ConfigManagerCore.enableDebug) {
GCLog.info("Removing drilled out asteroid at x" + (bv3.x) + " z" + (bv3.z));
}
((WorldProviderAsteroids) world.provider).removeAsteroid(bv3.x, bv3.y, bv3.z);
}
attemptCount++;
} while (attemptCount < 5);
GCLog.info("Failed to find good large asteroid landing spot! Falling back to making a small one.");
this.makeSmallLandingSpot(world, x, z);
return new Vector3(x, 310, z);
}
GCLog.severe("Null player when teleporting to Asteroids!");
return new Vector3(0, 310, 0);
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class ItemAstroMiner method onItemUseFirst.
@Override
public EnumActionResult onItemUseFirst(EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
TileEntity tile = null;
if (playerIn == null) {
return EnumActionResult.PASS;
} else {
final Block id = worldIn.getBlockState(pos).getBlock();
if (id == GCBlocks.fakeBlock) {
tile = worldIn.getTileEntity(pos);
if (tile instanceof TileEntityMulti) {
tile = ((TileEntityMulti) tile).getMainBlockTile();
}
}
if (id == AsteroidBlocks.minerBaseFull) {
tile = worldIn.getTileEntity(pos);
}
if (tile instanceof TileEntityMinerBase) {
// Don't open GUI on client
if (worldIn.isRemote) {
return EnumActionResult.FAIL;
}
if (worldIn.provider instanceof WorldProviderSpaceStation) {
playerIn.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.message.astro_miner7.fail")));
return EnumActionResult.FAIL;
}
if (((TileEntityMinerBase) tile).getLinkedMiner() != null) {
playerIn.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.message.astro_miner.fail")));
return EnumActionResult.FAIL;
}
// Gives a chance for any loaded Astro Miner to link itself
if (((TileEntityMinerBase) tile).ticks < 15) {
return EnumActionResult.FAIL;
}
EntityPlayerMP playerMP = (EntityPlayerMP) playerIn;
GCPlayerStats stats = GCPlayerStats.get(playerIn);
int astroCount = stats.getAstroMinerCount();
if (astroCount >= ConfigManagerAsteroids.astroMinerMax && (!playerIn.capabilities.isCreativeMode)) {
playerIn.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.message.astro_miner2.fail")));
return EnumActionResult.FAIL;
}
if (!((TileEntityMinerBase) tile).spawnMiner(playerMP)) {
playerIn.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.message.astro_miner1.fail") + " " + GCCoreUtil.translate(EntityAstroMiner.blockingBlock.toString())));
return EnumActionResult.FAIL;
}
if (!playerIn.capabilities.isCreativeMode) {
stats.setAstroMinerCount(stats.getAstroMinerCount() + 1);
playerIn.getHeldItem(hand).shrink(1);
}
return EnumActionResult.SUCCESS;
}
}
return EnumActionResult.PASS;
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EntityAlienVillager method processInteract.
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand) {
ItemStack itemstack = player.inventory.getCurrentItem();
boolean flag = itemstack != null && itemstack.getItem() == Items.SPAWN_EGG;
if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking()) {
PlayerGearData gearData = GalacticraftCore.proxy.getGearData(player);
if (!this.world.isRemote && (this.buyingList == null || this.buyingList.size() > 0)) {
if (gearData != null && gearData.getFrequencyModule() != GCPlayerHandler.GEAR_NOT_PRESENT) {
this.setCustomer(player);
player.displayVillagerTradeGui(this);
} else {
if (player instanceof EntityPlayerMP) {
EntityPlayerMP playerMP = (EntityPlayerMP) player;
GCPlayerStats stats = GCPlayerStats.get(playerMP);
if (stats.getChatCooldown() == 0) {
player.sendMessage(new TextComponentString(GCCoreUtil.translate("gui.village.warning.no_freq_mod")));
stats.setChatCooldown(20);
}
}
}
}
player.addStat(StatList.TALKED_TO_VILLAGER);
return true;
} else {
return super.processInteract(player, hand);
}
}
use of micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats in project Galacticraft by micdoodle8.
the class EntityTier1Rocket method onTeleport.
@Override
public void onTeleport(EntityPlayerMP player) {
final EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayer(player, false);
if (playerBase != null) {
GCPlayerStats stats = GCPlayerStats.get(player);
if (this.stacks == null || this.stacks.isEmpty()) {
stats.setRocketStacks(NonNullList.withSize(2, ItemStack.EMPTY));
} else {
stats.setRocketStacks(this.stacks);
}
stats.setRocketType(this.rocketType.getIndex());
stats.setRocketItem(GCItems.rocketTier1);
stats.setFuelLevel(this.fuelTank.getFluidAmount());
}
}
Aggregations