Planned update

This commit is contained in:
Anus 2013-05-19 17:52:40 +04:00
parent c514a08b99
commit 9824396ebb
12 changed files with 906 additions and 688 deletions

View file

@ -12,13 +12,13 @@ import net.minecraft.world.World;
public class BlockProtocol extends BlockContainer { public class BlockProtocol extends BlockContainer {
BlockProtocol(int id, int texture, Material material) { BlockProtocol(int id, int texture, Material material) {
super(id, texture, material); super(id, material);
} }
@Override // @Override
public String getTextureFile () { // public String getTextureFile () {
return CommonProxy.BLOCK_TEXTURE; // return CommonProxy.BLOCK_TEXTURE;
} // }
@Override @Override
public TileEntity createNewTileEntity(World var1) { public TileEntity createNewTileEntity(World var1) {

View file

@ -12,13 +12,13 @@ import net.minecraft.world.World;
public class BlockReactor extends BlockContainer { public class BlockReactor extends BlockContainer {
BlockReactor(int id, int texture, Material material) { BlockReactor(int id, int texture, Material material) {
super(id, texture, material); super(id, material);
} }
@Override // @Override
public String getTextureFile () { // public String getTextureFile () {
return CommonProxy.BLOCK_TEXTURE; // return CommonProxy.BLOCK_TEXTURE;
} // }
@Override @Override
public TileEntity createNewTileEntity(World var1) { public TileEntity createNewTileEntity(World var1) {

View file

@ -2,6 +2,7 @@ package cr0s.WarpDrive;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IPeripheral;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -100,6 +101,7 @@ public class EntityJump extends Entity {
} }
public void killEntity(String reason) { public void killEntity(String reason) {
System.out.println("[JE] Tick:");
if (!on) { return; } if (!on) { return; }
on = false; on = false;
@ -112,7 +114,7 @@ public class EntityJump extends Entity {
unlockWorlds(); unlockWorlds();
try { try {
if (!this.fromSpace && !this.toSpace) { worldObj.setEntityDead(this); } if (!this.fromSpace && !this.toSpace) { worldObj.removeEntity(this); }
//this.getTargetWorld().setEntityDead(this); //this.getTargetWorld().setEntityDead(this);
//this.setDead(); //this.setDead();
} catch (Exception e) { } catch (Exception e) {
@ -125,7 +127,7 @@ public class EntityJump extends Entity {
public void onUpdate() { public void onUpdate() {
if (!on) { if (!on) {
unlockWorlds(); unlockWorlds();
this.setDead(); worldObj.removeEntity(this);
return; return;
} }
@ -133,18 +135,19 @@ public class EntityJump extends Entity {
this.killEntity("Y-coord error!"); this.killEntity("Y-coord error!");
return; return;
} }
// Пропустить тик, ожидая генерации чанков // Пропустить тик, ожидая генерации чанков
//if (!checkForChunksGeneratedIn(getTargetWorld())) { if ((getTargetWorld().provider.dimensionId == worldObj.provider.dimensionId) && !checkForChunksGeneratedIn(getTargetWorld())) {
// return; return;
//} }
if (!isJumping) { if (!isJumping) {
this.toSpace = (dir == -1 && (maxY + distance > 255) && worldObj.provider.dimensionId != WarpDrive.instance.spaceDimID);
this.fromSpace = (dir == -2 && (minY - distance < 0) && worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID);
System.out.println("[JE] Preparing to jump..."); System.out.println("[JE] Preparing to jump...");
axisalignedbb = AxisAlignedBB.getBoundingBox(Xmin, minY, Zmin, Xmax, maxY, Zmax); axisalignedbb = AxisAlignedBB.getBoundingBox(Xmin, minY, Zmin, Xmax, maxY, Zmax);
this.toSpace = (dir == -1 && (maxY + distance > 255) && worldObj.provider.dimensionId != WarpDrive.instance.spaceDimID);
this.fromSpace = (dir == -2 && (minY - distance < 0) && worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID);
prepareToJump(); prepareToJump();
} else { } else {
if (currentIndexInShip >= ship.length-1) { if (currentIndexInShip >= ship.length-1) {
@ -168,22 +171,24 @@ public class EntityJump extends Entity {
} }
public void lockWorlds() { public void lockWorlds() {
getTargetWorld().editingBlocks = true; System.out.println("Locking worlds...");
getTargetWorld().isRemote = true;
// При прыжках между измерениями необходимо блокировать текущий мир // При прыжках между измерениями необходимо блокировать текущий мир
// Для предотвращения рассыпания проводов на корабле // Для предотвращения рассыпания проводов на корабле
if (getTargetWorld().provider.dimensionId != worldObj.provider.dimensionId) { if (getTargetWorld().provider.dimensionId != worldObj.provider.dimensionId) {
worldObj.editingBlocks = true; worldObj.isRemote = true;
} }
} }
public void unlockWorlds() { public void unlockWorlds() {
getTargetWorld().editingBlocks = false; System.out.println("Unlocking worlds..");
getTargetWorld().isRemote = false;
// При прыжках между измерениями необходимо блокировать оба мира // При прыжках между измерениями необходимо блокировать оба мира
// Для предотвращения рассыпания проводов на корабле // Для предотвращения рассыпания проводов на корабле
if (getTargetWorld().provider.dimensionId != worldObj.provider.dimensionId) { if (getTargetWorld().provider.dimensionId != worldObj.provider.dimensionId) {
worldObj.editingBlocks = false; worldObj.isRemote = false;
} }
} }
@ -235,8 +240,8 @@ public class EntityJump extends Entity {
int chunkZ = newZ >> 4; int chunkZ = newZ >> 4;
if (!w.getChunkProvider().chunkExists(chunkX, chunkZ)) { if (!w.getChunkProvider().chunkExists(chunkX, chunkZ)) {
System.out.println("[JE] Need to generate chunk at (" + chunkX + "; " + chunkZ + "). Creating fake player"); messageToAllPlayersOnShip("Generating chunks...");
w.getChunkProvider().provideChunk(chunkX, chunkZ); int blockID = w.getBlockId(newX, 128, newZ);
return false; return false;
} }
@ -286,7 +291,10 @@ public class EntityJump extends Entity {
} }
if (!betweenWorlds) { if (!betweenWorlds) {
distance = getPossibleJumpDistance(); // Не проверять при дальних прыжках
if (this.distance < 256) {
distance = getPossibleJumpDistance();
}
} else { } else {
distance = 1; distance = 1;
} }
@ -335,7 +343,7 @@ public class EntityJump extends Entity {
} }
//System.out.println("[EJ] Removing block: " + jb.x + " " + jb.y + " " + jb.z + " " + jb.blockID); //System.out.println("[EJ] Removing block: " + jb.x + " " + jb.y + " " + jb.z + " " + jb.blockID);
worldObj.setBlockAndMetadata(jb.x, jb.y, jb.z, 0, 0); worldObj.setBlockToAir(jb.x, jb.y, jb.z);
} }
} }
@ -416,6 +424,7 @@ public class EntityJump extends Entity {
* прыжок невозможен в принципе * прыжок невозможен в принципе
*/ */
public int getPossibleJumpDistance() { public int getPossibleJumpDistance() {
System.out.println("[JUMP] Calculating possible jump distance...");
int testDistance = this.distance; int testDistance = this.distance;
boolean canJump; boolean canJump;
@ -994,12 +1003,12 @@ public class EntityJump extends Entity {
if (!toSpace && !fromSpace) if (!toSpace && !fromSpace)
{ {
worldObj.setBlockAndMetadataWithNotify(newX, newY, newZ, blockID, blockMeta); worldObj.setBlock(newX, newY, newZ, blockID, blockMeta, 2);
} else if (toSpace) } else if (toSpace)
{ {
spaceWorld.setBlockAndMetadataWithNotify(newX, newY, newZ, blockID, blockMeta); spaceWorld.setBlock(newX, newY, newZ, blockID, blockMeta, 2);
} else if (fromSpace) { } else if (fromSpace) {
surfaceWorld.setBlockAndMetadataWithNotify(newX, newY, newZ, blockID, blockMeta); surfaceWorld.setBlock(newX, newY, newZ, blockID, blockMeta, 2);
} }
NBTTagCompound oldnbt = new NBTTagCompound(); NBTTagCompound oldnbt = new NBTTagCompound();
@ -1008,21 +1017,39 @@ public class EntityJump extends Entity {
if (shipBlock.blockTileEntity != null && blockID != 159 && blockID != 149 && blockID != 156 && blockID != 146 && blockID != 145) { if (shipBlock.blockTileEntity != null && blockID != 159 && blockID != 149 && blockID != 156 && blockID != 146 && blockID != 145) {
shipBlock.blockTileEntity.writeToNBT(oldnbt); shipBlock.blockTileEntity.writeToNBT(oldnbt);
TileEntity newTileEntity = null; TileEntity newTileEntity = null;
oldnbt.setInteger("x", newX);
oldnbt.setInteger("y", newY);
oldnbt.setInteger("z", newZ);
if (!toSpace && !fromSpace) { newTileEntity = TileEntity.createAndLoadEntity(oldnbt);
newTileEntity.invalidate();
/*if (!toSpace && !fromSpace) {
newTileEntity = worldObj.getBlockTileEntity(newX, newY, newZ); newTileEntity = worldObj.getBlockTileEntity(newX, newY, newZ);
} else if (toSpace) { } else if (toSpace) {
newTileEntity = spaceWorld.getBlockTileEntity(newX, newY, newZ); newTileEntity = spaceWorld.getBlockTileEntity(newX, newY, newZ);
} else if (fromSpace) { } else if (fromSpace) {
newTileEntity = surfaceWorld.getBlockTileEntity(newX, newY, newZ); newTileEntity = surfaceWorld.getBlockTileEntity(newX, newY, newZ);
} }*/
if (newTileEntity == null) { if (newTileEntity == null) {
System.out.println("PIZDEC!!!"); System.out.println("PIZDEC!!!");
return false; // PIZDEC!!! return false; // PIZDEC!!!
} }
/*
newTileEntity.invalidate();
newTileEntity.readFromNBT(oldnbt); newTileEntity.readFromNBT(oldnbt);
newTileEntity.xCoord = newX;
newTileEntity.yCoord = newY;
newTileEntity.zCoord = newZ;
*/
newTileEntity.worldObj = getTargetWorld();
newTileEntity.validate();
if (!toSpace && !fromSpace) if (!toSpace && !fromSpace)
{ {
worldObj.setBlockTileEntity(newX, newY, newZ, newTileEntity); worldObj.setBlockTileEntity(newX, newY, newZ, newTileEntity);
@ -1035,7 +1062,13 @@ public class EntityJump extends Entity {
surfaceWorld.setBlockTileEntity(newX, newY, newZ, newTileEntity); surfaceWorld.setBlockTileEntity(newX, newY, newZ, newTileEntity);
} }
worldObj.removeBlockTileEntity(oldX, oldY, oldZ); worldObj.removeBlockTileEntity(oldX, oldY, oldZ);
if (newTileEntity.getClass().getName().contains("TileEntityComputer") && newTileEntity instanceof IPeripheral)
{
System.out.println(((IPeripheral)newTileEntity).getMethodNames());
}
} }
} catch (Exception exception) { } catch (Exception exception) {
exception.printStackTrace(); exception.printStackTrace();

View file

@ -0,0 +1,167 @@
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.nbt.NBTTagCompound;
import net.minecraft.world.World;
public final class EntitySphereGen extends Entity {
public int xCoord;
public int yCoord;
public int zCoord;
public int type;
public int blockID;
public double radius, radiusSq, radius1Sq, surfaceRadius;
public int ceilRadius;
public boolean hollow = false;
private final int BLOCKS_PER_TICK = 2500;
private final int TYPE_STAR = 1;
private int currX, currY, currZ;
int blocksPassed, blocksTotal;
public boolean on;
public EntitySphereGen(World world) {
super(world);
}
public EntitySphereGen(World world, int x, int y, int z, int type) {
super(world);
this.xCoord = x;
this.posX = (double) x;
this.yCoord = y;
this.posY = (double) y;
this.zCoord = z;
this.posZ = (double) z;
this.currX = 0;
this.currY = 0;
this.currZ = 0;
this.type = type;
if (type == TYPE_STAR)
{
blockID = Block.glowStone.blockID;
//hollow = true;
surfaceRadius = 10D;
radius = 64D;
}
//radius += 0.5D;
radiusSq = radius * radius;
radius1Sq = (radius - 1.0D) * (radius - 1.0D);
ceilRadius = (int) Math.ceil(radius);
startGenerate();
}
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;
worldObj.removeEntity(this);
}
@SideOnly(Side.SERVER)
@Override
public void onUpdate() {
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;
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;
// }
if (dSq > radiusSq) {
continue;
}
if ((hollow) && (
(dSq < radius1Sq) || ((lengthSq(currX + 1, currY, currZ) <= radiusSq) && (lengthSq(currX, currY + 1, currZ) <= radiusSq) && (lengthSq(currX, currY, currZ + 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);
}
}
}
System.out.println(" [tick done]");
}
private static double lengthSq(double x, double y, double z) {
return (x * x) + (y * y) + (z * z);
}
@Override
protected void readEntityFromNBT(NBTTagCompound nbttagcompound) {
}
@Override
protected void entityInit() {
System.out.println("[SGEN] entityInit() called");
}
@Override
protected void writeEntityToNBT(NBTTagCompound var1) {
}
}

View file

@ -29,6 +29,7 @@ public class SpaceGenerator extends ChunkProviderGenerate implements IChunkProvi
public SpaceGenerator(World par1World, long par2) { public SpaceGenerator(World par1World, long par2) {
super(par1World, par2, false); super(par1World, par2, false);
rand = new Random();
this.worldObj = par1World; this.worldObj = par1World;
} }
@ -141,12 +142,6 @@ public class SpaceGenerator extends ChunkProviderGenerate implements IChunkProvi
MinecraftForge.EVENT_BUS.post(event); MinecraftForge.EVENT_BUS.post(event);
if (event.getResult() == Event.Result.DENY) return; */ if (event.getResult() == Event.Result.DENY) return; */
} }
@Override
public boolean unload100OldestChunks() {
// TODO Auto-generated method stub
return super.unload100OldestChunks();
}
@Override @Override
public boolean canSave() { public boolean canSave() {

View file

@ -91,12 +91,6 @@ public class SpaceProvider extends WorldProvider {
} }
} }
@SideOnly(Side.CLIENT)
@Override
public int getMoonPhase(long par1, float par3) {
return 4;
}
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
@Override @Override
public String getSaveFolder() { public String getSaveFolder() {
@ -171,25 +165,25 @@ public class SpaceProvider extends WorldProvider {
{ {
var5.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; var5.posX += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
var5.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf; var5.posZ += this.worldObj.rand.nextInt(spawnFuzz) - spawnFuzzHalf;
var5.posY = 250; var5.posY = 200;
} }
if (worldObj.isAirBlock(var5.posX, var5.posY, var5.posZ)) { if (worldObj.isAirBlock(var5.posX, var5.posY, var5.posZ)) {
worldObj.setBlockWithNotify(var5.posX, var5.posY, var5.posZ, Block.stone.blockID); worldObj.setBlock(var5.posX, var5.posY, var5.posZ, Block.stone.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX + 1, var5.posY + 1, var5.posZ, Block.glass.blockID); worldObj.setBlock(var5.posX + 1, var5.posY + 1, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX + 1, var5.posY + 2, var5.posZ, Block.glass.blockID); worldObj.setBlock(var5.posX + 1, var5.posY + 2, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX - 1, var5.posY + 1, var5.posZ, Block.glass.blockID); worldObj.setBlock(var5.posX - 1, var5.posY + 1, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX - 1, var5.posY + 2, var5.posZ, Block.glass.blockID); worldObj.setBlock(var5.posX - 1, var5.posY + 2, var5.posZ, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX, var5.posY + 1, var5.posZ + 1, Block.glass.blockID); worldObj.setBlock(var5.posX, var5.posY + 1, var5.posZ + 1, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX, var5.posY + 2, var5.posZ + 1, Block.glass.blockID); worldObj.setBlock(var5.posX, var5.posY + 2, var5.posZ + 1, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX, var5.posY + 1, var5.posZ - 1, Block.glass.blockID); worldObj.setBlock(var5.posX, var5.posY + 1, var5.posZ - 1, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX, var5.posY + 2, var5.posZ - 1, Block.glass.blockID); worldObj.setBlock(var5.posX, var5.posY + 3, var5.posZ - 1, Block.glass.blockID, 0, 2);
worldObj.setBlockWithNotify(var5.posX, var5.posY + 3, var5.posZ, Block.glass.blockID); //worldObj.setBlockWithNotify(var5.posX, var5.posY + 3, var5.posZ, Block.glass.blockID);
} }
return var5; return var5;
} }

View file

@ -34,13 +34,16 @@ public class SpaceTeleporter extends Teleporter {
//player.setWorld(world); //player.setWorld(world);
//player.setPositionAndUpdate(x, y, z); //player.setPositionAndUpdate(x, y, z);
} }
@Override @Override
public boolean func_85188_a(Entity par1Entity) { public boolean makePortal(Entity par1Entity)
return true; {
} return false;
}
@Override @Override
public void func_85189_a(long par1) { public boolean placeInExistingPortal(Entity par1Entity, double par2, double par4, double par6, float par8)
} {
return false;
}
} }

View file

@ -1,372 +1,356 @@
/* package cr0s.WarpDrive;
* To change this template, choose Tools | Templates
* and open the template in the editor. import cpw.mods.fml.common.IWorldGenerator;
*/ import java.util.Random;
package cr0s.WarpDrive; import net.minecraft.block.Block;
import net.minecraft.world.World;
import cpw.mods.fml.common.IWorldGenerator; import net.minecraft.world.chunk.IChunkProvider;
import java.util.Random;
import java.util.Vector; /**
import net.minecraft.block.Block; * @author Cr0s
import net.minecraft.world.World; */
import net.minecraft.world.chunk.IChunkProvider; public class SpaceWorldGenerator implements IWorldGenerator {
/** // Radius of simple moon
* public final int MOON_RADIUS = 32;
* @author user public final int MOON_CORE_RADIUS = 10;
*/
public class SpaceWorldGenerator implements IWorldGenerator { // Star radius
public final int STAR_RADIUS = 80;
// Радиус простой луны
public final int MOON_RADIUS = 32; // Upper than 128 almost nothing will be generated
public final int MOON_CORE_RADIUS = 5; public final int Y_LIMIT = 128;
// Lower limit
// Радиус звезды public final int Y_LIMIT_DOWN = 55;
public final int STAR_RADIUS = 80;
/**
// Выше 128 по Y почти ничего не будет сгенерировано * Generator for chunk
public final int Y_LIMIT = 128; * @param random
// Лимит по Y снизу * @param chunkX
public final int Y_LIMIT_DOWN = 55; * @param chunkZ
* @param world
/** * @param chunkGenerator
* Генерация для чанка * @param chunkProvider
* @param random */
* @param chunkX @Override
* @param chunkZ public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
* @param world if (world.provider.dimensionId != WarpDrive.instance.spaceDimID) {
* @param chunkGenerator return;
* @param chunkProvider }
*/
@Override int x = (chunkX * 16) + (5 - random.nextInt(10));
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) { int z = (chunkZ * 16) + (5 - random.nextInt(10));
if (world.provider.dimensionId != WarpDrive.instance.spaceDimID) {
return; int y = Y_LIMIT_DOWN + random.nextInt(Y_LIMIT - Y_LIMIT_DOWN);
}
// Moon setup
int x = (chunkX * 16) + (5 - random.nextInt(10)); if (random.nextInt(8000) == 1) {
int z = (chunkZ * 16) + (5 - random.nextInt(10)); System.out.println("Generating moon at " + x + " " + y + " " + z);
generateSphere2(world, x, y, z, MOON_RADIUS, false, 0, false);
int y = Y_LIMIT_DOWN + random.nextInt(Y_LIMIT - Y_LIMIT_DOWN);
// Generate moon's core
// Установка луны generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, Block.lavaStill.blockID, false); // Lava core
if (random.nextInt(8000) == 1) { generateSphere2(world, x, y, z, MOON_CORE_RADIUS + 1, false, Block.obsidian.blockID, true); // Obsidian shell
System.out.println("Generating moon at " + x + " " + y + " " + z);
generateSphere2(world, x, y, z, MOON_RADIUS, false, 0, false); return;
}
// Генерация ядра луны
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, Block.lavaStill.blockID, false); // Лавовое ядро // FIXME: Star setup
generateSphere2(world, x, y, z, MOON_CORE_RADIUS, false, Block.obsidian.blockID, false); // Обсидиановая оболочка /*if (random.nextInt(250) == 1) {
EntitySphereGen esg = new EntitySphereGen(world, x, y, z, 1);
return; esg.xCoord = x;
} esg.yCoord = y;
esg.zCoord = z;
// Установка звезды
// DISABLED DUE LAG esg.on = true;
/*if (random.nextInt(10000) == 1) {
System.out.println("Generating star at " + x + " " + y + " " + z); world.spawnEntityInWorld(esg);
generateSphere2(world, x, y, z, STAR_RADIUS, false, Block.glowStone.blockID, true);
generateSphere2(world, x, y, z, STAR_RADIUS -1, false, Block.glowStone.blockID, true); return;
generateSphere2(world, x, y, z, STAR_RADIUS -2, false, Block.glowStone.blockID, true); }*/
return;
}*/ // Simple asteroids
if (random.nextInt(200) == 1) {
// Простые астероиды System.out.println("Generating asteroid at " + x + " " + y + " " + z);
if (random.nextInt(200) == 1) { generateAsteroid(world, x, y, z, 6, 11);
System.out.println("Generating asteroid at " + x + " " + y + " " + z); return;
generateAsteroid(world, x, y, z, 6, 11); }
return;
} if (random.nextInt(1000) == 1) {
generateRandomAsteroid(world, x, y, z, 6, 11);
if (random.nextInt(2000) == 1) { }
generateRandomAsteroid(world, x, y, z, 6, 11);
} // Ice asteroid
if (random.nextInt(2000) == 1) {
// Ледяные астероиды System.out.println("Generating ice asteroid at " + x + " " + y + " " + z);
if (random.nextInt(2000) == 1) { generateAsteroidOfBlock(world, x, y, z, 6, 11, Block.ice.blockID);
System.out.println("Generating ice asteroid at " + x + " " + y + " " + z);
generateAsteroidOfBlock(world, x, y, z, 6, 11, Block.ice.blockID); return;
}
return;
} // Asteroid field
if (random.nextInt(3000) == 1) {
// Астероидные поля System.out.println("Generating asteroid field at " + x + " " + y + " " + z);
if (random.nextInt(3000) == 1) { generateAsteroidField(world, x, y, z);
System.out.println("Generating asteroid field at " + x + " " + y + " " + z);
generateAsteroidField(world, x, y, z); return;
}
return;
} // Diamond asteroid
if (random.nextInt(10000) == 1) {
// Алмазные астероиды System.out.println("Generating diamond asteroid at " + x + " " + y + " " + z);
if (random.nextInt(10000) == 1) { generateAsteroidOfBlock(world, x, y, z, 4, 6, Block.oreDiamond.blockID);
System.out.println("Generating diamond asteroid at " + x + " " + y + " " + z);
generateAsteroidOfBlock(world, x, y, z, 4, 6, Block.oreDiamond.blockID); // Diamond block core
world.setBlock(x, y, z, Block.blockDiamond.blockID, 0, 2);
// Ядро астероида из алмаза
world.setBlockWithNotify(x, y, z, Block.blockDiamond.blockID); // return;
}
return; }
}
} private void generateRandomAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
Random random = new Random();
private void generateRandomAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
Random random = new Random(); if (random.nextInt(30) == 1) {
System.out.println("Generating random asteroid of block at " + x + "; " + y + "; " + z);
if (random.nextInt(100) == 1) { generateAsteroidOfBlock(world, x, y, z, asteroidSizeMax, centerRadiusMax, getRandomSurfaceBlockID(random, false, true));
generateAsteroidOfBlock(world, x, y, z, asteroidSizeMax, centerRadiusMax, getRandomSurfaceBlockID(random, false)); } else {
} else { generateAsteroid(world, x, y, z, asteroidSizeMax, centerRadiusMax);
generateAsteroid(world, x, y, z, asteroidSizeMax, centerRadiusMax); }
} }
}
/**
/** * Asteroid field generator
* Генератор поля астероидов * @param world мир
* @param world мир * @param x координата центра поля
* @param x координата центра поля * @param y координата центра поля
* @param y координата центра поля * @param z координата центра поля
* @param z координата центра поля */
*/ private void generateAsteroidField(World world, int x, int y, int z) {
private void generateAsteroidField(World world, int x, int y, int z) { int numOfAsteroids = 15 + world.rand.nextInt(30);
int numOfAsteroids = 15 + world.rand.nextInt(30);
// Minimal distance between asteroids in field
// Минимальное расстояние между астероидами в поле final int FIELD_ASTEROID_MIN_DISTANCE = 5;
final int FIELD_ASTEROID_MIN_DISTANCE = 5;
// Maximum distance
// Максимальное расстояние между астероидами final int FIELD_ASTEROID_MAX_DISTANCE = 100;
final int FIELD_ASTEROID_MAX_DISTANCE = 100;
// Setting up of big asteroids
// Разброс больших астероидов for (int i = 1; i <= numOfAsteroids; i++) {
for (int i = 1; i <= numOfAsteroids; i++) { int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
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 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)));
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
// Place an asteroid
// Создаём астероид generateRandomAsteroid(world, aX, aY, aZ, 4, 6);
generateRandomAsteroid(world, aX, aY, aZ, 4, 6); }
}
// Setting up small asteroids
// Разброс маленьких астероидов for (int i = 1; i <= numOfAsteroids; i++) {
for (int i = 1; i <= numOfAsteroids; i++) { int aX = x + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
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 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)));
int aZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * (FIELD_ASTEROID_MIN_DISTANCE + world.rand.nextInt(FIELD_ASTEROID_MAX_DISTANCE)));
// Placing
// Создаём астероид generateRandomAsteroid(world, aX, aY, aZ, 2, 2);
generateRandomAsteroid(world, aX, aY, aZ, 2, 2); }
} }
}
/**
/** * Asteroid of block generator
* Генератор астероидов одного типа. Создаёт астероид в точке. *
* * @param x x-coord of center
* @param x координата центра астероида * @param y center
* @param y координата центра астероида * @param z center
* @param z координата центра астероида * @param asteroidSizeMax maximum asteroid size (by number of balls it consists)
* @param asteroidSizeMax максимальный размер астероида (по количеству составляющих его сфер) * @param centerRadiusMax maximum radius of central ball
* @param centerRadiusMax максимальный радиус центральной сферы */
*/ private void generateAsteroidOfBlock(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax, int blockID) {
private void generateAsteroidOfBlock(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax, int blockID) { int asteroidSize = 1 + world.rand.nextInt(6);
int asteroidSize = 1 + world.rand.nextInt(6);
if (asteroidSizeMax != 0) {
if (asteroidSizeMax != 0) { asteroidSize = Math.min(asteroidSizeMax, asteroidSize);
asteroidSize = Math.min(asteroidSizeMax, asteroidSize); }
}
int centerRadius = 1 + world.rand.nextInt(6);
int centerRadius = 1 + world.rand.nextInt(6); if (centerRadiusMax != 0) {
if (centerRadiusMax != 0) { centerRadius = Math.min(centerRadiusMax, centerRadius);
centerRadius = Math.min(centerRadiusMax, centerRadius); }
}
final int CENTER_SHIFT = 2; // Offset from center of central ball
final int CENTER_SHIFT = 2; // Смещение от центральной сферы
// Asteroid's center
// Центр астероида generateSphere2(world, x, y, z, centerRadius, true, blockID, false);
generateSphere2(world, x, y, z, centerRadius, true, blockID, false);
// Asteroids knolls
// Бугры астероида for (int i = 1; i <= asteroidSize; i++) {
for (int i = 1; i <= asteroidSize; i++) { int radius = 2 + world.rand.nextInt(centerRadius);
int radius = 2 + world.rand.nextInt(centerRadius);
int newX = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
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 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));
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
generateSphere2(world, newX, newY, newZ, radius, true, blockID, false);
generateSphere2(world, newX, newY, newZ, radius, true, blockID, false); }
} }
}
/**
/** * Asteroid generator
* Генератор простых астероидов. Создаёт астероид в точке. *
* * @param x x-coord of center
* @param x координата центра астероида * @param y center
* @param y координата центра астероида * @param z center
* @param z координата центра астероида * @param asteroidSizeMax maximum asteroid size (by number of balls it consists)
* @param asteroidSizeMax максимальный размер астероида (по количеству составляющих его сфер) * @param centerRadiusMax maximum radius of central ball
* @param centerRadiusMax максимальный радиус центральной сферы */
*/ private void generateAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) {
private void generateAsteroid(World world, int x, int y, int z, int asteroidSizeMax, int centerRadiusMax) { int asteroidSize = 1 + world.rand.nextInt(6);
int asteroidSize = 1 + world.rand.nextInt(6);
if (asteroidSizeMax != 0) {
if (asteroidSizeMax != 0) { asteroidSize = Math.min(asteroidSizeMax, asteroidSize);
asteroidSize = Math.min(asteroidSizeMax, asteroidSize); }
}
int centerRadius = 1 + world.rand.nextInt(6);
int centerRadius = 1 + world.rand.nextInt(6); if (centerRadiusMax != 0) {
if (centerRadiusMax != 0) { centerRadius = Math.min(centerRadiusMax, centerRadius);
centerRadius = Math.min(centerRadiusMax, centerRadius); }
}
final int CENTER_SHIFT = 2;
final int CENTER_SHIFT = 2; // Смещение от центральной сферы
generateSphere2(world, x, y, z, centerRadius, true, 0, false);
// Центр астероида
generateSphere2(world, x, y, z, centerRadius, true, 0, false); for (int i = 1; i <= asteroidSize; i++) {
int radius = 2 + world.rand.nextInt(centerRadius);
// Бугры астероида
for (int i = 1; i <= asteroidSize; i++) { int newX = x + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2));
int radius = 2 + world.rand.nextInt(centerRadius); 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));
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)); generateSphere2(world, newX, newY, newZ, radius, true, 0, false);
int newZ = z + (((world.rand.nextBoolean()) ? -1 : 1) * world.rand.nextInt(CENTER_SHIFT + centerRadius / 2)); }
}
generateSphere2(world, newX, newY, newZ, radius, true, 0, false);
} /**
} * Sphere generator
* @param world target world
/** * @param xCoord center
* Генератор сферических объектов * @param yCoord center
* @param world мир, в котором будет сгенерирована сфера/шар * @param zCoord center
* @param xCoord координата центра * @param radius sphere radius
* @param yCoord координата центра * @param corrupted skip random blocks when generating (corrupted effect)
* @param zCoord координата центра * @param forcedID sphere of specified blocks or random blocks if not specified
* @param radius радиус сферы/шара * @return
* @param corrupted пропускать случайные блоки при генерации */
* @param forcedID генерировать сферу из определённых блоков, 0 если блоки случайные public void generateSphere2(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, boolean hollow) {
* @return
*/ radius += 0.5D; // Radius from center of block
public void generateSphere2(World world, int xCoord, int yCoord, int zCoord, double radius, boolean corrupted, int forcedID, boolean hollow) { double radiusSq = radius * radius; // Optimization to avoid sqrts...
// FIXME: блокировка мира обязательна? double radius1Sq = (radius - 1.0D) * (radius - 1.0D); // for hollow sphere
//world.editingBlocks = true;
int ceilRadius = (int) Math.ceil(radius);
radius += 0.5D; // Отмеряем радиус от центра блока
double radiusSq = radius * radius; // Возведение радиуса в квадрат в целях оптимизации (избавлпние от кв. корней) // Pass the cube and check points for sphere equation x^2 + y^2 + z^2 = r^2
double radius1Sq = (radius - 1.0D) * (radius - 1.0D); // Квадратный радиус для пустой сферы for (int x = 0; x <= ceilRadius; x++) {
for (int y = 0; y <= ceilRadius; y++) {
int ceilRadius = (int) Math.ceil(radius); // Округляем радиус for (int z = 0; z <= ceilRadius; z++) {
double dSq = lengthSq(x, y, z); // Distance from current position to center
// Обходим куб со стороной, равной радиусу
// (проверка точек на удовлетворение уравнению сферы x^2 + y^2 + z^2 = r^2) // Skip too far blocks
for (int x = 0; x <= ceilRadius; x++) { if (dSq > radiusSq) {
for (int y = 0; y <= ceilRadius; y++) { continue;
for (int z = 0; z <= ceilRadius; z++) { }
double dSq = lengthSq(x, y, z); // Расстояние от центра до точки
// Hollow sphere condition
// Пропускать блоки, которые удалены от центра больше, чем на радиус if ((hollow) && (
if (dSq > radiusSq) { (dSq < radius1Sq) || ((lengthSq(x + 1, y, z) <= radiusSq) && (lengthSq(x, y + 1, z) <= radiusSq) && (lengthSq(x, y, z + 1) <= radiusSq))))
continue; {
} continue;
}
// Генерация полой сферы
if ((hollow) && (
(dSq < radius1Sq) || ((lengthSq(x + 1, y, z) <= radiusSq) && (lengthSq(x, y + 1, z) <= radiusSq) && (lengthSq(x, y, z + 1) <= radiusSq)))) // Place blocks
{ int blockID, meta = 0;
continue;
} if (!corrupted || world.rand.nextInt(10) != 1)
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
// Ставим блоки по всем осям в текущей точке if (blockID == 39701) { meta = blockID % 10; blockID = blockID / 10; }
int blockID, meta = 0; world.setBlock(xCoord + x, yCoord + y, zCoord + z, blockID, meta, 2);
world.setBlock(xCoord - x, yCoord + y, zCoord + z, blockID, meta, 2);
if (!corrupted || world.rand.nextInt(10) != 1) }
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted) : forcedID; if (!corrupted || world.rand.nextInt(10) != 1)
if (blockID > 2000 && blockID < 2500) { meta = blockID % 10; blockID = blockID / 10; } {
world.setBlockAndMetadata(xCoord + x, yCoord + y, zCoord + z, blockID, meta); blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
world.setBlockAndMetadata(xCoord - x, yCoord + y, zCoord + z, blockID, meta); 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);
if (!corrupted || world.rand.nextInt(10) != 1) }
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted) : forcedID; if (!corrupted || world.rand.nextInt(10) != 1)
if (blockID > 2000 && blockID < 2500) { meta = blockID % 10; blockID = blockID / 10; } {
world.setBlockAndMetadata(xCoord + x, yCoord - y, zCoord + z, blockID, meta); blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
world.setBlockAndMetadata(xCoord + x, yCoord + y, zCoord - z, blockID, meta); 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);
if (!corrupted || world.rand.nextInt(10) != 1) }
{
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted) : forcedID; if (!corrupted || world.rand.nextInt(10) != 1)
if (blockID > 2000 && blockID < 2500) { meta = blockID % 10; blockID = blockID / 10; } {
world.setBlockAndMetadata(xCoord - x, yCoord - y, zCoord + z, blockID, meta); blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted, false) : forcedID;
world.setBlockAndMetadata(xCoord + x, yCoord - y, zCoord - z, blockID, meta); 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);
if (!corrupted || world.rand.nextInt(10) != 1) }
{ }
blockID = (forcedID == 0) ? getRandomSurfaceBlockID(world.rand, corrupted) : forcedID; }
if (blockID > 2000 && blockID < 2500) { meta = blockID % 10; blockID = blockID / 10; } }
world.setBlockAndMetadata(xCoord - x, yCoord + y, zCoord - z, blockID, meta); }
world.setBlockAndMetadata(xCoord - x, yCoord - y, zCoord - z, blockID, meta);
} private static double lengthSq(double x, double y, double z) {
} return (x * x) + (y * y) + (z * z);
} }
}
private int getRandomSurfaceBlockID(Random random, boolean corrupted, boolean nocobble) {
// Разблокируем мир int[] ores = {
//world.editingBlocks = false; Block.oreIron.blockID,
} Block.oreGold.blockID,
Block.oreCoal.blockID,
private static double lengthSq(double x, double y, double z) { Block.oreEmerald.blockID,
return (x * x) + (y * y) + (z * z); Block.oreLapis.blockID,
} Block.oreRedstoneGlowing.blockID,
private int getRandomSurfaceBlockID(Random random, boolean corrupted) { // ICBM
int[] ores = { 3880,
Block.oreIron.blockID, 3970,
Block.oreGold.blockID, 39701, // 3970:1
Block.oreCoal.blockID,
Block.oreEmerald.blockID, // IC2 ores
Block.oreLapis.blockID, 247,
Block.oreRedstoneGlowing.blockID, 248,
249
// Ruby ore
242, };
// IC ores int blockID = Block.stone.blockID;
4093, // Uranium if (corrupted) {
4094, // Tin blockID = Block.cobblestone.blockID;
4095, // Copper ore }
4095, // Copper ore
}; if (random.nextInt(10) == 1 || nocobble) {
blockID = ores[random.nextInt(ores.length - 1)];
int redPowerOreBlockID = 242; }
int[] redPowerOres = { else if (random.nextInt(350) == 1) {
0, 1, 2, 3, 4, 5, 6, 7 // Рубины -- Николит blockID = 902; // quarz (AE)
}; }
else if (random.nextInt(500) == 1) {
blockID = Block.oreDiamond.blockID;
int blockID = Block.stone.blockID; }/* else if (random.nextInt(5000) == 1) {
if (corrupted) { blockID = 688;
blockID = Block.cobblestone.blockID; }*/
}
return blockID;
if (random.nextInt(10) == 1) { }
switch (random.nextInt(2)) { }
case 0:
blockID = ores[random.nextInt(ores.length - 1)];
break;
case 1: // OREM -- ORE (Руда), M - метаданные
blockID = Integer.parseInt(new StringBuilder().append(redPowerOreBlockID).append(redPowerOres[random.nextInt(redPowerOres.length - 1)]).toString());
}
} else if (random.nextInt(500) == 1) {
blockID = Block.oreDiamond.blockID;
} else if (random.nextInt(5000) == 1) {
blockID = 688;
}
return blockID;
}
}

View file

@ -6,35 +6,21 @@ package cr0s.WarpDrive;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import dan200.computer.api.IComputerAccess;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.DamageSource; import net.minecraft.util.DamageSource;
import dan200.computer.api.IPeripheral;
/** /**
* Protocol block tile entity * Protocol block tile entity
* @author Cr0s * @author Cr0s
*/ */
public class TileEntityProtocol extends TileEntity { public class TileEntityProtocol extends TileEntity implements IPeripheral {
public Boolean[] bits;
public ArrayList<Integer> input;
public ArrayList<Integer> output;
public boolean RX, TX, RST;
//TileEntityReactor warpCore; // Warp core entity
TileEntity dataCable; // Data cable entity
private int ticks = 0;
private final int UPDATE_TIMEOUT = 5; // seconds
private final int TRANSFER_RATE = 1; // ticks
private final int MAX_INPUT_BUFFER_SIZE = 25; // 25 bytes per packet
// Variables // Variables
private int distance = 0; private int distance = 0;
private int direction = 0; private int direction = 0;
@ -54,189 +40,18 @@ public class TileEntityProtocol extends TileEntity {
boolean ready = false; // Ready to operate (valid assembly) boolean ready = false; // Ready to operate (valid assembly)
public String[] methodsArray = {
"dim_getp", "dim_setp", // 0, 1
"dim_getn", "dim_setn", // 2, 3
"set_mode", "set_distance", "set_direction", // 4, 5, 6
"get_attached_players", "summon", "summon_all", // 7, 8, 9
"get_x", "get_y", "get_z", // 10, 11, 12
"get_energy_level", "do_jump", "get_ship_size" // 13, 14, 15
};
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)
@Override @Override
public void updateEntity() { public void updateEntity() {
ticks++;
ready = dataCable != null;
if (ticks == UPDATE_TIMEOUT) {
this.dataCable = searchRedPowerCable();
ticks = 0;
}
if (!ready) {
return;
}
bits = readCableStates();
if (dataCable == null || bits == null || bits[8] == null || bits.length == 0) {
return;
}
RX = bits[8];
TX = bits[9];
RST = bits[11];
if (input == null) {
input = new ArrayList<Integer>();
}
if (output == null) {
output = new ArrayList<Integer>();
}
if (RST) {
System.out.println("RST RECV");
if (TX) { analyzeInputData(); } else if (RX) { /* sendOutputData();*/ }
input.clear();
RST = false;
resetCableStates();
} else if (TX) {
int byteFromCable = readByte();
System.out.println("Byte from cable: " + byteFromCable + "");
input.add(byteFromCable);
if (input.size() > MAX_INPUT_BUFFER_SIZE) {
System.out.println("[!] Buffer overflow.");
}
resetCableStates();
} else if (RX) {
}
}
public TileEntity searchRedPowerCable() {
TileEntity result;
result = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);
if (result != null && result.toString().contains("TileCable")) {
return result;
}
result = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
if (result != null && result.toString().contains("TileCable")) {
return result;
}
result = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
if (result != null && result.toString().contains("TileCable")) {
return result;
}
result = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
if (result != null && result.toString().contains("TileCable")) {
return result;
}
return null;
}
public Boolean[] readCableStates() {
if (dataCable == null) { return null; }
NBTTagCompound tag = new NBTTagCompound();
dataCable.writeToNBT(tag);
byte states[] = tag.getByteArray("pwrs"); // Получить массив состояний кабеля
if (states == null) {
return null;
}
Boolean[] locCableStates = new Boolean[16];
for (int i = 0; i < 16; i++) {
locCableStates[i] = (states[i] != 0);
}
/*
if (RX || TX) {
System.out.println("[C] Cable bits: " + s);
}
*/
return locCableStates;
}
private int readByte() {
int result = 0;
//String binaryString = "";
Boolean[] states = readCableStates();
// Get first 8 bits
for (int i = 0; i < 8; i++) {
result += ((states[i]) ? 1 : 0) * Math.pow((int)2, i);
}
return result;
}
private void analyzeInputData() {
Integer packetID;
if (input == null || input.isEmpty()) {
return;
}
packetID = this.input.get(0);
System.out.println("---- PACKET RECV ----");
System.out.println("PacketID: " + packetID);
System.out.print("Data (" + (input.size() - 1) + " bytes): ");
for (int i = 1; i < input.size(); i++) {
System.out.print(input.get(i));
}
System.out.print("\n");
System.out.println("---- ----");
switch (packetID) {
case 0xFF:
doJump();
break;
case 0xFE:
setSummonAllFlag(true);
break;
case 0x00: // SETDST
if (input.size() == 2) {
setJumpDistance(input.get(1));
}
break;
case 0x01: // SETDIR
if (input.size() == 2) {
setDirection(input.get(1));
}
break;
case 0x02: // SETMODE
if (input.size() == 2) {
setMode(input.get(1));
}
break;
case 0x03: // SETPST
if (input.size() == 4) {
System.out.println("Setting positive gabarits: f: " + input.get(1) + " r: " + input.get(2) + " u: " + input.get(3));
setFront(input.get(1));
setRight(input.get(2));
setUp(input.get(3));
}
break;
case 0x04: // SETNEG
if (input.size() == 4) {
System.out.println("Setting negative gabarits: f: " + input.get(1) + " r: " + input.get(2) + " u: " + input.get(3));
setBack(input.get(1));
setLeft(input.get(2));
setDown(input.get(3));
}
break;
}
input.clear();
} }
private void setJumpDistance(int distance) { private void setJumpDistance(int distance) {
@ -260,19 +75,6 @@ public class TileEntityProtocol extends TileEntity {
setJumpFlag(true); setJumpFlag(true);
} }
private void resetCableStates() {
if (dataCable == null) {
return;
}
NBTTagCompound tag = new NBTTagCompound();
dataCable.writeToNBT(tag);
byte states[] = new byte[16];
tag.setByteArray("pwrs", states);
dataCable.readFromNBT(tag);
}
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag); super.readFromNBT(tag);
@ -502,4 +304,155 @@ public class TileEntityProtocol extends TileEntity {
public void setSummonAllFlag(boolean summonFlag) { public void setSummonAllFlag(boolean summonFlag) {
this.summonFlag = summonFlag; this.summonFlag = summonFlag;
} }
@Override
public String getType() {
return "warpcore";
}
@Override
public String[] getMethodNames() {
return (methodsArray);
}
@Override
public Object[] callMethod(IComputerAccess computer, int method, Object[] arguments) throws Exception {
//System.out.println("[ProtoBlock] Method " + method + " " + methodsArray[method] + " called!");
switch (method)
{
case 0: // dim_getp ()
return new Integer[] { getFront(), getRight(), getUp() };
case 1: // dim_setp (front, right, up)
if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) {
return new Integer[] { -1 };
}
System.out.println("Setting positive gabarits: f: " + ((Double)arguments[0]).intValue() + " r: " + ((Double)arguments[1]).intValue() + " u: " + ((Double)arguments[2]).intValue());
setFront(((Double)arguments[0]).intValue());
setRight(((Double)arguments[1]).intValue());
setUp(((Double)arguments[2]).intValue());
break;
case 2: // dim_getn ()
return new Integer[] { getBack(), getLeft(), getDown() };
case 3: // dim_setn (back, left, down)
if (arguments.length != 3 || (((Double)arguments[0]).intValue() < 0 || ((Double)arguments[1]).intValue() < 0 || ((Double)arguments[2]).intValue() < 0)) {
return new Integer[] { -1 };
}
System.out.println("Setting negative gabarits: b: " + ((Double)arguments[0]).intValue() + " l: " + ((Double)arguments[1]).intValue() + " d: " + ((Double)arguments[2]).intValue());
setBack(((Double)arguments[0]).intValue());
setLeft(((Double)arguments[1]).intValue());
setDown(((Double)arguments[2]).intValue());
break;
case 4: // set_mode (mode)
if (arguments.length != 1) {
return new Integer[] { -1 };
}
setMode(((Double)arguments[0]).intValue());
break;
case 5: // set_distance (distance)
if (arguments.length != 1) {
return new Integer[] { -1 };
}
setJumpDistance(((Double)arguments[0]).intValue());
break;
case 6: // set_direction (dir)
if (arguments.length != 1) {
return new Integer[] { -1 };
}
setDirection(((Double)arguments[0]).intValue());
break;
case 7: // get_attached_players
String list = "";
for (int i = 0; i < this.players.size(); i++) {
String nick = this.players.get(i);
list += nick + ((i == this.players.size() - 1)? "" : "\n");
}
if (players.isEmpty()) {
list = "";
}
return new Object[] { (String)list };
case 8: // summon
if (arguments.length != 1) {
return new Integer[] { -1 };
}
int playerID = ((Double)arguments[0]).intValue();
if (playerID >= 0 && playerID < players.size()) {
setToSummon(players.get(playerID));
}
break;
case 9: // summon_all
this.setSummonAllFlag(true);
case 10: // get_x
return new Object[] { (Integer)xCoord };
case 11: // get_y
return new Object[] { (Integer)yCoord };
case 12: // get_z
return new Object[] { (Integer)zCoord };
case 14: // do_jump
doJump();
break;
}
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;
}
} }

View file

@ -12,9 +12,11 @@ import java.util.List;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.tileentity.TileEntityChest;
import net.minecraft.util.AxisAlignedBB; import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MathHelper; import net.minecraft.util.MathHelper;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
@ -80,14 +82,11 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
public String coreState = ""; public String coreState = "";
public TileEntityProtocol controller; public TileEntityProtocol controller;
private TileEntityChest TileEntityChest;
@SideOnly(Side.SERVER) @SideOnly(Side.SERVER)
@Override @Override
public void updateEntity() { public void updateEntity() {
//if (ticks++ < 20 * TICK_INTERVAL) {
// return;
//}
TileEntity c = findControllerBlock(); TileEntity c = findControllerBlock();
if (c != null) { if (c != null) {
@ -97,6 +96,9 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
if (this.controller.isSummonAllFlag()) { if (this.controller.isSummonAllFlag()) {
summonPlayers(); summonPlayers();
controller.setSummonAllFlag(false); controller.setSummonAllFlag(false);
} else if (!this.controller.getToSummon().isEmpty()) {
summonSinglePlayer(this.controller.getToSummon());
this.controller.setToSummon("");
} }
} else { } else {
invalidAssembly = true; invalidAssembly = true;
@ -104,12 +106,25 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
switch (currentMode) { switch (currentMode) {
case MODE_TELEPORT: case MODE_TELEPORT:
teleportPlayersToSpace(); if (isChestSummonMode()) {
if (ticks++ < 20) {
return;
}
if (worldObj.isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord)) {
summonPlayersByChestCode();
ticks = 0;
}
} else {
teleportPlayersToSpace();
}
case MODE_BASIC_JUMP: case MODE_BASIC_JUMP:
case MODE_LONG_JUMP: case MODE_LONG_JUMP:
if (controller == null) { return; } if (controller == null) { return; }
coreState = "Energy: " + currentEnergyValue;
if (controller.isJumpFlag()) { if (controller.isJumpFlag()) {
System.out.println("Jumping!"); System.out.println("[W-C] Jumping!");
prepareToJump(); prepareToJump();
doJump(currentMode == MODE_LONG_JUMP); doJump(currentMode == MODE_LONG_JUMP);
controller.setJumpFlag(false); controller.setJumpFlag(false);
@ -127,21 +142,35 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(nick); EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(nick);
if (player != null && !testBB(aabb, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ))) { if (player != null && !testBB(aabb, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ))) {
summonPlayer(player); summonPlayer(player, xCoord + dx, yCoord, zCoord + dz);
} }
} }
} }
public void summonPlayer(EntityPlayerMP player) { public void summonSinglePlayer(String nickname) {
calculateSpatialShipParameters();
AxisAlignedBB aabb = AxisAlignedBB.getBoundingBox(this.minX, this.minY, this.minZ, this.maxX, this.maxY, this.maxZ);
for (int i = 0; i < controller.players.size(); i++) {
String nick = controller.players.get(i);
EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().getPlayerForUsername(nick);
if (player != null && nick.equals(nickname) && !testBB(aabb, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ))) {
summonPlayer(player, xCoord + dx, yCoord, zCoord + dz);
return;
}
}
}
public void summonPlayer(EntityPlayerMP player, int x, int y, int z) {
if (this.currentEnergyValue - this.ENERGY_PER_ENTITY_TO_SPACE >= 0) { if (this.currentEnergyValue - this.ENERGY_PER_ENTITY_TO_SPACE >= 0) {
player.setPositionAndUpdate(xCoord + dx, yCoord, zCoord + dz); player.setPositionAndUpdate(x, y, z);
if (player.dimension != worldObj.provider.dimensionId) { if (player.dimension != worldObj.provider.dimensionId) {
player.mcServer.getConfigurationManager().transferPlayerToDimension(player, this.worldObj.provider.dimensionId, new SpaceTeleporter(DimensionManager.getWorld(this.worldObj.provider.dimensionId), 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ))); player.mcServer.getConfigurationManager().transferPlayerToDimension(player, this.worldObj.provider.dimensionId, new SpaceTeleporter(DimensionManager.getWorld(this.worldObj.provider.dimensionId), 0, MathHelper.floor_double(player.posX), MathHelper.floor_double(player.posY), MathHelper.floor_double(player.posZ)));
} }
this.currentEnergyValue -= this.ENERGY_PER_ENTITY_TO_SPACE; this.currentEnergyValue -= this.ENERGY_PER_ENTITY_TO_SPACE;
player.sendChatToPlayer("[WarpCore] Welcome aboard, " + player.username + ".");
} }
} }
@ -245,11 +274,11 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
} }
} }
public void doJump(boolean longjump) { public void doJump(boolean longjump) {
if ((currentMode == this.MODE_BASIC_JUMP || currentMode == this.MODE_LONG_JUMP) && !invalidAssembly) { if ((currentMode == this.MODE_BASIC_JUMP || currentMode == this.MODE_LONG_JUMP) && !invalidAssembly) {
coreState = "Energy: " + currentEnergyValue + "; Ship blocks: " + shipVolume + "\n"; coreState = "Energy: " + currentEnergyValue + "; Ship blocks: " + shipVolume + "\n";
coreState += "* Need " + Math.max(0, calculateRequiredEnergy(shipVolume, distance) - currentEnergyValue) + " eU to jump"; coreState += "* Need " + Math.max(0, calculateRequiredEnergy(shipVolume, distance) - currentEnergyValue) + " eU to jump";
} }
// Подготовка к прыжку // Подготовка к прыжку
if ((cooldownTime <= 0) && (currentMode == this.MODE_BASIC_JUMP || currentMode == this.MODE_LONG_JUMP)) { if ((cooldownTime <= 0) && (currentMode == this.MODE_BASIC_JUMP || currentMode == this.MODE_LONG_JUMP)) {
@ -288,7 +317,6 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
System.out.println((new StringBuilder()).append("[JUMP] Totally moving ").append((new StringBuilder()).append(shipVolume).append(" blocks to length ").append(distance).append(" blocks, direction: ").append(direction).toString()).toString()); System.out.println((new StringBuilder()).append("[JUMP] Totally moving ").append((new StringBuilder()).append(shipVolume).append(" blocks to length ").append(distance).append(" blocks, direction: ").append(direction).toString()).toString());
// public EntityJump(World world, int x, int y, int z, int _dist, int _direction, int _dx, int _dz)
EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, distance, direction, dx, dz, this); EntityJump jump = new EntityJump(worldObj, xCoord, yCoord, zCoord, distance, direction, dx, dz, this);
jump.Xmax = maxX; jump.Xmax = maxX;
@ -314,7 +342,7 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
jump.on = true; jump.on = true;
System.out.println("[TE-WC] Calling onUpdate()..."); //System.out.println("[TE-WC] Calling onUpdate()...");
worldObj.spawnEntityInWorld(jump); worldObj.spawnEntityInWorld(jump);
coreState = ""; coreState = "";
@ -338,39 +366,103 @@ public class TileEntityReactor extends TileEntity implements IEnergySink {
int x = MathHelper.floor_double(entity.posX); int x = MathHelper.floor_double(entity.posX);
int z = MathHelper.floor_double(entity.posZ); int z = MathHelper.floor_double(entity.posZ);
//int y = MathHelper.floor_double(entity.posY);
final int WOOL_BLOCK_ID = 35;
int newY;
for (newY = 254; newY > 0; newY--) {
if (DimensionManager.getWorld(WarpDrive.instance.spaceDimID).getBlockId(x, newY, z) == WOOL_BLOCK_ID) {
break;
}
}
if (newY <= 0) { newY = 254; }
if (entity instanceof EntityPlayerMP) { if (entity instanceof EntityPlayerMP) {
((EntityPlayerMP) entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), WarpDrive.instance.spaceDimID, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, x, 256, z)); ((EntityPlayerMP) entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), WarpDrive.instance.spaceDimID, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, x, 256, z));
// Создаём платформу // Создаём платформу
if (DimensionManager.getWorld(WarpDrive.instance.spaceDimID).isAirBlock(x, 254, z)) { if (DimensionManager.getWorld(WarpDrive.instance.spaceDimID).isAirBlock(x, newY, z)) {
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x, 254, z, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x, newY, z, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x + 1, 254, z, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x + 1, newY, z, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x - 1, 254, z, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x - 1, newY, z, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x, 254, z + 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x, newY, z + 1, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x, 254, z - 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x, newY, z - 1, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x + 1, 254, z + 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x + 1, newY, z + 1, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x - 1, 254, z - 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x - 1, newY, z - 1, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x + 1, 254, z - 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x + 1, newY, z - 1, Block.stone.blockID, 0, 2);
DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlockWithNotify(x - 1, 254, z + 1, Block.stone.blockID); DimensionManager.getWorld(WarpDrive.instance.spaceDimID).setBlock(x - 1, newY, z + 1, Block.stone.blockID, 0, 2);
} }
// Перемещаем на платформу // Перемещаем на платформу
((EntityPlayerMP) entity).setPositionAndUpdate(x, 256, z); ((EntityPlayerMP) entity).setPositionAndUpdate(x, newY + 2, z);
// Делаем лётчиком
if (!((EntityPlayerMP) entity).capabilities.isCreativeMode) {
((EntityPlayerMP) entity).capabilities.allowFlying = true;
}
} }
} }
} }
} }
} }
public void summonPlayersByChestCode() {
if (worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord) == null) { return; }
TileEntityChest chest = (TileEntityChest)worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
EntityPlayerMP player;
for (int i = 0; i < MinecraftServer.getServer().getConfigurationManager().playerEntityList.size(); i++)
{
player = (EntityPlayerMP)MinecraftServer.getServer().getConfigurationManager().playerEntityList.get(i);
if (checkPlayerInventory(chest, player)) {
System.out.println("[P] Summoning " + player.username);
summonPlayer(player, xCoord, yCoord + 2, zCoord);
}
}
}
public boolean checkPlayerInventory(TileEntityChest chest, EntityPlayerMP player) {
Boolean result = false;
final int MIN_KEY_LENGTH = 5;
int keyLength = 0;
for (int index = 0; index < chest.getSizeInventory(); index++) {
ItemStack chestItem = chest.getStackInSlot(index);
ItemStack playerItem = player.inventory.getStackInSlot(9 + index);
if (chestItem == null || playerItem == null) { continue; }
//System.out.println(player.username + " " + index + " -> " + chestItem + " = " + playerItem);
if (chestItem.itemID != playerItem.itemID || chestItem.getItemDamage() != playerItem.getItemDamage() || chestItem.stackSize != playerItem.stackSize) {
return false;
} else { result = true; }
keyLength++;
}
if (keyLength < MIN_KEY_LENGTH) {
System.out.println("[ChestCode] Key is too short: " + keyLength + " < " + MIN_KEY_LENGTH);
return false;
}
return result;
}
public Boolean isChestSummonMode() {
TileEntity te = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
if (te != null) {
return (te instanceof TileEntityChest);
}
return false;
}
/* /*
* Проверка на вхождение точки в область (bounding-box) * Проверка на вхождение точки в область (bounding-box)
*/ */

View file

@ -10,8 +10,10 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; 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.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.LanguageRegistry;
import ic2.api.item.Items;
import net.minecraft.block.Block; import net.minecraft.block.Block;
import net.minecraft.block.material.Material; import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs; import net.minecraft.creativetab.CreativeTabs;
@ -19,10 +21,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase; import net.minecraft.world.biome.BiomeGenBase;
import net.minecraftforge.common.DimensionManager; import net.minecraftforge.common.DimensionManager;
import net.minecraftforge.common.MinecraftForge;
import ic2.api.Items;
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "0.0.1") @Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.0.0")
@NetworkMod(clientSideRequired = false, serverSideRequired = true) @NetworkMod(clientSideRequired = false, serverSideRequired = true)
/** /**
* @author Cr0s * @author Cr0s
@ -34,11 +34,11 @@ public class WarpDrive {
public final static Block warpCore = new BlockReactor(WARP_CORE_BLOCKID, 0, Material.rock) public final static Block warpCore = new BlockReactor(WARP_CORE_BLOCKID, 0, Material.rock)
.setHardness(0.5F).setStepSound(Block.soundMetalFootstep) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep)
.setBlockName("warpCore").setCreativeTab(CreativeTabs.tabRedstone); .setCreativeTab(CreativeTabs.tabRedstone);
public final static Block protocolBlock = new BlockProtocol(PROTOCOL_BLOCK_BLOCKID, 0, Material.rock) public final static Block protocolBlock = new BlockProtocol(PROTOCOL_BLOCK_BLOCKID, 0, Material.rock)
.setHardness(0.5F).setStepSound(Block.soundMetalFootstep) .setHardness(0.5F).setStepSound(Block.soundMetalFootstep)
.setBlockName("protocolBlock").setCreativeTab(CreativeTabs.tabRedstone); .setCreativeTab(CreativeTabs.tabRedstone);
/** /**
* *
@ -61,10 +61,6 @@ public class WarpDrive {
@Init @Init
public void load(FMLInitializationEvent event) { public void load(FMLInitializationEvent event) {
MinecraftForge.EVENT_BUS.register(new SpaceEventHandler());
LanguageRegistry.addName(warpCore, "Warp-drive Reactor Core"); LanguageRegistry.addName(warpCore, "Warp-drive Reactor Core");
GameRegistry.registerBlock(warpCore, "warpCore"); GameRegistry.registerBlock(warpCore, "warpCore");
GameRegistry.registerTileEntity(TileEntityReactor.class, "warpCore"); GameRegistry.registerTileEntity(TileEntityReactor.class, "warpCore");
@ -74,6 +70,8 @@ public class WarpDrive {
GameRegistry.registerTileEntity(TileEntityProtocol.class, "protocolBlock"); GameRegistry.registerTileEntity(TileEntityProtocol.class, "protocolBlock");
proxy.registerRenderers(); proxy.registerRenderers();
EntityRegistry.registerModEntity(EntitySphereGen.class, "EntitySphereGenerator", 1, WarpDrive.instance, 100, 1, false);
proxy.registerJumpEntity(); proxy.registerJumpEntity();
//if (FMLCommonHandler.instance().getEffectiveSide().isServer()) { //if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {

View file

@ -116,7 +116,6 @@ public class LoginHookClass implements IConnectionHandler {
if (kickReason.isEmpty()) { if (kickReason.isEmpty()) {
// Удалить пароль из имени пользователя // Удалить пароль из имени пользователя
netHandler.clientUsername = netHandler.clientUsername.split("\\.")[0]; netHandler.clientUsername = netHandler.clientUsername.split("\\.")[0];
netHandler.getPlayer().skinUrl = "http://koprokubach.servegame.com/getskin.php?user=" + netHandler.clientUsername;
} }
return kickReason; return kickReason;