Compare commits

..
93 changed files with 851 additions and 1330 deletions

No files matched your search

@@ -0,0 +1,119 @@
/*
* 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.mixin;
import com.cobblemon.mod.common.OrientationControllable;
import com.cobblemon.mod.common.api.orientation.OrientationController;
import com.cobblemon.mod.common.api.riding.Seat;
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate;
import com.cobblemon.mod.common.client.render.MatrixWrapper;
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState;
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel;
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix3f;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
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.Map;
@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin extends AbstractClientPlayer implements OrientationControllable {
@Shadow
private float jumpRidingScale;
public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) {
super(clientLevel, gameProfile);
}
@Inject(method = "getJumpRidingScale", at = @At("HEAD"), cancellable = true)
public void modifyJumpRidingScale(CallbackInfoReturnable<Float> cir) {
LocalPlayer player = (LocalPlayer) (Object) this;
if (player.isPassenger() && player.getVehicle() instanceof PokemonEntity pokemonEntity) {
var rideValue = pokemonEntity.<Float>ifRidingAvailableSupply(null, (behaviour, settings, state) -> {
if (behaviour.canJump(settings, state, pokemonEntity, player)) return null;
return behaviour.setRideBar(settings, state, pokemonEntity, player);
});
if (rideValue != null) {
cir.setReturnValue(rideValue);
}
}
}
@Override
public HitResult pick(double hitDistance, float partialTicks, boolean hitFluids) {
Entity vehicle = this.getVehicle();
if (vehicle instanceof PokemonEntity pokemonEntity) {
int seatIndex = pokemonEntity.getPassengers().indexOf(this);
Seat seat = pokemonEntity.getSeats().get(seatIndex);
PokemonClientDelegate delegate = (PokemonClientDelegate) pokemonEntity.getDelegate();
MatrixWrapper locator = delegate.getLocatorStates().get(seat.getLocator());
if (locator == null) {
super.pick(hitDistance, partialTicks, hitFluids);
}
Vec3 locatorOffset = new Vec3(locator.getMatrix().getTranslation(new Vector3f()));
OrientationController controller = this.getOrientationController();
float currEyeHeight = this.getEyeHeight();
Vector3f offset = new Vector3f(new Vector3f(0f, currEyeHeight - (this.getBbHeight() / 2), 0f));
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
PosableModel model = VaryingModelRepository.INSTANCE.getPoser(pokemonEntity.getPokemon().getSpecies().getResourceIdentifier(), new FloatingState());
offset.add(cobblemon$getFirstPersonOffset(model, seat));
}
Matrix3f orientation = controller.isActive() && controller.getOrientation() != null ? controller.getOrientation() : new Matrix3f();
Vec3 rotatedEyeHeight = new Vec3(orientation.transform(offset));
Vec3 eyePosition = locatorOffset.add(pokemonEntity.position()).add(rotatedEyeHeight);
Vec3 viewVector = this.getViewVector(partialTicks);
Vec3 viewDistanceVector = eyePosition.add(viewVector.x * hitDistance, viewVector.y * hitDistance, viewVector.z * hitDistance);
return this.level()
.clip(
new ClipContext(
eyePosition, viewDistanceVector, ClipContext.Block.OUTLINE, hitFluids ? net.minecraft.world.level.ClipContext.Fluid.ANY : net.minecraft.world.level.ClipContext.Fluid.NONE, this
)
);
}
return super.pick(hitDistance, partialTicks, hitFluids);
}
@Unique
private static @NotNull Vector3f cobblemon$getFirstPersonOffset(PosableModel model, Seat seat) {
Map<String, Vec3> cameraOffsets = model.getFirstPersonCameraOffset();
if (cameraOffsets.containsKey(seat.getLocator())) {
return cameraOffsets.get(seat.getLocator()).toVector3f();
} else {
return new Vector3f(0f, 0f, 0f);
}
}
}
@@ -10,51 +10,27 @@ package com.cobblemon.mod.common.mixin.client;
import com.cobblemon.mod.common.CobblemonNetwork;
import com.cobblemon.mod.common.OrientationControllable;
import com.cobblemon.mod.common.api.orientation.OrientationController;
import com.cobblemon.mod.common.api.riding.Seat;
import com.cobblemon.mod.common.client.entity.PokemonClientDelegate;
import com.cobblemon.mod.common.client.render.MatrixWrapper;
import com.cobblemon.mod.common.client.render.models.blockbench.FloatingState;
import com.cobblemon.mod.common.client.render.models.blockbench.PosableModel;
import com.cobblemon.mod.common.client.render.models.blockbench.repository.VaryingModelRepository;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.net.messages.server.orientation.ServerboundUpdateOrientationPacket;
import com.mojang.authlib.GameProfile;
import net.minecraft.client.CameraType;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.player.AbstractClientPlayer;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.level.ClipContext;
import net.minecraft.world.level.Level;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;
import org.joml.Matrix3f;
import org.joml.Vector3f;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Map;
@Mixin(LocalPlayer.class)
public abstract class LocalPlayerMixin extends AbstractClientPlayer implements OrientationControllable{
public abstract class LocalPlayerMixin extends LivingEntity {
@Unique Matrix3f cobblemon$lastOrientation;
@Shadow
private float jumpRidingScale;
public LocalPlayerMixin(ClientLevel clientLevel, GameProfile gameProfile) {
super(clientLevel, gameProfile);
protected LocalPlayerMixin(EntityType<? extends LivingEntity> entityType, Level level) {
super(entityType, level);
}
// @Inject(method = "sendPosition", at = @At("TAIL"))
@@ -100,73 +76,4 @@ public abstract class LocalPlayerMixin extends AbstractClientPlayer implements O
if (!(this instanceof OrientationControllable controllable)) return;
controllable.getOrientationController().setActive(false);
}
@Inject(method = "getJumpRidingScale", at = @At("HEAD"), cancellable = true)
public void modifyJumpRidingScale(CallbackInfoReturnable<Float> cir) {
LocalPlayer player = (LocalPlayer) (Object) this;
if (player.isPassenger() && player.getVehicle() instanceof PokemonEntity pokemonEntity) {
var rideValue = pokemonEntity.<Float>ifRidingAvailableSupply(null, (behaviour, settings, state) -> {
if (behaviour.canJump(settings, state, pokemonEntity, player)) return null;
return behaviour.setRideBar(settings, state, pokemonEntity, player);
});
if (rideValue != null) {
cir.setReturnValue(rideValue);
}
}
}
@Override
public HitResult pick(double hitDistance, float partialTicks, boolean hitFluids) {
Entity vehicle = this.getVehicle();
if (vehicle instanceof PokemonEntity pokemonEntity) {
int seatIndex = pokemonEntity.getPassengers().indexOf(this);
Seat seat = pokemonEntity.getSeats().get(seatIndex);
PokemonClientDelegate delegate = (PokemonClientDelegate) pokemonEntity.getDelegate();
MatrixWrapper locator = delegate.getLocatorStates().get(seat.getLocator());
if (locator == null) {
super.pick(hitDistance, partialTicks, hitFluids);
}
Vec3 locatorOffset = new Vec3(locator.getMatrix().getTranslation(new Vector3f()));
OrientationController controller = this.getOrientationController();
float currEyeHeight = this.getEyeHeight();
Vector3f offset = new Vector3f(new Vector3f(0f, currEyeHeight - (this.getBbHeight() / 2), 0f));
if (Minecraft.getInstance().options.getCameraType() == CameraType.FIRST_PERSON) {
PosableModel model = VaryingModelRepository.INSTANCE.getPoser(pokemonEntity.getPokemon().getSpecies().getResourceIdentifier(), new FloatingState());
offset.add(cobblemon$getFirstPersonOffset(model, seat));
}
Matrix3f orientation = controller.isActive() && controller.getOrientation() != null ? controller.getOrientation() : new Matrix3f();
Vec3 rotatedEyeHeight = new Vec3(orientation.transform(offset));
Vec3 eyePosition = locatorOffset.add(pokemonEntity.position()).add(rotatedEyeHeight);
Vec3 viewVector = this.getViewVector(partialTicks);
Vec3 viewDistanceVector = eyePosition.add(viewVector.x * hitDistance, viewVector.y * hitDistance, viewVector.z * hitDistance);
return this.level()
.clip(
new ClipContext(
eyePosition, viewDistanceVector, ClipContext.Block.OUTLINE, hitFluids ? net.minecraft.world.level.ClipContext.Fluid.ANY : net.minecraft.world.level.ClipContext.Fluid.NONE, this
)
);
}
return super.pick(hitDistance, partialTicks, hitFluids);
}
@Unique
private static @NotNull Vector3f cobblemon$getFirstPersonOffset(PosableModel model, Seat seat) {
Map<String, Vec3> cameraOffsets = model.getFirstPersonCameraOffset();
if (cameraOffsets.containsKey(seat.getLocator())) {
return cameraOffsets.get(seat.getLocator()).toVector3f();
} else {
return new Vector3f(0f, 0f, 0f);
}
}
}
@@ -78,7 +78,6 @@ import com.cobblemon.mod.common.config.constraint.IntConstraint
import com.cobblemon.mod.common.config.starter.StarterConfig
import com.cobblemon.mod.common.data.CobblemonDataProvider
import com.cobblemon.mod.common.events.AdvancementHandler
import com.cobblemon.mod.common.events.BellyHandler
import com.cobblemon.mod.common.events.FlowHandler
import com.cobblemon.mod.common.events.PokedexHandler
import com.cobblemon.mod.common.events.ServerTickHandler
@@ -285,11 +284,6 @@ object Cobblemon {
event.newFriendship = event.pokemon.friendship + increment.roundToInt()
}
CobblemonEvents.FULLNESS_UPDATED.subscribe(Priority.LOWEST) { event ->
event.newFullness = event.newFullness.coerceAtMost(100)
}
HeldItemProvider.register(CobblemonHeldItemManager, Priority.LOWEST)
}
@@ -760,8 +760,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val FINE_REMEDY = create("fine_remedy", RemedyItem(RemedyItem.FINE))
@JvmField
val SUPERB_REMEDY = create("superb_remedy", RemedyItem(RemedyItem.SUPERB))
@JvmField
val MOOMOO_MILK = create("moomoo_milk", Item(Item.Properties()))
@JvmField
val POTION = create("potion", PotionItem(PotionType.POTION))
@@ -259,7 +259,6 @@ object CobblemonNetwork {
// Pokemon Update Packets
list.add(PacketRegisterInfo(FriendshipUpdatePacket.ID, FriendshipUpdatePacket::decode, PokemonUpdatePacketHandler()))
list.add(PacketRegisterInfo(FullnessUpdatePacket.ID, FullnessUpdatePacket::decode, PokemonUpdatePacketHandler()))
list.add(PacketRegisterInfo(MoveSetUpdatePacket.ID, MoveSetUpdatePacket::decode, PokemonUpdatePacketHandler()))
list.add(PacketRegisterInfo(NatureUpdatePacket.ID, NatureUpdatePacket::decode, PokemonUpdatePacketHandler()))
list.add(PacketRegisterInfo(ShinyUpdatePacket.ID, ShinyUpdatePacket::decode, PokemonUpdatePacketHandler()))
@@ -125,7 +125,6 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
@JvmField
val MOCHI_USE = this.create("item.medicine.feather.use")
@JvmField
val MULCH_PLACE = this.create("block.mulch.place")
@JvmField
@@ -217,8 +216,6 @@ object CobblemonSounds : PlatformRegistry<Registry<SoundEvent>, ResourceKey<Regi
val BERRY_HARVEST = this.create("block.berry_bush.harvest")
@JvmField
val BERRY_EAT = this.create("item.berry.eat")
@JvmField
val BERRY_EAT_FULL = this.create("item.berry.eat.full")
@JvmField
val BIG_ROOT_BREAK = this.create("block.big_root.break")
@@ -0,0 +1,24 @@
/*
* 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.api.cooking
import com.mojang.serialization.Codec
import com.mojang.serialization.codecs.RecordCodecBuilder
data class MobCookingEffects(
val appliedEffects: List<SerializableMobEffectInstance> = emptyList()
) {
companion object {
val CODEC: Codec<MobCookingEffects> = RecordCodecBuilder.create { builder ->
builder.group(
SerializableMobEffectInstance.CODEC.listOf().optionalFieldOf("appliedEffects", emptyList()).forGetter { it.appliedEffects }
).apply(builder, ::MobCookingEffects)
}
}
}
@@ -29,21 +29,21 @@ data class Seasoning(
@SerializedName("colour", alternate = ["color"])
val colour: DyeColor,
@SerializedName("baitEffects")
val baitEffects: List<SpawnBait.Effect>? = null,
val baitEffects: List<SpawnBait.Effect> = emptyList(),
@SerializedName("food")
val food: Food? = null,
@SerializedName("mobEffects")
val mobEffects: List<SerializableMobEffectInstance>? = null
val mobEffects: MobCookingEffects? = null
) {
companion object {
val CODEC: Codec<Seasoning> = RecordCodecBuilder.create { builder ->
builder.group(
ITEM_REGISTRY_LIKE_CODEC.fieldOf("ingredient").forGetter { it.ingredient },
Codec.unboundedMap(Flavour.CODEC, Codec.INT).optionalFieldOf("flavours", null).forGetter { it.flavours },
Codec.unboundedMap(Flavour.CODEC, Codec.INT).fieldOf("flavours").forGetter { it.flavours }, // Use map codec
DyeColor.CODEC.fieldOf("colour").forGetter { it.colour },
SpawnBait.Effect.CODEC.listOf().optionalFieldOf("baitEffects", null).forGetter { it.baitEffects },
Food.CODEC.optionalFieldOf("food", null).forGetter { it.food },
SerializableMobEffectInstance.CODEC.listOf().optionalFieldOf("mobEffects", null).forGetter { it.mobEffects }
SpawnBait.Effect.CODEC.listOf().optionalFieldOf("baitEffects", emptyList()).forGetter { it.baitEffects },
Food.CODEC.optionalFieldOf("food", Food(0, 0f)).forGetter { it.food ?: Food(0, 0f) },
MobCookingEffects.CODEC.optionalFieldOf("mobEffects", MobCookingEffects()).forGetter { it.mobEffects ?: MobCookingEffects() }
).apply(builder, ::Seasoning)
}
@@ -51,11 +51,11 @@ data class Seasoning(
val BLANK_SEASONING = Seasoning(
ingredient = RegistryLikeIdentifierCondition<Item>(cobblemonResource("blank")),
flavours = Flavour.entries.associateWith { 0 },
flavours = Flavour.entries.associate { it to 0 },
colour = DyeColor.WHITE,
baitEffects = emptyList(),
food = Food(),
mobEffects = emptyList()
mobEffects = MobCookingEffects()
)
}
}
@@ -12,7 +12,6 @@ import com.cobblemon.mod.common.CobblemonItemComponents
import com.cobblemon.mod.common.api.berry.Berries
import com.cobblemon.mod.common.api.conditional.RegistryLikeCondition
import com.cobblemon.mod.common.api.conditional.RegistryLikeIdentifierCondition
import com.cobblemon.mod.common.api.cooking.Seasoning.Companion.BLANK_SEASONING
import com.cobblemon.mod.common.api.data.JsonDataRegistry
import com.cobblemon.mod.common.api.fishing.SpawnBait
import com.cobblemon.mod.common.api.reactive.SimpleObservable
@@ -44,6 +43,14 @@ object Seasonings : JsonDataRegistry<Seasoning> {
val seasonings = mutableListOf<Seasoning>()
val BLANK_SEASONING = Seasoning(
ingredient = RegistryLikeIdentifierCondition<Item>(cobblemonResource("blank")),
flavours = emptyMap(),
colour = DyeColor.WHITE,
food = Food(),
mobEffects = MobCookingEffects()
)
override fun sync(player: ServerPlayer) {
SeasoningRegistrySyncPacket(seasonings.toList()).sendToPlayer(player)
}
@@ -57,7 +64,7 @@ object Seasonings : JsonDataRegistry<Seasoning> {
colour = it.colour,
baitEffects = emptyList(),
food = Food(),
mobEffects = emptyList()
mobEffects = MobCookingEffects()
)
}.toMutableMap()
finalData.putAll(data)
@@ -89,12 +96,13 @@ object Seasonings : JsonDataRegistry<Seasoning> {
return effects.hunger > 0 || effects.saturation > 0f
}
fun getMobEffectsFromItemStack(stack: ItemStack): List<SerializableMobEffectInstance> {
return getFromItemStack(stack)?.mobEffects ?: emptyList()
fun getMobEffectFromItemStack(stack: ItemStack): MobCookingEffects? {
return getFromItemStack(stack)?.mobEffects
}
fun hasMobEffect(stack: ItemStack): Boolean {
return !getFromItemStack(stack)?.mobEffects.isNullOrEmpty()
val effects = getFromItemStack(stack)?.mobEffects ?: return false
return effects.appliedEffects.isNotEmpty()
}
fun getBaitEffectsFromItemStack(stack: ItemStack): List<SpawnBait.Effect> {
@@ -72,8 +72,6 @@ object CobblemonEvents {
@JvmField
val FRIENDSHIP_UPDATED = EventObservable<FriendshipUpdatedEvent>()
@JvmField
val FULLNESS_UPDATED = EventObservable<FullnessUpdatedEvent>()
@JvmField
val POKEMON_FAINTED = EventObservable<PokemonFaintedEvent>()
@JvmField
val EVOLUTION_ACCEPTED = CancelableObservable<EvolutionAcceptedEvent>()
@@ -1,17 +0,0 @@
package com.cobblemon.mod.common.api.events.pokemon
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.pokemon.Pokemon
/**
* Event that is fired when a player owned Pokémon has its fullness changed
*/
data class FullnessUpdatedEvent(
val pokemon: Pokemon,
val newFullnessInitial: Int
) {
var newFullness: Int = newFullnessInitial
set(value) {
field = value.coerceIn(0, pokemon.getMaxFullness())
}
}
@@ -85,7 +85,7 @@ object SpawnBaitEffects : JsonDataRegistry<SpawnBait> {
(it.ingredient as RegistryLikeIdentifierCondition<Item>).identifier.path == identifier.path
}
if (seasoning != null && !seasoning.baitEffects.isNullOrEmpty()) {
if (seasoning != null && seasoning.baitEffects.isNotEmpty()) {
return SpawnBait(
item = seasoning.ingredient,
effects = seasoning.baitEffects
@@ -12,7 +12,6 @@ import com.cobblemon.mod.common.advancement.CobblemonCriteria
import com.cobblemon.mod.common.advancement.criterion.PokemonInteractContext
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.callback.PartySelectCallbacks
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
import com.cobblemon.mod.common.api.text.red
import com.cobblemon.mod.common.battles.BagItemActionResponse
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
@@ -131,20 +130,12 @@ interface PokemonSelectingItem {
canSelect = { pk -> canUseOnPokemon(stack, pk) },
handler = { pk ->
if (stack.isHeld(player)) {
if (stack.`is`(CobblemonItemTags.POKE_FOOD)) {
if (!pk.isFull()) {
applyToPokemon(player, stack, pk)
CobblemonCriteria.POKEMON_INTERACT.trigger(player, PokemonInteractContext(pk.species.resourceIdentifier, BuiltInRegistries.ITEM.getKey(stack.item)))
}
} else {
applyToPokemon(player, stack, pk)
CobblemonCriteria.POKEMON_INTERACT.trigger(player, PokemonInteractContext(pk.species.resourceIdentifier, BuiltInRegistries.ITEM.getKey(stack.item)))
}
applyToPokemon(player, stack, pk)
CobblemonCriteria.POKEMON_INTERACT.trigger(player, PokemonInteractContext(pk.species.resourceIdentifier, BuiltInRegistries.ITEM.getKey(stack.item)))
}
}
)
return InteractionResultHolder.success(stack)
}
@@ -67,7 +67,6 @@ object CobblemonItemTags {
@JvmField val POKE_RODS = create("poke_rods")
@JvmField val POKEDEX = create("pokedex")
@JvmField val POKEDEX_SCREEN = create("pokedex_screen")
@JvmField val POKE_FOOD = create("poke_food")
@JvmField val POTIONS = create("potions")
@JvmField val PROTEIN_INGREDIENTS = create("protein_ingredients")
/** See [COOKED_MEAT] */
@@ -12,7 +12,6 @@ import com.cobblemon.mod.common.block.entity.CakeBlockEntity
import com.cobblemon.mod.common.item.components.FoodColourComponent
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.DyeColor
@@ -21,53 +20,33 @@ import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.BaseEntityBlock
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.Rotation
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.DirectionProperty
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.VoxelShape
abstract class CakeBlock(settings: Properties): BaseEntityBlock(settings) {
companion object {
val FACING: DirectionProperty = DirectionProperty.create("facing", Direction.Plane.HORIZONTAL)
val SHAPE_BY_BITE = arrayOf(
box(1.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(3.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(5.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(7.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(9.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(11.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(13.0, 0.0, 1.0, 15.0, 9.0, 15.0)
box(1.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(3.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(5.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(7.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(9.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(11.0, 0.0, 1.0, 15.0, 9.0, 15.0),
box(13.0, 0.0, 1.0, 15.0, 9.0, 15.0)
)
enum class Rotation {
NONE,
CLOCKWISE_90,
CLOCKWISE_180,
COUNTERCLOCKWISE_90
}
}
init {
registerDefaultState(stateDefinition.any().setValue(FACING, Direction.NORTH))
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
super.createBlockStateDefinition(builder)
builder.add(FACING)
}
override fun setPlacedBy(level: Level, pos: BlockPos, state: BlockState, placer: LivingEntity?, stack: ItemStack) {
override fun setPlacedBy(
level: Level,
pos: BlockPos,
state: BlockState,
placer: LivingEntity?,
stack: ItemStack
) {
super.setPlacedBy(level, pos, state, placer, stack)
if (placer != null) {
level.setBlock(pos, state.setValue(FACING, placer.direction.opposite), 2)
}
val blockEntity = level.getBlockEntity(pos) as? CakeBlockEntity
blockEntity?.initializeFromItemStack(stack)
}
@@ -78,60 +57,19 @@ abstract class CakeBlock(settings: Properties): BaseEntityBlock(settings) {
}
override fun getShape(
state: BlockState,
level: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape {
val bites = getBites(level, pos)
val blockEntity = level.getBlockEntity(pos) as? CakeBlockEntity
val maxBites = blockEntity?.maxBites ?: 6
val visualStage = ((bites * SHAPE_BY_BITE.size) / (maxBites + 1))
.coerceIn(0, SHAPE_BY_BITE.lastIndex)
val baseShape = SHAPE_BY_BITE[visualStage]
return when (state.getValue(FACING)) {
Direction.NORTH -> baseShape
Direction.SOUTH -> rotateShape(baseShape, Rotation.CLOCKWISE_180)
Direction.WEST -> rotateShape(baseShape, Rotation.COUNTERCLOCKWISE_90)
Direction.EAST -> rotateShape(baseShape, Rotation.CLOCKWISE_90)
else -> baseShape
}
}
private fun rotateShape(shape: VoxelShape, rotation: Rotation): VoxelShape {
var newShape = net.minecraft.world.phys.shapes.Shapes.empty()
for (box in shape.toAabbs()) {
val minX = box.minX
val minY = box.minY
val minZ = box.minZ
val maxX = box.maxX
val maxY = box.maxY
val maxZ = box.maxZ
val (rMinX, rMinZ, rMaxX, rMaxZ) = when (rotation) {
Rotation.NONE -> arrayOf(minX, minZ, maxX, maxZ)
Rotation.CLOCKWISE_90 -> arrayOf(minZ, 1.0 - maxX, maxZ, 1.0 - minX)
Rotation.CLOCKWISE_180 -> arrayOf(1.0 - maxX, 1.0 - maxZ, 1.0 - minX, 1.0 - minZ)
Rotation.COUNTERCLOCKWISE_90 -> arrayOf(1.0 - maxZ, minX, 1.0 - minZ, maxX)
}
val rotatedVoxel = net.minecraft.world.phys.shapes.Shapes.box(rMinX, minY, rMinZ, rMaxX, maxY, rMaxZ)
newShape = net.minecraft.world.phys.shapes.Shapes.or(newShape, rotatedVoxel)
}
return newShape
state: BlockState,
level: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape? {
return SHAPE_BY_BITE[getBites(level, pos)]
}
override fun spawnDestroyParticles(
level: Level,
player: Player,
pos: BlockPos,
state: BlockState
level: Level,
player: Player,
pos: BlockPos,
state: BlockState
) {
val blockEntity = level.getBlockEntity(pos) as? CakeBlockEntity
val color = blockEntity?.foodColourComponent?.colours?.lastOrNull()
@@ -162,7 +100,5 @@ abstract class CakeBlock(settings: Properties): BaseEntityBlock(settings) {
}
fun getBites(level: BlockGetter, pos: BlockPos): Int = (level.getBlockEntity(pos) as? CakeBlockEntity)?.bites ?: 0
fun setBites(level: BlockGetter, pos: BlockPos, bites: Int) {
(level.getBlockEntity(pos) as? CakeBlockEntity)?.bites = bites
}
fun setBites(level: BlockGetter, pos: BlockPos, bites: Int) = (level.getBlockEntity(pos) as? CakeBlockEntity)?.bites = bites
}
@@ -86,14 +86,15 @@ class CandlePokeCakeBlock(settings: Properties) : CakeBlock(settings) {
)
}
override fun codec(): MapCodec<out BaseEntityBlock?> {
override fun codec(): MapCodec<out BaseEntityBlock?>? {
return simpleCodec(::CandlePokeCakeBlock)
}
override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity {
override fun newBlockEntity(pos: BlockPos, state: BlockState): BlockEntity? {
return CandlePokeCakeBlockEntity(pos, state)
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block?, BlockState?>) {
super.createBlockStateDefinition(builder)
builder.add(LIT, CANDLE_COLOR)
}
@@ -106,7 +107,7 @@ class CandlePokeCakeBlock(settings: Properties) : CakeBlock(settings) {
player: Player,
hand: InteractionHand,
hitResult: BlockHitResult
): ItemInteractionResult {
): ItemInteractionResult? {
return if (!stack.`is`(Items.FLINT_AND_STEEL) && !stack.`is`(Items.FIRE_CHARGE)) {
if (candleHit(hitResult) && stack.isEmpty && state.getValue(LIT) == true) {
extinguish(player, state, level, pos)
@@ -133,7 +134,7 @@ class CandlePokeCakeBlock(settings: Properties) : CakeBlock(settings) {
pos: BlockPos,
player: Player,
hitResult: BlockHitResult
): InteractionResult {
): InteractionResult? {
val oldCookingComponent = getFoodColourComponent(level, pos)
val candle = getCandleByMapColorId(state.getValue(CANDLE_COLOR))
@@ -174,5 +175,5 @@ class CandlePokeCakeBlock(settings: Properties) : CakeBlock(settings) {
level: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape = SHAPE
): VoxelShape? = SHAPE
}
@@ -35,7 +35,7 @@ import net.minecraft.world.level.gameevent.GameEvent
import net.minecraft.world.phys.BlockHitResult
class PokeCakeBlock(settings: Properties): CakeBlock(settings) {
override fun codec(): MapCodec<out BaseEntityBlock?> {
override fun codec(): MapCodec<out BaseEntityBlock?>? {
return simpleCodec(::PokeCakeBlock)
}
@@ -62,7 +62,7 @@ class PokeCakeBlock(settings: Properties): CakeBlock(settings) {
pos: BlockPos,
player: Player,
hitResult: BlockHitResult
): InteractionResult {
): InteractionResult? {
if (level.isClientSide) {
if (eat(level, pos, player).consumesAction()) {
return InteractionResult.SUCCESS
@@ -84,7 +84,7 @@ class PokeCakeBlock(settings: Properties): CakeBlock(settings) {
player: Player,
hand: InteractionHand,
hitResult: BlockHitResult
): ItemInteractionResult {
): ItemInteractionResult? {
val item = stack.item
val block = state.block as? PokeCakeBlock
@@ -343,9 +343,16 @@ class BerryBlockEntity(pos: BlockPos, state: BlockState) : BlockEntity(Cobblemon
world.setBlock(pos, newState, UPDATE_CLIENTS)
world.gameEvent(player, GameEvent.BLOCK_CHANGE, pos)
resetGrowTimers(pos, newState)
return
// Notify top block too since we want observers to work there too
val abovePos = pos.above()
val aboveState = world.getBlockState(abovePos)
if (!aboveState.isAir) {
world.sendBlockUpdated(abovePos, aboveState, aboveState, Block.UPDATE_CLIENTS)
}
}
//Using a similar approach to ComputerCraft, implement this client side
interface RenderState : AutoCloseable {
var needsRebuild: Boolean
@@ -115,7 +115,7 @@ open class CakeBlockEntity(
return ClientboundBlockEntityDataPacket.create(this)
}
override fun getUpdateTag(registries: HolderLookup.Provider): CompoundTag {
override fun getUpdateTag(registries: HolderLookup.Provider): CompoundTag? {
val tag = CompoundTag()
saveAdditional(tag, registries)
return tag
@@ -70,7 +70,6 @@ class StatWidget(
private val statsOtherBaseResource = cobblemonResource("textures/gui/summary/summary_stats_other_base.png")
private val statsOtherBarTemplate = cobblemonResource("textures/gui/summary/summary_stats_other_bar.png")
private val friendshipOverlayResource = cobblemonResource("textures/gui/summary/summary_stats_friendship_overlay.png")
private val fullnessOverlayResource = cobblemonResource("textures/gui/summary/summary_stats_fullness_overlay.png")
private val tabMarkerResource = cobblemonResource("textures/gui/summary/summary_stats_tab_marker.png")
private val statIncreaseResource = cobblemonResource("textures/gui/summary/summary_stats_icon_increase.png")
private val statDecreaseResource = cobblemonResource("textures/gui/summary/summary_stats_icon_decrease.png")
@@ -252,79 +251,6 @@ class StatWidget(
)
}
private fun drawFullness(moduleX: Int, moduleY: Int, matrices: PoseStack, context: GuiGraphics, pokemon: Pokemon) {
val currentFullness = pokemon.currentFullness
val maxFullness = pokemon.getMaxFullness()
val barRatio = currentFullness.toFloat() / maxFullness.toFloat()
val barWidth = ceil(barRatio * 108)
blitk(
matrixStack = matrices,
texture = statsOtherBarTemplate,
x = moduleX,
y = moduleY,
height = 28,
width = 124
)
val (red, green, blue) = when {
barRatio <= 0.33 -> Triple(0f, 1f, 0f) // Green (full green)
barRatio <= 0.66 -> Triple(1f, 1f, 0f) // Yellow (red + green)
else -> Triple(1f, 0f, 0f) // Red (full red)
}
blitk(
matrixStack = matrices,
texture = CobblemonResources.WHITE,
x = moduleX + 8,
y = moduleY + 18,
height = 8,
width = barWidth,
red = red,
green = green,
blue = blue
)
// Draw the overlay
blitk(
matrixStack = matrices,
texture = fullnessOverlayResource,
x = moduleX / SCALE,
y = (moduleY + 16) / SCALE,
height = 20,
width = 248,
scale = SCALE
)
drawScaledText(
context = context,
font = CobblemonResources.DEFAULT_LARGE,
text = "Fullness".text().bold(),
x = moduleX + 62,
y = moduleY + 2.5,
centered = true,
shadow = true
)
drawScaledText(
context = context,
text = currentFullness.toString().text(),
x = moduleX + 11,
y = moduleY + 6,
scale = SCALE,
centered = true
)
drawScaledText(
context = context,
text = "${floor(barRatio * 100)}%".text(),
x = moduleX + 113,
y = moduleY + 6,
scale = SCALE,
centered = true
)
}
override fun renderWidget(context: GuiGraphics, pMouseX: Int, pMouseY: Int, pPartialTicks: Float) {
val renderChart = statOptions.get(statTabIndex) != OTHER
val matrices = context.pose()
@@ -465,9 +391,6 @@ class StatWidget(
drawFriendship(x + 5, drawY, matrices, context, pokemon.friendship)
drawY += 30
drawFullness(x + 5, drawY, matrices, context, pokemon)
drawY += 30
for (renderableFeature in renderableFeatures) {
val rendered = renderableFeature.render(
GuiGraphics = context,
@@ -8,7 +8,6 @@
package com.cobblemon.mod.common.client.render.block
import com.cobblemon.mod.common.block.CakeBlock
import com.cobblemon.mod.common.block.entity.CakeBlockEntity
import com.cobblemon.mod.common.item.components.FoodColourComponent
import com.cobblemon.mod.common.util.cobblemonResource
@@ -22,7 +21,6 @@ import net.minecraft.client.renderer.RenderType
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider
import net.minecraft.client.renderer.texture.TextureAtlasSprite
import net.minecraft.core.Direction
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.inventory.InventoryMenu.BLOCK_ATLAS
import org.joml.Vector3d
@@ -41,41 +39,41 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
object DefaultCakeLayout : CakeLayout {
override val topLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_top_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_top_layer3", LayerColor.PRIMARY),
CakeTexture("poke_snack_top_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_top_layer3", LayerColor.PRIMARY),
)
override val sideLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_side_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_side_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_side_layer3", LayerColor.PRIMARY),
CakeTexture("poke_snack_side_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_side_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_side_layer3", LayerColor.PRIMARY),
)
override val bottomLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_bottom_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_bottom_layer1", LayerColor.TERTIARY),
)
override val innerLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_inner_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_inner_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_inner_layer3", LayerColor.PRIMARY),
CakeTexture("poke_snack_inner_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_inner_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_inner_layer3", LayerColor.PRIMARY),
)
}
object HeartCakeLayout : CakeLayout {
override val topLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_top_layer4", LayerColor.SECONDARY),
CakeTexture("poke_snack_top_layer5", LayerColor.PRIMARY),
CakeTexture("poke_snack_top_layer4", LayerColor.SECONDARY),
CakeTexture("poke_snack_top_layer5", LayerColor.PRIMARY),
)
override val sideLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_side_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_side_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_side_layer3", LayerColor.PRIMARY),
CakeTexture("poke_snack_side_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_side_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_side_layer3", LayerColor.PRIMARY),
)
override val bottomLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_bottom_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_bottom_layer1", LayerColor.TERTIARY),
)
override val innerLayers: List<CakeTexture> = mutableListOf(
CakeTexture("poke_snack_inner_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_inner_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_inner_layer3", LayerColor.PRIMARY),
CakeTexture("poke_snack_inner_layer1", LayerColor.TERTIARY),
CakeTexture("poke_snack_inner_layer2", LayerColor.SECONDARY),
CakeTexture("poke_snack_inner_layer3", LayerColor.PRIMARY),
)
}
@@ -111,37 +109,37 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
}
override fun render(
blockEntity: CakeBlockEntity,
partialTick: Float,
poseStack: PoseStack,
bufferSource: MultiBufferSource,
packedLight: Int,
packedOverlay: Int
blockEntity: CakeBlockEntity,
partialTick: Float,
poseStack: PoseStack,
bufferSource: MultiBufferSource,
packedLight: Int,
packedOverlay: Int
) {
val foodColourComponent = blockEntity.foodColourComponent
renderCake(blockEntity, foodColourComponent, poseStack, bufferSource, packedLight, blockEntity.bites)
}
fun renderCake(
blockEntity: CakeBlockEntity,
foodColourComponent: FoodColourComponent?,
poseStack: PoseStack,
multiBufferSource: MultiBufferSource,
light: Int,
bites: Int,
blockEntity: CakeBlockEntity,
foodColourComponent: FoodColourComponent?,
poseStack: PoseStack,
multiBufferSource: MultiBufferSource,
light: Int,
bites: Int,
) {
val seedString = foodColourComponent?.colours?.joinToString()
val random = Random(seedString.hashCode())
val cakeLayout: CakeLayout = CAKE_LAYOUTS[random.nextInt(CAKE_LAYOUTS.size)]
val visualStages = 7f
val maxBites = blockEntity.maxBites.toFloat()
val bitesPerStage = ((maxBites + 1) / visualStages).coerceAtLeast(1f)
val visualStage = (bites / bitesPerStage).toInt().coerceIn(0, visualStages.toInt() - 1)
val biteOffset = (15f - 2f * visualStage) / 16f
val clippedWidth = (ATLAS_END - ATLAS_START) * biteOffset
val visualSegments = 7f
val segmentIndex = (bites.toFloat() / blockEntity.maxBites.toFloat()) * visualSegments
val segmentsRemaining = visualSegments - segmentIndex
val percentageToRender = segmentsRemaining / visualSegments
val clippedWidth = (ATLAS_END - ATLAS_START) * percentageToRender
val topLayer = cakeLayout.topLayers.first().texture
val uClipped = topLayer.u0 + (topLayer.u1 - topLayer.u0) * biteOffset
val uClipped = topLayer.u0 + (topLayer.u1 - topLayer.u0) * percentageToRender
val vertexConsumer = multiBufferSource.getBuffer(RenderType.cutout())
val primaryColor = foodColourComponent?.colours?.getOrNull(0)?.textureDiffuseColor ?: WHITE_OPAQUE_COLOR
@@ -150,42 +148,33 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
poseStack.pushPose()
poseStack.translate(0.5, 0.5, 0.5)
val facing = blockEntity.blockState.getValue(CakeBlock.FACING)
val angle = when (facing) {
Direction.NORTH -> 180f
Direction.SOUTH -> 0f
Direction.WEST -> 90f
Direction.EAST -> -90f
else -> 0f
}
poseStack.mulPose(Axis.YP.rotationDegrees(angle))
poseStack.mulPose(Axis.YP.rotationDegrees(180f))
poseStack.translate(-0.5, -0.5, -0.5)
poseStack.pushPose()
for (layer in cakeLayout.topLayers) {
val texture = layer.texture
drawQuad(
vertexConsumer, poseStack,
ATLAS_START, TOP_LAYER_HEIGHT, ATLAS_START, clippedWidth, TOP_LAYER_HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
ATLAS_START, TOP_LAYER_HEIGHT, ATLAS_START, clippedWidth, TOP_LAYER_HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
poseStack.popPose()
val translations = arrayOf(
Vector3d(-1.0, 1.0, 0.5 - PIXEL_SHIFT),
Vector3d(0.0, 1.0, 0.5 - PIXEL_SHIFT),
Vector3d(0.0, 1.0, -0.5 - PIXEL_SHIFT),
Vector3d(-1.0, 1.0, -0.5 - PIXEL_SHIFT),
Vector3d(-1.0, 1.0, 0.5 - PIXEL_SHIFT),
Vector3d(0.0, 1.0, 0.5 - PIXEL_SHIFT),
Vector3d(0.0, 1.0, -0.5 - PIXEL_SHIFT),
Vector3d(-1.0, 1.0, -0.5 - PIXEL_SHIFT),
)
val rotationsY = arrayOf(
Axis.YP.rotationDegrees(90f),
Axis.YP.rotationDegrees(0f),
Axis.YP.rotationDegrees(-90f),
Axis.YP.rotationDegrees(-180f)
Axis.YP.rotationDegrees(90f),
Axis.YP.rotationDegrees(0f),
Axis.YP.rotationDegrees(-90f),
Axis.YP.rotationDegrees(-180f)
)
val cakeIsFull = bites == 0
@@ -197,47 +186,47 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
poseStack.mulPose(Axis.XP.rotationDegrees(90f))
if (i == 0 && !cakeIsFull) {
poseStack.translate(0.0, -visualStage * PIXEL_SHIFT * 2, 0.0)
poseStack.translate(0.0, -bites * PIXEL_SHIFT * 2, 0.0)
for (layer in cakeLayout.innerLayers) {
val texture = layer.texture
drawQuad(
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
texture.u0, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
texture.u0, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
} else if (i == 0 || i == 1) {
for (layer in cakeLayout.sideLayers) {
val texture = layer.texture
drawQuad(
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, clippedWidth, HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, clippedWidth, HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
} else if (i == 2) {
for (layer in cakeLayout.sideLayers) {
val texture = layer.texture
drawQuad(
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
texture.u0, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
ATLAS_START, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
texture.u0, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
} else if (i == 3) {
val clippedStartX = ATLAS_START + (ATLAS_END - ATLAS_START) * (1 - biteOffset)
val clippedStartX = ATLAS_START + (ATLAS_END - ATLAS_START) * (1 - percentageToRender)
for (layer in cakeLayout.sideLayers) {
val texture = layer.texture
val clippedUStart = texture.u0 + (texture.u1 - texture.u0) * (1 - biteOffset)
val clippedUStart = texture.u0 + (texture.u1 - texture.u0) * (1 - percentageToRender)
drawQuad(
vertexConsumer, poseStack,
clippedStartX, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
clippedUStart, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
clippedStartX, HEIGHT, ATLAS_START, ATLAS_END, HEIGHT, ATLAS_END,
clippedUStart, texture.v0, texture.u1, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
}
@@ -253,10 +242,10 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
for (layer in cakeLayout.bottomLayers) {
val texture = layer.texture
drawQuad(
vertexConsumer, poseStack,
ATLAS_START, BOTTOM_LAYER_HEIGHT, ATLAS_START, clippedWidth, BOTTOM_LAYER_HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
vertexConsumer, poseStack,
ATLAS_START, BOTTOM_LAYER_HEIGHT, ATLAS_START, clippedWidth, BOTTOM_LAYER_HEIGHT, ATLAS_END,
texture.u0, texture.v0, uClipped, texture.v1,
light, layer.getColor(primaryColor, secondaryColor, tertiaryColor)
)
}
@@ -266,12 +255,12 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
}
private fun drawQuad(
builder: VertexConsumer,
poseStack: PoseStack,
x0: Float, y0: Float, z0: Float,
x1: Float, y1: Float, z1: Float,
u0: Float, v0: Float, u1: Float, v1: Float,
packedLight: Int, color: Int,
builder: VertexConsumer,
poseStack: PoseStack,
x0: Float, y0: Float, z0: Float,
x1: Float, y1: Float, z1: Float,
u0: Float, v0: Float, u1: Float, v1: Float,
packedLight: Int, color: Int,
) {
drawVertex(builder, poseStack, x0, y0, z0, u0, v0, packedLight, color)
drawVertex(builder, poseStack, x0, y1, z1, u0, v1, packedLight, color)
@@ -280,16 +269,16 @@ open class CakeBlockEntityRenderer(ctx: BlockEntityRendererProvider.Context) : B
}
private fun drawVertex(
builder: VertexConsumer,
poseStack: PoseStack,
x: Float, y: Float, z: Float,
u: Float, v: Float,
packedLight: Int, color: Int
builder: VertexConsumer,
poseStack: PoseStack,
x: Float, y: Float, z: Float,
u: Float, v: Float,
packedLight: Int, color: Int
) {
builder.addVertex(poseStack.last().pose(), x, y, z)
.setColor(color)
.setUv(u, v)
.setLight(packedLight)
.setNormal(0f, 1f, 0f)
.setColor(color)
.setUv(u, v)
.setLight(packedLight)
.setNormal(0f, 1f, 0f)
}
}
@@ -987,29 +987,6 @@ open class PokemonEntity(
player.setItemInHand(hand, milkBucket)
return InteractionResult.sidedSuccess(level().isClientSide)
}
//Camerupt gives Lava Bucket if player uses Bucket on it
else if (pokemon.species.name == "Camerupt" && pokemon.lastMilked >= 900) {
player.playSound(SoundEvents.GOAT_MILK, 1.0f, 1.0f)
val lavaBucket = ItemUtils.createFilledResult(itemStack, player, Items.LAVA_BUCKET.defaultInstance)
player.setItemInHand(hand, lavaBucket)
pokemon.milk()
return InteractionResult.sidedSuccess(level().isClientSide)
}
//Gogoat gives Milk Bucket if player uses Bucket on it
else if (pokemon.species.name == "Gogoat" && pokemon.gender.name == "FEMALE") {
player.playSound(SoundEvents.GOAT_MILK, 1.0f, 1.0f)
val milkBucket = ItemUtils.createFilledResult(itemStack, player, Items.MILK_BUCKET.defaultInstance)
player.setItemInHand(hand, milkBucket)
return InteractionResult.sidedSuccess(level().isClientSide)
}
//Bouffalant gives Milk Bucket if player uses Bucket on it
else if (pokemon.species.name == "Bouffalant" && pokemon.gender.name == "FEMALE") {
player.playSound(SoundEvents.GOAT_MILK, 1.0f, 1.0f)
val milkBucket = ItemUtils.createFilledResult(itemStack, player, Items.MILK_BUCKET.defaultInstance)
player.setItemInHand(hand, milkBucket)
return InteractionResult.sidedSuccess(level().isClientSide)
}
} else if (itemStack.`is`(Items.BOWL)) {
if (pokemon.aspects.any { it.contains("mooshtank") }) {
player.playSound(SoundEvents.MOOSHROOM_MILK, 1.0f, 1.0f)
@@ -1045,32 +1022,7 @@ open class PokemonEntity(
return InteractionResult.sidedSuccess(level().isClientSide)
}
}
//Shuckle uses it's fullness to dispense Berry Juice if a player uses Wooden Bowl on it
else if (pokemon.species.name == "Shuckle" && pokemon.currentFullness > 0 && pokemon.lastMilked >= 300) {
player.playSound(SoundEvents.MOOSHROOM_MILK, 1.0f, 1.0f)
val berryJuice = ItemUtils.createFilledResult(itemStack, player, CobblemonItems.BERRY_JUICE.defaultInstance)
player.setItemInHand(hand, berryJuice)
pokemon.currentFullness--
return InteractionResult.sidedSuccess(level().isClientSide)
}
} else if (itemStack.`is`(Items.GLASS_BOTTLE)) {
if ((pokemon.species.name == "Vespiquen") && pokemon.lastMilked >= 500) {
player.playSound(SoundEvents.GOAT_MILK, 1.0f, 1.0f)
val honeyBottle = ItemUtils.createFilledResult(itemStack, player, Items.HONEY_BOTTLE.defaultInstance)
player.setItemInHand(hand, honeyBottle)
pokemon.milk()
return InteractionResult.sidedSuccess(level().isClientSide)
}
//Miltank gives MooMoo Milk if player uses Glass Bottle on it
else if (pokemon.species.name == "Miltank" && pokemon.lastMilked >= 500) {
player.playSound(SoundEvents.MOOSHROOM_MILK, 1.0f, 1.0f)
val moomooMilk = ItemUtils.createFilledResult(itemStack, player, CobblemonItems.MOOMOO_MILK.defaultInstance)
player.setItemInHand(hand, moomooMilk)
pokemon.milk()
return InteractionResult.sidedSuccess(level().isClientSide)
}
}
// Flowers used on brown MooshTanks
else if (itemStack.`is`(Items.ALLIUM) ||
itemStack.`is`(Items.AZURE_BLUET) ||
@@ -1,39 +0,0 @@
/*
* 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.events
import com.cobblemon.mod.common.api.events.battles.BattleFaintedEvent
import com.cobblemon.mod.common.api.events.battles.BattleVictoryEvent
import com.cobblemon.mod.common.util.party
object BellyHandler {
fun onFaint(event : BattleFaintedEvent) {
event.battle.activePokemon.forEach() {
if(it.battlePokemon != event.killed) {
it.battlePokemon?.entity?.pokemon?.loseFullness(1)
}
}
}
fun onVictory(event : BattleVictoryEvent) {
event.battle.players.forEach() {
it.party().forEach() {
it.loseFullness(1)
}
}
// Redacted code which only made last 2 active pokemon lose fullness
/*event.battle.activePokemon.forEach() {
// every pokemon that took part in the battle loses 1 fullness
it.battlePokemon?.entity?.pokemon?.loseFullness(1)
}*/
}
}
@@ -28,13 +28,6 @@ object ServerTickHandler {
// Party tick
for (player in server.playerList.players) {
player.party().onSecondPassed(player)
for (pokemon in player.party()) {
// only run on pokemon who have a fullness value above 0 to save on resources for the server
if (pokemon.currentFullness > 0 || pokemon.isMilkable(pokemon)) {
pokemon.onSecondPassed(player, pokemon)
}
}
}
}
}
@@ -102,27 +102,19 @@ class AprijuiceItem(val type: Apricorn): CobblemonItem(Properties().stacksTo(16)
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
val boosts = getBoosts(stack, pokemon)
if (!canUseOnPokemon(stack, pokemon) || boosts.isEmpty() || pokemon.isFull()) {
if (boosts.isEmpty()) {
return InteractionResultHolder.fail(stack)
}
// Feed the Pokémon 1 fullness point
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
if (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
boosts.forEach { (stat, value) ->
pokemon.addRideBoost(stat, value)
}
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -100,13 +100,6 @@ class PokePuffItem : Item(Properties().stacksTo(16)), PokemonSelectingItem {
}
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon): InteractionResultHolder<ItemStack> {
if (pokemon.isFull()) {
return InteractionResultHolder.fail(stack)
}
// Feed the Pokémon 4 fullness points
pokemon.feedPokemon(4)
val friendshipChange = PokePuffUtils.calculateFriendshipChange(stack, pokemon.nature)
if (friendshipChange != 0) {
@@ -41,10 +41,6 @@ class FriendshipRaisingBerryItem(block: BerryBlock, val stat: Stat) : BerryItem(
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack> {
if (pokemon.isFull()) {
return InteractionResultHolder.fail(stack)
}
val friendshipRaiseAmount = genericRuntime.resolveInt(CobblemonMechanics.berries.friendshipRaiseAmount, pokemon)
val increasedFriendship = pokemon.incrementFriendship(friendshipRaiseAmount)
@@ -53,17 +49,7 @@ class FriendshipRaisingBerryItem(block: BerryBlock, val stat: Stat) : BerryItem(
val decreasedEVs = pokemon.evs.add(stat, -evLowerAmount, ItemEvSource(player, stack, pokemon)) != 0
return if (increasedFriendship || decreasedEVs) {
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -50,24 +50,12 @@ class HealingBerryItem(block: BerryBlock, val amount: () -> ExpressionLike): Ber
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (pokemon.isFullHealth() || pokemon.isFainted() || pokemon.isFull()) {
if (pokemon.isFullHealth() || pokemon.isFainted()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
pokemon.currentHealth = Integer.min(pokemon.currentHealth + genericRuntime.resolveInt(amount(), pokemon), pokemon.hp)
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
pokemon.currentHealth = Integer.min(pokemon.currentHealth + genericRuntime.resolveInt(amount(), pokemon), pokemon.maxHealth)
//pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -49,25 +49,12 @@ class PPRestoringBerryItem(block: BerryBlock, val amount: () -> ExpressionLike):
override fun canUseOnMove(stack: ItemStack, move: Move) = move.currentPp < move.maxPp
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.moveSet.any { canUseOnMove(stack, it) }
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon, move: Move) {
if (!pokemon.isFull()) {
pokemon.feedPokemon(1)
val moveToRecover = pokemon.moveSet.find { it.template == move.template }
if (moveToRecover != null && moveToRecover.currentPp < moveToRecover.maxPp) {
moveToRecover.currentPp =
min(moveToRecover.maxPp, moveToRecover.currentPp + genericRuntime.resolveInt(amount(), pokemon))
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
if (!player.isCreative) {
stack.shrink(1)
}
val moveToRecover = pokemon.moveSet.find { it.template == move.template }
if (moveToRecover != null && moveToRecover.currentPp < moveToRecover.maxPp) {
moveToRecover.currentPp = min(moveToRecover.maxPp, moveToRecover.currentPp + genericRuntime.resolveInt(amount(), pokemon))
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
}
}
@@ -53,29 +53,15 @@ class PortionHealingBerryItem(block: BerryBlock, val canCauseConfusion: Boolean,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (pokemon.isFullHealth() || pokemon.isFainted() || pokemon.isFull()) {
if (pokemon.isFullHealth() || pokemon.isFainted()) {
return InteractionResultHolder.fail(stack)
}
// count these berries as multiple feedings due to the amount they heal
pokemon.feedPokemon(5)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
pokemon.currentHealth = Integer.min(pokemon.currentHealth + (genericRuntime.resolveFloat(portion(), pokemon) * pokemon.hp).toInt(), pokemon.hp)
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
var amount = Integer.min(pokemon.currentHealth + (genericRuntime.resolveFloat(portion(), pokemon) * pokemon.maxHealth).toInt(), pokemon.maxHealth)
CobblemonEvents.POKEMON_HEALED.postThen(PokemonHealedEvent(pokemon, amount, this), { cancelledEvent -> return InteractionResultHolder.fail(stack)}) { event ->
amount = event.amount
}
pokemon.currentHealth = amount
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -47,15 +47,7 @@ class StatusCuringBerryItem(block: BerryBlock, vararg val status: Status): Berry
): InteractionResultHolder<ItemStack>? {
val currentStatus = pokemon.status?.status
return if (currentStatus != null && (status.isEmpty() || currentStatus in status)) {
pokemon.feedPokemon(1)
pokemon.status = null
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
@@ -25,8 +25,8 @@ object BaitSeasoningProcessor : SeasoningProcessor {
// From seasonings with baitEffects
val seasoningData = Seasonings.getFromItemStack(seasoningStack)
if (seasoningData != null && !seasoningData.baitEffects.isNullOrEmpty()) {
val itemId = seasoningStack.itemHolder.unwrapKey().get().location()
if (seasoningData != null && seasoningData.baitEffects.isNotEmpty()) {
val itemId = seasoningStack.item.builtInRegistryHolder().key().location()
val id = ResourceLocation("seasonings", itemId.path)
baitIdentifiers.add(id)
}
@@ -21,7 +21,8 @@ object MobEffectSeasoningProcessor : SeasoningProcessor {
override fun apply(result: ItemStack, seasoning: List<ItemStack>) {
val allEffects: List<SerializableMobEffectInstance> = seasoning
.flatMap { Seasonings.getMobEffectsFromItemStack(it) }
.mapNotNull { Seasonings.getFromItemStack(it)?.mobEffects }
.flatMap { it.appliedEffects }
val mergedEffects = MobEffectUtils.mergeEffects(allEffects).map { it.toInstance() }
@@ -482,7 +482,6 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.JOLLY_MINT)
entries.accept(CobblemonItems.NAIVE_MINT)
entries.accept(CobblemonItems.SERIOUS_MINT)
entries.accept(CobblemonItems.MOOMOO_MILK)
entries.accept(CobblemonItems.ABILITY_CAPSULE)
entries.accept(CobblemonItems.ABILITY_PATCH)
@@ -50,20 +50,9 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (pokemon.isFullHealth() || pokemon.isFull()) {
if (pokemon.isFullHealth()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
pokemon.currentHealth = Integer.min(pokemon.currentHealth + 20, pokemon.hp)
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL,1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT,1F, 1F + fullnessPercent)
}
var amount = Integer.min(pokemon.currentHealth + 20, pokemon.maxHealth)
CobblemonEvents.POKEMON_HEALED.postThen(PokemonHealedEvent(pokemon, amount, this), { cancelledEvent -> return InteractionResultHolder.fail(stack)}) { event ->
amount = event.amount
@@ -28,25 +28,11 @@ class FreshStartMochiItem : CobblemonItem(Properties()), PokemonSelectingItem {
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack> {
if (pokemon.isFull()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
pokemon.evs.forEach {
pokemon.evs[it.key] = 0
}
//pokemon.entity?.playSound(CobblemonSounds.MOCHI_USE, 1F, 1F) todo use mochi sounds for fullness levels and replace above
pokemon.entity?.playSound(CobblemonSounds.MOCHI_USE, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -10,35 +10,8 @@ package com.cobblemon.mod.common.item.interactive
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import com.cobblemon.mod.common.pokemon.Pokemon
import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.InteractionResult
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.ItemStack
class MochiItem(stat: Stats): EVIncreaseItem(stat, 10) {
override val sound: SoundEvent = CobblemonSounds.MOCHI_USE
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon): InteractionResultHolder<ItemStack> {
if (pokemon.isFull()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
val fullnessPercent = ((pokemon.currentFullness).toFloat() / (pokemon.getMaxFullness()).toFloat()) * (.5).toFloat()
if (pokemon.currentFullness >= pokemon.getMaxFullness()) {
player.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
if (!player.isCreative) {
stack.shrink(1)
}
return super.applyToPokemon(player, stack, pokemon)
}
}
@@ -1,20 +0,0 @@
package com.cobblemon.mod.common.net.messages.client.pokemon.update
import com.cobblemon.mod.common.net.IntSize
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.cobblemonResource
import com.cobblemon.mod.common.util.readSizedInt
import net.minecraft.network.RegistryFriendlyByteBuf
class FullnessUpdatePacket(pokemon: () -> Pokemon?, value: Int) : IntUpdatePacket<FullnessUpdatePacket>(pokemon, value) {
override val id = ID
override fun getSize() = IntSize.U_BYTE
override fun set(pokemon: Pokemon, value: Int) {
pokemon.currentFullness = value
}
companion object {
val ID = cobblemonResource("fullness_update")
fun decode(buffer: RegistryFriendlyByteBuf) = FullnessUpdatePacket(decodePokemon(buffer), buffer.readSizedInt(IntSize.U_BYTE))
}
}
@@ -19,7 +19,6 @@ import com.cobblemon.mod.common.api.data.ShowdownIdentifiable
import com.cobblemon.mod.common.api.entity.PokemonSender
import com.cobblemon.mod.common.api.events.CobblemonEvents
import com.cobblemon.mod.common.api.events.CobblemonEvents.FRIENDSHIP_UPDATED
import com.cobblemon.mod.common.api.events.CobblemonEvents.FULLNESS_UPDATED
import com.cobblemon.mod.common.api.events.CobblemonEvents.POKEMON_FAINTED
import com.cobblemon.mod.common.api.events.pokemon.*
import com.cobblemon.mod.common.api.events.pokemon.healing.PokemonHealedEvent
@@ -338,18 +337,6 @@ open class Pokemon : ShowdownIdentifiable {
}
}
var currentFullness = 0
set(value) {
if (value < 0) {
field = 0
return
}
FULLNESS_UPDATED.post(FullnessUpdatedEvent(this, value)) {
field = it.newFullness
onChange(FullnessUpdatePacket({ this }, it.newFullness))
}
}
var state: PokemonState = InactivePokemonState()
set(value) {
if (field != value) {
@@ -863,8 +850,6 @@ open class Pokemon : ShowdownIdentifiable {
this.moveSet.partialHeal()
}
/**
* Check if this Pokémon can be healed.
* This verifies if HP is not maxed, any status is present or any move is not full PP.
@@ -890,163 +875,6 @@ open class Pokemon : ShowdownIdentifiable {
return ElementalTypes.FIRE in types || form.behaviour.moving.swim.canSwimInLava || form.behaviour.fireImmune
}
// Fullness / Milking mechanics
//last time this pokemon was milked (this will increase overtime)
var lastMilked = 0
// reset the lastMilked timer whenever this pokemon is milked
fun milk() {
lastMilked = 0
}
// returns true depending on the type of pokemon
fun isMilkable(pokemon: Pokemon): Boolean {
if (
pokemon.species.name == "Miltank" ||
pokemon.species.name == "Camerupt" ||
pokemon.species.name == "Vespiquen" ||
pokemon.species.name == "Combee" ||
pokemon.species.name == "Shuckle" ||
(pokemon.species.name == "Gogoat" && pokemon.gender.name == "FEMALE") ||
(pokemon.species.name == "Bouffalant" && pokemon.gender.name == "FEMALE")
) {
return true
}
else {
return false
}
}
// function to return the max hunger for the pokemon
fun getMaxFullness(): Int {
// get base HP stat of the referenced Pokemon
//var baseHP = this.species.baseStats.getOrDefault(Stats.HP,0)
// get weight of the pokemon
var weight = this.species.weight.toDouble()
//return (baseFullness + scaleFullnessRates(baseHP))
return ((getGrassKnotPower(weight) / 10 / 2) + 1)
}
// function to get grassKnot power based on weight (in Lbs)
fun getGrassKnotPower(weight: Double): Int {
return when {
weight in 0.1..21.8 -> 20
weight in 21.9..54.9 -> 40
weight in 55.0..110.1 -> 60
weight in 110.2..220.3 -> 80
weight in 220.4..440.8 -> 100
weight >= 440.9 -> 120
else -> 0 // For weights less than 0.1
}
}
fun feedPokemon(feedCount: Int) {
// get the fullness set to 0 in case something weird happens
if (this.currentFullness < 0) {
this.currentFullness = 0
}
// if pokemon is not full then feed
if (this.isFull() == false) {
this.currentFullness += feedCount
}
// pokemon was fed the first berry so we should reset their metabolism cycle so there is no inconsistencies
if (this.currentFullness == 1) {
this.resetMetabolismCycle()
}
}
// decrease a pokemon's Fullness value by a certain amount
fun loseFullness(value: Int) {
this.currentFullness -= value
// handle possible case of fullness being less than 0
if (this.currentFullness < 0) {
this.currentFullness = 0
}
}
// Amount of seconds that need to pass for the pokemon to lose 1 fullness value
fun getMetabolismRate(): Int {
val hp = this.species.baseStats.getOrDefault(Stats.HP,0)
val atk = this.species.baseStats.getOrDefault(Stats.ATTACK,0)
val spatk = this.species.baseStats.getOrDefault(Stats.SPECIAL_ATTACK,0)
val def = this.species.baseStats.getOrDefault(Stats.DEFENCE,0)
val spdef = this.species.baseStats.getOrDefault(Stats.SPECIAL_DEFENCE,0)
val speed = this.species.baseStats.getOrDefault(Stats.SPEED,0)
// Base Stat Total for the pokemon
val BST = hp + atk + spatk + def + spdef + speed
// multiplying scaling value
val multiplier = 4
//base berry count
val baseBerryCount = 20
//rate of metabolism in seconds
var metabolismRate = ((baseBerryCount.toDouble() - ((speed.toDouble() / BST.toDouble()) * baseBerryCount.toDouble()) * multiplier.toDouble()) * 60.0).toInt()
// returns value in seconds for the onSecondPassed function
// check for below 0 value and set to minimum to 1 minute
if (metabolismRate <= 0) {
return 1 * 60
}
else {
return metabolismRate
}
}
// Boolean function that checks if a Pokemon can eat food based on fedTimes
fun isFull(): Boolean {
// Check if the pokemon is at max fullness
if (currentFullness >= this.getMaxFullness()) {
return true
}
return false
}
// The value that will increase per second until it hits a Pokemon's metabolism Factor then be set back to zero
var metabolismCycle = 0
// for setting the metabolism cycle of a pokemon back to 0 in certain cases
fun resetMetabolismCycle() {
this.metabolismCycle = 0
}
/**
* Called every second on the Pokémon for their fullness
*/
open fun onSecondPassed(player: ServerPlayer, pokemon: Pokemon) {
metabolismCycle += 1
// set cap for lastMilked to save on resources potentially [CURRENTLY SET TO 3 HOURS]
if (pokemon.lastMilked != 1500) {
pokemon.lastMilked += 1
}
// if the metabolismCycle value equals the Pokemon's metabolism rate then decrease Fullness by 1
if (metabolismCycle >= pokemon.getMetabolismRate()) {
// as a baseline we will decrement the Fullness by 1 for each metabolism cycle
val message = "${pokemon.species.name}'s Fullness went down by 1"
if (pokemon.currentFullness > 0) {
//player.sendMessage(Text.of(message))
pokemon.loseFullness(1)
}
//reset the metabolic cycle back to zero
metabolismCycle = 0
}
}
fun isPositionSafe(world: Level, pos: Vec3): Boolean {
return isPositionSafe(world, pos.toBlockPos())
}
@@ -18,7 +18,6 @@ object DataKeys {
const val POKEMON_GENDER = "Gender"
const val POKEMON_EXPERIENCE = "Experience"
const val POKEMON_FRIENDSHIP = "Friendship"
const val POKEMON_FULLNESS = "Fullness"
const val POKEMON_IVS = "IVs"
const val POKEMON_EVS = "EVs"
@@ -32,8 +32,7 @@ internal data class ClientPokemonP3(
val marks: Set<ResourceLocation>,
val potentialMarks: Set<ResourceLocation>,
val markings: List<Int>,
val rideBoosts: Map<String, Float>,
val currentFullness: Int
val rideBoosts: Map<String, Float>
) : Partial<Pokemon> {
override fun into(other: Pokemon): Pokemon {
@@ -50,7 +49,6 @@ internal data class ClientPokemonP3(
other.potentialMarks += this.potentialMarks.map { Marks.getByIdentifier(it) }.filterNotNull().toMutableSet()
other.markings = this.markings
this.rideBoosts.let { other.setRideBoosts(it.mapKeys { RidingStat.valueOf(it.key) }) }
other.currentFullness = this.currentFullness
return other
}
@@ -70,8 +68,7 @@ internal data class ClientPokemonP3(
Codec.list(ResourceLocation.CODEC).fieldOf(DataKeys.POKEMON_MARKS).xmap({ it.toSet() }, { it.toMutableList() }).forGetter(ClientPokemonP3::marks),
Codec.list(ResourceLocation.CODEC).fieldOf(DataKeys.POKEMON_POTENTIAL_MARKS).xmap({ it.toSet() }, { it.toMutableList() }).forGetter(ClientPokemonP3::potentialMarks),
Codec.list(Codec.INT).optionalFieldOf(DataKeys.POKEMON_MARKINGS, listOf(0, 0, 0, 0, 0, 0)).forGetter(ClientPokemonP3::markings),
Codec.unboundedMap(Codec.STRING, Codec.FLOAT).fieldOf(DataKeys.POKEMON_RIDE_BOOSTS).forGetter(ClientPokemonP3::rideBoosts),
Codec.intRange(0, Int.MAX_VALUE).fieldOf(DataKeys.POKEMON_FULLNESS).forGetter(ClientPokemonP3::currentFullness)
Codec.unboundedMap(Codec.STRING, Codec.FLOAT).fieldOf(DataKeys.POKEMON_RIDE_BOOSTS).forGetter(ClientPokemonP3::rideBoosts)
).apply(instance, ::ClientPokemonP3)
}
@@ -86,8 +83,7 @@ internal data class ClientPokemonP3(
pokemon.marks.map { it.identifier }.toSet(),
pokemon.potentialMarks.map { it.identifier }.toSet(),
pokemon.markings,
pokemon.getRideBoosts().mapKeys { it.key.name },
pokemon.currentFullness
pokemon.getRideBoosts().mapKeys { it.key.name }
)
}
}
@@ -39,8 +39,7 @@ internal data class PokemonP3(
val marks: Set<ResourceLocation>,
val potentialMarks: Set<ResourceLocation>,
val markings: List<Int>,
val rideBoosts: Map<String, Float>,
val currentFullness: Int
val rideBoosts: Map<String, Float>
) : Partial<Pokemon> {
override fun into(other: Pokemon): Pokemon {
@@ -74,7 +73,6 @@ internal data class PokemonP3(
other.potentialMarks += this.potentialMarks.map { Marks.getByIdentifier(it) }.filterNotNull().toMutableSet()
other.markings = this.markings
this.rideBoosts.let { other.setRideBoosts(it.mapKeys { RidingStat.valueOf(it.key) }) }
other.currentFullness = this.currentFullness
return other
}
@@ -92,8 +90,7 @@ internal data class PokemonP3(
Codec.list(ResourceLocation.CODEC).optionalFieldOf(DataKeys.POKEMON_POTENTIAL_MARKS, emptyList()).forGetter { it.potentialMarks.toMutableList() },
Codec.list(Codec.INT).optionalFieldOf(DataKeys.POKEMON_MARKINGS, listOf(0, 0, 0, 0, 0, 0)).forGetter(PokemonP3::markings),
Codec.unboundedMap(Codec.STRING, Codec.FLOAT).optionalFieldOf(DataKeys.POKEMON_RIDE_BOOSTS, emptyMap<String, Float>()).forGetter(PokemonP3::rideBoosts),
Codec.intRange(0, Int.MAX_VALUE).optionalFieldOf(DataKeys.POKEMON_FULLNESS, 0).forGetter(PokemonP3::currentFullness)
).apply(instance) { originalTrainerType, originalTrainer, forcedAspects, features, heldItemVisible, cosmeticItem, activeMark, marks, potentialMarks, markings, rideBoosts, currentFullness -> PokemonP3(originalTrainerType, originalTrainer, forcedAspects.toSet(), features, heldItemVisible, cosmeticItem.orElse(ItemStack.EMPTY), activeMark, marks.toMutableSet(), potentialMarks.toMutableSet(), markings, rideBoosts, currentFullness) }
).apply(instance) { originalTrainerType, originalTrainer, forcedAspects, features, heldItemVisible, cosmeticItem, activeMark, marks, potentialMarks, markings, rideBoosts -> PokemonP3(originalTrainerType, originalTrainer, forcedAspects.toSet(), features, heldItemVisible, cosmeticItem.orElse(ItemStack.EMPTY), activeMark, marks.toMutableSet(), potentialMarks.toMutableSet(), markings, rideBoosts) }
}
internal fun from(pokemon: Pokemon): PokemonP3 = PokemonP3(
@@ -111,8 +108,7 @@ internal data class PokemonP3(
pokemon.marks.map { it.identifier }.toSet(),
pokemon.potentialMarks.map { it.identifier }.toSet(),
pokemon.markings,
pokemon.getRideBoosts().mapKeys { it.key.name },
pokemon.currentFullness
pokemon.getRideBoosts().mapKeys { it.key.name }
)
}
}
@@ -622,7 +622,6 @@
"item.cobblemon.dire_hit": "Dire Hit",
"item.cobblemon.dire_hit.tooltip": "Temporarily boosts a Pokémon's critical hit ratio when used in battle",
"item.cobblemon.guard_spec": "Guard Spec",
"item.cobblemon.moomoo_milk": "Moomoo Milk",
"item.cobblemon.guard_spec.tooltip": "Temporarily prevents stat reduction when used in battle",
"item.cobblemon.full_heal": "Full Heal",
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/moomoo_milk"
}
}
@@ -196,9 +196,6 @@
"item.berry.eat": {
"sounds": [ "cobblemon:item/berry/berry_eat" ]
},
"item.berry.eat.full": {
"sounds": [ "cobblemon:item/berry/berry_eat_full" ]
},
"fishing.notification": {
"sounds": [
"cobblemon:fishing/fishing_notification_1",
@@ -737,7 +734,7 @@
"sounds": [ { "name": "cobblemon:move/confusion/confusion_actor", "volume": 0.9 } ]
},
"move.confusion.target": {
"sounds": [ { "name": "cobblemon:move/confusion/confusion_target", "volume": 0.8 } ]
"sounds": [ { "name": "cobblemon:move/confusion/confusion_target", "volume": 0.8 } ]
},
"move.swordsdance.actor": {
"sounds": [ { "name": "cobblemon:move/swords_dance/swords_dance_actor", "volume": 0.8 } ]
@@ -746,7 +743,7 @@
"sounds": [ { "name": "cobblemon:move/thunder_wave/thunder_wave_actor", "volume": 0.8 } ]
},
"move.thunderwave.target": {
"sounds": [ { "name": "cobblemon:move/thunder_wave/thunder_wave_target", "volume": 0.8 } ]
"sounds": [ { "name": "cobblemon:move/thunder_wave/thunder_wave_target", "volume": 0.8 } ]
},
"move.protect.actor": {
"sounds": [ { "name": "cobblemon:move/protect/protect_actor", "volume": 0.8 } ]
@@ -808,7 +805,7 @@
"sounds": [ { "name": "cobblemon:move/quick_attack/quick_attack_actor", "volume": 0.8 } ]
},
"move.quickattack.target": {
"sounds": [ { "name": "cobblemon:move/quick_attack/quick_attack_target", "volume": 0.8 } ]
"sounds": [ { "name": "cobblemon:move/quick_attack/quick_attack_target", "volume": 0.8 } ]
},
"move.seismictoss.actor": {
"sounds": [ { "name": "cobblemon:move/seismic_toss/seismic_toss_actor", "volume": 0.8 } ]
@@ -7315,4 +7312,4 @@
"pokemon.ironleaves.cry": {
"sounds": [ { "name": "cobblemon:pokemon/ironleaves/ironleaves_cry", "volume": 0.8 } ]
}
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 456 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:allium",
"colour": "pink",
"mobEffects": [
{
"effect": "minecraft:fire_resistance",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:fire_resistance",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:azure_bluet",
"colour": "light_gray",
"mobEffects": [
{
"effect": "minecraft:blindness",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:blindness",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:big_root",
"colour": "brown",
"mobEffects": [
{
"effect": "minecraft:resistance",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:resistance",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:blue_mint_leaf",
"colour": "blue",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:blue_orchid",
"colour": "blue",
"mobEffects": [
{
"effect": "minecraft:saturation",
"duration": 7,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:saturation",
"duration": 7,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:chorus_flower",
"colour": "purple",
"mobEffects": [
{
"effect": "minecraft:levitation",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:levitation",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:cornflower",
"colour": "blue",
"mobEffects": [
{
"effect": "minecraft:jump_boost",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:jump_boost",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:cyan_mint_leaf",
"colour": "cyan",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:dandelion",
"colour": "yellow",
"mobEffects": [
{
"effect": "minecraft:saturation",
"duration": 7,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:saturation",
"duration": 7,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:energy_root",
"colour": "brown",
"mobEffects": [
{
"effect": "minecraft:absorption",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:absorption",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:galarica_nuts",
"colour": "red",
"mobEffects": [
{
"effect": "minecraft:fire_resistance",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:fire_resistance",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:green_mint_leaf",
"colour": "green",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:honey_bottle",
"colour": "yellow",
"mobEffects": [
{
"effect": "minecraft:poison",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:poison",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:lilac",
"colour": "purple",
"mobEffects": [
{
"effect": "minecraft:slow_falling",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:slow_falling",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:lily_of_the_valley",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:poison",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:poison",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:mental_herb",
"colour": "green",
"mobEffects": [
{
"effect": "minecraft:darkness",
"duration": 15600,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:darkness",
"duration": 15600,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:milk",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:instant_health",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:instant_health",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:mirror_herb",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:invisibility",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:invisibility",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:orange_tulip",
"colour": "orange",
"mobEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:oxeye_daisy",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:regeneration",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:regeneration",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:peony",
"colour": "pink",
"mobEffects": [
{
"effect": "minecraft:slow_falling",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:slow_falling",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:pep_up_flower",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:strength",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:strength",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:pink_mint_leaf",
"colour": "pink",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:pink_petals",
"colour": "pink",
"mobEffects": [
{
"effect": "minecraft:regeneration",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:regeneration",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:pink_tulip",
"colour": "pink",
"mobEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:pitcher_plant",
"colour": "green",
"mobEffects": [
{
"effect": "minecraft:hunger",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:hunger",
"duration": 220,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -5,14 +5,16 @@
"hunger": 2,
"saturation": 1.2
},
"mobEffects": [
{
"effect": "minecraft:poison",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:poison",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:poppy",
"colour": "red",
"mobEffects": [
{
"effect": "minecraft:night_vision",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:night_vision",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:power_herb",
"colour": "orange",
"mobEffects": [
{
"effect": "minecraft:haste",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:haste",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:red_mint_leaf",
"colour": "red",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:red_tulip",
"colour": "red",
"mobEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:revival_herb",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:instant_health",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:instant_health",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:rose_bush",
"colour": "red",
"mobEffects": [
{
"effect": "minecraft:resistance",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:resistance",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -5,14 +5,16 @@
"hunger": 4,
"saturation": 0.8
},
"mobEffects": [
{
"effect": "minecraft:hunger",
"duration": 600,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:hunger",
"duration": 600,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:spore_blossom",
"colour": "green",
"mobEffects": [
{
"effect": "minecraft:mining_fatigue",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:mining_fatigue",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:sugar",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:speed",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:speed",
"duration": 260,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:sunflower",
"colour": "yellow",
"mobEffects": [
{
"effect": "minecraft:glowing",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:glowing",
"duration": 60,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:torchflower",
"colour": "orange",
"mobEffects": [
{
"effect": "minecraft:night_vision",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:night_vision",
"duration": 100,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:white_herb",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:hero_of_the_village",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:hero_of_the_village",
"duration": 1,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "cobblemon:white_mint_leaf",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:luck",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:white_tulip",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:weakness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:wildflowers",
"colour": "white",
"mobEffects": [
{
"effect": "minecraft:slowness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:slowness",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,14 +1,16 @@
{
"ingredient": "minecraft:wither_rose",
"colour": "black",
"mobEffects": [
{
"effect": "minecraft:wither",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
"mobEffects": {
"appliedEffects": [
{
"effect": "minecraft:wither",
"duration": 140,
"amplifier": 0,
"ambient": false,
"visible": true,
"showIcon": true
}
]
}
}
@@ -1,7 +0,0 @@
{
"replace": false,
"values": [
"#cobblemon:berries",
"cobblemon:berry_juice"
]
}
@@ -54,6 +54,7 @@
"ItemStackComponentizationFixMixin",
"LecternBlockMixin",
"LivingEntityMixin",
"LocalPlayerMixin",
"MinecraftDedicatedServerMixin",
"NbtUtilsMixin",
"PiglinBarterMixin",
@@ -74,6 +75,7 @@
"accessor.BiomeAccessor",
"accessor.BoatEntityAccessor",
"accessor.ChunkMapAccessor",
"accessor.EntryListWidgetAccessor",
"accessor.StatusEffectInstanceAccessor",
"accessor.TrackedEntityAccessor",
"entity.EntityMixin",