Skip to content

Commit

Permalink
Added particles for the Thermoregulator
Browse files Browse the repository at this point in the history
  • Loading branch information
Forstride committed Jan 8, 2024
1 parent a4d19c8 commit 3eeaf3f
Show file tree
Hide file tree
Showing 40 changed files with 136 additions and 38 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// 1.20.4 2024-01-08T12:48:48.1761072 Tags for minecraft:block mod id toughasnails
// 1.20.4 2024-01-07T21:24:08.2345992 Tags for minecraft:block mod id toughasnails
bffb0fdf09ac6cfbed64666a723e8a78cb784bbd data/minecraft/tags/blocks/mineable/axe.json
0342cd45a4d6f790afda91090de45871d9b0ef63 data/minecraft/tags/blocks/mineable/pickaxe.json
eed9ca8217c04724f67008aba1a0a5edde5697c2 data/toughasnails/tags/blocks/cooling_blocks.json
658fab0118eb1ac9896e1b9ab89f2d5ed055a967 data/toughasnails/tags/blocks/heating_blocks.json
4e9fc3338709900bd37b9707629283ff25f3234a data/toughasnails/tags/blocks/passable_blocks.json
e31d0ccf1dd374df5d89a102ae1829d4411012f6 data/toughasnails/tags/blocks/passable_blocks.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"values": [
"#minecraft:doors",
"#minecraft:trapdoors"
"#minecraft:trapdoors",
"minecraft:scaffolding"
]
}
10 changes: 10 additions & 0 deletions common/src/main/java/toughasnails/api/particle/TANParticles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package toughasnails.api.particle;

import net.minecraft.core.particles.SimpleParticleType;

public class TANParticles
{
public static SimpleParticleType THERMOREGULATOR_COOL;
public static SimpleParticleType THERMOREGULATOR_WARM;
public static SimpleParticleType THERMOREGULATOR_NEUTRAL;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.mojang.serialization.MapCodec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.util.RandomSource;
import net.minecraft.world.Containers;
import net.minecraft.world.InteractionHand;
Expand All @@ -25,6 +25,7 @@
import net.minecraft.world.level.block.state.properties.DirectionProperty;
import net.minecraft.world.phys.BlockHitResult;
import toughasnails.api.blockentity.TANBlockEntityTypes;
import toughasnails.api.particle.TANParticles;
import toughasnails.block.entity.ThermoregulatorBlockEntity;

import javax.annotation.Nullable;
Expand Down Expand Up @@ -120,7 +121,7 @@ public void onRemove(BlockState state, Level level, BlockPos pos, BlockState new
super.onRemove(state, level, pos, newState, $$4);
}

/*@Override
@Override
public void animateTick(BlockState p_221253_, Level p_221254_, BlockPos p_221255_, RandomSource p_221256_)
{
boolean cooling = p_221253_.getValue(COOLING);
Expand All @@ -142,10 +143,11 @@ public void animateTick(BlockState p_221253_, Level p_221254_, BlockPos p_221255
double xmove = direction$axis == Direction.Axis.X ? (double)direction.getStepX() * 0.15D : ymove;
double zmove = direction$axis == Direction.Axis.Z ? (double)direction.getStepZ() * 0.15D : ymove;

p_221254_.addParticle(ParticleTypes.CAMPFIRE_COSY_SMOKE, d0 + d5, d1 + d4, d2 + d6, xmove, ymove, zmove);
ParticleOptions particle = TANParticles.THERMOREGULATOR_NEUTRAL;
if (cooling && !heating) { particle = TANParticles.THERMOREGULATOR_COOL; }
if (!cooling && heating) { particle = TANParticles.THERMOREGULATOR_WARM; }

if (cooling && p_221256_.nextInt(6) == 0) { p_221254_.addParticle(ParticleTypes.SNOWFLAKE, d0 + d5, d1 + d6, d2 + d6, xmove, ymove, zmove); }
if (heating && p_221256_.nextInt(6) == 0) { p_221254_.addParticle(ParticleTypes.SMALL_FLAME, d0 + d5, d1 + d6, d2 + d6, xmove, ymove, zmove); }
p_221254_.addParticle(particle, d0 + d5, d1 + d4, d2 + d6, xmove, ymove, zmove);
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.core.Holder;
import net.minecraft.core.RegistryAccess;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.world.item.ItemStack;
Expand All @@ -23,7 +22,6 @@
import net.minecraft.world.item.armortrim.TrimMaterials;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import toughasnails.core.ToughAsNails;
import toughasnails.init.ModConfig;
import toughasnails.init.ModTags;
import toughasnails.thirst.ThirstOverlayRenderer;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package toughasnails.client.particle;

import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.particle.*;
import net.minecraft.core.particles.SimpleParticleType;

public class ThermoregulatorParticle extends TextureSheetParticle
{
ThermoregulatorParticle(ClientLevel p_105856_, double p_105857_, double p_105858_, double p_105859_, double p_105860_, double p_105861_, double p_105862_)
{
super(p_105856_, p_105857_, p_105858_, p_105859_);
this.lifetime = this.random.nextInt(8) + 8;
this.gravity = 3.0E-6F;
this.xd = p_105860_;
this.yd = p_105861_;
this.zd = p_105862_;
}

@Override
public void tick()
{
this.xo = this.x;
this.yo = this.y;
this.zo = this.z;
if (this.age++ < this.lifetime && !(this.alpha <= 0.0F))
{
this.move(this.xd, this.yd, this.zd);
if (this.age >= this.lifetime - 60 && this.alpha > 0.01F)
{
this.alpha -= 0.01F;
}

}
else
{
this.remove();
}
}

@Override
public float getQuadSize(float p_107089_)
{
float f = ((float)this.age + p_107089_) / (float)this.lifetime;
return this.quadSize * (1.0F - f * f);
}

@Override
public ParticleRenderType getRenderType() {
return ParticleRenderType.PARTICLE_SHEET_TRANSLUCENT;
}

public static class Provider implements ParticleProvider<SimpleParticleType>
{
private final SpriteSet sprites;

public Provider(SpriteSet p_105899_) {
this.sprites = p_105899_;
}

public Particle createParticle(SimpleParticleType p_105910_, ClientLevel p_105911_, double p_105912_, double p_105913_, double p_105914_, double p_105915_, double p_105916_, double p_105917_)
{
ThermoregulatorParticle particle = new ThermoregulatorParticle(p_105911_, p_105912_, p_105913_, p_105914_, p_105915_, p_105916_, p_105917_);
particle.setAlpha(0.5F);
particle.pickSprite(this.sprites);
return particle;
}
}
}
3 changes: 3 additions & 0 deletions common/src/main/java/toughasnails/core/ToughAsNails.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ private static void addClientHandlers()
EventManager.addListener(ModClient::registerBlockColors);
EventManager.addListener(ModClient::registerItemColors);

// Particles
EventManager.addListener(ModClient::registerParticleSprites);

// Tooltips
EventManager.addListener(TooltipHandler::onTooltip);
EventManager.addListener(TooltipHandler::onRenderTooltip);
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/java/toughasnails/init/ModClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package toughasnails.init;

import glitchcore.event.client.RegisterColorsEvent;
import glitchcore.event.client.RegisterParticleSpritesEvent;
import glitchcore.util.RenderTypeHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
Expand All @@ -21,8 +22,10 @@
import net.minecraft.world.level.Level;
import org.jetbrains.annotations.Nullable;
import toughasnails.api.item.TANItems;
import toughasnails.api.particle.TANParticles;
import toughasnails.api.temperature.TemperatureHelper;
import toughasnails.api.temperature.TemperatureLevel;
import toughasnails.client.particle.ThermoregulatorParticle;
import toughasnails.core.ToughAsNails;
import toughasnails.item.DyeableWoolItem;
import toughasnails.item.LeafArmorItem;
Expand Down Expand Up @@ -120,6 +123,13 @@ public static void registerBlockColors(RegisterColorsEvent.Block event)
event.register((state, world, pos, tintIndex) -> 0x3F76E4, WATER_PURIFIER);
}

public static void registerParticleSprites(RegisterParticleSpritesEvent event)
{
event.registerSpriteSet(TANParticles.THERMOREGULATOR_COOL, ThermoregulatorParticle.Provider::new);
event.registerSpriteSet(TANParticles.THERMOREGULATOR_WARM, ThermoregulatorParticle.Provider::new);
event.registerSpriteSet(TANParticles.THERMOREGULATOR_NEUTRAL, ThermoregulatorParticle.Provider::new);
}

public static void setupRenderTypes()
{
RenderType transparentRenderType = RenderType.cutoutMipped();
Expand Down
7 changes: 6 additions & 1 deletion common/src/main/java/toughasnails/init/ModParticles.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
******************************************************************************/
package toughasnails.init;

import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.particles.ParticleType;
import net.minecraft.core.particles.SimpleParticleType;
import net.minecraft.resources.ResourceLocation;
import toughasnails.api.TANAPI;
import toughasnails.api.particle.TANParticles;

import java.util.function.BiConsumer;

public class ModParticles
{
public static void registerParticles(BiConsumer<ResourceLocation, ParticleType<?>> func)
{
TANParticles.THERMOREGULATOR_COOL = register(func, "thermoregulator_cool", new SimpleParticleType(false));
TANParticles.THERMOREGULATOR_WARM = register(func, "thermoregulator_warm", new SimpleParticleType(false));
TANParticles.THERMOREGULATOR_NEUTRAL = register(func, "thermoregulator_neutral", new SimpleParticleType(false));
}

private static ParticleType<?> register(BiConsumer<ResourceLocation, ParticleType<?>> func, String name, ParticleType<?> particle)
private static <T extends ParticleType<? extends ParticleOptions>> T register(BiConsumer<ResourceLocation, ParticleType<?>> func, String name, T particle)
{
func.accept(new ResourceLocation(TANAPI.MOD_ID, name), particle);
return particle;
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"textures": [
"toughasnails:thermoregulator_cool_0",
"toughasnails:thermoregulator_cool_1",
"toughasnails:thermoregulator_cool_2",
"toughasnails:thermoregulator_cool_3"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"textures": [
"toughasnails:thermoregulator_neutral_0",
"toughasnails:thermoregulator_neutral_1",
"toughasnails:thermoregulator_neutral_2",
"toughasnails:thermoregulator_neutral_3"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"textures": [
"toughasnails:thermoregulator_warm_0",
"toughasnails:thermoregulator_warm_1",
"toughasnails:thermoregulator_warm_2",
"toughasnails:thermoregulator_warm_3"
]
}

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
1 change: 1 addition & 0 deletions common/src/main/resources/toughasnails.accesswidener
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ accessible method net/minecraft/client/renderer/item/ItemProperties register (Ln
accessible method net/minecraft/world/item/alchemy/PotionBrewing addMix (Lnet/minecraft/world/item/alchemy/Potion;Lnet/minecraft/world/item/Item;Lnet/minecraft/world/item/alchemy/Potion;)V

# Particle registration
accessible class net/minecraft/client/particle/ParticleEngine$SpriteParticleRegistration
accessible method net/minecraft/core/particles/SimpleParticleType <init> (Z)V

# Thirst
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ protected void addTags(HolderLookup.Provider provider)
// TAN tags
this.tag(ModTags.Blocks.COOLING_BLOCKS).add(Blocks.SOUL_FIRE, Blocks.SOUL_CAMPFIRE, Blocks.SOUL_LANTERN, Blocks.PACKED_ICE, Blocks.BLUE_ICE, Blocks.POWDER_SNOW_CAULDRON);
this.tag(ModTags.Blocks.HEATING_BLOCKS).add(Blocks.FIRE, Blocks.CAMPFIRE, Blocks.LANTERN, Blocks.LAVA, Blocks.MAGMA_BLOCK, Blocks.LAVA_CAULDRON);
this.tag(ModTags.Blocks.PASSABLE_BLOCKS).addTags(BlockTags.DOORS, BlockTags.TRAPDOORS);
this.tag(ModTags.Blocks.PASSABLE_BLOCKS).addTags(BlockTags.DOORS, BlockTags.TRAPDOORS).add(Blocks.SCAFFOLDING);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,5 @@ org.gradle.daemon=false

# Dependencies
nightconfig_version=3.6.7
glitchcore_version=1.0.0.40
glitchcore_version=1.0.0.41
serene_seasons_version=9.3.0.0

0 comments on commit 3eeaf3f

Please sign in to comment.