Skip to content

Commit

Permalink
Update and re-run tests datagen [skip ci] (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
Technici4n authored Jan 17, 2024
1 parent 39661d9 commit 75f2348
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"entity.neotests_custom_spawn_logic.adapted_spawn": "Adapted complex spawn egg",
"entity.neotests_custom_spawn_logic.complex_spawn": "Custom complex spawn egg",
"entity.neotests_custom_spawn_logic.simple_spawn": "Simple spawn egg"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"item.neotests_snow_boots.snow_boots": "Snow Boots"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"death_message_type": "test:msgtype",
"effects": "test:effects",
"exhaustion": 0.0,
"message_id": "test_mod",
"scaling": "test:scaling"
}
7 changes: 0 additions & 7 deletions tests/src/generated/resources/data/test/damage_type/test.json

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@

package net.neoforged.neoforge.debug.damagesource;

import java.util.Set;
import net.minecraft.core.Holder;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistrySetBuilder;
import net.minecraft.core.registries.Registries;
import net.minecraft.gametest.framework.GameTest;
import net.minecraft.network.chat.Component;
Expand All @@ -30,6 +32,7 @@
import net.minecraft.world.phys.Vec3;
import net.neoforged.neoforge.common.damagesource.IDeathMessageProvider;
import net.neoforged.neoforge.common.damagesource.IScalingFunction;
import net.neoforged.neoforge.common.data.DatapackBuiltinEntriesProvider;
import net.neoforged.testframework.DynamicTest;
import net.neoforged.testframework.annotation.ForEachTest;
import net.neoforged.testframework.annotation.TestHolder;
Expand Down Expand Up @@ -58,12 +61,12 @@ public class DamageTypeTests {
public static final DamageScaling SCALING = DamageScaling.create("TEST_SCALING", "test:scaling", SCALE_FUNC);
public static final DeathMessageType MSGTYPE = DeathMessageType.create("TEST_MSGTYPE", "test:msgtype", MSG_PROVIDER);

public static final ResourceKey<DamageType> TEST_DMG_TYPE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation("test", "test"));

@GameTest
@EmptyTemplate
@TestHolder(description = "Tests if custom damage types function as expected")
static void dmgTypeTests(final DynamicTest test, final RegistrationHelper reg) {
ResourceKey<DamageType> TEST_DMG_TYPE = ResourceKey.create(Registries.DAMAGE_TYPE, new ResourceLocation(reg.modId(), "test"));

Holder<Item> customSword = reg.registrar(Registries.ITEM).register("custom_damage_sword", () -> new Item(new Item.Properties()) {
@Override
public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity) {
Expand All @@ -74,6 +77,17 @@ public boolean onLeftClickEntity(ItemStack stack, Player player, Entity entity)
}
});

RegistrySetBuilder registrySetBuilder = new RegistrySetBuilder();
registrySetBuilder.add(Registries.DAMAGE_TYPE, bootstrap -> {
bootstrap.register(TEST_DMG_TYPE, new DamageType("test_mod", SCALING, 0.0f, EFFECTS, MSGTYPE));
});

reg.addProvider(event -> new DatapackBuiltinEntriesProvider(
event.getGenerator().getPackOutput(),
event.getLookupProvider(),
registrySetBuilder,
Set.of(reg.modId())));

test.onGameTest(helper -> {
Skeleton target = helper.spawnWithNoFreeWill(EntityType.SKELETON, 1, 1, 1);

Expand Down

0 comments on commit 75f2348

Please sign in to comment.