-
Notifications
You must be signed in to change notification settings - Fork 27
/
Spelunkery.java
68 lines (56 loc) · 2.33 KB
/
Spelunkery.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package com.ordana.spelunkery;
import com.ordana.spelunkery.configs.ClientConfigs;
import com.ordana.spelunkery.configs.CommonConfigs;
import com.ordana.spelunkery.loot_modifiers.ModLootOverrides;
import com.ordana.spelunkery.reg.*;
import net.mehvahdjukaar.moonlight.api.events.IDropItemOnDeathEvent;
import net.mehvahdjukaar.moonlight.api.events.MoonlightEventsHelper;
import net.mehvahdjukaar.moonlight.api.platform.PlatformHelper;
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Spelunkery {
public static final String MOD_ID = "spelunkery";
public static final Logger LOGGER = LogManager.getLogger();
private static boolean initiated = false;
public static ResourceLocation res(String name) {
return new ResourceLocation(MOD_ID, name);
}
public static void commonInit() {
if (initiated) {
return;
}
initiated = true;
CommonConfigs.init();
if(PlatformHelper.getEnv().isClient()){
ClientConfigs.init();
}
ModGameEvents.init();
ModLootOverrides.INSTANCE.register();
ModFeatures.init();
ModBlocks.init();
ModFluids.init();
ModItems.init();
ModEntities.init();
ModRecipes.init();
MoonlightEventsHelper.addListener(Spelunkery::compassLogic, IDropItemOnDeathEvent.class);
}
private static void compassLogic(IDropItemOnDeathEvent event) {
if (event.getItemStack().is(Items.DRAGON_EGG)) {
if (event.getPlayer() instanceof ServerPlayer serverPlayer && serverPlayer.getBlockY() < -64) {
ItemStack itemStack = event.getItemStack();
itemStack.shrink(1);
event.setReturnItemStack(new ItemStack(ModItems.EGGPLANT.get()));
event.setCanceled(true);
}
}
if (event.getItemStack().is(ModTags.KEEP_ON_DEATH)) {
if (event.getPlayer() instanceof ServerPlayer serverPlayer) CriteriaTriggers.USING_ITEM.trigger(serverPlayer, event.getItemStack());
event.setCanceled(true);
}
}
}