Search in sources :

Example 1 with BlockFalling

use of net.minecraft.block.BlockFalling in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class EntityFallingUpBlock method onUpdate.

@Override
public void onUpdate() {
    Block block = this.fallTile.getBlock();
    if (this.fallTile.getMaterial() == Material.AIR) {
        this.setDead();
    } else {
        this.prevPosX = this.posX;
        this.prevPosY = this.posY;
        this.prevPosZ = this.posZ;
        if (this.fallTime++ == 0) {
            BlockPos blockpos = new BlockPos(this);
            if (this.worldObj.getBlockState(blockpos).getBlock() == block) {
                this.worldObj.setBlockToAir(blockpos);
            } else if (!this.worldObj.isRemote) {
                this.setDead();
                return;
            }
        }
        if (!this.hasNoGravity()) {
            this.motionY += 0.03999999910593033D;
        }
        CallRunner.onEntityMove(this, this.motionX, this.motionY, this.motionZ);
        this.motionX *= 0.9800000190734863D;
        this.motionY *= 0.9800000190734863D;
        this.motionZ *= 0.9800000190734863D;
        if (!this.worldObj.isRemote) {
            BlockPos blockpos1 = new BlockPos(this);
            if (!onGround && isCollidedVertically) {
                IBlockState iblockstate = this.worldObj.getBlockState(blockpos1);
                if (// Forge: Don't indent below.
                this.worldObj.isAirBlock(new BlockPos(this.posX, this.posY + 1.009999999776482582D, this.posZ)))
                    if (BlockFalling.canFallThrough(this.worldObj.getBlockState(new BlockPos(this.posX, this.posY + 1.009999999776482582D, this.posZ)))) {
                        this.isCollidedVertically = false;
                        return;
                    }
                this.motionX *= 0.699999988079071D;
                this.motionZ *= 0.699999988079071D;
                this.motionY *= -0.5D;
                if (iblockstate.getBlock() != Blocks.PISTON_EXTENSION) {
                    this.setDead();
                    if (!this.canSetAsBlock) {
                        if (this.worldObj.canBlockBePlaced(block, blockpos1, true, EnumFacing.UP, (Entity) null, (ItemStack) null) && !BlockFalling.canFallThrough(this.worldObj.getBlockState(blockpos1.up())) && worldObj.setBlockState(blockpos1, this.fallTile, 3)) {
                            if (block instanceof BlockFalling) {
                                ((BlockFalling) block).onEndFalling(this.worldObj, blockpos1);
                            }
                            if (this.tileEntityData != null && block instanceof ITileEntityProvider) {
                                TileEntity tileentity = this.worldObj.getTileEntity(blockpos1);
                                if (tileentity != null) {
                                    NBTTagCompound nbttagcompound = tileentity.writeToNBT(new NBTTagCompound());
                                    for (String s : this.tileEntityData.getKeySet()) {
                                        NBTBase nbtbase = this.tileEntityData.getTag(s);
                                        if (!"x".equals(s) && !"y".equals(s) && !"z".equals(s)) {
                                            nbttagcompound.setTag(s, nbtbase.copy());
                                        }
                                    }
                                    tileentity.readFromNBT(nbttagcompound);
                                    tileentity.markDirty();
                                }
                            }
                        } else if (this.shouldDropItem && this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
                            this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
                        }
                    }
                }
            } else if (this.fallTime > 100 && !this.worldObj.isRemote && (blockpos1.getY() < 1 || blockpos1.getY() > 256) || this.fallTime > 600) {
                if (this.shouldDropItem && this.worldObj.getGameRules().getBoolean("doEntityDrops")) {
                    this.entityDropItem(new ItemStack(block, 1, block.damageDropped(this.fallTile)), 0.0F);
                }
                this.setDead();
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITileEntityProvider(net.minecraft.block.ITileEntityProvider) IBlockState(net.minecraft.block.state.IBlockState) NBTBase(net.minecraft.nbt.NBTBase) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) EntityFallingBlock(net.minecraft.entity.item.EntityFallingBlock) Block(net.minecraft.block.Block) BlockFalling(net.minecraft.block.BlockFalling) BlockPos(net.minecraft.util.math.BlockPos) ItemStack(net.minecraft.item.ItemStack)

Example 2 with BlockFalling

use of net.minecraft.block.BlockFalling in project RFToolsDimensions by McJty.

the class KnownDimletConfiguration method getBlockFeatures.

public static Set<Filter.Feature> getBlockFeatures(Block block) {
    Set<Filter.Feature> features = EnumSet.noneOf(Filter.Feature.class);
    ItemStack stack = null;
    try {
        stack = new ItemStack(block, 1, OreDictionary.WILDCARD_VALUE);
    } catch (Exception e) {
        Logging.getLogger().log(Level.ERROR, "Failed to create a dimlet for block " + block.getRegistryName() + "! Please report to the correct mod!", e);
        return features;
    }
    int[] iDs = null;
    if (ItemStackTools.isValid(stack) && stack.getItem() != null) {
        iDs = OreDictionary.getOreIDs(stack);
    }
    if (iDs != null && iDs.length > 0) {
        features.add(Filter.Feature.OREDICT);
    }
    if (block instanceof BlockFalling) {
        features.add(Filter.Feature.FALLING);
    }
    if (block.hasTileEntity(block.getDefaultState())) {
        features.add(Filter.Feature.TILEENTITY);
    }
    if (block instanceof IPlantable) {
        features.add(Filter.Feature.PLANTABLE);
    }
    if (!block.isFullBlock(block.getDefaultState())) {
        features.add(Filter.Feature.NOFULLBLOCK);
    }
    return features;
}
Also used : Filter(mcjty.rftoolsdim.config.Filter) IPlantable(net.minecraftforge.common.IPlantable) BlockFalling(net.minecraft.block.BlockFalling) ItemStack(net.minecraft.item.ItemStack)

Aggregations

BlockFalling (net.minecraft.block.BlockFalling)2 ItemStack (net.minecraft.item.ItemStack)2 Filter (mcjty.rftoolsdim.config.Filter)1 Block (net.minecraft.block.Block)1 ITileEntityProvider (net.minecraft.block.ITileEntityProvider)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityFallingBlock (net.minecraft.entity.item.EntityFallingBlock)1 NBTBase (net.minecraft.nbt.NBTBase)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 TileEntity (net.minecraft.tileentity.TileEntity)1 BlockPos (net.minecraft.util.math.BlockPos)1 IPlantable (net.minecraftforge.common.IPlantable)1