Search in sources :

Example 46 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class MaterialAbsorberTileEntity method writeToNBT.

@Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
    super.writeToNBT(tagCompound);
    int[] x = new int[toscan.size()];
    int[] y = new int[toscan.size()];
    int[] z = new int[toscan.size()];
    int i = 0;
    for (BlockPos c : toscan) {
        x[i] = c.getX();
        y[i] = c.getY();
        z[i] = c.getZ();
        i++;
    }
    tagCompound.setIntArray("toscanx", x);
    tagCompound.setIntArray("toscany", y);
    tagCompound.setIntArray("toscanz", z);
    return tagCompound;
}
Also used : BlockPos(net.minecraft.util.math.BlockPos)

Example 47 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class DimensionBuilderBlock method addProbeInfo.

@Override
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    super.addProbeInfo(mode, probeInfo, player, world, blockState, data);
    BlockPos pos = data.getPos();
    TileEntity te = world.getTileEntity(pos);
    if (te instanceof DimensionBuilderTileEntity) {
        DimensionBuilderTileEntity tileEntity = (DimensionBuilderTileEntity) te;
        NBTTagCompound tagCompound = tileEntity.hasTab();
        if (tagCompound != null) {
            int ticksLeft = tagCompound.getInteger("ticksLeft");
            int tickCost = tagCompound.getInteger("tickCost");
            int pct = (tickCost - ticksLeft) * 100 / tickCost;
            TheOneProbeSupport.addDimensionElement(probeInfo.horizontal(), pct).text(pct + "%");
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) BlockPos(net.minecraft.util.math.BlockPos)

Example 48 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class LiquidAbsorberTileEntity method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);
    int[] x = tagCompound.getIntArray("toscanx");
    int[] y = tagCompound.getIntArray("toscany");
    int[] z = tagCompound.getIntArray("toscanz");
    toscan.clear();
    for (int i = 0; i < x.length; i++) {
        toscan.add(new BlockPos(x[i], y[i], z[i]));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos)

Example 49 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class MaterialAbsorberTileEntity method readFromNBT.

@Override
public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);
    int[] x = tagCompound.getIntArray("toscanx");
    int[] y = tagCompound.getIntArray("toscany");
    int[] z = tagCompound.getIntArray("toscanz");
    toscan.clear();
    for (int i = 0; i < x.length; i++) {
        toscan.add(new BlockPos(x[i], y[i], z[i]));
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos)

Example 50 with BlockPos

use of net.minecraft.util.math.BlockPos in project RFToolsDimensions by McJty.

the class MaterialAbsorberTileEntity method checkStateServer.

private void checkStateServer() {
    if (absorbing > 0 || blockState == null) {
        timer--;
        if (timer <= 0) {
            timer = ABSORB_SPEED;
            IBlockState b = isValidSourceBlock(getPos().down());
            if (b != null) {
                if (blockState == null) {
                    absorbing = DimletConstructionConfiguration.maxBlockAbsorbtion;
                    if (b.getBlock() == Blocks.LIT_REDSTONE_ORE) {
                        b = Blocks.REDSTONE_ORE.getDefaultState();
                    }
                    if (Item.getItemFromBlock(b.getBlock()) != null) {
                        // Safety
                        blockState = b;
                        toscan.clear();
                    }
                }
                toscan.add(getPos().down());
            }
            if (!toscan.isEmpty()) {
                int r = getWorld().rand.nextInt(toscan.size());
                Iterator<BlockPos> iterator = toscan.iterator();
                BlockPos c = null;
                for (int i = 0; i <= r; i++) {
                    c = iterator.next();
                }
                toscan.remove(c);
                checkBlock(c, EnumFacing.DOWN);
                checkBlock(c, EnumFacing.UP);
                checkBlock(c, EnumFacing.EAST);
                checkBlock(c, EnumFacing.WEST);
                checkBlock(c, EnumFacing.SOUTH);
                checkBlock(c, EnumFacing.NORTH);
                if (blockMatches(c)) {
                    SoundTools.playSound(getWorld(), blockState.getBlock().getSoundType().breakSound, getPos().getX(), getPos().getY(), getPos().getZ(), 1.0f, 1.0f);
                    getWorld().setBlockToAir(c);
                    absorbing--;
                    IBlockState state = getWorld().getBlockState(c);
                    getWorld().notifyBlockUpdate(c, state, state, 3);
                }
            }
        }
        markDirtyClient();
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

BlockPos (net.minecraft.util.math.BlockPos)864 IBlockState (net.minecraft.block.state.IBlockState)220 TileEntity (net.minecraft.tileentity.TileEntity)135 Block (net.minecraft.block.Block)103 EnumFacing (net.minecraft.util.EnumFacing)95 ItemStack (net.minecraft.item.ItemStack)81 World (net.minecraft.world.World)77 EntityPlayer (net.minecraft.entity.player.EntityPlayer)54 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)46 Vec3d (net.minecraft.util.math.Vec3d)44 NotNull (org.jetbrains.annotations.NotNull)44 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)38 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)31 Entity (net.minecraft.entity.Entity)30 PhysicsWrapperEntity (ValkyrienWarfareBase.PhysicsManagement.PhysicsWrapperEntity)29 Nullable (org.jetbrains.annotations.Nullable)26 ArrayList (java.util.ArrayList)23 EntityLivingBase (net.minecraft.entity.EntityLivingBase)23 WorldServer (net.minecraft.world.WorldServer)23 TextComponentString (net.minecraft.util.text.TextComponentString)22