Fixed gravitite blocks, probably didn't break anything else.
This commit is contained in:
parent
4ea1e44564
commit
79c68d68b5
|
@ -3,6 +3,7 @@ package com.legacy.aether.blocks.util;
|
|||
import java.util.Random;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockSand;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
|
@ -47,14 +48,35 @@ public class BlockFloating extends Block {
|
|||
}
|
||||
|
||||
private void floatBlock(World world, int x, int y, int z) {
|
||||
if (canContinue(world, x, y + 1, z) && y < world.getHeight()) {
|
||||
EntityFloatingBlock floating = new EntityFloatingBlock(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
||||
boolean floatInstantly = BlockSand.fallInstantly;
|
||||
|
||||
if (!world.isRemote) {
|
||||
world.spawnEntityInWorld(floating);
|
||||
if (canContinue(world, x, y + 1, z) && y >= 0)
|
||||
{
|
||||
if (!floatInstantly)
|
||||
{
|
||||
if (!world.isRemote)
|
||||
{
|
||||
EntityFloatingBlock entity = new EntityFloatingBlock(world, x, y, z, world.getBlock(x, y, z), world.getBlockMetadata(x, y, z));
|
||||
world.setBlockToAir(x, y, z);
|
||||
world.spawnEntityInWorld(entity);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setBlockToAir(x, y, z);
|
||||
|
||||
world.setBlockToAir(x, y, z);
|
||||
int bottomPos = y - 1;
|
||||
|
||||
while (canContinue(world, x, bottomPos, z) && bottomPos > 0)
|
||||
{
|
||||
bottomPos = bottomPos - 1;
|
||||
}
|
||||
|
||||
if (bottomPos > 0)
|
||||
{
|
||||
world.setBlock(x, bottomPos + 1, z, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@ public class EntityFloatingBlock extends Entity implements IEntityAdditionalSpaw
|
|||
|
||||
private int timeFloated = 0;
|
||||
|
||||
private boolean hasActivated = false;
|
||||
|
||||
public EntityFloatingBlock(World worldIn) {
|
||||
super(worldIn);
|
||||
|
||||
|
@ -84,19 +86,25 @@ public class EntityFloatingBlock extends Entity implements IEntityAdditionalSpaw
|
|||
}
|
||||
}
|
||||
|
||||
if (this.isCollidedVertically && !this.onGround) {
|
||||
this.motionX *= 0.699999988079071D;
|
||||
this.motionZ *= 0.699999988079071D;
|
||||
this.motionY *= -0.5D;
|
||||
if (this.ticksExisted > 200)
|
||||
{
|
||||
this.setDead();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!BlockFloating.canContinue(this.worldObj, i, j + 1, k))
|
||||
{
|
||||
if (!this.worldObj.isRemote)
|
||||
{
|
||||
this.worldObj.setBlock(i, j, k, this.getBlock());
|
||||
|
||||
if (!block.canPlaceBlockAt(this.worldObj, i, j, k) || BlockFloating.canContinue(this.worldObj, i, j + 1, k) || !this.worldObj.setBlock(i, j, k, this.getBlock(), this.getMetadata(), 2)) {
|
||||
block.dropBlockAsItem(this.worldObj, i, j, k, this.getMetadata(), 0);
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
this.posX = i + 0.5D;
|
||||
this.posY = j;
|
||||
this.posZ = k + 0.5D;
|
||||
}
|
||||
} else if (this.timeFloated > 100) {
|
||||
block.dropBlockAsItem(this.worldObj, i, j, k, this.getMetadata(), 0);
|
||||
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue