Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix for travel renderer on server #452

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/api/java/com/enderio/api/travel/TravelEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@
import net.minecraftforge.common.util.Lazy;

import java.util.function.Function;
import java.util.function.Supplier;

public record TravelEntry<T extends ITravelTarget>(ResourceLocation serializationName, Function<CompoundTag, T> constructor,
Lazy<TravelRenderer<T>> renderer) {}
Supplier<Lazy<TravelRenderer<T>>> renderer) {}
5 changes: 3 additions & 2 deletions src/api/java/com/enderio/api/travel/TravelRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

@ApiStatus.Internal
public class TravelRegistry {

private static final Map<ResourceLocation, TravelEntry<?>> registry = new HashMap<>();

public static <T extends ITravelTarget> void addTravelEntry(ResourceLocation serializationName, Function<CompoundTag, T> constructor,
Lazy<TravelRenderer<T>> renderer) {
Supplier<Lazy<TravelRenderer<T>>> renderer) {
registry.put(serializationName, new TravelEntry<>(serializationName, constructor, renderer));
}

Expand All @@ -25,7 +26,7 @@ public static <T extends ITravelTarget> void addTravelEntry(TravelEntry<?> trave
}

public static <T extends ITravelTarget> TravelRenderer<T> getRenderer(T entry) {
return (TravelRenderer<T>) registry.get(entry.getSerializationName()).renderer().get();
return (TravelRenderer<T>) registry.get(entry.getSerializationName()).renderer().get().get();
}

public static Optional<ITravelTarget> deserialize(CompoundTag nbt) {
Expand Down
2 changes: 1 addition & 1 deletion src/machines/java/com/enderio/machines/EIOMachines.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void onConstruct(FMLConstructModEvent event) {
MinecraftForge.EVENT_BUS.addListener(EIOMachines::missingMappings);

IntegrationManager.addIntegration(EnderIOMachinesSelfIntegration.INSTANCE);
TravelRegistry.addTravelEntry(EnderIO.loc("travel_anchor"), AnchorTravelTarget::new, TravelAnchorRenderer::new);
TravelRegistry.addTravelEntry(EnderIO.loc("travel_anchor"), AnchorTravelTarget::new, () -> TravelAnchorRenderer::new);
}

@SubscribeEvent
Expand Down