Search in sources :

Example 1 with Shape

use of com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape in project Create by Creators-of-Create.

the class BeltTunnelTileEntity method updateTunnelConnections.

public void updateTunnelConnections() {
    flaps.clear();
    sides.clear();
    BlockState tunnelState = getBlockState();
    for (Direction direction : Iterate.horizontalDirections) {
        if (direction.getAxis() != tunnelState.getValue(BlockStateProperties.HORIZONTAL_AXIS)) {
            boolean positive = direction.getAxisDirection() == AxisDirection.POSITIVE ^ direction.getAxis() == Axis.Z;
            Shape shape = tunnelState.getValue(BeltTunnelBlock.SHAPE);
            if (BeltTunnelBlock.isStraight(tunnelState))
                continue;
            if (positive && shape == Shape.T_LEFT)
                continue;
            if (!positive && shape == Shape.T_RIGHT)
                continue;
        }
        sides.add(direction);
        // Flap might be occluded
        BlockState nextState = level.getBlockState(worldPosition.relative(direction));
        if (nextState.getBlock() instanceof BeltTunnelBlock)
            continue;
        if (nextState.getBlock() instanceof BeltFunnelBlock)
            if (nextState.getValue(BeltFunnelBlock.SHAPE) == BeltFunnelBlock.Shape.EXTENDED && nextState.getValue(BeltFunnelBlock.HORIZONTAL_FACING) == direction.getOpposite())
                continue;
        flaps.put(direction, new InterpolatedChasingValue().start(.25f).target(0).withSpeed(.05f));
    }
    sendData();
}
Also used : InterpolatedChasingValue(com.simibubi.create.foundation.utility.animation.InterpolatedChasingValue) BlockState(net.minecraft.world.level.block.state.BlockState) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) BeltFunnelBlock(com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock) Direction(net.minecraft.core.Direction) AxisDirection(net.minecraft.core.Direction.AxisDirection)

Example 2 with Shape

use of com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape in project Create by Creators-of-Create.

the class BuilderTransformers method beltTunnel.

public static <B extends BeltTunnelBlock> NonNullUnaryOperator<BlockBuilder<B, CreateRegistrate>> beltTunnel(String type, ResourceLocation particleTexture) {
    return b -> b.initialProperties(SharedProperties::stone).addLayer(() -> RenderType::cutoutMipped).properties(BlockBehaviour.Properties::noOcclusion).transform(pickaxeOnly()).blockstate((c, p) -> p.getVariantBuilder(c.get()).forAllStates(state -> {
        String id = "block/" + type + "_tunnel";
        Shape shape = state.getValue(BeltTunnelBlock.SHAPE);
        if (shape == BeltTunnelBlock.Shape.CLOSED)
            shape = BeltTunnelBlock.Shape.STRAIGHT;
        String shapeName = shape.getSerializedName();
        return ConfiguredModel.builder().modelFile(p.models().withExistingParent(id + "/" + shapeName, p.modLoc("block/belt_tunnel/" + shapeName)).texture("1", p.modLoc(id + "_top")).texture("2", p.modLoc(id)).texture("3", p.modLoc(id + "_top_window")).texture("particle", particleTexture)).rotationY(state.getValue(BeltTunnelBlock.HORIZONTAL_AXIS) == Axis.X ? 0 : 90).build();
    })).item(BeltTunnelItem::new).model((c, p) -> {
        String id = type + "_tunnel";
        p.withExistingParent("item/" + id, p.modLoc("block/belt_tunnel/item")).texture("1", p.modLoc("block/" + id + "_top")).texture("2", p.modLoc("block/" + id)).texture("particle", particleTexture);
    }).build();
}
Also used : ResourceLocation(net.minecraft.resources.ResourceLocation) DyeColor(net.minecraft.world.item.DyeColor) PistonType(net.minecraft.world.level.block.state.properties.PistonType) AllTags.axeOrPickaxe(com.simibubi.create.AllTags.axeOrPickaxe) EncasedCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour) ModelFile(net.minecraftforge.client.model.generators.ModelFile) ItemUseOverrides(com.simibubi.create.foundation.block.ItemUseOverrides) BlockBuilder(com.tterrag.registrate.builders.BlockBuilder) HashMap(java.util.HashMap) Supplier(java.util.function.Supplier) EncasedCogCTBehaviour(com.simibubi.create.content.contraptions.relays.encased.EncasedCogCTBehaviour) BlockStressDefaults(com.simibubi.create.foundation.block.BlockStressDefaults) AllTags.pickaxeOnly(com.simibubi.create.AllTags.pickaxeOnly) Axis(net.minecraft.core.Direction.Axis) AxisDirection(net.minecraft.core.Direction.AxisDirection) CreateRegistrate.connectedTextures(com.simibubi.create.foundation.data.CreateRegistrate.connectedTextures) Create(com.simibubi.create.Create) ItemLike(net.minecraft.world.level.ItemLike) Map(java.util.Map) AllItemTags(com.simibubi.create.AllTags.AllItemTags) CreateRegistrate.casingConnectivity(com.simibubi.create.foundation.data.CreateRegistrate.casingConnectivity) EncasedCogwheelBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock) AllBlocks(com.simibubi.create.AllBlocks) Nullable(javax.annotation.Nullable) BlockBehaviour(net.minecraft.world.level.block.state.BlockBehaviour) BlockStateProperties(net.minecraft.world.level.block.state.properties.BlockStateProperties) BeltTunnelBlock(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock) EncasedShaftBlock(com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock) RenderType(net.minecraft.client.renderer.RenderType) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) SoundType(net.minecraft.world.level.block.SoundType) MechanicalPistonGenerator(com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonGenerator) CasingBlock(com.simibubi.create.content.contraptions.base.CasingBlock) CTSpriteShiftEntry(com.simibubi.create.foundation.block.connected.CTSpriteShiftEntry) ConfiguredModel(net.minecraftforge.client.model.generators.ConfiguredModel) NonNullUnaryOperator(com.tterrag.registrate.util.nullness.NonNullUnaryOperator) ValveHandleBlock(com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock) Block(net.minecraft.world.level.block.Block) BlockStateGen.axisBlock(com.simibubi.create.foundation.data.BlockStateGen.axisBlock) RotatedPillarKineticBlock(com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock) AllBlockTags(com.simibubi.create.AllTags.AllBlockTags) BeltTunnelItem(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem) Rarity(net.minecraft.world.item.Rarity) Shape(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape) BlockBehaviour(net.minecraft.world.level.block.state.BlockBehaviour) BeltTunnelItem(com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem) RenderType(net.minecraft.client.renderer.RenderType)

Aggregations

Shape (com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock.Shape)2 AxisDirection (net.minecraft.core.Direction.AxisDirection)2 AllBlocks (com.simibubi.create.AllBlocks)1 AllBlockTags (com.simibubi.create.AllTags.AllBlockTags)1 AllItemTags (com.simibubi.create.AllTags.AllItemTags)1 AllTags.axeOrPickaxe (com.simibubi.create.AllTags.axeOrPickaxe)1 AllTags.pickaxeOnly (com.simibubi.create.AllTags.pickaxeOnly)1 Create (com.simibubi.create.Create)1 CasingBlock (com.simibubi.create.content.contraptions.base.CasingBlock)1 RotatedPillarKineticBlock (com.simibubi.create.content.contraptions.base.RotatedPillarKineticBlock)1 ValveHandleBlock (com.simibubi.create.content.contraptions.components.crank.ValveHandleBlock)1 MechanicalPistonGenerator (com.simibubi.create.content.contraptions.components.structureMovement.piston.MechanicalPistonGenerator)1 EncasedCTBehaviour (com.simibubi.create.content.contraptions.relays.encased.EncasedCTBehaviour)1 EncasedCogCTBehaviour (com.simibubi.create.content.contraptions.relays.encased.EncasedCogCTBehaviour)1 EncasedCogwheelBlock (com.simibubi.create.content.contraptions.relays.encased.EncasedCogwheelBlock)1 EncasedShaftBlock (com.simibubi.create.content.contraptions.relays.encased.EncasedShaftBlock)1 BeltTunnelBlock (com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelBlock)1 BeltTunnelItem (com.simibubi.create.content.logistics.block.belts.tunnel.BeltTunnelItem)1 BeltFunnelBlock (com.simibubi.create.content.logistics.block.funnel.BeltFunnelBlock)1 BlockStressDefaults (com.simibubi.create.foundation.block.BlockStressDefaults)1