Skip to content
This repository has been archived by the owner on Dec 14, 2021. It is now read-only.

Commit

Permalink
use fabric event to registor UnloadHandler (#172)
Browse files Browse the repository at this point in the history
  • Loading branch information
Milan authored Feb 14, 2021
1 parent e5b8e0f commit 26b4e39
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 59 deletions.
7 changes: 7 additions & 0 deletions src/main/java/reborncore/RebornCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@

import net.fabricmc.api.EnvType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerBlockEntityEvents;
import net.fabricmc.fabric.api.event.world.WorldTickCallback;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import reborncore.api.ToolManager;
import reborncore.api.blockentity.UnloadHandler;
import reborncore.common.RebornCoreCommands;
import reborncore.common.RebornCoreConfig;
import reborncore.common.blocks.BlockWrenchEventHandler;
Expand Down Expand Up @@ -105,6 +107,11 @@ public void onInitialize() {
RebornCoreCommands.setup();

RebornCoreTags.WATER_EXPLOSION_ITEM.toString();

/* register UnloadHandler */
ServerBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> {
if (blockEntity instanceof UnloadHandler) ((UnloadHandler) blockEntity).onUnload();
});

LOGGER.info("Reborn core is done for now, now to let other mods have their turn...");
LOADED = true;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/reborncore/RebornCoreClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@
package reborncore;

import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientBlockEntityEvents;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.event.client.ClientSpriteRegistryCallback;
import net.minecraft.client.texture.SpriteAtlasTexture;
import reborncore.api.blockentity.UnloadHandler;
import reborncore.client.HolidayRenderManager;
import reborncore.client.IconSupplier;
import reborncore.client.ItemStackRenderer;
Expand All @@ -46,5 +48,10 @@ public void onInitializeClient() {
ClientBoundPacketHandlers.init();
HudRenderCallback.EVENT.register(new ItemStackRenderer());
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());

/* register UnloadHandler */
ClientBlockEntityEvents.BLOCK_ENTITY_LOAD.register((blockEntity, world) -> {
if (blockEntity instanceof UnloadHandler) ((UnloadHandler) blockEntity).onUnload();
});
}
}
56 changes: 0 additions & 56 deletions src/main/java/reborncore/mixin/common/MixinWorld.java

This file was deleted.

5 changes: 2 additions & 3 deletions src/main/resources/reborncore.common.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"MixinItemStack",
"MixinLivingEntity",
"MixinPlayerEntity",
"MixinRecipeManager",
"MixinWorld"
"MixinRecipeManager"
],
"injectors": {
"defaultRequire": 1
}
}
}

0 comments on commit 26b4e39

Please sign in to comment.