Skip to content

Commit

Permalink
Finish up culling
Browse files Browse the repository at this point in the history
  • Loading branch information
Vazkii committed Dec 1, 2021
1 parent 34cfb8c commit 8edf357
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package vazkii.quark.base.handler;

import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.ai.attributes.AttributeModifierMap.MutableAttribute;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import vazkii.quark.base.Quark;

@EventBusSubscriber(modid = Quark.MOD_ID, bus = Bus.MOD)
public final class EntityAttributeHandler {

private static Map<EntityType<? extends LivingEntity>, Supplier<MutableAttribute>> attributeSuppliers = new HashMap<>();

public static void put(EntityType<? extends LivingEntity> type, Supplier<MutableAttribute> attrSupplier) {
attributeSuppliers.put(type, attrSupplier);
}

@SubscribeEvent
public static void onAttributeCreation(EntityAttributeCreationEvent event) {
for(EntityType<? extends LivingEntity> type : attributeSuppliers.keySet()) {
Supplier<MutableAttribute> supplier = attributeSuppliers.get(type);
event.put(type, supplier.get().create());
}
}

}
1 change: 0 additions & 1 deletion src/main/java/vazkii/quark/base/handler/QuarkSounds.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import com.google.common.collect.Lists;

import net.minecraft.block.SoundType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundEvent;
import net.minecraftforge.registries.GameData;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.entity.passive.WolfEntity;
import net.minecraft.world.gen.Heightmap.Type;
Expand All @@ -12,6 +11,7 @@
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -41,13 +41,11 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, shibaType, EntityClassification.CREATURE, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::canAnimalSpawn, spawnConfig);
EntitySpawnHandler.addEgg(shibaType, 0xa86741, 0xe8d5b6, spawnConfig);

EntityAttributeHandler.put(shibaType, WolfEntity::func_234233_eS_);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(shibaType, WolfEntity.func_234233_eS_().create());
}


@Override
@OnlyIn(Dist.CLIENT)
public void clientSetup() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.ai.attributes.Attributes;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
Expand All @@ -24,6 +23,7 @@
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.Quark;
import vazkii.quark.base.handler.BrewingHandler;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.item.QuarkItem;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
Expand Down Expand Up @@ -90,12 +90,12 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, crabType, EntityClassification.CREATURE, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, CrabEntity::spawnPredicate, spawnConfig);
EntitySpawnHandler.addEgg(crabType, 0x893c22, 0x916548, spawnConfig);

EntityAttributeHandler.put(crabType, CrabEntity::prepareAttributes);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(crabType, CrabEntity.prepareAttributes().create());

crabSpawnableTag = BlockTags.createOptional(new ResourceLocation(Quark.MOD_ID, "crab_spawnable"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MobEntity;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.item.Item;
import net.minecraft.util.math.vector.Vector3d;
import net.minecraftforge.api.distmarker.Dist;
Expand All @@ -15,6 +14,7 @@
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -48,13 +48,8 @@ public void construct() {

RegistryHelper.register(forgottenType, "forgotten");
EntitySpawnHandler.addEgg(forgottenType, 0x969487, 0x3a3330, this, () -> true);
}

@Override
public void setup() {
super.setup();

GlobalEntityTypeAttributes.put(forgottenType, ForgottenEntity.registerAttributes().create());

EntityAttributeHandler.put(forgottenType, ForgottenEntity::registerAttributes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.passive.IronGolemEntity;
import net.minecraft.entity.passive.WolfEntity;
import net.minecraft.tags.BlockTags;
Expand All @@ -18,6 +17,7 @@
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.Quark;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -63,12 +63,12 @@ public void construct() {
EntitySpawnHandler.track(this, foxhoundType, EntityClassification.MONSTER, lesserSpawnConfig, true);

EntitySpawnHandler.addEgg(foxhoundType, 0x890d0d, 0xf2af4b, spawnConfig);

EntityAttributeHandler.put(foxhoundType, WolfEntity::func_234233_eS_);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(foxhoundType, WolfEntity.func_234233_eS_().create());

public void setup() {
foxhoundSpawnableTag = BlockTags.createOptional(new ResourceLocation(Quark.MOD_ID, "foxhound_spawnable"));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.passive.AnimalEntity;
import net.minecraft.item.Food;
import net.minecraft.item.Item;
Expand All @@ -15,6 +14,7 @@
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.handler.BrewingHandler;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.item.QuarkItem;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
Expand Down Expand Up @@ -80,11 +80,8 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, frogType, EntityClassification.CREATURE, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, AnimalEntity::canAnimalSpawn, spawnConfig);
EntitySpawnHandler.addEgg(frogType, 0xbc9869, 0xffe6ad, spawnConfig);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(frogType, FrogEntity.prepareAttributes().create());

EntityAttributeHandler.put(frogType, FrogEntity::prepareAttributes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.world.gen.Heightmap.Type;
Expand All @@ -12,6 +11,7 @@
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -57,11 +57,8 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, stonelingType, EntityClassification.MONSTER, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, StonelingEntity::spawnPredicate, spawnConfig);
EntitySpawnHandler.addEgg(stonelingType, 0xA1A1A1, 0x505050, spawnConfig);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(stonelingType, StonelingEntity.prepareAttributes().create());

EntityAttributeHandler.put(stonelingType, StonelingEntity::prepareAttributes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.world.gen.Heightmap.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -61,11 +61,8 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, toretoiseType, EntityClassification.MONSTER, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, ToretoiseEntity::spawnPredicate, spawnConfig);
EntitySpawnHandler.addEgg(toretoiseType, 0x55413b, 0x383237, spawnConfig);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(toretoiseType, ToretoiseEntity.prepareAttributes().create());

EntityAttributeHandler.put(toretoiseType, ToretoiseEntity::prepareAttributes);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntitySpawnPlacementRegistry.PlacementType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ai.attributes.GlobalEntityTypeAttributes;
import net.minecraft.entity.monster.MonsterEntity;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
Expand All @@ -20,6 +19,7 @@
import net.minecraftforge.fml.client.registry.RenderingRegistry;
import vazkii.arl.util.RegistryHelper;
import vazkii.quark.base.Quark;
import vazkii.quark.base.handler.EntityAttributeHandler;
import vazkii.quark.base.module.LoadModule;
import vazkii.quark.base.module.ModuleCategory;
import vazkii.quark.base.module.QuarkModule;
Expand Down Expand Up @@ -94,12 +94,12 @@ public void construct() {

EntitySpawnHandler.registerSpawn(this, wraithType, EntityClassification.MONSTER, PlacementType.ON_GROUND, Type.MOTION_BLOCKING_NO_LEAVES, MonsterEntity::canMonsterSpawnInLight, spawnConfig);
EntitySpawnHandler.addEgg(wraithType, 0xececec, 0xbdbdbd, spawnConfig);

EntityAttributeHandler.put(wraithType, WraithEntity::registerAttributes);
}

@Override
public void setup() {
GlobalEntityTypeAttributes.put(wraithType, WraithEntity.registerAttributes().create());

wraithSpawnableTag = BlockTags.createOptional(new ResourceLocation(Quark.MOD_ID, "wraith_spawnable"));
}

Expand Down

0 comments on commit 8edf357

Please sign in to comment.