diff --git a/gradle.properties b/gradle.properties index 1906d711..3494007d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -32,7 +32,7 @@ mod_name=Just Dire Things # The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default. mod_license=MIT # The mod version. See https://semver.org/ -mod_version=1.4.0 +mod_version=1.4.1 # The group ID for the mod. It is only important when publishing as an artifact to a Maven repository. # This should match the base package used for the mod sources. # See https://maven.apache.org/guides/mini/guide-naming-conventions.html diff --git a/src/generated/resources/.cache/a2fd677372f1bb18b16a30f165ec0b70b89554af b/src/generated/resources/.cache/a2fd677372f1bb18b16a30f165ec0b70b89554af new file mode 100644 index 00000000..c79b264d --- /dev/null +++ b/src/generated/resources/.cache/a2fd677372f1bb18b16a30f165ec0b70b89554af @@ -0,0 +1,2 @@ +// 1.21.1 2024-09-18T12:55:01.3643366 JustDireThings FluidTags +8ae2f887f0ec5e3342028a75a1076411a177ef9c data/c/tags/fluid/experience.json diff --git a/src/generated/resources/data/c/tags/fluid/experience.json b/src/generated/resources/data/c/tags/fluid/experience.json new file mode 100644 index 00000000..8eba5d14 --- /dev/null +++ b/src/generated/resources/data/c/tags/fluid/experience.json @@ -0,0 +1,6 @@ +{ + "values": [ + "justdirethings:xp_fluid_source", + "justdirethings:xp_fluid_flowing" + ] +} \ No newline at end of file diff --git a/src/main/java/com/direwolf20/justdirethings/JustDireThings.java b/src/main/java/com/direwolf20/justdirethings/JustDireThings.java index 94f6530f..a325cf74 100644 --- a/src/main/java/com/direwolf20/justdirethings/JustDireThings.java +++ b/src/main/java/com/direwolf20/justdirethings/JustDireThings.java @@ -9,13 +9,13 @@ import com.direwolf20.justdirethings.common.capabilities.ExperienceHolderFluidTank; import com.direwolf20.justdirethings.common.containers.handlers.PotionCanisterHandler; import com.direwolf20.justdirethings.common.entities.DecoyEntity; -import com.direwolf20.justdirethings.common.fluids.xpfluid.XPFluid; import com.direwolf20.justdirethings.common.items.FluidCanister; import com.direwolf20.justdirethings.common.items.PortalGunV2; import com.direwolf20.justdirethings.common.items.TimeWand; import com.direwolf20.justdirethings.common.items.datacomponents.JustDireDataComponents; import com.direwolf20.justdirethings.common.items.interfaces.PoweredItem; import com.direwolf20.justdirethings.common.network.PacketHandler; +import com.direwolf20.justdirethings.datagen.JustDireFluidTags; import com.direwolf20.justdirethings.setup.ClientSetup; import com.direwolf20.justdirethings.setup.Config; import com.direwolf20.justdirethings.setup.ModSetup; @@ -303,7 +303,7 @@ public boolean canFillFluidType(FluidStack fluid) { event.registerBlock(Capabilities.FluidHandler.BLOCK, (level, pos, state, be, side) -> { if (be instanceof ExperienceHolderBE experienceHolderBE) { - return new ExperienceHolderFluidTank(experienceHolderBE, fluidstack -> fluidstack.getFluid() instanceof XPFluid); //TODO Tags? + return new ExperienceHolderFluidTank(experienceHolderBE, fluidstack -> fluidstack.is(JustDireFluidTags.EXPERIENCE)); } return null; }, diff --git a/src/main/java/com/direwolf20/justdirethings/common/capabilities/ExperienceHolderFluidTank.java b/src/main/java/com/direwolf20/justdirethings/common/capabilities/ExperienceHolderFluidTank.java index e5344a71..dcc4b097 100644 --- a/src/main/java/com/direwolf20/justdirethings/common/capabilities/ExperienceHolderFluidTank.java +++ b/src/main/java/com/direwolf20/justdirethings/common/capabilities/ExperienceHolderFluidTank.java @@ -39,17 +39,11 @@ public int fill(FluidStack resource, FluidAction action) { if (fluid.isEmpty()) { return Math.min(capacity, resource.getAmount() - resource.getAmount() % 20); } - if (!FluidStack.isSameFluidSameComponents(fluid, resource)) { - return 0; - } return Math.min(capacity - getFluidAmount() - ((capacity - getFluidAmount()) % 20), resource.getAmount() - resource.getAmount() % 20); } if (fluid.isEmpty()) { return resource.getAmount() - insertFluid(resource.getAmount()); } - if (!FluidStack.isSameFluidSameComponents(fluid, resource)) { - return 0; - } int filled = resource.getAmount() - insertFluid(resource.getAmount()); if (filled > 0) onContentsChanged(); diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/DataGenerators.java b/src/main/java/com/direwolf20/justdirethings/datagen/DataGenerators.java index 014b4975..de24c73c 100644 --- a/src/main/java/com/direwolf20/justdirethings/datagen/DataGenerators.java +++ b/src/main/java/com/direwolf20/justdirethings/datagen/DataGenerators.java @@ -27,6 +27,8 @@ public static void gatherData(GatherDataEvent event) { List.of(new LootTableProvider.SubProviderEntry(JustDireLootTables::new, LootContextParamSets.BLOCK)), event.getLookupProvider())); JustDireBlockTags blockTags = new JustDireBlockTags(packOutput, lookupProvider, event.getExistingFileHelper()); generator.addProvider(event.includeServer(), blockTags); + JustDireFluidTags fluidTags = new JustDireFluidTags(packOutput, lookupProvider, event.getExistingFileHelper()); + generator.addProvider(event.includeServer(), fluidTags); JustDireItemTags itemTags = new JustDireItemTags(packOutput, lookupProvider, blockTags, event.getExistingFileHelper()); generator.addProvider(event.includeServer(), itemTags); JustDireDataMaps dataMaps = new JustDireDataMaps(packOutput, lookupProvider); diff --git a/src/main/java/com/direwolf20/justdirethings/datagen/JustDireFluidTags.java b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireFluidTags.java new file mode 100644 index 00000000..8130104f --- /dev/null +++ b/src/main/java/com/direwolf20/justdirethings/datagen/JustDireFluidTags.java @@ -0,0 +1,40 @@ +package com.direwolf20.justdirethings.datagen; + +import com.direwolf20.justdirethings.JustDireThings; +import com.direwolf20.justdirethings.setup.Registration; +import net.minecraft.core.HolderLookup; +import net.minecraft.data.PackOutput; +import net.minecraft.data.tags.FluidTagsProvider; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.tags.FluidTags; +import net.minecraft.tags.TagKey; +import net.minecraft.world.level.material.Fluid; +import net.neoforged.neoforge.common.data.ExistingFileHelper; +import org.jetbrains.annotations.Nullable; + +import java.util.concurrent.CompletableFuture; + +public class JustDireFluidTags extends FluidTagsProvider { + + public static final TagKey EXPERIENCE = forgeTag("experience"); + + public JustDireFluidTags(PackOutput output, CompletableFuture lookupProvider, @Nullable ExistingFileHelper existingFileHelper) { + super(output, lookupProvider, JustDireThings.MODID, existingFileHelper); + } + + private static TagKey forgeTag(String name) { + return FluidTags.create(ResourceLocation.fromNamespaceAndPath("c", name)); + } + + @Override + protected void addTags(HolderLookup.Provider provider) { + this.tag(EXPERIENCE) + .add(Registration.XP_FLUID_SOURCE.get()) + .add(Registration.XP_FLUID_FLOWING.get()); + } + + @Override + public String getName() { + return "JustDireThings FluidTags"; + } +} diff --git a/src/main/java/com/direwolf20/justdirethings/util/interfacehelpers/FilterData.java b/src/main/java/com/direwolf20/justdirethings/util/interfacehelpers/FilterData.java index fec1eb40..7dd06720 100644 --- a/src/main/java/com/direwolf20/justdirethings/util/interfacehelpers/FilterData.java +++ b/src/main/java/com/direwolf20/justdirethings/util/interfacehelpers/FilterData.java @@ -6,6 +6,7 @@ import java.util.Map; import java.util.Objects; +import java.util.WeakHashMap; public class FilterData { public boolean allowlist = false, compareNBT = false; @@ -13,7 +14,7 @@ public class FilterData { //This is not saved in NBT, and is recreated as needed on demand public final Map filterCache = new Object2BooleanOpenHashMap<>(); - public final Map entityCache = new Object2BooleanOpenHashMap<>(); + public final WeakHashMap entityCache = new WeakHashMap<>(); public FilterData() {