Search in sources :

Example 1 with AbstractContraptionEntity

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);
}
Also used : ServerWorld(net.minecraft.world.server.ServerWorld) AirshipContraptionEntity(com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity) SuperGlueEntity(com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity) Vector3d(net.minecraft.util.math.vector.Vector3d) BlockPos(net.minecraft.util.math.BlockPos) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity) Overwrite(org.spongepowered.asm.mixin.Overwrite)

Example 2 with AbstractContraptionEntity

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);
}
Also used : Entity(net.minecraft.world.entity.Entity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity)

Example 3 with AbstractContraptionEntity

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);
    }
}
Also used : Entity(net.minecraft.world.entity.Entity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity) MinecartController(com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController) CapabilityMinecartController(com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 4 with AbstractContraptionEntity

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();
    }
}
Also used : AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity)

Example 5 with AbstractContraptionEntity

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);
}
Also used : Entity(net.minecraft.world.entity.Entity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity) AbstractContraptionEntity(com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity)

Aggregations

AbstractContraptionEntity (com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity)14 Entity (net.minecraft.world.entity.Entity)9 OrientedContraptionEntity (com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity)4 BlockState (net.minecraft.world.level.block.state.BlockState)3 BlockPos (net.minecraft.core.BlockPos)2 ServerPlayer (net.minecraft.server.level.ServerPlayer)2 Level (net.minecraft.world.level.Level)2 AABB (net.minecraft.world.phys.AABB)2 Vec3 (net.minecraft.world.phys.Vec3)2 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)2 AirshipContraptionEntity (com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity)1 Multimap (com.google.common.collect.Multimap)1 ByteArrayDataOutput (com.google.common.io.ByteArrayDataOutput)1 AllSoundEvents (com.simibubi.create.AllSoundEvents)1 Mode (com.simibubi.create.content.contraptions.components.deployer.DeployerTileEntity.Mode)1 ControlledContraptionEntity (com.simibubi.create.content.contraptions.components.structureMovement.ControlledContraptionEntity)1 SuperGlueEntity (com.simibubi.create.content.contraptions.components.structureMovement.glue.SuperGlueEntity)1 CartAssemblerBlockItem (com.simibubi.create.content.contraptions.components.structureMovement.mounted.CartAssemblerBlockItem)1 CapabilityMinecartController (com.simibubi.create.content.contraptions.components.structureMovement.train.capability.CapabilityMinecartController)1 MinecartController (com.simibubi.create.content.contraptions.components.structureMovement.train.capability.MinecartController)1