Skip to content

Commit

Permalink
Update to MC 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Dec 28, 2024
1 parent 3da3ad1 commit 9c645e7
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 45 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ neoforge_loader_version_range=[4,)
neoforge_update_json_url=https://raw.githubusercontent.com/CyclopsMC/Versions/master/neoforge_update/common-capabilities.json

# Dependencies
cyclopscore_version=1.25.5-689
cyclopscore_version=1.25.5-690
rfapi_version=1.12-2.1.0.7
enderio_version=3.0.0.40_alpha
endercore_version=0.4.0.24-alpha
Expand Down
19 changes: 19 additions & 0 deletions src/test/java/org/cyclops/commoncapabilities/TestInitHelpers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.cyclops.commoncapabilities;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.minecraft.DetectedVersion;
import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import net.neoforged.fml.loading.LoadingModList;

/**
* @author rubensworks
*/
public class TestInitHelpers {
public static void initMinecraft() {
SharedConstants.setVersion(DetectedVersion.BUILT_IN);
LoadingModList.of(Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Lists.newArrayList(), Maps.newHashMap());
Bootstrap.bootStrap();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.cyclops.commoncapabilities.api.capability.fluidhandler;

import com.google.common.collect.Lists;
import net.minecraft.DetectedVersion;
import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import net.minecraft.world.level.material.Fluids;
import net.neoforged.neoforge.fluids.FluidStack;
import net.neoforged.neoforge.fluids.capability.IFluidHandler;
import org.cyclops.commoncapabilities.TestInitHelpers;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -23,9 +21,7 @@ public class TestFilteredFluidHandlerFluidStackIterator {

@BeforeClass
public static void init() {
// We need the Minecraft registries to be filled
SharedConstants.setVersion(DetectedVersion.BUILT_IN);
Bootstrap.bootStrap();
TestInitHelpers.initMinecraft();

HANDLER_EMPTY = new ImmutableListFluidHandler(Lists.newArrayList());
HANDLER = new ImmutableListFluidHandler(Lists.newArrayList(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.cyclops.commoncapabilities.api.capability.itemhandler;

import net.minecraft.DetectedVersion;
import net.minecraft.SharedConstants;
import net.minecraft.core.NonNullList;
import net.minecraft.server.Bootstrap;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.neoforged.neoforge.items.IItemHandler;
import org.cyclops.commoncapabilities.TestInitHelpers;
import org.cyclops.commoncapabilities.ingredient.DataComparator;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -24,9 +22,7 @@ public class TestFilteredItemHandlerItemStackIterator {

@BeforeClass
public static void init() {
// We need the Minecraft registries to be filled
SharedConstants.setVersion(DetectedVersion.BUILT_IN);
Bootstrap.bootStrap();
TestInitHelpers.initMinecraft();

HANDLER_EMPTY = new ImmutableListItemHandler(NonNullList.withSize(0, ItemStack.EMPTY));
HANDLER = new ImmutableListItemHandler(NonNullList.of(ItemStack.EMPTY,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import net.minecraft.DetectedVersion;
import net.minecraft.SharedConstants;
import net.minecraft.server.Bootstrap;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import org.cyclops.commoncapabilities.IngredientComponents;
import org.cyclops.commoncapabilities.ModBaseMocked;
import org.cyclops.commoncapabilities.TestInitHelpers;
import org.cyclops.commoncapabilities.api.capability.itemhandler.ItemMatch;
import org.cyclops.commoncapabilities.api.ingredient.IngredientComponent;
import org.cyclops.commoncapabilities.api.ingredient.MixedIngredients;
Expand Down Expand Up @@ -40,8 +38,8 @@ private static void setStatic(Field field, Object newValue) throws IllegalAccess

@BeforeClass
public static void init() throws NoSuchFieldException, IllegalAccessException {
SharedConstants.setVersion(DetectedVersion.BUILT_IN);
Bootstrap.bootStrap();
TestInitHelpers.initMinecraft();

setStatic(IngredientComponent.class.getField("ITEMSTACK"), IngredientComponents.ITEMSTACK);
CyclopsCoreInstance.MOD = new ModBaseMocked();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.CoreMatchers.startsWith;
import static org.junit.Assert.assertThat;

public class TestIngredientMatcherItemStack {
Expand Down Expand Up @@ -209,7 +210,7 @@ public void testMatches() {
assertThat(M.matches(W_1, W_2_T1, ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, W_1_T2, ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, W_2_T2, ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, L_1, ItemMatch.DATA), is(true));
assertThat(M.matches(W_1, L_1, ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, L_1_T1, ItemMatch.DATA), is(false));

assertThat(M.matches(W_1, W_1, ItemMatch.ITEM | ItemMatch.STACKSIZE), is(true));
Expand All @@ -236,7 +237,7 @@ public void testMatches() {
assertThat(M.matches(W_1, W_2_T1, ItemMatch.STACKSIZE | ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, W_1_T2, ItemMatch.STACKSIZE | ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, W_2_T2, ItemMatch.STACKSIZE | ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, L_1, ItemMatch.STACKSIZE | ItemMatch.DATA), is(true));
assertThat(M.matches(W_1, L_1, ItemMatch.STACKSIZE | ItemMatch.DATA), is(false));
assertThat(M.matches(W_1, L_1_T1, ItemMatch.STACKSIZE | ItemMatch.DATA), is(false));

assertThat(M.matches(W_1, W_1, ItemMatch.ITEM | ItemMatch.STACKSIZE | ItemMatch.DATA), is(true));
Expand Down Expand Up @@ -306,35 +307,35 @@ public void testCompare() {
assertThat(M.compare(W_1, W_2_T2), is(-1));
assertThat(M.compare(W_1, W_1_T1), is(20));
assertThat(M.compare(W_1, W_1_T2), is(20));
assertThat(M.compare(W_1, L_1), is(-926));
assertThat(M.compare(W_1, L_1_T1), is(-926));
assertThat(M.compare(W_1, L_1), is(-971));
assertThat(M.compare(W_1, L_1_T1), is(-971));

assertThat(M.compare(W_1_T1, W_1), is(-20));
assertThat(M.compare(W_1_T1, W_2), is(-1));
assertThat(M.compare(W_1_T1, W_2_T1), is(-1));
assertThat(M.compare(W_1_T1, W_2_T2), is(-1));
assertThat(M.compare(W_1_T1, W_1_T1), is(0));
assertThat(M.compare(W_1_T1, W_1_T2), is(1));
assertThat(M.compare(W_1_T1, L_1), is(-926));
assertThat(M.compare(W_1_T1, L_1_T1), is(-926));
assertThat(M.compare(W_1_T1, L_1), is(-971));
assertThat(M.compare(W_1_T1, L_1_T1), is(-971));

assertThat(M.compare(W_1_T2, W_1), is(-20));
assertThat(M.compare(W_1_T2, W_2), is(-1));
assertThat(M.compare(W_1_T2, W_2_T1), is(-1));
assertThat(M.compare(W_1_T2, W_2_T2), is(-1));
assertThat(M.compare(W_1_T2, W_1_T1), is(-1));
assertThat(M.compare(W_1_T2, W_1_T2), is(0));
assertThat(M.compare(W_1_T2, L_1), is(-926));
assertThat(M.compare(W_1_T2, L_1_T1), is(-926));
assertThat(M.compare(W_1_T2, L_1), is(-971));
assertThat(M.compare(W_1_T2, L_1_T1), is(-971));

assertThat(M.compare(W_2, W_1), is(1));
assertThat(M.compare(W_2, W_1_T1), is(1));
assertThat(M.compare(W_2, W_1_T2), is(1));
assertThat(M.compare(W_2, W_2), is(0));
assertThat(M.compare(W_2, W_2_T1), is(20));
assertThat(M.compare(W_2, W_2_T2), is(20));
assertThat(M.compare(W_2, L_1), is(-926));
assertThat(M.compare(W_2, L_1_T1), is(-926));
assertThat(M.compare(W_2, L_1), is(-971));
assertThat(M.compare(W_2, L_1_T1), is(-971));

assertThat(M.compare(W_2_T1, W_1), is(1));
assertThat(M.compare(W_2_T1, W_1_T1), is(1));
Expand All @@ -349,24 +350,24 @@ public void testCompare() {
assertThat(M.compare(W_2_T2, W_2), is(-20));
assertThat(M.compare(W_2_T2, W_2_T1), is(-1));
assertThat(M.compare(W_2_T2, W_2_T2), is(0));
assertThat(M.compare(W_2_T2, L_1), is(-926));
assertThat(M.compare(W_2_T2, L_1_T1), is(-926));

assertThat(M.compare(L_1, W_1), is(926));
assertThat(M.compare(L_1, W_1_T1), is(926));
assertThat(M.compare(L_1, W_1_T2), is(926));
assertThat(M.compare(L_1, W_2), is(926));
assertThat(M.compare(L_1, W_2_T1), is(926));
assertThat(M.compare(L_1, W_2_T2), is(926));
assertThat(M.compare(W_2_T2, L_1), is(-971));
assertThat(M.compare(W_2_T2, L_1_T1), is(-971));

assertThat(M.compare(L_1, W_1), is(971));
assertThat(M.compare(L_1, W_1_T1), is(971));
assertThat(M.compare(L_1, W_1_T2), is(971));
assertThat(M.compare(L_1, W_2), is(971));
assertThat(M.compare(L_1, W_2_T1), is(971));
assertThat(M.compare(L_1, W_2_T2), is(971));
assertThat(M.compare(L_1, L_1), is(0));
assertThat(M.compare(L_1, L_1_T1), is(20));

assertThat(M.compare(L_1_T1, W_1), is(926));
assertThat(M.compare(L_1_T1, W_1_T1), is(926));
assertThat(M.compare(L_1_T1, W_1_T2), is(926));
assertThat(M.compare(L_1_T1, W_2), is(926));
assertThat(M.compare(L_1_T1, W_2_T1), is(926));
assertThat(M.compare(L_1_T1, W_2_T2), is(926));
assertThat(M.compare(L_1_T1, W_1), is(971));
assertThat(M.compare(L_1_T1, W_1_T1), is(971));
assertThat(M.compare(L_1_T1, W_1_T2), is(971));
assertThat(M.compare(L_1_T1, W_2), is(971));
assertThat(M.compare(L_1_T1, W_2_T1), is(971));
assertThat(M.compare(L_1_T1, W_2_T2), is(971));
assertThat(M.compare(L_1_T1, L_1), is(-20));
assertThat(M.compare(L_1_T1, L_1_T1), is(0));
}
Expand Down Expand Up @@ -397,8 +398,8 @@ public void testConditionCompare() {

@Test
public void testToString() {
assertThat(M.toString(W_1), is("minecraft:white_wool 1 {minecraft:max_stack_size=>64, minecraft:lore=>ItemLore[lines=[], styledLines=[]], minecraft:enchantments=>ItemEnchantments{enchantments={}, showInTooltip=true}, minecraft:repair_cost=>0, minecraft:attribute_modifiers=>ItemAttributeModifiers[modifiers=[], showInTooltip=true], minecraft:rarity=>COMMON}"));
assertThat(M.toString(W_1_T1), is("minecraft:white_wool 1 {minecraft:enchantment_glint_override=>true, minecraft:max_stack_size=>64, minecraft:lore=>ItemLore[lines=[], styledLines=[]], minecraft:enchantments=>ItemEnchantments{enchantments={}, showInTooltip=true}, minecraft:repair_cost=>0, minecraft:attribute_modifiers=>ItemAttributeModifiers[modifiers=[], showInTooltip=true], minecraft:rarity=>COMMON}"));
assertThat(M.toString(W_1), startsWith("minecraft:white_wool 1 {"));
assertThat(M.toString(W_1_T1), startsWith("minecraft:white_wool 1 {"));
}

}

0 comments on commit 9c645e7

Please sign in to comment.