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);
}
}
}
}
}
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);
}
}
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)
// {
//
// }
// }
// }
}
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;
}
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);
}
});
}
Aggregations