Search in sources :

Example 16 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class TileManager method getSlotsForFace.

@Override
public int[] getSlotsForFace(Direction side) {
    Direction direction = getFacingDirection();
    if (side == direction || side == direction.getOpposite()) {
        return new int[] {};
    }
    int[] slots = new int[inventory.size()];
    for (int i = 0; i < slots.length; i++) slots[i] = i;
    return slots;
}
Also used : Direction(net.minecraft.util.Direction)

Example 17 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class BPMultipartModel method getQuads.

@Nonnull
@Override
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
    BlockRendererDispatcher brd = Minecraft.getInstance().getBlockRenderer();
    Map<BlockState, IModelData> stateInfo = extraData.getData(TileBPMultipart.STATE_INFO);
    if (stateInfo != null) {
        return stateInfo.keySet().stream().flatMap(i -> brd.getBlockModel(i).getQuads(i, side, rand, stateInfo.get(i)).stream().map(q -> stateInfo.get(i).hasProperty(TileWire.COLOR_INFO) ? transform(q, stateInfo.get(i).getData(TileWire.COLOR_INFO), stateInfo.get(i).hasProperty(TileWire.LIGHT_INFO) ? stateInfo.get(i).getData(TileWire.LIGHT_INFO) : false) : q)).collect(Collectors.toList());
    } else {
        return Collections.emptyList();
    }
}
Also used : BakedQuadBuilder(net.minecraftforge.client.model.pipeline.BakedQuadBuilder) java.util(java.util) IBakedModel(net.minecraft.client.renderer.model.IBakedModel) ItemOverrideList(net.minecraft.client.renderer.model.ItemOverrideList) Direction(net.minecraft.util.Direction) RayTraceResult(net.minecraft.util.math.RayTraceResult) Minecraft(net.minecraft.client.Minecraft) BlockState(net.minecraft.block.BlockState) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) MultipartUtils(com.bluepowermod.util.MultipartUtils) TileWire(com.bluepowermod.tile.tier1.TileWire) VertexTransformer(net.minecraftforge.client.model.pipeline.VertexTransformer) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) IModelData(net.minecraftforge.client.model.data.IModelData) IVertexConsumer(net.minecraftforge.client.model.pipeline.IVertexConsumer) Collectors(java.util.stream.Collectors) TileBPMultipart(com.bluepowermod.tile.TileBPMultipart) Pair(com.mojang.datafixers.util.Pair) BakedQuad(net.minecraft.client.renderer.model.BakedQuad) BlockRayTraceResult(net.minecraft.util.math.BlockRayTraceResult) VertexFormatElement(net.minecraft.client.renderer.vertex.VertexFormatElement) LightUtil(net.minecraftforge.client.model.pipeline.LightUtil) ModelResourceLocation(net.minecraft.client.renderer.model.ModelResourceLocation) BlockState(net.minecraft.block.BlockState) IModelData(net.minecraftforge.client.model.data.IModelData) BlockRendererDispatcher(net.minecraft.client.renderer.BlockRendererDispatcher) Nonnull(javax.annotation.Nonnull)

Example 18 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class RenderLamp method render.

@Override
public void render(TileLamp te, float v, MatrixStack matrixStack, IRenderTypeBuffer iRenderTypeBuffer, int partialTicks, int destroyStage) {
    if (// || Loader.isModLoaded("albedo"))
    !(te.getBlockState().getBlock() instanceof BlockLamp))
        return;
    BlockState stateLamp = te.getBlockState();
    BlockLamp bLamp = (BlockLamp) stateLamp.getBlock();
    if (te.getLevel() == null) {
        return;
    }
    int power = stateLamp.getValue(BlockLamp.POWER);
    int color = bLamp.getColor(stateLamp, te.getLevel(), te.getBlockPos(), 0);
    int redMask = 0xFF0000, greenMask = 0xFF00, blueMask = 0xFF;
    int r = (color & redMask) >> 16;
    int g = (color & greenMask) >> 8;
    int b = (color & blueMask);
    AxisAlignedBB box = stateLamp.getShape(te.getLevel(), te.getBlockPos()).bounds();
    // Define our base Glow
    box = box.equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1)) ? box.inflate(0.05) : box.inflate(0.03125);
    boolean[] renderFaces = new boolean[] { true, true, true, true, true, true };
    // Remove overlapping Glow
    if (stateLamp.getShape(te.getLevel(), te.getBlockPos()).bounds().equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1))) {
        for (Direction face : Direction.values()) {
            BlockState state = te.getLevel().getBlockState(te.getBlockPos().relative(face.getOpposite()));
            if (state.getBlock() instanceof BlockLamp && state.getShape(te.getLevel(), te.getBlockPos()).bounds().equals(new AxisAlignedBB(0, 0, 0, 1, 1, 1))) {
                if (state.getValue(BlockLamp.POWER) > 0) {
                    renderFaces[face.get3DDataValue()] = false;
                    double offsetx = (face.getStepX() * 0.05) > 0 ? (face.getStepX() * 0.05) : 0;
                    double offsety = (face.getStepY() * 0.05) > 0 ? (face.getStepY() * 0.05) : 0;
                    double offsetz = (face.getStepZ() * 0.05) > 0 ? (face.getStepZ() * 0.05) : 0;
                    double toffsetx = (face.getStepX() * 0.05) < 0 ? (face.getStepX() * 0.05) : 0;
                    double toffsety = (face.getStepY() * 0.05) < 0 ? (face.getStepY() * 0.05) : 0;
                    double toffsetz = (face.getStepZ() * 0.05) < 0 ? (face.getStepZ() * 0.05) : 0;
                    box = new AxisAlignedBB(box.minX + offsetx, box.minY + offsety, box.minZ + offsetz, box.maxX + toffsetx, box.maxY + toffsety, box.maxZ + toffsetz);
                }
            }
        }
    }
    matrixStack.pushPose();
    double powerDivision = power / 18D;
    com.bluepowermod.client.render.RenderHelper.drawColoredCube(box, iRenderTypeBuffer.getBuffer(BPRenderTypes.LAMP_GLOW), matrixStack, r, g, b, (int) (powerDivision * 200), 200, renderFaces);
    matrixStack.popPose();
}
Also used : AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BlockState(net.minecraft.block.BlockState) BlockLamp(com.bluepowermod.block.lighting.BlockLamp) Direction(net.minecraft.util.Direction)

Example 19 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class Renderers method onModelBakeEvent.

@SubscribeEvent
public void onModelBakeEvent(ModelBakeEvent event) {
    // Register Multipart Model
    BPMultipartModel multipartModel = new BPMultipartModel();
    event.getModelRegistry().put(new ModelResourceLocation("bluepower:multipart", "waterlogged=false"), multipartModel);
    event.getModelRegistry().put(new ModelResourceLocation("bluepower:multipart", "waterlogged=true"), multipartModel);
    BPMicroblockModel microblockModel = new BPMicroblockModel();
    for (Direction dir : Direction.values()) {
        // Register Microblock Models
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=true")));
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=true")));
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "face=" + dir.getName()), event.getModelRegistry().get(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=true")));
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=true"), microblockModel);
        event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "facing=" + dir.getName() + ",waterlogged=false"), microblockModel);
    }
    event.getModelRegistry().put(new ModelResourceLocation("bluepower:half_block", "inventory"), microblockModel);
    event.getModelRegistry().put(new ModelResourceLocation("bluepower:panel", "inventory"), microblockModel);
    event.getModelRegistry().put(new ModelResourceLocation("bluepower:cover", "inventory"), microblockModel);
}
Also used : Direction(net.minecraft.util.Direction) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 20 with Direction

use of net.minecraft.util.Direction in project BluePower by Qmunity.

the class TileSortingMachine method triggerSorting.

private void triggerSorting() {
    Direction dir = getOutputDirection().getOpposite();
    // might need opposite
    TileEntity inputTE = getTileCache(dir);
    if (inputTE instanceof IInventory) {
        IInventory inputInv = (IInventory) inputTE;
        int[] accessibleSlots;
        if (inputInv instanceof ISidedInventory) {
            accessibleSlots = ((ISidedInventory) inputInv).getSlotsForFace(dir.getOpposite());
        } else {
            accessibleSlots = new int[inputInv.getContainerSize()];
            for (int i = 0; i < accessibleSlots.length; i++) accessibleSlots[i] = i;
        }
        for (int slot : accessibleSlots) {
            ItemStack stack = inputInv.getItem(slot);
            if (!stack.isEmpty() && IOHelper.canTakeItemThroughFaceFromInventory(inputInv, stack, slot, dir.getOpposite().ordinal())) {
                if (tryProcessItem(stack, false)) {
                    if (stack.getCount() == 0)
                        inputInv.setItem(slot, ItemStack.EMPTY);
                    return;
                }
            }
        }
        if (sortMode == SortMode.ANYSTACK_SEQUENTIAL) {
            for (int i = curColumn; i < inventory.size(); i += 8) {
                ItemStack filterStack = inventory.get(i);
                if (!filterStack.isEmpty()) {
                    ItemStack extractedStack = IOHelper.extract(inputTE, dir.getOpposite(), filterStack, true, false);
                    if (!extractedStack.isEmpty()) {
                        addItemToOutputBuffer(extractedStack.copy(), colors[curColumn]);
                        gotoNextNonEmptyColumn();
                        break;
                    }
                }
            }
        } else if (sortMode == SortMode.ALLSTACK_SEQUENTIAL) {
            if (matchAndProcessColumn(inputInv, accessibleSlots, curColumn)) {
                gotoNextNonEmptyColumn();
            }
        } else if (sortMode == SortMode.RANDOM_ALLSTACKS) {
            for (int i = 0; i < 8; i++) {
                if (matchAndProcessColumn(inputInv, accessibleSlots, i)) {
                    break;
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IInventory(net.minecraft.inventory.IInventory) ISidedInventory(net.minecraft.inventory.ISidedInventory) ItemStack(net.minecraft.item.ItemStack) Direction(net.minecraft.util.Direction)

Aggregations

Direction (net.minecraft.util.Direction)50 BlockState (net.minecraft.block.BlockState)18 TileEntity (net.minecraft.tileentity.TileEntity)17 BlockPos (net.minecraft.util.math.BlockPos)15 ItemStack (net.minecraft.item.ItemStack)12 Block (net.minecraft.block.Block)10 Nonnull (javax.annotation.Nonnull)8 Nullable (javax.annotation.Nullable)8 CompoundNBT (net.minecraft.nbt.CompoundNBT)6 IPowerBase (com.bluepowermod.api.power.IPowerBase)5 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 World (net.minecraft.world.World)5 Capability (net.minecraftforge.common.capabilities.Capability)5 BlutricityStorage (com.bluepowermod.api.power.BlutricityStorage)4 CapabilityBlutricity (com.bluepowermod.api.power.CapabilityBlutricity)4 EnergyHelper (com.bluepowermod.helper.EnergyHelper)4 BPTileEntityType (com.bluepowermod.tile.BPTileEntityType)4 TileMachineBase (com.bluepowermod.tile.TileMachineBase)4 INBT (net.minecraft.nbt.INBT)4 LazyOptional (net.minecraftforge.common.util.LazyOptional)4