Search in sources :

Example 51 with BlockPos

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

the class GuiProxy method getServerGuiElement.

@Override
public Object getServerGuiElement(int guiid, EntityPlayer entityPlayer, World world, int x, int y, int z) {
    if (guiid == RFToolsDim.GUI_MANUAL_DIMENSION) {
        return null;
    }
    //        if (guiid == RFToolsDim.GUI_MANUAL_MAIN || guiid == RFTools.GUI_TELEPORTPROBE || guiid == RFTools.GUI_ADVANCEDPORTER) {
    //            return null;
    //        } else if (guiid == RFTools.GUI_REMOTE_STORAGE_ITEM) {
    //            return new RemoteStorageItemContainer(entityPlayer);
    //        } else if (guiid == RFTools.GUI_MODULAR_STORAGE_ITEM) {
    //            return new ModularStorageItemContainer(entityPlayer);
    //        } else if (guiid == RFTools.GUI_STORAGE_FILTER) {
    //            return new StorageFilterContainer(entityPlayer);
    //        }
    BlockPos pos = new BlockPos(x, y, z);
    Block block = world.getBlockState(pos).getBlock();
    if (block instanceof GenericBlock) {
        GenericBlock genericBlock = (GenericBlock) block;
        TileEntity te = world.getTileEntity(pos);
        return genericBlock.createServerContainer(entityPlayer, te);
    }
    return null;
}
Also used : GenericBlock(mcjty.lib.container.GenericBlock) TileEntity(net.minecraft.tileentity.TileEntity) GenericBlock(mcjty.lib.container.GenericBlock) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 52 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class SmartLightingQuad method pipe.

@Override
public void pipe(IVertexConsumer consumer) {
    IBlockAccess world = null;
    BlockInfo info = null;
    if (consumer instanceof VertexLighterFlat) {
        try {
            info = (BlockInfo) blockInfo.get(consumer);
            world = info.getWorld();
            if (world instanceof ChunkCache)
                world = ((ChunkCache) world).worldObj;
            consumer = (IVertexConsumer) parent.get(consumer);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    consumer.setQuadOrientation(this.getFace());
    if (this.hasTintIndex())
        consumer.setQuadTint(this.getTintIndex());
    float[] data = new float[4];
    VertexFormat format = consumer.getVertexFormat();
    int count = format.getElementCount();
    int[] eMap = LightUtil.mapFormats(format, DefaultVertexFormats.ITEM);
    int itemCount = DefaultVertexFormats.ITEM.getElementCount();
    eMap[eMap.length - 1] = 2;
    for (int v = 0; v < 4; v++) for (int e = 0; e < count; e++) if (eMap[e] != itemCount) {
        if (//lightmap is UV with 2 shorts
        format.getElement(e).getUsage() == EnumUsage.UV && format.getElement(e).getType() == EnumType.SHORT) {
            int brightness;
            if (!ignoreLight && world != null && !(world instanceof ChunkCache)) {
                BlockPos here = blockPos.add(relativePos[v][0], relativePos[v][1], relativePos[v][2]);
                brightness = world.getCombinedLight(here, 0);
            } else
                brightness = staticBrightness;
            data[0] = ((float) ((brightness >> 0x04) & 0xF) * 0x20) / 0xFFFF;
            data[1] = ((float) ((brightness >> 0x14) & 0xF) * 0x20) / 0xFFFF;
        } else
            LightUtil.unpack(this.getVertexData(), data, DefaultVertexFormats.ITEM, v, eMap[e]);
        consumer.put(e, data);
    } else
        consumer.put(e, 0);
}
Also used : ChunkCache(net.minecraft.world.ChunkCache) IBlockAccess(net.minecraft.world.IBlockAccess) BlockPos(net.minecraft.util.math.BlockPos) VertexFormat(net.minecraft.client.renderer.vertex.VertexFormat)

Example 53 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class ConnModelReal method getQuads.

@Override
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side == null && state instanceof IExtendedBlockState) {
        IExtendedBlockState iExtendedBlockState = (IExtendedBlockState) state;
        ExtBlockstateAdapter ad = new ExtBlockstateAdapter(iExtendedBlockState, null, ExtBlockstateAdapter.ONLY_OBJ_CALLBACK);
        int x = 0, z = 0;
        if (iExtendedBlockState.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) {
            Set<Connection> conns = iExtendedBlockState.getValue(IEProperties.CONNECTIONS);
            if (conns != null && conns.size() > 0) {
                BlockPos tmp = conns.iterator().next().start;
                x = (tmp.getX() % 16 + 16) % 16;
                z = (tmp.getZ() % 16 + 16) % 16;
            }
        }
        Pair<Byte, ExtBlockstateAdapter> key = new ImmutablePair<>((byte) ((x << 4) | z), ad);
        IBakedModel ret = cache.get(key);
        if (ret == null) {
            ret = new AssembledBakedModel(iExtendedBlockState, textureAtlasSprite, base, rand);
            cache.put(key, ret);
        }
        return ret.getQuads(state, side, rand);
    }
    return base.getQuads(state, side, rand);
}
Also used : ImmutablePair(org.apache.commons.lang3.tuple.ImmutablePair) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) Connection(blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection) BlockPos(net.minecraft.util.math.BlockPos) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 54 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class EntityChemthrowerShot method onEntityUpdate.

@Override
public void onEntityUpdate() {
    if (this.getFluid() == null && this.worldObj.isRemote)
        this.fluid = getFluidSynced();
    IBlockState state = worldObj.getBlockState(new BlockPos(posX, posY, posZ));
    Block b = state.getBlock();
    if (b != null && this.canIgnite() && (state.getMaterial() == Material.FIRE || state.getMaterial() == Material.LAVA))
        this.setFire(6);
    super.onEntityUpdate();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) Block(net.minecraft.block.Block) BlockPos(net.minecraft.util.math.BlockPos)

Example 55 with BlockPos

use of net.minecraft.util.math.BlockPos in project ImmersiveEngineering by BluSunrize.

the class TileEntityWatermill method placeDummies.

@Override
public void placeDummies(BlockPos pos, IBlockState state, EnumFacing side, float hitX, float hitY, float hitZ) {
    for (int hh = -2; hh <= 2; hh++) for (int ww = -2; ww <= 2; ww++) if ((hh > -2 && hh < 2) || (ww > -2 && ww < 2)) {
        BlockPos pos2 = pos.add(facing.getAxis() == Axis.Z ? ww : 0, hh, facing.getAxis() == Axis.Z ? 0 : ww);
        worldObj.setBlockState(pos2, state);
        TileEntityWatermill dummy = (TileEntityWatermill) worldObj.getTileEntity(pos2);
        dummy.facing = facing;
        dummy.offset = new int[] { ww, hh };
    }
}
Also used : 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