use of com.simibubi.create.content.logistics.IRedstoneLinkable 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