Skip to content

Commit

Permalink
Merge branch 'Direwolf20-MC:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackwithking authored Sep 24, 2024
2 parents 1f7f4d4 + 527c3db commit ef65dcc
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// 1.21.1 2024-09-18T12:55:01.3643366 JustDireThings FluidTags
8ae2f887f0ec5e3342028a75a1076411a177ef9c data/c/tags/fluid/experience.json
6 changes: 6 additions & 0 deletions src/generated/resources/data/c/tags/fluid/experience.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"values": [
"justdirethings:xp_fluid_source",
"justdirethings:xp_fluid_flowing"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Fluid> EXPERIENCE = forgeTag("experience");

public JustDireFluidTags(PackOutput output, CompletableFuture<HolderLookup.Provider> lookupProvider, @Nullable ExistingFileHelper existingFileHelper) {
super(output, lookupProvider, JustDireThings.MODID, existingFileHelper);
}

private static TagKey<Fluid> 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";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

import java.util.Map;
import java.util.Objects;
import java.util.WeakHashMap;

public class FilterData {
public boolean allowlist = false, compareNBT = false;
public int blockItemFilter = -1;

//This is not saved in NBT, and is recreated as needed on demand
public final Map<ItemStackKey, Boolean> filterCache = new Object2BooleanOpenHashMap<>();
public final Map<Entity, Boolean> entityCache = new Object2BooleanOpenHashMap<>();
public final WeakHashMap<Entity, Boolean> entityCache = new WeakHashMap<>();

public FilterData() {

Expand Down

0 comments on commit ef65dcc

Please sign in to comment.