use of com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity in project Create_Aeronautics by Eriksonnaren.
the class ServerWorldEventMixin method addFreshEntity.
/**
* @author RyanHCode
*/
@Overwrite(remap = false)
public boolean addFreshEntity(Entity entity) {
if (((Object) this) instanceof ServerWorld && ((ServerWorld) (Object) this).dimension() == AirshipDimensionManager.WORLD_ID && !(entity instanceof AbstractContraptionEntity || entity instanceof SuperGlueEntity)) {
// get position of entity
Vector3d pos = entity.position();
BlockPos bPos = entity.blockPosition();
// get airship plot id
int id = AirshipManager.getIdFromPlotPos(bPos);
BlockPos plotPos = AirshipManager.getPlotPosFromId(id);
// get airship
AirshipContraptionEntity airship = AirshipManager.INSTANCE.AllAirships.get(id);
if (airship != null) {
Vector3d position = pos;
position = position.subtract(plotPos.getX(), plotPos.getY(), plotPos.getZ());
position = airship.toGlobalVector(position, 1.0f);
// rotate entity motion
entity.setDeltaMovement(airship.applyRotation(entity.getDeltaMovement(), 1.0f));
entity.setPosRaw(position.x, position.y, position.z);
entity.setLevel(airship.level);
return airship.level.addFreshEntity(entity);
}
}
return this.addEntity(entity);
}
use of com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity in project Create by Creators-of-Create.
the class ContraptionSeatMappingPacket method handle.
@Override
public void handle(Supplier<Context> context) {
context.get().enqueueWork(() -> {
Entity entityByID = Minecraft.getInstance().level.getEntity(entityID);
if (!(entityByID instanceof AbstractContraptionEntity))
return;
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
contraptionEntity.getContraption().setSeatMapping(mapping);
});
context.get().setPacketHandled(true);
}
use of com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity in project Create by Creators-of-Create.
the class CouplingHandler method preventEntitiesFromMoutingOccupiedCart.
@SubscribeEvent
public static void preventEntitiesFromMoutingOccupiedCart(EntityMountEvent event) {
Entity e = event.getEntityBeingMounted();
LazyOptional<MinecartController> optional = e.getCapability(CapabilityMinecartController.MINECART_CONTROLLER_CAPABILITY);
if (!optional.isPresent())
return;
if (event.getEntityMounting() instanceof AbstractContraptionEntity)
return;
MinecartController controller = optional.orElse(null);
if (controller.isCoupledThroughContraption()) {
event.setCanceled(true);
event.setResult(Result.DENY);
}
}
use of com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity in project Create by Creators-of-Create.
the class ContraptionRenderInfo method setupMatrices.
/**
* Need to call this during RenderLayerEvent.
*/
public void setupMatrices(PoseStack viewProjection, double camX, double camY, double camZ) {
if (!matrices.isReady()) {
AbstractContraptionEntity entity = contraption.entity;
viewProjection.pushPose();
double x = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.xOld, entity.getX()) - camX;
double y = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.yOld, entity.getY()) - camY;
double z = Mth.lerp(AnimationTickHolder.getPartialTicks(), entity.zOld, entity.getZ()) - camZ;
viewProjection.translate(x, y, z);
matrices.setup(viewProjection, entity);
viewProjection.popPose();
}
}
use of com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity in project Create by Creators-of-Create.
the class ContraptionFluidPacket method handle.
@Override
public void handle(Supplier<Context> context) {
context.get().enqueueWork(() -> {
Entity entityByID = Minecraft.getInstance().level.getEntity(entityId);
if (!(entityByID instanceof AbstractContraptionEntity))
return;
AbstractContraptionEntity contraptionEntity = (AbstractContraptionEntity) entityByID;
contraptionEntity.getContraption().updateContainedFluid(localPos, containedFluid);
});
context.get().setPacketHandled(true);
}
Aggregations