Skip to content

Commit

Permalink
Forge 41.1.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
SwanX1 committed Jul 31, 2022
1 parent 7b8a905 commit d965296
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VERSION=2.5.1
MINECRAFT_VERSION=1.19
FORGE_VERSION=41.0.64
FORGE_VERSION=41.1.0
MAPPINGS_CHANNEL=official
MAPPINGS_VERSION=1.19

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.ConfigGuiHandler;
import net.minecraftforge.client.ConfigScreenHandler;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
import net.minecraftforge.event.entity.living.LivingEvent.LivingTickEvent;
import net.minecraftforge.fml.ModLoadingContext;
import org.infernalstudios.infernalexp.InfernalExpansion;
import org.infernalstudios.infernalexp.config.gui.screens.ConfigScreen;
Expand All @@ -41,10 +41,10 @@ public class InfernalExpansionClient {

public static void init(Consumer<Runnable> enqueueWorkConsumer) {
// Register GUI Factories
ModLoadingContext.get().registerExtensionPoint(ConfigGuiHandler.ConfigGuiFactory.class, () -> new ConfigGuiHandler.ConfigGuiFactory((mc, screen) -> new ConfigScreen()));
ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory.class, () -> new ConfigScreenHandler.ConfigScreenFactory((mc, screen) -> new ConfigScreen()));

MinecraftForge.EVENT_BUS.register(new ClientEvents());
MinecraftForge.EVENT_BUS.addListener((LivingUpdateEvent event) -> DynamicLightingHandler.tick(event.getEntityLiving()));
MinecraftForge.EVENT_BUS.addListener((LivingTickEvent event) -> DynamicLightingHandler.tick(event.getEntity()));

enqueueWorkConsumer.accept(InfernalExpansionClient::threadSafeInit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public void loadResources() {
for (String entity : configs.keySet()) {
String resourceLocation = InfernalExpansion.MOD_ID + ":" + entity;

if (!ForgeRegistries.ENTITIES.containsKey(new ResourceLocation(resourceLocation)) || !InfernalExpansionConfig.MobSpawning.contains(entity)) {
if (!ForgeRegistries.ENTITY_TYPES.containsKey(new ResourceLocation(resourceLocation)) || !InfernalExpansionConfig.MobSpawning.contains(entity)) {
throw new ResourceLocationException(entity.split(":")[1] + " does not exist in the registry or is not a naturally spawning mob from Infernal Expansion");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.infernalstudios.infernalexp.events;

import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
import net.minecraftforge.event.level.BlockEvent;
import net.minecraftforge.fml.event.config.ModConfigEvent;
import org.infernalstudios.infernalexp.InfernalExpansion;
import org.infernalstudios.infernalexp.blocks.DullthornsBlock;
Expand Down Expand Up @@ -69,14 +70,13 @@
import net.minecraftforge.event.AddReloadListenerEvent;
import net.minecraftforge.event.AnvilUpdateEvent;
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.event.entity.living.LivingAttackEvent;
import net.minecraftforge.event.entity.living.LivingEntityUseItemEvent;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.event.entity.living.PotionColorCalculationEvent;
import net.minecraftforge.event.entity.player.BonemealEvent;
import net.minecraftforge.event.entity.player.PlayerInteractEvent;
import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.eventbus.api.Event;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
Expand Down Expand Up @@ -174,7 +174,7 @@ public void onRightClickBlock(PostRightClickBlockEvent event) {
Level world = event.getWorld();
BlockPos pos = event.getPos();
Direction face = event.getDirection();
Player player = event.getPlayer();
Player player = event.getEntity();
if (heldItemStack.getItem() == Items.BONE) {
pos = pos.relative(face);
BlockState blockstate = IEBlocks.BURIED_BONE.get().getPlaceableState(world, pos, face);
Expand Down Expand Up @@ -242,8 +242,8 @@ public void onRightClickBlock(PostRightClickBlockEvent event) {

@SubscribeEvent
public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
Level world = event.getWorld();
Player player = event.getPlayer();
Level world = event.getLevel();
Player player = event.getEntity();
ItemStack heldItemStack = player.getItemInHand(event.getHand());

if (heldItemStack.getItem() == Items.MAGMA_CREAM) {
Expand Down Expand Up @@ -318,7 +318,7 @@ public void onRightClickItem(PlayerInteractEvent.RightClickItem event) {
@SubscribeEvent
public void onApplyBonemeal(BonemealEvent event) {
Block block = event.getBlock().getBlock();
Level world = event.getWorld();
Level world = event.getLevel();
BlockPos pos = event.getPos();
if (block == Blocks.SHROOMLIGHT && Miscellaneous.SHROOMLIGHT_GROWABLE.getBool()) {
pos = pos.below();
Expand Down Expand Up @@ -353,8 +353,8 @@ public void onPotionColorCalculate(PotionColorCalculationEvent event) {
}

@SubscribeEvent
public void onLivingEntityUpdate(LivingEvent.LivingUpdateEvent event) {
LivingEntity entity = event.getEntityLiving();
public void onLivingEntityUpdate(LivingEvent.LivingTickEvent event) {
LivingEntity entity = event.getEntity();

// Make sure we are checking potion effects on the server, not client
if (entity.isEffectiveAi() && entity.getCommandSenderWorld() instanceof ServerLevel world) {
Expand Down Expand Up @@ -389,7 +389,7 @@ public void onLivingFinishUse(LivingEntityUseItemEvent.Finish event) {
}

@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event) {
public void onEntityJoin(EntityJoinLevelEvent event) {
if (event.getEntity() instanceof AreaEffectCloud entity) {
for (MobEffectInstance effect : entity.potion.getEffects()) {
if (effect.getEffect() == IEEffects.INFECTION.get()) {
Expand All @@ -403,7 +403,7 @@ public void onEntityJoin(EntityJoinWorldEvent event) {

@SubscribeEvent
public void onLivingEntityAttack(LivingAttackEvent event) {
LivingEntity entity = event.getEntityLiving();
LivingEntity entity = event.getEntity();

// If entity has infection, on hit, make a splash of particles
if (entity.isEffectiveAi() && entity.getCommandSenderWorld() instanceof ServerLevel world) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import net.minecraft.world.entity.monster.hoglin.Hoglin;
import net.minecraft.world.entity.monster.piglin.Piglin;
import net.minecraft.world.entity.monster.piglin.PiglinBrute;
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
import net.minecraftforge.event.entity.EntityJoinLevelEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.infernalstudios.infernalexp.InfernalExpansion;
Expand All @@ -43,7 +43,7 @@
public class MobEvents {

@SubscribeEvent
public void onEntityJoin(EntityJoinWorldEvent event) {
public void onEntityJoin(EntityJoinLevelEvent event) {

//
//RUN AWAY!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ public Direction getDirection() {
}

public ItemStack getItemStack() {
return getPlayer().getItemInHand(getHand());
return getEntity().getItemInHand(getHand());
}

public Level getWorld() {
return getPlayer().getCommandSenderWorld();
return getEntity().getCommandSenderWorld();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class IEBlockEntityTypes {

public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, InfernalExpansion.MOD_ID);
public static final DeferredRegister<BlockEntityType<?>> BLOCK_ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, InfernalExpansion.MOD_ID);

public static final RegistryObject<BlockEntityType<GlowCampfireBlockEntity>> GLOW_CAMPFIRE = BLOCK_ENTITY_TYPES.register("glow_campfire", () -> BlockEntityType.Builder.of(GlowCampfireBlockEntity::new, IEBlocks.GLOW_CAMPFIRE.get()).build(null));
public static final RegistryObject<BlockEntityType<LuminousFungusBlockEntity>> LUMINOUS_FUNGUS = BLOCK_ENTITY_TYPES.register("luminous_fungus", () -> BlockEntityType.Builder.of(LuminousFungusBlockEntity::new, IEBlocks.LUMINOUS_FUNGUS.get()).build(null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

public class IEEntityTypes {

public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITIES, InfernalExpansion.MOD_ID);
public static final DeferredRegister<EntityType<?>> ENTITY_TYPES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, InfernalExpansion.MOD_ID);

// Entity Types

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,33 @@

package org.infernalstudios.infernalexp.init;

import com.google.gson.JsonObject;
import org.infernalstudios.infernalexp.InfernalExpansion;
import org.infernalstudios.infernalexp.config.InfernalExpansionConfig;
import org.jetbrains.annotations.NotNull;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;

import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.predicates.LootItemCondition;
import net.minecraftforge.common.loot.GlobalLootModifierSerializer;
import net.minecraftforge.common.loot.IGlobalLootModifier;
import net.minecraftforge.common.loot.LootModifier;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.infernalstudios.infernalexp.InfernalExpansion;
import org.infernalstudios.infernalexp.config.InfernalExpansionConfig;
import org.jetbrains.annotations.NotNull;

public class IELootModifiers {

public static final DeferredRegister<GlobalLootModifierSerializer<?>> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.LOOT_MODIFIER_SERIALIZERS, InfernalExpansion.MOD_ID);
public static final DeferredRegister<Codec<? extends IGlobalLootModifier>> LOOT_MODIFIERS = DeferredRegister.create(ForgeRegistries.Keys.GLOBAL_LOOT_MODIFIER_SERIALIZERS, InfernalExpansion.MOD_ID);

public static final RegistryObject<GlobalLootModifierSerializer<HoglinLootModifier>> HOGLIN_LOOT_MODIFIER = LOOT_MODIFIERS.register("hoglin_loot_modifier", HoglinLootSerializer::new);
public static final RegistryObject<Codec<HoglinLootModifier>> HOGLIN_LOOT_MODIFIER = LOOT_MODIFIERS.register("hoglin_loot_modifier", () -> HoglinLootModifier.CODEC);

private static class HoglinLootModifier extends LootModifier {
public static final Codec<HoglinLootModifier> CODEC = RecordCodecBuilder.create(inst -> codecStart(inst).apply(inst, HoglinLootModifier::new));

/**
* Constructs a LootModifier.
Expand Down Expand Up @@ -78,23 +81,15 @@ protected HoglinLootModifier(LootItemCondition[] conditionsIn) {

return generatedLoot;
}

@Override
public Codec<? extends IGlobalLootModifier> codec() {
return CODEC;
}
}

public static void register(IEventBus eventBus) {
LOOT_MODIFIERS.register(eventBus);
InfernalExpansion.LOGGER.info("Infernal Expansion: Loot Modifiers Registered!");
}

private static class HoglinLootSerializer extends GlobalLootModifierSerializer<HoglinLootModifier> {

@Override
public HoglinLootModifier read(ResourceLocation location, JsonObject object, LootItemCondition[] conditionsIn) {
return new HoglinLootModifier(conditionsIn);
}

@Override
public JsonObject write(HoglinLootModifier instance) {
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private void addSpawns(ModifiableBiomeInfo.BiomeInfo.Builder builder, String bio
if (!spawnableBiomes.contains(biomeLocation)) return;

// Get the entity type from the name
EntityType<?> entityType = ForgeRegistries.ENTITIES.getValue(new ResourceLocation(entity));
EntityType<?> entityType = ForgeRegistries.ENTITY_TYPES.getValue(new ResourceLocation(entity));

// Check if the entity type exists
if (entityType == null) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
modLoader = "javafml" #mandatory

# A version range to match for said mod loader - for regular FML @Mod it will be the forge version
loaderVersion = "[41.0.64,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.
loaderVersion = "[41,)" #mandatory This is typically bumped every Minecraft version by Forge. See our download page for lists of versions.

license = "Apache-2.0"

Expand Down Expand Up @@ -73,7 +73,7 @@ Special Thanks:
[[dependencies.infernalexp]]
modId = "forge"
mandatory = true
versionRange = "[41.0.64,)"
versionRange = "[41.1.0,)"
ordering = "NONE"
side = "BOTH"
[[dependencies.infernalexp]]
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/infernal-expansion.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"common.WorldGenRegionAccessor",
"dev.MixinDataFixers",
"dev.MixinMinecraftServer",
"dev.MixinPrimaryLevelData",
"dev.MixinPrimaryLevelData"
],
"client": [
"client.MixinBlockGetter",
Expand Down

0 comments on commit d965296

Please sign in to comment.