Compare commits

...
Author SHA1 Message Date
Plastered_Crab b0f0c20404 Initial testing for Shader support for our particles 2026-06-15 20:49:08 -07:00
Polymeta e15ac73b1b Merge branch 'fix-enchanted-fossil-items' into 'main'
Fix crash when using enchanted items in the ressurection machine

Closes #1973

See merge request cable-mc/cobblemon!2307
2026-06-11 21:48:56 +00:00
lion 6c6576c117 Fix crash when using enchanted items in the ressurection machine 2026-06-11 21:48:55 +00:00
Polymeta ebdfa7edc0 Merge branch 'fix-pokemon-properties-nickname-parsing-to-json' into 'main'
Add pokémon nickname when serializing and deserializing to json on pokémon properties

Closes #1981

See merge request cable-mc/cobblemon!2306
2026-06-11 13:48:21 +00:00
lion 297e8eae77 Add pokémon nickname when serializing and deserializing to json on pokémon properties 2026-06-11 13:48:21 +00:00
Polymeta ea8179018d Merge branch 'modded-discs-compat' into 'main'
Add modded discs compatibility with disc shelves

See merge request cable-mc/cobblemon!2305
2026-06-11 08:20:18 +00:00
lion 14fccfae1d Add modded discs compatibility with disc shelves 2026-06-11 08:20:18 +00:00
Polymeta 26386638ad Merge branch 'PathingThresholds' into 'main'
Fixed wider pokemon being completely unable to hop up ledges

See merge request cable-mc/cobblemon!2304
2026-06-10 08:21:01 +00:00
JazzMcNade 5d1d99b64a Rolled back jump height change 2026-06-09 23:58:44 -05:00
Polymeta eb2a5837eb Merge branch 'oops-unsynced-tms' into 'main'
Sync TM Data

See merge request cable-mc/cobblemon!2303
2026-06-09 18:35:59 +00:00
Gertimoshka 93298d9a87 Sync TM Data 2026-06-09 20:48:35 +03:00
Polymeta 4d1f46c37c remove unused config values
Signed-off-by: Polymeta <4726322-polymeta@users.noreply.gitlab.com>
2026-06-08 14:55:41 +01:00
Polymeta a2101b5759 whoops
Signed-off-by: Polymeta <4726322-polymeta@users.noreply.gitlab.com>
2026-06-08 09:29:49 +01:00
Polymeta 187a190ec6 fix size categories not working properly on servers with non-default scales
Closes #2022

Signed-off-by: Polymeta <4726322-polymeta@users.noreply.gitlab.com>
2026-06-08 09:16:57 +01:00
JazzMcNade 0d433ff394 Fixed wider pokemon being completely unable to hop up ledges
Fixed pokemon not being able to hop up snow
2026-06-07 23:26:31 -05:00
Polymeta d873399d05 Merge branch 'implement_pokemon' into 'main'
for merging when the last of the QA fixes are finished

See merge request cable-mc/cobblemon!2302
2026-06-05 08:28:27 +00:00
Polymeta 56b5dba911 Merge branch 'stoobid-aram' into 'main'
Stoobid Aram, Actually Fixed the Processor this time

See merge request cable-mc/cobblemon!2301
2026-06-04 22:51:01 +00:00
Aram f0a66458e5 Stoobid Aram, Actually Fixed the Processor this time 2026-06-05 00:31:55 +02:00
20 changed files with 322 additions and 90 deletions

No files matched your search

+2
View File
@@ -300,6 +300,7 @@
- Regional Foods will now prioritize being eaten instead of used for healing Pokémon, shift clicking will use it as healing
- Resolved Z-Fighting on Pokédex Models
- Restored Ninjask's ability to do barrel rolls
- Fixed a crash caused by adding enchanted items to the Resurrection Machine
### Fixes
- Fixed Croagunk's walkspeed
@@ -360,6 +361,7 @@
- Separated all the functions of MoLangFunctions.kt into their own files.
- Spawn buckets and their base weights are now provided by the spawner, with different base weights for world, fishing, snack, and habitat spawn buckets.
- Removed "SpawnBucket" class in favour of just storing maps of bucket names to weights.
- Fixed nicknames not being applied to Pokémon spawned from `spawn_pool_world` files
### Molang & Datapacks
- Added `moveset_builders` datapack folder for different styles of movesets.
@@ -10,16 +10,14 @@ package com.cobblemon.mod.common.mixin;
import com.cobblemon.mod.common.mixin.accessor.SinglePoolElementAccessor;
import com.cobblemon.mod.common.world.structureprocessors.HeightRangeStructureProcessor;
import com.llamalad7.mixinextras.sugar.Local;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Holder;
import net.minecraft.util.RandomSource;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.Heightmap;
import net.minecraft.world.level.levelgen.structure.Structure;
import net.minecraft.world.level.levelgen.structure.pools.JigsawPlacement;
import net.minecraft.world.level.levelgen.structure.pools.LegacySinglePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.SinglePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructurePoolElement;
import net.minecraft.world.level.levelgen.structure.pools.StructureTemplatePool;
import net.minecraft.world.level.levelgen.structure.pools.*;
import net.minecraft.world.level.levelgen.structure.pools.alias.PoolAliasLookup;
import net.minecraft.world.level.levelgen.structure.templatesystem.LiquidSettings;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessor;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureProcessorList;
import org.spongepowered.asm.mixin.Mixin;
@@ -28,24 +26,38 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.List;
import java.util.Optional;
@Mixin(JigsawPlacement.class)
public class JigsawPlacementMixin {
@Inject(
method = "addPieces*",
at = @At("HEAD"),
method = "addPieces(Lnet/minecraft/world/level/levelgen/structure/Structure$GenerationContext;Lnet/minecraft/core/Holder;Ljava/util/Optional;ILnet/minecraft/core/BlockPos;ZLjava/util/Optional;ILnet/minecraft/world/level/levelgen/structure/pools/alias/PoolAliasLookup;Lnet/minecraft/world/level/levelgen/structure/pools/DimensionPadding;Lnet/minecraft/world/level/levelgen/structure/templatesystem/LiquidSettings;)Ljava/util/Optional;",
at = @At("RETURN"),
cancellable = true
)
private static void cobblemon$cancelInvalidHeightRangeStart(
CallbackInfoReturnable<Optional<Structure.GenerationStub>> cir,
@Local(argsOnly = true, ordinal = 0) Structure.GenerationContext generationContext,
@Local(argsOnly = true, ordinal = 0) Holder<StructureTemplatePool> startPool,
@Local(argsOnly = true, ordinal = 0) BlockPos startPos
private static void onAddPieces(
Structure.GenerationContext context,
Holder<StructureTemplatePool> startPool,
Optional<ResourceLocation> startJigsawName,
int maxDepth,
BlockPos pos,
boolean useExpansionHack,
Optional<Heightmap.Types> projectStartToHeightmap,
int maxDistanceFromCenter,
PoolAliasLookup aliasLookup,
DimensionPadding dimensionPadding,
LiquidSettings liquidSettings,
CallbackInfoReturnable<Optional<Structure.GenerationStub>> cir
) {
if (cobblemon$canAnyStartElementPlace(generationContext, startPool, startPos)) {
Optional<Structure.GenerationStub> result = cir.getReturnValue();
if (result.isEmpty()) {
return;
}
BlockPos spawnPos = result.get().position();
boolean canPlace = cobblemon$canAnyStartElementPlace(context, startPool, spawnPos);
if (canPlace) {
return;
}
@@ -58,19 +70,22 @@ public class JigsawPlacementMixin {
Holder<StructureTemplatePool> startPool,
BlockPos startPos
) {
List<StructurePoolElement> elements = startPool.value().getShuffledTemplates(RandomSource.create(0L));
for (StructurePoolElement element : elements) {
for (StructurePoolElement element : startPool.value().templates) {
Optional<HeightRangeStructureProcessor> heightRangeProcessor = cobblemon$getHeightRangeProcessor(element);
if (heightRangeProcessor.isEmpty()) {
return true;
}
if (heightRangeProcessor.get().isValidPlacement(
HeightRangeStructureProcessor processor = heightRangeProcessor.get();
boolean valid = processor.isValidPlacement(
generationContext.chunkGenerator(),
generationContext.heightAccessor(),
generationContext.randomState(),
startPos
)) {
);
if (valid) {
return true;
}
}
@@ -93,5 +108,4 @@ public class JigsawPlacementMixin {
return Optional.empty();
}
}
}
@@ -308,7 +308,9 @@ object Cobblemon {
this.config.maxPokemonLevel,
this.config.maxPokemonFriendship,
this.config.maxDynamaxLevel,
this.config.unlockAllMoveDexMovesByDefault
this.config.unlockAllMoveDexMovesByDefault,
this.config.pokemonIntrinsicSizeMin,
this.config.pokemonIntrinsicSizeMax
).sendToPlayer(player)
}
@@ -131,6 +131,7 @@ import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.ChangeP
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.RequestPCBoxWallpapersPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.SetPCBoxWallpapersPacket
import com.cobblemon.mod.common.net.messages.client.storage.pc.wallpaper.UnlockPCBoxWallpaperPacket
import com.cobblemon.mod.common.net.messages.client.tms.TechnicalMachineRegistrySyncPacket
import com.cobblemon.mod.common.net.messages.client.toast.ToastPacket
import com.cobblemon.mod.common.net.messages.client.trade.TradeAcceptanceChangedPacket
import com.cobblemon.mod.common.net.messages.client.trade.TradeCancelledPacket
@@ -439,6 +440,7 @@ object CobblemonNetwork {
list.add(PacketRegisterInfo(BehaviourSyncPacket.ID, BehaviourSyncPacket::decode, DataRegistrySyncPacketHandler()))
list.add(PacketRegisterInfo(MarkRegistrySyncPacket.ID, MarkRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
list.add(PacketRegisterInfo(RideSettingsSyncPacket.ID, RideSettingsSyncPacket::decode, RideSettingsSyncHandler))
list.add(PacketRegisterInfo(TechnicalMachineRegistrySyncPacket.ID, TechnicalMachineRegistrySyncPacket::decode, DataRegistrySyncPacketHandler()))
// Effects
list.add(PacketRegisterInfo(SpawnSnowstormParticlePacket.ID, SpawnSnowstormParticlePacket::decode, SpawnSnowstormParticleHandler))
@@ -759,6 +759,7 @@ open class PokemonProperties {
shiny?.let { json.addProperty(DataKeys.POKEMON_SHINY, it) }
gender?.let { json.addProperty(DataKeys.POKEMON_GENDER, it.name) }
species?.let { json.addProperty(DataKeys.POKEMON_SPECIES_TEXT, it) }
nickname?.let { json.addProperty(DataKeys.POKEMON_NICKNAME, it.string) }
form?.let { json.addProperty(DataKeys.POKEMON_FORM_ID, it) }
friendship?.let { json.addProperty(DataKeys.POKEMON_FRIENDSHIP, it) }
fullness?.let { json.addProperty(DataKeys.POKEMON_FULLNESS, it) }
@@ -795,6 +796,7 @@ open class PokemonProperties {
shiny = json.get(DataKeys.POKEMON_SHINY)?.asBoolean
gender = json.get(DataKeys.POKEMON_GENDER)?.asString?.let { Gender.valueOf(it) }
species = json.get(DataKeys.POKEMON_SPECIES_TEXT)?.asString
nickname = json.get(DataKeys.POKEMON_NICKNAME)?.asString?.let(Component::literal)
form = json.get(DataKeys.POKEMON_FORM_ID)?.asString
friendship = json.get(DataKeys.POKEMON_FRIENDSHIP)?.asInt
fullness = json.get(DataKeys.POKEMON_FULLNESS)?.asInt
@@ -8,6 +8,7 @@
package com.cobblemon.mod.common.api.snowstorm
import com.cobblemon.mod.common.client.render.ShaderCompat
import com.mojang.blaze3d.platform.GlStateManager
import com.mojang.blaze3d.systems.RenderSystem
import com.mojang.blaze3d.vertex.BufferBuilder
@@ -27,7 +28,26 @@ object ParticleMaterials {
RenderSystem.depthMask(true)
RenderSystem.setShader { GameRenderer.getParticleShader() }
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES)
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA)
// Premultiplied-alpha blending under an active shaderpack; straight alpha otherwise.
//
// WHY: Iris shaderpacks (Complementary Unbound/Reimagined, Bliss, Photon, ...) draw these
// custom particles through their *translucent* particle program, which composites with a
// premultiplied-alpha convention. Feeding it our straight-alpha colors makes faded
// (low-alpha) particles darken toward black instead of fading toward the background — the
// "gets darker as it fades" symptom. Switching to premultiplied blend (ONE, 1-SRC_ALPHA)
// AND premultiplying the vertex color by its alpha (see SnowstormParticle.render) matches
// that convention, so the fade looks ~like vanilla. This is one pack-agnostic code path:
// it targets the shared premultiplied convention, not any single pack.
//
// SAFE FOR THE MAJORITY: with premultiplied vertex color, `ONE * (rgb*a) + (1-a)*dst`
// equals straight alpha's `a*rgb + (1-a)*dst`, so the no-shader look is byte-identical;
// the branch only diverges while a shaderpack is active.
//
// RESIDUAL LIMITATION: a pack that explicitly declares `blend.gbuffers_particles_translucent`
// re-imposes its own blend and we cannot override that; and only the vertex alpha is
// premultiplied (not the texture's per-texel alpha), so very soft sprite edges may read
// slightly brighter than vanilla. The dominant over-lifetime fade is what this corrects.
applyTranslucentBlend()
return tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE)
}
@@ -38,7 +58,20 @@ object ParticleMaterials {
override fun begin(tessellator: Tesselator, textureManager: TextureManager): BufferBuilder {
RenderSystem.enableBlend()
RenderSystem.disableCull()
RenderSystem.depthMask(true)
// Translucent (additive) particles should not write depth. With a shaderpack active
// (Iris/OptiFine) these custom render types are drawn through the pack's *translucent*
// particle program; if they also write depth they get treated as solid geometry by the
// pack's depth-dependent passes (fog, deferred lighting, translucent compositing), which
// visibly dims the additive glow — the worst-affected symptom. Dropping depth writes only
// when shaders are active keeps the vanilla (no-shader) look — used by the vast majority
// of players — byte-for-byte identical.
//
// RESIDUAL LIMITATION: the additive blendFunc below (SRC_ALPHA, ONE) is honored by Iris
// (it swaps the shader program but does not override blend for particles), but a
// shaderpack still has final authority over how its translucent particle program lights
// and composites the fragment. We route depth correctly and preserve additive blending,
// but we cannot force true additive parity against a pack that composites it otherwise.
RenderSystem.depthMask(!ShaderCompat.shadersActive())
RenderSystem.setShader { GameRenderer.getParticleShader() }
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES)
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE)
@@ -52,10 +85,15 @@ object ParticleMaterials {
override fun begin(tessellator: Tesselator, textureManager: TextureManager): BufferBuilder {
RenderSystem.enableBlend()
RenderSystem.disableCull()
RenderSystem.depthMask(true)
// See ADD above: translucent particles drop depth writes only under an active shaderpack
// so the pack's translucent pass doesn't treat them as solid. No change to the vanilla look.
RenderSystem.depthMask(!ShaderCompat.shadersActive())
RenderSystem.setShader { GameRenderer.getParticleShader() }
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES)
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA)
// Premultiplied-alpha under shaders, straight alpha otherwise — see ALPHA for the full
// rationale. Paired with the vertex-color premultiply in SnowstormParticle.render so the
// no-shader look is unchanged.
applyTranslucentBlend()
return tessellator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE)
}
@@ -75,4 +113,26 @@ object ParticleMaterials {
override fun toString() = "OPAQUE"
}
/**
* True when [material]'s vertex color must be premultiplied by its alpha before being submitted
* (see [ALPHA]). Only the alpha-composited materials need it, and only while a shaderpack is
* active; ADD is additive and OPAQUE is not blended, so neither is premultiplied. Kept here so
* the vertex path ([com.cobblemon.mod.common.client.render.SnowstormParticle.render]) and the
* blend func set in [applyTranslucentBlend] always agree on which particles are premultiplied.
*/
fun premultipliesUnderShaders(material: ParticleMaterial): Boolean =
(material == ParticleMaterial.ALPHA || material == ParticleMaterial.BLEND) && ShaderCompat.shadersActive()
/**
* Premultiplied-alpha blend (source already carries rgb*a, so source factor is ONE) while a
* shaderpack is active; vanilla straight-alpha blend otherwise. See [ALPHA] for why.
*/
private fun applyTranslucentBlend() {
if (ShaderCompat.shadersActive()) {
RenderSystem.blendFunc(GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA)
} else {
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA)
}
}
}
@@ -12,6 +12,7 @@ import com.cobblemon.mod.common.api.data.JsonDataRegistry
import com.cobblemon.mod.common.api.moves.MoveTemplate
import com.cobblemon.mod.common.api.moves.adapters.MoveTemplateAdapter
import com.cobblemon.mod.common.api.reactive.SimpleObservable
import com.cobblemon.mod.common.net.messages.client.tms.TechnicalMachineRegistrySyncPacket
import com.cobblemon.mod.common.util.adapters.TMObtainMethodAdapter
import com.cobblemon.mod.common.util.adapters.IdentifierAdapter
import com.cobblemon.mod.common.util.cobblemonResource
@@ -70,5 +71,7 @@ object TechnicalMachines : JsonDataRegistry<TechnicalMachine> {
fun getByResourceLocation(resourceLocation: ResourceLocation) = tmMap[resourceLocation]
fun getAllResourceLocations() = tmMap.keys.toSet()
override fun sync(player: ServerPlayer) {}
override fun sync(player: ServerPlayer) {
TechnicalMachineRegistrySyncPacket(tmMap.values.toList()).sendToPlayer(player)
}
}
@@ -16,24 +16,20 @@ import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.HolderLookup
import net.minecraft.core.NonNullList
import net.minecraft.core.component.DataComponents
import net.minecraft.nbt.CompoundTag
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket
import net.minecraft.sounds.SoundEvent
import net.minecraft.sounds.SoundSource
import net.minecraft.world.ContainerHelper
import net.minecraft.world.Containers
import net.minecraft.world.InteractionResult
import net.minecraft.world.ItemInteractionResult
import net.minecraft.world.WorldlyContainer
import net.minecraft.world.*
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.entity.BlockEntity
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.level.gameevent.GameEvent
import java.util.OptionalInt
import net.minecraft.world.phys.BlockHitResult
import java.util.*
import kotlin.math.pow
class DiscShelfBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(CobblemonBlockEntities.DISC_SHELF, pos, state), WorldlyContainer {
@@ -134,25 +130,7 @@ class DiscShelfBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(Cobbl
return stack.item is TechnicalMachineItem
|| stack.item == CobblemonItems.UPGRADE
|| stack.item == CobblemonItems.DUBIOUS_DISC
|| stack.item == Items.MUSIC_DISC_13
|| stack.item == Items.MUSIC_DISC_CAT
|| stack.item == Items.MUSIC_DISC_BLOCKS
|| stack.item == Items.MUSIC_DISC_CHIRP
|| stack.item == Items.MUSIC_DISC_FAR
|| stack.item == Items.MUSIC_DISC_MALL
|| stack.item == Items.MUSIC_DISC_MELLOHI
|| stack.item == Items.MUSIC_DISC_STAL
|| stack.item == Items.MUSIC_DISC_STRAD
|| stack.item == Items.MUSIC_DISC_WARD
|| stack.item == Items.MUSIC_DISC_11
|| stack.item == Items.MUSIC_DISC_WAIT
|| stack.item == Items.MUSIC_DISC_OTHERSIDE
|| stack.item == Items.MUSIC_DISC_5
|| stack.item == Items.MUSIC_DISC_RELIC
|| stack.item == Items.MUSIC_DISC_PRECIPICE
|| stack.item == Items.MUSIC_DISC_CREATOR
|| stack.item == Items.MUSIC_DISC_CREATOR_MUSIC_BOX
|| stack.item == Items.MUSIC_DISC_PIGSTEP
|| stack.has(DataComponents.JUKEBOX_PLAYABLE)
}
fun onNoteBlockPulse(level: Level, noteBlockPos: BlockPos, soundEvent: SoundEvent) {
@@ -630,7 +630,8 @@ class FossilMultiblockStructure (
result.putInt(DataKeys.ORGANIC_MATERIAL, organicMaterialInside)
val fossilInv = ListTag()
fossilInventory.forEach { fossilInv.add(ItemStack.CODEC.encodeStart(NbtOps.INSTANCE, it).orThrow) }
val ops = registryLookup.createSerializationContext(NbtOps.INSTANCE)
fossilInventory.forEach { fossilInv.add(ItemStack.CODEC.encodeStart(ops, it).getOrThrow()) }
result.put(DataKeys.FOSSIL_INVENTORY, fossilInv)
result.putString(DataKeys.CONNECTOR_DIRECTION, tankConnectorDirection?.toString())
@@ -669,7 +670,10 @@ class FossilMultiblockStructure (
val fossilInv = if (nbt.contains(DataKeys.FOSSIL_INVENTORY)) { (nbt.get(DataKeys.FOSSIL_INVENTORY) as ListTag) } else ListTag()
val actualFossilList = mutableListOf<ItemStack>()
fossilInv.forEach { ItemStack.parse(registryLookup, it).ifPresent(actualFossilList::add) }
val ops = registryLookup.createSerializationContext(NbtOps.INSTANCE)
fossilInv.forEach { ItemStack.CODEC.parse(ops, it).result().ifPresent(actualFossilList::add) }
result.fossilInventory = actualFossilList
result.tankConnectorDirection = Direction.byName(nbt.getString(DataKeys.CONNECTOR_DIRECTION))
@@ -22,6 +22,8 @@ object ServerSettingsPacketHandler : ClientNetworkPacketHandler<ServerSettingsPa
ServerSettings.maxPokemonFriendship = packet.maxPokemonFriendship
ServerSettings.maxDynamaxLevel = packet.maxDynamaxLevel
ServerSettings.unlockAllMoveDexMovesByDefault = packet.unlockAllMoveDexMovesByDefault
ServerSettings.pokemonIntrinsicSizeMin = packet.pokemonIntrinsicSizeMin
ServerSettings.pokemonIntrinsicSizeMax = packet.pokemonIntrinsicSizeMax
}
}
@@ -0,0 +1,81 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.client.render
import java.lang.reflect.Method
/**
* Detects whether a shaderpack is currently active, via Iris (Fabric/NeoForge) or OptiFine.
*
* Every reference here is reflective and fully guarded: Iris/OptiFine are optional and may be
* absent at runtime, so we never hard-reference their classes. If neither is present (or their
* APIs ever change shape) the lookups fail silently during class init and [shadersActive] simply
* returns `false`. This is the loader-safe contract the rest of the particle code relies on — it
* must work identically on Fabric and NeoForge and when no shader mod is installed at all.
*
* The reflective handles are resolved once; only the cheap boolean accessor is invoked per call.
* Particle render types call this at most a handful of times per frame (once per [begin]), so the
* cost is negligible.
*/
object ShaderCompat {
// Iris: net.irisshaders.iris.api.v0.IrisApi.getInstance().isShaderPackInUse()
// getInstance() returns a stable singleton, so it is safe to cache.
private val irisInstance: Any?
private val irisIsShaderPackInUse: Method?
// OptiFine: net.optifine.Config.isShaders() (static)
private val optifineIsShaders: Method?
init {
var irisInst: Any? = null
var irisMethod: Method? = null
try {
val irisApi = Class.forName("net.irisshaders.iris.api.v0.IrisApi")
irisInst = irisApi.getMethod("getInstance").invoke(null)
irisMethod = irisApi.getMethod("isShaderPackInUse")
} catch (ignored: Throwable) {
irisInst = null
irisMethod = null
}
irisInstance = irisInst
irisIsShaderPackInUse = irisMethod
var optifineMethod: Method? = null
try {
optifineMethod = Class.forName("net.optifine.Config").getMethod("isShaders")
} catch (ignored: Throwable) {
optifineMethod = null
}
optifineIsShaders = optifineMethod
}
/**
* `true` when Iris or OptiFine reports an active (compiled and enabled) shaderpack. Never throws;
* any reflective failure is treated as "no shaders".
*/
fun shadersActive(): Boolean {
val instance = irisInstance
val irisMethod = irisIsShaderPackInUse
if (instance != null && irisMethod != null) {
try {
if (irisMethod.invoke(instance) == true) return true
} catch (ignored: Throwable) {}
}
val optifineMethod = optifineIsShaders
if (optifineMethod != null) {
try {
if (optifineMethod.invoke(null) == true) return true
} catch (ignored: Throwable) {}
}
return false
}
}
@@ -194,6 +194,16 @@ class SnowstormParticle(
val uvs = storm.effect.particle.uvMode.get(runtime, age / 20.0, lifetime / 20.0, uvDetails)
val colour = storm.getParticleColor() ?: storm.effect.particle.tinting.getTint(runtime)
// Under an active shaderpack the alpha-composited materials use premultiplied-alpha blending
// (see ParticleMaterials.ALPHA), so the color we submit must be premultiplied by its alpha to
// match. In vanilla this branch is skipped and the straight-alpha color is sent unchanged, so
// the no-shader look is identical. ADD/OPAQUE are never premultiplied.
val alpha = colour.w
val premultiply = ParticleMaterials.premultipliesUnderShaders(storm.effect.particle.material)
val red = if (premultiply) colour.x * alpha else colour.x
val green = if (premultiply) colour.y * alpha else colour.y
val blue = if (premultiply) colour.z * alpha else colour.z
val spriteURange = sprite.u1 - sprite.u0
val spriteVRange = sprite.v1 - sprite.v0
@@ -206,22 +216,22 @@ class SnowstormParticle(
vertexConsumer
.addVertex(particleVertices[0].x, particleVertices[0].y, particleVertices[0].z)
.setUv(maxU, maxV)
.setColor(colour.x, colour.y, colour.z, colour.w)
.setColor(red, green, blue, alpha)
.setLight(p)
vertexConsumer
.addVertex(particleVertices[1].x, particleVertices[1].y, particleVertices[1].z)
.setUv(maxU, minV)
.setColor(colour.x, colour.y, colour.z, colour.w)
.setColor(red, green, blue, alpha)
.setLight(p)
vertexConsumer
.addVertex(particleVertices[2].x, particleVertices[2].y, particleVertices[2].z)
.setUv(minU, minV)
.setColor(colour.x, colour.y, colour.z, colour.w)
.setColor(red, green, blue, alpha)
.setLight(p)
vertexConsumer
.addVertex(particleVertices[3].x, particleVertices[3].y, particleVertices[3].z)
.setUv(minU, maxV)
.setColor(colour.x, colour.y, colour.z, colour.w)
.setColor(red, green, blue, alpha)
.setLight(p)
}
@@ -15,6 +15,7 @@ import com.cobblemon.mod.common.util.cobblemonResource
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.blaze3d.vertex.VertexConsumer
import com.mojang.math.Axis
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.LevelRenderer
import net.minecraft.client.renderer.MultiBufferSource
import net.minecraft.client.renderer.RenderType
@@ -39,13 +40,13 @@ class DiscShelfBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) :
private val leftMargin = 1f
private val rightMargin = 1f
private val topMargin = 1f
private val bottomMargin = 1f
private val interRowSpacing = 0f
private val tmOverlayDepthOffset = -0.0002f
private val slotBrightnessMultiplier = 0.65f
private val tmBaseTexture = cobblemonResource("textures/block/disc_shelf/technical_machine_base.png")
private val tmOverlayTexture = cobblemonResource("textures/block/disc_shelf/technical_machine_overlay.png")
private val musicDiscUnknownTexture = cobblemonResource("textures/block/disc_shelf/music_disc_unknown.png")
override fun render(
entity: DiscShelfBlockEntity,
@@ -77,7 +78,6 @@ class DiscShelfBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) :
val slotWidth = slotWidthPixels / textureSize
val slotHeight = slotHeightPixels / textureSize
val verticalSpacing = (slotHeightPixels + interRowSpacing) / textureSize
val totalHeight = slotHeight * 7 + interRowSpacing * 6 / textureSize
val startY = topMargin / textureSize
for ((index, item) in entity.items.withIndex()) {
@@ -188,6 +188,13 @@ class DiscShelfBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) :
private fun getItemTexture(itemStack: ItemStack): ResourceLocation {
val id = BuiltInRegistries.ITEM.getKey(itemStack.item)
return cobblemonResource("textures/block/disc_shelf/${id.path}.png")
val resource = cobblemonResource("textures/block/disc_shelf/${id.path}.png")
val resourceManager = Minecraft.getInstance().resourceManager
if (resourceManager.getResource(resource).isEmpty) {
return musicDiscUnknownTexture
}
return resource
}
}
@@ -28,5 +28,7 @@ object ServerSettings {
var maxPokemonFriendship = Cobblemon.config.maxPokemonFriendship
var maxDynamaxLevel = Cobblemon.config.maxDynamaxLevel
var unlockAllMoveDexMovesByDefault = Cobblemon.config.unlockAllMoveDexMovesByDefault
var pokemonIntrinsicSizeMin = Cobblemon.config.pokemonIntrinsicSizeMin
var pokemonIntrinsicSizeMax = Cobblemon.config.pokemonIntrinsicSizeMax
}
@@ -243,18 +243,6 @@ class CobblemonConfig {
@CobblemonConfigField(Category.Pokemon, lang = "pokemon_intrinsic_size_max", SERVER)
var pokemonIntrinsicSizeMax = 1.05F
@CobblemonConfigField(Category.Pokemon, lang = "alpha_pokemon_size_small_multiplier", SERVER)
var alphaPokemonSizeSmallMultiplier = 1.70F
@CobblemonConfigField(Category.Pokemon, lang = "alpha_pokemon_size_medium_multiplier", SERVER)
var alphaPokemonSizeMediumMultiplier = 1.55F
@CobblemonConfigField(Category.Pokemon, lang = "alpha_pokemon_size_large_multiplier", SERVER)
var alphaPokemonSizeLargeMultiplier = 1.40F
@CobblemonConfigField(Category.Pokemon, lang = "alpha_pokemon_size_extra_large_multiplier", SERVER)
var alphaPokemonSizeExtraLargeMultiplier = 1.25F
@CobblemonConfigField(Category.Pokemon, lang = "baby_pokemon_level_duration", SERVER)
var babyPokemonLevelDuration = 9
@@ -347,9 +335,6 @@ class CobblemonConfig {
// @CobblemonConfigField(Category.Riding, lang = "third_person_view_bobbing", CLIENT)
var thirdPersonViewBobbing = true
@CobblemonConfigField(Category.Riding, lang = "invert_roll", CLIENT)
var invertRoll = false
@CobblemonConfigField(Category.Riding, lang = "invert_pitch", CLIENT)
var invertPitch = false
@@ -365,9 +350,6 @@ class CobblemonConfig {
@CobblemonConfigField(Category.Riding, lang = "swap_x_and_y_axes", CLIENT)
var swapXAndYAxes = false
@CobblemonConfigField(Category.Riding, lang = "automatic_righting_delay", CLIENT)
var rightingDelay = -1.0
@CobblemonConfigField(Category.Riding, lang = "disable_roll", CLIENT)
var disableRoll = false
@@ -26,7 +26,9 @@ class ServerSettingsPacket internal constructor(
val maxPokemonLevel: Int,
val maxPokemonFriendship: Int,
val maxDynamaxLevel: Int,
val unlockAllMoveDexMovesByDefault: Boolean
val unlockAllMoveDexMovesByDefault: Boolean,
val pokemonIntrinsicSizeMin: Float,
val pokemonIntrinsicSizeMax: Float
) : NetworkPacket<ServerSettingsPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
@@ -37,9 +39,14 @@ class ServerSettingsPacket internal constructor(
buffer.writeInt(Cobblemon.config.maxPokemonFriendship)
buffer.writeInt(Cobblemon.config.maxDynamaxLevel)
buffer.writeBoolean(Cobblemon.config.unlockAllMoveDexMovesByDefault)
buffer.writeFloat(Cobblemon.config.pokemonIntrinsicSizeMin)
buffer.writeFloat(Cobblemon.config.pokemonIntrinsicSizeMax)
}
companion object {
val ID = cobblemonResource("server_settings")
fun decode(buffer: RegistryFriendlyByteBuf) = ServerSettingsPacket(buffer.readBoolean(), buffer.readBoolean(), buffer.readBoolean(), buffer.readInt(), buffer.readInt(), buffer.readInt(), buffer.readBoolean())
fun decode(buffer: RegistryFriendlyByteBuf) = ServerSettingsPacket(buffer.readBoolean(),
buffer.readBoolean(), buffer.readBoolean(),
buffer.readInt(), buffer.readInt(), buffer.readInt(),
buffer.readBoolean(), buffer.readFloat(), buffer.readFloat())
}
}
@@ -8,7 +8,7 @@
package com.cobblemon.mod.common.pokemon
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.client.settings.ServerSettings
enum class PokemonSizeCategory {
XS,
@@ -21,7 +21,7 @@ enum class PokemonSizeCategory {
// Find which size category corresponds to the given scale modifier.
// The scale modifier should be between the intrinsic min and max size.
fun fromScale(scaleModifier: Float): PokemonSizeCategory {
val config = Cobblemon.config
val config = ServerSettings //Don't use cobblemon config here as it will be used by server AND client
val minScale = config.pokemonIntrinsicSizeMin
val maxScale = config.pokemonIntrinsicSizeMax
val range = (maxScale - minScale).coerceAtLeast(0.0001F)
@@ -318,7 +318,7 @@ class OmniPathNodeMaker : NodeEvaluator() {
// Hitbox thing looks confusing but if the hitbox volume is more than like, 5, it starts getting pretty
// fucking slow to use the findAcceptedNodeWalk function
val strictlyWalkPathing = !canFly() && !mob.isInWater && mob.boundingBox.size < MAX_HITBOX_SIZE_FOR_WALKING
val strictlyWalkPathing = !canFly() && !mob.isInWater
val doVerticalNeighbourChecks = (canFly() || mob.isInWater) && mob.boundingBox.size < MAX_HITBOX_FOR_VERTICAL_NEIGHBOURS
// Non-diagonal surroundings in 3d space
@@ -623,9 +623,11 @@ class OmniPathNodeMaker : NodeEvaluator() {
override fun getPathTypeOfMob(pfContext: PathfindingContext, x: Int, y: Int, z: Int, mob: Mob): PathType {
val set = EnumSet.noneOf(PathType::class.java)
val sizeX = (mob.boundingBox.maxX - mob.boundingBox.minX).toInt() + 1
val sizeY = (mob.boundingBox.maxY - mob.boundingBox.minY).toInt() + 1
val sizeZ = (mob.boundingBox.maxZ - mob.boundingBox.minZ).toInt() + 1
// Capping the observed size of hitboxes here to put an upper limit on the cost of larger hitbox mobs
// Mobs larger than these caps will inevitably become stuck on obstacles as their pathing will be flawed
val sizeX = ((mob.boundingBox.maxX - mob.boundingBox.minX).toInt() + 1).coerceAtMost(2)
val sizeY = ((mob.boundingBox.maxY - mob.boundingBox.minY).toInt() + 1).coerceAtMost(3)
val sizeZ = ((mob.boundingBox.maxZ - mob.boundingBox.minZ).toInt() + 1).coerceAtMost(2)
// TODO -- This is experimental code to see if this is meaningful. We should clean this up later when time permits.
val returnedEarlyPathType = mutableListOf<PathType>()
@@ -147,6 +147,8 @@ accessible method net/minecraft/world/level/block/AbstractCandleBlock addParticl
transitive-accessible class net/minecraft/world/inventory/BrewingStandMenu$IngredientsSlot
transitive-accessible class net/minecraft/world/inventory/BrewingStandMenu$FuelSlot
transitive-accessible field net/minecraft/world/level/levelgen/structure/pools/StructureTemplatePool templates Lit/unimi/dsi/fastutil/objects/ObjectArrayList;
transitive-accessible method net/minecraft/world/level/block/Block spawnDestroyParticles (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V
transitive-accessible method net/minecraft/world/food/FoodData add (IF)V
+70
View File
@@ -8,6 +8,8 @@
*
*/
import java.net.URI
configurations.all {
resolutionStrategy {
force(libs.fabric.loader)
@@ -48,6 +50,23 @@ dependencies {
isTransitive = false
}
modLocalRuntime(libs.fabric.debugutils)
// Shader-compat testing (DEV RUNTIME ONLY — never shipped, never a real dependency).
// Lets `runClient` load Iris + Sodium so shaderpacks actually run, which is required to
// exercise ParticleMaterials' depthMask branch (see ShaderCompat). isTransitive = false so
// these don't drag in a second copy of Fabric API / FLK (already provided above). If you bump
// these, keep the Iris<->Sodium pairing valid (Iris 1.8.x needs Sodium 0.6.x for MC 1.21.1).
modLocalRuntime("maven.modrinth:iris:1.8.8+1.21.1-fabric") { isTransitive = false }
modLocalRuntime("maven.modrinth:sodium:mc1.21.1-0.6.13-fabric") { isTransitive = false }
// Iris bundles these as jar-in-jar in production, but loom doesn't add a mod's nested *libraries*
// to the dev classpath, so the dev client crashes with NoClassDefFoundError (e.g. org.anarres.cpp
// / glsl-transformer) when Iris loads a shaderpack. Supply them as plain dev-runtime libs.
// Versions are taken verbatim from iris-1.8.8's META-INF/jars — keep them in lockstep if Iris is
// bumped. localRuntime = dev runtime only, not remapped, not exported to the published jar.
localRuntime("org.anarres:jcpp:1.4.14")
localRuntime("io.github.douira:glsl-transformer:2.0.1")
localRuntime("org.antlr:antlr4-runtime:4.13.1")
modImplementation(libs.fabric.loader)
modApi(libs.fabric.api)
modApi(libs.bundles.fabric)
@@ -110,6 +129,57 @@ publishing {
}
tasks {
// Downloads the Complementary Unbound shaderpack into the dev client's shaderpacks/ folder and
// enables Iris by default, so `runClient` comes up shader-ready with zero manual setup. Both
// writes are idempotent: existing files are left untouched, so your in-game shader choice and
// any pack you swap in are preserved across runs. Run dir is "runClient" (see platform-conventions).
val setupShaderTesting by registering {
group = "cobblemon"
description = "Provisions the test shaderpacks + enables Iris for the dev runClient."
// The four Iris packs we want particles to look correct under. Swap between them in-game
// (Video Settings -> Shader Packs) to A/B the premultiplied-alpha fix in ParticleMaterials.
// <filename> to <direct Modrinth CDN url>.
//
// VERSIONS ARE PINNED FOR MC 1.21.1. The newest releases of these packs reference the
// BIOME_PALE_GARDEN uniform (Pale Garden is a 1.21.4 biome), which Iris cannot resolve on
// 1.21.1 -> hard crash building the render pipeline ("Unknown variable: BIOME_PALE_GARDEN").
// Each pin below was confirmed Pale-Garden-free by grepping the archive. If this project ever
// targets >= 1.21.4, bump these to the latest versions.
val packs = mapOf(
"ComplementaryUnbound_r5.3.zip" to "https://cdn.modrinth.com/data/R6NEzAwj/versions/CVu3AGAd/ComplementaryUnbound_r5.3.zip",
"ComplementaryReimagined_r5.3.zip" to "https://cdn.modrinth.com/data/HVnmMxH1/versions/71Hn3myZ/ComplementaryReimagined_r5.3.zip",
"Bliss_v2.1.2_(Chocapic13_Shaders_edit).zip" to "https://cdn.modrinth.com/data/ZvMtQlho/versions/kC2Y8q1P/Bliss_v2.1.2_%28Chocapic13_Shaders_edit%29.zip",
"photon_v1.1.zip" to "https://cdn.modrinth.com/data/lLqFfGNs/versions/6FdrBtKp/photon_v1.1.zip"
)
val shaderpacksDir = layout.projectDirectory.dir("runClient/shaderpacks")
val irisProps = layout.projectDirectory.file("runClient/config/iris.properties")
// Default the in-game selection to Complementary Unbound (the originally-reported pack); idempotent.
val defaultPack = "ComplementaryUnbound_r5.3.zip"
outputs.dir(shaderpacksDir)
doLast {
packs.forEach { (filename, url) ->
val zip = shaderpacksDir.file(filename).asFile
if (!zip.exists()) {
zip.parentFile.mkdirs()
logger.lifecycle("Downloading shaderpack -> ${zip.relativeTo(rootProject.projectDir)}")
URI(url).toURL().openStream().use { input ->
zip.outputStream().use { output -> input.copyTo(output) }
}
}
}
val props = irisProps.asFile
if (!props.exists()) {
props.parentFile.mkdirs()
props.writeText("enableShaders=true\nshaderPack=$defaultPack\n")
logger.lifecycle("Wrote ${props.relativeTo(rootProject.projectDir)} (Iris auto-enabled with $defaultPack).")
}
}
}
named("runClient") {
dependsOn(setupShaderTesting)
}
// The AW file is needed in :fabric project resources when the game is run.
val copyAccessWidener by registering(Copy::class) {
from(loom.accessWidenerPath)