Skip to content

Commit

Permalink
update neoforge
Browse files Browse the repository at this point in the history
  • Loading branch information
Cheaterpaul committed Jun 23, 2024
1 parent b7b1565 commit 76f69b5
Show file tree
Hide file tree
Showing 23 changed files with 128 additions and 69 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ org.gradle.debug=false
# forge
minecraft_version=1.21
minecraft_version_range=[1.21,1.22)
forge_version=21.0.8-beta
forge_version_range=[21.0.8-beta,)
forge_version=21.0.25-beta
forge_version_range=[21.0.25-beta,)
loader_version_range=[1,)
parchment_minecraft_version=1.20.6
parchment_mappings_version=2024.05.01
Expand Down
16 changes: 16 additions & 0 deletions src/api/java/de/teamlapen/vampirism/api/VEnums.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package de.teamlapen.vampirism.api;

import net.minecraft.world.entity.MobCategory;
import net.neoforged.fml.common.asm.enumextension.EnumProxy;

public class VEnums {
/**
* Hunter creatures are of this creature type. But when they are counted for spawning they belong to {@link net.minecraft.world.entity.MobCategory#MONSTER}
*/
public static final EnumProxy<MobCategory> HUNTER_CATEGORY = new EnumProxy<>(MobCategory.class, "vampirism:hunter", 15, false, false, 128);
/**
* Vampire creatures are of this creature type. But when they are counted for spawning they belong to {@link net.minecraft.world.entity.MobCategory#MONSTER}
*/
public static final EnumProxy<MobCategory> VAMPIRE_CATEGORY = new EnumProxy<>(MobCategory.class, "vampirism:vampire", 30, false, false, 128);

}
10 changes: 1 addition & 9 deletions src/api/java/de/teamlapen/vampirism/api/VReference.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import de.teamlapen.vampirism.api.util.VResourceLocation;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.material.Fluid;
import net.neoforged.neoforge.common.PlantType;
import net.neoforged.neoforge.registries.DeferredHolder;
Expand All @@ -32,14 +31,7 @@ public class VReference {
public static final PlantType VAMPIRE_PLANT_TYPE = PlantType.get("vampirism_vampire");

public static final Supplier<Fluid> BLOOD = DeferredHolder.create(Registries.FLUID, VResourceLocation.mod("blood"));
/**
* Hunter creatures are of this creature type. But when they are counted for spawning they belong to {@link MobCategory#MONSTER}
*/
public static MobCategory HUNTER_CREATURE_TYPE = MobCategory.create("vampirism_hunter", "vampirism_hunter", 15, false, false, 128);
/**
* Vampire creatures are of this creature type. But when they are counted for spawning they belong to {@link MobCategory#MONSTER}
*/
public static MobCategory VAMPIRE_CREATURE_TYPE = MobCategory.create("vampirism_vampire", "vampirism_vampire", 30, false, false, 128);

/**
* Vampire Player Faction
* Filled during pre-init.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@
}
],
"underground_water_creature": [],
"vampirism_hunter": [],
"vampirism_vampire": [],
"vampirism:hunter": [],
"vampirism:vampire": [],
"water_ambient": [],
"water_creature": []
},
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/de/teamlapen/vampirism/ModEnums.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package de.teamlapen.vampirism;

import net.minecraft.world.inventory.RecipeBookType;
import net.neoforged.fml.common.asm.enumextension.EnumProxy;

public class ModEnums {
// public static final EnumProxy<RecipeBookType> WEAPON_TABLE_RECIPE_BOOK_TYPE = new EnumProxy<>(RecipeBookType.class);
}
1 change: 0 additions & 1 deletion src/main/java/de/teamlapen/vampirism/VampirismMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,6 @@ private void setup(final @NotNull FMLCommonSetupEvent event) {
event.enqueueWork(ModVillage::villagerTradeSetup);
event.enqueueWork(ModTiles::registerTileExtensionsUnsafe);
event.enqueueWork(ModItems::registerDispenserBehaviourUnsafe);
ModRecipes.Types.init();
TelemetryCollector.execute();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import de.teamlapen.lib.lib.util.SimpleSpawnerLogic;
import de.teamlapen.lib.lib.util.UtilLib;
import de.teamlapen.vampirism.api.VReference;
import de.teamlapen.vampirism.api.VEnums;
import de.teamlapen.vampirism.config.VampirismConfig;
import de.teamlapen.vampirism.core.ModEntities;
import de.teamlapen.vampirism.core.ModTiles;
Expand Down Expand Up @@ -30,8 +30,8 @@ public class TentBlockEntity extends BlockEntity {

public TentBlockEntity(@NotNull BlockPos pos, @NotNull BlockState state) {
super(ModTiles.TENT.get(), pos, state);
this.spawnerLogicHunter = new SimpleSpawnerLogic<>(ModEntities.HUNTER.get()).setActivateRange(64).setSpawnRange(6).setMinSpawnDelay(600).setMaxSpawnDelay(1000).setMaxNearbyEntities(2).setDailyLimit(VampirismConfig.BALANCE.hunterTentMaxSpawn.get()).setLimitTotalEntities(VReference.HUNTER_CREATURE_TYPE).setOnSpawned(hunter -> hunter.makeCampHunter(this.worldPosition));
this.spawnerLogicAdvancedHunter = new SimpleSpawnerLogic<>(ModEntities.ADVANCED_HUNTER.get()).setActivateRange(64).setSpawnRange(6).setMinSpawnDelay(1200).setMaxSpawnDelay(2000).setMaxNearbyEntities(1).setDailyLimit(1).setLimitTotalEntities(VReference.HUNTER_CREATURE_TYPE).setOnSpawned(hunter -> hunter.makeCampHunter(this.worldPosition));
this.spawnerLogicHunter = new SimpleSpawnerLogic<>(ModEntities.HUNTER.get()).setActivateRange(64).setSpawnRange(6).setMinSpawnDelay(600).setMaxSpawnDelay(1000).setMaxNearbyEntities(2).setDailyLimit(VampirismConfig.BALANCE.hunterTentMaxSpawn.get()).setLimitTotalEntities(VEnums.HUNTER_CATEGORY.getValue()).setOnSpawned(hunter -> hunter.makeCampHunter(this.worldPosition));
this.spawnerLogicAdvancedHunter = new SimpleSpawnerLogic<>(ModEntities.ADVANCED_HUNTER.get()).setActivateRange(64).setSpawnRange(6).setMinSpawnDelay(1200).setMaxSpawnDelay(2000).setMaxNearbyEntities(1).setDailyLimit(1).setLimitTotalEntities(VEnums.HUNTER_CATEGORY.getValue()).setOnSpawned(hunter -> hunter.makeCampHunter(this.worldPosition));
}

public boolean isSpawner() {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/de/teamlapen/vampirism/client/ModClientEnums.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package de.teamlapen.vampirism.client;

import de.teamlapen.vampirism.core.ModBlocks;
import net.minecraft.client.RecipeBookCategories;
import net.minecraft.world.item.ItemStack;
import net.neoforged.fml.common.asm.enumextension.EnumProxy;

import java.util.function.Supplier;

public class ModClientEnums {

public static final EnumProxy<RecipeBookCategories> WEAPON_TABLE_RECIPE_BOOK_CATEGORY = new EnumProxy<>(RecipeBookCategories.class, (Supplier<ItemStack>)() -> new ItemStack(ModBlocks.WEAPON_TABLE));

}
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,6 @@ public void setupClient(@NotNull FMLClientSetupEvent event) {
});
}

@SubscribeEvent
public void commonEvent(FMLCommonSetupEvent event) {
ModRecipes.Categories.init();
}

public void onDataMapsUpdated(DataMapsUpdatedEvent event) {
((VampirismClientEntityRegistry)VampirismAPI.entityRegistry()).syncOverlays();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.teamlapen.vampirism.client.renderer.entity.layers.ConvertedVampireEntityLayer;
import de.teamlapen.vampirism.entity.converted.VampirismEntityRegistry;
import de.teamlapen.vampirism.mixin.client.accessor.EntityRenderDispatcherAccessor;
import de.teamlapen.vampirism.mixin.client.accessor.LivingEntityRendererAccessor;
import net.minecraft.client.Minecraft;
import net.minecraft.client.model.EntityModel;
Expand All @@ -20,7 +21,7 @@ public VampirismClientEntityRegistry() {

public <I extends LivingEntity, U extends EntityModel<I>> void syncOverlays() {
for (EntityType<?> type: getConvertibleOverlay().keySet()) {
LivingEntityRenderer<I, U> render = (LivingEntityRenderer<I, U>) Minecraft.getInstance().getEntityRenderDispatcher().renderers.get(type);
LivingEntityRenderer<I, U> render = (LivingEntityRenderer<I, U>) ((EntityRenderDispatcherAccessor)Minecraft.getInstance().getEntityRenderDispatcher()).renderers().get(type);
if (render == null) {
LOGGER.error("Did not find renderer for {}", type);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.mojang.brigadier.builder.ArgumentBuilder;
import de.teamlapen.lib.lib.util.BasicCommand;
import de.teamlapen.vampirism.api.VReference;
import de.teamlapen.vampirism.api.VEnums;
import it.unimi.dsi.fastutil.objects.Object2IntMap;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.commands.Commands;
Expand All @@ -25,7 +25,7 @@ public class InfoEntitiesCommand extends BasicCommand {
private static int infoEntities(@NotNull CommandSourceStack commandSource, @NotNull ServerPlayer asPlayer) {
NaturalSpawner.SpawnState densityManager = asPlayer.serverLevel().getChunkSource().getLastSpawnState();
Object2IntMap<MobCategory> object2intmap = densityManager.getMobCategoryCounts();
commandSource.sendSuccess(() -> Component.literal(String.format("Creature: %d (%d), Monster: %s (%s), Hunter: %s (%s), Vampire: %s (%s)", object2intmap.getOrDefault(MobCategory.CREATURE, 0), MobCategory.CREATURE.getMaxInstancesPerChunk(), object2intmap.getOrDefault(MobCategory.MONSTER, 0), MobCategory.MONSTER.getMaxInstancesPerChunk(), object2intmap.getOrDefault(VReference.HUNTER_CREATURE_TYPE, 0), VReference.HUNTER_CREATURE_TYPE.getMaxInstancesPerChunk(), object2intmap.getOrDefault(VReference.VAMPIRE_CREATURE_TYPE, 0), VReference.VAMPIRE_CREATURE_TYPE.getMaxInstancesPerChunk())), true);
commandSource.sendSuccess(() -> Component.literal(String.format("Creature: %d (%d), Monster: %s (%s), Hunter: %s (%s), Vampire: %s (%s)", object2intmap.getOrDefault(MobCategory.CREATURE, 0), MobCategory.CREATURE.getMaxInstancesPerChunk(), object2intmap.getOrDefault(MobCategory.MONSTER, 0), MobCategory.MONSTER.getMaxInstancesPerChunk(), object2intmap.getOrDefault(VEnums.HUNTER_CATEGORY.getValue(), 0), VEnums.HUNTER_CATEGORY.getValue().getMaxInstancesPerChunk(), object2intmap.getOrDefault(VEnums.VAMPIRE_CATEGORY.getValue(), 0), VEnums.VAMPIRE_CATEGORY.getValue().getMaxInstancesPerChunk())), true);
return 0;
}
}
Loading

0 comments on commit 76f69b5

Please sign in to comment.