|
10 | 10 | import it.unimi.dsi.fastutil.objects.*; |
11 | 11 | import net.mine_diver.unsafeevents.EventBus; |
12 | 12 | import net.mine_diver.unsafeevents.MutableEventBus; |
13 | | -import net.modificationstation.stationapi.api.event.registry.RegistryEntryAddedEvent; |
14 | | -import net.modificationstation.stationapi.api.event.registry.RegistryEntryRemovedEvent; |
15 | | -import net.modificationstation.stationapi.api.event.registry.RegistryIdRemapEvent; |
| 13 | +import net.modificationstation.stationapi.api.event.registry.*; |
16 | 14 | import net.modificationstation.stationapi.api.registry.RegistryEntry.Reference; |
17 | 15 | import net.modificationstation.stationapi.api.registry.RegistryEntryList.Named; |
18 | 16 | import net.modificationstation.stationapi.api.registry.RegistryWrapper.Impl; |
|
30 | 28 |
|
31 | 29 | import static java.util.Objects.requireNonNullElseGet; |
32 | 30 | import static net.modificationstation.stationapi.api.StationAPI.LOGGER; |
| 31 | +import static net.modificationstation.stationapi.api.util.Namespace.MINECRAFT; |
33 | 32 |
|
34 | 33 | public class SimpleRegistry<T> implements MutableRegistry<T>, RemappableRegistry, ListenableRegistry { |
35 | 34 | final RegistryKey<? extends Registry<T>> key; |
@@ -132,6 +131,17 @@ public Reference<T> set(int rawId, RegistryKey<T> registryKey, T value, Lifecycl |
132 | 131 | return set(rawId, registryKey, value, lifecycle, true); |
133 | 132 | } |
134 | 133 |
|
| 134 | + private void onChange(RegistryKey<T> registryKey) { |
| 135 | + if (MINECRAFT == registryKey.getValue().getNamespace()) return; |
| 136 | + |
| 137 | + RegistryAttributeHolder holder = RegistryAttributeHolder.get(getKey()); |
| 138 | + |
| 139 | + if (holder.hasAttribute(RegistryAttribute.MODDED)) return; |
| 140 | + |
| 141 | + RegistryAttributeHolder.get(getKey()).addAttribute(RegistryAttribute.MODDED); |
| 142 | + LOGGER.debug("Registry {} has been marked as modded, registry entry {} was changed", getKey().getValue(), registryKey.getValue()); |
| 143 | + } |
| 144 | + |
135 | 145 | private Reference<T> set(int rawId, RegistryKey<T> registryKey, T value, Lifecycle lifecycle, boolean checkReservation) { |
136 | 146 | this.assertNotFrozen(registryKey); |
137 | 147 | Validate.notNull(registryKey); |
@@ -204,6 +214,7 @@ private Reference<T> set(int rawId, RegistryKey<T> registryKey, T value, Lifecyc |
204 | 214 | .object(value) |
205 | 215 | .build()); |
206 | 216 |
|
| 217 | + onChange(registryKey); |
207 | 218 | return reference; |
208 | 219 | } |
209 | 220 |
|
|
0 commit comments