Compare commits

..
362 changed files with 2066 additions and 5371 deletions

No files matched your search

-1
View File
@@ -227,7 +227,6 @@
- The Pokédex form lang key definition now follows `cobblemon.ui.pokedex.info.form.{species}-{formname}` instead of `cobblemon.ui.pokedex.info.form.{formname}`.
- Added `labels` & `has_label` as available Molang functions for the `speciesFunctions`
- Added datapack-defined starter categories via `data/<namespace>/starters/*.json`, with built-in fallback and `useConfigStarters` merge option.
- Fixed `entity.find_nearby_block` causing crashes when attempting to use a block tag
## [1.6.1 (January 26th, 2025)](#1-6-1)
@@ -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);
}
}
}
@@ -1,28 +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.mixin.block.entity;
import com.cobblemon.mod.common.Cobblemon;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.block.entity.SculkShriekerBlockEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(SculkShriekerBlockEntity.class)
public abstract class SculkShriekerBlockEntityMixin {
@Inject(method = "tryShriek", at = @At("HEAD"), cancellable = true)
// Cancel warden spawn by preventing the shrieker from activating
void cobblemon$cancelWardenSpawn(ServerLevel level, ServerPlayer player, CallbackInfo ci) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.WARDEN)) ci.cancel();
}
}
@@ -56,7 +56,7 @@ public abstract class ClientRecipeBookMixin {
case MISC -> var7 = CobblemonRecipeCategories.COOKING_POT_MISC.toVanillaCategory();
case FOODS -> var7 = CobblemonRecipeCategories.COOKING_POT_FOODS.toVanillaCategory();
case MEDICINES -> var7 = CobblemonRecipeCategories.COOKING_POT_MEDICINES.toVanillaCategory();
case COMPLEX_DISHES -> var7 = CobblemonRecipeCategories.COOKING_POT_COMPLEX_DISHES.toVanillaCategory();
case BAITS -> var7 = CobblemonRecipeCategories.COOKING_POT_BAITS.toVanillaCategory();
default -> throw new MatchException(null, null);
}
cir.setReturnValue(var7);
@@ -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);
}
}
}
@@ -50,10 +50,10 @@ public class RecipeBookCategoriesMixin {
private static void cobblemon$addRecipeBookType(CallbackInfo ci) {
ArrayList<RecipeBookCategories> types = new ArrayList<>(List.of($VALUES));
types.add(cobblemon$createCategory("COOKING_POT_SEARCH", $VALUES.length, new ItemStack(Items.COMPASS)));
types.add(cobblemon$createCategory("COOKING_POT_FOODS", $VALUES.length + 1, new ItemStack(CobblemonItems.LEEK_AND_POTATO_STEW)));
types.add(cobblemon$createCategory("COOKING_POT_MEDICINES", $VALUES.length + 2, new ItemStack(CobblemonItems.POTION)));
types.add(cobblemon$createCategory("COOKING_POT_COMPLEX_DISHES", $VALUES.length + 3, new ItemStack(CobblemonItems.POKE_PUFF)));
types.add(cobblemon$createCategory("COOKING_POT_MISC", $VALUES.length + 4, new ItemStack(CobblemonItems.PROTEIN)));
types.add(cobblemon$createCategory("COOKING_POT_FOODS", $VALUES.length + 1, new ItemStack(CobblemonItems.ROASTED_LEEK)));
types.add(cobblemon$createCategory("COOKING_POT_MEDICINES", $VALUES.length + 2, new ItemStack(CobblemonItems.HP_UP)));
types.add(cobblemon$createCategory("COOKING_POT_BAITS", $VALUES.length + 3, new ItemStack(CobblemonItems.PERSIM_BERRY)));
types.add(cobblemon$createCategory("COOKING_POT_MISC", $VALUES.length + 4, new ItemStack(CobblemonItems.MIRROR_HERB)));
$VALUES = types.toArray(RecipeBookCategories[]::new);
}
@@ -64,7 +64,7 @@ public class RecipeBookCategoriesMixin {
CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_FOODS.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_MEDICINES.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_COMPLEX_DISHES.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_BAITS.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_MISC.toVanillaCategory());
cir.setReturnValue(var10000);
return;
@@ -1,28 +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.mixin.entity;
import com.cobblemon.mod.common.Cobblemon;
import net.minecraft.core.BlockPos;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.SpawnPlacements;
import net.minecraft.world.level.LevelReader;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(SpawnPlacements.class)
public class SpawnPlacementsMixin {
@Inject(method = "isSpawnPositionOk", at = @At("HEAD"), cancellable = true)
// Cancel general mob spawn by returning false
private static void cobblemon$cancelMobSpawns(EntityType<?> entityType, LevelReader level, BlockPos pos, CallbackInfoReturnable<Boolean> cir) {
if (Cobblemon.spawnConfig.isBlacklisted(entityType)) cir.setReturnValue(false);
}
}
@@ -1,37 +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.mixin.structure;
import com.cobblemon.mod.common.Cobblemon;
import com.google.common.collect.Iterators;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureEntityInfo;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.Iterator;
@Mixin(StructureTemplate.class)
public abstract class StructureTemplateMixin {
@ModifyExpressionValue(
method = "placeEntities",
at = @At(value = "INVOKE",
target = "Ljava/util/List;iterator()Ljava/util/Iterator;"
)) // Modifies the iterator to ignore entities that are blacklisted
private Iterator<StructureEntityInfo> cobblemon$cancelStructureSpawn(Iterator<StructureEntityInfo> original) {
return Iterators.filter(original, info ->
Cobblemon.spawnConfig.isBlacklisted(info.nbt.getString("id"))
);
}
}
@@ -1,37 +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.mixin.structure.structures;
import com.cobblemon.mod.common.Cobblemon;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.structures.EndCityPieces;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(EndCityPieces.EndCityPiece.class)
public abstract class EndCityPieceMixin {
@Inject(
method = "handleDataMarker",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;"
),
cancellable = true) // Cancel the function if name == "Sentry" to prevent Shulker from spawning
void cobblemon$cancelShulkerSpawn(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box, CallbackInfo ci) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.SHULKER)) ci.cancel();
}
}
@@ -1,29 +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.mixin.structure.structures;
import com.cobblemon.mod.common.Cobblemon;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.WorldGenLevel;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.structures.OceanMonumentPieces;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(OceanMonumentPieces.OceanMonumentPiece.class)
public abstract class OceanMonumentPieceMixin {
@Inject(method = "spawnElder", at = @At("HEAD"), cancellable = true)
void cobblemon$cancelElderGuardianSpawn(WorldGenLevel level, BoundingBox box, int x, int y, int z, CallbackInfo ci) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.ELDER_GUARDIAN)) ci.cancel();
}
}
@@ -1,37 +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.mixin.structure.structures;
import com.cobblemon.mod.common.Cobblemon;
import net.minecraft.core.BlockPos;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.structures.OceanRuinPieces;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(OceanRuinPieces.OceanRuinPiece.class)
public abstract class OceanRuinPieceMixin {
@Inject(
method = "handleDataMarker",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/entity/EntityType;create(Lnet/minecraft/world/level/Level;)Lnet/minecraft/world/entity/Entity;"
),
cancellable = true) // Cancel the function if name == "drowned" to prevent Drowned from spawning
void cobblemon$cancelDrownedSpawn(String name, BlockPos pos, ServerLevelAccessor level, RandomSource random, BoundingBox box, CallbackInfo ci) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.DROWNED)) ci.cancel();
}
}
@@ -1,46 +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.mixin.structure.structures;
import com.cobblemon.mod.common.Cobblemon;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.core.Vec3i;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.ServerLevelAccessor;
import net.minecraft.world.level.levelgen.structure.BoundingBox;
import net.minecraft.world.level.levelgen.structure.structures.SwampHutPiece;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@Mixin(SwampHutPiece.class)
public abstract class SwampHutPieceMixin {
@WrapOperation(
method = "postProcess",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/levelgen/structure/BoundingBox;isInside(Lnet/minecraft/core/Vec3i;)Z"
)) // Prevent witch spawn by making box.isInside return false
boolean cobblemon$cancelWitchSpawn(BoundingBox box, Vec3i vector, Operation<Boolean> original) {
return !Cobblemon.spawnConfig.isBlacklisted(EntityType.WITCH) && original.call(box, vector);
}
@WrapOperation(method = "postProcess",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/levelgen/structure/structures/SwampHutPiece;spawnCat(Lnet/minecraft/world/level/ServerLevelAccessor;Lnet/minecraft/world/level/levelgen/structure/BoundingBox;)V"
)) // Prevent cat spawn by calling nothing
void cobblemon$cancelWitchCatSpawn(SwampHutPiece piece, ServerLevelAccessor level, BoundingBox box, Operation<Void> original) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.CAT)) return;
original.call(piece, level, box);
}
}
@@ -1,38 +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.mixin.structure.structures;
import com.cobblemon.mod.common.Cobblemon;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.level.levelgen.structure.structures.WoodlandMansionPieces;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.List;
@Mixin(WoodlandMansionPieces.WoodlandMansionPiece.class)
public abstract class WoodlandMansionPieceMixin {
@WrapOperation(
method = "handleDataMarker",
at = @At(
value = "INVOKE",
target = "Ljava/util/List;add(Ljava/lang/Object;)Z"
)) // Wraps calls to add to the list and ignores it if the mob to add is blacklisted
boolean cobblemon$cancelMansionSpawns(List instance, Object entity, Operation<Boolean> original) {
if (Cobblemon.spawnConfig.isBlacklisted(((Mob) entity).getType())) {
return true;
}
return original.call(instance, entity);
}
}
@@ -1,37 +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.mixin.worldgen;
import com.cobblemon.mod.common.Cobblemon;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.levelgen.feature.treedecorators.BeehiveDecorator;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.Optional;
import java.util.function.Consumer;
@Mixin(BeehiveDecorator.class)
public abstract class BeeHiveDecoratorMixin {
@WrapOperation(
method = "place",
at = @At(
value = "INVOKE",
target = "Ljava/util/Optional;ifPresent(Ljava/util/function/Consumer;)V"
)
)
<T> void cobblemon$cancelBeeSpawn(Optional instance, Consumer<? super @NotNull T> action, Operation<Void> original) {
if (Cobblemon.spawnConfig.isBlacklisted(EntityType.BEE)) return;
original.call(instance, action);
}
}
@@ -73,7 +73,6 @@ import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.client.CobblemonPack
import com.cobblemon.mod.common.command.argument.*
import com.cobblemon.mod.common.config.CobblemonConfig
import com.cobblemon.mod.common.config.CobblemonSpawnConfig
import com.cobblemon.mod.common.config.LastChangedVersion
import com.cobblemon.mod.common.config.constraint.IntConstraint
import com.cobblemon.mod.common.config.starter.StarterConfig
@@ -161,7 +160,6 @@ object Cobblemon {
var isDedicatedServer = false
val showdownThread = ShowdownThread()
lateinit var config: CobblemonConfig
lateinit var spawnConfig: CobblemonSpawnConfig
var spawningZoneGenerator: SpawningZoneGenerator = CobblemonSpawningZoneGenerator
var areaSpawnablePositionResolver: AreaSpawnablePositionResolver = object : AreaSpawnablePositionResolver {}
val bestSpawner = BestSpawner
@@ -468,13 +466,11 @@ object Cobblemon {
fun loadConfig() {
initializeConfig()
this.spawnConfig = CobblemonSpawnConfig("config/$MODID/blacklisted_mobs.json")
bestSpawner.init()
}
fun reloadConfig() {
initializeConfig()
spawnConfig.load()
bestSpawner.reloadConfig()
}
@@ -55,7 +55,6 @@ import net.minecraft.world.food.FoodProperties
import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.HangingSignItem
import net.minecraft.world.item.Item
import net.minecraft.world.item.Item.Properties
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.Rarity
@@ -372,55 +371,138 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val SINISTER_TEA = create("sinister_tea", SinisterTeaItem())
@JvmField
val POKE_PUFF = pokepuffItem("poke_puff")
val POKE_PUFF = pokepuffItem("poke_puff") // todo make a PokePuffItem class for friendship boosting purposes
// FOODS
@JvmField
val SWEET_HEART = noSettingsItem("sweet_heart") // todo make a SweetHeartItem class for breeding purposes
@JvmField
val TASTY_TAIL = noSettingsItem("tasty_tail")
val TASTY_TAIL = create("tasty_tail", object : Item(Properties().stacksTo(16)
.food(FoodProperties.Builder()
.nutrition(8)
.saturationModifier(12.8F)
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val PEWTER_CRUNCHIES = regionalFoodItem("pewter_crunchies", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f, false)
@JvmField
val PEWTER_CRUNCHIES = create("pewter_crunchies", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val RAGE_CANDY_BAR = regionalFoodItem("rage_candy_bar", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f, false)
@JvmField
val RAGE_CANDY_BAR = create("rage_candy_bar", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val LAVA_COOKIE = regionalFoodItem("lava_cookie", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val LAVA_COOKIE = create("lava_cookie", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val OLD_GATEAU = regionalFoodItem("old_gateau", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val OLD_GATEAU = create("old_gateau", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val CASTELIACONE = regionalFoodItem("casteliacone", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val CASTELIACONE = create("casteliacone", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val SHALOUR_SABLE = regionalFoodItem("shalour_sable", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val SHALOUR_SABLE = create("shalour_sable", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val LUMIOSE_GALETTE = regionalFoodItem("lumiose_galette", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val LUMIOSE_GALETTE = create("lumiose_galette", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val BIG_MALASADA = regionalFoodItem("big_malasada", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val BIG_MALASADA = create("big_malasada", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val SMOKED_TAIL_CURRY = regionalFoodItem("smoked_tail_curry", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f, false, ItemStack(Items.BOWL, 1))
/*@JvmField // todo see what we are doing for these (are there different kinds?)
val CURRY = create("curry", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10)
.saturationModifier(1.2F)
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F)
.alwaysEdible()
.usingConvertsTo(Items.BOWL)
.build())) {
override fun finishUsingItem(stack: ItemStack, world: Level, user: LivingEntity): ItemStack {
user.removeAllEffects()
return super.finishUsingItem(stack, world, user)
}
})*/
@JvmField // todo get final values for this from vera
val JUBILIFE_MUFFIN = regionalFoodItem("jubilife_muffin", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
@JvmField
val JUBILIFE_MUFFIN = create("jubilife_muffin", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10) // todo get final values for this from vera
.saturationModifier(1.2F) // todo get final values for this from vera
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F) // todo get final values for this from vera
.alwaysEdible()
.build())) {})
@JvmField // todo get final values for this from vera
val OPEN_FACED_SANDWICH = regionalFoodItem("open_faced_sandwich", 16, 10, 1.2f, MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1f)
/*@JvmField // todo see what we are doing for these (are there different kinds?)
val SANDWICH = create("sandwich", object : Item(Properties().stacksTo(16) // todo add all the effects and/or an item class for it for special interactions?
.food(FoodProperties.Builder()
.nutrition(10)
.saturationModifier(1.2F)
.effect(MobEffectInstance(MobEffects.ABSORPTION, 900, 0), 1F)
.alwaysEdible()
.usingConvertsTo(Items.BOWL)
.build())) {
override fun finishUsingItem(stack: ItemStack, world: Level, user: LivingEntity): ItemStack {
user.removeAllEffects()
return super.finishUsingItem(stack, world, user)
}
})*/
// todo we might need to wait on these for later? These impact battles and may be harder to do
// todo we might need to wait on these for later?
/*@JvmField
val CHOICE_DUMPLING = noSettingsItem("choice_dumpling") // todo make a ChoiceDumpingItem class for battle purposes
val CHOICE_DUMPLING = noSettingsItem("choice_dumpling") // todo make a ChoiceDumpingItem class for breeding purposes
@JvmField
val SWAP_SNACK = noSettingsItem("swap_snack") // todo make a SwapSnackItem class for battle purposes
val SWAP_SNACK = noSettingsItem("swap_snack") // todo make a SwapSnackItem class for breeding purposes
@JvmField
val TWICE_SPICED_BEETROOT = noSettingsItem("twice_spiced_beetroot") // todo make a TwiceSpiceBeetrootItem class for battle purposes
val TWICE_SPICED_BEETROOT = noSettingsItem("twice_spiced_beetroot") // todo make a TwiceSpiceBeetrootItem class for breeding purposes
*/
@JvmField
val POTATO_MOCHI = create("potato_mochi", object : Item(Properties().stacksTo(16)
@@ -451,6 +533,8 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
.alwaysEdible()
.build())) {})
// todo etc?
//@JvmField
//val SCATTER_BANG = this.create("scatter_bang", ScatterBangItem(Item.Settings()))
//@JvmField
@@ -676,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))
@@ -1497,39 +1579,6 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
return item
}
private fun regionalFoodItem(
name: String,
stacksTo: Int,
nutrition: Int,
saturationModifier: Float,
effect: MobEffectInstance? = null,
effectChance: Float? = null,
alwaysEdible: Boolean = false,
convertsToOnUse: ItemStack? = null
): RegionalFoodItem {
val foodPropertiesBuilder = FoodProperties.Builder()
.nutrition(nutrition)
.saturationModifier(saturationModifier)
if (effect != null && effectChance != null) {
foodPropertiesBuilder.effect(effect, effectChance)
}
if (alwaysEdible == true) {
foodPropertiesBuilder.alwaysEdible()
}
if (convertsToOnUse != null && !convertsToOnUse.isEmpty) {
foodPropertiesBuilder.usingConvertsTo(convertsToOnUse.item)
}
val properties = Item.Properties()
.stacksTo(stacksTo)
.food(foodPropertiesBuilder.build())
return create(name, RegionalFoodItem(properties))
}
private fun heldItem(name: String, remappedName: String? = null): CobblemonItem = create(
name,
CobblemonItem(Item.Properties()).also {
@@ -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()))
@@ -15,13 +15,13 @@ enum class CobblemonRecipeCategories {
COOKING_POT_SEARCH("COOKING_POT_SEARCH"),
COOKING_POT_FOODS("COOKING_POT_FOODS"),
COOKING_POT_MEDICINES("COOKING_POT_MEDICINES"),
COOKING_POT_COMPLEX_DISHES("COOKING_POT_COMPLEX_DISHES"),
COOKING_POT_BAITS("COOKING_POT_BAITS"),
COOKING_POT_MISC("COOKING_POT_MISC");
companion object {
val customAggregateCategories: Map<RecipeBookCategories, List<RecipeBookCategories>> = mapOf(
COOKING_POT_SEARCH.toVanillaCategory() to listOf(
COOKING_POT_FOODS.toVanillaCategory(), COOKING_POT_MISC.toVanillaCategory(), COOKING_POT_MEDICINES.toVanillaCategory(), COOKING_POT_COMPLEX_DISHES.toVanillaCategory()
COOKING_POT_FOODS.toVanillaCategory(), COOKING_POT_MISC.toVanillaCategory(), COOKING_POT_MEDICINES.toVanillaCategory(), COOKING_POT_BAITS.toVanillaCategory()
)
)
}
@@ -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")
@@ -32,7 +32,6 @@ class PokemonCriterion(
}
override fun matches(player: ServerPlayer, context: Pokemon): Boolean {
var speciesCheck = (species.equals(context.species.resourceIdentifier.path) || species.equals(context.species.resourceIdentifier.toString())) || species.equals("any")
return speciesCheck && properties.matches(context)
return (species.equals(context.species.resourceIdentifier.path) || species.equals(context.species.resourceIdentifier.toString())) && properties.matches(context)
}
}
@@ -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,25 +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.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
@@ -17,20 +17,25 @@ object SpawnBaitUtils {
return grouped.map { (key, groupEffects) ->
val (type, subcategory) = key
val count = groupEffects.size
val totalChance = groupEffects.sumOf { it.chance }
val totalValue = groupEffects.sumOf { it.value }
if (type == SpawnBait.Effects.RARITY_BUCKET) {
// we want to keep the highest rarity bucket effect instead of merging them
groupEffects.maxByOrNull { it.value }!!
} else {
val count = groupEffects.size
val totalChance = groupEffects.sumOf { it.chance }
val totalValue = groupEffects.sumOf { it.value }
val multiplier = when (count) {
2 -> 0.8
3 -> 0.6
else -> 1.0
val multiplier = when (count) {
2 -> 0.8
3 -> 0.6
else -> 1.0
}
val adjustedChance = (totalChance * multiplier).coerceAtMost(1.0)
val adjustedValue = ceil(totalValue * multiplier)
SpawnBait.Effect(type, subcategory, adjustedChance, adjustedValue)
}
val adjustedChance = (totalChance * multiplier).coerceAtMost(1.0)
val adjustedValue = ceil(totalValue * multiplier)
SpawnBait.Effect(type, subcategory, adjustedChance, adjustedValue)
}
}
}
@@ -12,7 +12,6 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.callback.MoveSelectCallbacks
import com.cobblemon.mod.common.api.callback.PartyMoveSelectCallbacks
import com.cobblemon.mod.common.api.moves.Move
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
@@ -93,13 +92,7 @@ interface PokemonAndMoveSelectingItem {
}
}
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
if (stack.`is`(CobblemonItemTags.POKE_FOOD)) {
return !pokemon.isFull()
}
return true
}
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean = bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
fun canUseOnMove(stack: ItemStack, pokemon: Pokemon, move: Move): Boolean = canUseOnMove(stack, move)
fun canUseOnMove(stack: ItemStack, move: Move): Boolean
@@ -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
@@ -106,13 +105,7 @@ interface PokemonSelectingItem {
}
}
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
if (stack.`is`(CobblemonItemTags.POKE_FOOD)) {
return !pokemon.isFull()
}
return true
}
fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean
fun canUseOnBattlePokemon(stack: ItemStack, battlePokemon: BattlePokemon): Boolean = bagItem!!.canUse(stack, battlePokemon.actor.battle, battlePokemon)
fun interactWithSpecificBattle(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon): InteractionResultHolder<ItemStack> {
@@ -143,7 +136,6 @@ interface PokemonSelectingItem {
}
)
return InteractionResultHolder.success(stack)
}
@@ -619,9 +619,8 @@ object MoLangFunctions {
map.put("biome") { _ -> entity.level().getBiome(entity.blockPosition()).asBiomeMoLangValue() }
map.put("is_passenger") { DoubleValue(entity.isPassenger) }
map.put("find_nearby_block") { params ->
val input = params.getString(0)
val isTag = input.contains("#")
val type = input.replace("#", "").asIdentifierDefaultingNamespace(namespace = "minecraft")
val type = params.getString(0).asIdentifierDefaultingNamespace(namespace = "minecraft")
val isTag = type.path.startsWith("#")
val range = params.getDoubleOrNull(1) ?: 10
val blockPos = entity.level().getBlockStatesWithPos(AABB.ofSize(entity.position(), range.toDouble(), range.toDouble(), range.toDouble()))
.filter { it.first.blockHolder.let { if (isTag) it.`is`(TagKey.create(Registries.BLOCK, type)) else it.`is`(type) } }
@@ -151,11 +151,6 @@ open class PlayerPartyStore(
removeList.add(it)
}
removeList.forEach { pokemon.evolutionProxy.server().remove(it) }
// Metabolism for Fullness
if (pokemon.currentFullness > 0) {
pokemon.tickMetabolism()
}
}
// Friendship
// ToDo expand this down the line just a very basic implementation for the first releases
@@ -28,7 +28,6 @@ object CobblemonItemTags {
@JvmField val APRICORN_POKE_BALLS = create("apricorn_poke_balls")
@JvmField val APRICORN_SPROUTS = create("apricorn_sprouts")
@JvmField val APRICORNS = create("apricorns")
@JvmField val APRIJUICES = create("aprijuices")
/** This tag is only used for a Torterra aspect based easter egg evolution at the moment.
* It simply includes the 'minecraft:azalea' and 'minecraft:flowering_azalea' items by default. */
@JvmField val AZALEA_TREE = create("azalea_tree")
@@ -52,7 +51,6 @@ object CobblemonItemTags {
@JvmField val FIRE_STONE_ORES = create("fire_stone_ores")
@JvmField val FOSSIL_MACHINE_PARTS = create("fossil_machine_parts")
@JvmField val FOSSILS = create("fossils")
@JvmField val FULL_HEAL_INGREDIENTS = create("full_heal_ingredients")
@JvmField val GILDED_CHESTS = create("gilded_chests")
@JvmField val HANGING_SIGNS = create("hanging_signs")
@JvmField val HERBS = create("herbs")
@@ -62,7 +60,6 @@ object CobblemonItemTags {
@JvmField val MINT_LEAF = create("mint_leaf")
@JvmField val MINT_SEEDS = create("mint_seeds")
@JvmField val MINTS = create("mints")
@JvmField val MOCHIS = create("mochis")
@JvmField val MOON_STONE_ORES = create("moon_stone_ores")
@JvmField val MUTATED_BERRIES = create("mutated_berries")
@JvmField val PLANTS = create("plants")
@@ -70,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] */
@@ -78,17 +74,14 @@ object CobblemonItemTags {
@JvmField val RED_TUMBLESTONE_BRICKS = create("red_tumblestone_bricks")
@JvmField val RED_TUMBLESTONES = create("red_tumblestones")
@JvmField val REMEDIES = create("remedies")
@JvmField val REMEDY_BERRIES = create("remedy_berries")
@JvmField val RESTORES = create("restores")
@JvmField val REVIVES = create("revives")
@JvmField val SANDWICH_VEGGIE = create("sandwich_veggies")
@JvmField val SEEDS = create("seeds")
@JvmField val SHINY_STONE_ORES = create("shiny_stone_ores")
@JvmField val SIGNS = create("signs")
@JvmField val SKY_TUMBLESTONE_BRICKS = create("sky_tumblestone_bricks")
@JvmField val SKY_TUMBLESTONES = create("sky_tumblestones")
@JvmField val SUN_STONE_ORES = create("sun_stone_ores")
@JvmField val SUPER_POTION_INGREDIENTS = create("super_potion_ingredients")
@JvmField val SWEETS = create("sweets")
@JvmField val TEACUPS = create("teacups")
@JvmField val TEAPOTS = create("teapots")
@@ -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
@@ -16,7 +16,6 @@ import com.cobblemon.mod.common.advancement.CobblemonCriteria
import com.cobblemon.mod.common.api.pasture.PastureLinkManager
import com.cobblemon.mod.common.api.scheduling.afterOnServer
import com.cobblemon.mod.common.api.text.red
import com.cobblemon.mod.common.api.text.textClickHandlers
import com.cobblemon.mod.common.block.PastureBlock
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.net.messages.client.effect.SpawnSnowstormEntityParticlePacket
@@ -97,15 +96,6 @@ class PokemonPastureBlockEntity(pos: BlockPos, state: BlockState) :
if (blockEntity.ticksUntilCheck <= 0) {
blockEntity.checkPokemon()
}
// for every tethered pokemon tick metabolism if fullness is above 0
val tetheredPokemonList = blockEntity.tetheredPokemon.filter { it.getPokemon() != null }
for (tetheredPokemon in tetheredPokemonList) {
val pokemon = tetheredPokemon.getPokemon()!!
if (pokemon.currentFullness > 0) {
pokemon.tickMetabolism()
}
}
blockEntity.togglePastureOn(blockEntity.getInRangeViewerCount(world, blockEntity.blockPos) > 0)
}
}
@@ -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)
}
}
@@ -21,7 +21,7 @@ fun generateAdditionalFlavorTooltip(flavours: Map<Flavour, Int>): MutableList<Co
resultLines.add(flavorSubHeader)
val combinedFlavorsLine = Component.literal("")
flavours.filter { it.key != Flavour.MILD }.forEach { (flavour, value) ->
flavours.forEach { (flavour, value) ->
var flavourText = lang("seasoning_flavor.${flavour.name.lowercase()}").withStyle(flavour.chatFormatting)
if (combinedFlavorsLine.string.isNotEmpty()) {
@@ -20,7 +20,7 @@ object SeasoningTooltipGenerator : TooltipGenerator() {
override fun generateAdditionalTooltip(stack: ItemStack, lines: MutableList<Component>): MutableList<Component>? {
val flavors = Seasonings.getFlavoursFromItemStack(stack)
if (flavors.all { it.value == 0 }) {
if (flavors.isEmpty()) {
return null
}
return generateAdditionalFlavorTooltip(flavors)
@@ -302,9 +302,6 @@ class CobblemonConfig {
@CobblemonConfigField(Category.Spawning, lang = "despawner_max_age_ticks")
var despawnerMaxAgeTicks = 3600
@CobblemonConfigField(Category.World, lang = "blacklist_vanilla_mobs")
var blacklistVanillaMobs = false
fun clone(): CobblemonConfig {
val newConfig = CobblemonConfig()
CobblemonConfig::class.memberProperties.forEach { property ->
@@ -1,69 +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.config
import com.cobblemon.mod.common.Cobblemon
import com.google.gson.GsonBuilder
import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.EntityType
import net.minecraft.world.entity.MobCategory
import java.io.File
import java.io.FileReader
import java.io.FileWriter
class CobblemonSpawnConfig(configPath: String) {
private val file = File(configPath)
private var blacklistedMobs: MutableList<String> = mutableListOf()
init {
if (Cobblemon.config.blacklistVanillaMobs) {
load()
save()
}
}
fun load() {
if (!file.exists()) {
blacklistedMobs = mutableListOf()
return
}
val reader = FileReader(file)
blacklistedMobs = GSON.fromJson(reader, blacklistedMobs::class.java)
}
fun save() {
val writer = FileWriter(file)
GSON.toJson(blacklistedMobs, writer)
writer.close()
}
fun <T: Entity> isBlacklisted(type: EntityType<T>): Boolean {
// Non-mobs can always spawn
if (!Cobblemon.config.blacklistVanillaMobs || type.category == MobCategory.MISC) return false
val location = type.builtInRegistryHolder().key().location()
return isBlacklisted(location.toString())
}
fun isBlacklisted(id: String): Boolean {
return id.substringBefore(":").equals("minecraft") && blacklistedMobs.contains(id.substringAfter(":"))
}
companion object {
val GSON = GsonBuilder()
.disableHtmlEscaping()
.setPrettyPrinting()
.create()
}
}
@@ -784,10 +784,7 @@ open class PokemonEntity(
pokemon = this.createSidedPokemon()
health = 0F
}
} else if(pokemon.storeCoordinates.get() == null) {
// when the vanilla /data merge command is used, it will also run through this load method
// and if we are not careful here, the pokemon instance will get rebuilt from scratch
// this will fuck with storages, as they are tied to these very pokemon instances and their observables
} else {
val ops = registryAccess().createSerializationContext(NbtOps.INSTANCE)
pokemon = try {
this.sidedCodec().decode(ops, nbt.getCompound(DataKeys.POKEMON)).orThrow.first
@@ -83,8 +83,7 @@ class AprijuiceItem(val type: Apricorn): CobblemonItem(Properties().stacksTo(16)
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
val boosts = getBoosts(stack, pokemon)
return boosts.isNotEmpty() && boosts.any { pokemon.canAddRideBoost(it.key, it.value) } && super.canUseOnPokemon(stack, pokemon)
return getBoosts(stack, pokemon).any { pokemon.canAddRideBoost(it.key, it.value) }
}
fun getBoosts(stack: ItemStack, pokemon: Pokemon): Map<RidingStat, Float> {
@@ -102,17 +101,20 @@ class AprijuiceItem(val type: Apricorn): CobblemonItem(Properties().stacksTo(16)
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
val boosts = getBoosts(stack, pokemon)
if (boosts.isEmpty()) {
return InteractionResultHolder.fail(stack)
}
if (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
val boosts = getBoosts(stack, pokemon)
// Feed the Pokémon 1 fullness point
pokemon.feedPokemon(1)
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 (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
// Feed the Pokémon 4 fullness points
pokemon.feedPokemon(4)
val friendshipChange = PokePuffUtils.calculateFriendshipChange(stack, pokemon.nature)
if (friendshipChange != 0) {
@@ -170,7 +163,7 @@ class PokePuffItem : Item(Properties().stacksTo(16)), PokemonSelectingItem {
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
return getFriendshipDelta(stack, pokemon) != 0 && super.canUseOnPokemon(stack, pokemon)
return getFriendshipDelta(stack, pokemon) != 0
}
private fun getFriendshipDelta(stack: ItemStack, pokemon: Pokemon): Int {
@@ -1,89 +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.item
import com.cobblemon.mod.common.CobblemonItemComponents
import com.cobblemon.mod.common.CobblemonItems
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.apricorn.Apricorn
import com.cobblemon.mod.common.api.conditional.RegistryLikeIdentifierCondition
import com.cobblemon.mod.common.api.cooking.Flavour
import com.cobblemon.mod.common.api.cooking.PokePuffUtils
import com.cobblemon.mod.common.api.cooking.Seasonings
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.riding.stats.RidingStat
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.pokemon.Nature
import com.cobblemon.mod.common.pokemon.Pokemon
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.network.chat.Component
import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvent
import net.minecraft.sounds.SoundEvents
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.Item
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.UseAnim
import net.minecraft.world.level.Level
class RegionalFoodItem(properties: Properties) : Item(properties), PokemonSelectingItem {
override val bagItem = null
override fun use(world: Level, player: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
val stack = player.getItemInHand(hand)
// Allow eating normally if player needs food
if (player.foodData.needsFood()) {
player.startUsingItem(hand)
return InteractionResultHolder.consume(stack)
}
return InteractionResultHolder.fail(stack)
}
override fun interactLivingEntity(stack: ItemStack, player: Player, target: LivingEntity, hand: InteractionHand): InteractionResult {
if (player.level().isClientSide) return InteractionResult.PASS
if (player is ServerPlayer && target is PokemonEntity) {
val pokemon = target.pokemon
if (pokemon.status != null) {
return InteractionResult.SUCCESS
}
}
return InteractionResult.PASS
}
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon): InteractionResultHolder<ItemStack> {
if (pokemon.status != null) {
pokemon.status = null
pokemon.entity?.playSound(SoundEvents.GENERIC_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
return InteractionResultHolder.success(stack)
}
return InteractionResultHolder.fail(stack)
}
override fun getUseAnimation(stack: ItemStack): UseAnim = UseAnim.EAT
override fun getUseDuration(stack: ItemStack, entity: LivingEntity): Int = 32
override fun getEatingSound(): SoundEvent = SoundEvents.GENERIC_EAT
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon): Boolean {
return pokemon.status != null && pokemon.currentHealth > 0
}
}
@@ -35,19 +35,12 @@ import net.minecraft.world.level.Level
*/
class FriendshipRaisingBerryItem(block: BerryBlock, val stat: Stat) : BerryItem(block), PokemonSelectingItem {
override val bagItem = null
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = (pokemon.evs.getOrDefault(stat) > 0 || pokemon.friendship < Cobblemon.config.maxPokemonFriendship)
&& super.canUseOnPokemon(stack, pokemon)
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.evs.getOrDefault(stat) > 0 || pokemon.friendship < Cobblemon.config.maxPokemonFriendship
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack> {
if (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
val friendshipRaiseAmount = genericRuntime.resolveInt(CobblemonMechanics.berries.friendshipRaiseAmount, pokemon)
val increasedFriendship = pokemon.incrementFriendship(friendshipRaiseAmount)
@@ -56,8 +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)
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -45,19 +45,17 @@ class HealingBerryItem(block: BerryBlock, val amount: () -> ExpressionLike): Ber
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = !pokemon.isFainted() && !pokemon.isFullHealth()
&& super.canUseOnPokemon(stack, pokemon)
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (!canUseOnPokemon(stack, pokemon)) {
if (pokemon.isFullHealth() || pokemon.isFainted()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
pokemon.currentHealth = Integer.min(pokemon.currentHealth + genericRuntime.resolveInt(amount(), pokemon), pokemon.maxHealth)
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
}
@@ -66,7 +64,7 @@ class HealingBerryItem(block: BerryBlock, val amount: () -> ExpressionLike): Ber
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
super.applyToBattlePokemon(player, stack, battlePokemon)
battlePokemon.originalPokemon.feedPokemon(1)
battlePokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
@@ -48,26 +48,20 @@ 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) }
&& super.canUseOnPokemon(stack, pokemon)
override fun applyToPokemon(player: ServerPlayer, stack: ItemStack, pokemon: Pokemon, move: Move) {
if (canUseOnPokemon(stack, pokemon) && canUseOnMove(stack, move)) {
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))
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)
}
}
}
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon, move: Move) {
super.applyToBattlePokemon(player, stack, battlePokemon, move)
battlePokemon.originalPokemon.feedPokemon(1)
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
@@ -48,26 +48,20 @@ class PortionHealingBerryItem(block: BerryBlock, val canCauseConfusion: Boolean,
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = !pokemon.isFainted() && !pokemon.isFullHealth()
&& super.canUseOnPokemon(stack, pokemon)
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (!canUseOnPokemon(stack, pokemon)) {
if (pokemon.isFullHealth() || pokemon.isFainted()) {
return InteractionResultHolder.fail(stack)
}
// count these berries as multiple feedings due to the amount they heal
pokemon.feedPokemon(5)
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)
}
@@ -76,7 +70,7 @@ class PortionHealingBerryItem(block: BerryBlock, val canCauseConfusion: Boolean,
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
super.applyToBattlePokemon(player, stack, battlePokemon)
battlePokemon.originalPokemon.feedPokemon(5)
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
@@ -39,19 +39,15 @@ class StatusCuringBerryItem(block: BerryBlock, vararg val status: Status): Berry
override fun getShowdownInput(actor: BattleActor, battlePokemon: BattlePokemon, data: String?) = "cure_status${status.takeIf { it.isNotEmpty() }?.let { " ${it.joinToString(separator = " ") { it.showdownName } }" } ?: "" }"
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.status?.let { it.status in status || status.isEmpty() } == true &&
pokemon.currentHealth > 0 &&
super.canUseOnPokemon(stack, pokemon)
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.status?.let { it.status in status || status.isEmpty() } == true && pokemon.currentHealth > 0
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
return if (canUseOnPokemon(stack, pokemon)) {
pokemon.feedPokemon(1)
val currentStatus = pokemon.status?.status
return if (currentStatus != null && (status.isEmpty() || currentStatus in status)) {
pokemon.status = null
pokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
stack.shrink(1)
@@ -64,7 +60,7 @@ class StatusCuringBerryItem(block: BerryBlock, vararg val status: Status): Berry
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
super.applyToBattlePokemon(player, stack, battlePokemon)
battlePokemon.originalPokemon.feedPokemon(1)
battlePokemon.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
@@ -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)
}
@@ -23,7 +23,7 @@ enum class CookingPotBookCategory(
) : StringRepresentable {
FOODS("foods", 0),
MEDICINES("medicines", 1),
COMPLEX_DISHES("complex_dishes", 2),
BAITS("baits", 2),
MISC("misc", 3);
override fun getSerializedName() = categoryName
@@ -37,20 +37,22 @@ class CookingPotShapelessRecipe(
override fun canCraftInDimensions(width: Int, height: Int) = width * height >= ingredients.size
override fun matches(input: CraftingInput, level: Level): Boolean {
val remaining = ingredients.toMutableList()
// Match ingredients in any order
val matchedIngredients = mutableListOf<Ingredient>()
for (item in input.items()) {
if (item.isEmpty) continue
val matchIndex = remaining.indexOfFirst { it.test(item) }
if (matchIndex != -1) {
remaining.removeAt(matchIndex)
// Find matching ingredient
val matchingIngredient = ingredients.find { it.test(item) && it !in matchedIngredients }
if (matchingIngredient != null) {
matchedIngredients.add(matchingIngredient)
} else {
return false
}
}
return remaining.isEmpty()
val matches = matchedIngredients.size == ingredients.size
return matches
}
class Serializer : RecipeSerializer<CookingPotShapelessRecipe> {
@@ -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)
@@ -38,8 +38,6 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = !pokemon.isFullHealth() && pokemon.currentHealth > 0
&& super.canUseOnPokemon(stack, pokemon)
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (user is ServerPlayer) {
return use(user, user.getItemInHand(hand))
@@ -52,11 +50,9 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack>? {
if (!canUseOnPokemon(stack, pokemon)) {
if (pokemon.isFullHealth()) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
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
@@ -76,7 +72,7 @@ class BerryJuiceItem : CobblemonItem(Properties()), PokemonSelectingItem, Healin
override fun applyToBattlePokemon(player: ServerPlayer, stack: ItemStack, battlePokemon: BattlePokemon) {
super.applyToBattlePokemon(player, stack, battlePokemon)
battlePokemon.originalPokemon.feedPokemon(1)
player.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F)
if (!player.isCreative) {
val woodenBowlItemStack = ItemStack(Items.BOWL)
if (!player.inventory.add(woodenBowlItemStack)) {
@@ -27,9 +27,7 @@ abstract class EVIncreaseItem(
val evIncreaseAmount: Int,
) : CobblemonItem(Properties()), PokemonSelectingItem {
override val bagItem = null
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.evs.getOrDefault(stat) < EVs.MAX_STAT_VALUE &&
super.canUseOnPokemon(stack, pokemon)
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.evs.getOrDefault(stat) < EVs.MAX_STAT_VALUE
abstract val sound: SoundEvent
override fun applyToPokemon(
@@ -21,25 +21,18 @@ import net.minecraft.world.level.Level
class FreshStartMochiItem : CobblemonItem(Properties()), PokemonSelectingItem {
override val bagItem = null
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.evs.any { it.value > 0 }
&& super.canUseOnPokemon(stack, pokemon)
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack> {
if (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
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,27 +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 (!canUseOnPokemon(stack, pokemon)) {
return InteractionResultHolder.fail(stack)
}
pokemon.feedPokemon(1)
if (!player.isCreative) {
stack.shrink(1)
}
return super.applyToPokemon(player, stack, pokemon)
}
}
@@ -1,28 +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.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,105 +875,6 @@ open class Pokemon : ShowdownIdentifiable {
return ElementalTypes.FIRE in types || form.behaviour.moving.swim.canSwimInLava || form.behaviour.fireImmune
}
// function to return the max hunger for the pokemon
fun getMaxFullness(): Int = ((getGrassKnotPower(this.species.weight.toDouble()) / 10 / 2) + 1)
// function to get grassKnot power based on weight (in Lbs)
fun getGrassKnotPower(weight: Double): Int = 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, playSound: Boolean = true) {
// if it is already full we don't need to do anything (this will likely only ever happen when feeding in battle since we check for fullness already anyways elsewhere)
if (isFull()) {
return
}
this.currentFullness = (this.currentFullness + feedCount).coerceIn(0, this.getMaxFullness())
// play sounds from the entity
if (this.entity != null && playSound) {
val fullnessPercent = ((this.currentFullness).toFloat() / (this.getMaxFullness()).toFloat()) * (.5f)
if (this.currentFullness >= this.getMaxFullness()) {
this.entity?.playSound(CobblemonSounds.BERRY_EAT_FULL, 1F, 1F)
}
else {
this.entity?.playSound(CobblemonSounds.BERRY_EAT, 1F, 1F + fullnessPercent)
}
}
// 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 = max(0, this.currentFullness - value)
}
// Amount of seconds that need to pass for the pokemon to lose 1 fullness value
fun getMetabolismRate(): Int {
val speed = this.species.baseStats.getOrDefault(Stats.SPEED,0)
// Base Stat Total for the pokemon
val BST = species.baseStats.values.sum()
// multiplying scaling value
val multiplier = 4
//base berry count
val baseBerryCount = 20
//rate of metabolism in seconds
val 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
return if (metabolismRate <= 0) {
1 * 60
} else {
metabolismRate
}
}
// Boolean function that checks if a Pokemon can eat food based on fedTimes
fun isFull(): Boolean = currentFullness >= this.getMaxFullness()
// 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 Player owned and Pastured Pokémon for their fullness
*/
open fun tickMetabolism() {
// have metabolism cycle increase each second
metabolismCycle += 1
// if the metabolismCycle value equals the Pokemon's metabolism rate then decrease Fullness by 1
if (metabolismCycle >= this.getMetabolismRate()) {
if (this.currentFullness > 0) {
this.loseFullness(1)
}
//reset the metabolic cycle back to zero (redundant if we always go down by 1, but in case we make it go down faster
this.resetMetabolismCycle()
}
}
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, 100).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, 100).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",
@@ -756,23 +755,6 @@
"item.cobblemon.aprijuice.prefix.tasty": "Tasty",
"item.cobblemon.aprijuice.prefix.delicious": "Delicious",
"item.cobblemon.aprijuice.quality_format": "%1$s %2$s",
"item.cobblemon.tasty_tail": "Tasty Tail",
"item.cobblemon.candied_berry": "Candied Berries",
"item.cobblemon.candied_apple": "Candied Apple",
"item.cobblemon.fried_rice": "Fried Rice",
"item.cobblemon.pewter_crunchies": "Pewter Crunchies",
"item.cobblemon.rage_candy_bar": "Rage Candy Bar",
"item.cobblemon.lava_cookie": "Lava Cookie",
"item.cobblemon.old_gateau": "Old Gateau",
"item.cobblemon.jubilife_muffin": "Jubilife Muffin",
"item.cobblemon.casteliacone": "Casteliacone",
"item.cobblemon.lumiose_galette": "Lumiose Galette",
"item.cobblemon.shalour_sable": "Shalour Sable",
"item.cobblemon.big_malasada": "Big Malasada",
"item.cobblemon.smoked_tail_curry": "Smoked-Tail Curry",
"item.cobblemon.potato_mochi": "Potato Mochi",
"item.cobblemon.open_faced_sandwich": "Open-Faced Sandwich",
"item.cobblemon.relic_coin": "Relic Coin",
"block.cobblemon.relic_coin_pouch": "Relic Coin Pouch",
@@ -3394,10 +3376,6 @@
"tag.item.cobblemon.held.visibility.face": "Face Displayed Held Items",
"tag.item.cobblemon.held.visibility.hat": "Hat Displayed Held Items",
"tag.item.cobblemon.held.visibility.hidden": "Non-Displayed Held Items",
"tag.item.cobblemon.full_heal_ingredients": "Full Heal Ingredients",
"tag.item.cobblemon.remedy_berries": "Remedy Berries",
"tag.item.cobblemon.sandwich_veggies": "Sandwich Vegetables",
"tag.item.cobblemon.super_potion_ingredients": "Super Potion Ingredients",
"npc.sacchi.name": "Professor Sacchi",
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/big_malasada"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/casteliacone"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/jubilife_muffin"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/lava_cookie"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/lumiose_galette"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/moomoo_milk"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/old_gateau"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/open_faced_sandwich"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/pewter_crunchies"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/rage_candy_bar"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/shalour_sable"
}
}
@@ -1,6 +0,0 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "cobblemon:item/smoked_tail_curry"
}
}
@@ -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: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 549 B

After

Width:  |  Height:  |  Size: 409 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 628 B

After

Width:  |  Height:  |  Size: 236 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 497 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 470 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 558 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 605 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 526 B

After

Width:  |  Height:  |  Size: 604 B

@@ -142,8 +142,4 @@ accessible field net/minecraft/client/gui/screens/recipebook/RecipeBookComponent
accessible method net/minecraft/world/level/block/AbstractCandleBlock addParticlesAndSound (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/util/RandomSource;)V
transitive-accessible method net/minecraft/world/entity/ai/behavior/RandomStroll getTargetSwimPos (Lnet/minecraft/world/entity/PathfinderMob;)Lnet/minecraft/world/phys/Vec3;
# Vanilla Spawns
# Structures
accessible class net/minecraft/world/level/levelgen/structure/structures/OceanMonumentPieces$OceanMonumentPiece
transitive-accessible method net/minecraft/world/entity/ai/behavior/RandomStroll getTargetSwimPos (Lnet/minecraft/world/entity/PathfinderMob;)Lnet/minecraft/world/phys/Vec3;
@@ -0,0 +1,34 @@
{
"parent": "cobblemon:recipes/root",
"criteria": {
"has_brew": {
"conditions": {
"items": [
{
"items": [
"cobblemon:medicinal_brew"
]
}
]
},
"trigger": "minecraft:inventory_changed"
},
"has_the_recipe": {
"conditions": {
"recipe": "cobblemon:calcium"
},
"trigger": "minecraft:recipe_unlocked"
}
},
"requirements": [
[
"has_brew",
"has_the_recipe"
]
],
"rewards": {
"recipes": [
"cobblemon:calcium"
]
}
}
Loaded 100 of 362 files, more files were not shown because too many files have changed in this diff. Show more