Skip to content

Commit

Permalink
deprecate addConvertible api methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed May 9, 2023
1 parent b3190d5 commit 74bca23
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ public interface IVampirismEntityRegistry {
* Requires a blood value to be registered for that creature
*
* @param overlay_loc Location of the overlay texture file
* @deprecated use data driven system
*/
@Deprecated
@ThreadSafeAPI
void addConvertible(EntityType<? extends PathfinderMob> type, ResourceLocation overlay_loc);

Expand All @@ -32,7 +34,10 @@ public interface IVampirismEntityRegistry {
*
* @param helper Helper instance for the DefaultHandler to specify some values for the converted creature
* @param overlay_loc Location of the overlay texture file
*
* @deprecated use data driven system
*/
@Deprecated
@ThreadSafeAPI
void addConvertible(EntityType<? extends PathfinderMob> type, ResourceLocation overlay_loc, IConvertingHandler.IDefaultHelper helper);

Expand All @@ -42,7 +47,9 @@ public interface IVampirismEntityRegistry {
*
* @param overlay_loc Location of the overlay texture file. Only required if Vampirism's default Converted Creature renderer is used, if you handle that stuff yourself, null is just fine.
* @param handler Handles the conversion
* @deprecated use data driven system
*/
@Deprecated
@ThreadSafeAPI
void addConvertible(EntityType<? extends PathfinderMob> type, ResourceLocation overlay_loc, IConvertingHandler<?> handler);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
Expand All @@ -51,9 +52,14 @@ public class VampirismEntityRegistry implements IVampirismEntityRegistry {
* Used to store convertible handlers after {@link FMLCommonSetupEvent}
*/
@NotNull
private final Map<EntityType<? extends PathfinderMob>, IConvertingHandler<?>> convertibles = new ConcurrentHashMap<>();
private final Map<EntityType<? extends PathfinderMob>, IConvertingHandler<?>> convertibles = new HashMap<>();
@NotNull
private final Map<EntityType<? extends PathfinderMob>, ResourceLocation> convertibleOverlay = new ConcurrentHashMap<>();
private final Map<EntityType<? extends PathfinderMob>, ResourceLocation> convertibleOverlay = new HashMap<>();

@NotNull
private final Map<EntityType<? extends PathfinderMob>, IConvertingHandler<?>> convertiblesAPI = new ConcurrentHashMap<>();
@NotNull
private final Map<EntityType<? extends PathfinderMob>, ResourceLocation> convertibleOverlayAPI = new ConcurrentHashMap<>();
/**
* Stores custom extended creature constructors after {@link InterModEnqueueEvent}
*/
Expand Down Expand Up @@ -85,10 +91,10 @@ public void addConvertible(EntityType<? extends PathfinderMob> type, ResourceLoc
@ThreadSafeAPI
public void addConvertible(EntityType<? extends PathfinderMob> type, @Nullable ResourceLocation overlay_loc, @NotNull IConvertingHandler<?> handler) {
if (finished) throw new IllegalStateException("Register convertibles during InterModEnqueueEvent");
convertibles.put(type, handler);
convertiblesAPI.put(type, handler);

if (FMLEnvironment.dist.isClient() && overlay_loc != null) {
convertibleOverlay.put(type, overlay_loc);
convertibleOverlayAPI.put(type, overlay_loc);
}
}

Expand Down Expand Up @@ -183,6 +189,8 @@ public void applyDataConvertibleOverlays(Map<EntityType<? extends PathfinderMob>
public void applyDataConvertibles(Map<EntityType<? extends PathfinderMob>, ConvertiblesReloadListener.EntityEntry> entries) {
this.convertibles.clear();
this.convertibleOverlay.clear();
this.convertibles.putAll(this.convertiblesAPI);
this.convertibleOverlay.putAll(this.convertibleOverlayAPI);
entries.forEach((type, entry) -> {
Optional<IConvertingHandler<?>> handler = entry.converter().map(Converter::createHandler);
this.convertibles.put(type, handler.orElseGet(() -> new DefaultConverter().createHandler()));
Expand Down

0 comments on commit 74bca23

Please sign in to comment.