use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class ModelFlag method renderFlag.
public void renderFlag(EntityFlag entity, float ticks) {
if (entity.flagData != null) {
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
GL11.glTranslatef(0.0F, -1.1F, 0.0F);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glDisable(GL11.GL_CULL_FACE);
float windLevel = 1.0F;
if (entity.world.provider instanceof IGalacticraftWorldProvider) {
windLevel = ((IGalacticraftWorldProvider) entity.world.provider).getWindLevel();
}
for (int i = 0; i < entity.flagData.getWidth(); i++) {
for (int j = 0; j < entity.flagData.getHeight(); j++) {
GL11.glPushMatrix();
GL11.glTranslatef(0, -1.0F, 0);
float offset = 0.0F;
float offsetAhead = 0.0F;
if (windLevel > 0) {
offset = (float) (Math.sin(ticks / 2.0F + i * 50 + 3) / 25.0F) * i / 30.0F;
offsetAhead = (float) (Math.sin(ticks / 2.0F + (i + 1) * 50 + 3) / 25.0F) * (i + 1) / 30.0F;
offset *= windLevel;
offsetAhead *= windLevel;
}
Vector3 col = entity.flagData.getColorAt(i, j);
GL11.glColor3f(col.floatX(), col.floatY(), col.floatZ());
Tessellator tess = Tessellator.getInstance();
BufferBuilder worldRenderer = tess.getBuffer();
worldRenderer.begin(GL11.GL_TRIANGLES, DefaultVertexFormats.POSITION);
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
worldRenderer.pos(i / 24.0F + 0.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offset, offset).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 1.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
worldRenderer.pos(i / 24.0F + 1.0 / 24.0F, j / 24.0F + 0.0 / 24.0F + offsetAhead, offsetAhead).endVertex();
tess.draw();
GL11.glColor3f(1, 1, 1);
GL11.glPopMatrix();
}
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_CULL_FACE);
GL11.glPopMatrix();
}
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class WorldUtil method getArrayOfPossibleDimensions.
/**
* This will *load* all the GC dimensions which the player has access to (taking account of space station permissions).
* Loading the dimensions through Forge activates any chunk loaders or forced chunks in that dimension,
* if the dimension was not previously loaded. This may place load on the server.
*
* @param tier - the rocket tier to test
* @param playerBase - the player who will be riding the rocket (needed for checking space station permissions)
* @return a Map of the names of the dimension vs. the dimension IDs
*/
public static HashMap<String, Integer> getArrayOfPossibleDimensions(int tier, EntityPlayerMP playerBase) {
List<Integer> ids = WorldUtil.getPossibleDimensionsForSpaceshipTier(tier, playerBase);
final HashMap<String, Integer> map = new HashMap<>(ids.size(), 1F);
for (Integer id : ids) {
CelestialBody celestialBody = getReachableCelestialBodiesForDimensionID(id);
// It's a space station
if (id > 0 && celestialBody == null) {
celestialBody = GalacticraftCore.satelliteSpaceStation;
// This no longer checks whether a WorldProvider can be created, for performance reasons (that causes the dimension to load unnecessarily at map building stage)
if (playerBase != null) {
final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.world, id, null);
map.put(celestialBody.getName() + "$" + data.getOwner() + "$" + data.getSpaceStationName() + "$" + id + "$" + data.getHomePlanet(), id);
}
} else // It's a planet or moon
{
if (celestialBody == GalacticraftCore.planetOverworld) {
map.put(celestialBody.getName(), id);
} else {
WorldProvider provider = WorldUtil.getProviderForDimensionServer(id);
if (celestialBody != null && provider != null) {
if (provider instanceof IGalacticraftWorldProvider && !(provider instanceof IOrbitDimension) || GCCoreUtil.getDimensionID(provider) == 0) {
map.put(celestialBody.getName(), GCCoreUtil.getDimensionID(provider));
}
}
}
}
}
ArrayList<CelestialBody> cBodyList = new ArrayList<>();
cBodyList.addAll(GalaxyRegistry.getRegisteredPlanets().values());
cBodyList.addAll(GalaxyRegistry.getRegisteredMoons().values());
for (CelestialBody body : cBodyList) {
if (!body.getReachable()) {
map.put(body.getLocalizedName() + "*", body.getDimensionID());
}
}
WorldUtil.celestialMapCache.put(playerBase, map);
return map;
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class RoomChest method addComponentParts.
@Override
public boolean addComponentParts(World worldIn, Random rand, StructureBoundingBox boundingBox) {
if (CompatibilityManager.isSpongeLoaded() && generated)
return true;
if (super.addComponentParts(worldIn, rand, boundingBox)) {
int chestX = this.sizeX / 2;
int chestY = 1;
int chestZ = this.sizeZ / 2;
this.setBlockState(worldIn, Blocks.CHEST.getDefaultState().withProperty(BlockTier1TreasureChest.FACING, this.getDirection().getOpposite()), chestX, chestY, chestZ, boundingBox);
BlockPos blockpos = new BlockPos(this.getXWithOffset(chestX, chestZ), this.getYWithOffset(chestY), this.getZWithOffset(chestX, chestZ));
TileEntityChest chest = (TileEntityChest) worldIn.getTileEntity(blockpos);
if (chest != null) {
ResourceLocation chesttype = RoomTreasure.MOONCHEST;
if (worldIn.provider instanceof IGalacticraftWorldProvider) {
chesttype = ((IGalacticraftWorldProvider) worldIn.provider).getDungeonChestType();
}
chest.setLootTable(chesttype, rand.nextLong());
}
generated = true;
return true;
}
return false;
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class RoomTreasure method addComponentParts.
@Override
public boolean addComponentParts(World worldIn, Random random, StructureBoundingBox chunkBox) {
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) {
this.setBlockState(worldIn, this.configuration.getBrickBlock(), i, j, k, chunkBox);
} else {
this.setBlockState(worldIn, Blocks.AIR.getDefaultState(), i, j, k, chunkBox);
}
} 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, chunkBox);
} 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 (chunkBox.isVecInside(blockpos) || CompatibilityManager.isSpongeLoaded()) {
worldIn.setBlockState(blockpos, GCBlocks.treasureChestTier1.getDefaultState().withProperty(BlockTier1TreasureChest.FACING, this.getDirection().getOpposite()), 2);
TileEntityTreasureChest treasureChest = (TileEntityTreasureChest) worldIn.getTileEntity(blockpos);
if (treasureChest != null) {
ResourceLocation chesttype = TABLE_TIER_1_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, chunkBox);
}
}
}
}
return true;
}
use of micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider in project Galacticraft by micdoodle8.
the class RoomChestVenus method addComponentParts.
@Override
public boolean addComponentParts(World worldIn, Random rand, StructureBoundingBox boundingBox) {
if (super.addComponentParts(worldIn, rand, boundingBox)) {
int chestX = this.sizeX / 2;
int chestY = 1;
int chestZ = this.sizeZ / 2;
this.setBlockState(worldIn, Blocks.CHEST.getDefaultState().withProperty(BlockTier1TreasureChest.FACING, this.getDirection().getOpposite()), chestX, chestY, chestZ, boundingBox);
BlockPos blockpos = new BlockPos(this.getXWithOffset(chestX, chestZ), this.getYWithOffset(chestY), this.getZWithOffset(chestX, chestZ));
TileEntityChest chest = (TileEntityChest) worldIn.getTileEntity(blockpos);
if (chest != null) {
ResourceLocation chesttype = RoomTreasureVenus.VENUSCHEST;
if (worldIn.provider instanceof IGalacticraftWorldProvider) {
chesttype = ((IGalacticraftWorldProvider) worldIn.provider).getDungeonChestType();
}
chest.setLootTable(RoomTreasureVenus.VENUSCHEST, rand.nextLong());
}
return true;
}
return false;
}
Aggregations