Skip to content

Commit

Permalink
Make powdered snow a fluid
Browse files Browse the repository at this point in the history
Right now is just used for a spilling effect, not sure if I will do anything more with it in the future, but it felt wrong to not have it
  • Loading branch information
KnightMiner committed Dec 21, 2023
1 parent cfab09e commit 76df1d5
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"tconstruct:powdered_snow"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"fluid": {
"tag": "forge:powdered_snow",
"amount": 100
},
"effects": [
{
"type": "tconstruct:set_freeze",
"time": 160
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ private static void init() {}
public static final TagKey<Fluid> EXPENSIVE_METAL_SPILLING = tag("spilling/metal/expensive");

public static final TagKey<Fluid> POTION = forgeTag("potion");
public static final TagKey<Fluid> POWDERED_SNOW = forgeTag("powdered_snow");

private static TagKey<Fluid> tag(String name) {
return TagKey.create(Registry.FLUID_REGISTRY, TConstruct.getResource(name));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ public void addTags() {
.addTag(TinkerFluids.enderSlime.getLocalTag());

this.tag(TinkerTags.Fluids.POTION).add(TinkerFluids.potion.get());
this.tag(TinkerTags.Fluids.POWDERED_SNOW).add(TinkerFluids.powderedSnow.get());

// tooltips //
this.tag(TinkerTags.Fluids.GLASS_TOOLTIPS).addTags(TinkerFluids.moltenGlass.getLocalTag(), TinkerFluids.liquidSoul.getLocalTag(), TinkerFluids.moltenObsidian.getLocalTag());
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/slimeknights/tconstruct/fluids/FluidEvents.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package slimeknights.tconstruct.fluids;

import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.event.furnace.FurnaceFuelBurnTimeEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fluids.FluidAttributes;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.fluids.util.ConstantFluidContainerWrapper;

/**
* Event subscriber for modifier events
Expand All @@ -20,4 +26,14 @@ static void onFurnaceFuel(FurnaceFuelBurnTimeEvent event) {
event.setBurnTime(30000);
}
}

@SubscribeEvent
static void attachCapabilities(AttachCapabilitiesEvent<ItemStack> event) {
ItemStack stack = event.getObject();
if (event.getObject().is(Items.POWDER_SNOW_BUCKET)) {
event.addCapability(
TConstruct.getResource("powdered_snow"),
new ConstantFluidContainerWrapper(new FluidStack(TinkerFluids.powderedSnow.get(), FluidAttributes.BUCKET_VOLUME), Items.BUCKET.getDefaultInstance()));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public TinkerFluids() {
.build()).tab(TAB_GENERAL).stacksTo(1).craftRemainder(Items.GLASS_BOTTLE),
() -> new FluidStack(venom.get(), FluidValues.BOTTLE))
);
public static final RegistryObject<UnplaceableFluid> powderedSnow = FLUIDS.registerFluid("powdered_snow", () -> new UnplaceableFluid(Items.POWDER_SNOW_BUCKET.delegate, FluidAttributes.builder(TConstruct.getResource("block/fluid/powdered_snow/still"), TConstruct.getResource("block/fluid/powdered_snow/flowing")).sound(SoundEvents.BUCKET_FILL, SoundEvents.BUCKET_EMPTY).temperature(270)));

// slime - note second name parameter is forge tag name
public static final FluidObject<ForgeFlowingFluid> earthSlime = FLUIDS.register("earth_slime", "slime", coolBuilder().density(1400).viscosity(1400).temperature(350), SlimeFluid.Source::new, SlimeFluid.Flowing::new, Material.WATER, 0);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package slimeknights.tconstruct.library.modifiers.spilling.effects;

import com.google.gson.JsonDeserializer;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.GsonHelper;
import net.minecraft.world.entity.Entity;
import net.minecraftforge.fluids.FluidStack;
import slimeknights.tconstruct.TConstruct;
import slimeknights.tconstruct.library.modifiers.spilling.ISpillingEffect;
import slimeknights.tconstruct.library.tools.context.ToolAttackContext;
import slimeknights.tconstruct.library.utils.JsonUtils;

/**
* Effect to set an entity freezing
*/
public record SetFreezeSpillingEffect(int time) implements ISpillingEffect {
public static final ResourceLocation ID = TConstruct.getResource("set_freeze");

@Override
public void applyEffects(FluidStack fluid, float scale, ToolAttackContext context) {
Entity target = context.getTarget();
if (target.canFreeze()) {
target.setTicksFrozen(Math.max(target.getTicksRequiredToFreeze(), target.getTicksFrozen()) + time);
target.setRemainingFireTicks(0);
}
}

@Override
public JsonObject serialize(JsonSerializationContext context) {
JsonObject json = JsonUtils.withType(ID);
json.addProperty("time", time);
return json;
}

/** Loader for this effect */
public static final JsonDeserializer<SetFreezeSpillingEffect> LOADER = (element, type, context) ->
new SetFreezeSpillingEffect(GsonHelper.getAsInt(element.getAsJsonObject(), "time"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
import slimeknights.tconstruct.library.modifiers.spilling.effects.RemoveEffectSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.RestoreHungerSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.SetFireSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.SetFreezeSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.TeleportSpillingEffect;
import slimeknights.tconstruct.library.modifiers.util.DynamicModifier;
import slimeknights.tconstruct.library.modifiers.util.ModifierDeferredRegister;
Expand Down Expand Up @@ -581,6 +582,7 @@ void registerSerializers(RegistryEvent.Register<RecipeSerializer<?>> event) {
ISpillingEffect.LOADER.registerDeserializer(PotionFluidEffect.ID, PotionFluidEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(RestoreHungerSpillingEffect.ID, RestoreHungerSpillingEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(SetFireSpillingEffect.ID, SetFireSpillingEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(SetFreezeSpillingEffect.ID, SetFreezeSpillingEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(TeleportSpillingEffect.ID, TeleportSpillingEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(AddInsomniaSpillingEffect.ID, AddInsomniaSpillingEffect.LOADER);
ISpillingEffect.LOADER.registerDeserializer(AddBreathSpillingEffect.ID, AddBreathSpillingEffect.LOADER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import slimeknights.tconstruct.library.modifiers.spilling.effects.RemoveEffectSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.RestoreHungerSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.SetFireSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.SetFreezeSpillingEffect;
import slimeknights.tconstruct.library.modifiers.spilling.effects.TeleportSpillingEffect;
import slimeknights.tconstruct.library.recipe.FluidValues;
import slimeknights.tconstruct.library.recipe.TagPredicate;
Expand Down Expand Up @@ -59,6 +60,8 @@ protected void addFluids() {
addFluid(Tags.Fluids.MILK, FluidAttributes.BUCKET_VOLUME / 10)
.addEffect(new CureEffectsSpillingEffect(new ItemStack(Items.MILK_BUCKET)))
.addEffect(StrongBonesModifier.SPILLING_EFFECT);
addFluid(TinkerTags.Fluids.POWDERED_SNOW, FluidAttributes.BUCKET_VOLUME / 10)
.addEffect(new SetFreezeSpillingEffect(160));

// blaze - more damage, less fire
burningFluid("blazing_blood", TinkerFluids.blazingBlood.getLocalTag(), FluidAttributes.BUCKET_VOLUME / 20, 3f, 5);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/tconstruct/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@
"fluid.tconstruct.flowing_blazing_blood": "Flowing Blazing Blood",
"item.tconstruct.blazing_blood_bucket": "Blazing Blood Bucket",

"fluid.tconstruct.powdered_snow": "Powdered Snow",

"_comment": "Food",

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"animation": {
"frametime": 4
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 76df1d5

Please sign in to comment.