Compare commits

..
Author SHA1 Message Date
Test e696c7b37e Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch
# Conflicts:
#	common/src/main/resources/assets/cobblemon/dynamiclights/item/flame_orb.json
#	common/src/main/resources/assets/cobblemon/models/block/display_case.json
#	common/src/main/resources/assets/cobblemon/models/block/kings_rock.json
#	common/src/main/resources/assets/cobblemon/models/item/wearable/exp_share.json
#	common/src/main/resources/assets/cobblemon/models/item/wearable/rocky_helmet.json
2025-11-22 13:05:20 -05:00
Test b543692180 Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch
# Conflicts:
#	common/src/main/resources/assets/cobblemon/lang/en_us.json
2025-10-17 22:14:14 -04:00
Test 98fab80fb4 Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch
# Conflicts:
#	common/src/main/resources/assets/cobblemon/lang/en_us.json
2025-10-05 22:59:38 -04:00
Test efc1fd719c Merge branch 'main' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch
# Conflicts:
#	common/src/main/kotlin/com/cobblemon/mod/common/CobblemonBlocks.kt
#	common/src/main/resources/assets/cobblemon/lang/en_us.json
2025-09-10 22:50:07 -04:00
dhi_holo 9fb20e8850 Batch 1b and 2
Only texture updates, includes a bunch of stuff
2025-08-02 12:05:01 +10:00
dhi_holo ef17a6d496 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-08-02 11:13:20 +10:00
dhi_holo bcb444577b Update luminous_moss.json 2025-07-31 22:06:12 +10:00
dhi_holo 190fccce8f Batch 1a
Everstone, Luminous Moss, Heat Rock, Icy Rock, Smooth Rock, Sharp Beak
2025-07-31 21:59:49 +10:00
dhi_holo 127310ce5b Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-31 21:20:46 +10:00
dhi_holo 72152aa2dd Eviolite 4
It's better now!
2025-07-31 21:18:22 +10:00
dhi_holo f9810a0f00 Changelog.
The Merge Request Draws Near
2025-07-26 17:23:26 +10:00
dhi_holo 15385b9276 Multi-vitamins! 2025-07-26 16:42:24 +10:00
dhi_holo dae2b18353 Fight Fight, Take Your Pills!
Battle Items now are placeable.
2025-07-26 13:04:34 +10:00
dhi_holo ca5bda092f Code Improvement
The Medicine Items use a different logic for determing how they get used, making it still have the menu out of battles, and you can also place them during battle, working exactly like berries (because it's berry code)
2025-07-25 15:18:48 +10:00
dhi_holo 31291713d0 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-25 13:39:10 +10:00
dhi_holo 16bbbf6e18 ETHER!
Ethers and Elixirs, almost
2025-07-25 13:38:38 +10:00
dhi_holo c4ad1dde27 Place Your Meds
It works! I am a geenus!

Also some minor cleanup (and a change I have no idea why happened but seems to not be causing issues..?)
2025-07-24 20:21:06 +10:00
dhi_holo 2c401d26d9 Status Part A
Status Restore Items now have blocks, they're just
Not connected to each other yet
2025-07-24 18:47:38 +10:00
dhi_holo d4714721eb Code Cleanup
Just some minor code cleanup, some stuff probably should be gone over with a more experienced eye before merging, but I'm happy with the level it is currently at.
2025-07-24 16:01:38 +10:00
dhi_holo 2fb22029ff Asset Cleanup
Making some stuff cleaner, improving some decisions, preparing for approval
2025-07-24 13:34:13 +10:00
dhi_holo a96411c50b You Cannot Handle My Potions, Traveller
Yippee, we got Potion Blocks finished up now!
2025-07-23 19:33:16 +10:00
dhi_holo 191005b29a Phone Light?
Dex now emits a small light level as it was meant to
2025-07-23 16:10:26 +10:00
dhi_holo d68759e4a3 Balls
Balls now have recipes
2025-07-23 15:26:35 +10:00
dhi_holo 25bf01ca20 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-23 10:08:47 +10:00
dhi_holo 4b8426d78c Magnetic Personality
Added Magnet Block, improved Six Face code, updated Metal Coat
2025-07-16 13:02:33 +10:00
dhi_holo 26c62acb6c Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-15 20:12:46 +10:00
dhi_holo 70522f3f3f Update metal_coat.png
contrast
2025-07-15 20:12:04 +10:00
dhi_holo 8423df7ef9 Metal Coated
Metal Coat is now placeable, plus some minor tweaks to how the other floor stackables are being handled
2025-07-15 18:12:37 +10:00
dhi_holo d8f83697c8 Remoss
Luminous Moss Remodel, and Galarica Wreath cleanup
2025-07-15 15:36:25 +10:00
dhi_holo 2b81da943e Redstone!!!!!!!!!!!!!!!! 2025-07-15 12:57:49 +10:00
dhi_holo a8e7a01e48 Unjammed 2025-07-14 18:47:31 +10:00
dhi_holo aa2a3d69fb Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-14 17:17:18 +10:00
dhi_holo 880f919f9f Jammed
Eject Button partially implemented as a redstone button - it just doesn't unclick currently, and I'm not certain why
2025-07-14 17:17:08 +10:00
dhi_holo d1557b23b4 Display Target 2025-07-13 19:17:35 +10:00
dhi_holo e3fab0f69c Darts and Cleanup
Ring Target, plus corrected stuff that broke/was inaccurate with the changes I did on a different branch that is now merged
2025-07-13 18:38:14 +10:00
dhi_holo 0f24cf8480 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-13 16:47:31 +10:00
dhi_holo 3ebba3dfe5 ROCK AND STEEL
Hard Stone and Iron Ball
2025-07-12 20:19:41 +10:00
dhi_holo b339b552c6 Beak n Cloak 2025-07-12 14:59:13 +10:00
dhi_holo 3a5095887d Clean Up
Fixed some lighting stuff and item models
2025-07-12 14:11:16 +10:00
dhi_holo 6b9821e170 MORB
Orbs can now be placed on walls and ceilings
2025-07-12 12:37:54 +10:00
dhi_holo e24a0e637a Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-12 10:25:22 +10:00
dhi_holo 924450d4c8 O R B
Life, Flame, Toxic Orbs, Light and Smoke Balls, Yippee
2025-07-11 18:49:38 +10:00
dhi_holo a4aabbb28f Evers
New Everstone and Eviolite models/textures
2025-07-11 13:38:04 +10:00
dhi_holo e5029bf074 Alloy!
Metal Alloy, added a flag to the EXP Share for future versions to pick up on innately, and fixed a bug with oval stone
2025-07-10 20:12:23 +10:00
dhi_holo 8135c3baef Not Evolution Stone Evolutation-Related Stones
Everstone, Eviolite, and Oval Stone, nice and cute in the display case
2025-07-10 20:11:29 +10:00
dhi_holo 72ce0a843d Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-10 11:01:06 +10:00
dhi_holo 2fef675958 Update dusk_stone.json
Whoops
2025-07-09 20:12:39 +10:00
dhi_holo 6b3722f9b9 Stoned
Base 10 Evolution Stones now have models and textures, yippee
2025-07-09 19:35:56 +10:00
dhi_holo 6384fc9fcb Stoning Continues 2025-07-09 12:05:02 +10:00
dhi_holo a8b2e2b72d Stoning
Added model files for all 10 stones, updated texture layouts, updated leaf stone, added sun stone
2025-07-09 08:28:04 +10:00
dhi_holo 431ab62ebb Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-09 08:10:35 +10:00
dhi_holo af50547477 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-08 20:14:29 +10:00
dhi_holo de5ab3d2dc Cleaning some files up
sweep sweep
2025-07-08 20:14:01 +10:00
dhi_holo a803bb9be8 Reorg and Stones
Reorganised how I do the Link Cable/Cobblemon Icons, started working on evolution stones in display case
2025-07-08 15:07:04 +10:00
dhi_holo b19074d130 Display Case Item Fixes
Wearables now render exactly like a regular item
Display Case shading is a bit better, thanks to a cleaned up model and one odd line of code
Placeable Items now in Creative Inventory for easity - should reorganise it later
2025-07-08 13:57:37 +10:00
dhi_holo 3c048b7eb0 Tag Changes
Display Case Items tag now is used for the Display Case, with Item Blocks being entirely separate, rather than being two tags for it.

Also changed the Plaque recipes.
2025-07-08 11:46:21 +10:00
dhi_holo 185b06082c Cleanup 2025-07-07 21:11:52 +10:00
dhi_holo b9bbbc3c4d Display Case Progress
The Decorative Item Blocks that are not wearables now render in the display case! Not perfectly yet, but progress is progress.

Also added temp recipes for the Plaques, they need more design decisions but I wanted the files there for now
2025-07-07 20:43:06 +10:00
dhi_holo f76886bab8 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-07 17:42:09 +10:00
dhi_holo f163cf0722 Update GalaricaWreathBlock.kt
fixing oversight
2025-07-07 17:28:32 +10:00
dhi_holo f1966208a8 Plaques!
Lots of plaques, missing a few recipes still but pretty close to all implemented for the builderinos
2025-07-07 17:27:28 +10:00
dhi_holo 52f4541836 Update CobblemonBlocks.kt 2025-07-06 18:02:11 +10:00
dhi_holo 4c7adb01b7 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-06 15:33:05 +10:00
dhi_holo f40fbf31bb Delete vivichoke_seeds.png
that was a weird file in the wrong place right there
2025-07-06 14:56:33 +10:00
dhi_holo cd1f052837 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-07-06 12:33:36 +10:00
dhi_holo fd323b5e61 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-26 17:46:49 +10:00
dhi_holo 69f4a52621 Pouches and Parity
Sachet, Bright Powder, Metal Powder, and Quick Powder are now placeable, and the DecorativeItemBlocks now place consistently with other blocks.
Tomorrow, we ORB
2025-06-18 20:41:57 +10:00
dhi_holo dff9612db4 Update Sprites
Upgrade, Dubious Disc, and Luminous Moss now use replaced sprites to better match their models. Peat Block now uses the 3D model instead of the sprite, but this can be toggled back using Custom Model Data.
2025-06-17 18:07:38 +10:00
dhi_holo 16049e5476 Slight Texture Relacement, and Moss Has Been Defeated
Block texture folder is becoming a nightmare to navigate, so I've moved my small modelled block textures into a sub-folder, leaving the full block textures in the main folder for now. May do a cleanup to make block texture folder and item texture folder have cleanliness parity at some point, not for this branch.

Also the luminous moss looks good now
2025-06-17 16:36:11 +10:00
dhi_holo 4331375832 It's Destiny
Destiny Knot texture updated with nicer contrast
2025-06-17 12:55:34 +10:00
dhi_holo e1b86ab910 Peatr, the textures are here 2025-06-17 11:37:19 +10:00
dhi_holo 161165d8da The Walls Are No Longer Barren
Galarica Wreath improvements, and two new block types, Wall Attached Decorative Item Blocks, and Wall Attached Stackable Item Blocks. WADIBs include Blunder and Weakness Policies, while WASIBs include the Cleanse and Spell Tags (which are also wearable).
2025-06-16 20:56:59 +10:00
dhi_holo cf5693de8a Peatr and logic for wall decor
the homse was here

Also completely redid the items so far to be itemNameBlockItem as that's a better convention to follow
2025-06-15 20:47:30 +10:00
dhi_holo 9a1afe9342 Never-Melt Crown 2025-06-15 11:21:13 +10:00
dhi_holo b3e77f9eb1 Merge branch 'decorative-items-proofofconceptbranch' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch 2025-06-14 21:14:17 +10:00
plastered_crab df06413ffb Potion changes 2025-06-14 04:11:30 -07:00
dhi_holo 9aa67d836b Potion Start and Never-Melt 2025-06-14 20:47:19 +10:00
dhi_holo 24bbb57ca4 Update CobblemonBlocks.kt
Checkpoint of the potion blocks before I totally upend this logic because it feels like class bloat
2025-06-14 17:31:23 +10:00
plastered_crab c976c9f85b Merge remote-tracking branch 'origin/decorative-items-proofofconceptbranch' into decorative-items-proofofconceptbranch 2025-06-13 23:59:21 -07:00
plastered_crab 16b94b19dc Potion changes 2025-06-13 23:59:09 -07:00
dhi_holo 5d2473066d Fixed an import 2025-06-14 16:45:39 +10:00
plastered_crab a835a8d314 Potion changes 2025-06-13 23:16:51 -07:00
plastered_crab 0bc351a533 Merge remote-tracking branch 'origin/decorative-items-proofofconceptbranch' into decorative-items-proofofconceptbranch 2025-06-13 22:56:28 -07:00
plastered_crab 7ad5e88402 Potion change to allow for menu to pop up only when in battle 2025-06-13 22:55:15 -07:00
dhi_holo 5a610932a2 very minor model tweak
NO. MORE. Z-FIGHTING!
2025-06-14 15:37:53 +10:00
dhi_holo 0bafe7e682 Merge branch 'decorative-items-proofofconceptbranch' of https://gitlab.com/cable-mc/cobblemon into decorative-items-proofofconceptbranch 2025-06-14 15:13:28 +10:00
plastered_crab 1260420bfb Potion change to allow for menu to pop up only when in battle 2025-06-13 22:12:38 -07:00
dhi_holo 185e8ec9b2 Translucents and Dubious Fix 2025-06-14 15:10:36 +10:00
dhi_holo f782c0f6ed Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-14 14:54:53 +10:00
dhi_holo aec0717e75 Stacks and Stacks
Ugrades and Dubious Discs are now placeable. They can be placed up to four times within the same block. This is done with a new class to let me do it for any future decorative blocks too! Huzzah.
2025-06-14 14:54:45 +10:00
dhi_holo 55276f5e96 Began Investigating Display Case Stuff
Committing this in an ask for help. I want the Relic Coin Pouch rendering stuff to work for all items added to this tag, just awkwardly shoving it in didn't work, so I'm pushing all my changes to ask for help.
2025-06-13 17:09:01 +10:00
dhi_holo 3e81be4c75 Weather Rocks!
Very good desk decoration
2025-06-13 12:28:04 +10:00
dhi_holo 37c393d314 Update GalaricaWreathBlock.kt 2025-06-12 17:31:19 +10:00
dhi_holo a0ee80b3b6 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-12 16:03:51 +10:00
dhi_holo 3809da42b2 Tick Tock (But Refined)
Metronome now has a togglable animation state, fixed issue with Galarica Wreath waterlogging
2025-06-12 16:03:36 +10:00
dhi_holo a18e96c10d Tick Tock
Metronome block now exists
2025-06-11 19:57:49 +10:00
dhi_holo adf159fd8e Knot Right?
Destiny Knot is now a block

Also added a Galarica block tag
2025-06-11 14:36:38 +10:00
dhi_holo 53dfdfd0c2 Galarica Complete, plus Shelmet Shell Helmet
Also fix something I've been overlooking
2025-06-11 13:11:05 +10:00
dhi_holo b956016c2d Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-11 11:16:05 +10:00
dhi_holo 119d11e03c Galar Foreva!!!
Minor cleanup of how the general decorative voxelshape is handled, and the start of the wreath nightmare
No data files yet, need to improve the placement logic on the wreath to let it have different rules for each direction
2025-06-10 20:19:44 +10:00
dhi_holo 55c8380777 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-10 16:05:58 +10:00
dhi_holo 90c7b88007 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-09 09:54:30 +10:00
dhi_holo 033137029d Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-08 12:59:07 +10:00
dhi_holo fa2246843f moss, yummy 2025-06-07 18:30:07 +10:00
dhi_holo 2dfa3dcdc1 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-07 16:12:08 +10:00
dhi_holo 8812c775cf Better Boundary Kings Rock
Just making it fit the model a little better, nothing fancy
(Also cleaning up some unused bounding boxes for the teapots)
2025-06-06 17:09:24 +10:00
dhi_holo f6c003e90f Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-06 16:29:05 +10:00
Polymeta 9c39cb3ebc make wearable check if a block got passed in and use that translation key otherwise item fallback lang
Signed-off-by: Polymeta <40173118+Polymeta@users.noreply.github.com>
2025-06-05 16:30:45 +01:00
dhi_holo 36f5c4597e Update en_us.json 2025-06-05 20:04:24 +10:00
dhi_holo f0aa728174 Fully Functional 2025-06-05 20:03:41 +10:00
Polymeta 4f34b6b556 fix errors and allow wearbles to be swapped with right click (same as armoritems)
Signed-off-by: Polymeta <40173118+Polymeta@users.noreply.github.com>
2025-06-05 10:07:21 +01:00
Polymeta d639f78571 make wearableItem a blockItem but make sure only valid blocks can be placed
Signed-off-by: Polymeta <40173118+Polymeta@users.noreply.github.com>
2025-06-05 00:11:13 +01:00
dhi_holo 6adc3991db Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-05 08:12:42 +10:00
dhi_holo 2f7889df97 Update CobblemonItems.kt 2025-06-05 08:11:28 +10:00
dhi_holo d8a667c424 Delete kings_rock.png 2025-06-04 20:27:59 +10:00
dhi_holo 9fda6a53c5 You Are King 2025-06-04 20:27:46 +10:00
dhi_holo c80ce11314 you are king 2025-06-04 20:26:38 +10:00
dhi_holo ef58eb86da Would You Care For Some Tea??? 2025-06-04 16:27:17 +10:00
dhi_holo 02129fe2a1 Merge branch 'main' into decorative-items-proofofconceptbranch 2025-06-04 09:46:22 +10:00
dhi_holo 3f2d8cec09 IT WORKS
Implemented a functional placeable Kings Rock!

Still needs a couple things to improve this, like being able to set the hitbox for each instance of the block implementation (like tumblestones), but for a first try I'm proud
2025-01-18 15:16:51 +10:00
1035 changed files with 33142 additions and 22176 deletions

No files matched your search

+488 -10
View File
@@ -1,19 +1,498 @@
# Changelog
## [1.7.2 (MONTH Xth, YEAR)](#1-7-2)
## [1.7.1 (MONTH xth, 2025)](#1-7-1)
### Additions
- Added `/npcdelete` uuid parameter support and usuable to console
- Added `/spectateBattle <player>` command to spectate battles without having to manually walk up to the target.
- Added an in-game configuration screen, allowing all settings from `main.json` to be edited directly in-game.
- Added `/cobblemonconfig reload` command to reload `main.json` configuration. **Note:** Some settings require a server restart to take effect; use this command cautiously.
- Added `blacklisted_items_to_hold` and `whitelisted_items_to_hold` tags to allow for controlling which items players can give to their Pokémon. If the whitelist is empty, it will consider all item as allowed (unless they are in the blacklist).
- Pokémon now follow the mouse cursor on the Summary screen, with an option to disable this in the settings.
- Added Datapackable Item interactions with Pokemon
- Pokémon's held items can now be rendered, with a visibility toggle in the Summary screen.
- Added cosmetic item functionality for Pokémon. Certain cosmetic items can be given to applicable Pokémon via the interact menu.
- Added the various log blocks as cosmetic items for Timburr and Komala.
- Added cosmetics for Spoink, Gurdurr, Conkeldurr, Squirtle Line, Sneasler, Sandile line, Treecko line, Braixen, Delphox, and Dragonite.
- Added Gilded Chest cosmetics for Chest Gimmighoul and Gholdengo
- Added `visibility/hidden`, `visibility/hat` and `visibility/face` tags to control where and how certain items are rendered.
- Added Pokémon markings, toggleable within the summary.
- Added `/boxcount` command to change PC boxes amount
- Added `/transformmodelpart (position|rotation|scale) <modelPart> <transform: x y z>` command that can add transformations to a pokemon's model part.
- The player executing the command must be facing the target pokemon entity. Transformations are not persistent and will revert when resources are reloaded.
- Added `legacy` and `special` sourced moves to Pokémon.
- Added lang keys for all moves and abilities up to Generation 9.
- Added `translucent_cull` boolean option into resolver's layer to allow for translucent textures with culling
- Added [LambDynamicLights](https://modrinth.com/mod/lambdynamiclights) support for items held by Pokémon, evolution stone blocks, evolution stone items, Pokédex, Luminous Moss, Flame Orb, and Magmarizer.
- Added the Clear Amulet, Grip Claw, Lagging Tail, Luminous Moss, Metal Alloy, Scroll of Darkness, Scroll of Waters
- Added Recipes for Masterpiece Cup, Eject Pack.
- Added modification to Minecraft Creative Inventory search to account for item names that contain `poké` when input contains `poke`.
- Added Campfire Pot as well as loads of new food items (Poke Puffs, Ponigiri, Sinister Tea, etc)
- Added Hearty Grains, a new crop used in the new cooking mechanic
- Added Tatami blocks and Tatami Mat blocks, made from Hearty Grain, for decorating builds
- Added `/pcsearch <player> <pokemonProperties>` command that searches for a specific Pokémon within a player's PC.
- Added `/pctake <player> <box> <slot>` command that takes a specific Pokémon from a player's PC. Removes the pokemon if target is self or ran from the server.
- Added Hyper Training items (IV Modification) as well as some additional candy items to do so (Health Candy, Sickly Candy)
- Added Galarica Nut Bushes
- Many Pokémon (mostly cats) are now feared by phantoms
- Combees are now capable of gathering nectar from flowers and delivering it to either Saccharine leaves or hives. (Hive interactions are restricted to wild Combees)
- Lightning is now affected by a Pokemon's ability/typing
- Pokémon with the ability Lightning Rod draw in lightning similar to a lightning rod block albeit with a lower priority and range, gain immunity to lightning damage, and receive a temporary damage buff.
- Pokémon with the ability Motor Drive are immune to lightning damage and receive a temporary speed buff when struck by lightning
- Pokémon with the ability Volt Absorb are immune to lightning damage and receive Regeneration II for a short duration
- Ground type Pokémon are immune to lightning damage
- Added functionality to Everstone when held by a Pokémon; suppresses evolution notification and hides evolve button in summary interface.
- Added optional `filePath` parameter to MoLang functions to allow for global stores (ex. `../global/`). Path must end in a forward slash.
- Added new optional property `attachment_options` for most EmitterShapes to be attached to the locator/entities scale, rotation, and/or position. Position is true by default.
- Galarica Nut bushes now generate on beaches
- Added a lot of new blocks
- Floor Placeable: Damp Rock, Heat Rock, Icy Rock, Smooth Rock, Sachet, Bright Powder, Metal Powder, Quick Powder, Luminous Moss, Chipped Pot, Cracked Pot, Masterpiece Teacup, Unremarkable Teacup, Destiny Knot, Iron Ball, Hard Stone, Galarica Cuff, Kings Rock, Never-Melt Ice
- Floor Stackable: Upgrade, Dubious Disc, Metal Coat, Potion, Super Potion, Hyper Potion, Max Potion, Full Restore, Antidote, Awakening, Burn Heal, Ice Heal, Paralyze Heal, Full Heal, Ether, Elixir, Max Ether, Max Elixir, X Accuracy, X Attack, X Defence, X Special Attack, X Special Defence, X Speed, Dire Hit, Guard Spec, HP Up, Protein, Iron, Carbos, Calcium, Zinc, PP Up, PP Max
- Floor Interactive: Metronome
- Wall Placeable: Weakness Policy, Blunder Policy
- Wall Stackable: Cleanse Tag, Spell Tag
- Wall Interactive: Ring Target
- Six Face (Rotation): Galarica Wreath, Magnet, Flame Orb, Toxic Orb, Life Orb, Smoke Ball, Light Ball, White Plaque, Light Gray Plaque, Gray Plaque, Black Plaque, Brown Plaque, Red Plaque, Orange Plaque, Yellow Plaque, Lime Plaque, Green Plaque, Cyan Plaque, Light Blue Plaque, Blue Plaque, Purple Plaque, Magenta Plaque, Pink Plaque
- Six Face (Rotation) Interactive: Eject Button
- Six Directional Block: Peat Block
- Added recipe to Smoke Ball and Light Ball
- Galarica Nut bushes now generate on beaches.
- Some Pokémon now pitch their bodies in the direction they're moving.
- Added new advancements Didn't Stop To Think, We Need To Cook, and Pokémon Jockey!.
- Berries can now be smelted into their respective dyes.
- Added Syrupy Apples.
- Added `/runmolang <molang> [<npc>|<player>|<pokemon>]` command that executes a MoLang expression with the provided options as environment variables, as well as the entity (as `q.entity`) that executed the command.
- Added bubble quirk to Kingler; like Krabby, Kingler will blows bubbles during dusk.
- Added `.Pre` and `.Post` to the following events:
- `PokemonRecallEvent`
- `TradeEvent`
- Added a new gamerule, 'healerHealsPC', when set to true a successful use of a healer will also heal all of the Pokemon in that player's PC.
### Pokémon Added
#### Gen 2
- Marill
- Azumarill
- Hoppip
- Skiploom
- Jumpluff
- Dunsparce
- Togepi
- Togetic
- Unown
- Houndour
- Houndoom
- Ho-Oh
- Lugia
- Alola Bias Pichu (built-in resourcepack)
#### Gen 3
- Azurill
- Meditite
- Medicham
- Electrike
- Manectric
- Spoink
- Grumpig
- Swablu
- Altaria
- Snorunt
- Glalie
- Latias
- Latios
#### Gen 4
- Bronzor
- Bronzong
- Croagunk
- Toxicroak
- Froslass
- Glameow
- Purugly
- Skorupi
- Drapion
- Togekiss
#### Gen 5
- Pansage
- Simisage
- Pansear
- Simisear
- Panpour
- Simipour
- Munna
- Musharna
- Blitzle
- Zebstrika
- Drilbur
- Excadrill
- Trubbish
- Garbodor
- Gothita
- Gothorita
- Gothitelle
- Solosis
- Duosion
- Reuniclus
- Tynamo
- Eelektrik
- Eelektross
- Axew
- Fraxure
- Haxorus
- Mienfoo
- Mienshao
- Sewaddle
- Swadloon
- Leavanny
- Druddigon
#### Gen 6
- Skiddo
- Gogoat
- Espurr
- Meowstic
- Inkay
- Malamar
- Hawlucha
- Dedenne
- Noibat
- Noivern
- Furfrou
- You can change Furfrou's form by using shears on it while it holds a certain dye in its cosmetic slot.
#### Gen 7
- Yungoos
- Gumshoos
- Drampa
- Alolan Grimer
- Alolan Muk
- Togedemaru
#### Gen 8
- Skwovet
- Greedent
- Chewtle
- Drednaw
- Toxel
- Toxtricity
- Morpeko
- Silicobra
- Sandaconda
- Sinistea
- Polteageist
- Galarian Corsola
- Cursola
- Mr. Rime
- Galarian Mr. Mime
- Clobbopus
- Grapploct
- Galarian Weezing
#### Gen 9
- Smoliv
- Dolliv
- Arboliva
- Tarountula
- Spidops
- Orthworm
- Dudunsparce
- Cyclizar
- Poltchageist
- Sinistcha
- Capsakid
- Scovillain
- Tadbulb
- Bellibolt
- Toedscool
- Toedscruel
- Rellor
- Rabsca
- Bramblin
- Brambleghast
### Animation updates for the following Pokémon
- Garchomp
- Tropius
- Nosepass
- Probopass
- Sneasel
- Weavile
- Sneasler
- Braixen
- Delphox
- Cinderace
- Kangaskhan
- Gossifleur
- Eldegoss
- Stonjourner
- Wailmer
- Lechonk
- Oinkologne
- Dratini
- Dragonair
- Dragonite
- G. Corsola
- Cursola
- Dunsparce
- Dudunsparce (both forms)
- Porygon
- Porygon2
- Porygon-Z
- Wattrel
- Kilowattrel
- Golurk
- Spinarak
- Ariados
- Wyrdeer
- Tyrantrum
- Pidove
- Tranquill
- Unfezant
- Beldum
- Metang
- Metagross
- Plusle
- Minun
- Murkrow
- Honchkrow
- Larvesta
- Volcarona
- Dwebble
- Crustle
- Mr. Mime
- Flygon
- Pichu
- Pikachu
- Raichu
- Alolan Raichu
- Espathra
- Abra
- Kadabra
- Alakazam
- Deino
- Zweilous
- Hydreigon
- Slaking
- Klink
- Klang
- Klinklang
- Baltoy
- Claydol
- Mamoswine
- Rufflet
- Braviary
- Girafarig
- Farigiraf
- Rookidee
- Corvisquire
- Corviknight
- Venipede
- Whirlipede
- Scolipede
- Venusaur
- Parasect
- Bastiodon
- Amaura
- Varoom
- Revavroom
- Bouffalant
- Lickilicky
- Blaziken
- Rhyhorn
- Rhydon
- Rhyperior
- Tauros
- Tauros - Paldea Aqua
- Tauros - Paldea Blaze
- Tauros - Paldea Combat
- Dewgong
- Exeggutor - Kanto
### Model updates for the following Pokémon
- Cleffa
- Clefairy
- Clefable
- Gyarados
- Dragonite
- Eevee
- Vaporeon
- Jolteon
- Flareon
- Espeon
- Umbreon
- Leafeon
- Glaceon
- Sylveon
- Treecko
- Grovyle
- Sceptile
- Honchkrow
- Gible
- Gabite
- Garchomp
- Pidgeot
- Nosepass
- Probopass
- Kangaskhan
- Cinderace
- Magnemite
- Magneton
- Magnezone
- Beldum
- Metang
- Metagross
- Hoothoot
- Noctowl
- Teddiursa
- Ursaring
- Ursaluna
- Heatmor
- Bouffalant
- Sigilyph
- Sharpedo
- Maractus
- Clodsire
- Scyther
- Scizor
- Cacturne
- Taillow
- Swellow
- Seel
- Dewgong
- Honedge
- Doublade
- Aegislash
- Drowzee
- Hypno
- Mudkip
- Marshtomp
- Swampert
- Shelmet
- Escavalier
- Klink
- Klank
- Klinklang
- Spinarak
- Ariados
- Pidove
- Tranquill
- Unfezant
- Sobble
- Drizzile
- Inteleon
- Plusle
- Minun
- Murkrow
- Zorua
- Zoroark
- Mime.Jr
- Mr. Mime
- Pichu
- Pikachu
- Raichu
- Alolan Raichu
- Dusknoir
- Deino
- Zweilous
- Hydreigon
- Dreepy
- Drakloak
- Dragapult
- Mamoswine
- Rookidee
- Corvisquire
- Corviknight
- Venipede
- Whirlipede
- Scolipede
- Farigiraf
- Staryu
- Starmie
- Gimmighoul
- Gholdengo
- Starly
- Staravia
- Staraptor
- Varoom
- Revavroom
- Nickit
- Thievul
- Litwick
- Lampent
- Chandelure
### Changes
- Changed pokemon caught and seen count to update based on the current pokedex being looked
- Renamed `chargeGainedPerTick` config to `secondsToChargeHealingMachine`.
- Made Blocks of Gold count as Big Nuggets when held by a Pokémon (for Fling functionality)
- Players can now eat Sweet and Tart Apples, Whipped Dreams, and the Alcremie Sweets.
- Updated Sweet and Tart Apple sprites
- Updated the following recipes: Air Balloon, Assault Vest, Binding Band, Black Belt, Blunder Policy, Choice Band, Choice Scarf, Cleanse Tag, Covert Cloak, Destiny Knot, Eject Button, Expert Belt, Focus Band, Focus Sash, Magnet, Metronome, Muscle Band, Power Anklet, Power Band, Power Belt, Power Bracer, Power Lens, Power Weight, Protective Pads, Protein, Punching Glove, Reaper Cloth, Rocky Helmet, Room Service, Sachet, Safety Goggles, Silk Scarf, Spell Tag, Utility Umbrella, Weakness Policy, Zinc, Chipped Pot, Cracked Pot, Unremarkable Cup, Loaded Dice, Charcoal Stick, Dragon Fang, Miracle Seed, Mystic Water, Never Melt Ice, Twisted Spoon, Black Glasses, Fairy Feather, Hard Stone, Silver Powder, Soft Sand
- Added alternate ingredient options to the following recipes: Cell Battery, Damp Rock, Heat Rock, Icy Rock, Smooth Rock
- Grouped together some recipes within the Recipe Book. Groups include: the seven basic Poké Balls, the seven basic Ancient Poké Balls, Gilded Chests, Pokedexes, and the Weather Rocks.
- Updated some item tags to better integrate behaviours between Cobblemon, Vanilla Minecraft, and other mods
- Removed Cooked Meat, Raw Meat, Protein Ingredients, and Zinc Ingredients, the first two are now using `c` namespace tags, the latter have better integrated use of tags within their recipes which removes need for custom tags.
- Added our seeds tag into `#c:seeds`, which is now made use of for the Miracle Seed recipe.
- Added herbs and snowballs to the consumable in PvE and Wild battle tags
- Tweaked the Natural Materials Vanilla file to fit with the changes to tags
- Substantially optimised spawning checks mainly by front-loading biome filtering.
- When using the `cobblemon` or `generation_9` capture calculators a critical capture with a single shake will always play for successful captures when you've already registered the Pokémon as caught in your Pokédex.
- Improved the performance of saving Pokédex and player data.
- Pokémon hitbox now scales with entity attribute `generic.scale`.
- Removed Shulker aspect and replaced it with cosmetic_item-shulker_shell.
- Shulker shell Forretress is now a cosmetic rather than a special evo and thus all shulker Forretress will revert back to normal until a shulker shell is put in their cosmetic slot.
- Updated `doPokemonSpawning` gamerule to support per-dimension configurations.
- The Pokedex now displays a form name of a "normal" Pokémon for when the base form is still a named form.
- Improved the zoom functionality of the Pokédex Scanner by giving the levels logarithmic scaling.
- Added a subtle rotation effect to the Pokédex Scanner's wheel when zooming.
- Improved parity with vanilla mobs' drop behavior; loot and XP drop on death instead of after the entire death sequence finishes.
- Quirk animations no longer play in the battle GUI since they were pretty distracting.
- A number of Pokemon that float above the ground visually (Gastly, Klingklang, etc.) are no longer considered to be touching the ground
- Changed the recipes for Level, Lure, and Moon Balls to be cleaner
- Renamed `pokemonId` and `type` to `species` in relevant Advancement triggers for conformity, this is a breaking change.
- Added a separate `species` argument to the `pick_starter`, `pasture_use` and `resurrect_pokemon` Advancement triggers.
- Made `CobblemonAgingDespawner` thresholds configurable via the config file.
- Tweaked Berry flavor data to balance cooking pot mechanics
- Made Red, Yellow, Green, Blue, Pink, Black, and White Apricorn Sprout and Saccharine Sapling able to be placed into flower pots.
- Added all Potted Apricorn Sprouts, Potted Saccharine Saplings, and Potted Pep-Up Flowers to the `#minecraft:flower_pots` block tag
- Corrected the healing values of the remedies and energy root, and reintroduced the friendship lowering mechanics for them, revival herb, and heal powder
- Updated battle language keys for side effects to use position-specific formats, improving grammatical consistency
- Saccharine Leaves are now Collectable
- Saccharine Leaves Age 1 or higher will now show Yellow particles when broken
- Destroying a Saccharine Honey Log will now drop a Saccharine Log instead of nothing
- Reworked some compost chances
- Updated interaction interface to include 4 more option spaces
- Made lecterns that hold a Pokédex emit light.
- Updated light levels for active PC, Pasture, Healing Machine, and Data Monitor.
- Vivichokes now always drop one seed when harvested, and converting a fully grown Vivichoke to seeds via crafting results in 1 seed.
- Healing Machine recipe rebalanced.
- Reorganised the `block` texture folder to be more organised, in line with the `item` texture folder.
- Offset in EmitterShape now ignores scale to be more like Blockbench by default. You can get this behaviour back by adding `"scale": true` in the `attachment_options` property in most EmitterShapes.
- Not specifying a dex in `/pokedex printcalculations {player} {dex}` will now print the National Dex statistics instead of showing all dexes. `/pokedex printcalculations {player} all` is how to view all dex statistics in one command.
- `custom_model_data=1` on items can now be displayed when placed in a Display Case by adding to the item tag `cobblemon:display_case_items`
- Upgrade, Dubious Disc, and Luminous Moss sprites have been updated to better match the new block forms
- Updated Peat Block and Peat Mulch recipes
- Minor tab reorganisation
- Removed Braised Vivichoke
- Updated Pokémon state icons shown in party interfaces
- MoLang `face` function can now be run on any `PosableEntity` (Like Pokémon!) instead of just NPCs.
- MoLang `run_action_effect` now works on Pokémon.
- Changed MoLang entity function `is_standing_on` to allow for block tags in the list.
- Added entity (as `q.entity`) that executed the command to the `executemolangscript` command.
- Refactored the following events to `.Pre` and `.Post` for consistency:
- `PokemonSentEvent`
- `ExperienceGainedEvent`
- `BattleStartedEvent`
- Updated `PokemonSentEvent` parameters to include the Position and Level of the Pokémon being sent out.
- Updated `EvolutionCompleteEvent` parameters to include the Source Pokemon that evolved.
- Updated `HatchEggEvent.Post` to include the Pokemon that hatched.
- Roseli Berry Trees now naturally generate in their preferred biomes.
- Refactored dynamic lights compat to be more future proof. The dynamic light support is only tested with LambDynamicLights, on NeoForged use that mod in combination with Sinytra Connector
- Shulker Boxes and Traveler's Backpacks can no longer be held by Pokémon. Thanks Monocle ;) You could re-enable this with a datapack but you'd be crazy.
### Changes
### Fixes
- Fixed orientation not getting reset after crashing while flying and getting back on the Pokémon.
- Fixed Furfrou not being trimmable on NeoForge.
- Fixed honey from Saccharine Leaves being harvestable at less than the max age.
- Items given from interacting with Saccharine Leaves are placed in the active hotbar slot if possible.
- Fix all Pokémon being saved to chunks and never despawning.
- Fixed PokeSnacks crashing if there was no available spawn.
- Fixed Pokémon spawn influences not being specific to regional forms
- Fixed crashing when viewing another player in spectator mode
### Developer
@@ -22,4 +501,3 @@
### Particles
### Localization
- Updated translations for:
-61
View File
@@ -1,61 +0,0 @@
# Changelog
## [1.7.1 (November 29th, 2025)](#1-7-1)
### Additions
- Added trades for Saccharine Saplings, Hearty Grains, Chipped Pot, and Masterpiece Teacup to the Wandering Trader.
- Added brewing recipe for Throat Spray.
- Added vanilla sprinting's field of view change to Pokémon land mounts.
- Added a customizable keybind for the riding freelook button.
- Added double tap to sprint on land mounts.
### Changes
- Made Jet pitch turning 1.5x faster across all Pokémon.
- Party Pokémon now attack only mobs that are attacking their owner, instead of randomly targeting unrelated mobs and getting themselves hurt.
- Reduced the cost of the Vivichoke Seed trade with the Wandering Trader.
### Fixes
- Fixed incorrect camera pivot on Bird, Jet, and Dolphin mounts, leading to some disorienting riding.
- Fixed players suffocating while on vanilla mounts.
- Fixed a graphics crash that could occur on some machines when campfire pots were nearby.
- Fixed ride controls overlay being displayed to passengers. The passengers probably don't need to know about those.
- Fixed mount jumping so that it doesn't switch back to ground animations.
- Fixed ridden Pokémon land collision and some issues around stepping up blocks. Land mounts are smoother overall now.
- Fixed Furfrou's pink and magenta trims being swapped. Only a man could make that mistake.
- Fixed friendship being reset to the default value when evolving a Pokémon.
- Fixed Combees not depositing honey upon leaving a hive if they entered it with nectar.
- Fixed pastured Combees not moving during the night or in rain.
- Fixed a case in which a Combee might try to path to a flower that no longer exists.
- Fixed Combees attempting to enter a full hive.
- Fixed a crash involving Combees and hives. 500 bee bugs. Bugged bees? We can be bees. Mark, this is good news.
- Fixed a crash related to NPC navigation.
- Fixed a crash when opening a PC box with certain wallpapers while using *VulkanMod*.
- Fixed a crash when you place a block in the way of hearty grains 2nd block.
- Fixed passengers hearing the shiny noise of a ridden shiny Pokémon.
- Ponigiri can no longer be eaten at full hunger.
- Fixed Poké Snack spawning sounds not coming from the block.
- Medicinal Brew's Campfire Pot recipe now correctly displays that it can be made using an empty glass bottle or a filled bottle.
- Fixed glass bottle not being returned when slathering honey on a saccharine leaf block.
- Fixed saccharine hanging signs sometimes dropping their oak wood counterpart when being broken.
- Fixed a bunch of incompatibilities with NeoForge mods.
- Fixed a bug where wind charges hitting pasture blocks would recall all Pokémon in it.
- Fixed the Home on the Range advancement triggering when opening the Pokémon interaction wheel.
- Fixed recipes that use concrete not working on NeoForge.
- Fixed Boltund's model.
- Fixed Cyclizar's textures.
### Developer
### Molang & Datapacks
- Removed automatic generation of PC wallpaper screen glow if no asset is provided; it is now optional.
- This is because there's no practical way to do this without blowing up things like *VulkanMod*.
### Particles
### Localization
- Updated translations for:
- French
- Japanese
- Korean
- Brazilian Portuguese
- Simplified Chinese
- Traditional Chinese
-2
View File
@@ -54,8 +54,6 @@ dependencies {
// Flywheel has no common dep so just pick one and don't use any platform specific code in common
// modCompileOnly(libs.flywheelFabric)
modCompileOnly(files("temp/vivecraft-1.21.1-1.3.4.jar")) // TODO: Switch this to a proper dependency when Vivecraft gets a maven repo
// Showdown
modCompileOnly(libs.graal)
@@ -17,7 +17,6 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.ai.memory.MemoryStatus;
import net.minecraft.world.item.component.CustomData;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BeehiveBlock;
@@ -53,9 +52,7 @@ public abstract class BeeOccupantMixin {
var facing = state.getValue(HorizontalDirectionalBlock.FACING);
newPos = pos.relative(facing).getCenter();
newYaw = facing.toYRot();
if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) {
brain.setMemory(CobblemonMemories.HIVE_LOCATION, pos); // This needs to be set in the case that the hive was picked up and moved.
}
brain.setMemory(CobblemonMemories.HIVE_LOCATION, pos); // This needs to be set in the case that the hive was picked up and moved.
} else {
// Block has likely been destroyed
var center = pos.getCenter();
@@ -65,31 +62,25 @@ public abstract class BeeOccupantMixin {
center.z + level.random.nextFloat() * 0.6 - 0.3
);
newYaw = level.random.nextFloat() * 360F;
if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) {
brain.eraseMemory(CobblemonMemories.HIVE_LOCATION);
}
brain.eraseMemory(CobblemonMemories.HIVE_LOCATION);
}
entity.yRotO = newYaw;
entity.setPos(newPos);
// Do honey logic
if (brain.checkMemory(CobblemonMemories.HAS_NECTAR, MemoryStatus.REGISTERED)) {
var hasNectar = brain.getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
if (hasNectar) {
// Remove nectar and reset got to hive cooldown
brain.eraseMemory(CobblemonMemories.HAS_NECTAR);
if (brain.checkMemory(CobblemonMemories.HIVE_LOCATION, MemoryStatus.REGISTERED)) {
brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN);
}
// Increment honey level of the hive
if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) {
int i = state.getValue(BeehiveBlock.HONEY_LEVEL);
if (i < 5) {
int j = level.random.nextInt(100) == 0 ? 2 : 1;
if (i + j > 5) {
--j;
}
level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, i + j));
var hasNectar = brain.getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
if (hasNectar) {
// Remove nectar and reset got to hive cooldown
brain.eraseMemory(CobblemonMemories.HAS_NECTAR);
brain.setMemoryWithExpiry(CobblemonMemories.HIVE_COOLDOWN, true, PathToBeeHiveTaskConfig.STAY_OUT_OF_HIVE_COOLDOWN);
// Increment honey level of the hive
if (state.is(BlockTags.BEEHIVES, (blockStateBase) -> blockStateBase.hasProperty(BeehiveBlock.HONEY_LEVEL))) {
int i = state.getValue(BeehiveBlock.HONEY_LEVEL);
if (i < 5) {
int j = level.random.nextInt(100) == 0 ? 2 : 1;
if (i + j > 5) {
--j;
}
level.setBlockAndUpdate(pos, state.setValue(BeehiveBlock.HONEY_LEVEL, i + j));
}
}
}
@@ -101,13 +92,12 @@ public abstract class BeeOccupantMixin {
@Inject(method = "of", at = @At("HEAD"), cancellable = true)
private static void cobblemon$of(Entity entity, CallbackInfoReturnable<BeehiveBlockEntity.Occupant> cir) {
if (entity instanceof PokemonEntity pokemonEntity) {
List<String> IGNORED_BEE_TAGS = Arrays.asList("Air", "ArmorDropChances", "ArmorItems", "CanPickUpLoot", "DeathTime", "FallDistance", "FallFlying", "Fire", "HandDropChances", "HandItems", "HurtByTimestamp", "HurtTime", "LeftHanded", "Motion", "NoGravity", "OnGround", "PortalCooldown", "Pos", "Rotation", "Passengers", "leash", "UUID");
List<String> IGNORED_BEE_TAGS = Arrays.asList("Air", "ArmorDropChances", "ArmorItems", "Brain", "CanPickUpLoot", "DeathTime", "FallDistance", "FallFlying", "Fire", "HandDropChances", "HandItems", "HurtByTimestamp", "HurtTime", "LeftHanded", "Motion", "NoGravity", "OnGround", "PortalCooldown", "Pos", "Rotation", "Passengers", "leash", "UUID");
CompoundTag compoundTag = new CompoundTag();
entity.save(compoundTag);
Objects.requireNonNull(compoundTag);
IGNORED_BEE_TAGS.forEach(compoundTag::remove);
boolean hasNectar = pokemonEntity.getBrain().checkMemory(CobblemonMemories.HAS_NECTAR, MemoryStatus.REGISTERED)
&& pokemonEntity.getBrain().getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
Boolean hasNectar = pokemonEntity.getBrain().getMemory(CobblemonMemories.HAS_NECTAR).orElse(false);
cir.setReturnValue(new BeehiveBlockEntity.Occupant(CustomData.of(compoundTag), 0, hasNectar ? 2400 : 600));
cir.cancel();
}
@@ -0,0 +1,38 @@
/*
* 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.block.PreEmptsExplosion;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
@Mixin(value = Explosion.class)
public class ExplosionMixin {
@Redirect(
method = "finalizeExplosion",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/level/Level;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;",
ordinal = 0
)
)
public BlockState cobblemon$whenExploded(Level world, BlockPos pos) {
BlockState blockState = world.getBlockState(pos);
if(blockState.getBlock() instanceof PreEmptsExplosion preExplosionBlock) {
preExplosionBlock.whenExploded(world, blockState, pos);
}
return blockState;
}
}
@@ -0,0 +1,32 @@
/*
* 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 net.minecraft.stats.RecipeBookSettings;
import net.minecraft.world.inventory.RecipeBookType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.util.Map;
@Mixin(RecipeBookSettings.class)
public class RecipeBookSettingsMixin {
@Shadow @Final public Map<RecipeBookType, RecipeBookSettings.TypeSettings> states;
@Inject(method = "<init>", at = @At("TAIL"))
private void cobblemon$init(CallbackInfo ci) {
states.put(RecipeBookType.valueOf("COOKING_POT"), new RecipeBookSettings.TypeSettings(true, true));
}
}
@@ -6,9 +6,8 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.fabric.mixin;
package com.cobblemon.mod.common.mixin;
import com.cobblemon.mod.common.CobblemonRecipeBookTypes;
import net.minecraft.world.inventory.RecipeBookType;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
@@ -41,9 +40,7 @@ public class RecipeBookTypeMixin {
)
private static void cobblemon$addRecipeBookType(CallbackInfo ci) {
ArrayList<RecipeBookType> types = new ArrayList<>(List.of($VALUES));
// if you change or add any of these, neoforge uses a separate mechanism
// check enumextensions.json and `CobblemonEnumExtensions`
types.add(cobblemon$createBookType(CobblemonRecipeBookTypes.COOKING_POT_NAME, $VALUES.length));
types.add(cobblemon$createBookType("COOKING_POT", $VALUES.length));
$VALUES = types.toArray(RecipeBookType[]::new);
}
}
@@ -33,7 +33,7 @@ public class AbstractClientPlayerMixin {
cir.setReturnValue(usageContext.getFovMultiplier());
} else {
// Only modify fov through riding if the pokedex is not open
AbstractClientPlayer player = (AbstractClientPlayer) (Object) this;
LocalPlayer player = (LocalPlayer) (Object) this;
// Only modify fov for the driver and not the passengers
if (player != null && player.isPassenger() && player.getVehicle() instanceof PokemonEntity && player.getVehicle().getControllingPassenger() == player) {
PokemonEntity ride = (PokemonEntity) player.getVehicle();
@@ -13,7 +13,6 @@ import com.cobblemon.mod.common.OrientationControllable;
import com.cobblemon.mod.common.api.orientation.OrientationController;
import com.cobblemon.mod.common.client.CobblemonClient;
import com.cobblemon.mod.common.client.keybind.keybinds.PartySendBinding;
import com.cobblemon.mod.common.client.keybind.keybinds.RidingFreelookBinding;
import com.cobblemon.mod.common.duck.RidePassenger;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext;
@@ -157,7 +156,7 @@ public abstract class MouseHandlerMixin {
}
var vehicleController = controllableVehicle.getOrientationController();
var freeLooking = RidingFreelookBinding.INSTANCE.isDown();
var lookaroundButtonPressed = Minecraft.getInstance().mouseHandler.isMiddlePressed();
Pair<Boolean, Boolean> mouseShouldModifyDriver = ((PokemonEntity) vehicle).ifRidingAvailableSupply(new Pair(false, false), (behaviour, settings, state) -> {
return behaviour.mouseModifiesDriverRotation(
settings,
@@ -171,7 +170,7 @@ public abstract class MouseHandlerMixin {
// affect the vehicle orientation when looking around.
// If the client is a passenger it will modify these rotations and return
//-------------------------------------------------------------------------
if (freeLooking || player.getControlledVehicle() == null) {
if (lookaroundButtonPressed || player.getControlledVehicle() == null) {
// Modify driver rotations
cobblemon$setDriverRotations(player, cursorDeltaX, cursorDeltaY);
@@ -193,10 +192,10 @@ public abstract class MouseHandlerMixin {
// Smoothly return driver rotations to zero when needed
//-------------------------------------------------------------------------
var playerRotater = (RidePassenger)player;
if( !freeLooking && !mouseShouldModifyDriver.getFirst()){
if( !lookaroundButtonPressed && !mouseShouldModifyDriver.getFirst()){
playerRotater.cobblemon$setRideYRot(lerp(min(5.0f * (float)movementTime, 1.0f), Mth.wrapDegrees(playerRotater.cobblemon$getRideYRot()), 0.0f));
}
if( !freeLooking && !mouseShouldModifyDriver.getSecond()) {
if( !lookaroundButtonPressed && !mouseShouldModifyDriver.getSecond()) {
playerRotater.cobblemon$setRideXRot(lerp(min(5.0f * (float)movementTime, 1.0f), Mth.wrapDegrees(playerRotater.cobblemon$getRideXRot()), 0.0f));
}
@@ -6,11 +6,10 @@
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.fabric.mixin;
package com.cobblemon.mod.common.mixin.client;
import com.cobblemon.mod.common.CobblemonItems;
import com.cobblemon.mod.common.CobblemonRecipeBookTypes;
import com.cobblemon.mod.common.CobblemonRecipeCategories;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.RecipeBookCategories;
@@ -50,19 +49,17 @@ public class RecipeBookCategoriesMixin {
)
private static void cobblemon$addRecipeBookType(CallbackInfo ci) {
ArrayList<RecipeBookCategories> types = new ArrayList<>(List.of($VALUES));
// if you change or add any of these, neoforge uses a separate mechanism
// check enumextensions.json and `CobblemonEnumExtensions`
types.add(cobblemon$createCategory("COBBLEMON_COOKING_POT_SEARCH", $VALUES.length, new ItemStack(Items.COMPASS)));
types.add(cobblemon$createCategory("COBBLEMON_COOKING_POT_FOODS", $VALUES.length + 1, new ItemStack(CobblemonItems.LEEK_AND_POTATO_STEW)));
types.add(cobblemon$createCategory("COBBLEMON_COOKING_POT_MEDICINES", $VALUES.length + 2, new ItemStack(CobblemonItems.POTION)));
types.add(cobblemon$createCategory("COBBLEMON_COOKING_POT_COMPLEX_DISHES", $VALUES.length + 3, new ItemStack(CobblemonItems.APRIJUICE_RED)));
types.add(cobblemon$createCategory("COBBLEMON_COOKING_POT_MISC", $VALUES.length + 4, new ItemStack(CobblemonItems.PROTEIN)));
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.APRIJUICE_RED)));
types.add(cobblemon$createCategory("COOKING_POT_MISC", $VALUES.length + 4, new ItemStack(CobblemonItems.PROTEIN)));
$VALUES = types.toArray(RecipeBookCategories[]::new);
}
@Inject(method = "getCategories", at = @At("HEAD"), cancellable = true)
private static void modifyCategories(RecipeBookType recipeBookType, CallbackInfoReturnable<List<RecipeBookCategories>> cir) {
if (recipeBookType == CobblemonRecipeBookTypes.INSTANCE.getCOOKING_POT()) {
if (recipeBookType == RecipeBookType.valueOf("COOKING_POT")) {
List var10000 = ImmutableList.of(
CobblemonRecipeCategories.COOKING_POT_SEARCH.toVanillaCategory(),
CobblemonRecipeCategories.COOKING_POT_FOODS.toVanillaCategory(),
@@ -11,7 +11,6 @@ package com.cobblemon.mod.common.mixin.entity;
import com.cobblemon.mod.common.OrientationControllable;
import com.cobblemon.mod.common.duck.RidePassenger;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.pokemon.Pokemon;
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import net.minecraft.client.player.LocalPlayer;
@@ -24,7 +23,6 @@ import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.Nullable;
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;
@@ -50,8 +48,16 @@ public abstract class EntityMixin {
)
)
public boolean cobblemon$forceOnGroundForStepUp(Entity entity, Operation<Boolean> original) {
if (entity instanceof PokemonEntity vehicle && entity.hasControllingPassenger()) {
return true;
if (entity instanceof PokemonEntity && entity.hasControllingPassenger()) {
BlockPos below = entity.blockPosition().below();
Level level = entity.level();
var blockStateBelow = level.getBlockState(below);
boolean isAirOrLiquid = blockStateBelow.isAir() || !blockStateBelow.getFluidState().isEmpty();
boolean canSupportEntity = blockStateBelow.isFaceSturdy(level, below, Direction.UP);
boolean standingOnSolid = canSupportEntity && !isAirOrLiquid;
if (standingOnSolid) {
return true;
}
}
return original.call(entity);
}
@@ -62,7 +68,18 @@ public abstract class EntityMixin {
cancellable = true
)
private void cobblemon$modifyEyePosition_partial(float partialTicks, CallbackInfoReturnable<Vec3> cir) {
cobblemon$getCustomEyePos(cir);
var entity = (Entity)(Object)this;
if (entity.level().isClientSide) return;
if (!(entity instanceof Player player)) return;
if (!(player instanceof RidePassenger ridePassenger)) return;
if (!(player.getVehicle() instanceof OrientationControllable vehicle)) return;
var vehicleController = vehicle.getOrientationController();
if (vehicleController == null) return;
// TODO: Determine if it needs partialtick involved.
Vec3 customEyePos = ridePassenger.cobblemon$getRideEyePos();
cir.setReturnValue(customEyePos);
}
@Inject(
@@ -71,20 +88,15 @@ public abstract class EntityMixin {
cancellable = true
)
private void cobblemon$modifyEyePosition_noPartial(CallbackInfoReturnable<Vec3> cir) {
cobblemon$getCustomEyePos(cir);
}
@Unique
private void cobblemon$getCustomEyePos(CallbackInfoReturnable<Vec3> cir) {
var entity = (Entity)(Object)this;
if (entity.level().isClientSide) return;
if (!(entity instanceof Player player)) return;
if (!(player instanceof RidePassenger ridePassenger)) return;
if (!(player.getVehicle() instanceof OrientationControllable vehicle)) return;
if (!(vehicle instanceof PokemonEntity)) return;
var vehicleController = vehicle.getOrientationController();
if (vehicleController == null) return;
// TODO: Determine if it needs partialtick involved.
Vec3 customEyePos = ridePassenger.cobblemon$getRideEyePos();
cir.setReturnValue(customEyePos);
}
@@ -42,8 +42,8 @@ import com.cobblemon.mod.common.api.scheduling.ServerRealTimeTaskTracker
import com.cobblemon.mod.common.api.scheduling.ServerTaskTracker
import com.cobblemon.mod.common.api.spawning.BestSpawner
import com.cobblemon.mod.common.api.spawning.CobblemonSpawningZoneGenerator
import com.cobblemon.mod.common.api.spawning.SpawningZoneGenerator
import com.cobblemon.mod.common.api.spawning.position.AreaSpawnablePositionResolver
import com.cobblemon.mod.common.api.spawning.SpawningZoneGenerator
import com.cobblemon.mod.common.api.starter.StarterHandler
import com.cobblemon.mod.common.api.stats.CobblemonStats
import com.cobblemon.mod.common.api.storage.PokemonStoreManager
@@ -76,8 +76,12 @@ import com.cobblemon.mod.common.config.LastChangedVersion
import com.cobblemon.mod.common.config.constraint.IntConstraint
import com.cobblemon.mod.common.config.starter.StarterConfig
import com.cobblemon.mod.common.data.CobblemonDataProvider
import com.cobblemon.mod.common.events.*
import com.cobblemon.mod.common.integration.vivecraft.CobblemonVR
import com.cobblemon.mod.common.events.AdvancementHandler
import com.cobblemon.mod.common.events.EntityCallbackHandler
import com.cobblemon.mod.common.events.CallbackHandler
import com.cobblemon.mod.common.events.PokedexHandler
import com.cobblemon.mod.common.events.ServerTickHandler
import com.cobblemon.mod.common.events.StatHandler
import com.cobblemon.mod.common.net.messages.client.settings.ServerSettingsPacket
import com.cobblemon.mod.common.permission.LaxPermissionValidator
import com.cobblemon.mod.common.platform.events.PlatformEvents
@@ -131,12 +135,10 @@ object Cobblemon {
const val MODID = CobblemonBuildDetails.MOD_ID
const val VERSION = CobblemonBuildDetails.VERSION
const val CONFIG_PATH = "config/$MODID/main.json"
@JvmField
val LOGGER: Logger = LogManager.getLogger()
lateinit var implementation: CobblemonImplementation
@Deprecated("This field is now a config value", ReplaceWith("Cobblemon.config.captureCalculator"))
var captureCalculator: CaptureCalculator
get() = this.config.captureCalculator
@@ -166,49 +168,21 @@ object Cobblemon {
val serverPlayerStructs = mutableMapOf<UUID, ObjectValue<Player>>()
val statistics: CobblemonStats = CobblemonStats
var cobblemonVR: CobblemonVR? = null
@JvmStatic
val builtinPacks = listOf<CobblemonPack>(
CobblemonPack(
id = "adorncompatibility",
name = "Adorn Compatibility",
packType = PackType.CLIENT_RESOURCES,
activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED,
neededMods = setOf("adorn")
),
CobblemonPack(
id = "gyaradosjump",
name = "Gyarados Jump Patterns",
packType = PackType.CLIENT_RESOURCES,
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED
),
CobblemonPack(
id = "regionbiasforms",
name = "Region Bias Forms",
packType = PackType.CLIENT_RESOURCES,
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED
),
CobblemonPack(
id = "uniqueshinyforms",
name = "Shinies for Magikarp Jump",
packType = PackType.CLIENT_RESOURCES,
activationBehaviour = ResourcePackActivationBehaviour.NORMAL
),
CobblemonPack(id = "adorncompatibility", name = "Adorn Compatibility", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.ALWAYS_ENABLED, neededMods = setOf("adorn")),
CobblemonPack(id = "gyaradosjump", name = "Gyarados Jump Patterns", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
CobblemonPack(id = "regionbiasforms", name = "Region Bias Forms", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED),
CobblemonPack(id = "uniqueshinyforms", name = "Shinies for Magikarp Jump", packType = PackType.CLIENT_RESOURCES, activationBehaviour = ResourcePackActivationBehaviour.NORMAL),
CobblemonPack(
id = "repurposedstructurescobblemon",
name = "Repurposed Structures Cobblemon",
packType = PackType.SERVER_DATA,
activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED,
neededMods = setOf("repurposed_structures")
),
CobblemonPack(id = "repurposedstructurescobblemon", name = "Repurposed Structures Cobblemon", packType = PackType.SERVER_DATA, activationBehaviour = ResourcePackActivationBehaviour.DEFAULT_ENABLED, neededMods = setOf("repurposed_structures")),
)
fun preInitialize(implementation: CobblemonImplementation) {
this.implementation = implementation
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if (CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
this.LOGGER.info("Launching Cobblemon ${CobblemonBuildDetails.VERSION}${if(CobblemonBuildDetails.SNAPSHOT) "-SNAPSHOT" else ""} ")
if (CobblemonBuildDetails.SNAPSHOT) {
this.LOGGER.info(" - Git Commit: ${smallCommitHash()} (https://gitlab.com/cable-mc/cobblemon/-/commit/${CobblemonBuildDetails.GIT_COMMIT})")
this.LOGGER.info(" - Branch: ${CobblemonBuildDetails.BRANCH}")
@@ -272,10 +246,7 @@ object Cobblemon {
}
PlatformEvents.RIGHT_CLICK_ENTITY.subscribe { event ->
if (event.player.getItemInHand(event.hand).item is NameTagItem && event.entity.type.`is`(
CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG
)
) {
if (event.player.getItemInHand(event.hand).item is NameTagItem && event.entity.type.`is`(CobblemonEntityTypeTags.CANNOT_HAVE_NAME_TAG)) {
event.cancel()
}
}
@@ -286,10 +257,7 @@ object Cobblemon {
pokemon.lockedEvolutions
.filterIsInstance<BlockClickEvolution>()
.forEach { evolution ->
evolution.attemptEvolution(
pokemon,
BlockClickEvolution.BlockInteractionContext(block, player.level())
)
evolution.attemptEvolution(pokemon, BlockClickEvolution.BlockInteractionContext(block, player.level()))
}
}
}
@@ -349,11 +317,6 @@ object Cobblemon {
SlowpokeTailRegrowthSpeciesFeatureProvider
)
if (implementation.isModInstalled("vivecraft")) { // VR integration
cobblemonVR = CobblemonVR()
cobblemonVR?.init()
}
CustomPokemonProperty.register(UncatchableProperty)
CustomPokemonProperty.register(BattleCloneProperty)
CustomPokemonProperty.register(PokemonFlagProperty)
@@ -373,7 +336,7 @@ object Cobblemon {
}
PlatformEvents.SERVER_TICK_POST.subscribe {
ServerTaskTracker.update(1 / 20F)
ServerTaskTracker.update(1/20F)
ServerRealTimeTaskTracker.update()
}
PlatformEvents.SERVER_TICK_PRE.subscribe {
@@ -417,22 +380,10 @@ object Cobblemon {
.applyConnectionString(ConnectionString(config.mongoDBConnectionString))
.build()
mongoClient = MongoClients.create(mongoClientSettings)
val generalMongoFactory = CachedPlayerDataStoreFactory(
PlayerDataMongoBackend(
mongoClient,
config.mongoDBDatabaseName,
"PlayerDataCollection"
)
)
val generalMongoFactory = CachedPlayerDataStoreFactory(PlayerDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PlayerDataCollection"))
generalMongoFactory.setup(server)
val pokedexMongoFactory = CachedPlayerDataStoreFactory(
DexDataMongoBackend(
mongoClient,
config.mongoDBDatabaseName,
"PokeDexCollection"
)
)
val pokedexMongoFactory = CachedPlayerDataStoreFactory(DexDataMongoBackend(mongoClient, config.mongoDBDatabaseName, "PokeDexCollection"))
pokedexMongoFactory.setup(server)
playerDataManager.setFactory(generalMongoFactory, PlayerInstancedDataStoreTypes.GENERAL)
@@ -554,7 +505,6 @@ object Cobblemon {
field.set(config, field.get(defaultConfig))
}
}
is IntConstraint -> {
var value = field.get(config)
if (value is Int) {
@@ -607,76 +557,20 @@ object Cobblemon {
}
private fun registerArgumentTypes() {
this.implementation.registerCommandArgument(
cobblemonResource("pokemon"),
SpeciesArgumentType::class,
SingletonArgumentInfo.contextFree(SpeciesArgumentType::species)
)
this.implementation.registerCommandArgument(
cobblemonResource("pokemon_properties"),
PokemonPropertiesArgumentType::class,
SingletonArgumentInfo.contextFree(PokemonPropertiesArgumentType::properties)
)
this.implementation.registerCommandArgument(
cobblemonResource("spawn_bucket"),
SpawnBucketArgumentType::class,
SingletonArgumentInfo.contextFree(SpawnBucketArgumentType::spawnBucket)
)
this.implementation.registerCommandArgument(
cobblemonResource("move"),
MoveArgumentType::class,
SingletonArgumentInfo.contextFree(MoveArgumentType::move)
)
this.implementation.registerCommandArgument(
cobblemonResource("party_slot"),
PartySlotArgumentType::class,
SingletonArgumentInfo.contextFree(PartySlotArgumentType::partySlot)
)
this.implementation.registerCommandArgument(
cobblemonResource("pokemon_store"),
PokemonStoreArgumentType::class,
SingletonArgumentInfo.contextFree(PokemonStoreArgumentType::pokemonStore)
)
this.implementation.registerCommandArgument(
cobblemonResource("dialogue"),
DialogueArgumentType::class,
SingletonArgumentInfo.contextFree(DialogueArgumentType::dialogue)
)
this.implementation.registerCommandArgument(
cobblemonResource("form"),
FormArgumentType::class,
SingletonArgumentInfo.contextFree(FormArgumentType::form)
)
this.implementation.registerCommandArgument(
cobblemonResource("dex"),
DexArgumentType::class,
SingletonArgumentInfo.contextFree(DexArgumentType::dex)
)
this.implementation.registerCommandArgument(
cobblemonResource("npc_class"),
NPCClassArgumentType::class,
SingletonArgumentInfo.contextFree(NPCClassArgumentType::npcClass)
)
this.implementation.registerCommandArgument(
cobblemonResource("wallpaper"),
UnlockablePCBoxWallpaperArgumentType::class,
SingletonArgumentInfo.contextFree(UnlockablePCBoxWallpaperArgumentType::wallpaper)
)
this.implementation.registerCommandArgument(
cobblemonResource("mark"),
MarkArgumentType::class,
SingletonArgumentInfo.contextFree(MarkArgumentType::mark)
)
this.implementation.registerCommandArgument(
cobblemonResource("transform_type"),
TransformTypeArgumentType::class,
SingletonArgumentInfo.contextFree(TransformTypeArgumentType::transformType)
)
this.implementation.registerCommandArgument(
cobblemonResource("model_part"),
ModelPartArgumentType::class,
SingletonArgumentInfo.contextFree(ModelPartArgumentType::modelPart)
)
this.implementation.registerCommandArgument(cobblemonResource("pokemon"), SpeciesArgumentType::class, SingletonArgumentInfo.contextFree(SpeciesArgumentType::species))
this.implementation.registerCommandArgument(cobblemonResource("pokemon_properties"), PokemonPropertiesArgumentType::class, SingletonArgumentInfo.contextFree(PokemonPropertiesArgumentType::properties))
this.implementation.registerCommandArgument(cobblemonResource("spawn_bucket"), SpawnBucketArgumentType::class, SingletonArgumentInfo.contextFree(SpawnBucketArgumentType::spawnBucket))
this.implementation.registerCommandArgument(cobblemonResource("move"), MoveArgumentType::class, SingletonArgumentInfo.contextFree(MoveArgumentType::move))
this.implementation.registerCommandArgument(cobblemonResource("party_slot"), PartySlotArgumentType::class, SingletonArgumentInfo.contextFree(PartySlotArgumentType::partySlot))
this.implementation.registerCommandArgument(cobblemonResource("pokemon_store"), PokemonStoreArgumentType::class, SingletonArgumentInfo.contextFree(PokemonStoreArgumentType::pokemonStore))
this.implementation.registerCommandArgument(cobblemonResource("dialogue"), DialogueArgumentType::class, SingletonArgumentInfo.contextFree(DialogueArgumentType::dialogue))
this.implementation.registerCommandArgument(cobblemonResource("form"), FormArgumentType::class, SingletonArgumentInfo.contextFree(FormArgumentType::form))
this.implementation.registerCommandArgument(cobblemonResource("dex"), DexArgumentType::class, SingletonArgumentInfo.contextFree (DexArgumentType::dex))
this.implementation.registerCommandArgument(cobblemonResource("npc_class"), NPCClassArgumentType::class, SingletonArgumentInfo.contextFree(NPCClassArgumentType::npcClass))
this.implementation.registerCommandArgument(cobblemonResource("wallpaper"), UnlockablePCBoxWallpaperArgumentType::class, SingletonArgumentInfo.contextFree(UnlockablePCBoxWallpaperArgumentType::wallpaper))
this.implementation.registerCommandArgument(cobblemonResource("mark"), MarkArgumentType::class, SingletonArgumentInfo.contextFree(MarkArgumentType::mark))
this.implementation.registerCommandArgument(cobblemonResource("transform_type"), TransformTypeArgumentType::class, SingletonArgumentInfo.contextFree(TransformTypeArgumentType::transformType))
this.implementation.registerCommandArgument(cobblemonResource("model_part"), ModelPartArgumentType::class, SingletonArgumentInfo.contextFree(ModelPartArgumentType::modelPart))
}
}
@@ -10,19 +10,26 @@ package com.cobblemon.mod.common
import com.cobblemon.mod.common.api.apricorn.Apricorn
import com.cobblemon.mod.common.block.*
import com.cobblemon.mod.common.block.campfirepot.CampfireBlock
import com.cobblemon.mod.common.block.LecternBlock
import com.cobblemon.mod.common.block.MintBlock.MintType
import com.cobblemon.mod.common.block.campfirepot.CampfireBlock
import com.cobblemon.mod.common.block.campfirepot.CampfirePotBlock
import com.cobblemon.mod.common.block.chest.GildedChestBlock
import com.cobblemon.mod.common.block.decor.*
import com.cobblemon.mod.common.block.decor.DecorativeItemBlock.ItemType
import com.cobblemon.mod.common.block.decor.StackableItemBlock.StackableItemType
import com.cobblemon.mod.common.block.decor.WallAttachedDecorativeItemBlock.WallItemType
import com.cobblemon.mod.common.block.decor.WallAttachedStackableItemBlock.WallStackableItemType
import com.cobblemon.mod.common.block.decor.SixFaceDecorativeItemBlock.SixFaceItemType
import com.cobblemon.mod.common.block.general.BaleBlock
import com.cobblemon.mod.common.block.general.HorizontalRotationCarpetBlock
import com.cobblemon.mod.common.block.general.HorizontalRotationalBlock
import com.cobblemon.mod.common.block.general.SixDirectionalBlock
import com.cobblemon.mod.common.block.grower.SaccharineTreeGrower
import com.cobblemon.mod.common.block.sign.CobblemonHangingSignBlock
import com.cobblemon.mod.common.block.sign.CobblemonSignBlock
import com.cobblemon.mod.common.block.sign.CobblemonWallHangingSignBlock
import com.cobblemon.mod.common.block.sign.CobblemonWallSignBlock
import com.cobblemon.mod.common.block.general.HorizontalRotationCarpetBlock
import com.cobblemon.mod.common.block.general.HorizontalRotationalBlock
import com.cobblemon.mod.common.mixin.invoker.*
import com.cobblemon.mod.common.platform.PlatformRegistry
import com.cobblemon.mod.common.util.cobblemonResource
@@ -215,7 +222,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
@JvmField
val SACCHARINE_WALL_SIGN = this.create("saccharine_wall_sign", CobblemonWallSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_SIGN), SACCHARINE_WOOD_TYPE))
@JvmField
val SACCHARINE_HANGING_SIGN = this.create("saccharine_hanging_sign", CobblemonHangingSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_HANGING_SIGN), SACCHARINE_WOOD_TYPE))
val SACCHARINE_HANGING_SIGN = this.create("saccharine_hanging_sign", CobblemonHangingSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_WALL_HANGING_SIGN), SACCHARINE_WOOD_TYPE))
@JvmField
val SACCHARINE_WALL_HANGING_SIGN = this.create("saccharine_wall_hanging_sign", CobblemonWallHangingSignBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.OAK_HANGING_SIGN), SACCHARINE_WOOD_TYPE))
@JvmField
@@ -460,6 +467,179 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
@JvmField
val RELIC_COIN_SACK = create("relic_coin_sack", CoinPouchBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_SACK_SOUNDS).pushReaction(PushReaction.DESTROY).strength(0.4f), false))
@JvmField
val KINGS_ROCK = create("kings_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_BLOCK_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), ItemType.GENERIC_7x6))
@JvmField
val CHIPPED_POT = create("chipped_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), ItemType.TEAPOT))
@JvmField
val CRACKED_POT = create("cracked_pot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), ItemType.TEAPOT))
@JvmField
val MASTERPIECE_TEACUP = create("masterpiece_teacup", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), ItemType.TEACUP))
@JvmField
val UNREMARKABLE_TEACUP = create("unremarkable_teacup", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.TUMBLESTONE_SOUNDS).mapColor(MapColor.NONE).noOcclusion(), ItemType.TEACUP))
@JvmField
val LUMINOUS_MOSS = create("luminous_moss", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.MOSS).mapColor(MapColor.NONE).noOcclusion().lightLevel{5}, ItemType.MOSS))
@JvmField
val GALARICA_CUFF = create("galarica_cuff", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.SWEET_BERRY_BUSH).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission(), ItemType.GENERIC_8x4))
@JvmField
val GALARICA_WREATH = create("galarica_wreath", GalaricaWreathBlock(BlockBehaviour.Properties.of().sound(SoundType.SWEET_BERRY_BUSH).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission()))
@JvmField
val DESTINY_KNOT = create("destiny_knot", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOL).mapColor(MapColor.NONE).noOcclusion(), ItemType.KNOT))
@JvmField
val METRONOME = create("metronome", MetronomeBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion()))
@JvmField
val DAMP_ROCK = create("damp_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DRIPSTONE_BLOCK).mapColor(MapColor.NONE).noOcclusion(), ItemType.GENERIC_8x))
@JvmField
val HEAT_ROCK = create("heat_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DRIPSTONE_BLOCK).mapColor(MapColor.NONE).noOcclusion(), ItemType.GENERIC_8x))
@JvmField
val ICY_ROCK = create("icy_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DRIPSTONE_BLOCK).mapColor(MapColor.NONE).noOcclusion(), ItemType.GENERIC_8x))
@JvmField
val SMOOTH_ROCK = create("smooth_rock", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.DRIPSTONE_BLOCK).mapColor(MapColor.NONE).noOcclusion(), ItemType.GENERIC_8x))
@JvmField
val UPGRADE = create("upgrade", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.UPGRADE))
@JvmField
val DUBIOUS_DISC = create("dubious_disc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.UPGRADE))
@JvmField
val NEVER_MELT_ICE = create("never_melt_ice", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().friction(0.989F), ItemType.GENERIC_7x6))
@JvmField
val PEAT_BLOCK = create("peat_block", SixDirectionalBlock(BlockBehaviour.Properties.of().mapColor(MapColor.CLAY).strength(0.5f).sound(SoundType.MUD)))
@JvmField
val CLEANSE_TAG = create("cleanse_tag", WallAttachedStackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission(), WallStackableItemType.TAG))
@JvmField
val SPELL_TAG = create("spell_tag", WallAttachedStackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().noCollission(), WallStackableItemType.TAG))
@JvmField
val BLUNDER_POLICY = create("blunder_policy", WallAttachedDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).noOcclusion().noCollission(), WallItemType.POLICY))
@JvmField
val WEAKNESS_POLICY = create("weakness_policy", WallAttachedDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).noOcclusion().noCollission(), WallItemType.POLICY))
@JvmField
val SACHET = create("sachet", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion(), ItemType.POUCH))
@JvmField
val BRIGHT_POWDER = create("bright_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion().lightLevel{2}, ItemType.POUCH))
@JvmField
val METAL_POWDER = create("metal_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion(), ItemType.POUCH))
@JvmField
val QUICK_POWDER = create("quick_powder", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.RELIC_COIN_POUCH_SOUNDS).mapColor(MapColor.NONE).pushReaction(PushReaction.DESTROY).noOcclusion(), ItemType.POUCH))
@JvmField
val LIFE_ORB = create("life_orb", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{2}, SixFaceItemType.GENERIC_8x))
@JvmField
val FLAME_ORB = create("flame_orb", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{15}, SixFaceItemType.GENERIC_8x))
@JvmField
val TOXIC_ORB = create("toxic_orb", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), SixFaceItemType.GENERIC_8x))
@JvmField
val LIGHT_BALL = create("light_ball", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{13}, SixFaceItemType.GENERIC_8x))
@JvmField
val SMOKE_BALL = create("smoke_ball", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), SixFaceItemType.GENERIC_8x))
/*@JvmField
val SOUL_DEW = create("soul_dew", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion().lightLevel{11}, SixFaceItemType.GENERIC_8x))*/
@JvmField
val IRON_BALL = create("iron_ball", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion().strength(5f), ItemType.GENERIC_8x)) //TODO Determine whether this should be a falling block with damage source - Idea is solid, but the damage bit is concerning to get working, so leaving it as a maybe for now
@JvmField
val HARD_STONE = create("hard_stone", DecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.STONE).mapColor(MapColor.NONE).noOcclusion().strength(0.5f), ItemType.GENERIC_8x))
@JvmField
val RING_TARGET = create("ring_target", WallAttachedTargetBlock(BlockBehaviour.Properties.of().sound(SoundType.WOOD).mapColor(MapColor.NONE).noOcclusion().strength(0.5f)))
@JvmField
val EJECT_BUTTON = create("eject_button", EjectButtonBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).strength(1.0f).pushReaction(PushReaction.DESTROY)))
@JvmField
val METAL_COAT = create("metal_coat", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.METAL_COAT))
@JvmField
val MAGNET = create("magnet", SixFaceDecorativeItemBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.NONE).noOcclusion(), SixFaceItemType.MAGNET))
@JvmField
val POTION = create("potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.POTION))
@JvmField
val SUPER_POTION = create("super_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.POTION))
@JvmField
val HYPER_POTION = create("hyper_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.POTION))
@JvmField
val MAX_POTION = create("max_potion", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.MAX_POTION))
@JvmField
val FULL_RESTORE = create("full_restore", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.MAX_POTION))
@JvmField
val ANTIDOTE = create("antidote", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val AWAKENING = create("awakening", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val BURN_HEAL = create("burn_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val ICE_HEAL = create("ice_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val PARALYZE_HEAL = create("paralyze_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val FULL_HEAL = create("full_heal", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.RESTORE))
@JvmField
val ETHER = create("ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.ETHER))
@JvmField
val MAX_ETHER = create("max_ether", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.ETHER))
@JvmField
val ELIXIR = create("elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.ETHER))
@JvmField
val MAX_ELIXIR = create("max_elixir", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.ETHER))
@JvmField
val X_ACCURACY = create("x_accuracy", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val X_ATTACK = create("x_attack", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val X_DEFENCE = create("x_defence", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val X_SPECIAL_ATTACK = create("x_special_attack", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val X_SPECIAL_DEFENCE = create("x_special_defence", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val X_SPEED = create("x_speed", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val DIRE_HIT = create("dire_hit", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val GUARD_SPEC = create("guard_spec", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.BATTLE_X))
@JvmField
val HP_UP = create("hp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val PROTEIN = create("protein", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val IRON = create("iron", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val CARBOS = create("carbos", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val CALCIUM = create("calcium", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val ZINC = create("zinc", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val PP_UP = create("pp_up", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val PP_MAX = create("pp_max", StackableItemBlock(BlockBehaviour.Properties.of().sound(SoundType.GLASS).mapColor(MapColor.NONE).noOcclusion(), StackableItemType.VITAMIN))
@JvmField
val WHITE_PLAQUE = create("white_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIGHT_GRAY_PLAQUE = create("light_gray_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val GRAY_PLAQUE = create("gray_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BLACK_PLAQUE = create("black_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BROWN_PLAQUE = create("brown_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val RED_PLAQUE = create("red_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val ORANGE_PLAQUE = create("orange_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val YELLOW_PLAQUE = create("yellow_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIME_PLAQUE = create("lime_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val GREEN_PLAQUE = create("green_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val CYAN_PLAQUE = create("cyan_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val LIGHT_BLUE_PLAQUE = create("light_blue_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val BLUE_PLAQUE = create("blue_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val PURPLE_PLAQUE = create("purple_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val MAGENTA_PLAQUE = create("magenta_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val PINK_PLAQUE = create("pink_plaque", PlaqueBlock(BlockBehaviour.Properties.of().sound(SoundType.METAL).mapColor(MapColor.METAL).noOcclusion().pushReaction(PushReaction.DESTROY).strength(5.0F)))
@JvmField
val GILDED_CHEST = create("gilded_chest", GildedChestBlock(BlockBehaviour.Properties.ofFullCopy(Blocks.CHEST).noOcclusion().sound(CobblemonSounds.GILDED_CHEST_SOUNDS), GildedChestBlock.Type.RED))
@JvmField
@@ -494,7 +674,7 @@ object CobblemonBlocks : PlatformRegistry<Registry<Block>, ResourceKey<Registry<
val LECTERN = create("lectern", LecternBlock(BlockBehaviour.Properties.of().mapColor(MapColor.WOOD).instrument(NoteBlockInstrument.BASS).sound(SoundType.WOOD).strength(2.5F).ignitedByLava().lightLevel { if (it.getValue(LecternBlock.EMIT_LIGHT) as Boolean) 13 else 0 }))
@JvmField
val DISPLAY_CASE = create("display_case", DisplayCaseBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.DISPLAY_CASE_SOUNDS).noOcclusion().pushReaction(PushReaction.BLOCK).mapColor(MapColor.STONE).strength(0.3F).requiresCorrectToolForDrops()))
val DISPLAY_CASE = create("display_case", DisplayCaseBlock(BlockBehaviour.Properties.of().sound(CobblemonSounds.DISPLAY_CASE_SOUNDS).instrument(NoteBlockInstrument.HAT).noOcclusion().pushReaction(PushReaction.BLOCK).mapColor(MapColor.STONE).strength(0.3F).requiresCorrectToolForDrops()))
// TODO after 1.7
// @JvmField
@@ -44,6 +44,7 @@ import com.cobblemon.mod.common.pokeball.PokeBall
import com.cobblemon.mod.common.pokemon.IVs
import com.cobblemon.mod.common.pokemon.helditem.CobblemonHeldItemManager
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.client.renderer.item.ItemProperties
import net.minecraft.core.Registry
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.core.registries.Registries
@@ -66,6 +67,7 @@ import net.minecraft.world.item.SignItem
import net.minecraft.world.item.SmithingTemplateItem
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
@Suppress("unused", "SameParameterValue")
object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<Item>>, Item>() {
@@ -73,7 +75,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
override val resourceKey: ResourceKey<Registry<Item>> = Registries.ITEM
@JvmField
val NPC_EDITOR = create("npc_editor", CobblemonItem(Item.Properties().stacksTo(1)))
val NPC_EDITOR = create("npc_editor", CobblemonItem(Properties().stacksTo(1)))
@JvmField
val pokeBalls = mutableListOf<PokeBallItem>()
@@ -217,7 +219,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val TATAMI_MAT = blockItem("tatami_mat", CobblemonBlocks.TATAMI_MAT)
@JvmField
val VIVICHOKE = compostableItem("vivichoke", CobblemonItem(Item.Properties()), 0.80f)
val VIVICHOKE = compostableItem("vivichoke", CobblemonItem(Properties()), 0.80f)
@JvmField
val VIVICHOKE_SEEDS = compostableItem("vivichoke_seeds", VivichokeItem(CobblemonBlocks.VIVICHOKE_SEEDS), 0.30f)
@@ -265,9 +267,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val APRICORN_LEAVES = compostableBlockItem("apricorn_leaves", CobblemonBlocks.APRICORN_LEAVES, 0.30f)
@JvmField
val APRICORN_BOAT = create("apricorn_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, false, Item.Properties().stacksTo(1)))
val APRICORN_BOAT = create("apricorn_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, false, Properties().stacksTo(1)))
@JvmField
val APRICORN_CHEST_BOAT = create("apricorn_chest_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, true, Item.Properties().stacksTo(1)))
val APRICORN_CHEST_BOAT = create("apricorn_chest_boat", CobblemonBoatItem(CobblemonBoatType.APRICORN, true, Properties().stacksTo(1)))
@JvmField
val APRICORN_DOOR = blockItem("apricorn_door", CobblemonBlocks.APRICORN_DOOR)
@@ -286,25 +288,33 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val APRICORN_STAIRS = blockItem("apricorn_stairs", CobblemonBlocks.APRICORN_STAIRS)
@JvmField
val APRICORN_SIGN = this.create("apricorn_sign", SignItem(Item.Properties().stacksTo(16), CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN))
val APRICORN_SIGN = this.create("apricorn_sign", SignItem(Properties().stacksTo(16), CobblemonBlocks.APRICORN_SIGN, CobblemonBlocks.APRICORN_WALL_SIGN))
@JvmField
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", HangingSignItem(CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN, Item.Properties().stacksTo(16)))
val APRICORN_HANGING_SIGN = this.create("apricorn_hanging_sign", HangingSignItem(CobblemonBlocks.APRICORN_HANGING_SIGN, CobblemonBlocks.APRICORN_WALL_HANGING_SIGN, Properties().stacksTo(16)))
@JvmField
val GILDED_CHEST = this.create("gilded_chest", BlockItem(CobblemonBlocks.GILDED_CHEST, Item.Properties()))
val GILDED_CHEST = this.create("gilded_chest", BlockItem(CobblemonBlocks.GILDED_CHEST, Properties()))
@JvmField
val BLUE_GILDED_CHEST = this.create("blue_gilded_chest", BlockItem(CobblemonBlocks.BLUE_GILDED_CHEST, Item.Properties()))
val BLUE_GILDED_CHEST = this.create("blue_gilded_chest", BlockItem(CobblemonBlocks.BLUE_GILDED_CHEST, Properties()))
@JvmField
val YELLOW_GILDED_CHEST = this.create("yellow_gilded_chest", BlockItem(CobblemonBlocks.YELLOW_GILDED_CHEST, Item.Properties()))
val YELLOW_GILDED_CHEST = this.create("yellow_gilded_chest", BlockItem(CobblemonBlocks.YELLOW_GILDED_CHEST,
Properties()
))
@JvmField
val PINK_GILDED_CHEST = this.create("pink_gilded_chest", BlockItem(CobblemonBlocks.PINK_GILDED_CHEST, Item.Properties()))
val PINK_GILDED_CHEST = this.create("pink_gilded_chest", BlockItem(CobblemonBlocks.PINK_GILDED_CHEST, Properties()))
@JvmField
val BLACK_GILDED_CHEST = this.create("black_gilded_chest", BlockItem(CobblemonBlocks.BLACK_GILDED_CHEST, Item.Properties()))
val BLACK_GILDED_CHEST = this.create("black_gilded_chest", BlockItem(CobblemonBlocks.BLACK_GILDED_CHEST,
Properties()
))
@JvmField
val WHITE_GILDED_CHEST = this.create("white_gilded_chest", BlockItem(CobblemonBlocks.WHITE_GILDED_CHEST, Item.Properties()))
val WHITE_GILDED_CHEST = this.create("white_gilded_chest", BlockItem(CobblemonBlocks.WHITE_GILDED_CHEST,
Properties()
))
@JvmField
val GREEN_GILDED_CHEST = this.create("green_gilded_chest", BlockItem(CobblemonBlocks.GREEN_GILDED_CHEST, Item.Properties()))
val GREEN_GILDED_CHEST = this.create("green_gilded_chest", BlockItem(CobblemonBlocks.GREEN_GILDED_CHEST,
Properties()
))
@JvmField
val GIMMIGHOUL_CHEST = this.create("gimmighoul_chest", BlockItem(CobblemonBlocks.GIMMIGHOUL_CHEST, Item.Properties()))
val GIMMIGHOUL_CHEST = this.create("gimmighoul_chest", BlockItem(CobblemonBlocks.GIMMIGHOUL_CHEST, Properties()))
// Saccharines
@JvmField
@@ -322,9 +332,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SACCHARINE_LEAVES = compostableBlockItem("saccharine_leaves", CobblemonBlocks.SACCHARINE_LEAVES, 0.35f)
@JvmField
val SACCHARINE_BOAT = create("saccharine_boat", CobblemonBoatItem(CobblemonBoatType.SACCHARINE, false, Item.Properties().stacksTo(1)))
val SACCHARINE_BOAT = create("saccharine_boat", CobblemonBoatItem(CobblemonBoatType.SACCHARINE, false, Properties().stacksTo(1)))
@JvmField
val SACCHARINE_CHEST_BOAT = create("saccharine_chest_boat", CobblemonBoatItem(CobblemonBoatType.SACCHARINE, true, Item.Properties().stacksTo(1)))
val SACCHARINE_CHEST_BOAT = create("saccharine_chest_boat", CobblemonBoatItem(CobblemonBoatType.SACCHARINE, true, Properties().stacksTo(1)))
@JvmField
val SACCHARINE_DOOR = blockItem("saccharine_door", CobblemonBlocks.SACCHARINE_DOOR)
@@ -343,9 +353,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SACCHARINE_STAIRS = blockItem("saccharine_stairs", CobblemonBlocks.SACCHARINE_STAIRS)
@JvmField
val SACCHARINE_SIGN = this.create("saccharine_sign", SignItem(Item.Properties().stacksTo(16), CobblemonBlocks.SACCHARINE_SIGN, CobblemonBlocks.SACCHARINE_WALL_SIGN))
val SACCHARINE_SIGN = this.create("saccharine_sign", SignItem(Properties().stacksTo(16), CobblemonBlocks.SACCHARINE_SIGN, CobblemonBlocks.SACCHARINE_WALL_SIGN))
@JvmField
val SACCHARINE_HANGING_SIGN = this.create("saccharine_hanging_sign", HangingSignItem(CobblemonBlocks.SACCHARINE_HANGING_SIGN, CobblemonBlocks.SACCHARINE_WALL_HANGING_SIGN, Item.Properties().stacksTo(16)))
val SACCHARINE_HANGING_SIGN = this.create("saccharine_hanging_sign", HangingSignItem(CobblemonBlocks.SACCHARINE_HANGING_SIGN, CobblemonBlocks.SACCHARINE_WALL_HANGING_SIGN, Properties().stacksTo(16)))
@JvmField
val SACCHARINE_SAPLING = compostableBlockItem("saccharine_sapling", CobblemonBlocks.SACCHARINE_SAPLING, 0.30f)
@@ -467,9 +477,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
// Evolution items
@JvmField val LINK_CABLE = create("link_cable", LinkCableItem())
@JvmField val DRAGON_SCALE = noSettingsItem("dragon_scale")
@JvmField val METAL_COAT = noSettingsItem("metal_coat")
@JvmField val UPGRADE = noSettingsItem("upgrade")
@JvmField val DUBIOUS_DISC = noSettingsItem("dubious_disc")
@JvmField val METAL_COAT = itemNameBlockItem("metal_coat", CobblemonBlocks.METAL_COAT)
@JvmField val UPGRADE = itemNameBlockItem("upgrade", CobblemonBlocks.UPGRADE)
@JvmField val DUBIOUS_DISC = itemNameBlockItem("dubious_disc", CobblemonBlocks.DUBIOUS_DISC)
@JvmField val DEEP_SEA_SCALE = noSettingsItem("deep_sea_scale")
@JvmField val DEEP_SEA_TOOTH = noSettingsItem("deep_sea_tooth")
@JvmField val ELECTIRIZER = noSettingsItem("electirizer")
@@ -478,7 +488,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField val PROTECTOR = noSettingsItem("protector")
@JvmField val REAPER_CLOTH = noSettingsItem("reaper_cloth")
@JvmField val PRISM_SCALE = noSettingsItem("prism_scale")
@JvmField val SACHET = noSettingsItem("sachet")
@JvmField val SACHET = itemNameBlockItem("sachet", CobblemonBlocks.SACHET)
@JvmField val WHIPPED_DREAM = create("whipped_dream", foodItem(8, 0.3f))
@JvmField val STRAWBERRY_SWEET = create("strawberry_sweet", foodItem(6, 0.125f))
@JvmField val LOVE_SWEET = create("love_sweet", foodItem(6, 0.125f))
@@ -487,26 +497,41 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField val FLOWER_SWEET = create("flower_sweet", foodItem(6, 0.125f))
@JvmField val STAR_SWEET = create("star_sweet", foodItem(6, 0.125f))
@JvmField val RIBBON_SWEET = create("ribbon_sweet", foodItem(6, 0.125f))
@JvmField val CHIPPED_POT = noSettingsItem("chipped_pot")
@JvmField val CRACKED_POT = noSettingsItem("cracked_pot")
@JvmField val MASTERPIECE_TEACUP = noSettingsItem("masterpiece_teacup")
@JvmField val UNREMARKABLE_TEACUP = noSettingsItem("unremarkable_teacup")
@JvmField val CHIPPED_POT = itemNameBlockItem("chipped_pot", CobblemonBlocks.CHIPPED_POT)
@JvmField val CRACKED_POT = itemNameBlockItem("cracked_pot", CobblemonBlocks.CRACKED_POT)
@JvmField val MASTERPIECE_TEACUP = itemNameBlockItem("masterpiece_teacup", CobblemonBlocks.MASTERPIECE_TEACUP)
@JvmField val UNREMARKABLE_TEACUP = itemNameBlockItem("unremarkable_teacup", CobblemonBlocks.UNREMARKABLE_TEACUP)
@JvmField val SWEET_APPLE = compostableItem("sweet_apple", foodItem(4, 0.3f), 0.65f)
@JvmField val TART_APPLE = compostableItem("tart_apple", foodItem(4, 0.3f), 0.65f)
@JvmField val SYRUPY_APPLE = compostableItem("syrupy_apple", foodItem(4, 0.3f), 0.65f)
@JvmField val GALARICA_CUFF = noSettingsItem("galarica_cuff")
@JvmField val GALARICA_WREATH = noSettingsItem("galarica_wreath")
@JvmField val GALARICA_CUFF = itemNameBlockItem("galarica_cuff", CobblemonBlocks.GALARICA_CUFF)
@JvmField val BLACK_AUGURITE = noSettingsItem("black_augurite")
@JvmField val PEAT_BLOCK = noSettingsItem("peat_block")
@JvmField val PEAT_BLOCK = itemNameBlockItem("peat_block", CobblemonBlocks.PEAT_BLOCK)
@JvmField val RAZOR_CLAW = noSettingsItem("razor_claw")
@JvmField val RAZOR_FANG = noSettingsItem("razor_fang")
@JvmField val AUSPICIOUS_ARMOR = heldItem("auspicious_armor")
@JvmField val MALICIOUS_ARMOR = heldItem("malicious_armor")
@JvmField val SHELL_HELMET = heldItem("shell_helmet")
@JvmField val METAL_ALLOY = noSettingsItem("metal_alloy")
@JvmField val SCROLL_OF_DARKNESS = noSettingsItem("scroll_of_darkness")
@JvmField val SCROLL_OF_WATERS = noSettingsItem("scroll_of_waters")
@JvmField val WHITE_PLAQUE = blockItem("white_plaque", CobblemonBlocks.WHITE_PLAQUE)
@JvmField val LIGHT_GRAY_PLAQUE = blockItem("light_gray_plaque", CobblemonBlocks.LIGHT_GRAY_PLAQUE)
@JvmField val GRAY_PLAQUE = blockItem("gray_plaque", CobblemonBlocks.GRAY_PLAQUE)
@JvmField val BLACK_PLAQUE = blockItem("black_plaque", CobblemonBlocks.BLACK_PLAQUE)
@JvmField val BROWN_PLAQUE = blockItem("brown_plaque", CobblemonBlocks.BROWN_PLAQUE)
@JvmField val RED_PLAQUE = blockItem("red_plaque", CobblemonBlocks.RED_PLAQUE)
@JvmField val ORANGE_PLAQUE = blockItem("orange_plaque", CobblemonBlocks.ORANGE_PLAQUE)
@JvmField val YELLOW_PLAQUE = blockItem("yellow_plaque", CobblemonBlocks.YELLOW_PLAQUE)
@JvmField val LIME_PLAQUE = blockItem("lime_plaque", CobblemonBlocks.LIME_PLAQUE)
@JvmField val GREEN_PLAQUE = blockItem("green_plaque", CobblemonBlocks.GREEN_PLAQUE)
@JvmField val CYAN_PLAQUE = blockItem("cyan_plaque", CobblemonBlocks.CYAN_PLAQUE)
@JvmField val LIGHT_BLUE_PLAQUE = blockItem("light_blue_plaque", CobblemonBlocks.LIGHT_BLUE_PLAQUE)
@JvmField val BLUE_PLAQUE = blockItem("blue_plaque", CobblemonBlocks.BLUE_PLAQUE)
@JvmField val PURPLE_PLAQUE = blockItem("purple_plaque", CobblemonBlocks.PURPLE_PLAQUE)
@JvmField val MAGENTA_PLAQUE = blockItem("magenta_plaque", CobblemonBlocks.MAGENTA_PLAQUE)
@JvmField val PINK_PLAQUE = blockItem("pink_plaque", CobblemonBlocks.PINK_PLAQUE)
private val berries = mutableMapOf<ResourceLocation, BerryItem>()
// Plants
@JvmField val CHERI_BERRY = berryItem("cheri", StatusCuringBerryItem(CobblemonBlocks.CHERI_BERRY, Statuses.PARALYSIS))
@@ -626,17 +651,17 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val EXPERIENCE_CANDY_XL = candyItem("exp_candy_xl") { _, _ -> CandyItem.DEFAULT_XL_CANDY_YIELD }
@JvmField
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK))
val CALCIUM = create("calcium", VitaminItem(Stats.SPECIAL_ATTACK, block = CobblemonBlocks.CALCIUM))
@JvmField
val CARBOS = create("carbos", VitaminItem(Stats.SPEED))
val CARBOS = create("carbos", VitaminItem(Stats.SPEED, block = CobblemonBlocks.CARBOS))
@JvmField
val HP_UP = create("hp_up", VitaminItem(Stats.HP))
val HP_UP = create("hp_up", VitaminItem(Stats.HP, block = CobblemonBlocks.HP_UP))
@JvmField
val IRON = create("iron", VitaminItem(Stats.DEFENCE))
val IRON = create("iron", VitaminItem(Stats.DEFENCE, block = CobblemonBlocks.IRON))
@JvmField
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK))
val PROTEIN = create("protein", VitaminItem(Stats.ATTACK, block = CobblemonBlocks.PROTEIN))
@JvmField
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE))
val ZINC = create("zinc", VitaminItem(Stats.SPECIAL_DEFENCE, block = CobblemonBlocks.ZINC))
@JvmField
val HEALTH_MOCHI = create("health_mochi", MochiItem(Stats.HP))
@JvmField
@@ -664,7 +689,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val CLEVER_FEATHER = create("clever_feather", FeatherItem(Stats.SPECIAL_DEFENCE))
@JvmField
val MEDICINAL_LEEK = heldItem("medicinal_leek", MedicinalLeekItem(CobblemonBlocks.MEDICINAL_LEEK, Item.Properties().food(FoodProperties.Builder().fast().nutrition(1).saturationModifier(0.2f).build())), "leek")
val MEDICINAL_LEEK = heldItem("medicinal_leek", MedicinalLeekItem(CobblemonBlocks.MEDICINAL_LEEK, Properties().food(FoodProperties.Builder().fast().nutrition(1).saturationModifier(0.2f).build())), "leek")
@JvmField
val ROASTED_LEEK = compostableItem("roasted_leek", CobblemonItem(Item.Properties().food(FoodProperties.Builder().fast().nutrition(3).saturationModifier(0.2f).build())), 0.85f)
@JvmField
@@ -699,15 +724,15 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val MOOMOO_MILK = create("moomoo_milk", MoomooMilk(Item.Properties().craftRemainder(Items.GLASS_BOTTLE).stacksTo((16))))
@JvmField
val POTION = create("potion", PotionItem(PotionType.POTION))
val POTION = potionItem("potion", PotionType.POTION, CobblemonBlocks.POTION)
@JvmField
val SUPER_POTION = create("super_potion", PotionItem(PotionType.SUPER_POTION))
val SUPER_POTION = potionItem("super_potion", PotionType.SUPER_POTION, CobblemonBlocks.SUPER_POTION)
@JvmField
val HYPER_POTION = create("hyper_potion", PotionItem(PotionType.HYPER_POTION))
val HYPER_POTION = potionItem("hyper_potion", PotionType.HYPER_POTION, CobblemonBlocks.HYPER_POTION)
@JvmField
val MAX_POTION = create("max_potion", PotionItem(PotionType.MAX_POTION))
val MAX_POTION = potionItem("max_potion", PotionType.MAX_POTION, CobblemonBlocks.MAX_POTION)
@JvmField
val FULL_RESTORE = create("full_restore", PotionItem(PotionType.FULL_RESTORE))
val FULL_RESTORE = potionItem("full_restore", PotionType.FULL_RESTORE, CobblemonBlocks.FULL_RESTORE)
@JvmField
val HEAL_POWDER = create("heal_powder", HealPowderItem())
@@ -718,9 +743,9 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val MAX_REVIVE = create("max_revive", ReviveItem(max = true))
@JvmField
val PP_UP = create("pp_up", PPUpItem(1))
val PP_UP = create("pp_up", PPUpItem(1, block = CobblemonBlocks.PP_UP))
@JvmField
val PP_MAX = create("pp_max", PPUpItem(3))
val PP_MAX = create("pp_max", PPUpItem(3, block = CobblemonBlocks.PP_MAX))
@JvmField
val RED_MINT_SEEDS = mintSeed("red", MintType.RED.getCropBlock())
@@ -792,28 +817,29 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SERIOUS_MINT = mintItem("serious_mint", MintItem(Natures.SERIOUS))
@JvmField val X_ACCURACY = create("x_${Stats.ACCURACY.identifier.path}", XStatItem(Stats.ACCURACY))
@JvmField val X_ATTACK = create("x_${Stats.ATTACK.identifier.path}", XStatItem(Stats.ATTACK))
@JvmField val X_DEFENSE = create("x_${Stats.DEFENCE.identifier.path}", XStatItem(Stats.DEFENCE))
@JvmField val X_SP_ATK = create("x_${Stats.SPECIAL_ATTACK.identifier.path}", XStatItem(Stats.SPECIAL_ATTACK))
@JvmField val X_SP_DEF = create("x_${Stats.SPECIAL_DEFENCE.identifier.path}", XStatItem(Stats.SPECIAL_DEFENCE))
@JvmField val X_SPEED = create("x_${Stats.SPEED.identifier.path}", XStatItem(Stats.SPEED))
@JvmField val X_ACCURACY = create("x_${Stats.ACCURACY.identifier.path}", XStatItem(Stats.ACCURACY, block = CobblemonBlocks.X_ACCURACY))
@JvmField val X_ATTACK = create("x_${Stats.ATTACK.identifier.path}", XStatItem(Stats.ATTACK, block = CobblemonBlocks.X_ATTACK))
@JvmField val X_DEFENSE = create("x_${Stats.DEFENCE.identifier.path}", XStatItem(Stats.DEFENCE, block = CobblemonBlocks.X_DEFENCE))
@JvmField val X_SP_ATK = create("x_${Stats.SPECIAL_ATTACK.identifier.path}", XStatItem(Stats.SPECIAL_ATTACK, block = CobblemonBlocks.X_SPECIAL_ATTACK))
@JvmField val X_SP_DEF = create("x_${Stats.SPECIAL_DEFENCE.identifier.path}", XStatItem(Stats.SPECIAL_DEFENCE, block = CobblemonBlocks.X_SPECIAL_DEFENCE))
@JvmField val X_SPEED = create("x_${Stats.SPEED.identifier.path}", XStatItem(Stats.SPEED, block = CobblemonBlocks.X_SPEED))
@JvmField val DIRE_HIT = create("dire_hit", DireHitItem())
@JvmField val GUARD_SPEC = create("guard_spec", GuardSpecItem())
@JvmField val DIRE_HIT = create("dire_hit", DireHitItem(block = CobblemonBlocks.DIRE_HIT))
@JvmField val GUARD_SPEC = create("guard_spec", GuardSpecItem(block = CobblemonBlocks.GUARD_SPEC))
@JvmField val BURN_HEAL = create("burn_heal", StatusCureItem("item.cobblemon.burn_heal", Statuses.BURN))
@JvmField val PARALYZE_HEAL = create("paralyze_heal", StatusCureItem("item.cobblemon.paralyze_heal", Statuses.PARALYSIS))
@JvmField val ICE_HEAL = create("ice_heal", StatusCureItem("item.cobblemon.ice_heal", Statuses.FROZEN))
@JvmField val ANTIDOTE = create("antidote", StatusCureItem("item.cobblemon.antidote", Statuses.POISON, Statuses.POISON_BADLY))
@JvmField val AWAKENING = create("awakening", StatusCureItem("item.cobblemon.awakening", Statuses.SLEEP))
@JvmField val BURN_HEAL = create("burn_heal", StatusCureItem("item.cobblemon.burn_heal", Statuses.BURN, block = CobblemonBlocks.BURN_HEAL))
@JvmField val PARALYZE_HEAL = create("paralyze_heal", StatusCureItem(
"item.cobblemon.paralyze_heal", Statuses.PARALYSIS, block = CobblemonBlocks.PARALYZE_HEAL))
@JvmField val ICE_HEAL = create("ice_heal", StatusCureItem("item.cobblemon.ice_heal", Statuses.FROZEN, block = CobblemonBlocks.ICE_HEAL))
@JvmField val ANTIDOTE = create("antidote", StatusCureItem("item.cobblemon.antidote", Statuses.POISON, Statuses.POISON_BADLY, block = CobblemonBlocks.ANTIDOTE))
@JvmField val AWAKENING = create("awakening", StatusCureItem("item.cobblemon.awakening", Statuses.SLEEP, block = CobblemonBlocks.AWAKENING))
@JvmField val FULL_HEAL = create("full_heal", StatusCureItem("item.cobblemon.full_heal"))
@JvmField val FULL_HEAL = create("full_heal", StatusCureItem("item.cobblemon.full_heal", block = CobblemonBlocks.FULL_HEAL))
@JvmField val ETHER = create("ether", EtherItem(max = false))
@JvmField val MAX_ETHER = create("max_ether", EtherItem(max = true))
@JvmField val ELIXIR = create("elixir", ElixirItem(max = false))
@JvmField val MAX_ELIXIR = create("max_elixir", ElixirItem(max = true))
@JvmField val ETHER = create("ether", EtherItem(max = false, block = CobblemonBlocks.ETHER))
@JvmField val MAX_ETHER = create("max_ether", EtherItem(max = true, block = CobblemonBlocks.MAX_ETHER))
@JvmField val ELIXIR = create("elixir", ElixirItem(max = false, block = CobblemonBlocks.ELIXIR))
@JvmField val MAX_ELIXIR = create("max_elixir", ElixirItem(max = true, block = CobblemonBlocks.MAX_ELIXIR))
@JvmField
val ABILITY_CAPSULE = this.create("ability_capsule", AbilityChangeItem(AbilityChanger.COMMON_ABILITY))
@@ -898,11 +924,18 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField val CHOICE_SPECS = wearableItem("choice_specs")
@JvmField val EXP_SHARE = wearableItem("exp_share")
@JvmField val FOCUS_BAND = wearableItem("focus_band")
@JvmField val KINGS_ROCK = wearableItem("kings_rock")
@JvmField val KINGS_ROCK = wearableItem("kings_rock", block = CobblemonBlocks.KINGS_ROCK)
@JvmField val MUSCLE_BAND = wearableItem("muscle_band")
@JvmField val ROCKY_HELMET = wearableItem("rocky_helmet")
@JvmField val SAFETY_GOGGLES = wearableItem("safety_goggles")
@JvmField val WISE_GLASSES = wearableItem("wise_glasses")
@JvmField val GALARICA_WREATH = wearableItem("galarica_wreath", block = CobblemonBlocks.GALARICA_WREATH)
@JvmField val SHELL_HELMET = wearableItem("shell_helmet")
@JvmField val NEVER_MELT_ICE = wearableItem("never_melt_ice", block = CobblemonBlocks.NEVER_MELT_ICE)
@JvmField val CLEANSE_TAG = wearableItem("cleanse_tag", block = CobblemonBlocks.CLEANSE_TAG)
@JvmField val SPELL_TAG = wearableItem("spell_tag", block = CobblemonBlocks.SPELL_TAG)
@JvmField val COVERT_CLOAK = wearableItem("covert_cloak")
@JvmField val SHARP_BEAK = wearableItem("sharp_beak")
// Held Items
@JvmField
@@ -922,7 +955,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val BLACK_SLUDGE = heldItem("black_sludge")
@JvmField
val BLUNDER_POLICY = heldItem("blunder_policy")
val BLUNDER_POLICY = itemNameBlockItem("blunder_policy", CobblemonBlocks.BLUNDER_POLICY)
@JvmField
val CELL_BATTERY = heldItem("cell_battery")
@JvmField
@@ -930,17 +963,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val CHOICE_SCARF = heldItem("choice_scarf")
@JvmField
val CLEANSE_TAG = heldItem("cleanse_tag")
@JvmField
val CLEAR_AMULET = heldItem("clear_amulet")
@JvmField
val COVERT_CLOAK = heldItem("covert_cloak")
@JvmField
val DESTINY_KNOT = heldItem("destiny_knot")
val DESTINY_KNOT = itemNameBlockItem("destiny_knot", CobblemonBlocks.DESTINY_KNOT)
@JvmField
val DRAGON_FANG = heldItem("dragon_fang")
@JvmField
val EJECT_BUTTON = heldItem("eject_button")
val EJECT_BUTTON = itemNameBlockItem("eject_button", CobblemonBlocks.EJECT_BUTTON)
@JvmField
val EJECT_PACK = heldItem("eject_pack")
@JvmField
@@ -954,7 +983,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val FAIRY_FEATHER = heldItem("fairy_feather")
@JvmField
val FLAME_ORB = heldItem("flame_orb")
val FLAME_ORB = itemNameBlockItem("flame_orb", CobblemonBlocks.FLAME_ORB)
@JvmField
val FLOAT_STONE = heldItem("float_stone")
@JvmField
@@ -964,19 +993,19 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val GRIP_CLAW = heldItem("grip_claw")
@JvmField
val HARD_STONE = heldItem("hard_stone")
val HARD_STONE = itemNameBlockItem("hard_stone", CobblemonBlocks.HARD_STONE)
@JvmField
val HEAVY_DUTY_BOOTS = heldItem("heavy_duty_boots")
@JvmField
val IRON_BALL = heldItem("iron_ball")
val IRON_BALL = itemNameBlockItem("iron_ball", CobblemonBlocks.IRON_BALL)
@JvmField
val LAGGING_TAIL = heldItem("lagging_tail")
@JvmField
val LEFTOVERS = compostableHeldItem("leftovers", null, 0.50f)
@JvmField
val LIFE_ORB = heldItem("life_orb")
val LIFE_ORB = itemNameBlockItem("life_orb", CobblemonBlocks.LIFE_ORB)
@JvmField
val LIGHT_BALL = heldItem("light_ball")
val LIGHT_BALL = itemNameBlockItem("light_ball", CobblemonBlocks.LIGHT_BALL)
@JvmField
val LIGHT_CLAY = heldItem("light_clay")
@JvmField
@@ -984,18 +1013,16 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val LUCKY_EGG = heldItem("lucky_egg")
@JvmField
val LUMINOUS_MOSS = heldItem("luminous_moss")
val LUMINOUS_MOSS = itemNameBlockItem("luminous_moss", CobblemonBlocks.LUMINOUS_MOSS)
@JvmField
val MAGNET = heldItem("magnet")
val MAGNET = itemNameBlockItem("magnet", CobblemonBlocks.MAGNET)
@JvmField
val METRONOME = heldItem("metronome")
val METRONOME = itemNameBlockItem("metronome", CobblemonBlocks.METRONOME)
@JvmField
val MIRACLE_SEED = heldItem("miracle_seed")
@JvmField
val MYSTIC_WATER = heldItem("mystic_water")
@JvmField
val NEVER_MELT_ICE = heldItem("never_melt_ice")
@JvmField
val POISON_BARB = heldItem("poison_barb")
@JvmField
val POWER_ANKLET = heldItem("power_anklet")
@@ -1020,14 +1047,12 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val RED_CARD = heldItem("red_card")
@JvmField
val RING_TARGET = heldItem("ring_target")
val RING_TARGET = itemNameBlockItem("ring_target", CobblemonBlocks.RING_TARGET)
@JvmField
val ROOM_SERVICE = heldItem("room_service")
@JvmField
val SCOPE_LENS = heldItem("scope_lens")
@JvmField
val SHARP_BEAK = heldItem("sharp_beak")
@JvmField
val SHED_SHELL = heldItem("shed_shell")
@JvmField
val SHELL_BELL = heldItem("shell_bell")
@@ -1038,9 +1063,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val SOFT_SAND = heldItem("soft_sand")
@JvmField
val SPELL_TAG = heldItem("spell_tag")
@JvmField
val SMOKE_BALL = heldItem("smoke_ball")
val SMOKE_BALL = itemNameBlockItem("smoke_ball", CobblemonBlocks.SMOKE_BALL)
@JvmField
val SOOTHE_BELL = heldItem("soothe_bell")
@JvmField
@@ -1050,13 +1073,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val THROAT_SPRAY = heldItem("throat_spray")
@JvmField
val TOXIC_ORB = heldItem("toxic_orb")
val TOXIC_ORB = itemNameBlockItem("toxic_orb", CobblemonBlocks.TOXIC_ORB)
@JvmField
val TWISTED_SPOON = heldItem("twisted_spoon")
@JvmField
val UTILITY_UMBRELLA = heldItem("utility_umbrella")
@JvmField
val WEAKNESS_POLICY = heldItem("weakness_policy")
val WEAKNESS_POLICY = itemNameBlockItem("weakness_policy", CobblemonBlocks.WEAKNESS_POLICY)
@JvmField
val WIDE_LENS = heldItem("wide_lens")
@JvmField
@@ -1072,19 +1095,19 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val WHITE_HERB = compostableHeldItem("white_herb", null, 0.85F)
@JvmField
val BRIGHT_POWDER = heldItem("bright_powder")
val BRIGHT_POWDER = itemNameBlockItem("bright_powder", CobblemonBlocks.BRIGHT_POWDER)
@JvmField
val METAL_POWDER = heldItem("metal_powder")
val METAL_POWDER = itemNameBlockItem("metal_powder", CobblemonBlocks.METAL_POWDER)
@JvmField
val QUICK_POWDER = heldItem("quick_powder")
val QUICK_POWDER = itemNameBlockItem("quick_powder", CobblemonBlocks.QUICK_POWDER)
@JvmField
val DAMP_ROCK = heldItem("damp_rock")
val DAMP_ROCK = itemNameBlockItem("damp_rock", CobblemonBlocks.DAMP_ROCK)
@JvmField
val HEAT_ROCK = heldItem("heat_rock")
val HEAT_ROCK = itemNameBlockItem("heat_rock", CobblemonBlocks.HEAT_ROCK)
@JvmField
val SMOOTH_ROCK = heldItem("smooth_rock")
val SMOOTH_ROCK = itemNameBlockItem("smooth_rock", CobblemonBlocks.SMOOTH_ROCK)
@JvmField
val ICY_ROCK = heldItem("icy_rock")
val ICY_ROCK = itemNameBlockItem("icy_rock", CobblemonBlocks.ICY_ROCK)
// Mulch
@JvmField
@@ -1152,11 +1175,11 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
val SUSPICIOUS_SHERD = itemWithRarity("suspicious_sherd", Rarity.UNCOMMON)
@JvmField
val TUMBLESTONE = this.create("tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE))
val TUMBLESTONE = this.create("tumblestone", TumblestoneItem(Properties(), CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE))
@JvmField
val BLACK_TUMBLESTONE = this.create("black_tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE))
val BLACK_TUMBLESTONE = this.create("black_tumblestone", TumblestoneItem(Properties(), CobblemonBlocks.SMALL_BUDDING_BLACK_TUMBLESTONE))
@JvmField
val SKY_TUMBLESTONE = this.create("sky_tumblestone", TumblestoneItem(Item.Properties(), CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE))
val SKY_TUMBLESTONE = this.create("sky_tumblestone", TumblestoneItem(Properties(), CobblemonBlocks.SMALL_BUDDING_SKY_TUMBLESTONE))
@JvmField
val SMALL_BUDDING_TUMBLESTONE = blockItem("small_budding_tumblestone", CobblemonBlocks.SMALL_BUDDING_TUMBLESTONE)
@@ -1413,7 +1436,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
@JvmField
val RELIC_COIN = noSettingsItem("relic_coin")
@JvmField
val RELIC_COIN_POUCH = blockItem("relic_coin_pouch", CobblemonBlocks.RELIC_COIN_POUCH)
val RELIC_COIN_POUCH = itemNameBlockItem("relic_coin_pouch", CobblemonBlocks.RELIC_COIN_POUCH)
@JvmField
val RELIC_COIN_SACK = blockItem("relic_coin_sack", CobblemonBlocks.RELIC_COIN_SACK)
@@ -1457,13 +1480,13 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
//@JvmField
//val BINDING_SOIL = blockItem("binding_soil", CobblemonBlocks.BINDING_SOIL)
private fun blockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): BlockItem = this.create(name, BlockItem(block, Item.Properties().rarity(rarity)))
private fun blockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): BlockItem = this.create(name, BlockItem(block, Properties().rarity(rarity)))
private fun itemNameBlockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): ItemNameBlockItem = this.create(name, ItemNameBlockItem(block, Item.Properties().rarity(rarity)))
private fun itemNameBlockItem(name: String, block: Block, rarity: Rarity = Rarity.COMMON): ItemNameBlockItem = this.create(name, ItemNameBlockItem(block, Properties().rarity(rarity)))
private fun noSettingsItem(name: String): CobblemonItem = this.create(name, CobblemonItem(Item.Properties()))
private fun noSettingsItem(name: String): CobblemonItem = this.create(name, CobblemonItem(Properties()))
private fun itemWithRarity(name: String, rarity: Rarity): CobblemonItem = this.create(name, CobblemonItem(Item.Properties().rarity(rarity)))
private fun itemWithRarity(name: String, rarity: Rarity): CobblemonItem = this.create(name, CobblemonItem(Properties().rarity(rarity)))
fun berries() = this.berries.toMap()
@@ -1479,7 +1502,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
private fun candyItem(name: String, rarity: Rarity = Rarity.COMMON, calculator: CandyItem.Calculator): CandyItem = this.create(name, CandyItem(rarity, calculator))
private fun pokerodItem(pokeRodId: ResourceLocation, rarity: Rarity = Rarity.COMMON): PokerodItem {
val settings = Item.Properties().stacksTo(1).durability(256).rarity(rarity)
val settings = Properties().stacksTo(1).durability(256).rarity(rarity)
val item = create(pokeRodId.path, PokerodItem(pokeRodId, settings))
pokeRods.add(item)
return item
@@ -1491,15 +1514,14 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
return item
}
private fun wearableItem(name: String, heldItemRemappedName: String? = null): CobblemonItem = create(
name,
WearableItem(name).also {
wearables.add(it)
if (heldItemRemappedName != null) {
CobblemonHeldItemManager.registerRemap(it, heldItemRemappedName)
}
}
)
private fun wearableItem(name: String, heldItemRemappedName: String? = null, block: Block = Blocks.AIR): WearableItem =
create(name,
WearableItem(name, block).also {
wearables.add(it)
if (heldItemRemappedName != null) {
CobblemonHeldItemManager.registerRemap(it, heldItemRemappedName)
}
})
private fun campfirePotItem(block: Block, color: CampfirePotColor): CampfirePotItem {
val item = create("campfire_pot_${color.suffix}", CampfirePotItem(block, color))
@@ -1538,7 +1560,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
foodPropertiesBuilder.usingConvertsTo(convertsToOnUse.item)
}
val properties = Item.Properties()
val properties = Properties()
.stacksTo(stacksTo)
.food(foodPropertiesBuilder.build())
@@ -1547,7 +1569,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
private fun heldItem(name: String, remappedName: String? = null): CobblemonItem = create(
name,
CobblemonItem(Item.Properties()).also {
CobblemonItem(Properties()).also {
if (remappedName != null) {
CobblemonHeldItemManager.registerRemap(it, remappedName)
}
@@ -1623,7 +1645,7 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
}
private fun compostableItem(name: String, item: Item? = null, increaseLevelChance: Float = .65f): Item {
val createdItem = this.create(name, item ?: CobblemonItem(Item.Properties()))
val createdItem = this.create(name, item ?: CobblemonItem(Properties()))
compostable(createdItem, increaseLevelChance)
return createdItem
}
@@ -1646,7 +1668,12 @@ object CobblemonItems : PlatformRegistry<Registry<Item>, ResourceKey<Registry<It
return createdItem
}
private fun potionItem(name: String, type: PotionType, block: Block): PotionItem {
val item = PotionItem(type, block)
return create(name, item)
}
private fun foodItem(nutrition: Int, saturationModifier: Float): Item {
return CobblemonItem(Item.Properties().food(FoodProperties.Builder().nutrition(nutrition).saturationModifier(saturationModifier).build()))
return CobblemonItem(Properties().food(FoodProperties.Builder().nutrition(nutrition).saturationModifier(saturationModifier).build()))
}
}
File diff suppressed because it is too large. Load diff
@@ -9,15 +9,14 @@
package com.cobblemon.mod.common
import net.minecraft.client.RecipeBookCategories
import net.minecraft.world.inventory.RecipeBookType
enum class CobblemonRecipeCategories {
COOKING_POT_SEARCH("COBBLEMON_COOKING_POT_SEARCH"),
COOKING_POT_FOODS("COBBLEMON_COOKING_POT_FOODS"),
COOKING_POT_MEDICINES("COBBLEMON_COOKING_POT_MEDICINES"),
COOKING_POT_COMPLEX_DISHES("COBBLEMON_COOKING_POT_COMPLEX_DISHES"),
COOKING_POT_MISC("COBBLEMON_COOKING_POT_MISC");
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_MISC("COOKING_POT_MISC");
companion object {
val customAggregateCategories: Map<RecipeBookCategories, List<RecipeBookCategories>> = mapOf(
@@ -36,9 +35,6 @@ enum class CobblemonRecipeCategories {
fun toVanillaCategory(): RecipeBookCategories {
return RecipeBookCategories.valueOf(this.id)
}
}
object CobblemonRecipeBookTypes {
const val COOKING_POT_NAME = "COBBLEMON_COOKING_POT"
val COOKING_POT: RecipeBookType = RecipeBookType.valueOf(COOKING_POT_NAME)
}
@@ -89,14 +89,7 @@ object CobblemonTradeOffers {
* @return The resulting list.
*/
fun resolveWanderingTradeOffers(): List<WandererTradeOffer> = listOf(
WandererTradeOffer(false, listOf(
VillagerTrades.ItemsForEmeralds(CobblemonItems.VIVICHOKE_SEEDS, 6, 1, 1, 6),
VillagerTrades.ItemsForEmeralds(CobblemonItems.SACCHARINE_SAPLING, 5, 1, 4, 1),
VillagerTrades.ItemsForEmeralds(CobblemonItems.HEARTY_GRAINS, 1, 1, 12, 1),
VillagerTrades.ItemsForEmeralds(CobblemonItems.CHIPPED_POT, 5, 1, 1, 2),
VillagerTrades.ItemsForEmeralds(CobblemonItems.MASTERPIECE_TEACUP, 5, 1, 1, 2)
))
WandererTradeOffer(false, listOf(VillagerTrades.ItemsForEmeralds(CobblemonItems.VIVICHOKE_SEEDS, 24, 1, 1, 6)))
)
/**
@@ -1,44 +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.ai.config.task
import com.cobblemon.mod.common.CobblemonMemories
import com.cobblemon.mod.common.api.ai.BehaviourConfigurationContext
import com.cobblemon.mod.common.api.ai.WrapperLivingEntityTask
import com.cobblemon.mod.common.api.npc.configuration.MoLangConfigVariable
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.entity.pokemon.ai.tasks.DefendOwnerTask
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.ai.behavior.BehaviorControl
import net.minecraft.world.entity.ai.memory.MemoryModuleType
class DefendOwnerTaskConfig : SingleTaskConfig {
override fun getVariables(
entity: LivingEntity,
behaviourConfigurationContext: BehaviourConfigurationContext
): List<MoLangConfigVariable> {
return emptyList()
}
override fun createTask(
entity: LivingEntity,
behaviourConfigurationContext: BehaviourConfigurationContext
): BehaviorControl<in LivingEntity>? {
behaviourConfigurationContext.addMemories(
MemoryModuleType.ATTACK_TARGET,
CobblemonMemories.NEAREST_VISIBLE_ATTACKER,
)
return WrapperLivingEntityTask(
DefendOwnerTask.create(),
PokemonEntity::class.java
)
}
}
@@ -109,7 +109,7 @@ class PollinateFlowerTaskConfig : SingleTaskConfig {
}
override fun stop(level: ServerLevel, entity: LivingEntity, gameTime: Long) {
hoverPos = null
if (successfulPollinationTicks > REQUIRED_SUCCESSFUL_POLLINATION_TICKS) {
entity.brain.setMemory(CobblemonMemories.HAS_NECTAR, true)
}
@@ -105,7 +105,6 @@ interface TaskConfig {
cobblemonResource("go_to_land") to GoToLandTaskConfig::class.java,
cobblemonResource("manage_flight_in_battle") to ManageFlightInBattleTaskConfig::class.java,
cobblemonResource("attack_hostile_mobs") to AttackHostileMobsTaskConfig::class.java,
cobblemonResource("defend_owner") to DefendOwnerTaskConfig::class.java,
cobblemonResource("move_to_sweet_berry_bush") to MoveToSweetBerryBushTaskConfig::class.java,
cobblemonResource("stop_moving_to_sweet_berry_bush") to StopTryingToReachSweetBerryBushTaskConfig::class.java,
cobblemonResource("harvest_sweet_berry_bush") to HarvestSweetBerryBushTaskConfig::class.java,
@@ -9,8 +9,13 @@
package com.cobblemon.mod.common.api.cooking
import com.cobblemon.mod.common.api.riding.stats.RidingStat
import com.cobblemon.mod.common.util.math.geometry.toDegrees
import com.cobblemon.mod.common.util.math.geometry.toRadians
import net.minecraft.util.FastColor
import net.minecraft.world.item.ItemStack
import kotlin.math.atan2
import kotlin.math.cos
import kotlin.math.sin
private val colourMap = mapOf(
Flavour.SPICY to 0xFEB37D,
@@ -29,30 +34,27 @@ private val bubbleColourMap = mapOf(
)
fun getColourMixFromSeasonings(seasonings: List<ItemStack>, forBubbles: Boolean = false): Int? {
val flavourValues = mutableMapOf<Flavour, Int>()
for (seasoning in seasonings) {
val flavours = Seasonings.getFlavoursFromItemStack(seasoning) ?: continue
for ((flavour, value) in flavours.entries) {
flavourValues[flavour] = (flavourValues[flavour] ?: 0) + value
}
}
val flavors = seasonings
.mapNotNull { Seasonings.getFlavoursFromItemStack(it) }
.flatMap { it.entries }
.groupingBy { it.key }
.fold(0) { acc, entry -> acc + entry.value }
if (flavourValues.isEmpty()) {
return null
}
if (flavors.isEmpty()) return null
val maxFlavorValue = flavourValues.values.maxOrNull()
val dominantFlavours = flavourValues.filter { it.value == maxFlavorValue }.map { it.key }
val maxFlavorValue = flavors.values.maxOrNull()
val dominantFlavors = flavors.filter { it.value == maxFlavorValue }.map { it.key }
return getColourMixFromFlavours(dominantFlavours, forBubbles)
return getColourMixFromFlavours(dominantFlavors, forBubbles)
}
fun getColourMixFromFlavours(dominantFlavours: List<Flavour>, forBubbles: Boolean = false): Int? {
val colors =
dominantFlavours
.mapNotNull { if (forBubbles) bubbleColourMap[it] else colourMap[it] }
dominantFlavours.mapNotNull { if (forBubbles) bubbleColourMap[it] else colourMap[it] }
.map { FastColor.ARGB32.opaque(it) }
if (colors.isEmpty()) return null
return getColourMixFromColors(colors)
}
@@ -60,33 +62,104 @@ fun getColourMixFromRideStatBoosts(dominantBoosts: Iterable<RidingStat>, forBubb
return getColourMixFromFlavours(dominantBoosts.map { it.flavour }, forBubbles)
}
// Mixing RGB colors directly often gives poor results
// Converting them to HSL and averaging hues circularly produces more natural blends
fun getColourMixFromColors(colors: List<Int>): Int? {
if (colors.isEmpty()) return null
if (colors.size == 1) return colors[0]
val firstWeight = 0.7f
val otherWeightTotal = 1f - firstWeight
val otherWeight = otherWeightTotal / (colors.size - 1)
val hslColors = colors.map {
val red = FastColor.ARGB32.red(it)
val green = FastColor.ARGB32.green(it)
val blue = FastColor.ARGB32.blue(it)
var alphaSum = 0f
var redSum = 0f
var greenSum = 0f
var blueSum = 0f
for (i in colors.indices) {
val weight = if (i == 0) firstWeight else otherWeight
val color = colors[i]
alphaSum += FastColor.ARGB32.alpha(color) * weight
redSum += FastColor.ARGB32.red(color) * weight
greenSum += FastColor.ARGB32.green(color) * weight
blueSum += FastColor.ARGB32.blue(color) * weight
rgbToHsl(red, green, blue)
}
return FastColor.ARGB32.color(
alphaSum.toInt(),
redSum.toInt(),
greenSum.toInt(),
blueSum.toInt()
val hues = hslColors.map { it.h.toDouble() }
val huesAverage = hueAverage(hues).toFloat()
val saturations = hslColors.map { it.s }
val saturationsAverage = average(saturations)
val lightness = hslColors.map { it.l }
val lightnessAverage = average(lightness)
val rgbColor = hslToRgb(huesAverage, saturationsAverage, lightnessAverage)
return FastColor.ARGB32.color(rgbColor.r, rgbColor.g, rgbColor.b)
}
// Based on https://iter.ca/post/hue-avg
fun hueAverage(hues: List<Double>): Float {
val points = hues.map { hue ->
val rad = hue.toRadians()
Pair(cos(rad), sin(rad))
}
val avgX = points.sumOf { it.first.toDouble() } / points.size
val avgY = points.sumOf { it.second.toDouble() } / points.size
var degrees = atan2(avgY, avgX).toDegrees()
if (degrees < 0) {
degrees += 360f
} else if (degrees > 360) {
degrees -= 360f
}
return degrees
}
fun average(values: List<Float>): Float {
if (values.isEmpty()) return 0f
return values.sum() / values.size
}
data class HSL(val h: Float, val s: Float, val l: Float)
fun rgbToHsl(r: Int, g: Int, b: Int): HSL {
val rf = r / 255f
val gf = g / 255f
val bf = b / 255f
val max = maxOf(rf, gf, bf)
val min = minOf(rf, gf, bf)
val delta = max - min
var h = 0f
val l = (max + min) / 2f
val s = if (delta == 0f) 0f else delta / (1f - kotlin.math.abs(2f * l - 1f))
if (delta != 0f) {
h = when (max) {
rf -> ((gf - bf) / delta) % 6f
gf -> ((bf - rf) / delta) + 2f
else -> ((rf - gf) / delta) + 4f
}
h *= 60f
if (h < 0) h += 360f
}
return HSL(h, s, l)
}
data class RGB(val r: Int, val g: Int, val b: Int)
fun hslToRgb(h: Float, s: Float, l: Float): RGB {
val c = (1f - kotlin.math.abs(2f * l - 1f)) * s
val x = c * (1f - kotlin.math.abs((h / 60f) % 2f - 1f))
val m = l - c / 2f
val (rf, gf, bf) = when {
h < 60f -> Triple(c, x, 0f)
h < 120f -> Triple(x, c, 0f)
h < 180f -> Triple(0f, c, x)
h < 240f -> Triple(0f, x, c)
h < 300f -> Triple(x, 0f, c)
else -> Triple(c, 0f, x)
}
return RGB(
((rf + m) * 255).toInt().coerceIn(0, 255),
((gf + m) * 255).toInt().coerceIn(0, 255),
((bf + m) * 255).toInt().coerceIn(0, 255)
)
}
@@ -37,6 +37,8 @@ import net.minecraft.resources.ResourceLocation
import net.minecraft.util.FormattedCharSequence
import org.joml.Matrix4f
import org.joml.Vector3f
import org.lwjgl.opengl.GL30
import java.nio.ByteBuffer
@JvmOverloads
fun blitk(
@@ -355,10 +357,10 @@ fun renderSprite(matrixStack: PoseStack, sprite: ResourceLocation) {
val matrix: PoseStack.Pose = matrixStack.last()
matrix.pose().translate(-1f, 0f, 0f)
RenderSystem.setShaderTexture(0, sprite)
RenderSystem.setShaderTexture(0, sprite);
RenderSystem.setShader(GameRenderer::getPositionTexShader)
val buffer = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX)
var buffer = Tesselator.getInstance().begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.POSITION_TEX)
buffer.addVertex(matrix, 2f, 0f, 0.0f).setUv(1f, 0f)
buffer.addVertex(matrix, 0f, 0f, 0.0f).setUv(0f, 0f)
@@ -367,3 +369,25 @@ fun renderSprite(matrixStack: PoseStack, sprite: ResourceLocation) {
BufferUploader.drawWithShader(buffer.buildOrThrow())
}
fun getPixelRGB(x: Int, y: Int): Triple<Int, Int, Int> {
val window = Minecraft.getInstance().window
val scale = window.guiScale
val buffer = ByteBuffer.allocateDirect(4)
RenderSystem.readPixels(
(x * scale).toInt(),
(window.height - y * scale - scale).toInt(),
1,
1,
GL30.GL_RGBA,
GL30.GL_UNSIGNED_BYTE,
buffer
)
return Triple(
buffer[0].toInt() and 0xFF,
buffer[1].toInt() and 0xFF,
buffer[2].toInt() and 0xFF
)
}
@@ -409,7 +409,13 @@ open class PokemonProperties {
shiny?.let { pokemon.shiny = it }
gender?.let { pokemon.gender = it }
level?.let { pokemon.level = it }
friendship?.also { pokemon.setFriendship(it) }
friendship.also {
if (it != null) {
pokemon.setFriendship(it)
} else {
pokemon.setFriendship(pokemon.form.baseFriendship)
}
}
fullness?.let { pokemon.currentFullness = it }
pokeball?.let { PokeBalls.getPokeBall(it.asIdentifierDefaultingNamespace())?.let { pokeball -> pokemon.caughtBall = pokeball } }
nature?.let { Natures.getNature(it.asIdentifierDefaultingNamespace())?.let { nature -> pokemon.nature = nature } }
@@ -322,7 +322,7 @@ class JetBehaviour : RidingBehaviour<JetSettings, JetState> {
val pitchRot = handling * state.currMouseYForce.get()
// Roll
val rollRot = handling * state.currMouseXForce.get()
val rollRot = handling * 1.5 * state.currMouseXForce.get()
val mouseRotation = Vec3(0.0, pitchRot, rollRot)
@@ -114,10 +114,10 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
input: Vec3
) {
if (vehicle.level().isClientSide) {
handleSprinting(state, driver)
handleSprinting(state)
inAirCheck(state, vehicle)
tickStamina(settings, state, vehicle)
state.walking.set(state.rideVelocity.get().horizontalDistance() > 0.01 || driver.zza != 0.0f)
state.walking.set(state.rideVelocity.get().horizontalDistance() > 0.01)
}
}
@@ -139,24 +139,9 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
}
fun handleSprinting(
state: HorseState,
driver: Player
state: HorseState
) {
val sprintTimerTickLength = 7 // Emulate vanillas tick timer length
var hasDoubleTapped = false
// If you are not sprinting and you just pressed down and theres no
if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && !state.sprinting.get() && state.sprintTickTimer.get() == 0) {
state.sprintTickTimer.set(sprintTimerTickLength)
} else if (!state.forwardHeldLastTick.get() && Minecraft.getInstance().options.keyUp.isDown() && state.sprintTickTimer.get() != 0) { // If has double tapped
hasDoubleTapped = true
}else if(!state.sprinting.get() && state.sprintTickTimer.get() > 0) {
state.sprintTickTimer.set(state.sprintTickTimer.get() - 1)
} else {
state.sprintTickTimer.set(0)
}
val tryingToSprint = (Minecraft.getInstance().options.keySprint.isDown() && Minecraft.getInstance().options.keyUp.isDown()) || hasDoubleTapped
val tryingToSprint = Minecraft.getInstance().options.keySprint.isDown() && Minecraft.getInstance().options.keyUp.isDown()
if (state.stamina.get() <= 0.0f || !Minecraft.getInstance().options.keyUp.isDown()) {
// If stamina runs out or the player is not holding forward then stop sprinting
@@ -171,9 +156,6 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
// If you are trying to sprint and the toggle allows it then start sprinting and disable toggle
state.sprinting.set(true)
}
// Take not of whether forward was held last tick
state.forwardHeldLastTick.set(Minecraft.getInstance().options.keyUp.isDown())
}
fun tickStamina(
@@ -245,7 +227,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
// Normalize the current rotation diff
val rotDiff = Mth.wrapDegrees(driver.yRot - vehicle.yRot).coerceIn(-maxYawDiff,maxYawDiff)
val rotDiffNorm = rotDiff / maxYawDiff//(rotDiff / maxYawDiff).coerceIn(-0.2f, 0.2f)
val rotDiffNorm = rotDiff / maxYawDiff
// Take the square root so that the ride levels out quicker when at lower differences between entity
// y and driver y
@@ -258,7 +240,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
val walkSpeed = getWalkSpeed(vehicle)
val w = max(walkSpeed, vehicle.deltaMovement.horizontalDistance())
val invRelSpeed = (RidingBehaviour.scaleToRange(w, walkSpeed, topSpeed ) - 1.0f) * -1.0f
val turnRate = ((handling.toFloat() / 20.0f) * max(walkHandlingBoost * sqrt(abs(invRelSpeed)), 1.0)).toFloat()
val turnRate = ((handling.toFloat() / 20.0f) * max(walkHandlingBoost * invRelSpeed, 1.0)).toFloat()
// Ensure you only ever rotate as much difference as there is between the angles.
val turnSpeed = turnRate * rotDiffMod
@@ -291,24 +273,30 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
val rideTopSpeed = vehicle.runtime.resolveDouble(settings.speedExpr ?: globalHorse.speedExpr!!)
val walkSpeed = getWalkSpeed(vehicle)
val topSpeed = if(canSprint && state.sprinting.get()) rideTopSpeed else walkSpeed
val accelTime = if(state.sprinting.get()) (vehicle.runtime.resolveDouble(settings.accelerationExpr ?: globalHorse.accelerationExpr!!) * 20.0) else 0.5 * 20.0
val accel = topSpeed / accelTime
val accel = topSpeed / (vehicle.runtime.resolveDouble(settings.accelerationExpr ?: globalHorse.accelerationExpr!!) * 20.0)
var activeInput = false
/******************************************************
* Gather the previous velocity and check for horizontal
* collisions
*****************************************************/
val dmSpeed = vehicle.deltaMovement.length()
val rvSpeed = state.rideVelocity.get().length()
var newVelocity = state.rideVelocity.get() //.normalize().scale(vehicle.deltaMovement.horizontalDistance())
/******************************************************
* Gather the previous velocity and check for horizontal
* collisions
*****************************************************/
// if (dmSpeed > rvSpeed) {
// // align the velocity vector to be in local vehicle space
// newVelocity = vehicle.deltaMovement
// val yawAligned = Matrix3f().rotateY(-vehicle.yRot.toRadians())
// newVelocity = (newVelocity.toVector3f().mul(yawAligned)).toVec3d()
// }
if (vehicle.horizontalCollision) {
var horizontalVec = Vec3(newVelocity.x, 0.0, newVelocity.z)
horizontalVec = horizontalVec.normalize().scale(min(horizontalVec.length(), 0.3))
newVelocity = Vec3(horizontalVec.x, newVelocity.y, horizontalVec.z)
newVelocity = newVelocity.normalize().scale(vehicle.deltaMovement.length())
}
/******************************************************
@@ -384,7 +372,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
state.jumpTicks.set(state.jumpTicks.get() + 1)
}
// Zero out lateral velocity possibly picked up from a controller transition
//Zero out lateral velocity possibly picked up from a controller transition
newVelocity = Vec3(0.0, newVelocity.y, newVelocity.z)
@@ -473,7 +461,7 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
vehicle: PokemonEntity,
driver: Player
): Float {
return if (state.sprinting.get()) 1.15f else 1.0f
return 1.0f
}
override fun useAngVelSmoothing(
@@ -532,14 +520,6 @@ class HorseBehaviour : RidingBehaviour<HorseSettings, HorseState> {
return true
}
override fun maxUpStep(
settings: HorseSettings,
state: HorseState,
vehicle: PokemonEntity
): Float? {
return if (state.inAir.get()) 0.0f else 1.2f
}
override fun getRideSounds(
settings: HorseSettings,
state: HorseState,
@@ -638,8 +618,6 @@ class HorseState : RidingBehaviourState() {
var sprintToggleable = ridingState(false, Side.CLIENT)
var inAir = ridingState(false, Side.CLIENT)
var jumpTicks = ridingState(0, Side.CLIENT)
var sprintTickTimer = ridingState(0, Side.CLIENT)
var forwardHeldLastTick = ridingState(false, Side.CLIENT)
override fun encode(buffer: FriendlyByteBuf) {
super.encode(buffer)
@@ -648,8 +626,6 @@ class HorseState : RidingBehaviourState() {
buffer.writeBoolean(sprintToggleable.get())
buffer.writeBoolean(inAir.get())
buffer.writeInt(jumpTicks.get())
buffer.writeInt(sprintTickTimer.get())
buffer.writeBoolean(forwardHeldLastTick.get())
}
override fun decode(buffer: FriendlyByteBuf) {
@@ -659,8 +635,6 @@ class HorseState : RidingBehaviourState() {
sprintToggleable.set(buffer.readBoolean(), forced = true)
inAir.set(buffer.readBoolean(), forced = true)
jumpTicks.set(buffer.readInt(), forced = true)
sprintTickTimer.set(buffer.readInt(), forced = true)
forwardHeldLastTick.set(buffer.readBoolean(), forced = true)
}
override fun reset() {
@@ -670,8 +644,6 @@ class HorseState : RidingBehaviourState() {
sprintToggleable.set(false, forced = true)
inAir.set(false, forced = true)
jumpTicks.set(0, forced = true)
sprintTickTimer.set(0, forced = true)
forwardHeldLastTick.set(false, forced = true)
}
override fun copy() = HorseState().also {
@@ -682,8 +654,6 @@ class HorseState : RidingBehaviourState() {
it.sprintToggleable.set(this.sprintToggleable.get(), forced = true)
it.inAir.set(this.inAir.get(), forced = true)
it.jumpTicks.set(this.jumpTicks.get(), forced = true)
it.sprintTickTimer.set(this.sprintTickTimer.get(), forced = true)
it.forwardHeldLastTick.set(this.forwardHeldLastTick.get(), forced = true)
}
override fun shouldSync(previous: RidingBehaviourState): Boolean {
@@ -40,12 +40,9 @@ class PokemonSpawnAction(
override fun createEntity(): PokemonEntity {
val props = props.copy()
props.level = levelRange.random()
val sourcePlayer = spawnablePosition.cause.entity as? ServerPlayer
val entity = props.createEntity(spawnablePosition.world, sourcePlayer)
entity.spawnCause = spawnablePosition.cause
entity.pokemon.setFriendship(entity.pokemon.form.baseFriendship)
SeasonFeatureHandler.updateSeason(entity.pokemon, Cobblemon.seasonResolver(spawnablePosition.world, spawnablePosition.position))
val heldItem = heldItem
if (heldItem != ItemStack.EMPTY && heldItem != null) {
@@ -44,7 +44,11 @@ abstract class SpawnAction<R>(
spawnablePosition.applyInfluences { it.affectAction(this) }
val result = run()
future.complete(result)
if (result != null) {
future.complete(result)
} else {
future.completeExceptionally(Exception("Nothing was spawned."))
}
return result
}
@@ -61,9 +61,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
val baitEVStat = effects.firstOrNull { it.type == Effects.EV }?.subcategory?.path?.let { Stats.getStat(it) }
if (detailSpecies != null && baitEVStat != null) {
val detailAspects = detail.pokemon.aspects
val formData = detailSpecies.getForm(detailAspects)
val evYieldValue = formData.evYield[baitEVStat]?.toFloat() ?: 0f
val evYieldValue = detailSpecies.evYield[baitEVStat]?.toFloat() ?: 0f
return when {
evYieldValue > 0 -> {
markUsed()
@@ -85,9 +83,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
val baitTypingEffect = baitEffect?.subcategory?.path?.let { ElementalTypes.get(it) }
if (detailSpecies != null && baitTypingEffect != null) {
val detailAspects = detail.pokemon.aspects
val formData = detailSpecies.getForm(detailAspects)
val isMatchingType = formData.types.contains(baitTypingEffect)
val isMatchingType = detailSpecies.types.contains(baitTypingEffect)
return when {
isMatchingType -> {
markUsed()
@@ -104,9 +100,6 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
val detailSpecies = detail.pokemon.species?.let { PokemonSpecies.getByName(it) }
if (detailSpecies != null) {
val detailAspects = detail.pokemon.aspects
val formData = detailSpecies.getForm(detailAspects)
// Collect all the egg group effects
val eggGroupEffects = effects.filter { it.type == Effects.EGG_GROUP }
@@ -118,7 +111,7 @@ open class SpawnBaitInfluence(val effects: List<SpawnBait.Effect>, val onUsed: (
LOGGER.warn("Unknown egg group identifier: $effectEggGroupKey")
return@firstOrNull false
}
formData.eggGroups.contains(eggGroup)
detailSpecies.eggGroups.contains(eggGroup)
}
if (matchingEffect != null) {
@@ -88,6 +88,7 @@ abstract class OneToOneFileStoreAdapter<S>(
result
}
else {
storeClass.getConstructor(UUID::class.java).newInstance(uuid)
var result = storeClass.getConstructor(UUID::class.java).newInstance(uuid)
save(storeClass, uuid, serialize(result, registryAccess))
oldFile.delete()
@@ -37,11 +37,10 @@ object CobblemonItemTags {
@JvmField val BLACK_TUMBLESTONE_BRICKS = create("black_tumblestone_bricks")
@JvmField val BLACK_TUMBLESTONES = create("black_tumblestones")
@JvmField val BOATS = create("boats")
/** This tag is used for Fossil Machine natural materials */
@JvmField val COOKED_MEAT = create("cooked_meat")
@JvmField val DAWN_STONE_ORES = create("dawn_stone_ores")
@JvmField val POTTERY_SHERDS = create("decorated_pot_sherds")
@JvmField val DEEP_SEAS = create("deep_seas")
@JvmField val DISPLAY_CASE_ITEMS = create("display_case_items")
@JvmField val DUSK_STONE_ORES = create("dusk_stone_ores")
@JvmField val ETHERS = create("ethers")
@JvmField val EVOLUTION_ITEMS = create("evolution_items")
@@ -57,6 +56,7 @@ object CobblemonItemTags {
@JvmField val HANGING_SIGNS = create("hanging_signs")
@JvmField val HERBS = create("herbs")
@JvmField val ICE_STONE_ORES = create("ice_stone_ores")
@JvmField val ITEM_BLOCKS = create("item_blocks")
@JvmField val LEAF_STONE_ORES = create("leaf_stone_ores")
@JvmField val MACHINES = create("machines")
@JvmField val MINT_LEAF = create("mint_leaf")
@@ -66,15 +66,13 @@ object CobblemonItemTags {
@JvmField val MOON_STONE_ORES = create("moon_stone_ores")
@JvmField val MUTATED_BERRIES = create("mutated_berries")
@JvmField val PLANTS = create("plants")
@JvmField val PLAQUES = create("plaques")
@JvmField val POKE_BALLS = create("poke_balls")
@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] */
@JvmField val RAW_MEAT = create("raw_meat")
@JvmField val RED_TUMBLESTONE_BRICKS = create("red_tumblestone_bricks")
@JvmField val RED_TUMBLESTONES = create("red_tumblestones")
@JvmField val REMEDIES = create("remedies")
@@ -19,6 +19,7 @@ import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.BlockItem
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.BaseEntityBlock
@@ -110,6 +111,8 @@ class DisplayCaseBlock(settings: Properties) : BaseEntityBlock(settings) {
override fun getRenderShape(state: BlockState) = RenderShape.MODEL
override fun getShadeBrightness(state: BlockState, level: BlockGetter, pos: BlockPos): Float {return 0.75f}
override fun getAnalogOutputSignal(state: BlockState, world: Level, pos: BlockPos): Int {
val stack = (world.getBlockEntity(pos) as DisplayCaseBlockEntity).getStack()
@@ -19,6 +19,7 @@ import net.minecraft.server.level.ServerLevel
import net.minecraft.tags.FluidTags
import net.minecraft.util.Mth
import net.minecraft.util.RandomSource
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.*
import net.minecraft.world.level.block.Block
@@ -174,7 +175,7 @@ class HeartyGrainsBlock(settings: Properties) : CropBlock(settings), SimpleWater
UPDATE_CLIENTS
)
}
else if (stateAbove.hasProperty(HALF) && stateAbove.getValue(HALF) == DoubleBlockHalf.UPPER) {
else if (stateAbove.getValue(HALF) == DoubleBlockHalf.UPPER) {
world.setBlock(
abovePos,
stateAbove.setValue(AGE, newAge),
@@ -34,7 +34,6 @@ import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Explosion
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
@@ -56,10 +55,9 @@ import net.minecraft.world.phys.shapes.VoxelShape
import java.util.*
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.gameevent.GameEvent
import java.util.function.BiConsumer
@Suppress("OVERRIDE_DEPRECATION", "DEPRECATION")
class PastureBlock(settings: Properties): BaseEntityBlock(settings), SimpleWaterloggedBlock {
class PastureBlock(settings: Properties): BaseEntityBlock(settings), SimpleWaterloggedBlock, PreEmptsExplosion {
companion object {
val CODEC = simpleCodec(::PastureBlock)
@@ -215,19 +213,9 @@ class PastureBlock(settings: Properties): BaseEntityBlock(settings), SimpleWater
return super.playerWillDestroy(world, pos, state, player)
}
override fun onExplosionHit(
state: BlockState,
level: Level,
pos: BlockPos,
explosion: Explosion,
dropConsumer: BiConsumer<ItemStack?, BlockPos?>
) {
val interaction = explosion.blockInteraction
if (interaction == Explosion.BlockInteraction.DESTROY || interaction == Explosion.BlockInteraction.DESTROY_WITH_DECAY) {
val blockEntity = level.getBlockEntity(pos) as? PokemonPastureBlockEntity ?: return
blockEntity.onBroken()
}
super.onExplosionHit(state, level, pos, explosion, dropConsumer)
override fun whenExploded(world: Level, state: BlockState, pos: BlockPos) {
val blockEntity = world.getBlockEntity(pos) as? PokemonPastureBlockEntity ?: return
blockEntity.onBroken()
}
override fun <T : BlockEntity?> getTicker(world: Level, state: BlockState, type: BlockEntityType<T>): BlockEntityTicker<T>? {
@@ -0,0 +1,17 @@
/*
* 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.block
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.core.BlockPos
import net.minecraft.world.level.Level
interface PreEmptsExplosion {
fun whenExploded(world: Level, state: BlockState, pos: BlockPos)
}
@@ -10,7 +10,6 @@ package com.cobblemon.mod.common.block
import com.bedrockk.molang.runtime.value.DoubleValue
import com.cobblemon.mod.common.entity.MoLangScriptingEntity
import com.cobblemon.mod.common.util.isServerSide
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.core.dispenser.DispenseItemBehavior
@@ -264,39 +263,23 @@ class SaccharineLeafBlock(settings: Properties) : LeavesBlock(settings) {
val isGlassBottle = itemStack.`is`(Items.GLASS_BOTTLE)
val isHoneyBottle = itemStack.`is`(Items.HONEY_BOTTLE)
if (isGlassBottle && isAtMaxAge(state)) {
if (level.isClientSide) return ItemInteractionResult.SUCCESS
if (isGlassBottle && !isAtMinAge(state)) {
// Decrement stack if not in creative mode
itemStack.consume(1, player)
// Give player a honey bottle
if (stack.isEmpty) {
// Replace the consumed empty bottle with a honey bottle
player.setItemInHand(hand, ItemStack(Items.HONEY_BOTTLE));
} else {
player.addItem(Items.HONEY_BOTTLE.defaultInstance)
}
// Give player honey bottle for now
player.addItem(Items.HONEY_BOTTLE.defaultInstance)
level.playSound(null, pos, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS)
level.setBlock(pos, state.setValue(AGE, 0), UPDATE_CLIENTS)
level.setBlock(pos, state.setValue(AGE, 0), 2)
level.gameEvent(null, GameEvent.BLOCK_CHANGE, pos)
return ItemInteractionResult.SUCCESS
} else if (isHoneyBottle && !isAtMaxAge(state)) {
if (level.isClientSide) return ItemInteractionResult.SUCCESS
// Decrement stack if not in creative mode
if (!player.isCreative) {
itemStack.consume(1, player)
if (stack.isEmpty) {
// Replace the consumed honey bottle with an empty bottle
player.setItemInHand(hand, ItemStack(Items.GLASS_BOTTLE));
} else {
player.addItem(Items.GLASS_BOTTLE.defaultInstance)
}
}
itemStack.consume(1, player)
level.playSound(null, pos, SoundEvents.HONEY_BLOCK_PLACE, SoundSource.BLOCKS)
level.setBlock(pos, state.setValue(AGE, 2), UPDATE_CLIENTS)
level.setBlock(pos, state.setValue(AGE, 2), 2)
level.gameEvent(null, GameEvent.BLOCK_CHANGE, pos)
return ItemInteractionResult.SUCCESS
}
@@ -9,7 +9,6 @@
package com.cobblemon.mod.common.block.campfirepot
import com.cobblemon.mod.common.CobblemonMenuType
import com.cobblemon.mod.common.CobblemonRecipeBookTypes.COOKING_POT
import com.cobblemon.mod.common.CobblemonRecipeTypes
import com.cobblemon.mod.common.api.cooking.Seasonings
import com.cobblemon.mod.common.block.entity.CampfireBlockEntity
@@ -212,7 +211,7 @@ class CookingPotMenu : RecipeBookMenu<CraftingInput, CookingPotRecipeBase>, Cont
}
override fun getRecipeBookType(): RecipeBookType {
return COOKING_POT
return RecipeBookType.valueOf("COOKING_POT")
}
override fun shouldMoveToInventory(slotIndex: Int): Boolean {
@@ -0,0 +1,199 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
class DecorativeItemBlock(settings: Properties, val itemType: ItemType) : Block(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(WATERLOGGED, false))
}
@Suppress("unused")
enum class ItemType : StringRepresentable {
TEAPOT,
TEACUP,
MOSS,
KNOT,
POUCH,
GENERIC_7x6,
GENERIC_8x,
GENERIC_8x4;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
override fun codec(): MapCodec<DecorativeItemBlock> {
return CODEC
}
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
var blockState = defaultBlockState()
.setValue(WATERLOGGED, ctx.level.getFluidState(ctx.clickedPos).type == Fluids.WATER)
val worldView = ctx.level
val blockPos = ctx.clickedPos
ctx.nearestLookingDirections.forEach { direction ->
if (direction.axis.isHorizontal) {
blockState = blockState.setValue(FACING, direction.opposite) as BlockState
if (blockState.canSurvive(worldView, blockPos)) {
return blockState
}
}
}
return null
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING)
builder.add(WATERLOGGED)
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
return when (itemType) {
ItemType.TEAPOT -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> TEAPOT_SOUTH
Direction.WEST -> TEAPOT_WEST
Direction.EAST -> TEAPOT_EAST
else -> TEAPOT_NORTH
}
}
ItemType.KNOT -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> KNOT_SOUTH
Direction.WEST -> KNOT_WEST
Direction.EAST -> KNOT_EAST
else -> KNOT_NORTH
}
}
ItemType.TEACUP -> TEACUP
ItemType.MOSS -> MOSS
ItemType.POUCH -> POUCH
ItemType.GENERIC_7x6 -> ITEM_7x6
ItemType.GENERIC_8x4 -> ITEM_8x4
else -> ITEM_8x
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(HORIZONTAL_FACING, rotation.rotate(state.getValue(HORIZONTAL_FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
companion object {
val CODEC: MapCodec<DecorativeItemBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec(),
ItemType.CODEC.fieldOf("itemType").forGetter(DecorativeItemBlock::itemType)
).apply(it, ::DecorativeItemBlock) }
val ITEM_8x = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)
val ITEM_8x4 = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.25, 0.75)
val ITEM_7x6 = Shapes.box(0.28125, 0.0, 0.28125, 0.71875, 0.375, 0.71875)
val POUCH = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.3125, 0.6875)
private val TEACUP = Shapes.or(
Shapes.box(0.375, 0.0, 0.375, 0.625, 0.0625, 0.625),
Shapes.box(0.3125, 0.0, 0.3125, 0.625, 0.25, 0.375),
Shapes.box(0.375, 0.0, 0.625, 0.6875, 0.25, 0.6875),
Shapes.box(0.625, 0.0, 0.3125, 0.6875, 0.25, 0.625),
Shapes.box(0.3125, 0.0, 0.375, 0.375, 0.25, 0.6875)
)
private val MOSS = Shapes.or(
Shapes.box(0.25, 0.0, 0.25, 0.75, 0.25, 0.75),
Shapes.box(0.3125, 0.25, 0.3125, 0.6875, 0.4375, 0.6875)
)
val KNOT_NORTH = Shapes.box(0.375, 0.0, 0.375, 0.75, 0.375, 0.75)
val KNOT_WEST = Shapes.box(0.375, 0.0, 0.25, 0.75, 0.375, 0.625)
val KNOT_SOUTH = Shapes.box(0.25, 0.0, 0.25, 0.625, 0.375, 0.625)
val KNOT_EAST = Shapes.box(0.25, 0.0, 0.375, 0.625, 0.375, 0.75)
private val TEAPOT_NORTH = Shapes.or(
Shapes.box(0.3125, 0.5, 0.3125, 0.6875, 0.625, 0.6875),
Shapes.box(0.4375, 0.625, 0.4375, 0.5625, 0.6875, 0.5625),
Shapes.box(0.25, 0.0625, 0.25, 0.75, 0.5, 0.75),
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.0625, 0.6875),
Shapes.box(0.75, 0.125, 0.40625, 0.875, 0.375, 0.59375)
)
private val TEAPOT_EAST = Shapes.or(
Shapes.box(0.3125, 0.5, 0.3125, 0.6875, 0.625, 0.6875),
Shapes.box(0.4375, 0.625, 0.4375, 0.5625, 0.6875, 0.5625),
Shapes.box(0.25, 0.0625, 0.25, 0.75, 0.5, 0.75),
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.0625, 0.6875),
Shapes.box(0.40625, 0.125, 0.75, 0.59375, 0.375, 0.875)
)
private val TEAPOT_SOUTH = Shapes.or(
Shapes.box(0.3125, 0.5, 0.3125, 0.6875, 0.625, 0.6875),
Shapes.box(0.4375, 0.625, 0.4375, 0.5625, 0.6875, 0.5625),
Shapes.box(0.25, 0.0625, 0.25, 0.75, 0.5, 0.75),
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.0625, 0.6875),
Shapes.box(0.125, 0.125, 0.40625, 0.25, 0.375, 0.59375)
)
private val TEAPOT_WEST = Shapes.or(
Shapes.box(0.3125, 0.5, 0.3125, 0.6875, 0.625, 0.6875),
Shapes.box(0.4375, 0.625, 0.4375, 0.5625, 0.6875, 0.5625),
Shapes.box(0.25, 0.0625, 0.25, 0.75, 0.5, 0.75),
Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.0625, 0.6875),
Shapes.box(0.40625, 0.125, 0.125, 0.59375, 0.375, 0.25)
)
}
}
@@ -0,0 +1,301 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.server.level.ServerLevel
import net.minecraft.sounds.SoundEvent
import net.minecraft.sounds.SoundSource
import net.minecraft.util.RandomSource
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.AttachFace
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.BooleanProperty
import net.minecraft.world.level.gameevent.GameEvent
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class EjectButtonBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
private val ticksToStayPressed: Int
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(FACE, AttachFace.FLOOR)
.setValue(POWERED, false)
.setValue(WATERLOGGED, false))
this.ticksToStayPressed = 20
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(FACE)
builder.add(POWERED)
builder.add(WATERLOGGED)
}
override fun codec(): MapCodec<EjectButtonBlock> {
return CODEC
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
}
//May need some clean up, ended up just copying this straight from the original class so I could inject the waterlogging stuff to make it properly work, but it does look a bit ugly
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val var2 = context.nearestLookingDirections
val var3 = var2.size
val fluidState = context.level.getFluidState(context.clickedPos)
for (var4 in 0 until var3) {
val direction = var2[var4]
var blockState = if (direction.axis === Direction.Axis.Y) {
defaultBlockState().setValue(
FACE,
if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR
)
.setValue(FACING, context.horizontalDirection.opposite).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
} else {
(defaultBlockState().setValue(FACE, AttachFace.WALL) as BlockState).setValue(
FACING,
direction.opposite
).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
}
if (blockState.canSurvive(context.level, context.clickedPos)) {
return blockState
}
}
return null
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
val direction = state.getValue(FACING)
return when (state.getValue(FACE)) {
AttachFace.FLOOR -> return if (state.getValue(POWERED)) {FLOOR_POWERED} else {FLOOR_UNPOWERED}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> return if (state.getValue(POWERED)) {EAST_WALL_POWERED} else {EAST_WALL_UNPOWERED}
Direction.WEST -> return if (state.getValue(POWERED)) {WEST_WALL_POWERED} else {WEST_WALL_UNPOWERED}
Direction.SOUTH -> return if (state.getValue(POWERED)) {SOUTH_WALL_POWERED} else {SOUTH_WALL_UNPOWERED}
Direction.NORTH -> return if (state.getValue(POWERED)) {NORTH_WALL_POWERED} else {NORTH_WALL_UNPOWERED}
else -> {FLOOR_UNPOWERED}
}
}
AttachFace.CEILING -> return if (state.getValue(POWERED)) {CEILING_POWERED} else {CEILING_UNPOWERED}
}
}
override fun getCollisionShape(
state: BlockState,
level: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape {
val direction = state.getValue(FACING)
return when (state.getValue(FACE)) {
AttachFace.FLOOR -> {FLOOR_PANEL}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> {EAST_WALL_PANEL}
Direction.WEST -> {WEST_WALL_PANEL}
Direction.SOUTH -> {SOUTH_WALL_PANEL}
Direction.NORTH -> {NORTH_WALL_PANEL}
else -> {FLOOR_PANEL}
}
}
AttachFace.CEILING -> {CEILING_PANEL}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
//It does in fact override, and crashes if it isn't overriding. Don't trust this.
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState?, level: LevelReader?, pos: BlockPos): Boolean {
return when (state?.getValue(FACE)) {
AttachFace.CEILING -> {
level!!.getBlockState(pos.above()).isSolid
}
AttachFace.WALL -> {
level!!.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
AttachFace.FLOOR -> {
level!!.getBlockState(pos.below()).isSolid
}
else -> true
}
}
override fun useWithoutItem(
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hitResult: BlockHitResult
): InteractionResult {
if (state.getValue(POWERED) as Boolean) {
return InteractionResult.CONSUME
} else {
this.press(state, level, pos, player)
return InteractionResult.sidedSuccess(level.isClientSide)
}
}
fun press(state: BlockState, level: Level, pos: BlockPos, player: Player?) {
level.setBlock(pos, state.setValue(POWERED, true) as BlockState, 3)
this.updateNeighbours(state, level, pos)
level.scheduleTick(pos, this, this.ticksToStayPressed)
//this.playSound(player, level, pos, true)
level.gameEvent(player, GameEvent.BLOCK_ACTIVATE, pos)
}
private fun updateNeighbours(state: BlockState, level: Level, pos: BlockPos) {
level.updateNeighborsAt(pos, this)
level.updateNeighborsAt(pos.relative(getConnectedDirection(state).getOpposite()), this)
}
override fun onRemove(
state: BlockState,
level: Level,
pos: BlockPos,
newState: BlockState,
movedByPiston: Boolean
) {
if (!movedByPiston && !state.`is`(newState.getBlock())) {
if (state.getValue(POWERED) as Boolean) {
this.updateNeighbours(state, level, pos)
}
super.onRemove(state, level, pos, newState, movedByPiston)
}
}
override fun getSignal(state: BlockState, level: BlockGetter, pos: BlockPos, direction: Direction): Int {
return if (state.getValue(POWERED) as Boolean) 15 else 0
}
override fun getDirectSignal(state: BlockState, level: BlockGetter, pos: BlockPos, direction: Direction): Int {
return if (state.getValue(POWERED) as Boolean && getConnectedDirection(state) == direction) 15 else 0
}
override fun isSignalSource(state: BlockState): Boolean {
return true
}
override fun tick(state: BlockState, level: ServerLevel, pos: BlockPos, random: RandomSource) {
if (state.getValue(POWERED)) {
this.checkPressed(state, level, pos)
}
}
protected fun checkPressed(state: BlockState, level: Level, pos: BlockPos) {
val abstractArrow = null
val bl = false
val bl2 = state.getValue(POWERED) as Boolean
if (bl != bl2) {
level.setBlock(pos, state.setValue(POWERED, bl) as BlockState, 3)
this.updateNeighbours(state, level, pos)
//this.playSound(null as Player?, level, pos, bl)
level.gameEvent(abstractArrow, if (bl) GameEvent.BLOCK_ACTIVATE else GameEvent.BLOCK_DEACTIVATE, pos)
}
if (bl) {
level.scheduleTick(BlockPos(pos), this, this.ticksToStayPressed)
}
}
companion object {
val CODEC: MapCodec<EjectButtonBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec()
).apply(it, ::EjectButtonBlock) }
val POWERED = BooleanProperty.create("powered")
val FLOOR_UNPOWERED = Shapes.or(
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875),
Shapes.box(0.375, 0.1875, 0.375, 0.625, 0.3125, 0.625) )
val FLOOR_POWERED = Shapes.or(
Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875),
Shapes.box(0.375, 0.1875, 0.375, 0.625, 0.25, 0.625) )
val FLOOR_PANEL = Shapes.box(0.125, 0.0, 0.125, 0.875, 0.1875, 0.875)
val CEILING_UNPOWERED = Shapes.or(
Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875),
Shapes.box(0.375, 0.6875, 0.375, 0.625, 0.8125, 0.625) )
val CEILING_POWERED = Shapes.or(
Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875),
Shapes.box(0.375, 0.75, 0.375, 0.625, 0.8125, 0.625) )
val CEILING_PANEL = Shapes.box(0.125, 0.8125, 0.125, 0.875, 1.0, 0.875)
val EAST_WALL_UNPOWERED = Shapes.or(
Shapes.box(0.0, 0.125, 0.125, 0.1875, 0.875, 0.875),
Shapes.box(0.1875, 0.375, 0.375, 0.3125, 0.625, 0.625) )
val EAST_WALL_POWERED = Shapes.or(
Shapes.box(0.0, 0.125, 0.125, 0.1875, 0.875, 0.875),
Shapes.box(0.1875, 0.375, 0.375, 0.25, 0.625, 0.625) )
val EAST_WALL_PANEL = Shapes.box(0.0, 0.125, 0.125, 0.1875, 0.875, 0.875)
val WEST_WALL_UNPOWERED = Shapes.or(
Shapes.box(0.8125, 0.125, 0.125, 1.0, 0.875, 0.875),
Shapes.box(0.6875, 0.375, 0.375, 0.8125, 0.625, 0.625) )
val WEST_WALL_POWERED = Shapes.or(
Shapes.box(0.8125, 0.125, 0.125, 1.0, 0.875, 0.875),
Shapes.box(0.75, 0.375, 0.375, 0.8125, 0.625, 0.625) )
val WEST_WALL_PANEL = Shapes.box(0.8125, 0.125, 0.125, 1.0, 0.875, 0.875)
val NORTH_WALL_UNPOWERED = Shapes.or(
Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0),
Shapes.box(0.375, 0.375, 0.6875, 0.625, 0.625, 0.8125) )
val NORTH_WALL_POWERED = Shapes.or(
Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0),
Shapes.box(0.375, 0.375, 0.75, 0.625, 0.625, 0.8125) )
val NORTH_WALL_PANEL = Shapes.box(0.125, 0.125, 0.8125, 0.875, 0.875, 1.0)
val SOUTH_WALL_UNPOWERED = Shapes.or(
Shapes.box(0.125, 0.125, 0.0, 0.875, 0.875, 0.1875),
Shapes.box(0.375, 0.375, 0.1875, 0.625, 0.625, 0.3125) )
val SOUTH_WALL_POWERED = Shapes.or(
Shapes.box(0.125, 0.125, 0.0, 0.875, 0.875, 0.1875),
Shapes.box(0.375, 0.375, 0.1875, 0.625, 0.625, 0.25) )
val SOUTH_WALL_PANEL = Shapes.box(0.125, 0.125, 0.0, 0.875, 0.875, 0.1875)
}
}
@@ -0,0 +1,155 @@
/*
* 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.block.decor
import com.cobblemon.mod.common.CobblemonBlocks
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.AttachFace
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class GalaricaWreathBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(FACE, AttachFace.WALL)
.setValue(WATERLOGGED, false))
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(FACE)
builder.add(WATERLOGGED)
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
//May need some clean up, ended up just copying this straight from the original class so I could inject the waterlogging stuff to make it properly work, but it does look a bit ugly
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val var2 = context.nearestLookingDirections
val var3 = var2.size
val fluidState = context.level.getFluidState(context.clickedPos)
for (var4 in 0 until var3) {
val direction = var2[var4]
var blockState = if (direction.axis === Direction.Axis.Y) {
defaultBlockState().setValue(
FACE,
if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR
)
.setValue(FACING, context.horizontalDirection.opposite).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
} else {
(defaultBlockState().setValue(FACE, AttachFace.WALL) as BlockState).setValue(
FACING,
direction.opposite
).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
}
if (blockState.canSurvive(context.level, context.clickedPos)) {
return blockState
}
}
return null
}
override fun codec(): MapCodec<GalaricaWreathBlock> {
return CODEC
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
val direction = state.getValue(FACING)
return when (state.getValue(FACE)) {
AttachFace.FLOOR -> {
FLOOR
}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> EAST_WALL
Direction.WEST -> WEST_WALL
Direction.SOUTH -> SOUTH_WALL
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_WALL
}
}
AttachFace.CEILING -> return if (direction.axis === Direction.Axis.X) {
HANGING_NS
} else {
HANGING_EW
}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
//It does in fact override, and crashes if it isn't overriding. Don't trust this.
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState?, level: LevelReader?, pos: BlockPos): Boolean {
when (state?.getValue(FACE)) {
AttachFace.CEILING -> {
val direction = getConnectedDirection(state!!).opposite
return canSupportCenter(level!!, pos.relative(direction), direction.opposite)
}
AttachFace.WALL -> {
return level!!.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
else -> return true
}
}
companion object {
val CODEC: MapCodec<GalaricaWreathBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec()
).apply(it, ::GalaricaWreathBlock) }
val FLOOR = Shapes.box(0.171875, 0.0, 0.171875, 0.828125, 0.203125, 0.828125)
val EAST_WALL = Shapes.box(0.0, 0.171875, 0.171875, 0.203125, 0.828125, 0.828125)
val WEST_WALL = Shapes.box(0.796875, 0.171875, 0.171875, 1.0, 0.828125, 0.828125)
val NORTH_WALL = Shapes.box(0.171875, 0.171875, 0.796875, 0.828125, 0.828125, 1.0)
val SOUTH_WALL = Shapes.box(0.171875, 0.171875, 0.0, 0.828125, 0.828125, 0.203125)
val HANGING_EW = Shapes.box(0.171875, 0.171875, 0.390625, 0.828125, 0.828125, 0.609375)
val HANGING_NS = Shapes.box(0.390625, 0.171875, 0.171875, 0.609375, 0.828125, 0.828125)
}
}
@@ -0,0 +1,165 @@
/*
* 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.block.decor
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.server.level.ServerLevel
import net.minecraft.sounds.SoundEvents
import net.minecraft.sounds.SoundSource
import net.minecraft.world.InteractionResult
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.Level
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.BooleanProperty
import net.minecraft.world.level.gameevent.GameEvent
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
class MetronomeBlock(settings: Properties) : Block(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(ACTIVE, false)
.setValue(WATERLOGGED, false)
)
}
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
var blockState = defaultBlockState().setValue(ACTIVE, false)
.setValue(WATERLOGGED, ctx.level.getFluidState(ctx.clickedPos).type == Fluids.WATER)
val worldView = ctx.level
val blockPos = ctx.clickedPos
ctx.nearestLookingDirections.forEach { direction ->
if (direction.axis.isHorizontal) {
blockState = blockState.setValue(FACING, direction.opposite) as BlockState
if (blockState.canSurvive(worldView, blockPos)) {
return blockState
}
}
}
return null
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING)
builder.add(ACTIVE)
builder.add(WATERLOGGED)
}
override fun getShape(
state: BlockState,
world: BlockGetter,
pos: BlockPos,
context: CollisionContext
): VoxelShape {
return when (state.getValue(HorizontalDirectionalBlock.FACING)) {
Direction.NORTH -> NORTH_OUTLINE
Direction.EAST -> EAST_OUTLINE
Direction.WEST -> WEST_OUTLINE
else -> SOUTH_OUTLINE
}
}
override fun useWithoutItem(
state: BlockState,
level: Level,
pos: BlockPos,
player: Player,
hitResult: BlockHitResult
): InteractionResult {
if (level.isClientSide) {
level.setBlockAndUpdate(pos, state.cycle(ACTIVE))
return InteractionResult.SUCCESS
} else {
this.push(state, level, pos, null as Player?)
return InteractionResult.CONSUME
}
}
fun push(state: BlockState, level: Level, pos: BlockPos?, player: Player?) {
var state = state
state = state.cycle(ACTIVE)
level.setBlock(pos!!, state, 3)
level.gameEvent(player, if (state.getValue(ACTIVE)) GameEvent.BLOCK_ACTIVATE else GameEvent.BLOCK_DEACTIVATE, pos)
}
override fun hasAnalogOutputSignal(state: BlockState): Boolean {
return true
}
override fun getAnalogOutputSignal(state: BlockState, level: Level, pos: BlockPos): Int {
return if (level.getBlockState(pos).getValue(ACTIVE) as Boolean) 4 else 0
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(HORIZONTAL_FACING, rotation.rotate(state.getValue(HORIZONTAL_FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
companion object {
val CODEC = simpleCodec(::MetronomeBlock)
val ACTIVE = BooleanProperty.create("active")
val NORTH_OUTLINE = Shapes.or(
Shapes.box(0.25, 0.0, 0.375, 0.75, 0.25, 0.5),
Shapes.box(0.25, 0.0, 0.5, 0.75, 0.8125, 0.75)
)
val SOUTH_OUTLINE = Shapes.or(
Shapes.box(0.25, 0.0, 0.5, 0.75, 0.25, 0.625),
Shapes.box(0.25, 0.0, 0.25, 0.75, 0.8125, 0.5)
)
val EAST_OUTLINE = Shapes.or(
Shapes.box(0.5, 0.0, 0.25, 0.625, 0.25, 0.75),
Shapes.box(0.25, 0.0, 0.25, 0.5, 0.8125, 0.75)
)
val WEST_OUTLINE = Shapes.or(
Shapes.box(0.375, 0.0, 0.25, 0.5, 0.25, 0.75),
Shapes.box(0.5, 0.0, 0.25, 0.75, 0.8125, 0.75)
)
}
}
@@ -0,0 +1,168 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.AttachFace
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class PlaqueBlock(properties : Properties) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(FACE, AttachFace.WALL)
.setValue(WATERLOGGED, false))
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(FACE)
builder.add(WATERLOGGED)
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
//May need some clean up, ended up just copying this straight from the original class so I could inject the waterlogging stuff to make it properly work, but it does look a bit ugly
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val var2 = context.nearestLookingDirections
val var3 = var2.size
val fluidState = context.level.getFluidState(context.clickedPos)
for (var4 in 0 until var3) {
val direction = var2[var4]
var blockState = if (direction.axis === Direction.Axis.Y) {
defaultBlockState().setValue(
FACE,
if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR
)
.setValue(FACING, context.horizontalDirection.opposite).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
} else {
(defaultBlockState().setValue(FACE, AttachFace.WALL) as BlockState).setValue(
FACING,
direction.opposite
).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
}
if (blockState.canSurvive(context.level, context.clickedPos)) {
return blockState
}
}
return null
}
override fun codec(): MapCodec<PlaqueBlock> {
return CODEC
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
val direction = state.getValue(FACING)
return when (state.getValue(FACE)) {
AttachFace.FLOOR -> return if (direction.axis === Direction.Axis.X) {
FLOOR_NS
} else {
FLOOR_EW
}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> EAST_WALL
Direction.WEST -> WEST_WALL
Direction.SOUTH -> SOUTH_WALL
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_WALL
}
}
AttachFace.CEILING -> return if (direction.axis === Direction.Axis.X) {
HANGING_NS
} else {
HANGING_EW
}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
//It does in fact override, and crashes if it isn't overriding. Don't trust this.
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState?, level: LevelReader?, pos: BlockPos): Boolean {
when (state?.getValue(FACE)) {
AttachFace.CEILING -> {
val direction = getConnectedDirection(state!!).opposite
return canSupportCenter(level!!, pos.relative(direction), direction.opposite)
}
AttachFace.WALL -> {
return level!!.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
AttachFace.FLOOR -> {
return level!!.getBlockState(pos.below()).isSolid
}
else -> return true
}
}
companion object {
val CODEC: MapCodec<PlaqueBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec()
).apply(it, ::PlaqueBlock) }
val FLOOR_EW = Shapes.or(
Shapes.box(0.125, 0.0, 0.46875, 0.3125, 0.125, 0.53125),
Shapes.box(0.6875, 0.0, 0.46875, 0.875, 0.125, 0.53125),
Shapes.box(0.0625, 0.125, 0.4375, 0.9375, 0.875, 0.5625)
)
val FLOOR_NS = Shapes.or(
Shapes.box(0.46875, 0.0, 0.125, 0.53125, 0.125, 0.3125),
Shapes.box(0.46875, 0.0, 0.6875, 0.53125, 0.125, 0.875),
Shapes.box(0.4375, 0.125, 0.0625, 0.5625, 0.875, 0.9375)
)
val EAST_WALL = Shapes.box(0.0, 0.125, 0.0625, 0.0625, 0.875, 0.9375)
val WEST_WALL = Shapes.box(0.9375, 0.125, 0.0625, 1.0, 0.875, 0.9375)
val NORTH_WALL = Shapes.box(0.0625, 0.125, 0.9375, 0.9375, 0.875, 1.0)
val SOUTH_WALL = Shapes.box(0.0625, 0.125, 0.0, 0.9375, 0.875, 0.0625)
val HANGING_NS = Shapes.box(0.4375, 0.0, 0.0625, 0.5625, 0.75, 0.9375)
val HANGING_EW = Shapes.box(0.0625, 0.0, 0.4375, 0.9375, 0.75, 0.5625)
}
}
@@ -0,0 +1,247 @@
/*
* 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.block.decor
import com.cobblemon.mod.common.CobblemonBlocks
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.AttachFace
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class SixFaceDecorativeItemBlock(properties : Properties, val sixFaceItemType: SixFaceItemType) : FaceAttachedHorizontalDirectionalBlock(properties), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(FACE, AttachFace.FLOOR)
.setValue(WATERLOGGED, false))
}
@Suppress("unused")
enum class SixFaceItemType : StringRepresentable {
MAGNET,
GENERIC_8x;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(FACE)
builder.add(WATERLOGGED)
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
//May need some clean up, ended up just copying this straight from the original class so I could inject the waterlogging stuff to make it properly work, but it does look a bit ugly
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val var2 = context.nearestLookingDirections
val var3 = var2.size
val fluidState = context.level.getFluidState(context.clickedPos)
for (var4 in 0 until var3) {
val direction = var2[var4]
var blockState = if (direction.axis === Direction.Axis.Y) {
defaultBlockState().setValue(
FACE,
if (direction == Direction.UP) AttachFace.CEILING else AttachFace.FLOOR
)
.setValue(FACING, context.horizontalDirection.opposite).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
} else {
(defaultBlockState().setValue(FACE, AttachFace.WALL) as BlockState).setValue(
FACING,
direction.opposite
).setValue(WATERLOGGED, fluidState.type === Fluids.WATER)
}
if (blockState.canSurvive(context.level, context.clickedPos)) {
return blockState
}
}
return null
}
override fun codec(): MapCodec<SixFaceDecorativeItemBlock> {
return CODEC
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
val direction = state.getValue(FACING)
return when (sixFaceItemType) {
SixFaceItemType.MAGNET -> {
when (state.getValue(FACE)) {
AttachFace.FLOOR -> {
when (direction) {
Direction.EAST -> EAST_FLOOR_MAGNET
Direction.WEST -> WEST_FLOOR_MAGNET
Direction.SOUTH -> SOUTH_FLOOR_MAGNET
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_FLOOR_MAGNET
}
}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> EAST_WALL_MAGNET
Direction.WEST -> WEST_WALL_MAGNET
Direction.SOUTH -> SOUTH_WALL_MAGNET
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_WALL_MAGNET
}
}
AttachFace.CEILING -> {
when (direction) {
Direction.EAST -> EAST_CEILING_MAGNET
Direction.WEST -> WEST_CEILING_MAGNET
Direction.SOUTH -> SOUTH_CEILING_MAGNET
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_CEILING_MAGNET
}
}
}
}
else -> {
when (state.getValue(FACE)) {
AttachFace.FLOOR -> {
FLOOR_8x
}
AttachFace.WALL -> {
when (direction) {
Direction.EAST -> EAST_WALL_8x
Direction.WEST -> WEST_WALL_8x
Direction.SOUTH -> SOUTH_WALL_8x
Direction.NORTH, Direction.UP, Direction.DOWN -> NORTH_WALL_8x
}
}
AttachFace.CEILING -> CEILING_8x
}
}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (getConnectedDirection(state).opposite == direction && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState?, level: LevelReader?, pos: BlockPos): Boolean {
return true
}
companion object {
val CODEC: MapCodec<SixFaceDecorativeItemBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec(),
SixFaceItemType.CODEC.fieldOf("sixFaceItemType").forGetter(SixFaceDecorativeItemBlock::sixFaceItemType)
).apply(it, ::SixFaceDecorativeItemBlock) }
val FLOOR_8x = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)
val EAST_WALL_8x = Shapes.box(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)
val WEST_WALL_8x = Shapes.box(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)
val NORTH_WALL_8x = Shapes.box(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)
val SOUTH_WALL_8x = Shapes.box(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)
val CEILING_8x = Shapes.box(0.25, 0.5, 0.25, 0.75, 1.0, 0.75)
val NORTH_FLOOR_MAGNET = Shapes.or(
Shapes.box(0.25, 0.0, 0.25, 0.4375, 0.1875, 0.5625),
Shapes.box(0.5625, 0.0, 0.25, 0.75, 0.1875, 0.5625),
Shapes.box(0.25, 0.0, 0.5625, 0.75, 0.1875, 0.75)
)
val EAST_FLOOR_MAGNET = Shapes.or(
Shapes.box(0.4375, 0.0, 0.25, 0.75, 0.1875, 0.4375),
Shapes.box(0.4375, 0.0, 0.5625, 0.75, 0.1875, 0.75),
Shapes.box(0.25, 0.0, 0.25, 0.4375, 0.1875, 0.75)
)
val SOUTH_FLOOR_MAGNET = Shapes.or(
Shapes.box(0.5625, 0.0, 0.4375, 0.75, 0.1875, 0.75),
Shapes.box(0.25, 0.0, 0.4375, 0.4375, 0.1875, 0.75),
Shapes.box(0.25, 0.0, 0.25, 0.75, 0.1875, 0.4375)
)
val WEST_FLOOR_MAGNET = Shapes.or(
Shapes.box(0.25, 0.0, 0.5625, 0.5625, 0.1875, 0.75),
Shapes.box(0.25, 0.0, 0.25, 0.5625, 0.1875, 0.4375),
Shapes.box(0.5625, 0.0, 0.25, 0.75, 0.1875, 0.75)
)
val NORTH_WALL_MAGNET = Shapes.or(
Shapes.box(0.25, 0.25, 0.8125, 0.4375, 0.5625, 1.0),
Shapes.box(0.5625, 0.25, 0.8125, 0.75, 0.5625, 1.0),
Shapes.box(0.25, 0.5625, 0.8125, 0.75, 0.75, 1.0)
)
val EAST_WALL_MAGNET = Shapes.or(
Shapes.box(0.0, 0.25, 0.25, 0.1875, 0.5625, 0.4375),
Shapes.box(0.0, 0.25, 0.5625, 0.1875, 0.5625, 0.75),
Shapes.box(0.0, 0.5625, 0.25, 0.1875, 0.75, 0.75)
)
val SOUTH_WALL_MAGNET = Shapes.or(
Shapes.box(0.5625, 0.25, 0.0, 0.75, 0.5625, 0.1875),
Shapes.box(0.25, 0.25, 0.0, 0.4375, 0.5625, 0.1875),
Shapes.box(0.25, 0.5625, 0.0, 0.75, 0.75, 0.1875)
)
val WEST_WALL_MAGNET = Shapes.or(
Shapes.box(0.8125, 0.25, 0.5625, 1.0, 0.5625, 0.75),
Shapes.box(0.8125, 0.25, 0.25, 1.0, 0.5625, 0.4375),
Shapes.box(0.8125, 0.5625, 0.25, 1.0, 0.75, 0.75)
)
val NORTH_CEILING_MAGNET = Shapes.or(
Shapes.box(0.25, 0.8125, 0.25, 0.4375, 1.0, 0.5625),
Shapes.box(0.5625, 0.8125, 0.25, 0.75, 1.0, 0.5625),
Shapes.box(0.25, 0.8125, 0.5625, 0.75, 1.0, 0.75)
)
val EAST_CEILING_MAGNET = Shapes.or(
Shapes.box(0.4375, 0.8125, 0.25, 0.75, 1.0, 0.4375),
Shapes.box(0.4375, 0.8125, 0.5625, 0.75, 1.0, 0.75),
Shapes.box(0.25, 0.8125, 0.25, 0.4375, 1.1875, 0.75)
)
val SOUTH_CEILING_MAGNET = Shapes.or(
Shapes.box(0.5625, 0.8125, 0.4375, 0.75, 1.0, 0.75),
Shapes.box(0.25, 0.8125, 0.4375, 0.4375, 1.0, 0.75),
Shapes.box(0.25, 0.8125, 0.25, 0.75, 1.0, 0.4375)
)
val WEST_CEILING_MAGNET = Shapes.or(
Shapes.box(0.25, 0.8125, 0.5625, 0.5625, 1.0, 0.75),
Shapes.box(0.25, 0.8125, 0.25, 0.5625, 1.0, 0.4375),
Shapes.box(0.5625, 0.8125, 0.25, 0.75, 1.0, 0.75)
)
}
}
@@ -0,0 +1,708 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.IntegerProperty
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
import kotlin.math.min
class StackableItemBlock(settings: Properties, val stackableItemType: StackableItemType) : Block(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(HORIZONTAL_FACING, Direction.NORTH)
.setValue(ITEMS, 1)
.setValue(WATERLOGGED, false))
}
@Suppress("unused")
enum class StackableItemType : StringRepresentable {
UPGRADE,
METAL_COAT,
POTION,
MAX_POTION,
RESTORE,
ETHER,
BATTLE_X,
VITAMIN,
GENERIC_8x;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
override fun codec(): MapCodec<StackableItemBlock> {
return CODEC
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
val blockState = context.level.getBlockState(context.clickedPos)
return if (blockState.`is`(this)) blockState.setValue(
ITEMS,
min(MAX_ITEMS, (blockState.getValue(ITEMS) + 1))
) else defaultBlockState().setValue(FACING, context.horizontalDirection.opposite).setValue(WATERLOGGED, context.level.getFluidState(context.clickedPos).type == Fluids.WATER)
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(HORIZONTAL_FACING)
builder.add(ITEMS)
builder.add(WATERLOGGED)
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
return when (stackableItemType) {
StackableItemType.UPGRADE -> {
when (state.getValue(ITEMS)) {
2 -> UPGRADE_DOUBLE
3 -> UPGRADE_TRIPLE
4 -> UPGRADE_QUARTET
else -> UPGRADE_SINGLE
}
}
StackableItemType.METAL_COAT -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> METAL_DOUBLE_EW
else -> METAL_DOUBLE_NS
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> METAL_TRIPLE_S
Direction.WEST -> METAL_TRIPLE_W
Direction.EAST -> METAL_TRIPLE_E
else -> METAL_TRIPLE_N
}
4 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> METAL_QUARTET_EW
else -> METAL_QUARTET_NS
}
else -> METAL_SINGLE
}
}
StackableItemType.POTION -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> POTION_DOUBLE_EW
else -> POTION_DOUBLE_NS
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> POTION_TRIPLE_SOUTH
Direction.WEST -> POTION_TRIPLE_WEST
Direction.EAST -> POTION_TRIPLE_EAST
else -> POTION_TRIPLE_NORTH
}
4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> POTION_QUARTET_SOUTH
Direction.WEST -> POTION_QUARTET_WEST
Direction.EAST -> POTION_QUARTET_EAST
else -> POTION_QUARTET_NORTH
}
else -> POTION_SINGLE
}
}
StackableItemType.MAX_POTION -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.SOUTH -> MAX_POTION_DOUBLE_SOUTH
Direction.WEST -> MAX_POTION_DOUBLE_WEST
Direction.EAST -> MAX_POTION_DOUBLE_EAST
else -> MAX_POTION_DOUBLE_NORTH
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> MAX_POTION_TRIPLE_SOUTH
Direction.WEST -> MAX_POTION_TRIPLE_WEST
Direction.EAST -> MAX_POTION_TRIPLE_EAST
else -> MAX_POTION_TRIPLE_NORTH
}
4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> MAX_POTION_QUARTET_SOUTH
Direction.WEST -> MAX_POTION_QUARTET_WEST
Direction.EAST -> MAX_POTION_QUARTET_EAST
else -> MAX_POTION_QUARTET_NORTH
}
else -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> MAX_POTION_SINGLE_EW
else -> MAX_POTION_SINGLE_NS
}
}
}
StackableItemType.RESTORE -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> RESTORE_DOUBLE_EW
else -> RESTORE_DOUBLE_NS
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> RESTORE_TRIPLE_SOUTH
Direction.WEST -> RESTORE_TRIPLE_WEST
Direction.EAST -> RESTORE_TRIPLE_EAST
else -> RESTORE_TRIPLE_NORTH
}
4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> RESTORE_QUARTET_SOUTH
Direction.WEST -> RESTORE_QUARTET_WEST
Direction.EAST -> RESTORE_QUARTET_EAST
else -> RESTORE_QUARTET_NORTH
}
else -> RESTORE_SINGLE
}
}
StackableItemType.ETHER -> {
when (state.getValue(ITEMS)) {
1 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> ETHER_SINGLE_EW
else -> ETHER_SINGLE_NS
}
2 -> when (state.getValue(FACING)) {
Direction.SOUTH -> ETHER_DOUBLE_SOUTH
Direction.WEST -> ETHER_DOUBLE_WEST
Direction.EAST -> ETHER_DOUBLE_EAST
else -> ETHER_DOUBLE_NORTH
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> ETHER_TRIPLE_SOUTH
Direction.WEST -> ETHER_TRIPLE_WEST
Direction.EAST -> ETHER_TRIPLE_EAST
else -> ETHER_TRIPLE_NORTH
}
4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> ETHER_QUARTET_SOUTH
Direction.WEST -> ETHER_QUARTET_WEST
Direction.EAST -> ETHER_QUARTET_EAST
else -> ETHER_QUARTET_NORTH
}
else -> ETHER_SINGLE_NS
}
}
StackableItemType.BATTLE_X -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> BATTLE_DOUBLE_EW
else -> BATTLE_DOUBLE_NS
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> BATTLE_TRIPLE_S
Direction.WEST -> BATTLE_TRIPLE_W
Direction.EAST -> BATTLE_TRIPLE_E
else -> BATTLE_TRIPLE_N
}
4 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> BATTLE_QUARTET_EW
else -> BATTLE_QUARTET_NS
}
else -> BATTLE_SINGLE
}
}
StackableItemType.VITAMIN -> {
when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.WEST, Direction.EAST -> VITAMIN_DOUBLE_EW
else -> VITAMIN_DOUBLE_NS
}
3 -> when (state.getValue(FACING)) {
Direction.SOUTH -> VITAMIN_TRIPLE_SOUTH
Direction.WEST -> VITAMIN_TRIPLE_WEST
Direction.EAST -> VITAMIN_TRIPLE_EAST
else -> VITAMIN_TRIPLE_NORTH
}
4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> VITAMIN_QUARTET_SOUTH
Direction.WEST -> VITAMIN_QUARTET_WEST
Direction.EAST -> VITAMIN_QUARTET_EAST
else -> VITAMIN_QUARTET_NORTH
}
else -> VITAMIN_SINGLE
}
}
else -> ITEM_8x
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
public override fun canBeReplaced(state: BlockState, useContext: BlockPlaceContext): Boolean {
return if (!useContext.isSecondaryUseActive && useContext.itemInHand.`is`(this.asItem()) && state.getValue(
ITEMS
) <= MAX_ITEMS
) true else super.canBeReplaced(state, useContext)
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(HORIZONTAL_FACING, rotation.rotate(state.getValue(HORIZONTAL_FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
companion object {
val CODEC: MapCodec<StackableItemBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec(),
StackableItemType.CODEC.fieldOf("stackableItemType").forGetter(StackableItemBlock::stackableItemType)
).apply(it, ::StackableItemBlock) }
val ITEMS = IntegerProperty.create("items", 1, 4)
const val MAX_ITEMS: Int = 4
//Non-Specific Hitbox Shapes
val ITEM_8x = Shapes.box(0.25, 0.0, 0.25, 0.75, 0.5, 0.75)
val ITEM_16xS = Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 1.0)
val ITEM_8x16 = Shapes.box(0.25, 0.0, 0.0, 0.75, 0.5, 1.0)
val ITEM_16x8 = Shapes.box(0.0, 0.0, 0.25, 1.0, 0.5, 0.75)
private val TRIANGLE_NORTH = Shapes.or(
Shapes.box(0.0, 0.0, 0.5, 1.0, 0.5, 1.0),
Shapes.box(0.25, 0.0, 0.0, 0.75, 0.5, 0.5)
)
private val TRIANGLE_EAST = Shapes.or(
Shapes.box(0.0, 0.0, 0.0, 0.5, 0.5, 1.0),
Shapes.box(0.5, 0.0, 0.25, 1.0, 0.5, 0.75)
)
private val TRIANGLE_SOUTH = Shapes.or(
Shapes.box(0.0, 0.0, 0.0, 1.0, 0.5, 0.5),
Shapes.box(0.25, 0.0, 0.5, 0.75, 0.5, 1.0)
)
private val TRIANGLE_WEST = Shapes.or(
Shapes.box(0.5, 0.0, 0.0, 1.0, 0.5, 1.0),
Shapes.box(0.0, 0.0, 0.25, 0.5, 0.5, 0.75)
)
//Specific Hitbox Shapes
val UPGRADE_SINGLE = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.125, 0.6875)
val UPGRADE_DOUBLE = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.25, 0.6875)
val UPGRADE_TRIPLE = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875)
val UPGRADE_QUARTET = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.5, 0.6875)
val METAL_SINGLE = Shapes.box(0.3125, 0.0, 0.3125, 0.6875, 0.375, 0.6875)
val METAL_DOUBLE_NS = Shapes.or(
Shapes.box(0.5, 0.0, 0.125, 0.875, 0.375, 0.5),
Shapes.box(0.125, 0.0, 0.5, 0.5, 0.375, 0.875)
)
val METAL_DOUBLE_EW = Shapes.or(
Shapes.box(0.5, 0.0, 0.5, 0.875, 0.375, 0.875),
Shapes.box(0.125, 0.0, 0.125, 0.5, 0.375, 0.5)
)
val METAL_TRIPLE_N = Shapes.or(
Shapes.box(0.3125, 0.0, 0.0625, 0.6875, 0.375, 0.4375),
Shapes.box(0.5625, 0.0, 0.5, 0.9375, 0.375, 0.875),
Shapes.box(0.125, 0.0, 0.5, 0.5, 0.375, 0.875)
)
val METAL_TRIPLE_E = Shapes.or(
Shapes.box(0.5625, 0.0, 0.3125, 0.9375, 0.375, 0.6875),
Shapes.box(0.125, 0.0, 0.5625, 0.5, 0.375, 0.9375),
Shapes.box(0.125, 0.0, 0.125, 0.5, 0.375, 0.5)
)
val METAL_TRIPLE_S = Shapes.or(
Shapes.box(0.3125, 0.0, 0.5625, 0.6875, 0.375, 0.9375),
Shapes.box(0.0625, 0.0, 0.125, 0.4375, 0.375, 0.5),
Shapes.box(0.5, 0.0, 0.125, 0.875, 0.375, 0.5)
)
val METAL_TRIPLE_W = Shapes.or(
Shapes.box(0.0625, 0.0, 0.3125, 0.4375, 0.375, 0.6875),
Shapes.box(0.5, 0.0, 0.0625, 0.875, 0.375, 0.4375),
Shapes.box(0.5, 0.0, 0.5, 0.875, 0.375, 0.875)
)
val METAL_QUARTET_NS = Shapes.or(
Shapes.box(0.5625, 0.0, 0.0625, 0.9375, 0.375, 0.4375),
Shapes.box(0.125, 0.0, 0.125, 0.5, 0.375, 0.5),
Shapes.box(0.5, 0.0, 0.5, 0.875, 0.375, 0.875),
Shapes.box(0.0625, 0.0, 0.5625, 0.4375, 0.375, 0.9375)
)
val METAL_QUARTET_EW = Shapes.or(
Shapes.box(0.5625, 0.0, 0.5625, 0.9375, 0.375, 0.9375),
Shapes.box(0.5, 0.0, 0.125, 0.875, 0.375, 0.5),
Shapes.box(0.125, 0.0, 0.5, 0.5, 0.375, 0.875),
Shapes.box(0.0625, 0.0, 0.0625, 0.4375, 0.375, 0.4375)
)
val POTION_SINGLE = Shapes.box(0.34375, 0.0, 0.34375, 0.65625, 0.625, 0.65625)
val POTION_DOUBLE_EW = Shapes.or(
Shapes.box(0.4375, 0.0, 0.5625, 0.75, 0.625, 0.875),
Shapes.box(0.25, 0.0, 0.125, 0.5625, 0.625, 0.4375)
)
val POTION_DOUBLE_NS = Shapes.or(
Shapes.box(0.5625, 0.0, 0.25, 0.875, 0.625, 0.5625),
Shapes.box(0.125, 0.0, 0.4375, 0.4375, 0.625, 0.75)
)
val POTION_TRIPLE_EAST = Shapes.or(
Shapes.box(0.5625, 0.0, 0.375, 0.875, 0.625, 0.6875),
Shapes.box(0.1875, 0.0, 0.125, 0.5, 0.625, 0.4375),
Shapes.box(0.0625, 0.0, 0.5625, 0.375, 0.625, 0.875)
)
val POTION_TRIPLE_WEST = Shapes.or(
Shapes.box(0.125, 0.0, 0.3125, 0.4375, 0.625, 0.625),
Shapes.box(0.5, 0.0, 0.5625, 0.8125, 0.625, 0.875),
Shapes.box(0.625, 0.0, 0.125, 0.9375, 0.625, 0.4375)
)
val POTION_TRIPLE_NORTH = Shapes.or(
Shapes.box(0.375, 0.0, 0.125, 0.6875, 0.625, 0.4375),
Shapes.box(0.125, 0.0, 0.5, 0.4375, 0.625, 0.8125),
Shapes.box(0.5625, 0.0, 0.625, 0.875, 0.625, 0.9375)
)
val POTION_TRIPLE_SOUTH = Shapes.or(
Shapes.box(0.3125, 0.0, 0.5625, 0.625, 0.625, 0.875),
Shapes.box(0.5625, 0.0, 0.1875, 0.875, 0.625, 0.5),
Shapes.box(0.125, 0.0, 0.0625, 0.4375, 0.625, 0.375)
)
val POTION_QUARTET_EAST = Shapes.or(
Shapes.box(0.5625, 0.0, 0.5, 0.875, 0.625, 0.8125),
Shapes.box(0.5, 0.0, 0.125, 0.8125, 0.625, 0.4375),
Shapes.box(0.0625, 0.0, 0.0625, 0.375, 0.625, 0.375),
Shapes.box(0.125, 0.0, 0.5625, 0.4375, 0.625, 0.875)
)
val POTION_QUARTET_WEST = Shapes.or(
Shapes.box(0.125, 0.0, 0.1875, 0.4375, 0.625, 0.5),
Shapes.box(0.1875, 0.0, 0.5625, 0.5, 0.625, 0.875),
Shapes.box(0.625, 0.0, 0.625, 0.9375, 0.625, 0.9375),
Shapes.box(0.5625, 0.0, 0.125, 0.875, 0.625, 0.4375)
)
val POTION_QUARTET_NORTH = Shapes.or(
Shapes.box(0.5, 0.0, 0.125, 0.8125, 0.625, 0.4375),
Shapes.box(0.125, 0.0, 0.1875, 0.4375, 0.625, 0.5),
Shapes.box(0.0625, 0.0, 0.625, 0.375, 0.625, 0.9375),
Shapes.box(0.5625, 0.0, 0.5625, 0.875, 0.625, 0.875)
)
val POTION_QUARTET_SOUTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.5625, 0.5, 0.625, 0.875),
Shapes.box(0.5625, 0.0, 0.5, 0.875, 0.625, 0.8125),
Shapes.box(0.625, 0.0, 0.0625, 0.9375, 0.625, 0.375),
Shapes.box(0.125, 0.0, 0.125, 0.4375, 0.625, 0.4375)
)
val MAX_POTION_SINGLE_NS = Shapes.box(0.34375, 0.0, 0.3125, 0.65625, 0.5, 0.6875)
val MAX_POTION_SINGLE_EW = Shapes.box(0.3125, 0.0, 0.34375, 0.6875, 0.5, 0.65625)
val MAX_POTION_DOUBLE_EAST = Shapes.or(
Shapes.box(0.3125, 0.0, 0.5, 0.6875, 0.5, 0.8125),
Shapes.box(0.25, 0.0, 0.125, 0.625, 0.5, 0.4375)
)
val MAX_POTION_DOUBLE_WEST = Shapes.or(
Shapes.box(0.3125, 0.0, 0.1875, 0.6875, 0.5, 0.5),
Shapes.box(0.375, 0.0, 0.5625, 0.75, 0.5, 0.875)
)
val MAX_POTION_DOUBLE_NORTH = Shapes.or(
Shapes.box(0.5, 0.0, 0.3125, 0.8125, 0.5, 0.6875),
Shapes.box(0.125, 0.0, 0.375, 0.4375, 0.5, 0.75)
)
val MAX_POTION_DOUBLE_SOUTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.3125, 0.5, 0.5, 0.6875),
Shapes.box(0.5625, 0.0, 0.25, 0.875, 0.5, 0.625)
)
val MAX_POTION_TRIPLE_EAST = Shapes.or(
Shapes.box(0.1875, 0.0, 0.625, 0.5625, 0.5, 0.9375),
Shapes.box(0.125, 0.0, 0.125, 0.5, 0.5, 0.4375),
Shapes.box(0.5625, 0.0, 0.3125, 0.9375, 0.5, 0.625)
)
val MAX_POTION_TRIPLE_WEST = Shapes.or(
Shapes.box(0.4375, 0.0, 0.0625, 0.8125, 0.5, 0.375),
Shapes.box(0.5, 0.0, 0.5625, 0.875, 0.5, 0.875),
Shapes.box(0.0625, 0.0, 0.375, 0.4375, 0.5, 0.6875)
)
val MAX_POTION_TRIPLE_NORTH = Shapes.or(
Shapes.box(0.625, 0.0, 0.4375, 0.9375, 0.5, 0.8125),
Shapes.box(0.125, 0.0, 0.5, 0.4375, 0.5, 0.875),
Shapes.box(0.3125, 0.0, 0.0625, 0.625, 0.5, 0.4375)
)
val MAX_POTION_TRIPLE_SOUTH = Shapes.or(
Shapes.box(0.0625, 0.0, 0.1875, 0.375, 0.5, 0.5625),
Shapes.box(0.5625, 0.0, 0.125, 0.875, 0.5, 0.5),
Shapes.box(0.375, 0.0, 0.5625, 0.6875, 0.5, 0.9375)
)
val MAX_POTION_QUARTET_EAST = Shapes.or(
Shapes.box(0.125, 0.0, 0.625, 0.5, 0.5, 0.9375),
Shapes.box(0.0625, 0.0, 0.125, 0.4375, 0.5, 0.4375),
Shapes.box(0.5625, 0.0, 0.5625, 0.9375, 0.5, 0.875),
Shapes.box(0.5, 0.0, 0.1875, 0.875, 0.5, 0.5)
)
val MAX_POTION_QUARTET_WEST = Shapes.or(
Shapes.box(0.5, 0.0, 0.0625, 0.875, 0.5, 0.375),
Shapes.box(0.5625, 0.0, 0.5625, 0.9375, 0.5, 0.875),
Shapes.box(0.0625, 0.0, 0.125, 0.4375, 0.5, 0.4375),
Shapes.box(0.125, 0.0, 0.5, 0.5, 0.5, 0.8125)
)
val MAX_POTION_QUARTET_NORTH = Shapes.or(
Shapes.box(0.625, 0.0, 0.5, 0.9375, 0.5, 0.875),
Shapes.box(0.125, 0.0, 0.5625, 0.4375, 0.5, 0.9375),
Shapes.box(0.5625, 0.0, 0.0625, 0.875, 0.5, 0.4375),
Shapes.box(0.1875, 0.0, 0.125, 0.5, 0.5, 0.5)
)
val MAX_POTION_QUARTET_SOUTH = Shapes.or(
Shapes.box(0.0625, 0.0, 0.125, 0.375, 0.5, 0.5),
Shapes.box(0.5625, 0.0, 0.0625, 0.875, 0.5, 0.4375),
Shapes.box(0.125, 0.0, 0.5625, 0.4375, 0.5, 0.9375),
Shapes.box(0.5, 0.0, 0.5, 0.8125, 0.5, 0.875)
)
val RESTORE_SINGLE = Shapes.box(0.375, 0.0, 0.375, 0.625, 0.5, 0.625)
val RESTORE_DOUBLE_EW = Shapes.or(
Shapes.box(0.375, 0.0, 0.1875, 0.625, 0.5, 0.4375),
Shapes.box(0.375, 0.0, 0.5625, 0.625, 0.5, 0.8125)
)
val RESTORE_DOUBLE_NS = Shapes.or(
Shapes.box(0.1875, 0.0, 0.375, 0.4375, 0.5, 0.625),
Shapes.box(0.5625, 0.0, 0.375, 0.8125, 0.5, 0.625)
)
val RESTORE_TRIPLE_EAST = Shapes.or(
Shapes.box(0.1875, 0.0, 0.1875, 0.4375, 0.5, 0.4375),
Shapes.box(0.25, 0.0, 0.5625, 0.5, 0.5, 0.8125),
Shapes.box(0.625, 0.0, 0.375, 0.875, 0.5, 0.625)
)
val RESTORE_TRIPLE_WEST = Shapes.or(
Shapes.box(0.5625, 0.0, 0.5625, 0.8125, 0.5, 0.8125),
Shapes.box(0.5, 0.0, 0.1875, 0.75, 0.5, 0.4375),
Shapes.box(0.125, 0.0, 0.375, 0.375, 0.5, 0.625)
)
val RESTORE_TRIPLE_NORTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.5, 0.8125),
Shapes.box(0.5625, 0.0, 0.5, 0.8125, 0.5, 0.75),
Shapes.box(0.375, 0.0, 0.125, 0.625, 0.5, 0.375)
)
val RESTORE_TRIPLE_SOUTH = Shapes.or(
Shapes.box(0.5625, 0.0, 0.1875, 0.8125, 0.5, 0.4375),
Shapes.box(0.1875, 0.0, 0.25, 0.4375, 0.5, 0.5),
Shapes.box(0.375, 0.0, 0.625, 0.625, 0.5, 0.875)
)
val RESTORE_QUARTET_EAST = Shapes.or(
Shapes.box(0.125, 0.0, 0.1875, 0.375, 0.5, 0.4375),
Shapes.box(0.1875, 0.0, 0.625, 0.4375, 0.5, 0.875),
Shapes.box(0.625, 0.0, 0.5, 0.875, 0.5, 0.75),
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.5, 0.375)
)
val RESTORE_QUARTET_WEST = Shapes.or(
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.5, 0.8125),
Shapes.box(0.5625, 0.0, 0.125, 0.8125, 0.5, 0.375),
Shapes.box(0.125, 0.0, 0.25, 0.375, 0.5, 0.5),
Shapes.box(0.125, 0.0, 0.625, 0.375, 0.5, 0.875)
)
val RESTORE_QUARTET_NORTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.625, 0.4375, 0.5, 0.875),
Shapes.box(0.625, 0.0, 0.5625, 0.875, 0.5, 0.8125),
Shapes.box(0.5, 0.0, 0.125, 0.75, 0.5, 0.375),
Shapes.box(0.125, 0.0, 0.125, 0.375, 0.5, 0.375)
)
val RESTORE_QUARTET_SOUTH = Shapes.or(
Shapes.box(0.5625, 0.0, 0.125, 0.8125, 0.5, 0.375),
Shapes.box(0.125, 0.0, 0.1875, 0.375, 0.5, 0.4375),
Shapes.box(0.25, 0.0, 0.625, 0.5, 0.5, 0.875),
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.5, 0.875)
)
val ETHER_SINGLE_EW = Shapes.box(0.34375, 0.0, 0.40625, 0.65625, 0.4375, 0.59375)
val ETHER_SINGLE_NS = Shapes.box(0.40625, 0.0, 0.34375, 0.59375, 0.4375, 0.65625)
val ETHER_DOUBLE_EAST = Shapes.or(
Shapes.box(0.375, 0.0, 0.5, 0.6875, 0.4375, 0.6875),
Shapes.box(0.25, 0.0, 0.25, 0.5625, 0.4375, 0.4375)
)
val ETHER_DOUBLE_WEST = Shapes.or(
Shapes.box(0.3125, 0.0, 0.3125, 0.625, 0.4375, 0.5),
Shapes.box(0.4375, 0.0, 0.5625, 0.75, 0.4375, 0.75)
)
val ETHER_DOUBLE_NORTH = Shapes.or(
Shapes.box(0.5, 0.0, 0.3125, 0.6875, 0.4375, 0.625),
Shapes.box(0.25, 0.0, 0.4375, 0.4375, 0.4375, 0.75)
)
val ETHER_DOUBLE_SOUTH = Shapes.or(
Shapes.box(0.3125, 0.0, 0.375, 0.5, 0.4375, 0.6875),
Shapes.box(0.5625, 0.0, 0.25, 0.75, 0.4375, 0.5625)
)
val ETHER_TRIPLE_EAST = Shapes.or(
Shapes.box(0.25, 0.0, 0.625, 0.5625, 0.4375, 0.8125),
Shapes.box(0.125, 0.0, 0.1875, 0.4375, 0.4375, 0.375),
Shapes.box(0.5, 0.0, 0.375, 0.8125, 0.4375, 0.5625)
)
val ETHER_TRIPLE_WEST = Shapes.or(
Shapes.box(0.4375, 0.0, 0.1875, 0.75, 0.4375, 0.375),
Shapes.box(0.5625, 0.0, 0.625, 0.875, 0.4375, 0.8125),
Shapes.box(0.1875, 0.0, 0.4375, 0.5, 0.4375, 0.625)
)
val ETHER_TRIPLE_NORTH = Shapes.or(
Shapes.box(0.625, 0.0, 0.4375, 0.8125, 0.4375, 0.75),
Shapes.box(0.1875, 0.0, 0.5625, 0.375, 0.4375, 0.875),
Shapes.box(0.375, 0.0, 0.1875, 0.5625, 0.4375, 0.5)
)
val ETHER_TRIPLE_SOUTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.25, 0.375, 0.4375, 0.5625),
Shapes.box(0.625, 0.0, 0.125, 0.8125, 0.4375, 0.4375),
Shapes.box(0.4375, 0.0, 0.5, 0.625, 0.4375, 0.8125)
)
val ETHER_QUARTET_EAST = Shapes.or(
Shapes.box(0.125, 0.0, 0.5625, 0.4375, 0.4375, 0.75),
Shapes.box(0.0625, 0.0, 0.1875, 0.375, 0.4375, 0.375),
Shapes.box(0.5625, 0.0, 0.625, 0.875, 0.4375, 0.8125),
Shapes.box(0.5, 0.0, 0.125, 0.8125, 0.4375, 0.3125)
)
val ETHER_QUARTET_WEST = Shapes.or(
Shapes.box(0.5625, 0.0, 0.25, 0.875, 0.4375, 0.4375),
Shapes.box(0.625, 0.0, 0.625, 0.9375, 0.4375, 0.8125),
Shapes.box(0.125, 0.0, 0.1875, 0.4375, 0.4375, 0.375),
Shapes.box(0.1875, 0.0, 0.6875, 0.5, 0.4375, 0.875)
)
val ETHER_QUARTET_NORTH = Shapes.or(
Shapes.box(0.5625, 0.0, 0.5625, 0.75, 0.4375, 0.875),
Shapes.box(0.1875, 0.0, 0.625, 0.375, 0.4375, 0.9375),
Shapes.box(0.625, 0.0, 0.125, 0.8125, 0.4375, 0.4375),
Shapes.box(0.125, 0.0, 0.1875, 0.3125, 0.4375, 0.5)
)
val ETHER_QUARTET_SOUTH = Shapes.or(
Shapes.box(0.25, 0.0, 0.125, 0.4375, 0.4375, 0.4375),
Shapes.box(0.625, 0.0, 0.0625, 0.8125, 0.4375, 0.375),
Shapes.box(0.1875, 0.0, 0.5625, 0.375, 0.4375, 0.875),
Shapes.box(0.6875, 0.0, 0.5, 0.875, 0.4375, 0.8125)
)
val BATTLE_SINGLE = Shapes.box(0.375, 0.0, 0.375, 0.625, 0.4375, 0.625)
val BATTLE_DOUBLE_NS = Shapes.or(
Shapes.box(0.5625, 0.0, 0.4375, 0.8125, 0.4375, 0.6875),
Shapes.box(0.1875, 0.0, 0.3125, 0.4375, 0.4375, 0.5625)
)
val BATTLE_DOUBLE_EW = Shapes.or(
Shapes.box(0.3125, 0.0, 0.5625, 0.5625, 0.4375, 0.8125),
Shapes.box(0.4375, 0.0, 0.1875, 0.6875, 0.4375, 0.4375)
)
val BATTLE_TRIPLE_N = Shapes.or(
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.4375, 0.875),
Shapes.box(0.125, 0.0, 0.5, 0.375, 0.4375, 0.75),
Shapes.box(0.4375, 0.0, 0.125, 0.6875, 0.4375, 0.375)
)
val BATTLE_TRIPLE_E = Shapes.or(
Shapes.box(0.125, 0.0, 0.625, 0.375, 0.4375, 0.875),
Shapes.box(0.25, 0.0, 0.125, 0.5, 0.4375, 0.375),
Shapes.box(0.625, 0.0, 0.4375, 0.875, 0.4375, 0.6875)
)
val BATTLE_TRIPLE_S = Shapes.or(
Shapes.box(0.125, 0.0, 0.125, 0.375, 0.4375, 0.375),
Shapes.box(0.625, 0.0, 0.25, 0.875, 0.4375, 0.5),
Shapes.box(0.3125, 0.0, 0.625, 0.5625, 0.4375, 0.875)
)
val BATTLE_TRIPLE_W = Shapes.or(
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.4375, 0.375),
Shapes.box(0.5, 0.0, 0.625, 0.75, 0.4375, 0.875),
Shapes.box(0.125, 0.0, 0.3125, 0.375, 0.4375, 0.5625)
)
val BATTLE_QUARTET_NS = Shapes.or(
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.4375, 0.875),
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.4375, 0.8125),
Shapes.box(0.5625, 0.0, 0.1875, 0.8125, 0.4375, 0.4375),
Shapes.box(0.125, 0.0, 0.125, 0.375, 0.4375, 0.375)
)
val BATTLE_QUARTET_EW = Shapes.or(
Shapes.box(0.125, 0.0, 0.625, 0.375, 0.4375, 0.875),
Shapes.box(0.1875, 0.0, 0.1875, 0.4375, 0.4375, 0.4375),
Shapes.box(0.5625, 0.0, 0.5625, 0.8125, 0.4375, 0.8125),
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.4375, 0.375)
)
val VITAMIN_SINGLE = Shapes.box(0.375, 0.0, 0.375, 0.625, 0.375, 0.625)
val VITAMIN_DOUBLE_EW = Shapes.or(
Shapes.box(0.3125, 0.0, 0.5625, 0.5625, 0.375, 0.8125),
Shapes.box(0.4375, 0.0, 0.1875, 0.6875, 0.375, 0.4375)
)
val VITAMIN_DOUBLE_NS = Shapes.or(
Shapes.box(0.5625, 0.0, 0.4375, 0.8125, 0.375, 0.6875),
Shapes.box(0.1875, 0.0, 0.3125, 0.4375, 0.375, 0.5625)
)
val VITAMIN_TRIPLE_EAST = Shapes.or(
Shapes.box(0.5, 0.0, 0.5625, 0.75, 0.375, 0.8125),
Shapes.box(0.5625, 0.0, 0.1875, 0.8125, 0.375, 0.4375),
Shapes.box(0.1875, 0.0, 0.375, 0.4375, 0.375, 0.625)
)
val VITAMIN_TRIPLE_WEST = Shapes.or(
Shapes.box(0.25, 0.0, 0.1875, 0.5, 0.375, 0.4375),
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.375, 0.8125),
Shapes.box(0.5625, 0.0, 0.375, 0.8125, 0.375, 0.625)
)
val VITAMIN_TRIPLE_NORTH = Shapes.or(
Shapes.box(0.5625, 0.0, 0.25, 0.8125, 0.375, 0.5),
Shapes.box(0.1875, 0.0, 0.1875, 0.4375, 0.375, 0.4375),
Shapes.box(0.375, 0.0, 0.5625, 0.625, 0.375, 0.8125)
)
val VITAMIN_TRIPLE_SOUTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.5, 0.4375, 0.375, 0.75),
Shapes.box(0.5625, 0.0, 0.5625, 0.8125, 0.375, 0.8125),
Shapes.box(0.375, 0.0, 0.1875, 0.625, 0.375, 0.4375)
)
val VITAMIN_QUARTET_EAST = Shapes.or(
Shapes.box(0.5625, 0.0, 0.5625, 0.8125, 0.375, 0.8125),
Shapes.box(0.625, 0.0, 0.1875, 0.875, 0.375, 0.4375),
Shapes.box(0.1875, 0.0, 0.125, 0.4375, 0.375, 0.375),
Shapes.box(0.125, 0.0, 0.625, 0.375, 0.375, 0.875)
)
val VITAMIN_QUARTET_WEST = Shapes.or(
Shapes.box(0.1875, 0.0, 0.1875, 0.4375, 0.375, 0.4375),
Shapes.box(0.125, 0.0, 0.5625, 0.375, 0.375, 0.8125),
Shapes.box(0.5625, 0.0, 0.625, 0.8125, 0.375, 0.875),
Shapes.box(0.625, 0.0, 0.125, 0.875, 0.375, 0.375)
)
val VITAMIN_QUARTET_NORTH = Shapes.or(
Shapes.box(0.5625, 0.0, 0.1875, 0.8125, 0.375, 0.4375),
Shapes.box(0.1875, 0.0, 0.125, 0.4375, 0.375, 0.375),
Shapes.box(0.125, 0.0, 0.5625, 0.375, 0.375, 0.8125),
Shapes.box(0.625, 0.0, 0.625, 0.875, 0.375, 0.875)
)
val VITAMIN_QUARTET_SOUTH = Shapes.or(
Shapes.box(0.1875, 0.0, 0.5625, 0.4375, 0.375, 0.8125),
Shapes.box(0.5625, 0.0, 0.625, 0.8125, 0.375, 0.875),
Shapes.box(0.625, 0.0, 0.1875, 0.875, 0.375, 0.4375),
Shapes.box(0.125, 0.0, 0.125, 0.375, 0.375, 0.375)
)
}
}
@@ -0,0 +1,170 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class WallAttachedDecorativeItemBlock(settings: Properties, val wallItemType: WallItemType) : Block(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(WATERLOGGED, false))
}
@Suppress("unused")
enum class WallItemType : StringRepresentable {
GENERIC_PLANE,
POLICY,
GENERIC_8x;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
override fun codec(): MapCodec<WallAttachedDecorativeItemBlock> {
return CODEC
}
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
var blockState = defaultBlockState()
.setValue(WATERLOGGED, ctx.level.getFluidState(ctx.clickedPos).type == Fluids.WATER)
val worldView = ctx.level
val blockPos = ctx.clickedPos
ctx.nearestLookingDirections.forEach { direction ->
if (direction.axis.isHorizontal) {
blockState = blockState.setValue(FACING, direction.opposite) as BlockState
if (blockState.canSurvive(worldView, blockPos)) {
return blockState
}
}
}
return null
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(WATERLOGGED)
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
return when (wallItemType) {
WallItemType.GENERIC_PLANE -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> FULL_PLANE_SOUTH
Direction.WEST -> FULL_PLANE_WEST
Direction.EAST -> FULL_PLANE_EAST
else -> FULL_PLANE_NORTH
}
}
WallItemType.POLICY -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> POLICY_SOUTH
Direction.WEST -> POLICY_WEST
Direction.EAST -> POLICY_EAST
else -> POLICY_NORTH
}
}
else -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> ITEM_8x_SOUTH
Direction.WEST -> ITEM_8x_WEST
Direction.EAST -> ITEM_8x_EAST
else -> ITEM_8x_NORTH
}
}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction.opposite == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
return level!!.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
companion object {
val CODEC: MapCodec<WallAttachedDecorativeItemBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec(),
WallItemType.CODEC.fieldOf("wallItemType").forGetter(WallAttachedDecorativeItemBlock::wallItemType)
).apply(it, ::WallAttachedDecorativeItemBlock) }
val ITEM_8x_NORTH = Shapes.box(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)
val ITEM_8x_WEST = Shapes.box(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)
val ITEM_8x_SOUTH = Shapes.box(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)
val ITEM_8x_EAST = Shapes.box(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)
val FULL_PLANE_NORTH = Shapes.box(0.0, 0.0, 0.925, 1.0, 1.0, 1.0)
val FULL_PLANE_WEST = Shapes.box(0.925, 0.0, 0.0, 1.0, 1.0, 1.0)
val FULL_PLANE_SOUTH = Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.075)
val FULL_PLANE_EAST = Shapes.box(0.0, 0.0, 0.0, 0.075, 1.0, 1.0)
val POLICY_NORTH = Shapes.box(0.0625, 0.125, 0.925, 1.0, 0.875, 0.9375)
val POLICY_WEST = Shapes.box(0.925, 0.125, 0.0625, 1.0, 0.875, 0.9375)
val POLICY_SOUTH = Shapes.box(0.0625, 0.125, 0.0, 0.9375, 0.875, 0.075)
val POLICY_EAST = Shapes.box(0.0, 0.125, 0.0625, 0.075, 0.875, 0.9375)
}
}
@@ -0,0 +1,213 @@
/*
* 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.block.decor
import com.cobblemon.mod.common.block.decor.StackableItemBlock.Companion
import com.cobblemon.mod.common.block.decor.StackableItemBlock.Companion.ITEMS
import com.cobblemon.mod.common.block.decor.StackableItemBlock.Companion.MAX_ITEMS
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.util.StringRepresentable
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties.HORIZONTAL_FACING
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.IntegerProperty
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
import kotlin.math.min
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class WallAttachedStackableItemBlock(settings: Properties, val wallStackableItemType: WallStackableItemType) : Block(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(ITEMS, 1)
.setValue(WATERLOGGED, false))
}
@Suppress("unused")
enum class WallStackableItemType : StringRepresentable {
TAG,
GENERIC_8x;
override fun getSerializedName(): String = this.name.lowercase()
companion object {
val CODEC = StringRepresentable.fromEnum(::values)
}
}
override fun codec(): MapCodec<WallAttachedStackableItemBlock> {
return CODEC
}
override fun getStateForPlacement(context: BlockPlaceContext): BlockState? {
val blockState = context.level.getBlockState(context.clickedPos)
return if (blockState.`is`(this)) blockState.setValue(
ITEMS,
min(MAX_ITEMS, (blockState.getValue(ITEMS) + 1))
) else {
var blockState = defaultBlockState()
.setValue(WATERLOGGED, context.level.getFluidState(context.clickedPos).type == Fluids.WATER)
val worldView = context.level
val blockPos = context.clickedPos
context.nearestLookingDirections.forEach { direction ->
if (direction.axis.isHorizontal) {
blockState = blockState.setValue(FACING, direction.opposite)
if (blockState.canSurvive(worldView, blockPos)) {
return blockState
}
}
}
return null
}
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState);
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(ITEMS)
builder.add(WATERLOGGED)
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
return when (wallStackableItemType) {
WallStackableItemType.TAG -> return when (state.getValue(ITEMS)) {
2 -> when (state.getValue(FACING)) {
Direction.SOUTH -> TAGS_SOUTH
Direction.WEST -> TAGS_WEST
Direction.EAST -> TAGS_EAST
else -> TAGS_NORTH
}
3, 4 -> when (state.getValue(FACING)) {
Direction.SOUTH -> TAGS_WIDE_SOUTH
Direction.WEST -> TAGS_WIDE_WEST
Direction.EAST -> TAGS_WIDE_EAST
else -> TAGS_WIDE_NORTH
}
5, 6, 7, 8 -> when (state.getValue(FACING)) {
Direction.SOUTH -> FULL_PLANE_SOUTH
Direction.WEST -> FULL_PLANE_WEST
Direction.EAST -> FULL_PLANE_EAST
else -> FULL_PLANE_NORTH
}
else -> when (state.getValue(FACING)) {
Direction.SOUTH -> TAG_SOUTH
Direction.WEST -> TAG_WEST
Direction.EAST -> TAG_EAST
else -> TAG_NORTH
}
}
else -> {
when (state.getValue(FACING)) {
Direction.SOUTH -> ITEM_8x_SOUTH
Direction.WEST -> ITEM_8x_WEST
Direction.EAST -> ITEM_8x_EAST
else -> ITEM_8x_NORTH
}
}
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction.opposite == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
public override fun canBeReplaced(state: BlockState, useContext: BlockPlaceContext): Boolean {
return if (!useContext.isSecondaryUseActive && useContext.itemInHand.`is`(this.asItem()) && state.getValue(
ITEMS
) <= MAX_ITEMS
) true else super.canBeReplaced(state, useContext)
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
return level!!.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
companion object {
val CODEC: MapCodec<WallAttachedStackableItemBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec(),
WallStackableItemType.CODEC.fieldOf("wallStackableItemType").forGetter(WallAttachedStackableItemBlock::wallStackableItemType)
).apply(it, ::WallAttachedStackableItemBlock) }
val ITEMS = IntegerProperty.create("items", 1, 8)
const val MAX_ITEMS: Int = 8
val ITEM_8x_NORTH = Shapes.box(0.25, 0.25, 0.5, 0.75, 0.75, 1.0)
val ITEM_8x_WEST = Shapes.box(0.5, 0.25, 0.25, 1.0, 0.75, 0.75)
val ITEM_8x_SOUTH = Shapes.box(0.25, 0.25, 0.0, 0.75, 0.75, 0.5)
val ITEM_8x_EAST = Shapes.box(0.0, 0.25, 0.25, 0.5, 0.75, 0.75)
val FULL_PLANE_NORTH = Shapes.box(0.0, 0.0, 0.925, 1.0, 1.0, 1.0)
val FULL_PLANE_WEST = Shapes.box(0.925, 0.0, 0.0, 1.0, 1.0, 1.0)
val FULL_PLANE_SOUTH = Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.075)
val FULL_PLANE_EAST = Shapes.box(0.0, 0.0, 0.0, 0.075, 1.0, 1.0)
//One Tag
val TAG_NORTH = Shapes.box(0.375, 0.25, 0.925, 0.625, 0.6875, 1.0)
val TAG_WEST = Shapes.box(0.925, 0.25, 0.375, 1.0, 0.6875, 0.625)
val TAG_SOUTH = Shapes.box(0.375, 0.25, 0.0, 0.625, 0.6875, 0.075)
val TAG_EAST = Shapes.box(0.0, 0.25, 0.375, 0.075, 0.6875, 0.625)
//Two Tags
val TAGS_NORTH = Shapes.box(0.375, 0.125, 0.925, 0.875, 0.6875, 1.0)
val TAGS_WEST = Shapes.box(0.925, 0.125, 0.125, 1.0, 0.6875, 0.625)
val TAGS_SOUTH = Shapes.box(0.125, 0.125, 0.0, 0.625, 0.6875, 0.075)
val TAGS_EAST = Shapes.box(0.0, 0.125, 0.375, 0.075, 0.6875, 0.875)
//Three and Four Tags
val TAGS_WIDE_NORTH = Shapes.box(0.125, 0.125, 0.925, 0.875, 0.875, 1.0)
val TAGS_WIDE_WEST = Shapes.box(0.925, 0.125, 0.125, 1.0, 0.875, 0.875)
val TAGS_WIDE_SOUTH = Shapes.box(0.125, 0.125, 0.0, 0.875, 0.875, 0.075)
val TAGS_WIDE_EAST = Shapes.box(0.0, 0.125, 0.125, 0.075, 0.875, 0.875)
}
}
@@ -0,0 +1,126 @@
/*
* 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.block.decor
import com.mojang.serialization.MapCodec
import com.mojang.serialization.codecs.RecordCodecBuilder
import net.minecraft.core.BlockPos
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.BlockGetter
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.LevelReader
import net.minecraft.world.level.block.*
import net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING
import net.minecraft.world.level.block.state.BlockState
import net.minecraft.world.level.block.state.StateDefinition
import net.minecraft.world.level.block.state.properties.BlockStateProperties
import net.minecraft.world.level.block.state.properties.BlockStateProperties.WATERLOGGED
import net.minecraft.world.level.block.state.properties.Property
import net.minecraft.world.level.material.FluidState
import net.minecraft.world.level.material.Fluids
import net.minecraft.world.level.pathfinder.PathComputationType
import net.minecraft.world.phys.shapes.CollisionContext
import net.minecraft.world.phys.shapes.Shapes
import net.minecraft.world.phys.shapes.VoxelShape
@Suppress("DEPRECATED", "OVERRIDE_DEPRECATION")
class WallAttachedTargetBlock(settings: Properties) : TargetBlock(settings), SimpleWaterloggedBlock {
init {
registerDefaultState(stateDefinition.any()
.setValue(FACING, Direction.NORTH)
.setValue(WATERLOGGED, false)
.setValue(OUTPUT_POWER, 0))
}
override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState? {
var blockState = defaultBlockState()
.setValue(WATERLOGGED, ctx.level.getFluidState(ctx.clickedPos).type == Fluids.WATER)
val worldView = ctx.level
val blockPos = ctx.clickedPos
ctx.nearestLookingDirections.forEach { direction ->
if (direction.axis.isHorizontal) {
blockState = blockState.setValue(FACING, direction.opposite) as BlockState
if (blockState.canSurvive(worldView, blockPos)) {
return blockState
}
}
}
return null
}
override fun getFluidState(blockState: BlockState): FluidState? {
return if (blockState.getValue(WATERLOGGED)) Fluids.WATER.getSource(false) else super.getFluidState(blockState)
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {
builder.add(FACING)
builder.add(WATERLOGGED)
builder.add(*arrayOf<Property<*>>(OUTPUT_POWER))
}
override fun getShape(
state: BlockState,
blockGetter: BlockGetter,
pos: BlockPos,
collisionContext: CollisionContext
): VoxelShape {
return when (state.getValue(FACING)) {
Direction.SOUTH -> FULL_PLANE_SOUTH
Direction.WEST -> FULL_PLANE_WEST
Direction.EAST -> FULL_PLANE_EAST
else -> FULL_PLANE_NORTH
}
}
@Deprecated("Deprecated in Java")
override fun updateShape(
state: BlockState,
direction: Direction,
neighborState: BlockState,
world: LevelAccessor,
pos: BlockPos,
neighborPos: BlockPos
): BlockState {
if (state.getValue(WATERLOGGED)) {
world.scheduleTick(pos, Fluids.WATER, Fluids.WATER.getTickDelay(world))
}
return if (direction.opposite == state.getValue(FACING) && !state.canSurvive(world, pos)) Blocks.AIR.defaultBlockState()
else super.updateShape(state, direction, neighborState, world, pos, neighborPos)
}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)))
}
@Deprecated("Deprecated in Java")
override fun isPathfindable(state: BlockState, type: PathComputationType): Boolean {
return false
}
@Deprecated("Deprecated in Java")
override fun canSurvive(state: BlockState, level: LevelReader, pos: BlockPos): Boolean {
return level.getBlockState(pos.relative(state.getValue(FACING).opposite)).isSolid
}
companion object {
val CODEC: MapCodec<WallAttachedTargetBlock> = RecordCodecBuilder.mapCodec {
it.group(
propertiesCodec()
).apply(it, ::WallAttachedTargetBlock) }
val OUTPUT_POWER = BlockStateProperties.POWER;
val FULL_PLANE_NORTH = Shapes.box(0.0, 0.0, 0.925, 1.0, 1.0, 1.0)
val FULL_PLANE_WEST = Shapes.box(0.925, 0.0, 0.0, 1.0, 1.0, 1.0)
val FULL_PLANE_SOUTH = Shapes.box(0.0, 0.0, 0.0, 1.0, 1.0, 0.075)
val FULL_PLANE_EAST = Shapes.box(0.0, 0.0, 0.0, 0.075, 1.0, 1.0)
}
}
@@ -111,18 +111,13 @@ class CampfireBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlock
BlockEntitySoundTracker.stop(pos, campfireBlockEntity.ambientSound.location)
}
val seasonings = campfireBlockEntity.getSeasonings()
if (seasonings.size != campfireBlockEntity.lastSeasoningStacks.size || seasonings.any { it !in campfireBlockEntity.lastSeasoningStacks }) {
campfireBlockEntity.lastSeasoningStacks = seasonings
campfireBlockEntity.brothColor =
getColourMixFromSeasonings(campfireBlockEntity.getSeasonings())
?: BASE_BROTH_COLOR
campfireBlockEntity.brothColor =
getColourMixFromSeasonings(seasonings)
?: BASE_BROTH_COLOR
campfireBlockEntity.bubbleColor =
getColourMixFromSeasonings(seasonings, true)
?: BASE_BROTH_BUBBLE_COLOR
}
campfireBlockEntity.bubbleColor =
getColourMixFromSeasonings(campfireBlockEntity.getSeasonings(), true)
?: BASE_BROTH_BUBBLE_COLOR
if (campfireBlockEntity.particleCooldown > 0) {
campfireBlockEntity.particleCooldown--
@@ -246,9 +241,6 @@ class CampfireBlockEntity(pos: BlockPos, state: BlockState) : BaseContainerBlock
var bubbleColor: Int = BASE_BROTH_BUBBLE_COLOR
var time: Int = 0
/** Used to know if we should be changing the colour of the broth or if we can go with the previous colour. */
var lastSeasoningStacks = listOf<ItemStack>()
var dataAccess: ContainerData = object : ContainerData {
override fun get(index: Int): Int {
return when (index) {
@@ -49,6 +49,7 @@ import net.minecraft.world.entity.Entity
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.block.state.BlockState
import java.util.*
open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
TintBlockEntity(CobblemonBlockEntities.POKE_SNACK, pos, state),
@@ -119,7 +120,7 @@ open class PokeSnackBlockEntity(pos: BlockPos, state: BlockState) :
level.dimension(),
)
block.eat(level, blockPos, blockState, null)
block.eat(level, blockPos, blockState, action.spawnablePosition.cause.entity as? Player)
}
}
@@ -0,0 +1,48 @@
/*
* 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.block.general
import com.mojang.serialization.MapCodec
import net.minecraft.core.Direction
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.LevelAccessor
import net.minecraft.world.level.block.AmethystClusterBlock
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.DirectionalBlock
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.material.Fluids
class SixDirectionalBlock(properties: Properties) : DirectionalBlock(properties) {
init {registerDefaultState(stateDefinition.any().setValue(FACING, Direction.UP))}
companion object {
val CODEC = simpleCodec(::SixDirectionalBlock)}
public override fun codec(): MapCodec<SixDirectionalBlock> {
return CODEC
}
override fun createBlockStateDefinition(builder: StateDefinition.Builder<Block, BlockState>) {builder.add(FACING)}
@Deprecated("Deprecated in Java")
override fun rotate(state: BlockState, rotation: Rotation): BlockState {
return state.setValue(FACING, rotation.rotate(state.getValue(FACING)))
}
/* override fun mirror(state: BlockState, mirror: Mirror): BlockState {
return state.rotate(mirror.getRotation((state.getValue(FACING))!!))
}*/
override fun getStateForPlacement(context: BlockPlaceContext): BlockState {
return defaultBlockState().setValue(FACING, context.clickedFace)
}
}
@@ -8,9 +8,7 @@
package com.cobblemon.mod.common.client
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.Cobblemon.LOGGER
import com.cobblemon.mod.common.Cobblemon.cobblemonVR
import com.cobblemon.mod.common.CobblemonBlockEntities
import com.cobblemon.mod.common.CobblemonBlocks
import com.cobblemon.mod.common.CobblemonClientImplementation
@@ -29,7 +27,6 @@ import com.cobblemon.mod.common.client.gui.PartyOverlayDataControl
import com.cobblemon.mod.common.client.gui.RideControlsOverlay
import com.cobblemon.mod.common.client.gui.battle.BattleOverlay
import com.cobblemon.mod.common.client.gui.cookingpot.CookingPotScreen
import com.cobblemon.mod.common.client.integration.vivecraft.CobblemonVRClient
import com.cobblemon.mod.common.client.particle.BedrockParticleOptionsRepository
import com.cobblemon.mod.common.client.render.ClientPlayerIcon
import com.cobblemon.mod.common.client.render.DeferredRenderer
@@ -75,7 +72,6 @@ import com.cobblemon.mod.common.client.tooltips.TooltipManager
import com.cobblemon.mod.common.client.trade.ClientTrade
import com.cobblemon.mod.common.entity.boat.CobblemonBoatType
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.integration.vivecraft.CobblemonVR
import com.cobblemon.mod.common.platform.events.PlatformEvents
import com.cobblemon.mod.common.pokedex.scanner.PokedexUsageContext
import com.cobblemon.mod.common.util.isLookingAt
@@ -156,10 +152,6 @@ object CobblemonClient {
this.registerTooltipManagers()
this.registerMenuScreens()
if (Cobblemon.implementation.isModInstalled("vivecraft")) { // VR integration
CobblemonVRClient.init()
}
LOGGER.info("Registering custom BuiltinItemRenderers")
CobblemonBuiltinItemRendererRegistry.register(CobblemonItems.POKEMON_MODEL, PokemonItemRenderer())
@@ -194,10 +186,8 @@ object CobblemonClient {
) { it is PokemonEntity }
nearbyPokemon?.forEach { entity ->
if (entity is PokemonEntity && !entity.isSilent && !entity.passengers.contains(player)) {
if (player.isLookingAt(entity) && !player.isSpectator && entity.pokemon.shiny) entity.delegate.spawnShinyParticle(
player
)
if (entity is PokemonEntity && !entity.isSilent) {
if (player.isLookingAt(entity) && !player.isSpectator && entity.pokemon.shiny) entity.delegate.spawnShinyParticle(player)
entity.delegate.spawnAspectParticle()
}
}
@@ -245,6 +235,12 @@ object CobblemonClient {
CobblemonBlocks.POKE_CAKE
)
this.implementation.registerBlockRenderType(
RenderType.translucent(),
CobblemonBlocks.UPGRADE,
CobblemonBlocks.DUBIOUS_DISC
)
this.implementation.registerBlockRenderType(
RenderType.cutout(),
CobblemonBlocks.GILDED_CHEST,
@@ -329,7 +325,89 @@ object CobblemonClient {
CobblemonBlocks.PINK_CAMPFIRE_POT,
CobblemonBlocks.RED_CAMPFIRE_POT,
CobblemonBlocks.WHITE_CAMPFIRE_POT,
CobblemonBlocks.YELLOW_CAMPFIRE_POT
CobblemonBlocks.YELLOW_CAMPFIRE_POT,
CobblemonBlocks.KINGS_ROCK,
CobblemonBlocks.CHIPPED_POT,
CobblemonBlocks.CRACKED_POT,
CobblemonBlocks.MASTERPIECE_TEACUP,
CobblemonBlocks.UNREMARKABLE_TEACUP,
CobblemonBlocks.LUMINOUS_MOSS,
CobblemonBlocks.GALARICA_CUFF,
CobblemonBlocks.GALARICA_WREATH,
CobblemonBlocks.DESTINY_KNOT,
CobblemonBlocks.METRONOME,
CobblemonBlocks.DAMP_ROCK,
CobblemonBlocks.HEAT_ROCK,
CobblemonBlocks.ICY_ROCK,
CobblemonBlocks.SMOOTH_ROCK,
CobblemonBlocks.NEVER_MELT_ICE,
CobblemonBlocks.CLEANSE_TAG,
CobblemonBlocks.SPELL_TAG,
CobblemonBlocks.BLUNDER_POLICY,
CobblemonBlocks.WEAKNESS_POLICY,
CobblemonBlocks.RING_TARGET,
CobblemonBlocks.LIFE_ORB,
CobblemonBlocks.FLAME_ORB,
CobblemonBlocks.TOXIC_ORB,
CobblemonBlocks.LIGHT_BALL,
CobblemonBlocks.SMOKE_BALL,
CobblemonBlocks.EJECT_BUTTON,
CobblemonBlocks.METAL_COAT,
CobblemonBlocks.MAGNET,
CobblemonBlocks.RELIC_COIN_POUCH,
CobblemonBlocks.SACHET,
CobblemonBlocks.BRIGHT_POWDER,
CobblemonBlocks.METAL_POWDER,
CobblemonBlocks.QUICK_POWDER,
CobblemonBlocks.POTION,
CobblemonBlocks.SUPER_POTION,
CobblemonBlocks.HYPER_POTION,
CobblemonBlocks.MAX_POTION,
CobblemonBlocks.FULL_RESTORE,
CobblemonBlocks.ANTIDOTE,
CobblemonBlocks.AWAKENING,
CobblemonBlocks.BURN_HEAL,
CobblemonBlocks.ICE_HEAL,
CobblemonBlocks.PARALYZE_HEAL,
CobblemonBlocks.FULL_HEAL,
CobblemonBlocks.ETHER,
CobblemonBlocks.MAX_ETHER,
CobblemonBlocks.ELIXIR,
CobblemonBlocks.MAX_ELIXIR,
CobblemonBlocks.X_ACCURACY,
CobblemonBlocks.X_ATTACK,
CobblemonBlocks.X_DEFENCE,
CobblemonBlocks.X_SPECIAL_ATTACK,
CobblemonBlocks.X_SPECIAL_DEFENCE,
CobblemonBlocks.X_SPEED,
CobblemonBlocks.DIRE_HIT,
CobblemonBlocks.GUARD_SPEC,
CobblemonBlocks.HP_UP,
CobblemonBlocks.PROTEIN,
CobblemonBlocks.IRON,
CobblemonBlocks.CARBOS,
CobblemonBlocks.CALCIUM,
CobblemonBlocks.ZINC,
CobblemonBlocks.PP_UP,
CobblemonBlocks.PP_MAX,
CobblemonBlocks.WHITE_PLAQUE,
CobblemonBlocks.LIGHT_GRAY_PLAQUE,
CobblemonBlocks.GRAY_PLAQUE,
CobblemonBlocks.BLACK_PLAQUE,
CobblemonBlocks.BROWN_PLAQUE,
CobblemonBlocks.RED_PLAQUE,
CobblemonBlocks.ORANGE_PLAQUE,
CobblemonBlocks.YELLOW_PLAQUE,
CobblemonBlocks.LIME_PLAQUE,
CobblemonBlocks.GREEN_PLAQUE,
CobblemonBlocks.CYAN_PLAQUE,
CobblemonBlocks.LIGHT_BLUE_PLAQUE,
CobblemonBlocks.BLUE_PLAQUE,
CobblemonBlocks.PURPLE_PLAQUE,
CobblemonBlocks.MAGENTA_PLAQUE,
CobblemonBlocks.PINK_PLAQUE
)
this.createBoatModelLayers()
@@ -379,10 +457,7 @@ object CobblemonClient {
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.DISPLAY_CASE, ::DisplayCaseRenderer)
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.LECTERN, ::LecternBlockEntityRenderer)
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.CAMPFIRE, ::CampfireBlockEntityRenderer)
this.implementation.registerBlockEntityRenderer(
CobblemonBlockEntities.POKE_SNACK,
::PokeSnackBlockEntityRenderer
)
this.implementation.registerBlockEntityRenderer(CobblemonBlockEntities.POKE_SNACK, ::PokeSnackBlockEntityRenderer)
}
private fun registerEntityRenderers() {
@@ -411,11 +486,7 @@ object CobblemonClient {
private fun registerItemColors() {
implementation.registerItemColors(AprijuiceItemColorProvider, *CobblemonItems.aprijuices.toTypedArray())
implementation.registerItemColors(
PokeSnackItemColorProvider,
CobblemonItems.POKE_SNACK,
CobblemonItems.POKE_CAKE
)
implementation.registerItemColors(PokeSnackItemColorProvider, CobblemonItems.POKE_SNACK, CobblemonItems.POKE_CAKE)
implementation.registerItemColors(PokeBaitItemColorProvider, CobblemonItems.POKE_BAIT)
implementation.registerItemColors(PonigiriItemColorProvider, CobblemonItems.PONIGIRI)
implementation.registerItemColors(SinisterTeaItemColorProvider, CobblemonItems.SINISTER_TEA)
@@ -38,7 +38,7 @@ import kotlin.math.max
class RideControlsOverlay : Gui(Minecraft.getInstance()) {
companion object {
private const val CONTROLS_FADE_FRAMES = 20F
private const val FADE_FRAMES = 20F
private const val BASELINE_FPS = 60F
private const val HALF_SCALE = 0.5F
@@ -63,9 +63,9 @@ class RideControlsOverlay : Gui(Minecraft.getInstance()) {
private val screenExemptions: List<Class<out Screen>> = listOf(ChatScreen::class.java)
private var controlsMaxDurationFrames = Cobblemon.config.displayControlSeconds * BASELINE_FPS
private var controlsDurationFrames = controlsMaxDurationFrames
private var controlsFadeFrames = CONTROLS_FADE_FRAMES
private var maxDurationFrames = Cobblemon.config.displayControlSeconds * BASELINE_FPS
private var durationFrames = maxDurationFrames
private var fadeFrames = FADE_FRAMES
private var lastMouseX = 0
private var lastMouseY = 0
@@ -88,132 +88,123 @@ class RideControlsOverlay : Gui(Minecraft.getInstance()) {
if (minecraft.options.hideGui || minecraft.debugOverlay.showDebugScreen()) return
minecraft.player?.let { player ->
val riddenEntity = player.vehicle
if (riddenEntity != null && riddenEntity is PokemonEntity) {
// Only show controls to driver
if (riddenEntity === player.controlledVehicle) {
renderControls(minecraft, context, tickCounter, riddenEntity)
}
} else {
resetControlsOverlayState()
val riddenEntity = minecraft.player?.vehicle
if (riddenEntity != null && riddenEntity is PokemonEntity) {
// Update max duration if user has changed config
val configDuration = Cobblemon.config.displayControlSeconds * BASELINE_FPS
if (maxDurationFrames != configDuration) {
maxDurationFrames = configDuration
resetOverlayState()
}
// Don't render if duration config set to 0 or less
if (maxDurationFrames <= 0F) return
val rideBehaviourSettings = riddenEntity.ridingController?.context?.settings ?: return
val ridingBehaviourState = riddenEntity.ridingController?.context?.state ?: return
val rideBehaviourKey = rideBehaviourSettings.key
// Update current ride behaviour if changed
// If composite, get active behaviour instead
if (rideBehaviourKey == CompositeBehaviour.KEY) {
val activeBehaviour = (ridingBehaviourState as CompositeState).activeBehaviour.get()
if (currentBehaviourKey != activeBehaviour) {
currentBehaviourKey = activeBehaviour
resetOverlayState()
}
} else if (currentBehaviourKey != rideBehaviourKey) {
currentBehaviourKey = rideBehaviourKey
resetOverlayState()
}
// Render elements if entity has ride behaviour and if display duration has not ended yet
if (rideBehaviourSettings != null && fadeFrames > 0) {
val tickDelta = tickCounter.realtimeDeltaTicks.takeIf { !minecraft.isPaused } ?: 0F
val updateInterval = (tickDelta / 20F) * BASELINE_FPS
durationFrames = max(durationFrames - updateInterval, 0F)
if (durationFrames == 0F && fadeFrames > 0) fadeFrames = max(fadeFrames - updateInterval, 0F)
var showVerticalMouse = true // Show moving mouse up and down with arrows
var showHorizontalMouse = true // Show moving mouse left and right with arrows
var showSneakKey = true
var showJumpKey = true
var showMovementKeys = true
var disableHorizontalMovementKeys = false // Disable left and right movement keys
// Configure what controls to show for each behaviour
when (currentBehaviourKey) {
BirdBehaviour.KEY -> {}
BoatBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
showSneakKey = false
}
BurstBehaviour.KEY -> {}
DolphinBehaviour.KEY -> {
disableHorizontalMovementKeys = true
showSneakKey = false
showJumpKey = false
}
GliderBehaviour.KEY -> {}
HelicopterBehaviour.KEY -> {}
HorseBehaviour.KEY -> {
showVerticalMouse = false
disableHorizontalMovementKeys = true
showSneakKey = false
}
HoverBehaviour.KEY -> {
showVerticalMouse = false
}
JetBehaviour.KEY -> {
showSneakKey = false
showJumpKey = false
}
MinekartBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
showSneakKey = false
}
RocketBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
}
VehicleBehaviour.KEY -> {}
}
val centerX = minecraft.window.guiScaledWidth / 2
val centerY = minecraft.window.guiScaledHeight / 2
renderMouseControls(
context,
!showMovementKeys && !showJumpKey && !showSneakKey,
showHorizontalMouse,
showVerticalMouse,
centerX,
centerY / 2,
fadeFrames / FADE_FRAMES
)
renderKeyControls(
context,
!showHorizontalMouse && !showVerticalMouse,
showMovementKeys,
disableHorizontalMovementKeys,
showJumpKey,
showSneakKey,
minecraft.player?.input,
centerX,
centerY / 2,
fadeFrames / FADE_FRAMES
)
}
} else {
resetOverlayState()
}
}
private fun renderControls(minecraft: Minecraft, context: GuiGraphics, tickCounter: DeltaTracker, riddenEntity: PokemonEntity) {
// Update max duration if user has changed config
val configDuration = Cobblemon.config.displayControlSeconds * BASELINE_FPS
if (controlsMaxDurationFrames != configDuration) {
controlsMaxDurationFrames = configDuration
resetControlsOverlayState()
}
// Don't render if duration config set to 0 or less
if (controlsMaxDurationFrames <= 0F) return
val rideBehaviourSettings = riddenEntity.ridingController?.context?.settings ?: return
val ridingBehaviourState = riddenEntity.ridingController?.context?.state ?: return
val rideBehaviourKey = rideBehaviourSettings.key
// Update current ride behaviour if changed
// If composite, get active behaviour instead
if (rideBehaviourKey == CompositeBehaviour.KEY) {
val activeBehaviour = (ridingBehaviourState as CompositeState).activeBehaviour.get()
if (currentBehaviourKey != activeBehaviour) {
currentBehaviourKey = activeBehaviour
resetControlsOverlayState()
}
} else if (currentBehaviourKey != rideBehaviourKey) {
currentBehaviourKey = rideBehaviourKey
resetControlsOverlayState()
}
// Render elements if entity has ride behaviour and if display duration has not ended yet
if (rideBehaviourSettings != null && controlsFadeFrames > 0) {
val tickDelta = tickCounter.realtimeDeltaTicks.takeIf { !minecraft.isPaused } ?: 0F
val updateInterval = (tickDelta / 20F) * BASELINE_FPS
controlsDurationFrames = max(controlsDurationFrames - updateInterval, 0F)
if (controlsDurationFrames == 0F && controlsFadeFrames > 0) controlsFadeFrames = max(controlsFadeFrames - updateInterval, 0F)
var showVerticalMouse = true // Show moving mouse up and down with arrows
var showHorizontalMouse = true // Show moving mouse left and right with arrows
var showSneakKey = true
var showJumpKey = true
var showMovementKeys = true
var disableHorizontalMovementKeys = false // Disable left and right movement keys
// Configure what controls to show for each behaviour
when (currentBehaviourKey) {
BirdBehaviour.KEY -> {}
BoatBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
showSneakKey = false
}
BurstBehaviour.KEY -> {}
DolphinBehaviour.KEY -> {
disableHorizontalMovementKeys = true
showSneakKey = false
showJumpKey = false
}
GliderBehaviour.KEY -> {}
HelicopterBehaviour.KEY -> {}
HorseBehaviour.KEY -> {
showVerticalMouse = false
disableHorizontalMovementKeys = true
showSneakKey = false
}
HoverBehaviour.KEY -> {
showVerticalMouse = false
}
JetBehaviour.KEY -> {
showSneakKey = false
showJumpKey = false
}
MinekartBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
showSneakKey = false
}
RocketBehaviour.KEY -> {
showVerticalMouse = false
showHorizontalMouse = false
}
VehicleBehaviour.KEY -> {}
}
val centerX = minecraft.window.guiScaledWidth / 2
val centerY = minecraft.window.guiScaledHeight / 2
renderMouseControls(
context,
!showMovementKeys && !showJumpKey && !showSneakKey,
showHorizontalMouse,
showVerticalMouse,
centerX,
centerY / 2,
controlsFadeFrames / CONTROLS_FADE_FRAMES
)
renderKeyControls(
context,
!showHorizontalMouse && !showVerticalMouse,
showMovementKeys,
disableHorizontalMovementKeys,
showJumpKey,
showSneakKey,
minecraft.player?.input,
centerX,
centerY / 2,
controlsFadeFrames / CONTROLS_FADE_FRAMES
)
}
}
private fun resetControlsOverlayState() {
if (controlsDurationFrames != controlsMaxDurationFrames) controlsDurationFrames = controlsMaxDurationFrames
if (controlsFadeFrames != CONTROLS_FADE_FRAMES) controlsFadeFrames = CONTROLS_FADE_FRAMES
private fun resetOverlayState() {
if (durationFrames != maxDurationFrames) durationFrames = maxDurationFrames
if (fadeFrames != FADE_FRAMES) fadeFrames = FADE_FRAMES
if (mouseMovedUp != null) {
mouseMovedUp = null
lastMouseY = 0
@@ -422,7 +413,7 @@ class RideControlsOverlay : Gui(Minecraft.getInstance()) {
if (showJump || showSneak) {
val offsetY = if (showMovement) 0 else -14
var label: MutableComponent?
var label: MutableComponent? = null
if (showJump && showSneak) {
label = "key.sneak".asTranslated().append("/").append("key.jump".asTranslated())
@@ -11,6 +11,7 @@ package com.cobblemon.mod.common.client.gui.pc
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.gui.blitk
import com.cobblemon.mod.common.api.gui.getPixelRGB
import com.cobblemon.mod.common.api.storage.StorePosition
import com.cobblemon.mod.common.api.storage.party.PartyPosition
import com.cobblemon.mod.common.api.storage.pc.PCPosition
@@ -283,6 +284,20 @@ class StorageWidget(
height = 189,
alpha = if (screenLoaded) 1F else ((pcGui.ticksElapsed).toFloat() / 10F).coerceIn(0F, 1F)
)
} else {
val rgb = getPixelRGB(x + (SCREEN_WIDTH / 2), y + (SCREEN_HEIGHT / 2))
blitk(
matrixStack = matrices,
texture = screenGlowResource,
x = x - 17,
y = y - 17,
width = 208,
height = 189,
red = rgb.first / 255F,
green = rgb.second / 255F,
blue = rgb.third / 255F,
alpha = if (screenLoaded) 1F else ((pcGui.ticksElapsed).toFloat() / 10F).coerceIn(0F, 1F)
)
}
blitk(
@@ -592,10 +592,6 @@ class PokemonInfoWidget(val pX: Int, val pY: Int, val updateForm: (PokedexForm)
}
private fun switchForm(nextIndex: Boolean) {
if (visibleForms.isEmpty() || currentEntry == null) {
return
}
selectedPoseIndex = 0
if (nextIndex) {
@@ -606,8 +602,6 @@ class PokemonInfoWidget(val pX: Int, val pY: Int, val updateForm: (PokedexForm)
else selectedFormIndex = visibleForms.lastIndex
}
selectedFormIndex = selectedFormIndex.coerceIn(0, visibleForms.lastIndex)
setupButtons(currentEntry!!, visibleForms[selectedFormIndex])
updateAspects()
}
@@ -1,26 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft
import com.cobblemon.mod.common.client.integration.vivecraft.party.PartyOnArm
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityManager
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityRegistration
import com.cobblemon.mod.common.client.integration.vivecraft.listener.proximity.PokeRodBaitListener
import org.vivecraft.api.data.VRBodyPart
class CobblemonVRClient {
companion object {
fun init() {
PartyOnArm.init()
ProximityManager.init()
ProximityManager.register(
ProximityRegistration(
bodyA = VRBodyPart.MAIN_HAND,
bodyB = VRBodyPart.OFF_HAND,
distanceThreshold = 0.25f,
angleThreshold = 120f,
listener = PokeRodBaitListener("Main-OffHand")
)
)
}
}
}
@@ -1,40 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.listener.proximity
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityListener
import com.cobblemon.mod.common.client.integration.vivecraft.proximity.ProximityRegistration
import com.cobblemon.mod.common.net.messages.server.pokerod.ApplyBaitPacket
import net.minecraft.client.Minecraft
import net.minecraft.world.InteractionHand
import net.minecraft.world.item.ItemStack
import org.vivecraft.api.data.VRBodyPart
import org.vivecraft.api.data.VRPose
class PokeRodBaitListener(private val name: String) : ProximityListener {
//TODO: Also add that if 1 is Rod the other needs to be seasoning
override fun isActive(registration: ProximityRegistration): Boolean {
val player = Minecraft.getInstance().player ?: return false
val handA: InteractionHand = VRBodyPart.toInteractionHand(registration.bodyA) ?: return false
val itemStackA: ItemStack = player.getItemInHand(handA)
val handB: InteractionHand = VRBodyPart.toInteractionHand(registration.bodyB) ?: return false
val itemStackB: ItemStack = player.getItemInHand(handB)
return itemStackA.`is`(CobblemonItemTags.POKE_RODS) || itemStackB.`is`(CobblemonItemTags.POKE_RODS)
}
override fun onEnter(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
Cobblemon.LOGGER.info("[$name] Enter: $bodyA <-> $bodyB")
}
override fun onExit(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
Cobblemon.LOGGER.info("[$name] Exit: $bodyA <-> $bodyB")
}
override fun onTick(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose) {
Cobblemon.LOGGER.info("[$name] Proximity: $bodyA <-> $bodyB")
CobblemonNetwork.sendToServer(ApplyBaitPacket())
}
}
@@ -1,237 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
import com.cobblemon.mod.common.Cobblemon
import net.minecraft.client.Minecraft
import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.phys.Vec3
import org.vivecraft.api.client.VRClientAPI
import org.vivecraft.api.client.tracker.swing.SwingContext
import org.vivecraft.api.client.tracker.swing.SwingListener
import org.vivecraft.api.data.VRBodyPart
import kotlin.math.abs
/**
* Listener that classifies directional swings (up, down, forward, backward, left, right)
* using Vivecraft VR pose history and invokes handler methods for each direction.
*
* @param forwardDotThreshold Dot product threshold used to classify forward/back/left/right directions.
* @param historyTicks Number of ticks used to compute velocity from historical poses.
*/
abstract class DirectionalSwingListener(
private val forwardDotThreshold: Double = 0.3,
private val historyTicks: Int = 10
) : SwingListener {
protected val minecraft: Minecraft = Minecraft.getInstance()
protected val clientData: VRClientAPI = VRClientAPI.instance()
/**
* Compute the net movement vector for the specified body part over the given number of ticks.
* Returns null if historical pose data is unavailable, insufficient, or movement is negligible.
*
* @param bodyPart The VR body part to compute movement for.
* @param ticks The number of ticks of history to consider.
* @return The movement vector or null if unavailable/insignificant.
*/
private fun changeForVelocity(bodyPart: VRBodyPart, ticks: Int = historyTicks): Vec3? {
val history = clientData.historicalVRPoses ?: return null
if (history.ticksOfHistory() < ticks) return null
val delta = history.netMovement(bodyPart, ticks)
delta?.lengthSqr()?.let { if (it < 1e-6) return null }
return delta
}
/**
* Called when an upward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the upward action was handled, false otherwise.
*/
protected open fun onUpwardSwing(
useHand: InteractionHand,
player: Player
): Boolean {
Cobblemon.LOGGER.info(
"Ignoring swing: upward movement. player={}, hand={}",
player, useHand
)
return true
}
/**
* Called when a downward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the downward action was handled, false otherwise.
*/
protected open fun onDownwardSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
Cobblemon.LOGGER.info(
"Ignoring swing: downward movement. handVel={}, player={}, hand={}",
handVel, player, useHand
)
return true
}
/**
* Called when a forward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the forward action was handled, false otherwise.
*/
protected open fun onForwardSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
return true
}
/**
* Called when a backward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the backward action was handled, false otherwise.
*/
protected open fun onBackwardSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
Cobblemon.LOGGER.info(
"Ignoring swing: backward movement. handVel={}, player={}, hand={}",
handVel, player, useHand
)
return true
}
/**
* Called when a leftward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the leftward action was handled, false otherwise.
*/
protected open fun onLeftSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
Cobblemon.LOGGER.info(
"Ignoring swing: leftward movement. handVel={}, player={}, hand={}",
handVel, player, useHand
)
return true
}
/**
* Called when a rightward swing is detected.
*
* @param useHand The hand used for the swing.
* @param handVel The velocity vector of the hand during the swing.
* @param player The player performing the swing.
* @return True if the rightward action was handled, false otherwise.
*/
protected open fun onRightSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
Cobblemon.LOGGER.info(
"Ignoring swing: rightward movement. handVel={}, player={}, hand={}",
handVel, player, useHand
)
return true
}
/**
* Checks if the given item stack is valid for processing by this swing listener.
* Subclasses must implement this to specify which items they handle.
* @param itemStack The item stack to validate.
* @return True if the item stack is valid, false otherwise.
*/
protected abstract fun isValidItem(itemStack: ItemStack): Boolean
/**
* Called when a swing ends. Validates the held item, computes hand velocity from historical poses,
* handles vertical swings first (upward/downward) and then classifies horizontal direction:
* forward/backward by dot with player look direction; left/right by projecting onto a right vector
* computed from world up and forward. Ambiguous swings are ignored.
*
* @param context Vivecraft swing context containing body part information.
*/
override fun onSwingEnd(context: SwingContext?) {
val player = minecraft.player ?: return
val ctx = context ?: return
val useHand: InteractionHand = VRBodyPart.toInteractionHand(ctx.bodyPart) ?: return
val itemStack: ItemStack = player.getItemInHand(useHand)
if (!isValidItem(itemStack)) return
val handVel = changeForVelocity(ctx.bodyPart) ?: run {
Cobblemon.LOGGER.info(
"Ignoring swing: insufficient historical pose data for velocity. bodyPart={}, player={}",
ctx.bodyPart, player
)
return
}
val vertical = handVel.y
if (vertical > 0.0) {
if (onUpwardSwing(useHand, player)) return
} else if (vertical < 0.0) {
if (onDownwardSwing(useHand, handVel, player)) return
}
val forward = player.lookAngle.normalize()
val handDir = handVel.normalize()
val forwardDot = handDir.dot(forward)
val worldUp = Vec3(0.0, 1.0, 0.0)
val right = forward.cross(worldUp).let {
if (it.lengthSqr() < 1e-6) Vec3(1.0, 0.0, 0.0) else it.normalize()
}
val rightDot = handDir.dot(right)
if (forwardDot > forwardDotThreshold) {
if (onForwardSwing(useHand, handVel, player)) return
return
}
if (forwardDot < -forwardDotThreshold) {
if (onBackwardSwing(useHand, handVel, player)) return
return
}
if (abs(rightDot) > forwardDotThreshold) {
if (rightDot > 0.0) {
if (onRightSwing(useHand, handVel, player)) return
} else {
if (onLeftSwing(useHand, handVel, player)) return
}
return
}
Cobblemon.LOGGER.info(
"Ignoring swing: ambiguous direction. forwardDot={}, rightDot={}, handVel={}, player={}",
forwardDot, rightDot, handVel, player
)
}
}
@@ -1,29 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.phys.Vec3
class PokeBallSwingListener : DirectionalSwingListener() {
override fun isValidItem(itemStack: ItemStack): Boolean =
itemStack.`is`(CobblemonItemTags.POKE_BALLS)
override fun onForwardSwing(
useHand: InteractionHand,
handVel: Vec3,
player: Player
): Boolean {
CobblemonNetwork.sendToServer(SendOutPokeBallPacket())
return true
}
override fun onDownwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
CobblemonNetwork.sendToServer(SendOutPokeBallPacket())
return super.onDownwardSwing(useHand, handVel, player)
}
}
@@ -1,31 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.listener.swing
import com.cobblemon.mod.common.CobblemonNetwork
import com.cobblemon.mod.common.api.tags.CobblemonItemTags
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
import com.cobblemon.mod.common.net.messages.server.pokerod.ReelPokeRodPacket
import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.phys.Vec3
class PokeRodSwingListener : DirectionalSwingListener() {
override fun isValidItem(itemStack: ItemStack): Boolean =
itemStack.`is`(CobblemonItemTags.POKE_RODS)
override fun onUpwardSwing(useHand: InteractionHand, player: Player): Boolean {
CobblemonNetwork.sendToServer(ReelPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
return super.onUpwardSwing(useHand, player)
}
override fun onForwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
CobblemonNetwork.sendToServer(CastPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
return super.onForwardSwing(useHand, handVel, player)
}
override fun onDownwardSwing(useHand: InteractionHand, handVel: Vec3, player: Player): Boolean {
CobblemonNetwork.sendToServer(CastPokeRodPacket(useHand == InteractionHand.MAIN_HAND))
return super.onDownwardSwing(useHand, handVel, player)
}
}
@@ -1,188 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.party
import com.cobblemon.mod.common.Cobblemon
import com.cobblemon.mod.common.client.CobblemonClient
import com.cobblemon.mod.common.entity.pokeball.EmptyPokeBallEntity
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.platform.events.ClientTickEvent
import com.cobblemon.mod.common.platform.events.PlatformEvents
import com.cobblemon.mod.common.platform.events.RenderEvent
import com.cobblemon.mod.common.pokemon.Pokemon
import com.mojang.math.Axis
import net.minecraft.client.Minecraft
import net.minecraft.client.gui.GuiGraphics
import net.minecraft.client.player.LocalPlayer
import net.minecraft.client.renderer.LightTexture
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.InteractionHand
import net.minecraft.world.entity.Entity
import net.minecraft.world.phys.Vec3
import org.joml.Vector3f
import org.vivecraft.api.VRAPI
import org.vivecraft.api.client.InteractModule
import org.vivecraft.api.client.VRClientAPI
import org.vivecraft.api.data.VRBodyPartData
import java.util.function.Consumer
class PartyOnArm : InteractModule {
val fakePartyEntities: Array<Entity?> = arrayOfNulls(6)
var selectedIndex = -1
private fun onTick(tickEvent: ClientTickEvent.Post) {
val client = tickEvent.client
client.player ?: return
val playerData = VRClientAPI.instance().postTickWorldPose ?: return
val offHandData = playerData.offHand
// Keep up-to-date fakePartyEntities, which is done so we always have a Pokemon or PokeBall entity available to
// render and keep it ticking so we have proper animations.
val party = CobblemonClient.storage.party
// Handle the selected index, placing either a Pokemon or null
if (selectedIndex > -1) {
val actual = party.get(selectedIndex)
if (actual == null) {
fakePartyEntities[selectedIndex] = null
} else if (fakePartyEntities[selectedIndex] is PokemonEntity) {
fakePartyEntities[selectedIndex]!!.tick()
} else {
fakePartyEntities[selectedIndex] = PokemonEntity(client.level!!, actual)
}
}
// Handle the other indices, placing a pokeball or null
for (i in 0..5) {
if (i != selectedIndex) {
val actual = party.get(i)
if (actual == null) {
fakePartyEntities[i] = null
} else if (fakePartyEntities[i] !is EmptyPokeBallEntity) {
val pokeBall = EmptyPokeBallEntity(actual.caughtBall, client.level!!)
pokeBall.captureState = EmptyPokeBallEntity.CaptureState.FALL
fakePartyEntities[i] = pokeBall
} else {
fakePartyEntities[i]!!.tick()
}
}
}
// Check primary hand for overlap with any of the Pokemon
val centerPos = getCenterPos(offHandData)
selectedIndex = -1
for (i in 0..5) {
if (party.get(i) != null) {
val pokemonPos = getPokemonPos(centerPos, playerData.offHand, i)
if (playerData.mainHand.pos.distanceToSqr(pokemonPos) < DIST_SELECT_SQR) {
selectedIndex = i
break
}
}
}
}
private fun onRender(renderEvent: RenderEvent) {
if (renderEvent.stage != RenderEvent.Stage.AFTER_ENTITIES) return
val mc = Minecraft.getInstance()
val bufferSource = mc.renderBuffers().bufferSource()
val guiGraphics = GuiGraphics(mc, mc.renderBuffers().bufferSource())
val cameraPos = renderEvent.camera.getPosition()
val poseStack = guiGraphics.pose()
val partialTick = renderEvent.tickCounter.getGameTimeDeltaPartialTick(true)
val offHandData = VRClientAPI.instance().getWorldRenderPose()?.offHand ?: return
val centerPos = getCenterPos(offHandData)
for (i in 0..5) {
val pokemon = fakePartyEntities[i]
if (pokemon != null) {
poseStack.pushPose()
val pokemonPos = getPokemonPos(centerPos, offHandData, i)
val renderPos = Vec3(
-cameraPos.x + pokemonPos.x,
-cameraPos.y + pokemonPos.y,
-cameraPos.z + pokemonPos.z,
)
poseStack.translate(renderPos.x, renderPos.y, renderPos.z)
poseStack.scale(0.05f, 0.05f, 0.05f)
poseStack.mulPose(Axis.YN.rotation(offHandData.yaw.toFloat()))
poseStack.mulPose(Axis.XN.rotation(offHandData.pitch.toFloat()))
poseStack.mulPose(Axis.ZP.rotation(offHandData.roll.toFloat() + Math.PI.toFloat()))
mc.entityRenderDispatcher.getRenderer(pokemon).render(pokemon, 0f, partialTick, poseStack, bufferSource,
LightTexture.FULL_BRIGHT)
poseStack.popPose()
}
}
}
private fun getCenterPos(pose: VRBodyPartData): Vec3 {
return pose.pos.subtract(pose.dir.scale(0.125))
}
private fun getPokemonPos(centerPos: Vec3, controllerData: VRBodyPartData, index: Int): Vec3 {
var pos = centerPos
// Move to bottom of hand
var downVecF = Vector3f(0f, -0.0625f, 0f)
downVecF.rotate(Axis.ZP.rotation(controllerData.roll.toFloat()))
downVecF.rotate(Axis.XN.rotation(controllerData.pitch.toFloat()))
downVecF.rotate(Axis.YN.rotation(controllerData.yaw.toFloat()))
pos = pos.add(Vec3(downVecF.x.toDouble(), downVecF.y.toDouble(), downVecF.z.toDouble()))
// Move right or left based on index
val rightF = Vector3f(0f, 0f, 1f) // Default forward vector of Minecraft
rightF.rotate(Axis.YN.rotation(Math.PI.toFloat() / 2f))
rightF.rotate(Axis.ZP.rotation(controllerData.roll.toFloat()))
rightF.rotate(Axis.XN.rotation(controllerData.pitch.toFloat()))
rightF.rotate(Axis.YN.rotation(controllerData.yaw.toFloat()))
val right = Vec3(rightF.x.toDouble(), rightF.y.toDouble(), rightF.z.toDouble())
if (index > 2) {
pos = pos.add(right.scale(-0.0625))
} else {
pos = pos.add(right.scale(0.0625))
}
// Offset by -hand direction if on left, 0 if center, or +hand direction if right
return pos.add(controllerData.dir.scale(DIST_BETWEEN_HORIZONTAL * (index % 3 - 1)))
}
override fun getId(): ResourceLocation {
return INTERACT_ID
}
override fun isActive(
player: LocalPlayer,
hand: InteractionHand,
handPosition: Vec3
): Boolean {
return hand == InteractionHand.MAIN_HAND && selectedIndex > -1
}
override fun onPress(
player: LocalPlayer,
hand: InteractionHand
): Boolean {
// UUID lookup is done at press time since the Pokemon may have switched since initially hovered over, such
// as via commands.
val uuid = CobblemonClient.storage.party.get(selectedIndex)?.uuid ?: return false
CobblemonClient.storage.switchToPokemon(uuid)
return true
}
companion object {
const val DIST_BETWEEN_HORIZONTAL: Double = 0.125
const val DIST_BETWEEN_VERTICAL: Float = 0.05f
const val DIST_SELECT_SQR: Double = 0.1 * 0.1
val INTERACT_ID = ResourceLocation(Cobblemon.MODID, "party_on_arm_interact_module")
private val INSTANCE = PartyOnArm()
fun init() {
PlatformEvents.RENDER.subscribe(Consumer { renderEvent: RenderEvent? -> INSTANCE.onRender(renderEvent!!) })
PlatformEvents.CLIENT_TICK_POST.subscribe(Consumer { tickEvent: ClientTickEvent.Post? ->
INSTANCE.onTick(
tickEvent!!
)
})
VRAPI.instance().register(INSTANCE)
}
}
}
@@ -1,12 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
import org.vivecraft.api.data.VRBodyPart
import org.vivecraft.api.data.VRPose
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
interface ProximityListener {
fun isActive(registration: ProximityRegistration): Boolean = true
fun onEnter(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
fun onExit(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
fun onTick(bodyA: VRBodyPart, bodyB: VRBodyPart, pose: VRPose)
}
@@ -1,79 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
import com.cobblemon.mod.common.platform.events.ClientTickEvent
import com.cobblemon.mod.common.platform.events.PlatformEvents
import org.vivecraft.api.client.VRClientAPI
import kotlin.math.acos
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
class ProximityManager {
private val registrations = mutableListOf<ProximityRegistration>()
private val previousInProximity = mutableMapOf<ProximityRegistration, Boolean>()
private val api: VRClientAPI = VRClientAPI.instance()
fun register(registration: ProximityRegistration) {
registrations += registration
previousInProximity.putIfAbsent(registration, false)
}
fun unregister(registration: ProximityRegistration) {
registrations -= registration
previousInProximity.remove(registration)
}
fun clear() {
registrations.clear()
previousInProximity.clear()
}
fun isActive(registration: ProximityRegistration): Boolean {
return registration.listener.isActive(registration)
}
fun onTick(tickEvent: ClientTickEvent.Post) {
val vrPose = api.getPostTickWorldPose() ?: return
for (reg in registrations) {
if (!isActive(reg)) continue
val poseA = vrPose.getBodyPartData(reg.bodyA) ?: continue
val poseB = vrPose.getBodyPartData(reg.bodyB) ?: continue
val distance = poseA.pos.distanceTo(poseB.pos)
val dot = poseA.dir.dot(poseB.dir).coerceIn(-1.0, 1.0)
val angleDeg = Math.toDegrees(acos(dot)).toFloat()
val angleOk = angleDeg <= reg.angleThreshold
val nowInProximity = distance <= reg.distanceThreshold && angleOk
val wasInProximity = previousInProximity[reg] ?: false
if (!wasInProximity && nowInProximity) {
reg.listener.onEnter(reg.bodyA, reg.bodyB, vrPose)
} else if (wasInProximity && !nowInProximity) {
reg.listener.onExit(reg.bodyA, reg.bodyB, vrPose)
}
if (nowInProximity) {
reg.listener.onTick(reg.bodyA, reg.bodyB, vrPose)
}
previousInProximity[reg] = nowInProximity
}
}
companion object {
private val INSTANCE = ProximityManager()
fun init() {
PlatformEvents.CLIENT_TICK_POST.subscribe { tickEvent: ClientTickEvent.Post? ->
INSTANCE.onTick(
tickEvent!!
)
}
}
fun register(registration: ProximityRegistration) = INSTANCE.register(registration)
fun unregister(registration: ProximityRegistration) = INSTANCE.unregister(registration)
fun clearAll() = INSTANCE.clear()
}
}
@@ -1,12 +0,0 @@
package com.cobblemon.mod.common.client.integration.vivecraft.proximity
import org.vivecraft.api.data.VRBodyPart
// TODO: Make an PR to Vivecraft that adds this feature directly to Vivecraft
data class ProximityRegistration(
val bodyA: VRBodyPart,
val bodyB: VRBodyPart,
val distanceThreshold: Float,
val angleThreshold: Float = 180f,
val listener: ProximityListener
)
@@ -38,7 +38,6 @@ object CobblemonKeyBinds {
val PARTY_OVERLAY_DOWN = this.queue(DownShiftPartyBinding)
val PARTY_OVERLAY_UP = this.queue(UpShiftPartyBinding)
val SEND_OUT_POKEMON = this.queue(PartySendBinding)
val RIDING_FREELOOK = this.queue(RidingFreelookBinding)
fun register(registrar: (KeyMapping) -> Unit) {
this.keyBinds.forEach(registrar::invoke)
@@ -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.client.keybind.keybinds
import com.cobblemon.mod.common.client.keybind.CobblemonBlockingKeyBinding
import com.cobblemon.mod.common.client.keybind.KeybindCategories
import com.mojang.blaze3d.platform.InputConstants
object RidingFreelookBinding : CobblemonBlockingKeyBinding(
"key.cobblemon.ridingfreelook",
InputConstants.Type.KEYSYM,
InputConstants.KEY_LALT,
KeybindCategories.COBBLEMON_CATEGORY
) {
override fun onTick() {
}
override fun onRelease() {
}
override fun onPress() {
}
}
@@ -15,6 +15,7 @@ import com.cobblemon.mod.common.block.DisplayCaseBlock
import com.cobblemon.mod.common.block.entity.DisplayCaseBlockEntity
import com.cobblemon.mod.common.client.render.models.blockbench.repository.RenderContext
import com.cobblemon.mod.common.item.PokedexItem
import com.cobblemon.mod.common.item.WearableItem
import com.mojang.blaze3d.vertex.PoseStack
import com.mojang.math.Axis
import net.minecraft.client.Minecraft
@@ -31,9 +32,7 @@ class DisplayCaseRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntit
val context = RenderContext().also {
it.put(RenderContext.RENDER_STATE, RenderContext.RenderState.WORLD)
}
val coinPouchStack: ItemStack by lazy { ItemStack(
CobblemonItems.RELIC_COIN_POUCH
).also { it.set(DataComponents.CUSTOM_MODEL_DATA, CustomModelData(1)) } }
override fun render(
entity: DisplayCaseBlockEntity,
tickDelta: Float,
@@ -42,8 +41,8 @@ class DisplayCaseRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntit
light: Int,
overlay: Int
) {
val stack: ItemStack = if (entity.getStack().`is`(CobblemonItems.RELIC_COIN_POUCH)) {
coinPouchStack
val stack: ItemStack = if (entity.getStack().`is`(CobblemonItemTags.DISPLAY_CASE_ITEMS)) {
entity.getStack().copyWithCount(1).also { it.set(DataComponents.CUSTOM_MODEL_DATA, CustomModelData(1)) }
} else {
entity.getStack()
}
@@ -161,11 +160,13 @@ class DisplayCaseRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntit
stack.item is BannerItem -> PositioningType.BANNER
stack.`is`(CobblemonItemTags.POKE_BALLS) -> PositioningType.POKE_BALL
stack.item is PokedexItem -> PositioningType.POKEDEX
stack.item == CobblemonItems.RELIC_COIN_POUCH -> PositioningType.COIN_POUCH
stack.`is`(CobblemonItemTags.DISPLAY_CASE_ITEMS) -> PositioningType.ITEM_BLOCK
stack.item == CobblemonItems.PASTURE -> PositioningType.PASTURE
//stack.item == CobblemonItems.POKEMON_MODEL -> PositioningType.ITEM_MODEL
stack.item == Items.SHIELD -> PositioningType.SHIELD
stack.item == Items.DECORATED_POT -> PositioningType.MOB_HEAD
stack.item is WearableItem -> PositioningType.ITEM_MODEL
stack.`is`(CobblemonItemTags.PLAQUES) -> PositioningType.ITEM_MODEL
Minecraft.getInstance().itemRenderer.getModel(stack, world, null, 0).isGui3d -> PositioningType.BLOCK_MODEL
else -> PositioningType.ITEM_MODEL
}
@@ -185,6 +186,6 @@ class DisplayCaseRenderer(ctx: BlockEntityRendererProvider.Context) : BlockEntit
MOB_HEAD(1f, 1f, 1f, 0f, -0.025f, 0f, 180f),
SHIELD(1f, 1f, 1f, 0f, -0.045f, 0f, 180f),
PASTURE(1f, 1f, 1f, 0f, 0.0375f, 0f),
COIN_POUCH(1f, 1f, 1f, 0f, 0.415f, 0f)
ITEM_BLOCK(1f, 1f, 1f, 0f, 0.415f, 0f)
}
}
@@ -34,7 +34,6 @@ import net.minecraft.world.phys.HitResult
import net.minecraft.world.phys.Vec3
import org.joml.Matrix3f
import org.joml.Quaternionf
import org.joml.Vector3d
import org.joml.Vector3f
import kotlin.math.min
import kotlin.math.sign
@@ -79,15 +78,15 @@ object MountedCameraRenderer {
// Get additional offset from poser and add to the eyeHeight offset
val currEyeHeight: Double = Mth.lerp(instance.partialTickTime.toDouble(), eyeHeight, eyeHeightOld)
var offset = Vec3(0.0, currEyeHeight - (driver.bbHeight / 2), 0.0)
var eyeOffset = Vec3(0.0, currEyeHeight - (driver.bbHeight / 2), 0.0)
val offset = Vec3(0.0, currEyeHeight - (driver.bbHeight / 2), 0.0)
val eyeOffset = Vec3(0.0, currEyeHeight - (driver.bbHeight / 2), 0.0)
val shouldFlip = !(vehicleController.active && vehicleController.orientation != null) // Do not flip the offset for 3rd person reverse unless we are using normal mc camera rotation.
val isFirstPerson = Minecraft.getInstance().options.cameraType == CameraType.FIRST_PERSON
eyeOffset = eyeOffset.add(getFirstPersonOffset(model, locatorName))
eyeOffset.add(getFirstPersonOffset(model, locatorName))
// Get the offset based on first person, third person, or third person with view bobbing enabled from the posers.
offset = offset.add(
offset.add(
if (isFirstPerson) {
getFirstPersonOffset(model, locatorName)
} else /* if (Cobblemon.config.thirdPersonViewBobbing) */ {
@@ -102,8 +101,8 @@ object MountedCameraRenderer {
else Quaternionf()
.rotateY((Math.PI.toFloat() - Mth.lerp(instance.partialTickTime, vehicle.yRotO, vehicle.yRot).toRadians()))
offset = rotation.transform(Vector3d(offset.x, offset.y, offset.z)).let { Vec3(it.x, it.y, it.z) }
eyeOffset = rotation.transform(Vector3d(eyeOffset.x, eyeOffset.y, eyeOffset.z)).let { Vec3(it.x, it.y, it.z) }
rotation.transform(offset.toVector3f())
rotation.transform(eyeOffset.toVector3f())
val eyeLocatorOffset = Vec3(locator.matrix.getTranslation(Vector3f()))
val eyePos = eyeLocatorOffset.add(entityPos)
@@ -0,0 +1,120 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen9
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
import com.cobblemon.mod.common.client.render.models.blockbench.createTransformation
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
import com.cobblemon.mod.common.client.render.models.blockbench.pose.ModelPartTransformation
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
import com.cobblemon.mod.common.entity.PoseType
import com.cobblemon.mod.common.util.isBattling
import net.minecraft.client.model.geom.ModelPart
import net.minecraft.world.phys.Vec3
class TinkatinkModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
override val rootPart = root.registerChildWithAllChildren("tinkatink")
override val head = getPart("head")
override val rightArm = getPart("arm_right")
override val leftArm = getPart("arm_left")
override val rightLeg = getPart("leg_right")
override val leftLeg = getPart("leg_left")
override var portraitScale = 2.0F
override var portraitTranslation = Vec3(0.0, -1.01, 0.0)
override var profileScale = 1.0F
override var profileTranslation = Vec3(0.0, 0.25, 0.0)
lateinit var standing: Pose
lateinit var walking: Pose
lateinit var sleep: Pose
lateinit var battleidle: Pose
lateinit var shoulderLeft: Pose
lateinit var shoulderRight: Pose
val shoulderOffset = 1
override val cryAnimation = CryProvider { bedrockStateful("tinkatink", "cry") }
override fun registerPoses() {
val blink = quirk { bedrockStateful("tinkatink", "blink") }
sleep = registerPose(
poseType = PoseType.SLEEP,
animations = arrayOf(bedrock("tinkatink", "sleep"))
)
standing = registerPose(
poseName = "standing",
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
transformTicks = 10,
condition = { !it.isBattling },
quirks = arrayOf(blink),
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatink", "ground_idle")
)
)
walking = registerPose(
poseName = "walking",
poseTypes = PoseType.MOVING_POSES,
transformTicks = 10,
quirks = arrayOf(blink),
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatink", "ground_walk")
)
)
battleidle = registerPose(
poseName = "battle_idle",
poseTypes = PoseType.STATIONARY_POSES,
transformTicks = 10,
quirks = arrayOf(blink),
condition = { it.isBattling },
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatink", "battle_idle")
)
)
shoulderLeft = registerPose(
poseType = PoseType.SHOULDER_LEFT,
quirks = arrayOf(blink),
condition = { !it.isBattling },
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatink", "shoulder_left")
),
transformedParts = arrayOf(
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, shoulderOffset)
)
)
shoulderRight = registerPose(
poseType = PoseType.SHOULDER_RIGHT,
quirks = arrayOf(blink),
condition = { !it.isBattling },
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatink", "shoulder_right")
),
transformedParts = arrayOf(
rootPart.createTransformation().addPosition(ModelPartTransformation.X_AXIS, -shoulderOffset)
)
)
}
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walking, battleidle, sleep)) bedrockStateful("tinkatink", "faint") else null
}
@@ -0,0 +1,87 @@
/*
* Copyright (C) 2023 Cobblemon Contributors
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package com.cobblemon.mod.common.client.render.models.blockbench.pokemon.gen9
import com.cobblemon.mod.common.client.render.models.blockbench.PosableState
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BimanualFrame
import com.cobblemon.mod.common.client.render.models.blockbench.frame.BipedFrame
import com.cobblemon.mod.common.client.render.models.blockbench.frame.HeadedFrame
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.CryProvider
import com.cobblemon.mod.common.client.render.models.blockbench.pokemon.PokemonPosableModel
import com.cobblemon.mod.common.client.render.models.blockbench.pose.Pose
import com.cobblemon.mod.common.entity.PoseType
import com.cobblemon.mod.common.util.isBattling
import net.minecraft.client.model.geom.ModelPart
import net.minecraft.world.phys.Vec3
class TinkatuffModel (root: ModelPart) : PokemonPosableModel(root), HeadedFrame, BipedFrame, BimanualFrame {
override val rootPart = root.registerChildWithAllChildren("tinkatuff")
override val head = getPart("head")
override val rightArm = getPart("arm_right")
override val leftArm = getPart("arm_left")
override val rightLeg = getPart("leg_right")
override val leftLeg = getPart("leg_left")
override var portraitScale = 1.9F
override var portraitTranslation = Vec3(0.0, -0.41, 0.0)
override var profileScale = 0.9F
override var profileTranslation = Vec3(0.0, 0.4, 0.0)
lateinit var standing: Pose
lateinit var walking: Pose
lateinit var sleep: Pose
lateinit var battleidle: Pose
override val cryAnimation = CryProvider { bedrockStateful("tinkatuff", "cry") }
override fun registerPoses() {
val blink = quirk { bedrockStateful("tinkatuff", "blink") }
sleep = registerPose(
poseType = PoseType.SLEEP,
animations = arrayOf(bedrock("tinkatuff", "sleep"))
)
standing = registerPose(
poseName = "standing",
poseTypes = PoseType.STATIONARY_POSES + PoseType.UI_POSES,
transformTicks = 10,
condition = { !it.isBattling },
quirks = arrayOf(blink),
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatuff", "ground_idle")
)
)
walking = registerPose(
poseName = "walking",
poseTypes = PoseType.MOVING_POSES,
transformTicks = 10,
quirks = arrayOf(blink),
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatuff", "ground_walk")
)
)
battleidle = registerPose(
poseName = "battle_idle",
poseTypes = PoseType.STATIONARY_POSES,
transformTicks = 10,
quirks = arrayOf(blink),
condition = { it.isBattling },
animations = arrayOf(
singleBoneLook(),
bedrock("tinkatuff", "battle_idle")
)
)
}
override fun getFaintAnimation(state: PosableState) = if (state.isPosedIn(standing, walking, battleidle, sleep)) bedrockStateful("tinkatuff", "faint") else null
}
@@ -477,6 +477,8 @@ object VaryingModelRepository {
inbuilt("illumise", ::IllumiseModel)
inbuilt("yamper", ::YamperModel)
inbuilt("boltund", ::BoltundModel)
inbuilt("tinkatink", ::TinkatinkModel)
inbuilt("tinkatuff", ::TinkatuffModel)
inbuilt("fuecoco", :: FuecocoModel)
inbuilt("crocalor", :: CrocalorModel)
inbuilt("skeledirge", :: SkeledirgeModel)
@@ -39,16 +39,15 @@ class FollowWalkTargetTask(
private var lookTargetPos: BlockPos? = null
private var speed = 0f
override fun checkExtraStartConditions(level: ServerLevel, entity: PathfinderMob): Boolean {
override fun checkExtraStartConditions(arg: ServerLevel, arg2: PathfinderMob): Boolean {
if (this.pathUpdateCountdownTicks > 0) {
--this.pathUpdateCountdownTicks
return false
} else {
val brain = entity.brain
val brain = arg2.brain
val walkTarget = brain.getMemory(MemoryModuleType.WALK_TARGET).get()
val hasReached = this.hasReached(entity, walkTarget)
resetPathUpdateCountdownTicks(entity)
if (!hasReached && this.hasFinishedPath(entity, walkTarget, level.gameTime)) {
val hasReached = this.hasReached(arg2, walkTarget)
if (!hasReached && this.hasFinishedPath(arg2, walkTarget, arg.gameTime)) {
this.lookTargetPos = walkTarget.target.currentBlockPosition()
return true
} else {
@@ -62,10 +61,6 @@ class FollowWalkTargetTask(
}
}
fun resetPathUpdateCountdownTicks(entity: PathfinderMob) {
pathUpdateCountdownTicks = entity.random.nextInt(20) + 20
}
override fun canStillUse(arg: ServerLevel, arg2: PathfinderMob, l: Long): Boolean {
if (this.path != null && this.lookTargetPos != null) {
val optional = arg2.brain.getMemory(MemoryModuleType.WALK_TARGET)
@@ -80,7 +75,7 @@ class FollowWalkTargetTask(
override fun stop(world: ServerLevel, entity: PathfinderMob, l: Long) {
val walkTarget = entity.brain.getMemory(MemoryModuleType.WALK_TARGET).orElse(null)
if (walkTarget != null && !this.hasReached(entity, walkTarget) && entity.navigation.isStuck) {
resetPathUpdateCountdownTicks(entity)
this.pathUpdateCountdownTicks = world.getRandom().nextInt(40)
}
entity.navigation.stop()
@@ -186,7 +186,7 @@ class OmniPathNavigation(val world: Level, val entity: Mob) : GroundPathNavigati
val blockState = this.world.getBlockState(target)
val path = if (!blockState.isSolid
|| (blockState.`is`(BlockTags.LEAVES) && blockState.block == CobblemonBlocks.SACCHARINE_LEAVES && pather.canPathThroughSaccLeaves())) {
|| (blockState.`is`(BlockTags.LEAVES) && blockState.block == CobblemonBlocks.SACCHARINE_LEAVES && (this.entity as PokemonEntity).canPathThroughSaccLeaves())) {
findPath(target, distance)
} else {
blockPos = target.above()
@@ -269,7 +269,7 @@ class OmniPathNavigation(val world: Level, val entity: Mob) : GroundPathNavigati
// If we can fly and we're airborne, return the current Y position
return vec.y
}
if (world.getBlockState(blockPos).block == CobblemonBlocks.SACCHARINE_LEAVES && pather.canPathThroughSaccLeaves()) {
if (world.getBlockState(blockPos).block == CobblemonBlocks.SACCHARINE_LEAVES && (this.entity as PokemonEntity).canPathThroughSaccLeaves()) {
return vec.y + 0.5
}
return if ((canFloat()) && blockGetter.getFluidState(blockPos).`is`(FluidTags.WATER)) vec.y + 0.5 else super.getGroundY(vec)
@@ -802,14 +802,13 @@ class PokeRodFishingBobberEntity(type: EntityType<out PokeRodFishingBobberEntity
spawnAction.complete()
val result = spawnAction.future
val resultingSpawn = result.get()
if (resultingSpawn == null) {
if (result.isCompletedExceptionally) {
noBite(player)
return false
}
var spawnedPokemon: PokemonEntity? = null
val resultingSpawn = result.get()
if (resultingSpawn is EntitySpawnResult) {
for (entity in resultingSpawn.entities) {
@@ -547,11 +547,6 @@ open class PokemonEntity(
ifRidingAvailable { _, _, state -> pokemon.rideStamina = state.stamina.get() }
ridingController?.context?.state?.reset()
ridingAnimationData.clear()
// reset riding orientation
if (this is OrientationControllable) {
this.orientationController.reset()
}
}
}
@@ -1282,7 +1277,7 @@ open class PokemonEntity(
}
override fun shouldBeSaved(): Boolean {
if (ownerUUID == null && !pokemon.isNPCOwned() && (Cobblemon.config.savePokemonToWorld || isPersistenceRequired)) {
if (ownerUUID == null && !pokemon.isNPCOwned() && (Cobblemon.config.savePokemonToWorld || isPersistenceRequired || this.pokemon.canDropHeldItem)) {
CobblemonEvents.POKEMON_ENTITY_SAVE_TO_WORLD.postThen(PokemonEntitySaveToWorldEvent(this)) {
return true
}
@@ -10,11 +10,8 @@ package com.cobblemon.mod.common.entity.pokemon.ai.sensors
import com.cobblemon.mod.common.CobblemonMemories
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.util.getMemorySafely
import net.minecraft.server.level.ServerLevel
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.Mob
import net.minecraft.world.entity.ai.memory.MemoryModuleType
import net.minecraft.world.entity.ai.memory.NearestVisibleLivingEntities
import net.minecraft.world.entity.ai.sensing.Sensor
@@ -31,17 +28,8 @@ class DefendOwnerSensor : Sensor<PokemonEntity>(10) {
}
private fun setNearestAttacker(entity: PokemonEntity, visibleMobs: NearestVisibleLivingEntities, owner: LivingEntity) {
val nearestAttacker = visibleMobs.findClosest { livingEntity ->
// Prevents Pokémons from attacking players as owned Pokémons are currently invulnerable
if (livingEntity is ServerPlayer) return@findClosest false
if (livingEntity.lastHurtMob == owner) return@findClosest true
if (livingEntity is Mob && livingEntity.target == owner) return@findClosest true
val mobAttackTarget = livingEntity.brain.getMemorySafely(MemoryModuleType.ATTACK_TARGET)
if (mobAttackTarget.isPresent && mobAttackTarget.get() == owner) return@findClosest true
return@findClosest false
val nearestAttacker = visibleMobs.findClosest { mob ->
mob.lastHurtMob == owner
}.map { mob -> mob as LivingEntity }
entity.brain.setMemory(CobblemonMemories.NEAREST_VISIBLE_ATTACKER, nearestAttacker)
@@ -10,10 +10,18 @@ package com.cobblemon.mod.common.entity.pokemon.ai.tasks
import com.cobblemon.mod.common.CobblemonMemories
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.google.common.collect.ImmutableMap
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.ai.attributes.Attributes
import net.minecraft.world.entity.ai.behavior.Behavior
import net.minecraft.world.entity.ai.behavior.OneShot
import net.minecraft.world.entity.ai.behavior.declarative.BehaviorBuilder
import net.minecraft.world.entity.ai.behavior.declarative.Trigger
import net.minecraft.world.entity.ai.memory.MemoryModuleType
import net.minecraft.world.entity.ai.memory.MemoryStatus
import net.minecraft.world.entity.ai.memory.WalkTarget
import net.minecraft.world.entity.ai.targeting.TargetingConditions
object DefendOwnerTask {
fun create(): OneShot<PokemonEntity> {
@@ -52,9 +52,8 @@ object PlaceHoneyInHiveTask {
if (blockEntity.isFull) {
// Erase Hive memory and give the bee a moment to locate a new hive
entity.brain.eraseMemory(CobblemonMemories.HIVE_LOCATION)
} else {
blockEntity.addOccupant(entity)
}
blockEntity.addOccupant(entity)
}
return@Trigger true
@@ -1,16 +0,0 @@
package com.cobblemon.mod.common.integration.vivecraft
import com.cobblemon.mod.common.client.integration.vivecraft.listener.swing.PokeBallSwingListener
import com.cobblemon.mod.common.client.integration.vivecraft.listener.swing.PokeRodSwingListener
import org.vivecraft.api.VRAPI
class CobblemonVR {
fun init() {
VRAPI.instance()
.register(PokeBallSwingListener())
VRAPI.instance()
.register(PokeRodSwingListener())
}
}
@@ -23,7 +23,7 @@ import net.minecraft.world.level.Level
import kotlin.math.cos
class PokeBallItem(
val pokeBall: PokeBall
val pokeBall: PokeBall
) : CobblemonItem(Properties().apply {
when (pokeBall.name) {
// Master balls are a netherite product and should be fire immune
@@ -43,7 +43,7 @@ class PokeBallItem(
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
}
fun throwPokeBall(world: Level, player: ServerPlayer) {
private fun throwPokeBall(world: Level, player: ServerPlayer) {
val pokeBallEntity = EmptyPokeBallEntity(pokeBall, player.level(), player).apply {
val overhandFactor: Float = if (player.xRot < 0) {
5f * cos(player.xRot.toRadians())
@@ -57,5 +57,4 @@ class PokeBallItem(
}
world.addFreshEntity(pokeBallEntity)
}
}
@@ -10,10 +10,20 @@ package com.cobblemon.mod.common.item
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.EquipmentSlot
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.Equipable
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.context.BlockPlaceContext
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.level.block.Blocks
import net.minecraft.world.level.block.state.BlockState
class WearableItem(val name: String): CobblemonItem(Properties()), Equipable {
class WearableItem(val name: String, block: Block = Blocks.AIR): ItemNameBlockItem(block, Properties()), Equipable {
companion object {
const val MODEL_PATH = "item/wearable"
}
@@ -22,4 +32,17 @@ class WearableItem(val name: String): CobblemonItem(Properties()), Equipable {
fun getModel2d(): ResourceLocation = cobblemonResource(this.name)
override fun getEquipmentSlot(): EquipmentSlot { return EquipmentSlot.HEAD }
override fun use(level: Level, player: Player, usedHand: InteractionHand): InteractionResultHolder<ItemStack> {
return this.swapWithEquipmentSlot(this, level, player, usedHand)
}
override fun getDescriptionId(): String {
return if (block == Blocks.AIR) this.getOrCreateDescriptionId() else super.getDescriptionId()
}
override fun canPlace(context: BlockPlaceContext, state: BlockState): Boolean {
//not all wearable items are placeable, so we default it to AIR and prevent placement in that case
return if (state.block == Blocks.AIR) false else super.canPlace(context, state)
}
}
@@ -13,10 +13,11 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.*
import net.minecraft.world.level.block.Block
class DireHitItem : CobblemonItem(Properties()), SimpleBagItemLike {
class DireHitItem(block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.dire_hit"
override val returnItem = Items.AIR
@@ -13,9 +13,10 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.*
import net.minecraft.world.level.block.Block
class GuardSpecItem : CobblemonItem(Properties()), SimpleBagItemLike {
class GuardSpecItem(block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.guard_spec"
override val returnItem = Items.AIR
@@ -14,9 +14,10 @@ import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.item.CobblemonItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.world.item.*
import net.minecraft.world.level.block.Block
class XStatItem(val stat: Stat, stages: Int = 2) : CobblemonItem(Properties()), SimpleBagItemLike {
class XStatItem(val stat: Stat, stages: Int = 2, block: Block) : ItemNameBlockItem(block, Properties()), SimpleBagItemLike {
override val bagItem = object : BagItem {
override val itemName = "item.cobblemon.x_${stat.identifier.path}"
override val returnItem = Items.AIR
@@ -66,6 +66,7 @@ object CobblemonItemGroups {
@JvmStatic val EVOLUTION_ITEMS get() = BuiltInRegistries.CREATIVE_MODE_TAB.get(EVOLUTION_ITEMS_KEY)
@JvmStatic val BUILDING_BLOCKS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("building_blocks")), this::blocksInjections)
@JvmStatic val COLORED_BLOCKS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("colored_blocks")), this::colorInjections)
@JvmStatic val FOOD_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("food_and_drinks")), this::foodInjections)
@JvmStatic val TOOLS_AND_UTILITIES_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("tools_and_utilities")), this::toolsAndUtilitiesInjections)
@JvmStatic val INGREDIENTS_INJECTIONS = this.inject(ResourceKey.create(BuiltInRegistries.CREATIVE_MODE_TAB.key(), ResourceLocation.parse("ingredients")), this::ingredientsInjections)
@@ -319,6 +320,7 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.SMOOTH_TUMBLESTONE)
entries.accept(CobblemonItems.SMOOTH_TUMBLESTONE_STAIRS)
entries.accept(CobblemonItems.SMOOTH_TUMBLESTONE_SLAB)
entries.accept(CobblemonItems.POLISHED_BLACK_TUMBLESTONE)
entries.accept(CobblemonItems.POLISHED_BLACK_TUMBLESTONE_STAIRS)
entries.accept(CobblemonItems.POLISHED_BLACK_TUMBLESTONE_SLAB)
@@ -332,6 +334,7 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.SMOOTH_BLACK_TUMBLESTONE)
entries.accept(CobblemonItems.SMOOTH_BLACK_TUMBLESTONE_STAIRS)
entries.accept(CobblemonItems.SMOOTH_BLACK_TUMBLESTONE_SLAB)
entries.accept(CobblemonItems.POLISHED_SKY_TUMBLESTONE)
entries.accept(CobblemonItems.POLISHED_SKY_TUMBLESTONE_STAIRS)
entries.accept(CobblemonItems.POLISHED_SKY_TUMBLESTONE_SLAB)
@@ -381,7 +384,100 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.THUNDER_STONE_BLOCK)
entries.accept(CobblemonItems.WATER_STONE_BLOCK)
entries.accept(CobblemonItems.PEAT_BLOCK)
CobblemonItems.campfire_pots.forEach(entries::accept)
entries.accept(CobblemonItems.WHITE_PLAQUE)
entries.accept(CobblemonItems.LIGHT_GRAY_PLAQUE)
entries.accept(CobblemonItems.GRAY_PLAQUE)
entries.accept(CobblemonItems.BLACK_PLAQUE)
entries.accept(CobblemonItems.BROWN_PLAQUE)
entries.accept(CobblemonItems.RED_PLAQUE)
entries.accept(CobblemonItems.ORANGE_PLAQUE)
entries.accept(CobblemonItems.YELLOW_PLAQUE)
entries.accept(CobblemonItems.LIME_PLAQUE)
entries.accept(CobblemonItems.GREEN_PLAQUE)
entries.accept(CobblemonItems.CYAN_PLAQUE)
entries.accept(CobblemonItems.LIGHT_BLUE_PLAQUE)
entries.accept(CobblemonItems.BLUE_PLAQUE)
entries.accept(CobblemonItems.PURPLE_PLAQUE)
entries.accept(CobblemonItems.MAGENTA_PLAQUE)
entries.accept(CobblemonItems.PINK_PLAQUE)
//Decorative Items - Easy to move around if we later want down here
entries.accept(CobblemonItems.CHIPPED_POT)
entries.accept(CobblemonItems.CRACKED_POT)
entries.accept(CobblemonItems.MASTERPIECE_TEACUP)
entries.accept(CobblemonItems.UNREMARKABLE_TEACUP)
entries.accept(CobblemonItems.DESTINY_KNOT)
entries.accept(CobblemonItems.EJECT_BUTTON)
entries.accept(CobblemonItems.FLAME_ORB)
entries.accept(CobblemonItems.TOXIC_ORB)
entries.accept(CobblemonItems.LIFE_ORB)
entries.accept(CobblemonItems.LIGHT_BALL)
entries.accept(CobblemonItems.SMOKE_BALL)
entries.accept(CobblemonItems.IRON_BALL)
entries.accept(CobblemonItems.HARD_STONE)
entries.accept(CobblemonItems.DAMP_ROCK)
entries.accept(CobblemonItems.HEAT_ROCK)
entries.accept(CobblemonItems.ICY_ROCK)
entries.accept(CobblemonItems.SMOOTH_ROCK)
entries.accept(CobblemonItems.KINGS_ROCK)
entries.accept(CobblemonItems.NEVER_MELT_ICE)
entries.accept(CobblemonItems.GALARICA_CUFF)
entries.accept(CobblemonItems.GALARICA_WREATH)
entries.accept(CobblemonItems.LUMINOUS_MOSS)
entries.accept(CobblemonItems.MAGNET)
entries.accept(CobblemonItems.METRONOME)
entries.accept(CobblemonItems.RING_TARGET)
entries.accept(CobblemonItems.BRIGHT_POWDER)
entries.accept(CobblemonItems.METAL_POWDER)
entries.accept(CobblemonItems.QUICK_POWDER)
entries.accept(CobblemonItems.SACHET)
entries.accept(CobblemonItems.METAL_COAT)
entries.accept(CobblemonItems.UPGRADE)
entries.accept(CobblemonItems.DUBIOUS_DISC)
entries.accept(CobblemonItems.CLEANSE_TAG)
entries.accept(CobblemonItems.SPELL_TAG)
entries.accept(CobblemonItems.BLUNDER_POLICY)
entries.accept(CobblemonItems.WEAKNESS_POLICY)
entries.accept(CobblemonItems.POTION)
entries.accept(CobblemonItems.SUPER_POTION)
entries.accept(CobblemonItems.HYPER_POTION)
entries.accept(CobblemonItems.MAX_POTION)
entries.accept(CobblemonItems.FULL_RESTORE)
entries.accept(CobblemonItems.ANTIDOTE)
entries.accept(CobblemonItems.AWAKENING)
entries.accept(CobblemonItems.BURN_HEAL)
entries.accept(CobblemonItems.ICE_HEAL)
entries.accept(CobblemonItems.PARALYZE_HEAL)
entries.accept(CobblemonItems.FULL_HEAL)
entries.accept(CobblemonItems.ETHER)
entries.accept(CobblemonItems.MAX_ETHER)
entries.accept(CobblemonItems.ELIXIR)
entries.accept(CobblemonItems.MAX_ELIXIR)
entries.accept(CobblemonItems.X_ATTACK)
entries.accept(CobblemonItems.X_DEFENSE)
entries.accept(CobblemonItems.X_SP_ATK)
entries.accept(CobblemonItems.X_SP_DEF)
entries.accept(CobblemonItems.X_SPEED)
entries.accept(CobblemonItems.X_ACCURACY)
entries.accept(CobblemonItems.DIRE_HIT)
entries.accept(CobblemonItems.GUARD_SPEC)
entries.accept(CobblemonItems.HP_UP)
entries.accept(CobblemonItems.PROTEIN)
entries.accept(CobblemonItems.IRON)
entries.accept(CobblemonItems.CALCIUM)
entries.accept(CobblemonItems.ZINC)
entries.accept(CobblemonItems.CARBOS)
entries.accept(CobblemonItems.PP_UP)
entries.accept(CobblemonItems.PP_MAX)
}
private fun consumableEntries(displayContext: ItemDisplayParameters, entries: Output) {
@@ -590,8 +686,8 @@ object CobblemonItemGroups {
entries.accept(CobblemonItems.TART_APPLE)
entries.accept(CobblemonItems.SWEET_APPLE)
entries.accept(CobblemonItems.SYRUPY_APPLE)
entries.accept(CobblemonItems.CRACKED_POT)
entries.accept(CobblemonItems.CHIPPED_POT)
entries.accept(CobblemonItems.CRACKED_POT)
entries.accept(CobblemonItems.MASTERPIECE_TEACUP)
entries.accept(CobblemonItems.UNREMARKABLE_TEACUP)
entries.accept(CobblemonItems.STRAWBERRY_SWEET)
@@ -765,6 +861,25 @@ object CobblemonItemGroups {
}
}
private fun colorInjections(injector: Injector) {
injector.putLast(CobblemonItems.WHITE_PLAQUE)
injector.putAfter(CobblemonItems.LIGHT_GRAY_PLAQUE, CobblemonItems.WHITE_PLAQUE)
injector.putAfter(CobblemonItems.GRAY_PLAQUE, CobblemonItems.LIGHT_GRAY_PLAQUE)
injector.putAfter(CobblemonItems.BLACK_PLAQUE, CobblemonItems.GRAY_PLAQUE)
injector.putAfter(CobblemonItems.BROWN_PLAQUE, CobblemonItems.BLACK_PLAQUE)
injector.putAfter(CobblemonItems.RED_PLAQUE, CobblemonItems.BROWN_PLAQUE)
injector.putAfter(CobblemonItems.ORANGE_PLAQUE, CobblemonItems.RED_PLAQUE)
injector.putAfter(CobblemonItems.YELLOW_PLAQUE, CobblemonItems.ORANGE_PLAQUE)
injector.putAfter(CobblemonItems.LIME_PLAQUE, CobblemonItems.YELLOW_PLAQUE)
injector.putAfter(CobblemonItems.GREEN_PLAQUE, CobblemonItems.LIME_PLAQUE)
injector.putAfter(CobblemonItems.CYAN_PLAQUE, CobblemonItems.GREEN_PLAQUE)
injector.putAfter(CobblemonItems.LIGHT_BLUE_PLAQUE, CobblemonItems.CYAN_PLAQUE)
injector.putAfter(CobblemonItems.BLUE_PLAQUE, CobblemonItems.LIGHT_BLUE_PLAQUE)
injector.putAfter(CobblemonItems.PURPLE_PLAQUE, CobblemonItems.BLUE_PLAQUE)
injector.putAfter(CobblemonItems.MAGENTA_PLAQUE, CobblemonItems.PURPLE_PLAQUE)
injector.putAfter(CobblemonItems.PINK_PLAQUE, CobblemonItems.MAGENTA_PLAQUE)
}
private fun foodInjections(injector: Injector) {
injector.putAfter(CobblemonItems.TART_APPLE, Items.ENCHANTED_GOLDEN_APPLE)
injector.putAfter(CobblemonItems.SWEET_APPLE, CobblemonItems.TART_APPLE)
@@ -0,0 +1,58 @@
/*
* 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.interactive
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.pokemon.stats.ItemEvSource
import com.cobblemon.mod.common.api.pokemon.stats.Stat
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.pokemon.EVs
import com.cobblemon.mod.common.pokemon.Pokemon
import net.minecraft.server.level.ServerPlayer
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemNameBlockItem
import net.minecraft.world.item.ItemStack
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
abstract class EVIncreaseBlockItem(
val stat: Stat,
val evIncreaseAmount: Int, block: Block
) : ItemNameBlockItem(block, 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)
abstract val sound: SoundEvent
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
pokemon: Pokemon
): InteractionResultHolder<ItemStack> {
val evsGained = pokemon.evs.add(stat, evIncreaseAmount, ItemEvSource(player, stack, pokemon))
return if (evsGained > 0) {
pokemon.entity?.playSound(sound, 1F, 1F)
stack.consume(1, player)
InteractionResultHolder.success(stack)
} else {
InteractionResultHolder.fail(stack)
}
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (user is ServerPlayer) {
return use(user, user.getItemInHand(hand))
}
return InteractionResultHolder.success(user.getItemInHand(hand))
}
}
@@ -13,9 +13,11 @@ import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.getBattleState
import com.cobblemon.mod.common.util.giveOrDropItemStack
import kotlin.math.min
import net.minecraft.world.entity.player.Player
@@ -24,9 +26,13 @@ import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.level.ServerLevel
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.item.ItemNameBlockItem
import net.minecraft.world.item.Rarity
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* Items for recovering PP in all moves at once.
@@ -35,8 +41,8 @@ import net.minecraft.world.level.Level
* @since June 30th, 2023
*/
class ElixirItem(
val max: Boolean
) : CobblemonItem(Properties().apply {
val max: Boolean, block: Block
) : ItemNameBlockItem(block, Properties().apply {
if (max) rarity(Rarity.UNCOMMON)
}), PokemonSelectingItem {
override val bagItem = object : BagItem {
@@ -82,9 +88,8 @@ class ElixirItem(
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (world is ServerLevel && user is ServerPlayer) {
val stack = user.getItemInHand(hand)
return use(user, stack)
return use(user, user.getItemInHand(hand))
}
return InteractionResultHolder.success(user.getItemInHand(hand))
return super<ItemNameBlockItem>.use(world, user, hand)
}
}
@@ -14,9 +14,11 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonAndMoveSelectingItem
import com.cobblemon.mod.common.api.moves.Move
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.getBattleState
import com.cobblemon.mod.common.util.giveOrDropItemStack
import kotlin.math.min
import net.minecraft.world.entity.player.Player
@@ -25,9 +27,13 @@ import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
import net.minecraft.server.level.ServerLevel
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.item.ItemNameBlockItem
import net.minecraft.world.item.Rarity
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* Item for recovering PP for a specific move in a Pokémon's move list. Opens a move selection GUI.
@@ -36,8 +42,8 @@ import net.minecraft.world.level.Level
* @since June 30th, 2023
*/
class EtherItem(
val max: Boolean
) : CobblemonItem(Properties().apply {
val max: Boolean, block: Block
) : ItemNameBlockItem(block, Properties().apply {
if (max) rarity(Rarity.UNCOMMON)
}), PokemonAndMoveSelectingItem {
override val bagItem = object : BagItem {
@@ -70,6 +76,6 @@ class EtherItem(
if (world is ServerLevel && user is ServerPlayer) {
return use(user, user.getItemInHand(hand)) ?: InteractionResultHolder.pass(user.getItemInHand(hand))
}
return InteractionResultHolder.success(user.getItemInHand(hand))
return super<ItemNameBlockItem>.use(world, user, hand)
}
}
@@ -18,12 +18,13 @@ import net.minecraft.world.item.ItemStack
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.Rarity
import net.minecraft.world.item.*
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
class PPUpItem(
val amount: Int
) : CobblemonItem(Properties().apply {
val amount: Int, block: Block
) : ItemNameBlockItem(block, Properties().apply {
if (amount>1) rarity(Rarity.UNCOMMON)
}), PokemonAndMoveSelectingItem {
@@ -75,8 +75,7 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
if (baitCount > 1) {
baitStack.count = baitCount - 1
stack.set(
CobblemonItemComponents.BAIT, RodBaitComponent(baitStack)
stack.set(CobblemonItemComponents.BAIT, RodBaitComponent(baitStack)
)
}
}
@@ -150,163 +149,90 @@ class PokerodItem(val pokeRodId: ResourceLocation, settings: Properties) : Fishi
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
val itemStack = user.getItemInHand(hand)
val offHandItem = user.getItemInHand(InteractionHand.OFF_HAND)
attemptApplyOffhandBait(world, user, itemStack, offHandItem)?.let { return it }
// Check if offhand item is valid bait and the rod is not in use, if so then apply bait from offhand
if (!world.isClientSide && user.fishing == null && SpawnBaitEffects.isFishingBait(offHandItem)) {
CobblemonEvents.BAIT_SET_PRE.postThen(BaitSetEvent(itemStack, offHandItem), { event ->
return InteractionResultHolder.fail(itemStack)
}, {
playAttachSound(user)
if (user.fishing != null) {
attemptReel(world, user, hand, itemStack)?.let { return it }
} else {
attemptCast(world, user, hand, itemStack)?.let { return it }
// if there is bait on the rod already then drop it on the ground before applying offhand bait
val baitStack = getBaitStackOnRod(itemStack)
if (baitStack != ItemStack.EMPTY && offHandItem.item != baitStack.item) {
user.drop(baitStack, true) // Drop the full stack
// apply single bait item from offhand
val singleBait = offHandItem.copy()
singleBait.count = 1
setBait(itemStack, singleBait)
offHandItem.shrink(1)
}
})
}
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
}
fun applyBait(
rodStack: ItemStack,
baitSource: ItemStack,
player: Player?
): Boolean {
if (baitSource.isEmpty || !SpawnBaitEffects.isFishingBait(baitSource)) return false
val existingBait = getBaitStackOnRod(rodStack)
if (!existingBait.isEmpty && existingBait.item == baitSource.item) return false
var applied = false
CobblemonEvents.BAIT_SET_PRE.postThen(
BaitSetEvent(rodStack, baitSource),
{ return false },
{
if (!existingBait.isEmpty && player != null) {
player.drop(existingBait, true)
}
val singleBait = baitSource.copy()
singleBait.count = 1
setBait(rodStack, singleBait)
baitSource.shrink(1)
applied = true
var i: Int
if (user.fishing != null) { // if the bobber is out yet
if (!world.isClientSide) {
CobblemonEvents.POKEROD_REEL.postThen(
PokerodReelEvent(user, itemStack),
{ event -> return InteractionResultHolder.fail(itemStack) },
{ event ->
i = user.fishing!!.retrieve(itemStack)
itemStack.hurtAndBreak(i, user, hand.toEquipmentSlot())
world.playSoundServer(
Vec3(user.x,
user.y,
user.z),
CobblemonSounds.FISHING_ROD_REEL_IN,
SoundSource.PLAYERS,
1.0f,
1.0f / (world.getRandom().nextFloat() * 0.4f + 0.8f)
)
}
)
}
)
return applied
}
fun attemptApplyOffhandBait(
world: Level,
user: Player,
rodStack: ItemStack,
offHandItem: ItemStack
): InteractionResultHolder<ItemStack>? {
if (world.isClientSide) return null
if (user.fishing != null) return null
world.playSound(null as Player?, user.x, user.y, user.z, CobblemonSounds.FISHING_ROD_REEL_IN, SoundSource.PLAYERS, 1.0f, 1.0f)
user.gameEvent(GameEvent.ITEM_INTERACT_FINISH)
} else { // if the bobber is not out yet
val applied = applyBait(
rodStack = rodStack,
baitSource = offHandItem,
player = user
)
if (!world.isClientSide) {
val lureLevel = world.enchantmentRegistry.getHolder(Enchantments.LURE).map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }.orElse(0)
val luckLevel = world.enchantmentRegistry.getHolder(Enchantments.LUCK_OF_THE_SEA).map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }.orElse(0)
if (applied) {
playAttachSound(user)
return InteractionResultHolder.sidedSuccess(rodStack, false)
val bobberEntity = PokeRodFishingBobberEntity(
user,
pokeRodId,
getBaitStackOnRod(itemStack),
world,
luckLevel,
lureLevel,
itemStack
)
CobblemonEvents.POKEROD_CAST_PRE.postThen(
PokerodCastEvent.Pre(itemStack, bobberEntity, getBaitStackOnRod(itemStack)),
{ event -> return InteractionResultHolder.fail(itemStack) },
{ event ->
world.addFreshEntity(bobberEntity)
var baitId = getBaitStackOnRod(itemStack).takeUnless { it.isEmpty }?.itemHolder?.unwrapKey()?.orElse(null)?.location() ?: cobblemonResource("empty_bait")
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, CastPokeRodContext(baitId))
CobblemonEvents.POKEROD_CAST_POST.post(
PokerodCastEvent.Post(itemStack, bobberEntity, getBaitStackOnRod(itemStack))
)
}
)
}
user.awardStat(Stats.ITEM_USED.get(this))
user.gameEvent(GameEvent.ITEM_INTERACT_START)
}
return null
}
fun attemptReel(
world: Level,
user: Player,
hand: InteractionHand,
itemStack: ItemStack
): InteractionResultHolder<ItemStack>? {
if (user.fishing == null) return null
if (!world.isClientSide) {
CobblemonEvents.POKEROD_REEL.postThen(
PokerodReelEvent(user, itemStack),
{ event -> return InteractionResultHolder.fail(itemStack) },
{ event ->
val i = user.fishing!!.retrieve(itemStack)
itemStack.hurtAndBreak(i, user, hand.toEquipmentSlot())
world.playSoundServer(
Vec3(user.x, user.y, user.z),
CobblemonSounds.FISHING_ROD_REEL_IN,
SoundSource.PLAYERS,
1.0f,
1.0f / (world.getRandom().nextFloat() * 0.4f + 0.8f)
)
}
)
}
world.playSound(
null as Player?,
user.x,
user.y,
user.z,
CobblemonSounds.FISHING_ROD_REEL_IN,
SoundSource.PLAYERS,
1.0f,
1.0f
)
user.gameEvent(GameEvent.ITEM_INTERACT_FINISH)
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
}
fun attemptCast(
world: Level,
user: Player,
hand: InteractionHand,
itemStack: ItemStack
): InteractionResultHolder<ItemStack>? {
if (user.fishing != null) return null
if (!world.isClientSide) {
val lureLevel = world.enchantmentRegistry.getHolder(Enchantments.LURE)
.map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }
.orElse(0)
val luckLevel = world.enchantmentRegistry.getHolder(Enchantments.LUCK_OF_THE_SEA)
.map { EnchantmentHelper.getItemEnchantmentLevel(it, itemStack) }
.orElse(0)
val bobberEntity = PokeRodFishingBobberEntity(
user,
pokeRodId,
getBaitStackOnRod(itemStack),
world,
luckLevel,
lureLevel,
itemStack
)
CobblemonEvents.POKEROD_CAST_PRE.postThen(
PokerodCastEvent.Pre(itemStack, bobberEntity, getBaitStackOnRod(itemStack)),
{ event -> return InteractionResultHolder.fail(itemStack) },
{ event ->
world.addFreshEntity(bobberEntity)
val baitId = getBaitStackOnRod(itemStack).takeUnless { it.isEmpty }
?.itemHolder?.unwrapKey()?.orElse(null)?.location()
?: cobblemonResource("empty_bait")
CobblemonCriteria.CAST_POKE_ROD.trigger(user as ServerPlayer, CastPokeRodContext(baitId))
CobblemonEvents.POKEROD_CAST_POST.post(
PokerodCastEvent.Post(itemStack, bobberEntity, getBaitStackOnRod(itemStack))
)
}
)
}
user.awardStat(Stats.ITEM_USED.get(this))
user.gameEvent(GameEvent.ITEM_INTERACT_START)
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide)
}
@@ -23,6 +23,7 @@ import net.minecraft.world.level.Level
class PonigiriItem : Item(
Properties().stacksTo(64)
.food(FoodProperties.Builder()
.alwaysEdible()
.nutrition(2)
.saturationModifier(0.55f)
.build())
@@ -8,6 +8,7 @@
package com.cobblemon.mod.common.item.interactive
import com.cobblemon.mod.common.CobblemonBlocks
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.battles.model.PokemonBattle
import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
@@ -17,28 +18,37 @@ import com.cobblemon.mod.common.api.item.HealingSource
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.molang.ExpressionLike
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.asExpressionLike
import com.cobblemon.mod.common.util.genericRuntime
import com.cobblemon.mod.common.util.getBattleState
import com.cobblemon.mod.common.util.giveOrDropItemStack
import com.cobblemon.mod.common.util.resolveInt
import net.minecraft.server.level.ServerLevel
import java.lang.Integer.min
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
import net.minecraft.world.InteractionResult
import net.minecraft.world.InteractionResultHolder
import net.minecraft.world.item.Rarity
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.item.*
import net.minecraft.world.item.context.UseOnContext
import net.minecraft.world.level.ClipContext
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
import net.minecraft.world.phys.BlockHitResult
import net.minecraft.world.phys.HitResult
class PotionItem(
val type: PotionType
) : CobblemonItem(Properties().apply {
val type: PotionType,
block: Block
) : ItemNameBlockItem(block, Properties().apply {
when (type.name) {
PotionType.MAX_POTION.name -> rarity(Rarity.UNCOMMON)
PotionType.MAX_POTION.name,
PotionType.FULL_RESTORE.name -> rarity(Rarity.UNCOMMON)
}
}), PokemonSelectingItem, HealingSource {
@@ -46,10 +56,10 @@ class PotionItem(
override val bagItem = type
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = !pokemon.isFullHealth() && pokemon.currentHealth > 0
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (user is ServerPlayer) {
if (world is ServerLevel && user is ServerPlayer) {
return use(user, user.getItemInHand(hand))
}
return InteractionResultHolder.success(user.getItemInHand(hand))
return super<ItemNameBlockItem>.use(world, user, hand)
}
override fun applyToPokemon(
@@ -14,17 +14,24 @@ import com.cobblemon.mod.common.api.battles.model.actor.BattleActor
import com.cobblemon.mod.common.api.item.PokemonSelectingItem
import com.cobblemon.mod.common.api.pokemon.status.Status
import com.cobblemon.mod.common.battles.pokemon.BattlePokemon
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity
import com.cobblemon.mod.common.item.CobblemonItem
import com.cobblemon.mod.common.item.battle.BagItem
import com.cobblemon.mod.common.pokemon.Pokemon
import com.cobblemon.mod.common.util.getBattleState
import com.cobblemon.mod.common.util.giveOrDropItemStack
import net.minecraft.server.level.ServerLevel
import net.minecraft.world.entity.player.Player
import net.minecraft.world.item.ItemStack
import net.minecraft.world.item.Items
import net.minecraft.server.level.ServerPlayer
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.item.ItemNameBlockItem
import net.minecraft.world.level.Level
import net.minecraft.world.level.block.Block
/**
* An item that cures statuses. Based on the [status] parameter it can be either specific [Status]es or all statuses (none specified).
@@ -32,7 +39,7 @@ import net.minecraft.world.level.Level
* @author Hiroku
* @since June 30th, 2023
*/
class StatusCureItem(val itemName: String, vararg val status: Status) : CobblemonItem(Properties()), PokemonSelectingItem {
class StatusCureItem(val itemName: String, vararg val status: Status, block: Block) : ItemNameBlockItem(block, Properties()), PokemonSelectingItem {
override val bagItem = object : BagItem {
override val itemName = this@StatusCureItem.itemName
override val returnItem = Items.AIR
@@ -41,6 +48,13 @@ class StatusCureItem(val itemName: String, vararg val status: Status) : Cobblemo
}
override fun canUseOnPokemon(stack: ItemStack, pokemon: Pokemon) = pokemon.status?.let { it.status in status || status.isEmpty() } == true && pokemon.currentHealth > 0
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (world is ServerLevel && user is ServerPlayer) {
return use(user, user.getItemInHand(hand))
}
return super<ItemNameBlockItem>.use(world, user, hand)
}
override fun applyToPokemon(
player: ServerPlayer,
stack: ItemStack,
@@ -64,11 +78,4 @@ class StatusCureItem(val itemName: String, vararg val status: Status) : Cobblemo
super.applyToBattlePokemon(player, stack, battlePokemon)
battlePokemon.entity?.playSound(CobblemonSounds.MEDICINE_SPRAY_USE, 1F, 1F)
}
override fun use(world: Level, user: Player, hand: InteractionHand): InteractionResultHolder<ItemStack> {
if (user is ServerPlayer) {
return use(user, user.getItemInHand(hand))
}
return InteractionResultHolder.success(user.getItemInHand(hand))
}
}
@@ -11,7 +11,8 @@ package com.cobblemon.mod.common.item.interactive
import com.cobblemon.mod.common.CobblemonSounds
import com.cobblemon.mod.common.api.pokemon.stats.Stats
import net.minecraft.sounds.SoundEvent
import net.minecraft.world.level.block.Block
class VitaminItem(stat: Stats) : EVIncreaseItem(stat, 10) {
class VitaminItem(stat: Stats, block: Block) : EVIncreaseBlockItem(stat, 10, block) {
override val sound: SoundEvent = CobblemonSounds.MEDICINE_PILLS_USE
}
@@ -1,16 +0,0 @@
package com.cobblemon.mod.common.net.messages.server.pokeball
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.network.RegistryFriendlyByteBuf
class SendOutPokeBallPacket() : NetworkPacket<SendOutPokeBallPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
}
companion object {
val ID = cobblemonResource("send_out_pokeball")
fun decode(buffer: RegistryFriendlyByteBuf) = SendOutPokeBallPacket()
}
}
@@ -1,16 +0,0 @@
package com.cobblemon.mod.common.net.messages.server.pokerod
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.network.RegistryFriendlyByteBuf
class ApplyBaitPacket() : NetworkPacket<ApplyBaitPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
}
companion object {
val ID = cobblemonResource("apply_bait")
fun decode(buffer: RegistryFriendlyByteBuf) = ApplyBaitPacket()
}
}
@@ -1,17 +0,0 @@
package com.cobblemon.mod.common.net.messages.server.pokerod
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.network.RegistryFriendlyByteBuf
class CastPokeRodPacket(val mainHand: Boolean) : NetworkPacket<CastPokeRodPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
buffer.writeBoolean(mainHand)
}
companion object {
val ID = cobblemonResource("cast_pokerod")
fun decode(buffer: RegistryFriendlyByteBuf) = CastPokeRodPacket(buffer.readBoolean())
}
}
@@ -1,17 +0,0 @@
package com.cobblemon.mod.common.net.messages.server.pokerod
import com.cobblemon.mod.common.api.net.NetworkPacket
import com.cobblemon.mod.common.util.cobblemonResource
import net.minecraft.network.RegistryFriendlyByteBuf
class ReelPokeRodPacket(val mainHand: Boolean) : NetworkPacket<ReelPokeRodPacket> {
override val id = ID
override fun encode(buffer: RegistryFriendlyByteBuf) {
buffer.writeBoolean(mainHand)
}
companion object {
val ID = cobblemonResource("reel_pokerod")
fun decode(buffer: RegistryFriendlyByteBuf) = ReelPokeRodPacket(buffer.readBoolean())
}
}
@@ -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.net.serverhandling.pokeball
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.item.PokeBallItem
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
import com.cobblemon.mod.common.util.isServerSide
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
object SendOutPokeBallHandler : ServerNetworkPacketHandler<SendOutPokeBallPacket> {
override fun handle(packet: SendOutPokeBallPacket, server: MinecraftServer, player: ServerPlayer) {
(player.mainHandItem.item as? PokeBallItem)?.let { pokeball ->
if (player.level().isServerSide()) {
pokeball.throwPokeBall(player.level(), player)
}
// TODO: player.mainHandItem.consume(1, player)
}
}
}
@@ -1,41 +0,0 @@
package com.cobblemon.mod.common.net.serverhandling.pokerod
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.item.interactive.PokerodItem
import com.cobblemon.mod.common.net.messages.server.pokerod.ApplyBaitPacket
import com.cobblemon.mod.common.util.isServerSide
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
object ApplyBaitHandler : ServerNetworkPacketHandler<ApplyBaitPacket> {
override fun handle(packet: ApplyBaitPacket, server: MinecraftServer, player: ServerPlayer) {
val mainHandItem = player.getItemInHand(InteractionHand.MAIN_HAND)
val offHandItem = player.getItemInHand(InteractionHand.OFF_HAND)
println("[ApplyBaitHandler] Main hand: ${mainHandItem.item}")
println("[ApplyBaitHandler] Off hand: ${offHandItem.item}")
(mainHandItem.item as? PokerodItem)?.let { pokerod ->
if (player.level().isServerSide()) {
pokerod.applyBait(
mainHandItem,
offHandItem,
player
)
}
}
(offHandItem.item as? PokerodItem)?.let { pokerod ->
if (player.level().isServerSide()) {
pokerod.applyBait(
offHandItem,
mainHandItem,
player
)
}
}
}
}
@@ -1,35 +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.serverhandling.pokerod
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.item.PokeBallItem
import com.cobblemon.mod.common.item.interactive.PokerodItem
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
import com.cobblemon.mod.common.util.isServerSide
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
object CastPokeRodHandler : ServerNetworkPacketHandler<CastPokeRodPacket> {
override fun handle(packet: CastPokeRodPacket, server: MinecraftServer, player: ServerPlayer) {
val hand = if (packet.mainHand) InteractionHand.MAIN_HAND else InteractionHand.OFF_HAND
(player.getItemInHand(hand).item as? PokerodItem)?.let { pokerod ->
if (player.level().isServerSide()) pokerod.attemptCast(
player.level(),
player,
hand,
player.getItemInHand(hand)
)
}
}
}
@@ -1,36 +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.serverhandling.pokerod
import com.cobblemon.mod.common.api.net.ServerNetworkPacketHandler
import com.cobblemon.mod.common.item.PokeBallItem
import com.cobblemon.mod.common.item.interactive.PokerodItem
import com.cobblemon.mod.common.net.messages.server.pokeball.SendOutPokeBallPacket
import com.cobblemon.mod.common.net.messages.server.pokerod.CastPokeRodPacket
import com.cobblemon.mod.common.net.messages.server.pokerod.ReelPokeRodPacket
import com.cobblemon.mod.common.util.isServerSide
import net.minecraft.server.MinecraftServer
import net.minecraft.server.level.ServerPlayer
import net.minecraft.world.InteractionHand
object ReelPokeRodHandler : ServerNetworkPacketHandler<ReelPokeRodPacket> {
override fun handle(packet: ReelPokeRodPacket, server: MinecraftServer, player: ServerPlayer) {
val hand = if (packet.mainHand) InteractionHand.MAIN_HAND else InteractionHand.OFF_HAND
(player.getItemInHand(hand).item as? PokerodItem)?.let { pokerod ->
if (player.level().isServerSide()) pokerod.attemptReel(
player.level(),
player,
hand,
player.getItemInHand(hand)
)
}
}
}
Loaded 100 of 1035 files, more files were not shown because too many files have changed in this diff. Show more