mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
Add MobEffect tags (#8231)
This commit is contained in:
1 parent
950e7b032a
commit
e2a205d2e7
5 files changed
+49
-2
No files matched your search
@@ -17,12 +17,22 @@
|
||||
}
|
||||
|
||||
public void m_6742_(LivingEntity p_19467_, int p_19468_) {
|
||||
@@ -179,4 +_,29 @@
|
||||
@@ -179,4 +_,39 @@
|
||||
public boolean m_19486_() {
|
||||
return this.f_19447_ == MobEffectCategory.BENEFICIAL;
|
||||
}
|
||||
+
|
||||
+ // FORGE START
|
||||
+ private final net.minecraftforge.common.util.ReverseTagWrapper<MobEffect> reverseTags = new net.minecraftforge.common.util.ReverseTagWrapper<>(this, () -> net.minecraft.tags.SerializationTags.m_13199_().m_144452_(Registry.f_122900_));
|
||||
+
|
||||
+ public java.util.Set<net.minecraft.resources.ResourceLocation> getTags() {
|
||||
+ return reverseTags.getTagNames();
|
||||
+ }
|
||||
+
|
||||
+ public boolean is(net.minecraft.tags.Tag<MobEffect> tag) {
|
||||
+ return tag.m_8110_(this);
|
||||
+ }
|
||||
+
|
||||
+ private Object effectRenderer;
|
||||
+
|
||||
+ /*
|
||||
|
||||
@@ -87,6 +87,7 @@ cf16f861eaf5815238c2278eb48bde0688cb73b7 assets/scaffolding_test/blockstates/sca
|
||||
8b6073e66bdfecc75229939f550c32460f9b3d81 data/custom_tag_types_test/tags/block_entity_types/storage.json
|
||||
862196702dcd5538c5ceb4ac6202e57eb5c8a97f data/custom_tag_types_test/tags/custom_tag_types_test/custom_types/tests.json
|
||||
8c1969250406edfbd470cc06aca4dcccfd6ce682 data/custom_tag_types_test/tags/enchantments/fire.json
|
||||
acd80cfdb22681f810e41f38776a4ff7ef703799 data/custom_tag_types_test/tags/mob_effects/beacon.json
|
||||
44985f1cb0df54b632187ed97a6a443455f1e51c data/custom_tag_types_test/tags/potions/damage.json
|
||||
806659ba3e9c12797df0fe7211a222795834fdfd data/data_gen_test/advancements/conditional.json
|
||||
0001aa55877ddee50e3180db7337e926797d7e4d data/data_gen_test/advancements/obtain_dirt.json
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:speed",
|
||||
"minecraft:jump_boost",
|
||||
"minecraft:haste",
|
||||
"minecraft:regeneration",
|
||||
"minecraft:resistance",
|
||||
"minecraft:strength"
|
||||
]
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class GameData
|
||||
makeRegistry(BLOCKS, Block.class, "air").addCallback(BlockCallbacks.INSTANCE).legacyName("blocks").create();
|
||||
makeRegistry(FLUIDS, Fluid.class, "empty").create();
|
||||
makeRegistry(ITEMS, Item.class, "air").addCallback(ItemCallbacks.INSTANCE).legacyName("items").create();
|
||||
makeRegistry(MOB_EFFECTS, MobEffect.class).legacyName("potions").create();
|
||||
makeRegistry(MOB_EFFECTS, MobEffect.class).legacyName("potions").tagFolder("mob_effects").create();
|
||||
//makeRegistry(BIOMES, Biome.class).legacyName("biomes").create();
|
||||
makeRegistry(SOUND_EVENTS, SoundEvent.class).legacyName("soundevents").create();
|
||||
makeRegistry(POTIONS, Potion.class, "empty").legacyName("potiontypes").tagFolder("potions").create();
|
||||
|
||||
@@ -25,6 +25,8 @@ import javax.annotation.Nullable;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
import net.minecraft.resources.ResourceKey;
|
||||
import net.minecraft.world.effect.MobEffect;
|
||||
import net.minecraft.world.effect.MobEffects;
|
||||
import net.minecraft.world.item.enchantment.Enchantment;
|
||||
import net.minecraft.world.item.enchantment.EnchantmentHelper;
|
||||
import net.minecraft.world.item.enchantment.Enchantments;
|
||||
@@ -76,6 +78,7 @@ public class CustomTagTypesTest
|
||||
private static final Tag.Named<Enchantment> FIRE = ForgeTagHandler.createOptionalTag(ForgeRegistries.ENCHANTMENTS, new ResourceLocation(MODID, "fire"));
|
||||
private static final Tag.Named<Potion> DAMAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.POTIONS, new ResourceLocation(MODID, "damage"));
|
||||
private static final Tag.Named<BlockEntityType<?>> STORAGE = ForgeTagHandler.createOptionalTag(ForgeRegistries.BLOCK_ENTITIES, new ResourceLocation(MODID, "storage"));
|
||||
private static final Tag.Named<MobEffect> BEACON = ForgeTagHandler.createOptionalTag(ForgeRegistries.MOB_EFFECTS, new ResourceLocation(MODID, "beacon"));
|
||||
|
||||
public CustomTagTypesTest()
|
||||
{
|
||||
@@ -95,6 +98,7 @@ public class CustomTagTypesTest
|
||||
gen.addProvider(new EnchantmentTags(gen, existingFileHelper));
|
||||
gen.addProvider(new PotionTags(gen, existingFileHelper));
|
||||
gen.addProvider(new BlockEntityTypeTags(gen, existingFileHelper));
|
||||
gen.addProvider(new MobEffectTypeTags(gen, existingFileHelper));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,6 +113,7 @@ public class CustomTagTypesTest
|
||||
if (itemStack.getItem() instanceof PotionItem) logTagsIfPresent(PotionUtils.getPotion(itemStack).getTags());
|
||||
BlockEntity blockEntity = event.getWorld().getBlockEntity(event.getPos());
|
||||
if (blockEntity != null) logTagsIfPresent(blockEntity.getType().getTags());
|
||||
event.getEntityLiving().getActiveEffects().forEach((mobEffectInstance) -> logTagsIfPresent(mobEffectInstance.getEffect().getTags()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,4 +214,24 @@ public class CustomTagTypesTest
|
||||
return "Block Entity Type Tags";
|
||||
}
|
||||
}
|
||||
|
||||
public static class MobEffectTypeTags extends ForgeRegistryTagsProvider<MobEffect>
|
||||
{
|
||||
public MobEffectTypeTags(DataGenerator gen, @Nullable ExistingFileHelper existingFileHelper)
|
||||
{
|
||||
super(gen, ForgeRegistries.MOB_EFFECTS, MODID, existingFileHelper);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addTags()
|
||||
{
|
||||
tag(BEACON).add(MobEffects.MOVEMENT_SPEED, MobEffects.JUMP, MobEffects.DIG_SPEED, MobEffects.REGENERATION, MobEffects.DAMAGE_RESISTANCE, MobEffects.DAMAGE_BOOST);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return "Mob Effect Tags";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user