Skip to content

Commit

Permalink
added keybind for clearing goop puddles
Browse files Browse the repository at this point in the history
  • Loading branch information
absolutelyaya committed Feb 18, 2024
1 parent cf72edd commit 3e64abc
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 6 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
- Added Censor Mode Setting
- Improved Surface Detection (Goop now sticks to non-full block surfaces like slabs)
- goop is no longer offset weirdly in negative coordinates
- Added Random Rotation Setting
- Added Random Rotation Setting
- Added Keybind for clearing all Goop
2 changes: 2 additions & 0 deletions src/main/java/absolutelyaya/goop/client/GoopClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import absolutelyaya.goop.particles.GoopDropParticle;
import absolutelyaya.goop.particles.GoopParticle;
import absolutelyaya.goop.particles.GoopStringParticle;
import absolutelyaya.goop.registries.KeybindRegistry;
import absolutelyaya.goop.registries.PacketRegistry;
import absolutelyaya.goop.registries.ParticleRegistry;
import me.shedaniel.autoconfig.AutoConfig;
Expand Down Expand Up @@ -33,6 +34,7 @@ public void onInitializeClient()
particleRegistry.register(ParticleRegistry.EGG_GOOP, EggGoopParticle.Factory::new);

PacketRegistry.registerClient();
KeybindRegistry.register();
}

public static boolean recolorMature()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.entity.Entity;
import net.minecraft.particle.DustParticleEffect;
import net.minecraft.particle.ParticleType;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.RegistryKeys;
Expand Down Expand Up @@ -46,7 +45,7 @@ protected GoopDropParticle(ClientWorld clientWorld, Vec3d pos, Vec3d vel, Sprite
{
super(clientWorld, pos.x, pos.y, pos.z);
GoopConfig config = GoopClient.getConfig();
color = mature && config.censorMature ? Vec3d.unpackRgb(config.censorColor) : color;
color = mature && GoopClient.recolorMature() ? Vec3d.unpackRgb(config.censorColor) : color;
setColor((float)color.getX(), (float)color.getY(), (float)color.getZ());
this.color = color;
this.scale = scale - (scale > 1 ? 1.25f * (scale / 2) : 0f);
Expand Down
8 changes: 7 additions & 1 deletion src/main/java/absolutelyaya/goop/particles/GoopParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.jetbrains.annotations.Nullable;

import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Queue;

public class GoopParticle extends SurfaceAlignedParticle
Expand All @@ -34,7 +35,7 @@ protected GoopParticle(ClientWorld world, double x, double y, double z, SpritePr
super(world, x, y, z, spriteProvider, color, scale, dir, deform);
this.maxAge = config.permanent ? Integer.MAX_VALUE : 200 + random.nextInt(100);
this.alpha = Math.min(random.nextFloat() + 0.5f, 1);
this.color = mature && config.censorMature ? Vec3d.unpackRgb(config.censorColor) : color;
this.color = mature && GoopClient.recolorMature() ? Vec3d.unpackRgb(config.censorColor) : color;
this.scale = 0;
this.size = scale;
this.normalAlpha = alpha;
Expand Down Expand Up @@ -111,6 +112,11 @@ public void markDead()
GOOP_QUEUE.remove(this);
}

public static void removeAll()
{
new ArrayList<>(GOOP_QUEUE).forEach(GoopParticle::markDead);
}

public static class Factory implements ParticleFactory<GoopParticleEffect>
{
protected final SpriteProvider spriteProvider;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ protected GoopStringParticle(ClientWorld world, Vec3d pos, SpriteProvider sprite
gravityStrength = random.nextFloat() * 0.25f + 0.1f;
maxAge = random.nextInt(15) + 20;
GoopConfig config = GoopClient.getConfig();
color = mature && config.censorMature ? Vec3d.unpackRgb(config.censorColor) : color;
color = mature && GoopClient.recolorMature() ? Vec3d.unpackRgb(config.censorColor) : color;
setColor((float)color.getX(), (float)color.getY(), (float)color.getZ());
this.scale = this.scale.multiply(scale);
collidesWithWorld = true;
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/absolutelyaya/goop/registries/KeybindRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package absolutelyaya.goop.registries;

import absolutelyaya.goop.particles.GoopParticle;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
import net.minecraft.client.util.InputUtil;

public class KeybindRegistry
{
public static final KeyBinding CLEAR_GOOP = KeyBindingHelper.registerKeyBinding(
new KeyBinding("key.goop.clear", InputUtil.Type.KEYSYM,
InputUtil.UNKNOWN_KEY.getCode(), "category.goop"));

static boolean clearPressed;

public static void register()
{
ClientTickEvents.END_CLIENT_TICK.register(client ->
{
while (CLEAR_GOOP.wasPressed() && !clearPressed)
{
GoopParticle.removeAll();
clearPressed = true;
}
while (CLEAR_GOOP.wasPressed()); //remove stored presses
clearPressed = CLEAR_GOOP.isPressed();
});
}
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/goop/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"modmenu.descriptionTranslation.goop": "Adds Splatter Particle Effects for Blood, Slime or other cool VFX",
"yaya.support.kofi": "Support yayas hijinx",

"category.goop": "Goop Technology",
"key.goop.clear": "Clear Goop",

"text.autoconfig.goop.title": "Goop Config",

"text.autoconfig.goop.category.default": "Goop",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
"Absolutelyaya"
],
"contact": {
"repo": "https://github.com/absolutelyaya/Goop"
"issues": "https://github.com/absolutelyaya/Goop/issues",
"repo": "https://github.com/absolutelyaya/Goop",
"homepage": "https://absolutelyaya.neocities.org/"
},
"license": "MIT",
"icon": "assets/goop/icon.png",
Expand Down

0 comments on commit 3e64abc

Please sign in to comment.