epic 1.6.2 update

+ Air generators
+ Improved sphere generation
+ Gas blocks
+ Hyper space
+ New bugs and glitches!
This commit is contained in:
Anus 2013-07-24 01:37:21 +04:00
parent a23becf173
commit 352941f648
29 changed files with 3455 additions and 1266 deletions

View file

@ -0,0 +1,262 @@
package cr0s.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockAir extends Block
{
private final boolean TRANSPARENT_AIR = true;
protected BlockAir(int par1)
{
super(par1, Material.air);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isAirBlock(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4)
{
return null;
}
@Override
public boolean isBlockReplaceable(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public boolean canCollideCheck(int var1, boolean var2)
{
return false;
}
@Override
public int getRenderBlockPass()
{
return TRANSPARENT_AIR ? 1 : 0;
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
this.blockIcon = par1IconRegister.registerIcon("warpdrive:airBlock");
}
@Override
public int getMobilityFlag()
{
return 1;
}
@Override
public int idDropped(int var1, Random var2, int var3)
{
return -1;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
/**
* How many world ticks before ticking
*/
@Override
public int tickRate(World par1World)
{
return 20;
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World par1World, int x, int y, int z, Random par5Random)
{
int concentration = par1World.getBlockMetadata(x, y, z);
boolean isInSpaceWorld = par1World.provider.dimensionId == WarpDrive.instance.spaceDimID || par1World.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID;
// Remove air block to vacuum block
if (concentration <= 0 || !isInSpaceWorld) {
//System.out.println("Killing air block");
par1World.setBlock(x, y, z, 0, 0, 2); // replace our air block to vacuum block
} else {
//System.out.println("Conc: current " + concentration + " new: " + (concentration - 1) + " to spread: " + (concentration - 2));
// Try to spread the air
spreadAirBlock(par1World, x, y, z, concentration);
}
par1World.scheduleBlockUpdate(x, y, z, this.blockID, 20);
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID)
{
return false;
}
else
{
final int i = par1IBlockAccess.getBlockId(par2, par3, par4);
boolean var6 = false;
if (Block.blocksList[i] != null)
{
var6 = !Block.blocksList[i].isOpaqueCube();
}
final boolean var7 = i == 0;
if ((var6 || var7) && par5 == 3 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 4 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 5 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 2 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 0 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 1 && !var6)
{
return true;
}
else
{
return false;
}
}
}
private void spreadAirBlock(World worldObj, int x, int y, int z, int concentration) {
if (concentration <= 0) {
return;
}
int mid_concentration;
int block_count = 1;
final int K = 128;
mid_concentration = worldObj.getBlockMetadata(x, y, z) * K;
if(worldObj.isAirBlock(x + 1, y, z)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x + 1, y, z) * K;
}
if(worldObj.isAirBlock(x - 1, y, z)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x - 1, y, z) * K;
}
if(worldObj.isAirBlock(x, y + 1, z)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x, y + 1, z) * K;
}
if(worldObj.isAirBlock(x, y - 1, z)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x, y - 1, z) * K;
}
if(worldObj.isAirBlock(x, y, z + 1)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x, y, z + 1) * K;
}
if(worldObj.isAirBlock(x, y, z - 1)){
block_count++;
mid_concentration += worldObj.getBlockMetadata(x, y, z - 1) * K;
}
mid_concentration = mid_concentration / block_count;
SetAirBlockConcentration(worldObj, x, y, z, mid_concentration / K);
if(worldObj.isAirBlock(x + 1, y, z) && (mid_concentration>worldObj.getBlockMetadata(x+1, y, z) * K)){
SetAirBlockConcentration(worldObj, x+1, y, z, mid_concentration / K);
}
if(worldObj.isAirBlock(x - 1, y, z) && (mid_concentration>worldObj.getBlockMetadata(x-1, y, z) * K)){
SetAirBlockConcentration(worldObj, x-1, y, z, mid_concentration / K);
}
if(worldObj.isAirBlock(x, y + 1, z) && (mid_concentration>worldObj.getBlockMetadata(x, y+1, z) * K)){
SetAirBlockConcentration(worldObj, x, y + 1, z, mid_concentration / K);
}
if(worldObj.isAirBlock(x, y - 1, z) && (mid_concentration>worldObj.getBlockMetadata(x, y-1, z) * K)){
SetAirBlockConcentration(worldObj, x, y - 1, z, mid_concentration / K);
}
if(worldObj.isAirBlock(x, y, z + 1) && (mid_concentration>worldObj.getBlockMetadata(x, y, z+1) * K)){
SetAirBlockConcentration(worldObj, x, y, z + 1, mid_concentration / K);
}
if(worldObj.isAirBlock(x, y, z - 1) && (mid_concentration>worldObj.getBlockMetadata(x, y, z-1) * K)){
SetAirBlockConcentration(worldObj, x, y, z - 1, mid_concentration / K);
}
}
private void SetAirBlockConcentration(World worldObj, int x, int y, int z, int concentration) {
worldObj.setBlock(x, y, z, this.blockID, concentration, 2);
}
@Override
public boolean func_82506_l()
{
return false;
}
/**
* Returns if this block is collidable. Args: x, y, z
*/
@Override
public boolean isCollidable()
{
return false;
}
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
if (par1World.provider.dimensionId == WarpDrive.instance.spaceDimID)
{
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate(par1World));
} else
{
par1World.setBlockToAir(par2, par3, par4);
}
}
}

View file

@ -0,0 +1,97 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
public class BlockAirGenerator extends BlockContainer {
private Icon[] iconBuffer;
private final int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_SIDE_ACTIVATED = 2;
public BlockAirGenerator(int id, int texture, Material material) {
super(id, material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
iconBuffer = new Icon[3];
iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:airgenSideInactive");
iconBuffer[ICON_BOTTOM] = par1IconRegister.registerIcon("warpdrive:contBottom");
iconBuffer[ICON_SIDE_ACTIVATED] = par1IconRegister.registerIcon("warpdrive:airgenSideActive");
}
@Override
public Icon getIcon(int side, int metadata)
{
if (side == 0) {
return iconBuffer[ICON_BOTTOM];
} else
if (side == 1) {
if (metadata == 0) {
return iconBuffer[ICON_INACTIVE_SIDE];
} else {
return iconBuffer[ICON_SIDE_ACTIVATED];
}
}
if (metadata == 0) // Inactive state
{
return iconBuffer[ICON_INACTIVE_SIDE];
} else if (metadata == 1) {
return iconBuffer[ICON_SIDE_ACTIVATED];
}
return null;
}
@Override
public TileEntity createNewTileEntity(World var1) {
return new TileEntityAirGenerator();
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 1;
}
/**
* Returns the ID of the items to drop on destruction.
*/
@Override
public int idDropped(int par1, Random par2Random, int par3)
{
return this.blockID;
}
@Override
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return false;
}
TileEntityAirGenerator gen = (TileEntityAirGenerator)par1World.getBlockTileEntity(par2, par3, par4);
if (gen != null){
par5EntityPlayer.addChatMessage("[AirGen] Energy level: " + gen.getCurrentEnergyValue() + " Eu");
}
return true;
}
}

View file

@ -0,0 +1,184 @@
package cr0s.WarpDrive;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
public class BlockGas extends Block
{
private Icon[] gasIcons;
protected BlockGas(int par1)
{
super(par1, Material.air);
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public boolean isAirBlock(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public AxisAlignedBB getCollisionBoundingBoxFromPool(World var1, int var2, int var3, int var4)
{
return null;
}
@Override
public boolean isBlockReplaceable(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public boolean canPlaceBlockAt(World var1, int var2, int var3, int var4)
{
return true;
}
@Override
public boolean canCollideCheck(int var1, boolean var2)
{
return false;
}
@Override
public int getRenderBlockPass()
{
return 1; // transparency enabled
}
@Override
public void registerIcons(IconRegister par1IconRegister)
{
gasIcons = new Icon[12];
gasIcons[0] = par1IconRegister.registerIcon("warpdrive:gasBlockBlue");
gasIcons[1] = par1IconRegister.registerIcon("warpdrive:gasBlockRed");
gasIcons[2] = par1IconRegister.registerIcon("warpdrive:gasBlockGreen");
gasIcons[3] = par1IconRegister.registerIcon("warpdrive:gasBlockYellow");
gasIcons[4] = par1IconRegister.registerIcon("warpdrive:gasBlockDark");
gasIcons[5] = par1IconRegister.registerIcon("warpdrive:gasBlockDarkness");
gasIcons[6] = par1IconRegister.registerIcon("warpdrive:gasBlockWhite");
gasIcons[7] = par1IconRegister.registerIcon("warpdrive:gasBlockMilk");
gasIcons[8] = par1IconRegister.registerIcon("warpdrive:gasBlockOrange");
gasIcons[9] = par1IconRegister.registerIcon("warpdrive:gasBlockSyren");
gasIcons[10] = par1IconRegister.registerIcon("warpdrive:gasBlockGray");
gasIcons[11] = par1IconRegister.registerIcon("warpdrive:gasBlockViolet");
}
@Override
public Icon getIcon(int side, int metadata)
{
return gasIcons[metadata];
}
@Override
public int getMobilityFlag()
{
return 1;
}
@Override
public int idDropped(int var1, Random var2, int var3)
{
return -1;
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random par1Random)
{
return 0;
}
@Override
public boolean shouldSideBeRendered(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
if (par1IBlockAccess.getBlockId(par2, par3, par4) == this.blockID)
{
return false;
}
else
{
final int i = par1IBlockAccess.getBlockId(par2, par3, par4);
boolean var6 = false;
if (Block.blocksList[i] != null)
{
var6 = !Block.blocksList[i].isOpaqueCube();
}
final boolean var7 = i == 0;
if ((var6 || var7) && par5 == 3 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 4 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 5 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 2 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 0 && !var6)
{
return true;
}
else if ((var6 || var7) && par5 == 1 && !var6)
{
return true;
}
else
{
return false;
}
}
}
@Override
public boolean func_82506_l()
{
return false;
}
/**
* Returns if this block is collidable. Args: x, y, z
*/
@Override
public boolean isCollidable()
{
return false;
}
@Override
public void onBlockAdded(World par1World, int par2, int par3, int par4)
{
// Gas blocks allow only in space
if (par1World.provider.dimensionId != WarpDrive.instance.spaceDimID)
{
par1World.setBlockToAir(par2, par3, par4);
}
}
}

View file

@ -28,7 +28,7 @@ public class BlockProtocol extends BlockContainer {
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
{
iconBuffer = new Icon[7];
iconBuffer = new Icon[8];
// Solid textures
iconBuffer[ICON_INACTIVE_SIDE] = par1IconRegister.registerIcon("warpdrive:contSideInactive");
@ -40,6 +40,7 @@ public class BlockProtocol extends BlockContainer {
iconBuffer[ICON_SIDE_ACTIVATED + 1] = par1IconRegister.registerIcon("warpdrive:contSideActive2");
iconBuffer[ICON_SIDE_ACTIVATED + 2] = par1IconRegister.registerIcon("warpdrive:contSideActive3");
iconBuffer[ICON_SIDE_ACTIVATED + 3] = par1IconRegister.registerIcon("warpdrive:contSideActive4");
iconBuffer[ICON_SIDE_ACTIVATED + 4] = par1IconRegister.registerIcon("warpdrive:contSideActive4");
}
@Override
@ -97,7 +98,7 @@ public class BlockProtocol extends BlockContainer {
if (controller != null){
controller.attachPlayer(par5EntityPlayer);
par5EntityPlayer.sendChatToPlayer("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList());
par5EntityPlayer.addChatMessage("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList());
}
return true;
}

View file

@ -18,8 +18,6 @@ public class BlockRadar extends BlockContainer {
private final int ICON_INACTIVE_SIDE = 0, ICON_BOTTOM = 1, ICON_TOP = 2, ICON_SIDE_ACTIVATED = 3, ICON_SIDE_ACTIVATED_SCAN = 4;
private ArrayList<TileEntityReactor> searchResults;
public BlockRadar(int id, int texture, Material material) {
super(id, material);
}
@ -91,7 +89,7 @@ public class BlockRadar extends BlockContainer {
TileEntityRadar radar = (TileEntityRadar)par1World.getBlockTileEntity(par2, par3, par4);
if (radar != null){
par5EntityPlayer.sendChatToPlayer("[Radar] Energy level: " + radar.getCurrentEnergyValue() + " Eu");
par5EntityPlayer.addChatMessage("[Radar] Energy level: " + radar.getCurrentEnergyValue() + " Eu");
}
WarpDrive.instance.registry.printRegistry();

View file

@ -88,7 +88,7 @@ public class BlockReactor extends BlockContainer {
TileEntityReactor reactor = (TileEntityReactor)par1World.getBlockTileEntity(par2, par3, par4);
if (reactor != null){
par5EntityPlayer.sendChatToPlayer(reactor.getCoreState());
par5EntityPlayer.addChatMessage(reactor.getCoreState());
}
return true;
}

View file

@ -3,13 +3,17 @@ package cr0s.WarpDrive;
import cpw.mods.fml.common.registry.EntityRegistry;
public class CommonProxy {
public static final String BLOCK_TEXTURE = "WarpDrive.png";
public void registerJumpEntity() {
public void registerEntities() {
EntityRegistry.registerModEntity(EntityJump.class, "EntityJump", 1, WarpDrive.instance, 80, 1, false);
EntityRegistry.registerModEntity(EntitySphereGen.class, "EntitySphereGenerator", 1, WarpDrive.instance, 200, 1, false);
EntityRegistry.registerModEntity(EntityStarCore.class, "EntityStarCore", 1, WarpDrive.instance, 300, 1, false);
}
public void registerRenderers() {
}
public void registerSound() {
}
}

View file

@ -4,7 +4,6 @@ import cpw.mods.fml.common.FMLCommonHandler;
import dan200.computer.api.IPeripheral;
import dan200.turtle.api.ITurtleAccess;
import dan200.turtle.api.TurtleSide;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.block.Block;
@ -21,7 +20,6 @@ import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.ForgeChunkManager;
@ -54,6 +52,9 @@ public class EntityJump extends Entity {
public int minY;
public int dx;
public int dz;
public int mode;
public World targetWorld;
private Ticket sourceWorldTicket;
private Ticket targetWorldTicket;
@ -72,13 +73,15 @@ public class EntityJump extends Entity {
int state = STATE_IDLE;
int currentIndexInShip = 0;
private final int BLOCKS_PER_TICK = 3000;
private final int BLOCKS_PER_TICK = 3500;
private List<MovingEntity> entitiesOnShip;
AxisAlignedBB axisalignedbb;
private boolean fromSpace, toSpace, betweenWorlds;
public boolean toHyperSpace, fromHyperSpace;
private boolean isInHyperSpace;
int destX, destZ;
boolean isCoordJump;
@ -138,8 +141,6 @@ public class EntityJump extends Entity {
@Override
public void onUpdate() {
System.out.println("[JE@"+this+"] onUpdate()");
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
if (!on) {
@ -263,7 +264,7 @@ public class EntityJump extends Entity {
Entity entity = me.entity;
if (entity instanceof EntityPlayer) {
((EntityPlayer)entity).sendChatToPlayer("[WarpCore] " + msg);
((EntityPlayer)entity).addChatMessage("[WarpCore] " + msg);
}
}
}
@ -272,22 +273,27 @@ public class EntityJump extends Entity {
public void prepareToJump() {
LocalProfiler.start("EntityJump.prepareToJump");
toSpace = (dir == -1 && (maxY + distance > 255) && worldObj.provider.dimensionId != WarpDrive.instance.spaceDimID);
isInHyperSpace = (worldObj.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID);
toSpace = (dir == -1 && (maxY + distance > 255) && worldObj.provider.dimensionId == 0);
fromSpace = (dir == -2 && (minY - distance < 0) && worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID);
betweenWorlds = fromSpace || toSpace;
betweenWorlds = fromSpace || toSpace || toHyperSpace || fromHyperSpace;
if (toSpace) {
if (toSpace || fromHyperSpace) {
targetWorld = DimensionManager.getWorld(WarpDrive.instance.spaceDimID);
} else if (fromSpace) {
targetWorld = DimensionManager.getWorld(0);
} else if (toHyperSpace) {
targetWorld = DimensionManager.getWorld(WarpDrive.instance.hyperSpaceDimID);
} else {
targetWorld = this.worldObj;
}
axisalignedbb = AxisAlignedBB.getBoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
turnOffModems();
// FIXME
//turnOffModems();
// Calculate jump vector
if (isCoordJump) {
@ -295,6 +301,9 @@ public class EntityJump extends Entity {
moveZ = destZ - zCoord;
moveY = 0;
distance = 0;
} else if (toHyperSpace || fromHyperSpace) {
moveX = moveY = moveZ = 0;
distance = 0;
} else {
if (betweenWorlds) {
moveX = moveY = 0;
@ -331,13 +340,17 @@ public class EntityJump extends Entity {
}
}
if (betweenWorlds) {
System.out.println("[JE] Worlds: " + worldObj.provider.getDimensionName() + " -> " + targetWorld.provider.getDimensionName());
}
forceChunks();
lockWorlds();
saveEntities(axisalignedbb);
System.out.println("[JE] Saved " + entitiesOnShip.size() + " entities from ship");
if (!isCoordJump) {
if (!isCoordJump && !(toHyperSpace || fromHyperSpace)) {
if (dir != -2 && dir != -1) {
messageToAllPlayersOnShip("Jumping in direction " + dir + " degrees to distance " + distance + " blocks ");
} else if (dir == -1) {
@ -345,9 +358,13 @@ public class EntityJump extends Entity {
} else if (dir == -2) {
messageToAllPlayersOnShip("Jumping DOWN to distance " + distance + " blocks ");
}
} else
} else if (toHyperSpace) {
messageToAllPlayersOnShip("Entering HYPERSPACE...");
} else if (fromHyperSpace) {
messageToAllPlayersOnShip("Leaving HYPERSPACE");
} else if (isCoordJump)
{
messageToAllPlayersOnShip("Jumping to beacon at (" + destX + "; " + yCoord + "; " + destZ + ")!");
messageToAllPlayersOnShip("Jumping by coordinates to (" + destX + "; " + yCoord + "; " + destZ + ")!");
}
bedrockOnShip = false;
@ -392,7 +409,7 @@ public class EntityJump extends Entity {
if (currentIndexInShip >= ship.length) break;
JumpBlock jb = ship[currentIndexInShip];
if (jb.blockTileEntity != null) {
if (jb != null && jb.blockTileEntity != null) {
worldObj.removeBlockTileEntity(jb.x, jb.y, jb.z);
}
@ -435,7 +452,7 @@ public class EntityJump extends Entity {
for(int z = z1; z <= z2; z++) {
int blockID = worldObj.getBlockId(x, y, z);
// Skip air blocks
if (blockID == 0) {
if (blockID == 0 || blockID == WarpDrive.AIR_BLOCKID || blockID == WarpDrive.GAS_BLOCKID) {
continue;
}
@ -516,14 +533,16 @@ public class EntityJump extends Entity {
int blockID = worldObj.getBlockId(x, y, z);
// Пропускаем пустые блоки воздуха
if (blockID != 0) {
shipSize++;
if (blockID == 0 || blockID == WarpDrive.AIR_BLOCKID || blockID == WarpDrive.GAS_BLOCKID) {
continue;
}
shipSize++;
if (blockID == Block.bedrock.blockID) {
bedrockOnShip = true;
LocalProfiler.stop();
return shipSize;
}
if (blockID == Block.bedrock.blockID) {
bedrockOnShip = true;
LocalProfiler.stop();
return shipSize;
}
}
}
@ -694,6 +713,7 @@ public class EntityJump extends Entity {
}
int movementVector[] = getVector(dir);
// TODO: Disasm, plz fix it. Local variable hiding class global field
int moveX = movementVector[0] * testDistance;
int moveY = movementVector[1] * testDistance;
int moveZ = movementVector[2] * testDistance;
@ -716,7 +736,7 @@ public class EntityJump extends Entity {
return false;
}
if (blockOnShipID != 0 && blockID != 0 /*&& blockID != 9 && blockID != 8*/ && blockID != 18) {
if (blockOnShipID != 0 && blockID != 0 && blockID != WarpDrive.AIR_BLOCKID && blockID != WarpDrive.GAS_BLOCKID && blockID != 18) {
blowX = x;
blowY = y;
blowZ = z;
@ -748,30 +768,34 @@ public class EntityJump extends Entity {
* @param p - периферийное устройство
*/
private void turnOffModem(IPeripheral p) {
if (p.getType() == "modem") {
// FIXME
/*if (p.getType() == "modem") {
String[] methods = p.getMethodNames();
for(int i = 0; i < methods.length; i++) {
if (methods[i] == "closeAll") {
try {
p.callMethod(null, i, null);
p.callMethod(null, i, null); // FIXME
} catch (Exception e) {
// ignore iy
}
return;
}
}
}
}*/
}
/**
* Выключение всех модемов на корабле
*/
private void turnOffModems() {
for (int x = minX; x <= maxX; x++) {
// FIXME
/*for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
for (int y = minY; y <= maxY; y++) {
int blockID = worldObj.getBlockId(x, y, z);
if (blockID == 0) continue;
if (blockID == 0 || blockID == WarpDrive.AIR_BLOCKID || blockID == WarpDrive.GAS_BLOCKID) {
continue;
}
TileEntity tileEntity = worldObj.getBlockTileEntity(x, y, z);
if (tileEntity == null) continue;
@ -789,7 +813,7 @@ public class EntityJump extends Entity {
}
}
}
}
}*/
}
@ -827,7 +851,7 @@ public class EntityJump extends Entity {
shipBlock.blockTileEntity.writeToNBT(oldnbt);
TileEntity newTileEntity = null;
// CC's computers and turtles moving workaround
if (blockID == 1225 || blockID == 1227 || blockID == 1228) {
if (blockID == 1225 || blockID == 1227 || blockID == 1228 || blockID == 1230) {
oldnbt.setInteger("x", newX);
oldnbt.setInteger("y", newY);
oldnbt.setInteger("z", newZ);
@ -865,17 +889,17 @@ public class EntityJump extends Entity {
@Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
System.out.println("[JE@"+this+"] readEntityFromNBT()");
//System.out.println("[JE@"+this+"] readEntityFromNBT()");
}
@Override
protected void entityInit() {
System.out.println("[JE@"+this+"] entityInit()");
//System.out.println("[JE@"+this+"] entityInit()");
}
@Override
protected void writeEntityToNBT(NBTTagCompound var1) {
System.out.println("[JE@"+this+"] writeEntityToNBT()");
//System.out.println("[JE@"+this+"] writeEntityToNBT()");
}
// Own implementation of setting blocks withow light recalculation in optimization purposes
@ -966,7 +990,7 @@ public class EntityJump extends Entity {
{
extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta);
// Removed light recalcalations
// Removed light recalculations
/*if (flag)
{
c.generateSkylightMap();

View file

@ -1,39 +1,55 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.storage.ExtendedBlockStorage;
public final class EntitySphereGen extends Entity {
public int xCoord;
public int yCoord;
public int zCoord;
public int type;
private int radius;
private int blockID;
private int blockMeta;
private boolean hollow;
private boolean fillingSphere; // new sphere blocks does not replace existing blocks (for gases)
private boolean surfaceSphere; // generate random surface blocks or fixed blockID
public int blockID;
public double radius, radiusSq, radius1Sq, surfaceRadius;
public int ceilRadius;
public boolean hollow = false;
private final int BLOCKS_PER_TICK = 10000;
private final int STATE_SAVING = 0;
private final int STATE_SETUP = 1;
private final int STATE_STOP = 2;
private int state = STATE_SAVING;
private final int BLOCKS_PER_TICK = 2500;
private final int TYPE_STAR = 1;
private int currentIndex = 0;
private int currX, currY, currZ;
int blocksPassed, blocksTotal;
private ArrayList<JumpBlock> blocks;
public boolean on;
private boolean isICBMLoaded = false, isAELoaded = false;
public EntitySphereGen(World world) {
super(world);
}
public EntitySphereGen(World world, int x, int y, int z, int type) {
public EntitySphereGen(World world, int x, int y, int z, int radius, int blockID, int blockMeta, boolean hollow, boolean fillingSphere, boolean surfaceSphere) {
super(world);
// Check for mods is present
isICBMLoaded = Loader.isModLoaded("ICBM|Explosion");
isAELoaded = Loader.isModLoaded("AppliedEnergistics");
this.xCoord = x;
this.posX = (double) x;
@ -44,36 +60,20 @@ public final class EntitySphereGen extends Entity {
this.zCoord = z;
this.posZ = (double) z;
this.currX = 0;
this.currY = 0;
this.currZ = 0;
this.type = type;
this.radius = radius;
this.blockID = blockID;
this.blockMeta = blockMeta;
this.hollow = hollow;
this.fillingSphere = fillingSphere;
this.surfaceSphere = surfaceSphere;
if (type == TYPE_STAR)
{
blockID = Block.glowStone.blockID;
//hollow = true;
surfaceRadius = 10D;
radius = 64D;
}
this.state = STATE_SAVING;
//radius += 0.5D;
radiusSq = radius * radius;
radius1Sq = (radius - 1.0D) * (radius - 1.0D);
ceilRadius = (int) Math.ceil(radius);
startGenerate();
blocks = new ArrayList<JumpBlock>();
}
public void startGenerate() {
this.on = true;
System.out.println("[SGEN] Generating sphere on (" + xCoord + "; " + yCoord + "; " + zCoord + ") with radius " + ceilRadius + " type: " + type);
}
public void killEntity() {
on = false;
this.state = STATE_STOP;
worldObj.removeEntity(this);
}
@ -81,75 +81,168 @@ public final class EntitySphereGen extends Entity {
public void onUpdate() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
if (!on)
{
System.out.println("[SGEN] onUpdate(): entity disabled.");
killEntity();
return;
}
System.out.print("[SGEN] Tick of generation...");
blocksPassed = 0;
for (; currX <= ceilRadius; currX++) {
if (blocksPassed > BLOCKS_PER_TICK) break;
switch (this.state) {
case STATE_SAVING:
System.out.println("[ESG] Saving blocks...");
saveSphereBlocks();
this.state = STATE_SETUP;
break;
for (currY = 0; currY <= ceilRadius; currY++) {
if (blocksPassed > BLOCKS_PER_TICK) break;
for (currZ = 0; currZ <= ceilRadius; currZ++) {
if (blocksPassed > BLOCKS_PER_TICK) break;
double dSq = lengthSq(currX, currY, currZ);
blocksTotal++;
blocksPassed++;
//if (blocksTotal % 1000 == 0) {
//System.out.println("[SGEN]: current (" + currX + "; " + currY + "; " + currZ + "); Blocks passed: " + blocksPassed + ", total: " + blocksTotal);
//}
// if (currX > ceilRadius && currY > ceilRadius && currZ > ceilRadius)
// {
// System.out.println("[SGEN] DONE");
// killEntity();
// return;
// }
case STATE_SETUP:
if (currentIndex >= blocks.size()-1) {
currentIndex = 0;
killEntity();
} else {
setupBlocksTick();
}
}
}
private void setupBlocksTick() {
LocalProfiler.start("EntitySphereGen.setupBlocksTick");
int blocksToMove = Math.min(BLOCKS_PER_TICK, blocks.size() - currentIndex);
System.out.println("[ESG] Setting up blocks: " + currentIndex + "/" + blocks.size() + " [bts: " + blocksToMove + "]");
int notifyFlag;
for (int index = 0; index < blocksToMove; index++) {
if (currentIndex >= blocks.size()) break;
notifyFlag = (currentIndex % 1000 == 0 ? 2 : 0);
JumpBlock jb = blocks.get(currentIndex);
mySetBlock(worldObj, jb.x, jb.y, jb.z, jb.blockID, jb.blockMeta, notifyFlag);
currentIndex++;
}
LocalProfiler.stop();
}
private void saveSphereBlocks() {
radius += 0.5D; // Radius from center of block
double radiusSq = radius * radius; // Optimization to avoid square roots
double radius1Sq = (radius - 1.0D) * (radius - 1.0D); // for hollow sphere
int ceilRadius = (int) Math.ceil(radius);
// Pass the cube and check points for sphere equation x^2 + y^2 + z^2 = r^2
for (int x = 0; x <= ceilRadius; x++) {
for (int y = 0; y <= ceilRadius; y++) {
for (int z = 0; z <= ceilRadius; z++) {
double dSq = lengthSq(x, y, z); // Distance from current position to center
// Skip too far blocks
if (dSq > radiusSq) {
continue;
}
// Hollow sphere condition
if ((hollow) && (
(dSq < radius1Sq) || ((lengthSq(currX + 1, currY, currZ) <= radiusSq) && (lengthSq(currX, currY + 1, currZ) <= radiusSq) && (lengthSq(currX, currY, currZ + 1) <= radiusSq))))
(dSq < radius1Sq) || ((lengthSq(x + 1, y, z) <= radiusSq) && (lengthSq(x, y + 1, z) <= radiusSq) && (lengthSq(x, y, z + 1) <= radiusSq))))
{
continue;
}
int meta = 0;
worldObj.setBlock(xCoord + currX, yCoord + currY, zCoord + currZ, blockID, meta, 0);
worldObj.setBlock(xCoord - currX, yCoord + currY, zCoord + currZ, blockID, meta, 0);
worldObj.setBlock(xCoord + currX, yCoord - currY, zCoord + currZ, blockID, meta, 0);
worldObj.setBlock(xCoord + currX, yCoord + currY, zCoord - currZ, blockID, meta, 0);
worldObj.setBlock(xCoord - currX, yCoord - currY, zCoord + currZ, blockID, meta, 0);
worldObj.setBlock(xCoord + currX, yCoord - currY, zCoord - currZ, blockID, meta, 0);
worldObj.setBlock(xCoord - currX, yCoord + currY, zCoord - currZ, blockID, meta, 0);
worldObj.setBlock(xCoord - currX, yCoord - currY, zCoord - currZ, blockID, meta, 0);
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
// Add blocks to memory
addBlock(new JumpBlock(blockID, blockMeta, xCoord + x, yCoord + y, zCoord + z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord - x, yCoord + y, zCoord + z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord + x, yCoord - y, zCoord + z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord + x, yCoord + y, zCoord - z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord - x, yCoord - y, zCoord + z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord + x, yCoord - y, zCoord - z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord - x, yCoord + y, zCoord - z));
if (surfaceSphere) {
blockID = getRandomSurfaceBlockID(worldObj.rand, false, false);
if (blockID == 39701) { blockMeta = blockID % 10; blockID = blockID / 10; }
}
addBlock(new JumpBlock(blockID, blockMeta, xCoord - x, yCoord - y, zCoord - z));
}
}
}
System.out.println(" [tick done]");
System.out.println("[ESG] Saved " + blocks.size() + " blocks");
}
private void addBlock(JumpBlock jb) {
// Do not replace exitsting blocks if fillingSphere is true
if (fillingSphere && !worldObj.isAirBlock(jb.x, jb.y, jb.z)) {
return;
}
blocks.add(jb);
}
public int getRandomSurfaceBlockID(Random random, boolean corrupted, boolean nocobble) {
List<Integer> ores = new ArrayList<Integer>();
ores.add(Block.oreIron.blockID);
ores.add(Block.oreGold.blockID);
ores.add(Block.oreCoal.blockID);
ores.add(Block.oreEmerald.blockID);
ores.add(Block.oreLapis.blockID);
ores.add(Block.oreRedstoneGlowing.blockID);
ores.add(247);//IC2
ores.add(248);
ores.add(249);
if (isICBMLoaded)
{
ores.add(3880);
ores.add(3970);
ores.add(39701);
}
int _blockID = Block.stone.blockID;
if (corrupted) {
_blockID = Block.cobblestone.blockID;
}
if (random.nextInt(25) == 5 || nocobble) {
_blockID = ores.get(random.nextInt(ores.size() - 1));
}
else if (random.nextInt(350) == 1 && isAELoaded) {
_blockID = 902; // quarz (AE)
}
else if (random.nextInt(500) == 1) {
_blockID = Block.oreDiamond.blockID;
}
return _blockID;
}
private static double lengthSq(double x, double y, double z) {
return (x * x) + (y * y) + (z * z);
}
@ -160,10 +253,109 @@ public final class EntitySphereGen extends Entity {
@Override
protected void entityInit() {
System.out.println("[SGEN] entityInit() called");
}
@Override
protected void writeEntityToNBT(NBTTagCompound var1) {
}
// Own implementation of setting blocks withow light recalculation in optimization purposes
public boolean mySetBlock(World w, int x, int y, int z, int blockId, int blockMeta, int par6)
{
if (x >= -30000000 && z >= -30000000 && x < 30000000 && z < 30000000)
{
if (y < 0)
{
return false;
}
else if (y >= 256)
{
return false;
}
else
{
w.markBlockForUpdate(x, y, z);
Chunk chunk = w.getChunkFromChunkCoords(x >> 4, z >> 4);
return myChunkSBIDWMT(chunk, x & 15, y, z & 15, blockId, blockMeta);
}
}
else
{
return false;
}
}
public boolean myChunkSBIDWMT(Chunk c, int x, int y, int z, int blockId, int blockMeta)
{
int j1 = z << 4 | x;
if (y >= c.precipitationHeightMap[j1] - 1)
{
c.precipitationHeightMap[j1] = -999;
}
//int k1 = c.heightMap[j1];
int l1 = c.getBlockID(x, y, z);
int i2 = c.getBlockMetadata(x, y, z);
if (l1 == blockId && i2 == blockMeta)
{
return false;
}
else
{
ExtendedBlockStorage[] storageArrays = c.getBlockStorageArray();
ExtendedBlockStorage extendedblockstorage = storageArrays[y >> 4];
if (extendedblockstorage == null)
{
if (blockId == 0)
{
return false;
}
extendedblockstorage = storageArrays[y >> 4] = new ExtendedBlockStorage(y >> 4 << 4, !c.worldObj.provider.hasNoSky);
}
int j2 = c.xPosition * 16 + x;
int k2 = c.zPosition * 16 + z;
extendedblockstorage.setExtBlockID(x, y & 15, z, blockId);
if (extendedblockstorage.getExtBlockID(x, y & 15, z) != blockId)
{
return false;
}
else
{
extendedblockstorage.setExtBlockMetadata(x, y & 15, z, blockMeta);
TileEntity tileentity;
if (blockId != 0)
{
if (Block.blocksList[blockId] != null && Block.blocksList[blockId].hasTileEntity(blockMeta))
{
tileentity = c.getChunkBlockTileEntity(x, y, z);
if (tileentity == null)
{
tileentity = Block.blocksList[blockId].createTileEntity(c.worldObj, blockMeta);
c.worldObj.setBlockTileEntity(j2, y, k2, tileentity);
}
if (tileentity != null)
{
tileentity.updateContainingBlockInfo();
tileentity.blockMetadata = blockMeta;
}
}
}
c.isModified = true;
return true;
}
}
}
}

View file

@ -0,0 +1,142 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.FMLCommonHandler;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
public final class EntityStarCore extends Entity {
public int xCoord;
public int yCoord;
public int zCoord;
private int radius;
private final int KILL_RADIUS = 40;
private final int BURN_RADIUS = 80;
private final int ENTITY_ACTION_INTERVAL = 20; // ticks
private int ticks = 0;
public EntityStarCore(World world) {
super(world);
}
public EntityStarCore(World world, int x, int y, int z, int radius) {
super(world);
this.xCoord = x;
this.posX = (double) x;
this.yCoord = y;
this.posY = (double) y;
this.zCoord = z;
this.posZ = (double) z;
this.radius = radius;
}
private void actionToEntitiesNearStar() {
int xmax, ymax, zmax, x1, x2, z1, z2;
int xmin, ymin, zmin;
final int CUBE_SIDE = this.radius + KILL_RADIUS + BURN_RADIUS;
x1 = xCoord + CUBE_SIDE;
x2 = xCoord - CUBE_SIDE;
if (x1 < x2) {
xmin = x1;
xmax = x2;
} else
{
xmin = x2;
xmax = x1;
}
z1 = zCoord + CUBE_SIDE;
z2 = zCoord - CUBE_SIDE;
if (z1 < z2) {
zmin = z1;
zmax = z2;
} else
{
zmin = z2;
zmax = z1;
}
ymax = yCoord + CUBE_SIDE;
ymin = yCoord - CUBE_SIDE;
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(xmin, ymin, zmin, xmax, ymax, zmax);
List list = worldObj.getEntitiesWithinAABBExcludingEntity(this, aabb);
/*System.out.println("-");
System.out.println("Coordinates: (" + xCoord + "; " + yCoord + "; " + zCoord + "). Cube side: " + CUBE_SIDE);
System.out.println("[" + this + "] X: " + xmin + " -> " + xmax);
System.out.println("[" + this + "] Y: " + ymin + " -> " + ymax);
System.out.println("[" + this + "] Z: " + zmin + " -> " + zmax);
*/
for (Object o : list) {
if (o == null || !(o instanceof Entity)) {
continue;
}
if (o instanceof EntityLivingBase) {
EntityLivingBase entity = (EntityLivingBase)o;
//System.out.println("Found: " + entity.getEntityName() + " distance: " + entity.getDistanceToEntity(this));
if (entity.getDistanceToEntity(this) <= (this.radius + KILL_RADIUS)) {
// 100% kill, ignores any protection
entity.attackEntityFrom(DamageSource.onFire, 9000);
} else if (entity.getDistanceToEntity(this) <= (this.radius + BURN_RADIUS)) {
// burn entity to 100 seconds
entity.setFire(100);
}
}
}
}
public void killEntity() {
worldObj.removeEntity(this);
}
@Override
public void onUpdate() {
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
return;
if (++ticks > ENTITY_ACTION_INTERVAL) {
ticks = 0;
actionToEntitiesNearStar();
}
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
this.xCoord = nbttagcompound.getInteger("x");
this.yCoord = nbttagcompound.getInteger("y");
this.zCoord = nbttagcompound.getInteger("z");
this.radius = nbttagcompound.getInteger("radius");
}
@Override
protected void entityInit() {
}
@Override
protected void writeEntityToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setInteger("x", this.xCoord);
nbttagcompound.setInteger("y", this.yCoord);
nbttagcompound.setInteger("z", this.zCoord);
nbttagcompound.setInteger("radius", this.radius);
}
}

View file

@ -0,0 +1,68 @@
package cr0s.WarpDrive;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.MathHelper;
/*
* /generate <structure>
* Possible structures:
* moon, ship, asteroid, astfield, gascloud, star
*/
public class GenerateCommand extends CommandBase {
@Override
public String getCommandName() {
return "generate";
}
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandUsage(ICommandSender par1ICommandSender) {
return "/" + getCommandName() + " <structure>\nPossible structures: moon, ship, asteroid, astfield, gascloud, star";
}
@Override
public void processCommand(ICommandSender icommandsender, String[] params) {
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
String struct = params[0];
// Reject command, if player is not in space
if (player.dimension != WarpDrive.instance.spaceDimID && (!"ship".equals(struct))) {
player.addChatMessage("* generate: this structure generation allowed only in space!");
return;
}
int x = MathHelper.floor_double(player.posX);
int y = MathHelper.floor_double(player.posY);
int z = MathHelper.floor_double(player.posZ);
if (struct.equals("moon")) {
notifyAdmins(icommandsender, "/generate: generating moon at " + x + ", " + (y - 16) + ", " + z, new Object[0]);
WarpDrive.instance.spaceWorldGenerator.generateMoon(player.worldObj, x, y - 16, z);
} else if (struct.equals("ship")) {
notifyAdmins(icommandsender, "/generate: generating NPC ship at " + x + ", " + y + ", " + z, new Object[0]);
new WorldGenSmallShip(false).generate(player.worldObj, player.worldObj.rand, x, y, z);
} else if (struct.equals("asteroid")) {
notifyAdmins(icommandsender, "/generate: generating asteroid at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
WarpDrive.instance.spaceWorldGenerator.generateAsteroid(player.worldObj, x, y - 10, z, 6, 11);
} else if (struct.equals("astfield")) {
notifyAdmins(icommandsender, "/generate: generating asteroid field at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
WarpDrive.instance.spaceWorldGenerator.generateAsteroidField(player.worldObj, x, y, z);
} else if (struct.equals("gascloud")) {
notifyAdmins(icommandsender, "/generate: generating gas cloud at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
WarpDrive.instance.spaceWorldGenerator.generateGasCloudOfColor(player.worldObj, x, y, z, 15, 20, player.worldObj.rand.nextInt(12));
} else if (struct.equals("star")) {
notifyAdmins(icommandsender, "/generate: generating star at " + x + ", " + (y - 10) + ", " + z, new Object[0]);
WarpDrive.instance.spaceWorldGenerator.generateStar(player.worldObj, x, y, z);
}
}
}

View file

@ -0,0 +1,181 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cr0s.WarpDrive;
import java.util.List;
import java.util.Random;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.util.IProgressUpdate;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.ChunkProviderGenerate;
public class HyperSpaceGenerator extends ChunkProviderGenerate implements IChunkProvider {
private Random rand;
private BiomeGenBase[] biomesForGeneration = new BiomeGenBase[1];
/**
* Reference to the World object.
*/
private World worldObj;
public HyperSpaceGenerator(World par1World, long par2) {
super(par1World, par2, false);
rand = new Random();
this.worldObj = par1World;
}
@Override
public Chunk provideChunk(int par1, int par2) {
this.rand.setSeed((long) par1 * 341873128712L + (long) par2 * 132897987541L);
byte[] var3 = new byte[32768];
generateTerrain(par1, par2, var3);
//this.caveGenerator.generate(this, this.worldObj, par1, par2, var3);
this.biomesForGeneration[0] = WarpDrive.spaceBiome;
Chunk var4 = new Chunk(this.worldObj, var3, par1, par2);
var4.generateSkylightMap();
return var4;
}
@Override
public Chunk loadChunk(int var1, int var2) {
// TODO Auto-generated method stub
return this.provideChunk(var1, var2);
}
@Override
public void populate(IChunkProvider var1, int var2, int var3) {
//super.populate(var1, var2, var3);
// Generate chunk population
// GameRegistry.generateWorld(var2, var3, worldObj, var1, var1);
}
@Override
public boolean saveChunks(boolean var1, IProgressUpdate var2) {
return super.saveChunks(var1, var2);
}
@Override
public void generateTerrain(int par1, int par2, byte[] par3ArrayOfByte) {
this.biomesForGeneration[0] = WarpDrive.spaceBiome;
// if (!"Space".equals(worldObj.provider.getDimensionName())) {
// }
/*byte var4 = 4;
byte var5 = 16;
byte var6 = 16;
int var7 = var4 + 1;
byte var8 = 17;
int var9 = var4 + 1;
this.biomesForGeneration[0] = WarpDrive.spaceBiome;
this.noiseArray = this.initializeNoiseField(this.noiseArray, par1 * var4, 0, par2 * var4, var7, var8, var9);
for (int var10 = 0; var10 < var4; ++var10) {
for (int var11 = 0; var11 < var4; ++var11) {
for (int var12 = 0; var12 < var5; ++var12) {
double var13 = 0.125D;
double var15 = this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 0];
double var17 = this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 0];
double var19 = this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 0];
double var21 = this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 0];
double var23 = (this.noiseArray[((var10 + 0) * var9 + var11 + 0) * var8 + var12 + 1] - var15) * var13;
double var25 = (this.noiseArray[((var10 + 0) * var9 + var11 + 1) * var8 + var12 + 1] - var17) * var13;
double var27 = (this.noiseArray[((var10 + 1) * var9 + var11 + 0) * var8 + var12 + 1] - var19) * var13;
double var29 = (this.noiseArray[((var10 + 1) * var9 + var11 + 1) * var8 + var12 + 1] - var21) * var13;
for (int var31 = 0; var31 < 8; ++var31) {
double var32 = 0.25D;
double var34 = var15;
double var36 = var17;
double var38 = (var19 - var15) * var32;
double var40 = (var21 - var17) * var32;
for (int var42 = 0; var42 < 4; ++var42) {
int var43 = var42 + var10 * 4 << 11 | 0 + var11 * 4 << 7 | var12 * 8 + var31;
short var44 = 128;
var43 -= var44;
double var45 = 0.25D;
double var49 = (var36 - var34) * var45;
double var47 = var34 - var49;
for (int var51 = 0; var51 < 4; ++var51) {
if ((var47 += var49) > 0.0D) {
par3ArrayOfByte[var43 += var44] = (byte) Block.stone.blockID;
} else if (var12 * 8 + var31 < var6) {
par3ArrayOfByte[var43 += var44] = (byte) Block.sandStone.blockID;
} else {
par3ArrayOfByte[var43 += var44] = 0;
}
}
var34 += var38;
var36 += var40;
}
var15 += var23;
var17 += var25;
var19 += var27;
var21 += var29;
}
}
}
}*/
}
@Override
public void replaceBlocksForBiome(int par1, int par2, byte[] par3ArrayOfByte, BiomeGenBase[] par4ArrayOfBiomeGenBase)
{
/*ChunkProviderEvent.ReplaceBiomeBlocks event = new ChunkProviderEvent.ReplaceBiomeBlocks(this, par1, par2, par3ArrayOfByte, par4ArrayOfBiomeGenBase);
MinecraftForge.EVENT_BUS.post(event);
if (event.getResult() == Event.Result.DENY) return; */
}
@Override
public boolean canSave() {
// TODO Auto-generated method stub
return super.canSave();
}
@Override
public String makeString() {
// TODO Auto-generated method stub
return super.makeString();
}
@Override
public List getPossibleCreatures(EnumCreatureType var1, int var2, int var3,
int var4) {
// TODO Auto-generated method stub
return null;
}
@Override
public ChunkPosition findClosestStructure(World var1, String var2,
int var3, int var4, int var5) {
// TODO Auto-generated method stub
return null;
}
@Override
public int getLoadedChunkCount() {
// TODO Auto-generated method stub
return super.getLoadedChunkCount();
}
@Override
public void recreateStructures(int var1, int var2) {
// TODO Auto-generated method stub
}
}

View file

@ -0,0 +1,215 @@
package cr0s.WarpDrive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManagerHell;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
public class HyperSpaceProvider extends WorldProvider {
public int exitXCoord;
public int exitYCoord;
public int exitZCoord;
public int exitDimID;
public HyperSpaceProvider() {
this.worldChunkMgr = new WorldChunkManagerHell(WarpDrive.spaceBiome, 0.0F, 0.0F);
this.hasNoSky = false;
}
@Override
public String getDimensionName() {
return "Hyperspace";
}
@Override
public boolean canRespawnHere() {
return true;
}
@SideOnly(Side.CLIENT)
@Override
public float getStarBrightness(float par1)
{
return 0F;
}
@Override
public boolean isSurfaceWorld()
{
return true;
}
@Override
public int getAverageGroundLevel()
{
return 1;
}
@Override
public double getHorizon()
{
return 1;
}
@Override
public boolean canSnowAt(int x, int y, int z) {
return false;
}
@Override
public void updateWeather()
{
super.resetRainAndThunder();
}
@Override
public BiomeGenBase getBiomeGenForCoords(int x, int z)
{
return WarpDrive.spaceBiome;
}
@Override
public void setAllowedSpawnTypes(boolean allowHostile, boolean allowPeaceful) {
super.setAllowedSpawnTypes(false, false);
}
@Override
public float calculateCelestialAngle(long par1, float par3) {
return 0.5F;
}
@Override
protected void generateLightBrightnessTable()
{
float var1 = 0.0F;
for (int var2 = 0; var2 <= 15; ++var2)
{
float var3 = 1.0F - (float)var2 / 15.0F;
this.lightBrightnessTable[var2] = (1.0F - var3) / (var3 * 3.0F + 1.0F) * (1.0F - var1) + var1;
}
}
@SideOnly(Side.CLIENT)
@Override
public String getSaveFolder() {
return (dimensionId == 0 ? null : "WarpDrive/HyperSpace" + dimensionId);
}
@Override
public boolean canCoordinateBeSpawn(int par1, int par2) {
int var3 = this.worldObj.getFirstUncoveredBlock(par1, par2);
return var3 != 0;
}
@Override
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {
setCloudRenderer(new CloudRenderBlank());
setSkyRenderer(new CloudRenderBlank());
return this.worldObj.getWorldVec3Pool().getVecFromPool((double) 1, (double) 0, (double) 0);
}
@SideOnly(Side.CLIENT)
@Override
public Vec3 getFogColor(float par1, float par2) {
return this.worldObj.getWorldVec3Pool().getVecFromPool((double) 0.1, (double) 0, (double) 0);
}
@SideOnly(Side.CLIENT)
@Override
public boolean isSkyColored()
{
return true;
}
@Override
public ChunkCoordinates getEntrancePortalLocation()
{
return null;
}
@Override
public int getRespawnDimension(EntityPlayerMP player) {
return WarpDrive.instance.hyperSpaceDimID;
}
@Override
public IChunkProvider createChunkGenerator() {
return new HyperSpaceGenerator(worldObj, 46);
}
@Override
public boolean canBlockFreeze(int x, int y, int z, boolean byWater) {
return false;
}
@Override
public ChunkCoordinates getRandomizedSpawnPoint() {
ChunkCoordinates var5 = new ChunkCoordinates(this.worldObj.getSpawnPoint());
//boolean isAdventure = worldObj.getWorldInfo().getGameType() == EnumGameType.ADVENTURE;
int spawnFuzz = 100;
int spawnFuzzHalf = spawnFuzz / 2;
{
var5.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
var5.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
var5.posY = 200;
}
if (worldObj.isAirBlock(var5.posX, var5.posY, var5.posZ)) {
worldObj.setBlock(var5.posX, var5.posY, var5.posZ, Block.stone.blockID, 0, 2);
worldObj.setBlock(var5.posX + 1, var5.posY + 1, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX + 1, var5.posY + 2, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX - 1, var5.posY + 1, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX - 1, var5.posY + 2, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY + 1, var5.posZ + 1, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY + 2, var5.posZ + 1, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY + 1, var5.posZ - 1, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY + 2, var5.posZ - 1, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY + 3, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlock(var5.posX, var5.posY, var5.posZ, WarpDrive.AIR_BLOCKID, 15, 2);
worldObj.setBlock(var5.posX, var5.posY + 1, var5.posZ, WarpDrive.AIR_BLOCKID, 15, 2);
}
return var5;
}
@Override
public boolean getWorldHasVoidParticles() {
return false;
}
@Override
public boolean isDaytime() {
return true;
}
@Override
public boolean canDoLightning(Chunk chunk)
{
return false;
}
@Override
public boolean canDoRainSnowIce(Chunk chunk)
{
return false;
}
}

View file

@ -0,0 +1,22 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package cr0s.WarpDrive;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraftforge.client.IRenderHandler;
/**
*
* @author user
*/
public class HyperSpaceSkyRenderer extends IRenderHandler {
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc) {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View file

@ -0,0 +1,29 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.IWorldGenerator;
import java.util.Random;
import net.minecraft.world.World;
import net.minecraft.world.chunk.IChunkProvider;
/**
* @author Cr0s
*/
public class HyperSpaceWorldGenerator implements IWorldGenerator {
/**
* Generator for chunk
* @param random
* @param chunkX
* @param chunkZ
* @param world
* @param chunkGenerator
* @param chunkProvider
*/
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
if (world.provider.dimensionId != WarpDrive.instance.hyperSpaceDimID) {
// ...
}
}
}

View file

@ -0,0 +1,25 @@
package cr0s.WarpDrive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.event.ForgeSubscribe;
public class SoundHandler
{
@SideOnly(Side.CLIENT)
@ForgeSubscribe
public void onSoundLoad(SoundLoadEvent event)
{
try
{
System.out.println("[WarpDrive] Registering sound files...");
event.manager.addSound("warpdrive:warp.ogg");
}
catch (Exception e)
{
System.err.println("Failed to register sound: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
}

View file

@ -1,82 +1,75 @@
/*
* Невесомость и отключение текучести жидкостей
*/
package cr0s.WarpDrive;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.common.ForgeHooks;
/**
* Обработчик событий в мире Space
* @author Cr0s
*/
public class SpaceEventHandler {
@ForgeSubscribe
public void livingUpdate(LivingUpdateEvent event) {
EntityLiving entity = event.entityLiving;
final int HELMET_ID_SKUBA = 30082;
final int HELMET_ID_QUANTUM = 30174;
final int HELMET_ID_ADV_SOLAR = 30832;
final int HELMET_ID_HYB_SOLAR = 30833;
final int HELMET_ID_ULT_SOLAR = 30834;
final int HELMET_HEAD = 397;
// Движение происходит в космическом пространстве
if (entity.worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID) {
if (entity instanceof EntityPlayerMP) {
if (isEntityInVacuum(entity)) {
if (!(entity.getCurrentArmor(3) != null && (entity.getCurrentArmor(3).itemID == HELMET_ID_SKUBA || entity.getCurrentArmor(3).itemID == HELMET_ID_QUANTUM || entity.getCurrentArmor(3).itemID == HELMET_HEAD
|| entity.getCurrentArmor(3).itemID == HELMET_ID_ADV_SOLAR || entity.getCurrentArmor(3).itemID == HELMET_ID_HYB_SOLAR || entity.getCurrentArmor(3).itemID == HELMET_ID_ULT_SOLAR))) {
entity.attackEntityFrom(DamageSource.drown, 3);
}
}
// Отправить назад на Землю
if (entity.posY < -10.0D) {
((EntityPlayerMP)entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), 0, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, MathHelper.floor_double(entity.posX), 250, MathHelper.floor_double(entity.posZ)));
((EntityPlayerMP)entity).setFire(30);
((EntityPlayerMP)entity).setPositionAndUpdate(entity.posX, 250D, entity.posZ);
}
}
}
}
/**
* Проверка, находится ли Entity в открытом космосе
* @param e
* @return
*/
private boolean isEntityInVacuum(Entity e) {
int x = MathHelper.floor_double(e.posX);
int y = MathHelper.floor_double(e.posY);
int z = MathHelper.floor_double(e.posZ);
final int CHECK_DISTANCE = 10;
if (e.onGround) { return false; }
for (int ny = y; ny > (y - CHECK_DISTANCE); ny--) {
if (!e.worldObj.isAirBlock(x, ny, z)) {
return false;
}
}
if (!e.worldObj.canBlockSeeTheSky(x, y, z) || !e.worldObj.canBlockSeeTheSky(x, y - 1, z) ) {
return false;
}
return true;
}
}
/*
* Невесомость и отключение текучести жидкостей
*/
package cr0s.WarpDrive;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MathHelper;
import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
/**
* Обработчик событий в мире Space
* @author Cr0s
*/
public class SpaceEventHandler {
@ForgeSubscribe
public void livingUpdate(LivingUpdateEvent event) {
EntityLivingBase entity = event.entityLiving;
if (Math.abs(MathHelper.floor_double(entity.posX)) > WarpDrive.WORLD_LIMIT_BLOCKS || Math.abs(MathHelper.floor_double(entity.posZ)) > WarpDrive.WORLD_LIMIT_BLOCKS) {
entity.attackEntityFrom(DamageSource.outOfWorld, 9000);
return;
}
final int HELMET_ID_SKUBA = 30082;
final int HELMET_ID_QUANTUM = 30174;
final int HELMET_ID_HAZMAT = 14023;
final int HELMET_ID_NANO = 30178;
// Обновление происходит в космическом или гипер пространстве
if (entity.worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID || entity.worldObj.provider.dimensionId == WarpDrive.instance.hyperSpaceDimID) {
boolean inVacuum = isEntityInVacuum(entity);
// Damage entity if in vacuum without protection
if (inVacuum) {
if (entity instanceof EntityPlayerMP) {
if (!(((EntityPlayerMP)entity).getCurrentArmor(3) != null && (((EntityPlayerMP)entity).getCurrentArmor(3).itemID == HELMET_ID_SKUBA || ((EntityPlayerMP)entity).getCurrentArmor(3).itemID == HELMET_ID_QUANTUM || ((EntityPlayerMP)entity).getCurrentArmor(3).itemID == HELMET_ID_NANO || ((EntityPlayerMP)entity).getCurrentArmor(3).itemID == HELMET_ID_HAZMAT))) {
entity.attackEntityFrom(DamageSource.drown, 1);
}
// Отправить назад на Землю
if (entity.posY < -10.0D) {
((EntityPlayerMP)entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), 0, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, MathHelper.floor_double(entity.posX), 250, MathHelper.floor_double(entity.posZ)));
((EntityPlayerMP)entity).setFire(30);
((EntityPlayerMP)entity).setPositionAndUpdate(entity.posX, 250D, entity.posZ);
}
} else {
entity.attackEntityFrom(DamageSource.drown, 1);
}
}
}
}
/**
* Проверка, находится ли Entity в открытом космосе
* @param e
* @return
*/
private boolean isEntityInVacuum(Entity e) {
int x = MathHelper.floor_double(e.posX);
int y = MathHelper.floor_double(e.posY);
int z = MathHelper.floor_double(e.posZ);
if ((e.worldObj.getBlockId(x, y, z) == 0 || e.worldObj.getBlockId(x, y, z) == WarpDrive.GAS_BLOCKID) && (e.worldObj.getBlockId(x, y + 1, z) == 0 || e.worldObj.getBlockId(x, y + 1, z) == WarpDrive.GAS_BLOCKID)) {
return true;
}
return false;
}
}

View file

@ -9,11 +9,9 @@ import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.Vec3;
import net.minecraft.world.WorldProvider;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.biome.WorldChunkManager;
import net.minecraft.world.biome.WorldChunkManagerHell;
import net.minecraft.world.chunk.Chunk;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraftforge.client.IRenderHandler;
public class SpaceProvider extends WorldProvider {
@ -42,8 +40,27 @@ public class SpaceProvider extends WorldProvider {
public float getStarBrightness(float par1)
{
return 1.0F;
}
@Override
public boolean isSurfaceWorld()
{
return true;
}
@Override
public int getAverageGroundLevel()
{
return 1;
}
@Override
public double getHorizon()
{
return 1;
}
@Override
public boolean canSnowAt(int x, int y, int z) {
return false;
@ -52,7 +69,10 @@ public class SpaceProvider extends WorldProvider {
@Override
public void updateWeather()
{
super.resetRainAndThunder();
this.worldObj.getWorldInfo().setRainTime(0);
this.worldObj.getWorldInfo().setRaining(false);
this.worldObj.getWorldInfo().setThunderTime(0);
this.worldObj.getWorldInfo().setThundering(false);
}
@Override
@ -103,14 +123,10 @@ public class SpaceProvider extends WorldProvider {
return var3 != 0;
}
@Override
public double getHorizon() {
return 0;
}
@Override
public Vec3 getSkyColor(Entity cameraEntity, float partialTicks) {
setCloudRenderer(new CloudRenderBlank());
//setSkyRenderer(new SpaceSkyRenderer());
return this.worldObj.getWorldVec3Pool().getVecFromPool((double) 0, (double) 0, (double) 0);
}

View file

@ -0,0 +1,305 @@
package cr0s.WarpDrive;
import java.util.Random;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.client.renderer.GLAllocation;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.IRenderHandler;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.client.FMLClientHandler;
/**
* Copyright 2012-2013, micdoodle8
*
* All rights reserved.
*
*/
public class SpaceSkyRenderer extends IRenderHandler
{
private static final ResourceLocation overworldTexture = new ResourceLocation("genericmod:textures/earth.png");
private static final ResourceLocation sunTexture = new ResourceLocation("genericmod:textures/sun.png");
public int starGLCallList = GLAllocation.generateDisplayLists(3);
public int glSkyList;
public int glSkyList2;
private final boolean MORE_STARS = false;
public SpaceSkyRenderer()
{
GL11.glPushMatrix();
GL11.glNewList(this.starGLCallList, GL11.GL_COMPILE);
this.renderStars();
GL11.glEndList();
GL11.glPopMatrix();
final Tessellator tessellator = Tessellator.instance;
this.glSkyList = this.starGLCallList + 1;
GL11.glNewList(this.glSkyList, GL11.GL_COMPILE);
final byte byte2 = 64;
final int i = 256 / byte2 + 2;
float f = 16F;
for (int j = -byte2 * i; j <= byte2 * i; j += byte2)
{
for (int l = -byte2 * i; l <= byte2 * i; l += byte2)
{
tessellator.startDrawingQuads();
tessellator.addVertex(j + 0, f, l + 0);
tessellator.addVertex(j + byte2, f, l + 0);
tessellator.addVertex(j + byte2, f, l + byte2);
tessellator.addVertex(j + 0, f, l + byte2);
tessellator.draw();
}
}
GL11.glEndList();
this.glSkyList2 = this.starGLCallList + 2;
GL11.glNewList(this.glSkyList2, GL11.GL_COMPILE);
f = -16F;
tessellator.startDrawingQuads();
for (int k = -byte2 * i; k <= byte2 * i; k += byte2)
{
for (int i1 = -byte2 * i; i1 <= byte2 * i; i1 += byte2)
{
tessellator.addVertex(k + byte2, f, i1 + 0);
tessellator.addVertex(k + 0, f, i1 + 0);
tessellator.addVertex(k + 0, f, i1 + byte2);
tessellator.addVertex(k + byte2, f, i1 + byte2);
}
}
tessellator.draw();
GL11.glEndList();
}
@Override
public void render(float partialTicks, WorldClient world, Minecraft mc)
{
SpaceProvider spaceProvider = null;
if (world.provider instanceof SpaceProvider)
{
spaceProvider = (SpaceProvider) world.provider;
}
GL11.glDisable(GL11.GL_TEXTURE_2D);
final Vec3 var2 = this.getCustomSkyColor();
float var3 = (float) var2.xCoord * (1 - world.getStarBrightness(partialTicks) * 2);
float var4 = (float) var2.yCoord * (1 - world.getStarBrightness(partialTicks) * 2);
float var5 = (float) var2.zCoord * (1 - world.getStarBrightness(partialTicks) * 2);
float var8;
if (mc.gameSettings.anaglyph)
{
final float var6 = (var3 * 30.0F + var4 * 59.0F + var5 * 11.0F) / 100.0F;
final float var7 = (var3 * 30.0F + var4 * 70.0F) / 100.0F;
var8 = (var3 * 30.0F + var5 * 70.0F) / 100.0F;
var3 = var6;
var4 = var7;
var5 = var8;
}
GL11.glColor3f(1, 1, 1);
final Tessellator var23 = Tessellator.instance;
GL11.glDepthMask(false);
GL11.glEnable(GL11.GL_FOG);
GL11.glColor3f(0, 0, 0);
GL11.glCallList(this.glSkyList);
GL11.glDisable(GL11.GL_FOG);
GL11.glDisable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
RenderHelper.disableStandardItemLighting();
float var10;
float var11;
float var12;
float var20 = 0;
if (spaceProvider != null)
{
var20 = spaceProvider.getStarBrightness(partialTicks);
}
if (var20 > 0.0F)
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, var20);
GL11.glCallList(this.starGLCallList);
}
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
GL11.glPushMatrix();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glRotatef(-90.0F, 0.0F, 1.0F, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 5F);
GL11.glRotatef(world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F, 0.0F);
var12 = 30.0F;
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(sunTexture);
var23.startDrawingQuads();
var23.addVertexWithUV(-var12, 150.0D, -var12, 0.0D, 0.0D);
var23.addVertexWithUV(var12, 150.0D, -var12, 1.0D, 0.0D);
var23.addVertexWithUV(var12, 150.0D, var12, 1.0D, 1.0D);
var23.addVertexWithUV(-var12, 150.0D, var12, 0.0D, 1.0D);
var23.draw();
GL11.glPopMatrix();
GL11.glPushMatrix();
GL11.glDisable(GL11.GL_BLEND);
// HOME:
var12 = 10.0F;
final float earthRotation = (float) (world.getSpawnPoint().posZ - mc.thePlayer.posZ) * 0.01F;
GL11.glScalef(0.6F, 0.6F, 0.6F);
GL11.glRotatef(earthRotation, 1.0F, 0.0F, 0.0F);
GL11.glRotatef(200F, 1.0F, 0.0F, 0.0F);
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1F);
FMLClientHandler.instance().getClient().renderEngine.func_110577_a(overworldTexture);
world.getMoonPhase();
var23.startDrawingQuads();
var23.addVertexWithUV(-var12, -100.0D, var12, 0, 1);
var23.addVertexWithUV(var12, -100.0D, var12, 1, 1);
var23.addVertexWithUV(var12, -100.0D, -var12, 1, 0);
var23.addVertexWithUV(-var12, -100.0D, -var12, 0, 0);
var23.draw();
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
GL11.glDisable(GL11.GL_BLEND);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL11.glEnable(GL11.GL_FOG);
GL11.glPopMatrix();
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor3f(0.0F, 0.0F, 0.0F);
final double var25 = mc.thePlayer.getPosition(partialTicks).yCoord - world.getHorizon();
if (var25 < 0.0D)
{
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, 12.0F, 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
var10 = 1.0F;
var11 = -((float) (var25 + 65.0D));
var12 = -var10;
var23.startDrawingQuads();
var23.setColorRGBA_I(0, 255);
var23.addVertex(-var10, var11, var10);
var23.addVertex(var10, var11, var10);
var23.addVertex(var10, var12, var10);
var23.addVertex(-var10, var12, var10);
var23.addVertex(-var10, var12, -var10);
var23.addVertex(var10, var12, -var10);
var23.addVertex(var10, var11, -var10);
var23.addVertex(-var10, var11, -var10);
var23.addVertex(var10, var12, -var10);
var23.addVertex(var10, var12, var10);
var23.addVertex(var10, var11, var10);
var23.addVertex(var10, var11, -var10);
var23.addVertex(-var10, var11, -var10);
var23.addVertex(-var10, var11, var10);
var23.addVertex(-var10, var12, var10);
var23.addVertex(-var10, var12, -var10);
var23.addVertex(-var10, var12, -var10);
var23.addVertex(-var10, var12, var10);
var23.addVertex(var10, var12, var10);
var23.addVertex(var10, var12, -var10);
var23.draw();
}
GL11.glColor3f(70F / 256F, 70F / 256F, 70F / 256F);
GL11.glPushMatrix();
GL11.glTranslatef(0.0F, -((float) (var25 - 16.0D)), 0.0F);
GL11.glCallList(this.glSkyList2);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glDepthMask(true);
}
private void renderStars()
{
final Random var1 = new Random(10842L);
final Tessellator var2 = Tessellator.instance;
var2.startDrawingQuads();
for (int var3 = 0; var3 < (MORE_STARS ? 20000 : 6000); ++var3)
{
double var4 = var1.nextFloat() * 2.0F - 1.0F;
double var6 = var1.nextFloat() * 2.0F - 1.0F;
double var8 = var1.nextFloat() * 2.0F - 1.0F;
final double var10 = 0.15F + var1.nextFloat() * 0.1F;
double var12 = var4 * var4 + var6 * var6 + var8 * var8;
if (var12 < 1.0D && var12 > 0.01D)
{
var12 = 1.0D / Math.sqrt(var12);
var4 *= var12;
var6 *= var12;
var8 *= var12;
final double var14 = var4 * (MORE_STARS ? var1.nextDouble() * 100D + 150D : 100.0D);
final double var16 = var6 * (MORE_STARS ? var1.nextDouble() * 100D + 150D : 100.0D);
final double var18 = var8 * (MORE_STARS ? var1.nextDouble() * 100D + 150D : 100.0D);
final double var20 = Math.atan2(var4, var8);
final double var22 = Math.sin(var20);
final double var24 = Math.cos(var20);
final double var26 = Math.atan2(Math.sqrt(var4 * var4 + var8 * var8), var6);
final double var28 = Math.sin(var26);
final double var30 = Math.cos(var26);
final double var32 = var1.nextDouble() * Math.PI * 2.0D;
final double var34 = Math.sin(var32);
final double var36 = Math.cos(var32);
for (int var38 = 0; var38 < 4; ++var38)
{
final double var39 = 0.0D;
final double var41 = ((var38 & 2) - 1) * var10;
final double var43 = ((var38 + 1 & 2) - 1) * var10;
final double var47 = var41 * var36 - var43 * var34;
final double var49 = var43 * var36 + var41 * var34;
final double var53 = var47 * var28 + var39 * var30;
final double var55 = var39 * var28 - var47 * var30;
final double var57 = var55 * var22 - var49 * var24;
final double var61 = var49 * var22 + var55 * var24;
var2.addVertex(var14 + var57, var16 + var53, var18 + var61);
}
}
}
var2.draw();
}
private Vec3 getCustomSkyColor()
{
return Vec3.fakePool.getVecFromPool(0.26796875D, 0.1796875D, 0.0D);
}
public float getSkyBrightness(float par1)
{
final float var2 = FMLClientHandler.instance().getClient().theWorld.getCelestialAngle(par1);
float var3 = 1.0F - (MathHelper.sin(var2 * (float) Math.PI * 2.0F) * 2.0F + 0.25F);
if (var3 < 0.0F)
{
var3 = 0.0F;
}
if (var3 > 1.0F)
{
var3 = 1.0F;
}
return var3 * var3 * 1F;
}
}

View file

@ -0,0 +1,45 @@
package cr0s.WarpDrive;
import net.minecraft.command.CommandBase;
import net.minecraft.command.ICommandSender;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.MathHelper;
import net.minecraft.world.WorldServer;
public class SpaceTpCommand extends CommandBase {
@Override
public int getRequiredPermissionLevel() {
return 2;
}
@Override
public String getCommandName() {
return "space";
}
@Override
public void processCommand(ICommandSender icommandsender, String[] astring) {
EntityPlayerMP player = (EntityPlayerMP)icommandsender;
MinecraftServer server = MinecraftServer.getServer();
int targetDim = WarpDrive.instance.spaceDimID;
if (astring.length >= 1) {
if ("hyper".equals(astring[0])) {
targetDim = WarpDrive.instance.hyperSpaceDimID;
}
}
WorldServer to = server.worldServerForDimension(targetDim);
SpaceTeleporter teleporter = new SpaceTeleporter(to, 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ));
server.getConfigurationManager().transferPlayerToDimension(player, targetDim, teleporter);
}
@Override
public String getCommandUsage(ICommandSender icommandsender) {
return "/space [hyper]";
}
}

View file

@ -19,7 +19,9 @@ public class SpaceWorldGenerator implements IWorldGenerator {
public final int MOON_CORE_RADIUS = 10;
// Star radius
public final int STAR_RADIUS = 80;
public final int RED_DWARF_RADIUS = 42;
public final int YELLOW_GIANT_RADIUS = 64;
public final int YELLOW_SUPERGIANT_RADIUS = 80;
// Upper than 128 almost nothing will be generated
public final int Y_LIMIT = 128;
@ -51,40 +53,17 @@ public class SpaceWorldGenerator implements IWorldGenerator {
int x = (chunkX * 16) + (5 - random.nextInt(10));
int z = (chunkZ * 16) + (5 - random.nextInt(10));
int y = Y_LIMIT_DOWN + random.nextInt(Y_LIMIT - Y_LIMIT_DOWN);
// Moon setup
if (random.nextInt(8000) == 1) {
System.out.println("Generating moon at " + x + " " + y + " " + z);
generateSphere2(world, x, y, z, MOON_RADIUS, false, 0, false);
// Generate moon's core
if (random.nextInt(10) > 3)
{
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, Block.lavaStill.blockID, false); // Lava core
generateSphere2(world, x, y, z, MOON_CORE_RADIUS + 1, false, Block.obsidian.blockID, true); // Obsidian shell
} else
{
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, 0, false);
generateSmallShip(world, x, y, z);
}
if (Math.abs(x) > WarpDrive.WORLD_LIMIT_BLOCKS || Math.abs(z) > WarpDrive.WORLD_LIMIT_BLOCKS) {
return;
}
// FIXME: Star setup
/*if (random.nextInt(250) == 1) {
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, 1);
esg.xCoord = x;
esg.yCoord = y;
esg.zCoord = z;
esg.on = true;
world.spawnEntityInWorld(esg);
int y = Y_LIMIT_DOWN + random.nextInt(Y_LIMIT - Y_LIMIT_DOWN);
// Moon setup
if (random.nextInt(8000) == 1) {
generateMoon(world, x, y, z);
return;
}*/
}
// Simple asteroids
if (random.nextInt(500) == 1) {
@ -96,6 +75,10 @@ public class SpaceWorldGenerator implements IWorldGenerator {
// Random asteroid of block
if (random.nextInt(1000) == 1) {
generateRandomAsteroid(world, x, y, z, 6, 11);
if (random.nextBoolean()) {
generateGasCloudOfColor(world, x, y, z, 6, 11, random.nextInt(12));
}
}
// Ice asteroid
@ -122,10 +105,119 @@ public class SpaceWorldGenerator implements IWorldGenerator {
// Diamond block core
world.setBlock(x, y, z, Block.blockDiamond.blockID, 0, 2);
// return;
if (random.nextBoolean()) {
generateGasCloudOfColor(world, x, y, z, 6, 11, random.nextInt(12));
}
}
}
public void generateMoon(World world, int x, int y, int z) {
System.out.println("Generating moon at " + x + " " + y + " " + z);
generateSphereEntity(world, x, y, z, MOON_RADIUS, false, 0, 0);
// Generate moon's core
if (world.rand.nextInt(10) > 2)
{
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, Block.lavaStill.blockID, false); // Lava core
generateSphere2(world, x, y, z, MOON_CORE_RADIUS + 1, false, Block.obsidian.blockID, true); // Obsidian shell
} else
{
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, 0, false);
generateSmallShip(world, x, y, z);
}
// Generate moon's atmosphere
if (world.rand.nextBoolean()) {
int gasColor = 1 + world.rand.nextInt(11);
generateGasSphereEntity(world, x, y, z, MOON_RADIUS + 5, true, gasColor);
}
// Place bedrock blocks
world.setBlock(x, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x + MOON_CORE_RADIUS, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x - MOON_CORE_RADIUS, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z + MOON_CORE_RADIUS, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z - MOON_CORE_RADIUS, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y + MOON_CORE_RADIUS, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y - MOON_CORE_RADIUS, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x + MOON_RADIUS / 2, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x - MOON_RADIUS / 2, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z + MOON_RADIUS / 2, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z - MOON_RADIUS / 2, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y + MOON_RADIUS / 2, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y - MOON_RADIUS / 2, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x + MOON_RADIUS - 5, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x - MOON_RADIUS - 5, y, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z + MOON_RADIUS - 5, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y, z - MOON_RADIUS - 5, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y + MOON_RADIUS - 5, z, Block.bedrock.blockID, 0, 0);
world.setBlock(x, y - MOON_RADIUS - 5, z, Block.bedrock.blockID, 0, 0);
}
private void placeStarCore(World world, int x, int y, int z, int radius) {
EntityStarCore core = new EntityStarCore(world, x, y, z, radius);
core.xCoord = x;
core.yCoord = y;
core.zCoord = z;
core.setPosition((double)x, (double)y, (double)z);
world.spawnEntityInWorld(core);
}
public void generateStar(World world, int x, int y, int z) {
int starClass = world.rand.nextInt(3);
System.out.println("Generating star (class " + starClass + ") at " + x + " " + y + " " + z);
switch (starClass) {
case 0: // red dwarf
generateSphereEntity(world, x, y, z, RED_DWARF_RADIUS, false, Block.blockRedstone.blockID, 0);
// Heliosphere of red gas
generateGasSphereEntity(world, x, y, z, RED_DWARF_RADIUS + 6, true, 1);
placeStarCore(world, x, y, z, RED_DWARF_RADIUS + 6);
break;
case 1: // yellow giant
generateSphereEntity(world, x, y, z, YELLOW_GIANT_RADIUS, false, Block.glowStone.blockID, 0);
// Heliosphere of yellow gas
generateGasSphereEntity(world, x, y, z, YELLOW_GIANT_RADIUS + 6, true, 3);
placeStarCore(world, x, y, z, YELLOW_GIANT_RADIUS + 6);
break;
case 2:
generateSphereEntity(world, x, y, z, YELLOW_SUPERGIANT_RADIUS, false, Block.glowStone.blockID, 0);
// Heliosphere of yellow gas
generateGasSphereEntity(world, x, y, z, YELLOW_SUPERGIANT_RADIUS + 6, true, 3);
placeStarCore(world, x, y, z, YELLOW_SUPERGIANT_RADIUS + 6);
break;
}
}
private void generateSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int blockID, int blockMeta) {
boolean isSurface = (blockID == 0);
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, radius, blockID, blockMeta, hollow, false, isSurface);
esg.xCoord = x;
esg.yCoord = y;
esg.zCoord = z;
world.spawnEntityInWorld(esg);
}
private void generateGasSphereEntity(World world, int x, int y, int z, int radius, boolean hollow, int color) {
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, radius, WarpDrive.GAS_BLOCKID, color, hollow, true, false);
esg.xCoord = x;
esg.yCoord = y;
esg.zCoord = z;
world.spawnEntityInWorld(esg);
}
private void generateSmallShip(World world, int x, int y, int z) {
x = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(10));
y = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(10));
@ -154,8 +246,9 @@ public class SpaceWorldGenerator implements IWorldGenerator {
* @param y координата центра поля
* @param z координата центра поля
*/
private void generateAsteroidField(World world, int x, int y, int z) {
public void generateAsteroidField(World world, int x, int y, int z) {
int numOfAsteroids = 15 + world.rand.nextInt(30);
int numOfClouds = 5 + world.rand.nextInt(10);
// Minimal distance between asteroids in field
final int FIELD_ASTEROID_MIN_DISTANCE = 5;
@ -186,8 +279,61 @@ public class SpaceWorldGenerator implements IWorldGenerator {
generateSmallShip(world, aX, aY, aZ);
}
}
int gasColor = world.rand.nextInt(12);
// Setting up gas clouds
for (int i = 1; i <= numOfClouds; i++) {
int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
int aY = y + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
// Placing
if (world.rand.nextInt(10) != 0) {
generateGasCloudOfColor(world, aX, aY, aZ, 12, 15, gasColor);
}
}
}
/**
* Gas cloud generator
*
* @param x x-coord of center
* @param y center
* @param z center
* @param cloudSizeMax maximum gas cloud size (by number of balls it consists)
* @param centerRadiusMax maximum radius of central ball
*/
public void generateGasCloudOfColor(World world, int x, int y, int z, int cloudSizeMax, int centerRadiusMax, int color) {
int cloudSize = 1 + world.rand.nextInt(20);
if (cloudSizeMax != 0) {
cloudSize = Math.min(cloudSizeMax, cloudSize);
}
int centerRadius = 1 + world.rand.nextInt(20);
if (centerRadiusMax != 0) {
centerRadius = Math.min(centerRadiusMax, centerRadius);
}
final int CENTER_SHIFT = 2; // Offset from center of central ball
// Asteroid's center
generateGasSphereEntity(world, x, y, z, centerRadius, false, color);
// Asteroids knolls
for (int i = 1; i <= cloudSize; i++) {
int radius = 2 + world.rand.nextInt(centerRadius);
int newX = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
int newY = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
generateGasSphereEntity(world, newX, newY, newZ, radius, false, color);
}
}
/**
* Asteroid of block generator
*
@ -236,7 +382,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
* @param asteroidSizeMax maximum asteroid size (by number of balls it consists)
* @param centerRadiusMax maximum radius of central ball
*/
private void generateAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
public void generateAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
int asteroidSize = 1 + world.rand.nextInt(6);
if (asteroidSizeMax != 0) {
@ -251,7 +397,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
final int CENTER_SHIFT = 2;
generateSphere2(world, x, y, z, centerRadius, true, 0, false);
generateSphere2(world, x, y, z, centerRadius, true, -1, false);
for (int i = 1; i <= asteroidSize; i++) {
int radius = 2 + world.rand.nextInt(centerRadius);
@ -260,10 +406,10 @@ public class SpaceWorldGenerator implements IWorldGenerator {
int newY = y + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
generateSphere2(world, newX, newY, newZ, radius, true, 0, false);
generateSphere2(world, newX, newY, newZ, radius, true, -1, false);
}
}
/**
* Sphere generator
* @param world target world
@ -307,7 +453,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
if (!corrupted || world.rand.nextInt(10) != 1)
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
blockID = (forcedID == -1) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
if (blockID == 39701) { meta = blockID % 10; blockID = blockID / 10; }
world.setBlock(xCoord + x, yCoord + y, zCoord + z, blockID, meta, 2);
world.setBlock(xCoord - x, yCoord + y, zCoord + z, blockID, meta, 2);
@ -315,7 +461,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
if (!corrupted || world.rand.nextInt(10) != 1)
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
blockID = (forcedID == -1) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
if (blockID == 39701) { meta = blockID % 10; blockID = blockID / 10; }
world.setBlock(xCoord + x, yCoord - y, zCoord + z, blockID, meta, 2);
world.setBlock(xCoord + x, yCoord + y, zCoord - z, blockID, meta, 2);
@ -323,7 +469,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
if (!corrupted || world.rand.nextInt(10) != 1)
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
blockID = (forcedID == -1) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
if (blockID == 39701) { meta = blockID % 10; blockID = blockID / 10; }
world.setBlock(xCoord - x, yCoord - y, zCoord + z, blockID, meta, 2);
world.setBlock(xCoord + x, yCoord - y, zCoord - z, blockID, meta, 2);
@ -331,7 +477,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
if (!corrupted || world.rand.nextInt(10) != 1)
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
blockID = (forcedID == -1) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
if (blockID == 39701) { meta = blockID % 10; blockID = blockID / 10; }
world.setBlock(xCoord - x, yCoord + y, zCoord - z, blockID, meta, 2);
world.setBlock(xCoord - x, yCoord - y, zCoord - z, blockID, meta, 2);
@ -345,7 +491,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
return (x * x) + (y * y) + (z * z);
}
private int getRandomSurfaceBlockID(Random random, boolean corrupted, boolean nocobble) {
public int getRandomSurfaceBlockID(Random random, boolean corrupted, boolean nocobble) {
List<Integer> ores = new ArrayList<Integer>();
ores.add(Block.oreIron.blockID);
ores.add(Block.oreGold.blockID);
@ -353,6 +499,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
ores.add(Block.oreEmerald.blockID);
ores.add(Block.oreLapis.blockID);
ores.add(Block.oreRedstoneGlowing.blockID);
ores.add(Block.oreNetherQuartz.blockID);
ores.add(247);//IC2
ores.add(248);
ores.add(249);
@ -367,7 +514,7 @@ public class SpaceWorldGenerator implements IWorldGenerator {
blockID = Block.cobblestone.blockID;
}
if (random.nextInt(10) == 1 || nocobble) {
if (random.nextInt(25) == 5 || nocobble) {
blockID = ores.get(random.nextInt(ores.size() - 1));
}
else if (random.nextInt(350) == 1 && isAELoaded) {

View file

@ -0,0 +1,153 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.FMLCommonHandler;
import ic2.api.Direction;
import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.MinecraftForge;
public class TileEntityAirGenerator extends TileEntity implements IEnergySink {
public boolean addedToEnergyNet;
private final int EU_PER_AIRBLOCK = 300;
private final int MAX_ENERGY_VALUE = 36 * EU_PER_AIRBLOCK;
private int currentEnergyValue = 0;
private int cooldownTicks = 0;
private final float AIR_POLLUTION_INTERVAL = 10;
private final int START_CONCENTRATION_VALUE = 15;
@Override
public void updateEntity() {
if (!addedToEnergyNet && !worldObj.isRemote) {
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
addedToEnergyNet = true;
}
if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
return;
}
// Air generator works only in spaces
if (worldObj.provider.dimensionId != WarpDrive.instance.spaceDimID && worldObj.provider.dimensionId != WarpDrive.instance.hyperSpaceDimID) {
return;
}
if (addedToEnergyNet && currentEnergyValue > EU_PER_AIRBLOCK) {
if (cooldownTicks++ > AIR_POLLUTION_INTERVAL) {
cooldownTicks = 0;
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 1, 2); // set enabled texture
releaseAir();
}
} else
{
if (cooldownTicks++ > 20) {
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, 0, 2); // set disabled texture
cooldownTicks = 0;
}
}
}
private void releaseAir() {
if (worldObj.isAirBlock(xCoord + 1, yCoord, zCoord) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord + 1, yCoord, zCoord, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
if (worldObj.isAirBlock(xCoord - 1, yCoord, zCoord) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord - 1, yCoord, zCoord, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
if (worldObj.isAirBlock(xCoord, yCoord + 1, zCoord) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord, yCoord + 1, zCoord, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
if (worldObj.isAirBlock(xCoord, yCoord - 1, zCoord) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord, yCoord - 1, zCoord, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
if (worldObj.isAirBlock(xCoord, yCoord, zCoord + 1) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord, yCoord, zCoord + 1, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
if (worldObj.isAirBlock(xCoord, yCoord, zCoord - 1) && (currentEnergyValue - EU_PER_AIRBLOCK >= 0)) {
worldObj.setBlock(xCoord, yCoord, zCoord - 1, WarpDrive.AIR_BLOCKID, START_CONCENTRATION_VALUE, 2);
currentEnergyValue -= EU_PER_AIRBLOCK;
}
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
this.currentEnergyValue = tag.getInteger("energy");
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setInteger("energy", this.getCurrentEnergyValue());
}
// IEnergySink methods implementation
@Override
public int demandsEnergy() {
return (MAX_ENERGY_VALUE - currentEnergyValue);
}
@Override
public int injectEnergy(Direction directionFrom, int amount) {
// Избыток энергии
int leftover = 0;
currentEnergyValue += amount;
if (getCurrentEnergyValue() > MAX_ENERGY_VALUE) {
leftover = (getCurrentEnergyValue() - MAX_ENERGY_VALUE);
currentEnergyValue = MAX_ENERGY_VALUE;
}
return leftover;
}
@Override
public int getMaxSafeInput() {
return Integer.MAX_VALUE;
}
@Override
public boolean acceptsEnergyFrom(TileEntity emitter, Direction direction) {
return true;
}
@Override
public boolean isAddedToEnergyNet() {
return addedToEnergyNet;
}
/**
* @return the currentEnergyValue
*/
public int getCurrentEnergyValue() {
return currentEnergyValue;
}
@Override
public void invalidate() {
if (addedToEnergyNet) {
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
addedToEnergyNet = false;
}
super.invalidate();
}
}

View file

@ -8,6 +8,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer;
@ -149,14 +150,14 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral {
String nick = players.get(i);
if (ep.username.equals(nick)) {
ep.sendChatToPlayer("[WarpCtrlr] Detached.");
ep.addChatMessage("[WarpCtrlr] Detached.");
players.remove(i);
return;
}
}
ep.attackEntityFrom(DamageSource.generic, 1);
ep.sendChatToPlayer("[WarpCtrlr] Successfully attached.");
ep.addChatMessage("[WarpCtrlr] Successfully attached.");
players.add(ep.username);
updatePlayersString();
}
@ -345,7 +346,75 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral {
}
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception {
public boolean canAttachToSide(int side) {
return true;
}
@Override
public void attach(IComputerAccess computer) {
}
@Override
public void detach(IComputerAccess computer) {
}
/**
* @return the toSummon
*/
public String getToSummon() {
return toSummon;
}
/**
* @param toSummon the toSummon to set
*/
public void setToSummon(String toSummon) {
this.toSummon = toSummon;
}
/**
* @return the beaconFrequency
*/
public String getBeaconFrequency() {
return beaconFrequency;
}
/**
* @param beaconFrequency the beaconFrequency to set
*/
public void setBeaconFrequency(String beaconFrequency) {
//System.out.println("Setting beacon freqency: " + beaconFrequency);
this.beaconFrequency = beaconFrequency;
}
public TileEntity findCoreBlock() {
this.core = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
return null;
}
@Override
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
//System.out.println("[ProtoBlock] Method " + method + " " + methodsArray[method] + " called!");
switch (method)
@ -510,72 +579,4 @@ public class TileEntityProtocol extends TileEntity implements IPeripheral {
return new Integer[] { 0 };
}
@Override
public boolean canAttachToSide(int side) {
return true;
}
@Override
public void attach(IComputerAccess computer) {
}
@Override
public void detach(IComputerAccess computer) {
}
/**
* @return the toSummon
*/
public String getToSummon() {
return toSummon;
}
/**
* @param toSummon the toSummon to set
*/
public void setToSummon(String toSummon) {
this.toSummon = toSummon;
}
/**
* @return the beaconFrequency
*/
public String getBeaconFrequency() {
return beaconFrequency;
}
/**
* @param beaconFrequency the beaconFrequency to set
*/
public void setBeaconFrequency(String beaconFrequency) {
//System.out.println("Setting beacon freqency: " + beaconFrequency);
this.beaconFrequency = beaconFrequency;
}
public TileEntity findCoreBlock() {
this.core = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
this.core = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
if (this.core != null && this.core instanceof TileEntityReactor) {
return this.core;
}
return null;
}
}

View file

@ -4,6 +4,7 @@ import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import dan200.computer.api.ILuaContext;
import dan200.computer.api.IPeripheral;
import ic2.api.Direction;
import ic2.api.energy.event.EnergyTileLoadEvent;
@ -96,7 +97,7 @@ public class TileEntityRadar extends TileEntity implements IPeripheral, IEnergyS
}
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception {
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
switch (method) {
case 0: // scanRay (toX, toY, toZ)
return new Object[] { -1 };
@ -235,5 +236,4 @@ public class TileEntityRadar extends TileEntity implements IPeripheral, IEnergyS
}
super.invalidate();
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,6 @@
package cr0s.WarpDrive;
import cpw.mods.fml.common.FMLCommonHandler;
import java.util.List;
import cpw.mods.fml.common.Mod;
@ -7,12 +8,13 @@ import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.ServerStarting;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import ic2.api.item.Items;
@ -28,8 +30,8 @@ import net.minecraftforge.common.ForgeChunkManager.LoadingCallback;
import net.minecraftforge.common.ForgeChunkManager.Ticket;
import net.minecraftforge.common.MinecraftForge;
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.0.0")
@NetworkMod(clientSideRequired = false, serverSideRequired = true)
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.0.1")
@NetworkMod(clientSideRequired = true, serverSideRequired = true)
/**
* @author Cr0s
*/
@ -39,6 +41,12 @@ public class WarpDrive implements LoadingCallback {
public final static int PROTOCOL_BLOCK_BLOCKID = 501;
public final static int RADAR_BLOCK_BLOCKID = 502;
public final static int ISOLATION_BLOCKID = 503;
public final static int AIR_BLOCKID = 504;
public final static int AIRGEN_BLOCKID = 505;
public final static int GAS_BLOCKID = 506;
// World limits
public final static int WORLD_LIMIT_BLOCKS = 100000;
public final static Block warpCore = new BlockReactor(WARP_CORE_BLOCKID, 0, Material.rock)
.setHardness(0.5F).setStepSound(Block.soundMetalFootstep)
@ -55,24 +63,39 @@ public class WarpDrive implements LoadingCallback {
public final static Block isolationBlock = new BlockWarpIsolation(ISOLATION_BLOCKID, 0, Material.rock)
.setHardness(0.5F).setStepSound(Block.soundMetalFootstep)
.setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Warp-Field Isolation Block");
/**
*
*/
public final static Block airgenBlock = new BlockAirGenerator(AIRGEN_BLOCKID, 0, Material.rock)
.setHardness(0.5F).setStepSound(Block.soundMetalFootstep)
.setCreativeTab(CreativeTabs.tabRedstone).setUnlocalizedName("Air Generator");
public final static Block airBlock = (new BlockAir(AIR_BLOCKID)).setHardness(0.0F).setUnlocalizedName("Air block");
public final static Block gasBlock = (new BlockGas(GAS_BLOCKID)).setHardness(0.0F).setUnlocalizedName("Gas block");
public static BiomeGenBase spaceBiome;
public World space;
private int spaceProviderID;
public int spaceDimID;
public SpaceWorldGenerator spaceWorldGenerator;
public HyperSpaceWorldGenerator hyperSpaceWorldGenerator;
public World hyperSpace;
private int hyperSpaceProviderID;
public int hyperSpaceDimID;
@Instance("WarpDrive")
public static WarpDrive instance;
@SidedProxy(clientSide = "cr0s.WarpDrive.ClientProxy", serverSide = "cr0s.WarpDrive.CommonProxy")
public static CommonProxy proxy;
public WarpCoresRegistry registry;
@PreInit
public void preInit(FMLPreInitializationEvent event) {
// Stub Method
if(FMLCommonHandler.instance().getSide().isClient())
{
System.out.println("[WarpDrive] Registering sounds event handler...");
MinecraftForge.EVENT_BUS.register(new SoundHandler());
}
}
@Init
@ -93,21 +116,35 @@ public class WarpDrive implements LoadingCallback {
LanguageRegistry.addName(isolationBlock, "Warp-Field Isolation Block");
GameRegistry.registerBlock(isolationBlock, "isolationBlock");
EntityRegistry.registerModEntity(EntitySphereGen.class, "EntitySphereGenerator", 1, WarpDrive.instance, 100, 1, false);
proxy.registerJumpEntity();
LanguageRegistry.addName(airBlock, "Air block");
GameRegistry.registerBlock(airBlock, "airBlock");
LanguageRegistry.addName(gasBlock, "Gas block");
GameRegistry.registerBlock(gasBlock, "gasBlock");
LanguageRegistry.addName(airgenBlock, "Air Generator");
GameRegistry.registerBlock(airgenBlock, "airgenBlock");
GameRegistry.registerTileEntity(TileEntityAirGenerator.class, "airgenBlock");
proxy.registerEntities();
ForgeChunkManager.setForcedChunkLoadingCallback(instance, instance);
spaceWorldGenerator = new SpaceWorldGenerator();
GameRegistry.registerWorldGenerator(spaceWorldGenerator);
hyperSpaceWorldGenerator = new HyperSpaceWorldGenerator();
GameRegistry.registerWorldGenerator(hyperSpaceWorldGenerator);
registerSpaceDimension();
registerHyperSpaceDimension();
MinecraftForge.EVENT_BUS.register(new SpaceEventHandler());
}
@PostInit
public void postInit(FMLPostInitializationEvent event) {
space = DimensionManager.getWorld(spaceDimID);
hyperSpace = DimensionManager.getWorld(hyperSpaceDimID);
GameRegistry.addRecipe(new ItemStack(warpCore), "ici", "cmc", "ici",
'i', Items.getItem("iridiumPlate"), 'm', Items.getItem("advancedMachine"), 'c', Items.getItem("advancedCircuit"));
@ -121,6 +158,9 @@ public class WarpDrive implements LoadingCallback {
GameRegistry.addRecipe(new ItemStack(isolationBlock), "iii", "idi", "iii",
'i', Items.getItem("iridiumPlate"), 'm', Items.getItem("advancedMachine"), 'd', Block.blockDiamond);
GameRegistry.addRecipe(new ItemStack(airgenBlock), "lcl", "lml", "lll",
'l', Block.leaves, 'm', Items.getItem("advancedMachine"), 'c', Items.getItem("advancedCircuit"));
registry = new WarpCoresRegistry();
}
@ -133,6 +173,21 @@ public class WarpDrive implements LoadingCallback {
DimensionManager.registerDimension(this.spaceDimID, this.spaceProviderID);
}
private void registerHyperSpaceDimension() {
this.hyperSpaceProviderID = 15;
DimensionManager.registerProviderType(this.hyperSpaceProviderID, HyperSpaceProvider.class, true);
this.hyperSpaceDimID = DimensionManager.getNextFreeDimId();
DimensionManager.registerDimension(this.hyperSpaceDimID, this.hyperSpaceProviderID);
}
@ServerStarting
public void serverLoad(FMLServerStartingEvent event)
{
event.registerServerCommand(new GenerateCommand());
event.registerServerCommand(new SpaceTpCommand());
}
@Override
public void ticketsLoaded(List<Ticket> tickets, World world) {
for(Ticket ticket : tickets) {

View file

@ -43,8 +43,12 @@ public class WorldGenSmallShip extends WorldGenerator
break;
}
final int ADV_SOLAR_BLOCKID = 194;
int ADV_SOLAR_BLOCKID = 194;
int solarType = rand.nextInt(2);
if (!isAdvSolPanelLoaded) {
ADV_SOLAR_BLOCKID = Items.getItem("solarPanel").itemID;
solarType = Items.getItem("solarPanel").getItemDamage();
}
world.setBlock(i + 0, j + 1, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 0, j + 1, k + 10, WorldGenStructure.getStoneBlock(corrupted, rand));
@ -290,6 +294,9 @@ public class WorldGenSmallShip extends WorldGenerator
world.setBlock(i + 9, j + 6, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 9, j + 6, k + 6, cableType.itemID, cableType.getItemDamage(), 0);
world.setBlock(i + 9, j + 6, k + 7, ADV_SOLAR_BLOCKID, solarType, 0);
// Placing air generator
world.setBlock(i + 9, j + 5, k + 7, WarpDrive.AIRGEN_BLOCKID, 0, 0);
world.setBlock(i + 9, j + 6, k + 10, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 9, j + 6, k + 11, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 9, j + 7, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));
@ -328,6 +335,10 @@ public class WorldGenSmallShip extends WorldGenerator
world.setBlock(i + 10, j + 6, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 10, j + 6, k + 6, cableType.itemID, cableType.getItemDamage(), 0);
world.setBlock(i + 10, j + 6, k + 7, ADV_SOLAR_BLOCKID, solarType, 0);
// Placing air generator
world.setBlock(i + 10, j + 5, k + 7, WarpDrive.AIRGEN_BLOCKID, 0, 0);
world.setBlock(i + 10, j + 6, k + 10, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 10, j + 6, k + 11, WorldGenStructure.getStoneBlock(corrupted, rand));
world.setBlock(i + 10, j + 7, k + 4, WorldGenStructure.getStoneBlock(corrupted, rand));

View file

@ -1,13 +1,10 @@
package cr0s.WarpDrive.client;
import cr0s.WarpDrive.CommonProxy;
import net.minecraftforge.client.MinecraftForgeClient;
public class ClientProxy extends CommonProxy {
@Override
public void registerRenderers() {
System.out.println("[WD] Preloading textures...");
MinecraftForgeClient.preloadTexture(CommonProxy.BLOCK_TEXTURE);
}
}

View file

@ -1,37 +1,37 @@
package cr0s.serverMods;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingFallEvent;
/**
* Гашение урона при падении с джетпаком или квантовыми бутсами
* @author Cr0s
*/
public class AntiFallDamage {
private final int JETPACK_ID = 30210;
private final int ELECTRIC_JETPACK_ID = 30209;
private final int QUANTUM_BOOTS_ID = 30171;
@ForgeSubscribe
public void livingFall(LivingFallEvent event) {
EntityLiving entity = event.entityLiving;
float distance = event.distance;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
int check = MathHelper.ceiling_float_int(distance - 3.0F);
if (check > 0) { // Падение может нанести урон
// Проверяем наличие защиты
if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == QUANTUM_BOOTS_ID) ||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == JETPACK_ID) ||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == ELECTRIC_JETPACK_ID)) {
event.setCanceled(true); // Блокируем падение, если защита есть
}
}
}
}
}
package cr0s.serverMods;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;
import net.minecraftforge.event.ForgeSubscribe;
import net.minecraftforge.event.entity.living.LivingFallEvent;
/**
* Гашение урона при падении с джетпаком или квантовыми бутсами
* @author Cr0s
*/
public class AntiFallDamage {
private final int JETPACK_ID = 30210;
private final int ELECTRIC_JETPACK_ID = 30209;
private final int QUANTUM_BOOTS_ID = 30171;
@ForgeSubscribe
public void livingFall(LivingFallEvent event) {
EntityLivingBase entity = event.entityLiving;
float distance = event.distance;
if (entity instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) entity;
int check = MathHelper.ceiling_float_int(distance - 3.0F);
if (check > 0) { // Падение может нанести урон
// Проверяем наличие защиты
if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == QUANTUM_BOOTS_ID) ||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == JETPACK_ID) ||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == ELECTRIC_JETPACK_ID)) {
event.setCanceled(true); // Блокируем падение, если защита есть
}
}
}
}
}