use of com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity in project Create_Aeronautics by Eriksonnaren.
the class ClientPacketHandler method handlePacket.
public static void handlePacket(AirshipAddSubcontraptionPacket msg, Supplier<NetworkEvent.Context> ctx) {
Map<Integer, AirshipContraptionEntity> allAirships = AirshipManager.INSTANCE.AllClientAirships;
if (allAirships.containsKey(msg.plotID)) {
AirshipContraptionEntity airship = allAirships.get(msg.plotID);
airship.addSubcontraptionClient(msg.nbt, msg.uuid, msg.pos);
}
}
use of com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity 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.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity in project Create_Aeronautics by Eriksonnaren.
the class ContraptionColliderMixin method collideEntitiesMixin.
@Redirect(remap = false, method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/components/structureMovement/ContraptionCollider;getWorldToLocalTranslation(Lnet/minecraft/entity/Entity;Lnet/minecraft/util/math/vector/Vector3d;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/util/math/vector/Vector3d;"))
private static Vector3d collideEntitiesMixin(Entity entity, Vector3d anchorVec, Matrix3d rotationMatrix, float yawOffset, AbstractContraptionEntity contraptionEntity) {
Vector3d position = getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset);
if (contraptionEntity instanceof AirshipContraptionEntity) {
AirshipContraptionEntity airshipEntity = (AirshipContraptionEntity) contraptionEntity;
position = position.add(airshipEntity.centerOfMassOffset);
}
return position;
}
use of com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity in project Create_Aeronautics by Eriksonnaren.
the class ContraptionRenderInfoMixin method afterBeginFrame.
// /**
// * @author Eriksonn
// */
// @Overwrite(remap = false)
// public void beginFrame(BeginFrameEvent event) {
// matrices.clear();
//
// AbstractContraptionEntity entity = contraption.entity;
// if(entity instanceof ControlledContraptionEntity && entity.level.dimension() == AirshipDimensionManager.WORLD_ID) {
// int plotId = AirshipManager.getIdFromPlotPos(entity.blockPosition());
// AirshipContraptionEntity airshipEntity = AirshipManager.INSTANCE.AllAirships.get(plotId);
// if (airshipEntity != null) {
// entity = airshipEntity;
// }
// }
// visible = event.getClippingHelper().isVisible(entity.getBoundingBoxForCulling().inflate(2));
// }
@Inject(locals = LocalCapture.CAPTURE_FAILHARD, remap = false, method = "beginFrame", at = @At("TAIL"))
public void afterBeginFrame(BeginFrameEvent event, CallbackInfo ci, AbstractContraptionEntity entity) {
if (entity instanceof ControlledContraptionEntity && entity.level instanceof FakeAirshipClientWorld) {
int plotId = AirshipManager.getIdFromPlotPos(entity.blockPosition());
AirshipContraptionEntity airshipEntity = AirshipManager.INSTANCE.AllAirships.get(plotId);
if (airshipEntity != null) {
visible = event.getClippingHelper().isVisible(airshipEntity.getBoundingBoxForCulling().inflate(2));
}
}
//
}
use of com.eriksonn.createaeronautics.contraptions.AirshipContraptionEntity in project Create_Aeronautics by Eriksonnaren.
the class RedstoneLinkNetworkMixin method updateNetworkOf.
@Inject(method = "updateNetworkOf", remap = false, at = @At("HEAD"))
public void updateNetworkOf(IWorld world, IRedstoneLinkable inRealWorldActor, CallbackInfo ci) {
// airship dimension trickery
ServerWorld airshipDimension = AirshipDimensionManager.INSTANCE.getWorld();
if (world != airshipDimension) {
// iterate over all airships in the world
for (AirshipContraptionEntity airship : AirshipManager.INSTANCE.AllAirships.values()) {
// plotpos
BlockPos plotPos = airship.getPlotPos();
// get network
Set<IRedstoneLinkable> airshipNetwork = Create.REDSTONE_LINK_NETWORK_HANDLER.getNetworkOf(airshipDimension, inRealWorldActor);
Set<IRedstoneLinkable> realWorldNetwork = Create.REDSTONE_LINK_NETWORK_HANDLER.getNetworkOf(world, inRealWorldActor);
int power = 0;
for (Iterator<IRedstoneLinkable> iterator = airshipNetwork.iterator(); iterator.hasNext(); ) {
IRedstoneLinkable inAirshipDimensionActor = iterator.next();
if (!inAirshipDimensionActor.isAlive()) {
iterator.remove();
continue;
}
if (!withinRange(inRealWorldActor, airship, plotPos, inAirshipDimensionActor)) {
iterator.remove();
continue;
}
if (power < 15)
power = Math.max(inAirshipDimensionActor.getTransmittedStrength(), power);
for (Iterator<IRedstoneLinkable> iterator1 = realWorldNetwork.iterator(); iterator1.hasNext(); ) {
IRedstoneLinkable inRealWorldActor2 = iterator1.next();
if (!inRealWorldActor2.isAlive()) {
iterator1.remove();
continue;
}
if (!withinRange(inRealWorldActor2, airship, plotPos, inAirshipDimensionActor)) {
iterator1.remove();
continue;
}
if (power < 15)
power = Math.max(inRealWorldActor2.getTransmittedStrength(), power);
}
}
if (inRealWorldActor instanceof LinkBehaviour) {
LinkBehaviour linkBehaviour = (LinkBehaviour) inRealWorldActor;
// fix one-to-one loading order problem
if (linkBehaviour.isListening()) {
linkBehaviour.newPosition = true;
linkBehaviour.setReceivedStrength(power);
}
}
for (IRedstoneLinkable other : airshipNetwork) {
if (other != inRealWorldActor && other.isListening() && withinRange(inRealWorldActor, airship, plotPos, other))
other.setReceivedStrength(power);
}
}
}
}
Aggregations