make everything use the hexagonal particles (why did i have it otherwise?)

This commit is contained in:
petrak@ 2023-02-16 15:12:19 -06:00
parent 07ab36ad34
commit 182aabd032
17 changed files with 77 additions and 68 deletions

View file

@ -24,47 +24,43 @@ public class ConjureParticle extends TextureSheetParticle {
private static final Random RANDOM = new Random();
private final SpriteSet sprites;
private final boolean light;
ConjureParticle(ClientLevel pLevel, double x, double y, double z, double dx, double dy, double dz,
SpriteSet pSprites, int color, boolean light) {
SpriteSet pSprites, int color) {
super(pLevel, x, y, z, dx, dy, dz);
this.light = light;
this.quadSize *= light ? 0.9f : 0.75f;
this.quadSize *= 0.9f;
this.setParticleSpeed(dx, dy, dz);
var r = FastColor.ARGB32.red(color);
var g = FastColor.ARGB32.green(color);
var b = FastColor.ARGB32.blue(color);
this.setColor(r / 255f, g / 255f, b / 255f);
this.setAlpha(light ? 0.3f : 1.0f);
this.setAlpha(0.3f);
this.friction = 0.96F;
this.gravity = light && dy != 0 && dx != 0 && dz != 0 ? -0.01F : 0F;
this.gravity = dy != 0 && dx != 0 && dz != 0 ? -0.01F : 0F;
this.speedUpWhenYMotionIsBlocked = true;
this.sprites = pSprites;
this.roll = RANDOM.nextFloat(360);
this.oRoll = this.roll;
this.lifetime = (int) ((light ? 64.0D : 32.0D) / ((Math.random() + 3f) * 0.25f));
this.lifetime = (int) (64.0 / ((Math.random() + 3f) * 0.25f));
this.hasPhysics = false;
this.setSpriteFromAge(pSprites);
}
public @NotNull ParticleRenderType getRenderType() {
return this.light ? LIGHT_RENDER_TYPE : CONJURE_RENDER_TYPE;
return CONJURE_RENDER_TYPE;
}
public void tick() {
super.tick();
this.setSpriteFromAge(this.sprites);
this.alpha = 1.0f - ((float) this.age / (float) this.lifetime);
if (light) {
this.alpha *= 0.3f;
this.quadSize *= 0.96f;
}
}
public void setSpriteFromAge(@NotNull SpriteSet pSprite) {
if (!this.removed) {
@ -88,13 +84,12 @@ public class ConjureParticle extends TextureSheetParticle {
public Particle createParticle(ConjureParticleOptions type, ClientLevel level,
double pX, double pY, double pZ,
double pXSpeed, double pYSpeed, double pZSpeed) {
return new ConjureParticle(level, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed, this.sprite, type.color(),
type.isLight());
return new ConjureParticle(level, pX, pY, pZ, pXSpeed, pYSpeed, pZSpeed, this.sprite, type.color());
}
}
// https://github.com/VazkiiMods/Botania/blob/db85d778ab23f44c11181209319066d1f04a9e3d/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java
private record ConjureRenderType(boolean light) implements ParticleRenderType {
private record ConjureRenderType() implements ParticleRenderType {
@Override
public void begin(BufferBuilder buf, TextureManager texMan) {
Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer();
@ -104,7 +99,7 @@ public class ConjureParticle extends TextureSheetParticle {
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES);
var tex = texMan.getTexture(TextureAtlas.LOCATION_PARTICLES);
IClientXplatAbstractions.INSTANCE.setFilterSave(tex, this.light, false);
IClientXplatAbstractions.INSTANCE.setFilterSave(tex, true, false);
buf.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
RenderSystem.enableDepthTest();
}
@ -121,10 +116,9 @@ public class ConjureParticle extends TextureSheetParticle {
@Override
public String toString() {
return HexAPI.MOD_ID + (light ? ":light" : ":conjure");
return HexAPI.MOD_ID + ":conjure";
}
}
public static final ConjureRenderType CONJURE_RENDER_TYPE = new ConjureRenderType(false);
public static final ConjureRenderType LIGHT_RENDER_TYPE = new ConjureRenderType(true);
public static final ConjureRenderType CONJURE_RENDER_TYPE = new ConjureRenderType();
}

View file

@ -1,13 +1,20 @@
package at.petrak.hexcasting.common.blocks;
import at.petrak.hexcasting.common.blocks.entity.BlockEntityQuenchedAllay;
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.EntityBlock;
import net.minecraft.world.level.block.RenderShape;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
import static at.petrak.hexcasting.api.HexAPI.modLoc;
@ -31,4 +38,27 @@ public class BlockQuenchedAllay extends Block implements EntityBlock {
public RenderShape getRenderShape(BlockState state) {
return RenderShape.INVISIBLE;
}
@Override
public void animateTick(BlockState state, Level level, BlockPos pos, RandomSource rand) {
ParticleOptions options = new ConjureParticleOptions(0x8932b8);
Vec3 center = Vec3.atCenterOf(pos);
for (Direction direction : Direction.values()) {
int dX = direction.getStepX();
int dY = direction.getStepY();
int dZ = direction.getStepZ();
int count = rand.nextInt(10) / 4;
for (int i = 0; i < count; i++) {
double pX = center.x + (dX == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dX * 0.55D);
double pY = center.y + (dY == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dY * 0.55D);
double pZ = center.z + (dZ == 0 ? Mth.nextDouble(rand, -0.5D, 0.5D) : (double) dZ * 0.55D);
double vPerp = Mth.nextDouble(rand, 0.0, 0.01);
double vX = vPerp * dX;
double vY = vPerp * dY;
double vZ = vPerp * dZ;
level.addParticle(options, pX, pY, pZ, vX, vY, vZ);
}
}
}
}

View file

@ -32,7 +32,7 @@ public class BlockSconce extends AmethystBlock {
var cy = pPos.getY() + 0.5;
var cz = pPos.getZ() + 0.5;
int[] colors = {0xff_6f4fab, 0xff_b38ef3, 0xff_cfa0f3, 0xff_cfa0f3, 0xff_fffdd5};
pLevel.addParticle(new ConjureParticleOptions(colors[rand.nextInt(colors.length)], true), cx, cy, cz,
pLevel.addParticle(new ConjureParticleOptions(colors[rand.nextInt(colors.length)]), cx, cy, cz,
rand.triangle(-0.01f, 0.01f), rand.triangle(0.01f, 0.05f), rand.triangle(-0.01f, 0.01f));
if (rand.nextFloat() < 0.08f) {
pLevel.playLocalSound(cx, cy, cz,

View file

@ -31,7 +31,7 @@ public class BlockEntityConjured extends HexBlockEntity {
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
RANDOM.nextFloat() * 3)));
assert level != null;
level.addParticle(new ConjureParticleOptions(color, false),
level.addParticle(new ConjureParticleOptions(color),
pEntity.getX() + (RANDOM.nextFloat() * 0.6D) - 0.3D,
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
pEntity.getZ() + (RANDOM.nextFloat() * 0.6D) - 0.3D,
@ -50,7 +50,7 @@ public class BlockEntityConjured extends HexBlockEntity {
assert level != null;
if (getBlockState().getBlock() instanceof BlockConjuredLight) {
if (RANDOM.nextFloat() < 0.5) {
level.addParticle(new ConjureParticleOptions(color, true),
level.addParticle(new ConjureParticleOptions(color),
(double) getBlockPos().getX() + 0.45D + (RANDOM.nextFloat() * 0.1D),
(double) getBlockPos().getY() + 0.45D + (RANDOM.nextFloat() * 0.1D),
(double) getBlockPos().getZ() + 0.45D + (RANDOM.nextFloat() * 0.1D),
@ -60,7 +60,7 @@ public class BlockEntityConjured extends HexBlockEntity {
}
} else {
if (RANDOM.nextFloat() < 0.2) {
level.addParticle(new ConjureParticleOptions(color, false),
level.addParticle(new ConjureParticleOptions(color),
(double) getBlockPos().getX() + RANDOM.nextFloat(),
(double) getBlockPos().getY() + RANDOM.nextFloat(),
(double) getBlockPos().getZ() + RANDOM.nextFloat(),
@ -78,7 +78,7 @@ public class BlockEntityConjured extends HexBlockEntity {
.add(new Vec3(RANDOM.nextFloat(), RANDOM.nextFloat(), RANDOM.nextFloat()).scale(
RANDOM.nextFloat() * 3)));
assert level != null;
level.addParticle(new ConjureParticleOptions(color, false),
level.addParticle(new ConjureParticleOptions(color),
entity.getX() + (RANDOM.nextFloat() * 0.8D) - 0.2D,
getBlockPos().getY() + (RANDOM.nextFloat() * 0.05D) + 0.95D,
entity.getZ() + (RANDOM.nextFloat() * 0.8D) - 0.2D,

View file

@ -1,8 +1,11 @@
package at.petrak.hexcasting.common.casting.operators.spells.great
import at.petrak.hexcasting.api.casting.*
import at.petrak.hexcasting.api.casting.ParticleSpray
import at.petrak.hexcasting.api.casting.RenderedSpell
import at.petrak.hexcasting.api.casting.castables.SpellAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getPlayer
import at.petrak.hexcasting.api.casting.getPositiveDouble
import at.petrak.hexcasting.api.casting.iota.Iota
import at.petrak.hexcasting.api.misc.MediaConstants
import at.petrak.hexcasting.api.player.FlightAbility

View file

@ -25,9 +25,7 @@ public class HexParticles {
private static final Map<ResourceLocation, ParticleType<?>> PARTICLES = new LinkedHashMap<>();
public static final ConjureParticleOptions.Type CONJURE_PARTICLE = register(
"conjure_block_particle", new ConjureParticleOptions.Type(false));
public static final ConjureParticleOptions.Type LIGHT_PARTICLE = register(
"conjure_light_particle", new ConjureParticleOptions.Type(false));
"conjure_particle", new ConjureParticleOptions.Type(false));
private static <O extends ParticleOptions, T extends ParticleType<O>> T register(String id, T particle) {
var old = PARTICLES.put(modLoc(id), particle);
@ -39,12 +37,12 @@ public class HexParticles {
public static class FactoryHandler {
public interface Consumer {
<T extends ParticleOptions> void register(ParticleType<T> type, Function<SpriteSet, ParticleProvider<T>> constructor);
<T extends ParticleOptions> void register(ParticleType<T> type,
Function<SpriteSet, ParticleProvider<T>> constructor);
}
public static void registerFactories(Consumer consumer) {
consumer.register(CONJURE_PARTICLE, ConjureParticle.Provider::new);
consumer.register(LIGHT_PARTICLE, ConjureParticle.Provider::new);
}
}
}

View file

@ -1,7 +1,7 @@
package at.petrak.hexcasting.common.network;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
import at.petrak.hexcasting.api.casting.ParticleSpray;
import at.petrak.hexcasting.api.misc.FrozenColorizer;
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
import io.netty.buffer.ByteBuf;
import net.minecraft.client.Minecraft;
@ -96,7 +96,7 @@ public record MsgCastParticleAck(ParticleSpray spray, FrozenColorizer colorizer)
var vel = velUnlen.scale(msg.spray().getVel().length() / 20);
Minecraft.getInstance().level.addParticle(
new ConjureParticleOptions(color, false),
new ConjureParticleOptions(color),
pos.x, pos.y, pos.z,
vel.x, vel.y, vel.z
);

View file

@ -11,21 +11,20 @@ import net.minecraft.network.FriendlyByteBuf;
import java.util.Locale;
public record ConjureParticleOptions(int color, boolean isLight) implements ParticleOptions {
public record ConjureParticleOptions(int color) implements ParticleOptions {
@Override
public ParticleType<?> getType() {
return (this.isLight ? HexParticles.LIGHT_PARTICLE : HexParticles.CONJURE_PARTICLE);
return HexParticles.CONJURE_PARTICLE;
}
@Override
public void writeToNetwork(FriendlyByteBuf buf) {
buf.writeInt(this.color);
buf.writeBoolean(this.isLight);
}
@Override
public String writeToString() {
return String.format(Locale.ROOT, "%s %s", this.color, this.isLight);
return String.format(Locale.ROOT, "%s %s", this.color);
}
public static final Deserializer<ConjureParticleOptions> DESERIALIZER = new Deserializer<>() {
@ -35,18 +34,14 @@ public record ConjureParticleOptions(int color, boolean isLight) implements Part
reader.expect(' ');
var color = reader.readInt();
reader.expect(' ');
var isLight = reader.readBoolean();
return new ConjureParticleOptions(color, isLight);
return new ConjureParticleOptions(color);
}
@Override
public ConjureParticleOptions fromNetwork(ParticleType<ConjureParticleOptions> type,
FriendlyByteBuf buf) {
var col = buf.readInt();
var isLight = buf.readBoolean();
return new ConjureParticleOptions(col, isLight);
return new ConjureParticleOptions(col);
}
};
@ -58,8 +53,7 @@ public record ConjureParticleOptions(int color, boolean isLight) implements Part
public static final Codec<ConjureParticleOptions> CODEC = RecordCodecBuilder.create(
instance -> instance.group(
Codec.INT.fieldOf("color")
.forGetter((ConjureParticleOptions o) -> o.color),
Codec.BOOL.fieldOf("isLight").forGetter(ConjureParticleOptions::isLight)
.forGetter((ConjureParticleOptions o) -> o.color)
)
.apply(instance, ConjureParticleOptions::new)
);

View file

@ -21,14 +21,16 @@ import org.spongepowered.asm.mixin.injection.callback.LocalCapture;
public abstract class MixinClientLevel {
@Inject(method = "doAnimateTick",
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;animateTick(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/util/RandomSource;)V"),
at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/Block;animateTick" +
"(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/Level;" +
"Lnet/minecraft/core/BlockPos;Lnet/minecraft/util/RandomSource;)V"),
locals = LocalCapture.CAPTURE_FAILSOFT)
public void addBuddingAmethystParticles(int $$0, int $$1, int $$2, int $$3, RandomSource rand, Block $$5,
BlockPos.MutableBlockPos pos, CallbackInfo ci, int trueX, int trueY, int trueZ, BlockState state) {
ClientLevel self = ((ClientLevel) (Object) this);
if (state.is(Blocks.BUDDING_AMETHYST)) {
ParticleOptions options = new ConjureParticleOptions(0x8932b8, true);
ParticleOptions options = new ConjureParticleOptions(0x8932b8);
Vec3 center = Vec3.atCenterOf(pos);
for (Direction direction : Direction.values()) {
int dX = direction.getStepX();

View file

@ -1,12 +0,0 @@
{
"textures": [
"minecraft:glitter_7",
"minecraft:glitter_6",
"minecraft:glitter_5",
"minecraft:glitter_4",
"minecraft:glitter_3",
"minecraft:glitter_2",
"minecraft:glitter_1",
"minecraft:glitter_0"
]
}

View file

@ -1,4 +1,4 @@
// 1.19.2 2023-02-16T14:39:33.238626068 Tags for minecraft:item
// 1.19.2 2023-02-16T15:02:55.372897302 Tags for minecraft:item
5928bad07d3872bb60f29ef4f3c885c8e1967c20 data/hexcasting/tags/items/phial_base.json
fdb48f194d7937ab6b423fa4b90a4d438bf6dd90 data/minecraft/tags/items/wooden_doors.json
e5df19a1dc6eadf14cd9b0f0fe45a74330b745e9 data/hexcasting/tags/items/edified_planks.json

View file

@ -1,4 +1,4 @@
// 1.19.2 2023-02-16T14:39:33.233974586 LootTables
// 1.19.2 2023-02-16T15:02:55.383534971 LootTables
dec1d3592e82f99d9e059d9c771530f103b2bda5 data/hexcasting/loot_tables/blocks/empty_directrix.json
2c42fc5d8c74c98ad15b8bd50f56541fccbef750 data/hexcasting/loot_tables/blocks/edified_tile.json
cfb39e2151725fe4f9a7269d9b5de8031ea54a44 data/hexcasting/loot_tables/blocks/directrix_redstone.json

View file

@ -1,4 +1,4 @@
// 1.19.2 2023-02-16T14:39:33.251128348 Tags for minecraft:block
// 1.19.2 2023-02-16T15:02:55.382692786 Tags for minecraft:block
20183cd61968ff6548df2dde1100b6378d68d64b data/minecraft/tags/blocks/wooden_buttons.json
357eddf3cee6f16725bed0701d57b2ca3097d74d data/minecraft/tags/blocks/mineable/shovel.json
5216ba5c57db29b8dee9aebc63a2e3b17c97dc17 data/minecraft/tags/blocks/wooden_trapdoors.json

View file

@ -1,4 +1,4 @@
// 1.19.2 2023-02-16T14:39:33.251726701 Tags for hexcasting:action
// 1.19.2 2023-02-16T15:02:55.371794178 Tags for hexcasting:action
e5afc567ea17f035e4eb1d1d48825100b7f6ad68 data/hexcasting/tags/action/per_world_pattern.json
e5afc567ea17f035e4eb1d1d48825100b7f6ad68 data/hexcasting/tags/action/requires_enlightenment.json
e5afc567ea17f035e4eb1d1d48825100b7f6ad68 data/hexcasting/tags/action/can_start_enlighten.json

View file

@ -1,4 +1,4 @@
// 1.19.2 2023-02-16T14:39:33.239546224 Recipes
// 1.19.2 2023-02-16T15:02:55.38732648 Recipes
9f75d3e93ecbbbf3ed9a92b2943397e09dcae1a9 data/hexcasting/recipes/dye_colorizer_light_blue.json
04569ccadfd99f203b0485d0c3e877209290f2b3 data/hexcasting/advancements/recipes/hexcasting.creative_tab/dye_colorizer_pink.json
2a9d4a0f3618abf9e9b8699b318a984d2c836913 data/hexcasting/advancements/recipes/brainsweep/brainsweep/directrix_redstone.json

View file

@ -24,7 +24,7 @@ public class FabricParticleEngineMixin {
@Inject(at = @At("RETURN"), method = "<clinit>")
private static void addTypes(CallbackInfo ci) {
RENDER_ORDER = ImmutableList.<ParticleRenderType>builder().addAll(RENDER_ORDER)
.add(ConjureParticle.CONJURE_RENDER_TYPE, ConjureParticle.LIGHT_RENDER_TYPE)
.add(ConjureParticle.CONJURE_RENDER_TYPE, ConjureParticle.CONJURE_RENDER_TYPE)
.build();
}
}