Search in sources :

Example 1 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create_Aeronautics by Eriksonnaren.

the class SimulatedContraptionRigidbody method updateWings.

void updateWings() {
    for (Map.Entry<BlockPos, BlockState> entry : entity.sails.entrySet()) {
        Vector3d pos = getLocalCoordinate(entry.getKey());
        Vector3d vel = getLocalVelocityAtPosition(pos);
        Vector3d normal = getFacingVector(entry.getValue());
        Vector3d force = normal.scale(-0.8f * normal.dot(vel));
        addForce(force, pos);
    }
    for (Map.Entry<UUID, ControlledContraptionEntity> contraptionEntityEntry : entity.subContraptions.entrySet()) {
        // TODO: make propellers not provide lift
        if (contraptionEntityEntry.getValue() != null) {
            Contraption subContraption = contraptionEntityEntry.getValue().getContraption();
            for (Map.Entry<BlockPos, Template.BlockInfo> blockStateEntry : subContraption.getBlocks().entrySet()) {
                if (blockStateEntry.getValue().state.getBlock() instanceof SailBlock) {
                    Vector3d pos = contraptionEntityEntry.getValue().applyRotation(VecHelper.getCenterOf(blockStateEntry.getKey()), 0);
                    pos.subtract(centerOfMass);
                    Vector3d vel = getLocalVelocityAtPosition(pos);
                    Vector3d normal = getFacingVector(blockStateEntry.getValue().state);
                    normal = contraptionEntityEntry.getValue().applyRotation(normal, 0);
                    Vector3d force = normal.scale(-0.8f * normal.dot(vel));
                    addForce(force, pos);
                }
            }
        }
    }
}
Also used : ControlledContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity) BlockState(net.minecraft.block.BlockState) Vector3d(net.minecraft.util.math.vector.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) AirshipContraption(com.eriksonn.createaeronautics.contraptions.AirshipContraption) SailBlock(com.simibubi.create.content.contraptions.components.structureMovement.bearing.SailBlock)

Example 2 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionEntityRenderer method render.

@Override
public void render(AirshipContraptionEntity entity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int overlay) {
    super.render(entity, yaw, partialTicks, ms, buffers, overlay);
    Contraption contraption = entity.getContraption();
    BlockPos anchorPos = AirshipManager.getPlotPosFromId(entity.plotId);
    if (contraption != null) {
    // ContraptionRenderDispatcher.renderFromEntity(entity, contraption, buffers);
    }
}
Also used : BlockPos(net.minecraft.util.math.BlockPos) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption)

Example 3 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create_Aeronautics by Eriksonnaren.

the class AirshipContraptionRenderer method render.

public void render(AirshipContraptionEntity entity, float yaw, float partialTicks, MatrixStack ms, IRenderTypeBuffer buffers, int overlay) {
    super.render(entity, yaw, partialTicks, ms, buffers, overlay);
    // ContraptionMatrices matrices = new ContraptionMatrices(ms, entity);
    Contraption contraption = entity.getContraption();
    if (contraption != null) {
    // ContraptionRenderDispatcher.render(entity, contraption, matrices, buffers);
    }
    ClientWorld w = ClientWorldLoader.getWorld(AirshipDimensionManager.INSTANCE.getWorld().dimension());
    AirshipContraption aircon = (AirshipContraption) contraption;
    Vector3i vec1 = new Vector3i((float) entity.position().x - 5, (float) entity.position().y - 5, (float) entity.position().z - 5);
    Vector3i vec2 = new Vector3i((float) entity.position().x + 5, (float) entity.position().y + 5, (float) entity.position().z + 5);
    vec1 = new Vector3i(-4, -4, -4);
    vec2 = new Vector3i(4, 4, 4);
    // timer=1;
    // if (timer==1)
    // renderer.setActive(true);
    // renderer.tick();
    // if (timer==1)
    // renderer.update();
    AirshipWorld aw = new AirshipWorld(AirshipDimensionManager.INSTANCE.getWorld());
    // if (timer==1)
    // renderer.display(aw,aircon.anchor,new MutableBoundingBox(vec1.getX(),vec1.getY(),vec1.getZ(),vec2.getX(),vec2.getY(),vec2.getZ()));
    timer++;
    timer = timer % 15;
    // SuperRenderTypeBuffer buffer = SuperRenderTypeBuffer.getInstance();
    ms.pushPose();
    // Quaternion Q2 = .copy();
    // Q2.mul(Q);
    // ms.mulPose(entity.Quat);
    // ms.mulPose();
    // renderer.render(ms,buffer);
    // buffer.draw();
    ms.popPose();
    // if(aircon!=null) {
    // if(aircon.storageWorld !=null) {
    // PortalRendering.onBeginPortalWorldRendering();
    // try {
    int renderDistance = 3;
// WorldRenderInfo worldRenderInfo = new WorldRenderInfo(w, CGlobal.originalCamera.getPosition(), new Matrix4f(new Quaternion(0, 0, 0, 1)), false, entity.getUUID(), renderDistance);
// WorldRenderInfo.pushRenderInfo(worldRenderInfo);
// Test(w,Runnable::run);
// MyGameRenderer.renderWorldNew(worldRenderInfo, Runnable::run);
// switchAndRenderTheWorld(w, CGlobal.originalCamera.getPosition(), CGlobal.originalCamera.getPosition(), Runnable::run, 3);
// WorldRenderInfo.popRenderInfo();
// PortalRendering.onEndPortalWorldRendering();
// GlStateManager._enableDepthTest();
// GlStateManager._disableBlend();
// MyRenderHelper.restoreViewPort();
// }
// catch(Exception e)
// {
// 
// }
// }
// }
}
Also used : Vector3i(net.minecraft.util.math.vector.Vector3i) ClientWorld(net.minecraft.client.world.ClientWorld) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) AirshipWorld(com.eriksonn.createaeronautics.dimension.AirshipWorld)

Example 4 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create by Creators-of-Create.

the class SimpleBlockMovingInteraction method handlePlayerInteraction.

@Override
public boolean handlePlayerInteraction(Player player, InteractionHand activeHand, BlockPos localPos, AbstractContraptionEntity contraptionEntity) {
    Contraption contraption = contraptionEntity.getContraption();
    StructureBlockInfo info = contraption.getBlocks().get(localPos);
    BlockState newState = handle(player, contraption, localPos, info.state);
    if (info.state == newState)
        return false;
    setContraptionBlockData(contraptionEntity, localPos, new StructureBlockInfo(info.pos, newState, info.nbt));
    if (updateColliders())
        contraption.invalidateColliders();
    return true;
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption) StructureBlockInfo(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo)

Example 5 with Contraption

use of com.simibubi.create.content.contraptions.components.structureMovement.Contraption in project Create by Creators-of-Create.

the class EntityContraptionInteractionMixin method forCollision.

private void forCollision(Vec3 anchorPos, TriConsumer<Contraption, BlockState, BlockPos> action) {
    getIntersectingContraptions().forEach(cEntity -> {
        Vec3 localPos = ContraptionCollider.getWorldToLocalTranslation(anchorPos, cEntity);
        localPos = anchorPos.add(localPos);
        BlockPos blockPos = new BlockPos(localPos);
        Contraption contraption = cEntity.getContraption();
        StructureTemplate.StructureBlockInfo info = contraption.getBlocks().get(blockPos);
        if (info != null) {
            BlockState blockstate = info.state;
            action.accept(contraption, blockstate, blockPos);
        }
    });
}
Also used : BlockState(net.minecraft.world.level.block.state.BlockState) Vec3(net.minecraft.world.phys.Vec3) BlockPos(net.minecraft.core.BlockPos) StructureTemplate(net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate) Contraption(com.simibubi.create.content.contraptions.components.structureMovement.Contraption)

Aggregations

Contraption (com.simibubi.create.content.contraptions.components.structureMovement.Contraption)11 BlockPos (net.minecraft.util.math.BlockPos)5 Vector3d (net.minecraft.util.math.vector.Vector3d)4 BlockState (net.minecraft.block.BlockState)3 RaycastHelper (com.simibubi.create.foundation.utility.RaycastHelper)2 ISpeedContraption (com.teammoeg.frostedheart.util.ISpeedContraption)2 Minecraft (net.minecraft.client.Minecraft)2 ClientPlayerEntity (net.minecraft.client.entity.player.ClientPlayerEntity)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2 BlockRayTraceResult (net.minecraft.util.math.BlockRayTraceResult)2 VoxelShape (net.minecraft.util.math.shapes.VoxelShape)2 Template (net.minecraft.world.gen.feature.template.Template)2 BlockState (net.minecraft.world.level.block.state.BlockState)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 MutableObject (org.apache.commons.lang3.mutable.MutableObject)2 AirshipContraption (com.eriksonn.createaeronautics.contraptions.AirshipContraption)1 AirshipContraptionEntity (com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity)1 AirshipWorld (com.eriksonn.createaeronautics.dimension.AirshipWorld)1 MatrixTransformStack (com.jozufozu.flywheel.util.transform.MatrixTransformStack)1 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1