Skip to content

Commit

Permalink
fix /reload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuclearfarts authored and Nuclearfarts committed Nov 6, 2020
1 parent c405151 commit 45536ea
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/wovenmc/woven/impl/tags/WovenTagsImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
@ApiStatus.Internal
public class WovenTagsImpl implements WovenTags {
public static final WovenTagsImpl INSTANCE = new WovenTagsImpl();
public static DynamicRegistryManager.Impl registryManager;
public static DynamicRegistryManager registryManager;

private final Map<RegistryKey<? extends Registry<?>>, TagGroup<?>> tagGroupMap = new HashMap<>();

Expand Down Expand Up @@ -76,7 +76,7 @@ public <T> Tag<T> get(RegistryKey<Registry<T>> registryKey, Identifier id) {
@SuppressWarnings({ "rawtypes", "unchecked" })
public List<TagLoaderInfo<?>> prepare(ResourceManager manager) {
tagGroupMap.clear();
Map<? extends RegistryKey<? extends Registry<?>>, ? extends SimpleRegistry<?>> dynRegistries = ((DynamicRegistryManagerImplAccessor) (Object) registryManager)
Map<? extends RegistryKey<? extends Registry<?>>, ? extends SimpleRegistry<?>> dynRegistries = ((DynamicRegistryManagerImplAccessor) registryManager)
.getRegistries();
List<TagLoaderInfo<?>> loaderList = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020 WovenMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package net.wovenmc.woven.mixin.tags;

import java.util.concurrent.CompletableFuture;

import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import net.minecraft.resource.ServerResourceManager;
import net.minecraft.server.MinecraftServer;
import net.wovenmc.woven.impl.tags.WovenTagsImpl;

@Mixin(MinecraftServer.class)
public class MinecraftServerMixin {
@Shadow
@Final
private ServerResourceManager serverResourceManager;

@Inject(at = @At("HEAD"), method = "reloadResources")
private void storeServerDynamicRegManager(CallbackInfoReturnable<CompletableFuture<Void>> cir) {
WovenTagsImpl.registryManager = ((MinecraftServer) (Object) this).getRegistryManager();
}
}
1 change: 1 addition & 0 deletions src/main/resources/woven-tags.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"DynamicRegistryManagerImplAccessor",
"DynamicRegistryManagerMixin",
"FluidTagsAccessor",
"MinecraftServerMixin",
"TagManagerLoaderMixin"
]
}

0 comments on commit 45536ea

Please sign in to comment.