use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project MorePlanets by SteveKunG.
the class ItemSpaceWarperCore method onItemRightClick.
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer player, EnumHand hand) {
ItemStack itemStack = player.getHeldItem(hand);
if (!player.world.isRemote) {
if (player.isSneaking()) {
if (GCCoreUtil.getDimensionID(world) == 0 || world.provider instanceof IGalacticraftWorldProvider) {
if (!itemStack.hasTagCompound()) {
itemStack.setTagCompound(new NBTTagCompound());
itemStack.getTagCompound().setInteger("DimensionID", GCCoreUtil.getDimensionID(world));
itemStack.getTagCompound().setString("DimensionName", WorldUtil.getProviderForDimensionServer(GCCoreUtil.getDimensionID(world)).getDimensionType().getName());
itemStack.getTagCompound().setInteger("X", MathHelper.floor(player.posX));
itemStack.getTagCompound().setInteger("Y", MathHelper.floor(player.posY));
itemStack.getTagCompound().setInteger("Z", MathHelper.floor(player.posZ));
itemStack.getTagCompound().setFloat("Pitch", player.rotationPitch);
itemStack.getTagCompound().setFloat("Yaw", player.rotationYaw);
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add.message")));
return new ActionResult<>(EnumActionResult.SUCCESS, itemStack);
} else {
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.warp_core_data_add_fail.message")));
}
} else {
player.sendMessage(JsonUtils.create(LangUtils.translate("gui.space_dimension_only.message")).setStyle(JsonUtils.red()));
}
}
}
return new ActionResult<>(EnumActionResult.PASS, itemStack);
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project MorePlanets by SteveKunG.
the class EntitySpaceFishHook method handleHookRetraction.
@Override
public int handleHookRetraction() {
if (!this.world.isRemote && this.angler != null) {
int i = 0;
if (this.caughtEntity != null) {
this.bringInHookedEntity();
this.world.setEntityState(this, (byte) 31);
i = this.caughtEntity instanceof EntityItem ? 3 : 5;
} else if (this.ticksCatchable > 0) {
LootContext.Builder lootBuilder = new LootContext.Builder((WorldServer) this.world);
lootBuilder.withLuck(this.luck + this.angler.getLuck());
double x = MathHelper.floor(this.posX);
double y = MathHelper.floor(this.getEntityBoundingBox().minY) + 1.0F;
double z = MathHelper.floor(this.posZ);
Block block = this.world.getBlockState(new BlockPos(x, y - 1, z)).getBlock();
ResourceLocation resource = block instanceof IFishableLiquidBlock ? ((IFishableLiquidBlock) block).getLootTable() : this.world.provider instanceof IGalacticraftWorldProvider ? MPLootTables.SPACE_FISHING : LootTableList.GAMEPLAY_FISHING;
for (ItemStack itemStack : this.world.getLootTableManager().getLootTableFromLocation(resource).generateLootForPools(this.rand, lootBuilder.build())) {
EntityItem entityItem = new EntityItem(this.world, this.posX, this.posY, this.posZ, itemStack);
double d0 = this.angler.posX - this.posX;
double d1 = this.angler.posY - this.posY;
double d2 = this.angler.posZ - this.posZ;
double d3 = MathHelper.sqrt(d0 * d0 + d1 * d1 + d2 * d2);
entityItem.motionX = d0 * 0.1D;
entityItem.motionY = d1 * 0.1D + MathHelper.sqrt(d3) * 0.08D;
entityItem.motionZ = d2 * 0.1D;
this.world.spawnEntity(entityItem);
this.angler.world.spawnEntity(new EntityXPOrb(this.angler.world, this.angler.posX, this.angler.posY + 0.5D, this.angler.posZ + 0.5D, this.rand.nextInt(6) + 1));
Item item = itemStack.getItem();
if (item == Items.FISH || item == Items.COOKED_FISH) {
this.angler.addStat(StatList.FISH_CAUGHT, 1);
}
}
i = 1;
}
if (this.inGround) {
i = 2;
}
this.setDead();
return i;
} else {
return 0;
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class AsteroidsEventHandlerClient method onClientTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientTick(ClientTickEvent event) {
Minecraft minecraft = Minecraft.getMinecraft();
WorldClient world = minecraft.world;
if (world != null) {
if (world.provider instanceof WorldProviderAsteroids) {
if (world.provider.getSkyRenderer() == null) {
world.provider.setSkyRenderer(new SkyProviderAsteroids((IGalacticraftWorldProvider) world.provider));
}
if (world.provider.getCloudRenderer() == null) {
world.provider.setCloudRenderer(new CloudRenderer());
}
}
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class RoomTreasureVenus method addComponentParts.
@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox boundingBox) {
for (int i = 0; i <= this.sizeX; i++) {
for (int j = 0; j <= this.sizeY; j++) {
for (int k = 0; k <= this.sizeZ; k++) {
if (i == 0 || i == this.sizeX || j == 0 || j == this.sizeY || k == 0 || k == this.sizeZ) {
boolean placeBlock = true;
if (getDirection().getAxis() == EnumFacing.Axis.Z) {
int start = (this.boundingBox.maxX - this.boundingBox.minX) / 2 - 1;
int end = (this.boundingBox.maxX - this.boundingBox.minX) / 2 + 1;
if (i > start && i <= end && j < 3 && j > 0) {
if (getDirection() == EnumFacing.SOUTH && k == 0) {
placeBlock = false;
} else if (getDirection() == EnumFacing.NORTH && k == this.sizeZ) {
placeBlock = false;
}
}
} else {
int start = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 - 1;
int end = (this.boundingBox.maxZ - this.boundingBox.minZ) / 2 + 1;
if (k > start && k <= end && j < 3 && j > 0) {
if (getDirection() == EnumFacing.EAST && i == 0) {
placeBlock = false;
} else if (getDirection() == EnumFacing.WEST && i == this.sizeX) {
placeBlock = false;
}
}
}
if (placeBlock) {
DungeonConfigurationVenus venusConfig = (DungeonConfigurationVenus) this.configuration;
this.setBlockState(worldIn, j == 0 || j == this.sizeY ? venusConfig.getBrickBlockFloor() : this.configuration.getBrickBlock(), i, j, k, boundingBox);
} else {
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
}
} else if ((i == 1 && k == 1) || (i == 1 && k == this.sizeZ - 1) || (i == this.sizeX - 1 && k == 1) || (i == this.sizeX - 1 && k == this.sizeZ - 1)) {
this.setBlockState(worldIn, Blocks.GLOWSTONE.getDefaultState(), i, j, k, boundingBox);
} else if (i == this.sizeX / 2 && j == 1 && k == this.sizeZ / 2) {
BlockPos blockpos = new BlockPos(this.getXWithOffset(i, k), this.getYWithOffset(j), this.getZWithOffset(i, k));
if (boundingBox.isVecInside(blockpos)) {
worldIn.setBlockState(blockpos, VenusBlocks.treasureChestTier3.getDefaultState().withProperty(BlockTier3TreasureChest.FACING, this.getDirection().getOpposite()), 2);
TileEntityTreasureChest treasureChest = (TileEntityTreasureChest) worldIn.getTileEntity(blockpos);
if (treasureChest != null) {
ResourceLocation chesttype = TABLE_TIER_3_DUNGEON;
if (worldIn.provider instanceof IGalacticraftWorldProvider) {
chesttype = ((IGalacticraftWorldProvider) worldIn.provider).getDungeonChestType();
}
treasureChest.setLootTable(chesttype, random.nextLong());
}
}
} else {
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, boundingBox);
}
}
}
}
return true;
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class TransformerHooks method getGravityForEntity.
public static double getGravityForEntity(Entity entity) {
if (entity.world.provider instanceof IGalacticraftWorldProvider) {
if (entity instanceof EntityChicken && !OxygenUtil.isAABBInBreathableAirBlock(entity.world, entity.getEntityBoundingBox())) {
return 0.08D;
}
final IGalacticraftWorldProvider customProvider = (IGalacticraftWorldProvider) entity.world.provider;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
if (player.inventory != null) {
int armorModLowGrav = 100;
int armorModHighGrav = 100;
for (ItemStack armorPiece : player.getArmorInventoryList()) {
if (armorPiece != null && armorPiece.getItem() instanceof IArmorGravity) {
armorModLowGrav -= ((IArmorGravity) armorPiece.getItem()).gravityOverrideIfLow(player);
armorModHighGrav -= ((IArmorGravity) armorPiece.getItem()).gravityOverrideIfHigh(player);
}
}
if (armorModLowGrav > 100) {
armorModLowGrav = 100;
}
if (armorModHighGrav > 100) {
armorModHighGrav = 100;
}
if (armorModLowGrav < 0) {
armorModLowGrav = 0;
}
if (armorModHighGrav < 0) {
armorModHighGrav = 0;
}
if (customProvider.getGravity() > 0) {
return 0.08D - (customProvider.getGravity() * armorModLowGrav) / 100;
}
return 0.08D - (customProvider.getGravity() * armorModHighGrav) / 100;
}
}
return 0.08D - customProvider.getGravity();
} else if (entity instanceof IAntiGrav) {
return 0;
} else {
return 0.08D;
}
}
Aggregations