use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class BlockShortRangeTelepad method breakBlock.
@Override
public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
final TileEntity tileAt = worldIn.getTileEntity(pos);
int fakeBlockCount = 0;
for (int x = -1; x <= 1; x++) {
for (int y = 0; y < 3; y += 2) {
for (int z = -1; z <= 1; z++) {
if (!(x == 0 && y == 0 && z == 0)) {
if (worldIn.getBlockState(pos.add(x, y, z)).getBlock() == AsteroidBlocks.fakeTelepad) {
fakeBlockCount++;
}
}
}
}
}
if (tileAt instanceof TileEntityShortRangeTelepad) {
if (fakeBlockCount > 0) {
((TileEntityShortRangeTelepad) tileAt).onDestroy(tileAt);
}
ShortRangeTelepadHandler.removeShortRangeTeleporter((TileEntityShortRangeTelepad) tileAt);
}
super.breakBlock(worldIn, pos, state);
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class BlockShortRangeTelepad method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(worldIn, pos, state, placer, stack);
TileEntity tile = worldIn.getTileEntity(pos);
boolean validSpot = true;
for (int x = -1; x <= 1; x++) {
for (int y = 0; y < 3; y += 2) {
for (int z = -1; z <= 1; z++) {
if (!(x == 0 && y == 0 && z == 0)) {
Block blockAt = worldIn.getBlockState(pos.add(x, y, z)).getBlock();
if (!blockAt.getMaterial().isReplaceable()) {
validSpot = false;
}
}
}
}
}
if (!validSpot) {
worldIn.setBlockToAir(pos);
if (placer instanceof EntityPlayer) {
if (!worldIn.isRemote) {
((EntityPlayer) placer).addChatMessage(new ChatComponentText(EnumColor.RED + GCCoreUtil.translate("gui.warning.noroom")));
}
((EntityPlayer) placer).inventory.addItemStackToInventory(new ItemStack(Item.getItemFromBlock(this), 1, 0));
}
return;
}
if (tile instanceof TileEntityShortRangeTelepad) {
((TileEntityShortRangeTelepad) tile).onCreate(worldIn, pos);
((TileEntityShortRangeTelepad) tile).setOwner(PlayerUtil.getName(((EntityPlayer) placer)));
}
}
use of micdoodle8.mods.galacticraft.planets.asteroids.tile.TileEntityShortRangeTelepad in project Galacticraft by micdoodle8.
the class BlockShortRangeTelepad method randomDisplayTick.
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
final TileEntity tileAt = worldIn.getTileEntity(pos);
if (tileAt instanceof TileEntityShortRangeTelepad) {
TileEntityShortRangeTelepad telepad = (TileEntityShortRangeTelepad) tileAt;
float teleportTimeScaled = Math.min(1.0F, telepad.teleportTime / (float) TileEntityShortRangeTelepad.MAX_TELEPORT_TIME);
float f;
float r;
float g;
float b;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 4; j++) {
f = rand.nextFloat() * 0.6F + 0.4F;
r = f * 0.3F;
g = f * (0.3F + (teleportTimeScaled * 0.7F));
b = f * (1.0F - (teleportTimeScaled * 0.7F));
GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.2 + rand.nextDouble() * 0.6, pos.getY() + 0.1, pos.getZ() + 0.2 + rand.nextDouble() * 0.6), new Vector3(0.0, 1.4, 0.0), telepad, false);
}
f = rand.nextFloat() * 0.6F + 0.4F;
r = f * 0.3F;
g = f * (0.3F + (teleportTimeScaled * 0.7F));
b = f * (1.0F - (teleportTimeScaled * 0.7F));
GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.0 + rand.nextDouble() * 0.2, pos.getY() + 2.9, pos.getZ() + rand.nextDouble()), new Vector3(0.0, -2.95, 0.0), telepad, true);
GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + 0.8 + rand.nextDouble() * 0.2, pos.getY() + 2.9, pos.getZ() + rand.nextDouble()), new Vector3(0.0, -2.95, 0.0), telepad, true);
GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + rand.nextDouble(), pos.getY() + 2.9, pos.getZ() + 0.2 + rand.nextDouble() * 0.2), new Vector3(0.0, -2.95, 0.0), telepad, true);
GalacticraftPlanets.spawnParticle("portalBlue", new Vector3(pos.getX() + rand.nextDouble(), pos.getY() + 2.9, pos.getZ() + 0.8 + rand.nextDouble() * 0.2), new Vector3(0.0, -2.95, 0.0), telepad, true);
}
}
}
Aggregations