├── .editorconfig ├── .github ├── ISSUE_TEMPLATE │ └── bug-report.md └── workflows │ ├── blob-build.yml │ ├── build.yml │ └── maven.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── NOTES.md ├── README.md ├── jitpack.yml ├── pom.xml └── src └── main ├── java └── me │ └── profelements │ └── dynatech │ ├── DynaTech.java │ ├── DynaTechLiquids.java │ ├── attributes │ └── LiquidStorage.java │ ├── blocks │ ├── CokeOvenController.java │ └── IMultiblock.java │ ├── events │ └── PicnicBasketFeedPlayerEvent.java │ ├── fluids │ ├── FluidStack.java │ ├── FluidTank.java │ └── FluidTankAdapter.java │ ├── interfaces │ └── LiquidContainer.java │ ├── items │ ├── RecipeBook.java │ ├── abstracts │ │ ├── AbstractContainer.java │ │ ├── AbstractElectricMachine.java │ │ ├── AbstractElectricTicker.java │ │ ├── AbstractGenerator.java │ │ ├── AbstractMachine.java │ │ ├── AbstractTicker.java │ │ └── AbstractTickingContainer.java │ ├── backpacks │ │ ├── PicnicBasket.java │ │ └── SoulboundPicnicBacket.java │ ├── electric │ │ ├── AntigravityBubble.java │ │ ├── BandaidManager.java │ │ ├── BarbedWire.java │ │ ├── FurnaceController.java │ │ ├── KitchenAutoCrafter.java │ │ ├── MaterialHive.java │ │ ├── PotionSprinkler.java │ │ ├── SeedPlucker.java │ │ ├── WeatherController.java │ │ ├── WirelessCharger.java │ │ ├── generators │ │ │ ├── ChippingGenerator.java │ │ │ ├── CulinaryGenerator.java │ │ │ ├── DragonEggGenerator.java │ │ │ ├── EggMill.java │ │ │ ├── HydroGenerator.java │ │ │ ├── StardustReactor.java │ │ │ ├── WaterMill.java │ │ │ └── WindMill.java │ │ ├── growthchambers │ │ │ ├── GrowthChamber.java │ │ │ ├── GrowthChamberEnd.java │ │ │ ├── GrowthChamberEndMK2.java │ │ │ ├── GrowthChamberMK2.java │ │ │ ├── GrowthChamberNether.java │ │ │ ├── GrowthChamberNetherMK2.java │ │ │ ├── GrowthChamberOcean.java │ │ │ └── GrowthChamberOceanMK2.java │ │ ├── machines │ │ │ ├── MineralizedApiary.java │ │ │ └── Orechid.java │ │ └── transfer │ │ │ ├── Tesseract.java │ │ │ ├── WirelessEnergyBank.java │ │ │ ├── WirelessEnergyPoint.java │ │ │ ├── WirelessItemInput.java │ │ │ └── WirelessItemOutput.java │ ├── machines │ │ └── PetalApothecary.java │ ├── misc │ │ ├── Bee.java │ │ ├── DimensionalHomeDimension.java │ │ ├── ItemBand.java │ │ ├── MobDropItem.java │ │ ├── StarDustMeteor.java │ │ ├── VexGem.java │ │ └── WitherGolem.java │ └── tools │ │ ├── AngelGem.java │ │ ├── AutoInputUpgrade.java │ │ ├── AutoOutputUpgrade.java │ │ ├── DimensionalHome.java │ │ ├── ElectricalStimulator.java │ │ ├── InventoryFilter.java │ │ ├── LiquidContainerItem.java │ │ ├── LiquidTank.java │ │ ├── Scoop.java │ │ └── TesseractBinder.java │ ├── listeners │ ├── BlockBreakBlockListener.java │ ├── CoalCokeListener.java │ ├── ElectricalStimulatorListener.java │ ├── ExoticGardenIntegrationListener.java │ ├── GastronomiconIntegrationListener.java │ ├── InventoryFilterListener.java │ ├── PicnicBasketListener.java │ ├── RegistryListeners.java │ └── UpgradesListener.java │ ├── registries │ ├── ItemGroups.java │ ├── Items.java │ ├── RecipeTypes.java │ ├── Recipes.java │ ├── Registries.java │ ├── Registry.java │ ├── TypedKey.java │ └── events │ │ ├── RegistryAddEvent.java │ │ ├── RegistryFreezeEvent.java │ │ └── RegistryRemoveEvent.java │ ├── setup │ └── DynaTechItemsSetup.java │ ├── tasks │ └── ItemBandTask.java │ └── utils │ ├── ChestMenuUtils.java │ ├── EnergyUtils.java │ ├── ItemWrapper.java │ ├── Liquid.java │ ├── LiquidRegistry.java │ ├── Recipe.java │ ├── RecipeRegistry.java │ └── TimedRecipe.java └── resources ├── config.yml └── plugin.yml /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset=utf-8 5 | end_of_line = lf 6 | indent_style = space 7 | insert_final_newline = true 8 | indent_size = 4 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a Bug or an Issue with this Plugin. 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | ## Description (Required) 11 | 12 | 13 | 14 | 15 | ## Steps to reproduce the Issue (Required) 16 | 17 | 18 | ## Expected behavior (Required) 19 | 20 | 21 | ## Server Log / Error Report 22 | 23 | 24 | 25 | ## Environment (Required) 26 | 27 | 28 | 29 | 30 | - Minecraft Version: 31 | - CS-CoreLib Version: 32 | - Slimefun Version: 33 | - Plugin Version: 34 | -------------------------------------------------------------------------------- /.github/workflows/blob-build.yml: -------------------------------------------------------------------------------- 1 | name: Blob Build Deployment 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | jobs: 9 | publish: 10 | name: Upload Release 11 | runs-on: ubuntu-latest 12 | if: contains(github.event.head_commit.message, '[ci skip]') == false 13 | steps: 14 | - uses: actions/checkout@v4 15 | - name: Setup java 21 16 | uses: actions/setup-java@v4 17 | with: 18 | distribution: 'temurin' 19 | java-version: '21' 20 | cache: maven 21 | - name: Build with Maven 22 | run: mvn -B package --file pom.xml 23 | 24 | - name: Upload to Blob Builds 25 | uses: WalshyDev/blob-builds/gh-action@main 26 | with: 27 | project: DynaTech 28 | apiToken: ${{ secrets.BLOB_BUILDS_API_TOKEN }} 29 | file: ./target/DynaTech.jar 30 | releaseNotes: ${{ github.event.head_commit.message }} 31 | releaseChannel: 'Main' 32 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: build-maven-project 2 | run-name: Build maven project 3 | on: [push] 4 | jobs: 5 | build: 6 | runs-on: ubuntu-latest 7 | steps: 8 | - uses: actions/checkout@v4 9 | - name: Setup java 21 10 | uses: actions/setup-java@v4 11 | with: 12 | distribution: 'temurin' 13 | java-version: '21' 14 | cache: maven 15 | - name: Build with Maven 16 | run: mvn -B package --file pom.xml 17 | - name: Upload artifact 18 | uses: actions/upload-artifact@v4 19 | with: 20 | path: ${{ github.workspace }}/target/DynaTech.jar 21 | name: dynatech-artifact 22 | 23 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: Java CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | build: 13 | 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - uses: actions/checkout@v2.3.3 18 | - name: Set up JDK 16 19 | uses: actions/setup-java@v2 20 | with: 21 | distribution: 'adopt' 22 | java-version: '16' 23 | - name: Build with Maven 24 | run: mvn package --file pom.xml 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bin/ 2 | /.settings/ 3 | /target/ 4 | /.idea/ 5 | *.iml 6 | .project 7 | .classpath 8 | dependency-reduced-pom.xml 9 | .DS_Store 10 | /.vscode 11 | Notes.txt 12 | .factorypath 13 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | # 29/4/24 3 | 4 | ## Additions: 5 | - Add Dragon Egg Mill 6 | - Add Dragon Egg Turbine 7 | - Allow RecipeRegistry to grab recipe via key 8 | 9 | ## Fixes: 10 | - Regular block now drops if broken before durability = 0 for degrading generators. 11 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 ProfElements 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /NOTES.md: -------------------------------------------------------------------------------- 1 | ## New Additions 2 | - **Tunnel Bores** : An automated mining minecart using coal and rails. //Idea > https://wiki.gm4.co/wiki/Tunnel_Bores 3 | - **Dog House** : When right clicked on a dog changes it into a `Companion` that can level up and help you out. //Texture > d089b260aedd4bf2cf0f9ac7fb0e9e3a461cc4fef098ecd660fd0c9827986f5c 4 | - **Advanced Enchantment Table** : Taking much more exp you can choose the enchantments on items 5 | - **Stave** : A magical staff that changes based on what runes you add to it 6 | - **Skeletal Bee** : A Bee that sometimes makes material hive output double at the cost of dying // Texture > 7129324c900a58cf34b42ce3f07c1753f9f7523f22bccbc9afc63f191fd1395 7 | - **Nether Heat Upgrade** : When applied to a solar panel, let them generate half the amount of energy while in the nether. 8 | 9 | ## Steam Revolution 10 | - **Steam Tank** : A tank that hold steams for all machines in a Steam network can grab and use 11 | - **Boiler** : Takes in water and coal and produces steam. 12 | - **Furnace Heater** : When placed adjacent to a furnace powers it using steam instead of conventional materials 13 | - **Steam Workbench** : Auto crafter using steam 14 | - **Steam Turbine** : Takes in steam and produces electricity 15 | - **Ore Washer** : Cleans ores and other materials to produce more pure variants (2x ore doubling + chance at nuggets) 16 | - **Simple Steam Pipe** : Connects steam blocks together 17 | 18 | ## Out of Depth 19 | - **Talisman Pouch** : Put talisman in pouch and works like inv or enderchest //Require visibility changes to slimefun for little gain. 20 | - **Training Dummy** : Unkillable Armor Stand that show how much damage you deal //Dont know how to use EntityInteractEvent 21 | - **Treasure Chest** : A one time lootbox from any lootchest //Just dont know how to hack the inventory stuffs 22 | 23 | ## Questioning 24 | - **Basalt Generator** : One block basalt generator //I really dont know how useful this would be 25 | - **Blackstone Generator**: One block blackstone generator //I really dont knoww how useful this would be 26 | - **Bossbar Projector**: Projects a bossbar with a name and bossbar type in a range //I dont know how hard implmenting this would be 27 | 28 | ## Coding and commit conventions 29 | - **fix** : bugfix or general fix to item or system //GitMoji emoji : :bug: 30 | - **feat** : adding a new feature to an item or a new item //GitMoji emoji : :sparkles: 31 | - **BREAKING CHANGE** : litterally what it says on the tin, if this is here expect breakage //GitMoji emoji : :recycle: 32 | - **wip** : Work in Progress stuff to eventually become a feature or bugfix //GitMoji emoji : :construction: 33 | - **work** : general working on weather its cleaninp up or otherwise //GitMoji emoji : :construction: 34 | 35 | ## ROUND 1 36 | - Add Wind Mill [x] 37 | - Add Wind Turbine [x] 38 | - Fix Water Mill [x] 39 | - Fix Hydro Turbine [x] 40 | - Fix Dragon Egg Generator [x] 41 | - Add Dragon Egg Turbine [x] 42 | ### ROUND 2 43 | - Add Recipe Book [x] 44 | - Add Liquid Storage [ ] 45 | - Add Liquid Storage Tank (Liquid Storage Block) [ ] 46 | - Add Liquid Storage Capsule (Liquid Storage Item) [ ] 47 | ### ROUND OTHER 48 | - Add Fishing Machine [ ] 49 | ## MISC Notes 50 | To register a recipe without a SlimefunItem + SlimefunItemStack combo 51 | use RecipeType.register(ItemStack[], ItemStack) 52 | //recipe, result ex. RecipeType.ENHANCED_CRAFING_TABLE.register(new ItemStack[] {new ItemStack(Material.OAK)}, new ItemStack(Material.SPRUCE)); 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DynaTech 2 | A set of item and machines that I made to make things easier for me and just for fun. 3 | Most of these could possibly be overpowered or heavily underpowered. 4 | 5 | **THIS PLUGIN REQUIRES ATLEAST JAVA 11** 6 | **THIS PLUGIN REQUIRES ATLEAST MINECRAFT 1.20.6** 7 | 8 | DynaTech **never** tries to be backwards with older minecraft versions. 9 | I do not want to deal with the extra issues or development time that supporting older versions needs. 10 | ### [Download](https://blob.build/project/DynaTech) 11 | 12 | ## Machines 13 | - **Auto-Kitchen** - If you have ExoticGarden installed, this machine will become available. It automatically crafts any Kitchen recipe inserted into it. 14 | - **Growth Chambers** - Automatically grow some plants. We have multiple variants for all your needs. Supports Exotic Garden saplings, plants, and bushes. 15 | - **Antigravity Bubble** - Temporary creative flight within a 45 block area when powered. 16 | - **Weather Controller** - Controls the weather when given a key item (Sunflower > Clear, Lilac > Rain, Creeper Head > Thunder). 17 | - **Potion Sprinkler** - A ranged potion applier, the potions have durability basically. Has a 10 block range. 18 | - **Barbed Wire** - Pushes mob back in a radius. Has a 9 block range, perfect for mob farms. 19 | - **Material Hive** - An infinite resource generator, requires Bees and a stack of the output items. Supported Materials are [here](https://github.com/ProfElements/DynaTech/blob/1b6aee96937da31c7bdb84df284392530149ce63/src/main/java/me/profelements/dynatech/items/electric/MaterialHive.java#L169). For the Material Hive, each bee you put in minuses the amount of time it takes to produce the material, so 128 bees is better then 1 bee, please note each type of bee has a different seconds minus amount. Check bee section for more info. 20 | - **Wireless Charger** - Charges Rechargeable Items in a Players inventory in a 16 block radius around it 21 | - **Seed Plucker** - Plucks seed from plant-based material, supports Exotic Garden Fruits, but not essences. 22 | - **Item Band Manager** - Manages the application and ripping of Item Bands. 23 | - **Orechid** - Changes Stone and Netherack into Overworld and Nether ores respectively 24 | - **Wireless Energy Bank** - Stores energy to be transfer wirelessly Using the Wireless Energy Point 25 | - **Wireless Energy Point** - Transfers energy wirelessly using the Energy from the Wireless Energy Bank 26 | - **Wireless Item Input** - Input point for 1 way wireless item transfer 27 | - **Wireless Item Output** - Output Point for 1 way wireless item transfer 28 | - **Tesseract** - Two way item and energy transport. 29 | - External Heater - Externally heats Furnace-like blocks. 30 | ## Generators 31 | - **Hydro Generator** - Generates energy from flowing water (Waterlog the generator) 32 | - **Dragon Egg Generator** - Generates energy from the warmth of a dragon egg. (Place the dragon egg on top) 33 | - **Chipping Generator** - Generates energy from damaged and or durability based items 34 | - **Culinary Generator** - Generates energy from food energy, suports Exotic Garden Food in the Food Category. 35 | - **Stardust Reactor** - Generates energy from Star Dust, and lots of it 36 | 37 | ## Tools 38 | - **Picnic Basket** - Its an upgraded Cooler. It can eat any ExoticGarden custom foods, or just regular vanilla foods, it has a configurable blacklist in the items.yml 39 | - **Electrical Stimulator** - Feed the player for energy. 40 | - **Inventory Filter** - Upon item pickup, if item is the same as one in the Inventory Filter's filter it voids the item. 41 | - **Angel Gem** - Permanent Creative Flight, it has some speed settings. 42 | - **Scoop** - The only way to get naturals Bees. Scoop them into item form. 43 | - **Dimensional Home** - Gives you a small home in another dimension to teleport to and from. (it sends to you back to your bed spawn if you are in the dimension.) 44 | - **Tesseract Binder** - Binds Tesseract in a better manner then binding themselves via direct linking 45 | - **Portable Fluid Tank** - Holds 16 buckets of any fluid. Can place them back down too 46 | 47 | ## Bees 48 | - **Bee** - A Natural Bee, for each one -2 seconds to resource creation time in Material Hive. 49 | - **Robotic Bee** - A Robotic bee made of magic and scrap parts. -2 seconds to resource creation time in Material Hive. 50 | - **Advanced Robotic Bee** - An Advanced version of the Robotic Bee. -10 seconds to resource creation time in Material Hive. 51 | 52 | ## Item Bands 53 | - **Healthy Item Band** - When applied to armor or weapons gain 4 hearts while wearing or holding the item in your main hand. 54 | - **Hasty Item Band** - When applied to armor or weapons gain 2 levels of haste while wearing or hold the item in your main hand. 55 | 56 | ## Integrations 57 | - **Vex Mob Data Card** - If InfinityExpansion is installed then you get a Vex Mob Data Card to help with Ghostly Essence and Vex Gems 58 | - **Phantom Mob Data Card** - If InfinityExpansion is install then you get a Phantom Mob Data card to help with Phantom Membrane 59 | ## Credits 60 | [NCBPFluffyBear](https://github.com/ncbpfluffybear) for their autocrafter code since it helped alot with the Auto-Kitchen. 61 | 62 | [Mooy1](https://github.com/mooy1) for their hydro generator code so I could figure out how to do waterlogging right. 63 | 64 | [Seggan](https://github.com/seggan) for showing me how to make a good container class instead of using Slimefun's default. 65 | 66 | [WalshyDev](https://github.com/WalshyDev) for answering my spam in the programming help channel. 67 | 68 | [Slimefun Discord](https://slimefun.dev/discord) for putting up with my outright spam of the programming help channel. 69 | 70 | [Slimefun](https://github.com/slimefun/slimefun4) for being incredibly intuitive to make an addon for and overall being generally helpful when needing examples. 71 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - sdk install java 21.0.1-open 3 | - sdk use java 21.0.1-open 4 | 5 | jdk: 6 | - openjdk21 7 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/DynaTechLiquids.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech; 2 | 3 | import org.bukkit.Color; 4 | import org.bukkit.Material; 5 | import org.bukkit.NamespacedKey; 6 | 7 | import me.profelements.dynatech.utils.Liquid; 8 | import me.profelements.dynatech.utils.LiquidRegistry; 9 | 10 | public class DynaTechLiquids { 11 | 12 | public static void registerLiquids(LiquidRegistry registry) { 13 | 14 | // START Vanilla 15 | 16 | // Water 17 | Liquid.init() 18 | .setKey(new NamespacedKey(NamespacedKey.MINECRAFT, "water")) 19 | .setName("Water") 20 | .setColor(Color.BLUE) 21 | .setLiquidMaterial(Material.WATER) 22 | .setStorageMaterial(Material.LIGHT_BLUE_STAINED_GLASS_PANE) 23 | .register(registry); 24 | 25 | // Lava 26 | Liquid.init() 27 | .setKey(new NamespacedKey(NamespacedKey.MINECRAFT, "lava")) 28 | .setName("Lava") 29 | .setColor(Color.ORANGE) 30 | .setLiquidMaterial(Material.LAVA) 31 | .setStorageMaterial(Material.ORANGE_STAINED_GLASS_PANE) 32 | .register(registry); 33 | 34 | // Honey 35 | Liquid.init() 36 | .setKey(new NamespacedKey(NamespacedKey.MINECRAFT, "honey")) 37 | .setName("Honey") 38 | .setColor(Color.YELLOW) 39 | .setLiquidMaterial(Material.LAVA) 40 | .setStorageMaterial(Material.YELLOW_STAINED_GLASS_PANE) 41 | .register(registry); 42 | 43 | // Potion 44 | Liquid.init() 45 | .setKey(new NamespacedKey(NamespacedKey.MINECRAFT, "potion")) 46 | .setName("Potion") 47 | .setColor(Color.WHITE) 48 | .setLiquidMaterial(Material.WATER) 49 | .setStorageMaterial(Material.WHITE_STAINED_GLASS_PANE) 50 | .register(registry); 51 | 52 | // Milk 53 | Liquid.init() 54 | .setKey(new NamespacedKey(NamespacedKey.MINECRAFT, "milk")) 55 | .setName("Milk") 56 | .setColor(Color.WHITE) 57 | .setLiquidMaterial(Material.WATER) 58 | .setStorageMaterial(Material.WHITE_STAINED_GLASS_PANE) 59 | .register(registry); 60 | // END Vanilla 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/blocks/IMultiblock.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.blocks; 2 | 3 | import org.bukkit.Location; 4 | import org.bukkit.NamespacedKey; 5 | import org.bukkit.World; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.block.BlockFace; 8 | 9 | import com.google.common.base.Predicate; 10 | 11 | public interface IMultiblock { 12 | 13 | Predicate[][][] getMultiblockBlocks(); 14 | 15 | boolean isController(World w, int x, int y, int z); 16 | 17 | boolean isValidMultiblock(Location l, BlockFace facing); 18 | 19 | void createMultiblock(Location l, BlockFace facing); 20 | 21 | void destroyMultiblock(Location l, BlockFace facing); 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/events/PicnicBasketFeedPlayerEvent.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.events; 2 | 3 | import me.profelements.dynatech.items.backpacks.PicnicBasket; 4 | import org.bukkit.entity.Player; 5 | import org.bukkit.event.Cancellable; 6 | import org.bukkit.event.HandlerList; 7 | import org.bukkit.event.player.PlayerEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import javax.annotation.Nonnull; 11 | import javax.annotation.ParametersAreNonnullByDefault; 12 | 13 | import com.google.common.base.Preconditions; 14 | 15 | public class PicnicBasketFeedPlayerEvent extends PlayerEvent implements Cancellable { 16 | 17 | public static final HandlerList handlers = new HandlerList(); 18 | 19 | private final PicnicBasket picnicBasket; 20 | private final ItemStack picnicBasketItem; 21 | 22 | private ItemStack itemConsumed; 23 | private boolean cancelled; 24 | 25 | @ParametersAreNonnullByDefault 26 | public PicnicBasketFeedPlayerEvent(Player player, PicnicBasket picnicBasket, ItemStack picnicBasketItem, ItemStack itemConsumed) { 27 | super(player); 28 | 29 | this.picnicBasket = picnicBasket; 30 | this.picnicBasketItem = picnicBasketItem; 31 | this.itemConsumed =itemConsumed; 32 | 33 | 34 | } 35 | 36 | @Nonnull 37 | public PicnicBasket getPicnicBasket() { 38 | return picnicBasket; 39 | } 40 | 41 | @Nonnull 42 | public ItemStack getPicnicBasketItem() { 43 | return picnicBasketItem; 44 | } 45 | 46 | @Nonnull 47 | public ItemStack getItemConsumed() { 48 | return itemConsumed.clone(); 49 | } 50 | 51 | public void setConsumedItem(@Nonnull ItemStack item) { 52 | Preconditions.checkNotNull(item, "Consumed item can not be null"); 53 | Preconditions.checkArgument(item.getType().isEdible(), "Item must be edible"); 54 | 55 | this.itemConsumed = item; 56 | } 57 | 58 | @Override 59 | public boolean isCancelled() { 60 | return cancelled; 61 | } 62 | 63 | @Override 64 | public void setCancelled(boolean cancel) { 65 | this.cancelled = cancel; 66 | } 67 | 68 | @Nonnull 69 | public static HandlerList getHandlerList() { 70 | return handlers; 71 | } 72 | 73 | @Nonnull 74 | @Override 75 | public HandlerList getHandlers() { 76 | return getHandlerList(); 77 | } 78 | 79 | 80 | } 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/fluids/FluidStack.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.fluids; 2 | 3 | import javax.annotation.Nullable; 4 | 5 | import org.bukkit.NamespacedKey; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.inventory.meta.ItemMeta; 9 | import org.bukkit.persistence.PersistentDataType; 10 | 11 | import io.github.bakedlibs.dough.data.persistent.PersistentDataAPI; 12 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 13 | import me.profelements.dynatech.DynaTech; 14 | 15 | public record FluidStack(NamespacedKey fluid, int amount) { 16 | 17 | public static int BUCKET_AMOUNT = 1000; 18 | public static int BOTTLE_AMOUNT = 250; 19 | public static NamespacedKey LAVA_FLUID = NamespacedKey.minecraft("lava"); 20 | public static NamespacedKey WATER_FLUID = NamespacedKey.minecraft("water"); 21 | public static NamespacedKey MILK_FLUID = NamespacedKey.minecraft("milk"); 22 | public static NamespacedKey POTION_FLUID = NamespacedKey.minecraft("potion"); 23 | 24 | public static NamespacedKey FLUID_KEY = new NamespacedKey(DynaTech.getInstance(), "fluid"); 25 | public static NamespacedKey FLUID_AMOUNT_KEY = new NamespacedKey(DynaTech.getInstance(), "fluid_amount"); 26 | 27 | public static FluidStack of(NamespacedKey fluid, int amount) { 28 | return new FluidStack(fluid, amount); 29 | } 30 | 31 | public void toBlock(Block block) { 32 | String fluidType = BlockStorage.getLocationInfo(block.getLocation(), FLUID_KEY.toString()); 33 | String fluidAmount = BlockStorage.getLocationInfo(block.getLocation(), FLUID_AMOUNT_KEY.toString()); 34 | 35 | if (fluidType != null && fluidType != this.fluid().toString()) { 36 | return; 37 | } 38 | 39 | BlockStorage.addBlockInfo(block, FLUID_KEY.toString(), this.fluid().toString()); 40 | 41 | int amount = 0; 42 | if (fluidAmount != null) { 43 | amount = Integer.parseInt(fluidAmount); 44 | } 45 | 46 | BlockStorage.addBlockInfo(block, FLUID_AMOUNT_KEY.toString(), String.valueOf(amount + this.amount())); 47 | } 48 | 49 | public static @Nullable FluidStack fromBlock(Block block) { 50 | String fluidType = BlockStorage.getLocationInfo(block.getLocation(), FLUID_KEY.toString()); 51 | String fluidAmount = BlockStorage.getLocationInfo(block.getLocation(), FLUID_AMOUNT_KEY.toString()); 52 | 53 | if (fluidType != null && fluidAmount != null) { 54 | return FluidStack.of(NamespacedKey.fromString(fluidType), Integer.parseInt(fluidAmount)); 55 | } else { 56 | return null; 57 | } 58 | 59 | } 60 | 61 | public static @Nullable FluidStack fromItemStack(ItemStack itemStack) { 62 | String fluidType = PersistentDataAPI.getString(itemStack.getItemMeta(), FLUID_KEY, ""); 63 | int fluidAmount = PersistentDataAPI.getInt(itemStack.getItemMeta(), 64 | FLUID_AMOUNT_KEY, 0); 65 | 66 | if (fluidType != "" && fluidAmount != 0) { 67 | return FluidStack.of(NamespacedKey.fromString(fluidType), fluidAmount); 68 | } else { 69 | return null; 70 | } 71 | 72 | } 73 | 74 | public void toItemStack(ItemStack itemStack) { 75 | ItemMeta meta = itemStack.getItemMeta(); 76 | 77 | String fluidType = PersistentDataAPI.getString(meta, FLUID_KEY, ""); 78 | int fluidAmount = PersistentDataAPI.getInt(meta, FLUID_AMOUNT_KEY, 0); 79 | 80 | if (fluidType.equals("") || this.fluid().equals(NamespacedKey.fromString(fluidType))) { 81 | PersistentDataAPI.setString(meta, FLUID_KEY, this.fluid().toString()); 82 | PersistentDataAPI.setInt(meta, FLUID_AMOUNT_KEY, fluidAmount + this.amount()); 83 | } 84 | 85 | itemStack.setItemMeta(meta); 86 | } 87 | 88 | public ItemMeta apply(ItemMeta meta) { 89 | String fluidType = PersistentDataAPI.getString(meta, FLUID_KEY, ""); 90 | int fluidAmount = PersistentDataAPI.getInt(meta, FLUID_AMOUNT_KEY, 0); 91 | 92 | if (fluidType != null && this.fluid() == NamespacedKey.fromString(fluidType)) { 93 | PersistentDataAPI.setString(meta, FLUID_KEY, this.fluid().toString()); 94 | PersistentDataAPI.setInt(meta, FLUID_AMOUNT_KEY, fluidAmount + this.amount()); 95 | } 96 | 97 | return meta; 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/fluids/FluidTankAdapter.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.fluids; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.Nullable; 5 | 6 | import org.bukkit.Material; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.block.data.Levelled; 9 | import org.bukkit.inventory.ItemStack; 10 | import org.bukkit.inventory.meta.PotionMeta; 11 | import org.bukkit.potion.PotionType; 12 | 13 | import com.google.common.base.Preconditions; 14 | 15 | public class FluidTankAdapter { 16 | 17 | private FluidTankAdapter() { 18 | } 19 | 20 | public static @Nullable FluidStack getFluidFromItemStack(@Nonnull ItemStack itemStack) { 21 | switch (itemStack.getType()) { 22 | case Material.WATER_BUCKET: 23 | return FluidStack.of(FluidStack.WATER_FLUID, FluidStack.BUCKET_AMOUNT); 24 | case Material.MILK_BUCKET: 25 | return FluidStack.of(FluidStack.MILK_FLUID, FluidStack.BUCKET_AMOUNT); 26 | case Material.LAVA_BUCKET: 27 | return FluidStack.of(FluidStack.LAVA_FLUID, FluidStack.BUCKET_AMOUNT); 28 | case Material.POTION: 29 | if (itemStack.getItemMeta() instanceof PotionMeta pm) { 30 | if (pm.getBasePotionType() == PotionType.WATER) { 31 | return FluidStack.of(FluidStack.WATER_FLUID, FluidStack.BOTTLE_AMOUNT); 32 | } else { 33 | return FluidStack.of(FluidStack.POTION_FLUID, FluidStack.BOTTLE_AMOUNT); 34 | } 35 | } 36 | default: 37 | return null; 38 | } 39 | } 40 | 41 | public static @Nullable FluidStack getFluidStackFromBlock(@Nonnull Block block) { 42 | Preconditions.checkNotNull(block); 43 | switch (block.getType()) { 44 | case Material.LAVA_CAULDRON: 45 | return FluidStack.of(FluidStack.LAVA_FLUID, FluidStack.BUCKET_AMOUNT); 46 | case Material.WATER_CAULDRON: 47 | case Material.WATER: 48 | case Material.LAVA: 49 | return getFluidStackFromLevelled(block); 50 | default: 51 | return null; 52 | } 53 | } 54 | 55 | public static @Nullable FluidStack getFluidStackFromLevelled(@Nonnull Block block) { 56 | Preconditions.checkNotNull(block); 57 | 58 | if (!(block.getBlockData() instanceof Levelled) || block.getType() == Material.COMPOSTER) { 59 | return null; 60 | } 61 | 62 | Levelled lvl = (Levelled) block.getBlockData(); 63 | 64 | // Level 0 is special cased as a source block of water or lava. 65 | // Cauldron level starts at 1; 66 | // Max cauldron level = 3. so this is a Levelled source we can't use 67 | if (lvl.getLevel() > 3) { 68 | return null; 69 | } 70 | 71 | // This is either Material.LAVA, or Material.WATER 72 | if (lvl.getLevel() == 0) { 73 | switch (block.getType()) { 74 | case Material.WATER: 75 | return FluidStack.of(FluidStack.WATER_FLUID, FluidStack.BUCKET_AMOUNT); 76 | case Material.LAVA: 77 | return FluidStack.of(FluidStack.LAVA_FLUID, FluidStack.BUCKET_AMOUNT); 78 | default: 79 | return null; 80 | } 81 | } 82 | 83 | if (block.getType() == Material.WATER_CAULDRON) { 84 | return FluidStack.of(FluidStack.WATER_FLUID, (lvl.getLevel() / lvl.getMaximumLevel()) * 1000); 85 | } 86 | 87 | return null; 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/interfaces/LiquidContainer.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.interfaces; 2 | 3 | import me.profelements.dynatech.utils.Liquid; 4 | 5 | public interface LiquidContainer { 6 | 7 | Liquid getLiquid(); 8 | 9 | int getLiquidCapacity(); 10 | 11 | default boolean isFinite() { 12 | return true; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/RecipeBook.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 8 | import me.profelements.dynatech.utils.ChestMenuUtils; 9 | import me.profelements.dynatech.utils.Recipe; 10 | 11 | public class RecipeBook extends SlimefunItem { 12 | 13 | public RecipeBook(ItemGroup itemGroup, SlimefunItemStack stack, Recipe recipe) { 14 | super(itemGroup, stack, recipe.getRecipeType(), recipe.getInput()); 15 | 16 | addItemHandler(onRightClick()); 17 | } 18 | 19 | private final ItemUseHandler onRightClick() { 20 | return new ItemUseHandler() { 21 | 22 | @Override 23 | public void onRightClick(PlayerRightClickEvent e) { 24 | ChestMenuUtils.openRecipeBook(e.getPlayer()); 25 | } 26 | 27 | }; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/abstracts/AbstractContainer.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | import org.bukkit.Location; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.entity.Player; 10 | import org.bukkit.event.block.BlockBreakEvent; 11 | import org.bukkit.event.block.BlockPlaceEvent; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 15 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 16 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 17 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 18 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotHopperable; 19 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 20 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; 21 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 22 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; 23 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 24 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 25 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 26 | import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; 27 | 28 | 29 | 30 | public abstract class AbstractContainer extends SlimefunItem implements NotHopperable { 31 | 32 | protected AbstractContainer(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 33 | super(itemGroup, item, recipeType, recipe); 34 | 35 | new BlockMenuPreset(getId(), getItemName()) { 36 | @Override 37 | public void init() { 38 | setupMenu(this); 39 | } 40 | 41 | @Override 42 | public boolean canOpen(Block b, Player p) { 43 | return p.hasPermission("slimefun.inventory.bypass") || Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK); 44 | } 45 | 46 | @Nonnull 47 | @Override 48 | public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { 49 | if (flow == ItemTransportFlow.INSERT) { 50 | return getInputSlots(); 51 | } else { 52 | return getOutputSlots(); 53 | } 54 | } 55 | 56 | @Override 57 | public void newInstance(BlockMenu m, Block b) { 58 | onNewInstance(m, b); 59 | } 60 | }; 61 | 62 | } 63 | 64 | @Override 65 | public void preRegister() { 66 | addItemHandler(new BlockBreakHandler(false, false) { 67 | @Override 68 | public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) { 69 | BlockMenu menu = BlockStorage.getInventory(e.getBlock()); 70 | if (menu != null) { 71 | onBreak(e, menu, e.getBlock().getLocation()); 72 | } 73 | } 74 | }); 75 | 76 | addItemHandler(new BlockPlaceHandler(false) { 77 | @Override 78 | public void onPlayerPlace(BlockPlaceEvent e) { 79 | onPlace(e, e.getBlockPlaced()); 80 | } 81 | }); 82 | 83 | } 84 | 85 | protected abstract void setupMenu(BlockMenuPreset preset); 86 | 87 | @Nonnull 88 | protected abstract int[] getInputSlots(); 89 | 90 | @Nonnull 91 | protected abstract int[] getOutputSlots(); 92 | 93 | protected void onNewInstance(BlockMenu m, Block b) {} 94 | 95 | protected void onBreak(BlockBreakEvent e, BlockMenu m, Location l) {} 96 | 97 | protected void onPlace(BlockPlaceEvent e, Block b) {} 98 | 99 | } 100 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/abstracts/AbstractElectricTicker.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.abstracts; 2 | 3 | import javax.annotation.Nonnull; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import com.google.common.base.Preconditions; 10 | 11 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 12 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 13 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 14 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; 15 | import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; 16 | 17 | public abstract class AbstractElectricTicker extends AbstractTicker implements EnergyNetComponent { 18 | 19 | private int energyConsumedPerTick = -1; 20 | private int energyCapacity = -1; 21 | private int processingSpeed = -1; 22 | 23 | protected AbstractElectricTicker(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 24 | super(itemGroup, item, recipeType, recipe); 25 | } 26 | 27 | @Override 28 | protected boolean checkTickPreconditions(Block b) { 29 | return takeCharge(b.getLocation()); 30 | } 31 | 32 | @Nonnull 33 | @Override 34 | public EnergyNetComponentType getEnergyComponentType() { 35 | return EnergyNetComponentType.CONSUMER; 36 | } 37 | 38 | public int getCapacity() { 39 | return energyCapacity; 40 | } 41 | 42 | public int getEnergyConsumption() { 43 | return energyConsumedPerTick; 44 | } 45 | 46 | public int getSpeed() { 47 | return processingSpeed; 48 | } 49 | 50 | public final AbstractElectricTicker setCapacity(int capacity) { 51 | Preconditions.checkArgument(capacity > 0, "The capacity must be greater then 0"); 52 | 53 | this.energyCapacity = capacity; 54 | return this; 55 | } 56 | 57 | public final AbstractElectricTicker setConsumption(int consumption) { 58 | Preconditions.checkArgument(getCapacity() > 0, "Capacity must be set before consumption"); 59 | Preconditions.checkArgument(consumption < getCapacity() && consumption != 0, "Consuption can not be greater then capacity"); 60 | 61 | this.energyConsumedPerTick = consumption; 62 | return this; 63 | } 64 | 65 | public final AbstractElectricTicker setProcessingSpeed(int speed) { 66 | Preconditions.checkArgument(speed > 0, "Speed must be greater then zero!"); 67 | 68 | this.processingSpeed = speed; 69 | return this; 70 | } 71 | 72 | protected boolean takeCharge(Location l) { 73 | Preconditions.checkNotNull(l, "Can't take energy from a null location"); 74 | 75 | if (isChargeable()) { 76 | int charge = getCharge(l); 77 | 78 | if (charge < getEnergyConsumption()) { 79 | return false; 80 | } 81 | 82 | setCharge(l, charge - getEnergyConsumption()); 83 | } 84 | return true; 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/abstracts/AbstractMachine.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.abstracts; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.Nullable; 5 | 6 | import org.bukkit.Location; 7 | import org.bukkit.Material; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.event.block.BlockBreakEvent; 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 13 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 14 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 15 | import io.github.thebusybiscuit.slimefun4.core.attributes.MachineProcessHolder; 16 | import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; 17 | import io.github.thebusybiscuit.slimefun4.core.machines.MachineProcessor; 18 | import io.github.thebusybiscuit.slimefun4.implementation.operations.CraftingOperation; 19 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 20 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 21 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 22 | 23 | public abstract class AbstractMachine extends AbstractTickingContainer implements MachineProcessHolder, RecipeDisplayItem { 24 | 25 | private final MachineProcessor processor = new MachineProcessor<>(this); 26 | 27 | protected AbstractMachine(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 28 | super(itemGroup, item, recipeType, recipe); 29 | 30 | processor.setProgressBar(getProgressBar()); 31 | } 32 | 33 | @Nonnull 34 | @Override 35 | public MachineProcessor getMachineProcessor() { 36 | return processor; 37 | } 38 | 39 | @Nullable 40 | public abstract MachineRecipe findNextRecipe(BlockMenu menu); 41 | 42 | @Nonnull 43 | protected abstract ItemStack getProgressBar(); 44 | 45 | protected boolean checkCraftPreconditions(Block b) { 46 | return true; 47 | } 48 | 49 | protected boolean onCraftFinish(BlockMenu menu, ItemStack[] ingredients) { 50 | return true; 51 | } 52 | 53 | protected void addOutputs(BlockMenu menu, Block b, ItemStack[] outputs) { 54 | for (ItemStack output: outputs) { 55 | if (output != null) { 56 | menu.pushItem(output.clone(), getOutputSlots()); 57 | } 58 | } 59 | } 60 | 61 | @Override 62 | protected void onBreak(BlockBreakEvent e, BlockMenu menu, Location l) { 63 | super.onBreak(e, menu, l); 64 | 65 | menu.dropItems(l, getInputSlots()); 66 | menu.dropItems(l, getOutputSlots()); 67 | 68 | processor.endOperation(e.getBlock()); 69 | } 70 | 71 | @Override 72 | protected void tick(BlockMenu menu, Block b) { 73 | CraftingOperation currentOp = processor.getOperation(b); 74 | 75 | if (currentOp != null) { 76 | if (checkCraftPreconditions(b)) { 77 | 78 | if(!currentOp.isFinished()) { 79 | processor.updateProgressBar(menu, getProgressSlot(), currentOp); 80 | currentOp.addProgress(1); 81 | } else { 82 | menu.replaceExistingItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " ")); 83 | 84 | boolean isFinished = onCraftFinish(menu, currentOp.getIngredients()); 85 | if (isFinished) { 86 | addOutputs(menu, b, currentOp.getResults()); 87 | } 88 | 89 | processor.endOperation(b); 90 | } 91 | } 92 | } else { 93 | MachineRecipe next = findNextRecipe(menu); 94 | 95 | if (next != null) { 96 | currentOp = new CraftingOperation(next); 97 | processor.startOperation(b, currentOp); 98 | 99 | processor.updateProgressBar(menu, getProgressSlot(), currentOp); 100 | } 101 | } 102 | } 103 | 104 | protected int getProgressSlot() { 105 | return 22; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/abstracts/AbstractTicker.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.abstracts; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.block.Block; 7 | import org.bukkit.event.block.BlockBreakEvent; 8 | import org.bukkit.event.block.BlockPlaceEvent; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 12 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 13 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 14 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 15 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; 16 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 17 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 18 | import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; 19 | 20 | public abstract class AbstractTicker extends SlimefunItem { 21 | 22 | protected AbstractTicker(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 23 | super(itemGroup, item, recipeType, recipe); 24 | } 25 | 26 | @Override 27 | public void preRegister() { 28 | addItemHandler(new BlockTicker() { 29 | @Override 30 | public boolean isSynchronized() { 31 | return AbstractTicker.this.isSynchronized(); 32 | } 33 | 34 | @Override 35 | public void tick(Block b, SlimefunItem item, Config data) { 36 | if (checkTickPreconditions(b)) { 37 | AbstractTicker.this.tick(b, item); 38 | onTickFinish(b); 39 | } 40 | 41 | } 42 | }); 43 | 44 | addItemHandler(new BlockBreakHandler(false, false) { 45 | @Override 46 | public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) { 47 | onBreak(e, e.getBlock().getLocation()); 48 | } 49 | }); 50 | 51 | addItemHandler(new BlockPlaceHandler(false) { 52 | @Override 53 | public void onPlayerPlace(BlockPlaceEvent e) { 54 | onPlace(e, e.getBlockPlaced()); 55 | } 56 | }); 57 | 58 | } 59 | 60 | protected void onBreak(BlockBreakEvent e, Location l) {}; 61 | 62 | protected void onPlace(BlockPlaceEvent e, Block blockPlaced) {}; 63 | 64 | protected boolean checkTickPreconditions(Block b) { return true; }; 65 | protected boolean onTickFinish(Block b) { return true; } 66 | 67 | protected abstract void tick(Block b, SlimefunItem item); 68 | 69 | protected boolean isSynchronized() { 70 | return false; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/abstracts/AbstractTickingContainer.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.abstracts; 2 | 3 | import org.bukkit.block.Block; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 7 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 8 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 9 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 10 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 11 | import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker; 12 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 13 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 14 | 15 | public abstract class AbstractTickingContainer extends AbstractContainer { 16 | 17 | protected AbstractTickingContainer(ItemGroup itemGroup, SlimefunItemStack item ,RecipeType recipeType, ItemStack[] recipe) { 18 | super(itemGroup, item, recipeType, recipe); 19 | } 20 | 21 | @Override 22 | public void preRegister() { 23 | super.preRegister(); 24 | 25 | addItemHandler(new BlockTicker() { 26 | @Override 27 | public boolean isSynchronized() { 28 | return AbstractTickingContainer.this.isSynchronized(); 29 | } 30 | 31 | @Override 32 | public void tick(Block b, SlimefunItem item, Config data) { 33 | BlockMenu menu = BlockStorage.getInventory(b); 34 | if (menu != null) { 35 | AbstractTickingContainer.this.tick(menu, b); 36 | } 37 | } 38 | 39 | }); 40 | } 41 | 42 | protected abstract void tick(BlockMenu menu, Block b); 43 | 44 | protected boolean isSynchronized() { 45 | return false; 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/backpacks/SoulboundPicnicBacket.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.backpacks; 2 | 3 | import javax.annotation.ParametersAreNonnullByDefault; 4 | 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 8 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 9 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 10 | import io.github.thebusybiscuit.slimefun4.core.attributes.Soulbound; 11 | 12 | public class SoulboundPicnicBacket extends PicnicBasket implements Soulbound { 13 | 14 | @ParametersAreNonnullByDefault 15 | public SoulboundPicnicBacket(int size, ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 16 | super(size, itemGroup, item, recipeType, recipe); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/AntigravityBubble.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import me.profelements.dynatech.DynaTech; 8 | import me.profelements.dynatech.items.abstracts.AbstractElectricTicker; 9 | 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.GameMode; 12 | import org.bukkit.Location; 13 | import org.bukkit.block.Block; 14 | import org.bukkit.entity.Entity; 15 | import org.bukkit.entity.Player; 16 | import org.bukkit.event.EventHandler; 17 | import org.bukkit.event.Listener; 18 | import org.bukkit.event.block.BlockBreakEvent; 19 | import org.bukkit.event.block.BlockPlaceEvent; 20 | import org.bukkit.event.player.PlayerTeleportEvent; 21 | import org.bukkit.event.world.ChunkUnloadEvent; 22 | import org.bukkit.inventory.ItemStack; 23 | 24 | import java.util.Collection; 25 | import java.util.HashMap; 26 | import java.util.HashSet; 27 | import java.util.Iterator; 28 | import java.util.Map; 29 | import java.util.Set; 30 | import java.util.UUID; 31 | 32 | public class AntigravityBubble extends AbstractElectricTicker implements Listener { 33 | 34 | private final Map> enabledPlayers = new HashMap<>(); 35 | private final Set teleportedPlayers = new HashSet<>(); 36 | 37 | public AntigravityBubble(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 38 | super(itemGroup, item, recipeType, recipe); 39 | Bukkit.getPluginManager().registerEvents(this, DynaTech.getInstance()); 40 | } 41 | 42 | @Override 43 | protected void onPlace(BlockPlaceEvent e, Block blockPlaced) { 44 | enabledPlayers.put(blockPlaced.getLocation(), new HashSet<>()); 45 | } 46 | 47 | @Override 48 | protected void onBreak(BlockBreakEvent e, Location l) { 49 | for (UUID plyr : enabledPlayers.get(l)) { 50 | Player player = Bukkit.getPlayer(plyr); 51 | 52 | player.setAllowFlight(false); 53 | player.setFlying(false); 54 | player.setFallDistance(0.f); 55 | } 56 | 57 | enabledPlayers.remove(l); 58 | 59 | } 60 | 61 | @EventHandler 62 | public void onPlayerTeleport(PlayerTeleportEvent e) { 63 | if (e.getPlayer() != null) { 64 | teleportedPlayers.add(e.getPlayer().getUniqueId()); 65 | } 66 | } 67 | 68 | @EventHandler 69 | public void onChunkUnload(ChunkUnloadEvent e) { 70 | for (Map.Entry> entry : enabledPlayers.entrySet()) { 71 | if (entry.getKey().getChunk() == e.getChunk()) { 72 | Set players = enabledPlayers.getOrDefault(entry.getKey(), new HashSet<>()); 73 | for (Iterator iterator = players.iterator(); iterator.hasNext();) { 74 | Player p = Bukkit.getPlayer(iterator.next()); 75 | 76 | if (p != null) { 77 | p.setAllowFlight(false); 78 | p.setFlying(false); 79 | p.setFallDistance(0.f); 80 | 81 | iterator.remove(); 82 | } 83 | } 84 | break; 85 | } 86 | } 87 | enabledPlayers.entrySet().removeIf(entry -> entry.getKey().getChunk().equals(e.getChunk())); 88 | } 89 | 90 | @Override 91 | protected void tick(Block b, SlimefunItem item) { 92 | Collection bubbledEntities = b.getWorld().getNearbyEntities(b.getLocation(), 16, 16, 16, Player.class::isInstance); 93 | for (Entity entity : bubbledEntities) { 94 | Player p = (Player) entity; 95 | 96 | if (!p.getAllowFlight() && (p.getGameMode() != GameMode.CREATIVE || p.getGameMode() != GameMode.SPECTATOR)) { 97 | enabledPlayers.getOrDefault(b.getLocation(), new HashSet<>()).add(p.getUniqueId()); 98 | p.setAllowFlight(true); 99 | } 100 | } 101 | 102 | Set players = enabledPlayers.getOrDefault(b.getLocation(), new HashSet<>()); 103 | for (Iterator iterator = players.iterator(); iterator.hasNext(); ) { 104 | UUID id = iterator.next(); 105 | Player p = Bukkit.getPlayer(id); 106 | 107 | if (p != null && !bubbledEntities.contains(p) || (p != null && teleportedPlayers.contains(id))) { 108 | p.setAllowFlight(false); 109 | p.setFlying(false); 110 | p.setFallDistance(0.f); 111 | 112 | iterator.remove(); 113 | } 114 | } 115 | 116 | teleportedPlayers.clear(); 117 | } 118 | 119 | @Override 120 | protected boolean isSynchronized() { 121 | return true; 122 | } 123 | } 124 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/BarbedWire.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import javax.annotation.ParametersAreNonnullByDefault; 7 | 8 | import org.bukkit.Location; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.entity.Entity; 11 | import org.bukkit.entity.EntityType; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.util.NumberConversions; 14 | import org.bukkit.util.Vector; 15 | 16 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 17 | import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 18 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 19 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 20 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 21 | import me.profelements.dynatech.items.abstracts.AbstractElectricTicker; 22 | 23 | public class BarbedWire extends AbstractElectricTicker { 24 | 25 | private static final int DEFAULT_ENTITY_PUSH_FORCE = 10; 26 | private static final int DEFAULT_ENTITY_DETECT_RANGE = 9; 27 | 28 | private final ItemSetting entityPushForce = new ItemSetting<>(this, "entity-push-force", DEFAULT_ENTITY_PUSH_FORCE); 29 | private final ItemSetting entityDetectRange = new ItemSetting<>(this, "entity-detect-range", DEFAULT_ENTITY_DETECT_RANGE); 30 | 31 | @ParametersAreNonnullByDefault 32 | public BarbedWire(ItemGroup group, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 33 | super(group, item, recipeType, recipe); 34 | addItemSetting(entityPushForce, entityDetectRange); 35 | } 36 | 37 | private List getEntityWhitelist() { 38 | ArrayList whitelist = new ArrayList<>(); 39 | 40 | whitelist.add(EntityType.ARROW); 41 | whitelist.add(EntityType.BLAZE); 42 | whitelist.add(EntityType.CAVE_SPIDER); 43 | whitelist.add(EntityType.CREEPER); 44 | whitelist.add(EntityType.DRAGON_FIREBALL); 45 | whitelist.add(EntityType.DROWNED); 46 | whitelist.add(EntityType.ELDER_GUARDIAN); 47 | whitelist.add(EntityType.ENDER_DRAGON); 48 | whitelist.add(EntityType.ENDERMAN); 49 | whitelist.add(EntityType.ENDERMITE); 50 | whitelist.add(EntityType.EVOKER); 51 | whitelist.add(EntityType.FIREBALL); 52 | whitelist.add(EntityType.GHAST); 53 | whitelist.add(EntityType.GIANT); 54 | whitelist.add(EntityType.GUARDIAN); 55 | whitelist.add(EntityType.HOGLIN); 56 | whitelist.add(EntityType.HUSK); 57 | whitelist.add(EntityType.ILLUSIONER); 58 | whitelist.add(EntityType.MAGMA_CUBE); 59 | whitelist.add(EntityType.PHANTOM); 60 | whitelist.add(EntityType.PIGLIN); 61 | whitelist.add(EntityType.PIGLIN_BRUTE); 62 | whitelist.add(EntityType.PILLAGER); 63 | whitelist.add(EntityType.RAVAGER); 64 | whitelist.add(EntityType.SHULKER); 65 | whitelist.add(EntityType.SHULKER_BULLET); 66 | whitelist.add(EntityType.SILVERFISH); 67 | whitelist.add(EntityType.SKELETON); 68 | whitelist.add(EntityType.SLIME); 69 | whitelist.add(EntityType.SMALL_FIREBALL); 70 | whitelist.add(EntityType.SPIDER); 71 | whitelist.add(EntityType.STRAY); 72 | whitelist.add(EntityType.VEX); 73 | whitelist.add(EntityType.VINDICATOR); 74 | whitelist.add(EntityType.WARDEN); 75 | whitelist.add(EntityType.WITCH); 76 | whitelist.add(EntityType.WITHER); 77 | whitelist.add(EntityType.WITHER_SKELETON); 78 | whitelist.add(EntityType.WITHER_SKULL); 79 | whitelist.add(EntityType.ZOGLIN); 80 | whitelist.add(EntityType.ZOMBIE); 81 | whitelist.add(EntityType.ZOMBIFIED_PIGLIN); 82 | 83 | return whitelist; 84 | } 85 | 86 | protected void tick(Block block, SlimefunItem item) { 87 | int entityDetectionRange = entityDetectRange.getValue(); 88 | List entityTypeWhitelist = getEntityWhitelist(); 89 | Location loc = block.getLocation(); 90 | 91 | for (Entity e : block.getWorld().getNearbyEntities(loc, entityDetectionRange, entityDetectionRange, entityDetectionRange)) { 92 | if (entityTypeWhitelist.contains(e.getType())) { 93 | 94 | /// Find the Direction Vector. normailze it. multiply by the push force. apply it to the entity. 95 | Vector launchDirection = loc.subtract(e.getLocation()).toVector().normalize().multiply(entityPushForce.getValue()); 96 | 97 | /// If any of the components are not finite just set it to zero. 98 | if (NumberConversions.isFinite(launchDirection.getX()) && NumberConversions.isFinite(launchDirection.getY()) 99 | && NumberConversions.isFinite(launchDirection.getZ())) { 100 | e.setVelocity(launchDirection); 101 | } else { 102 | e.setVelocity(new Vector(0, 0, 0)); 103 | } 104 | } 105 | } 106 | } 107 | 108 | @Override 109 | protected boolean isSynchronized() { 110 | return true; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/FurnaceController.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | import java.util.List; 6 | import java.util.Set; 7 | 8 | import org.bukkit.Material; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.block.BlockFace; 11 | import org.bukkit.block.BlockState; 12 | import org.bukkit.block.Furnace; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 16 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 17 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 18 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 19 | import io.github.thebusybiscuit.slimefun4.libraries.paperlib.PaperLib; 20 | import io.github.thebusybiscuit.slimefun4.libraries.paperlib.features.blockstatesnapshot.BlockStateSnapshotResult; 21 | import me.profelements.dynatech.items.abstracts.AbstractElectricTicker; 22 | 23 | public class FurnaceController extends AbstractElectricTicker { 24 | 25 | private static final Set ignoredFaces = new HashSet<>(); 26 | 27 | public FurnaceController(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 28 | super(itemGroup, item, recipeType, recipe); 29 | 30 | ignoredFaces.add(BlockFace.UP); 31 | ignoredFaces.add(BlockFace.DOWN); 32 | ignoredFaces.add(BlockFace.NORTH_NORTH_EAST); 33 | ignoredFaces.add(BlockFace.NORTH_NORTH_WEST); 34 | ignoredFaces.add(BlockFace.SOUTH_SOUTH_EAST); 35 | ignoredFaces.add(BlockFace.SOUTH_SOUTH_WEST); 36 | ignoredFaces.add(BlockFace.WEST_NORTH_WEST); 37 | ignoredFaces.add(BlockFace.WEST_SOUTH_WEST); 38 | ignoredFaces.add(BlockFace.EAST_SOUTH_EAST); 39 | ignoredFaces.add(BlockFace.EAST_NORTH_EAST); 40 | 41 | } 42 | 43 | protected void tick(Block b, SlimefunItem item) { 44 | for (BlockFace face : BlockFace.values()) { 45 | if (ignoredFaces.contains(face)) { 46 | continue; 47 | } 48 | 49 | Block relBlock = b.getRelative(face); 50 | if (getMachines().contains(relBlock.getType())) { 51 | BlockStateSnapshotResult result = PaperLib.getBlockState(relBlock, false); 52 | BlockState state = result.getState(); 53 | 54 | if (state instanceof Furnace furnace && furnace.getCookTimeTotal() > 0) { 55 | furnace.setBurnTime((short) 1600); 56 | 57 | if (result.isSnapshot()) { 58 | state.update(true, true); 59 | } 60 | } 61 | } 62 | } 63 | } 64 | 65 | @Override 66 | protected boolean isSynchronized() { 67 | return true; 68 | } 69 | 70 | 71 | private List getMachines() { 72 | List machines = new ArrayList<>(); 73 | 74 | machines.add(Material.FURNACE); 75 | machines.add(Material.BLAST_FURNACE); 76 | machines.add(Material.SMOKER); 77 | 78 | return machines; 79 | } 80 | } 81 | 82 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/KitchenAutoCrafter.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import javax.annotation.ParametersAreNonnullByDefault; 4 | 5 | import org.bukkit.inventory.ItemStack; 6 | 7 | import io.github.thebusybiscuit.exoticgarden.ExoticGardenRecipeTypes; 8 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 9 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 10 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 11 | import io.github.thebusybiscuit.slimefun4.implementation.items.autocrafters.SlimefunAutoCrafter; 12 | 13 | public class KitchenAutoCrafter extends SlimefunAutoCrafter { 14 | 15 | @ParametersAreNonnullByDefault 16 | public KitchenAutoCrafter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 17 | super(itemGroup, item, recipeType, recipe, ExoticGardenRecipeTypes.KITCHEN); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/SeedPlucker.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 8 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 9 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 10 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 11 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 12 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 13 | import me.profelements.dynatech.items.abstracts.AbstractElectricMachine; 14 | 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | import org.bukkit.Material; 19 | import org.bukkit.entity.Player; 20 | import org.bukkit.event.inventory.InventoryClickEvent; 21 | import org.bukkit.inventory.ItemStack; 22 | 23 | public class SeedPlucker extends AbstractElectricMachine { 24 | 25 | private static final int[] INPUT_SLOTS = new int[] { 19, 20 }; 26 | private static final int[] OUTPUT_SLOTS = new int[] { 24, 25 }; 27 | 28 | private static final int[] INPUT_BORDER_SLOTS = new int[] { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; 29 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; 30 | private static final int[] BACKGROUND_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44 }; 31 | 32 | private static final ItemStack PROGRESS_ITEM = new ItemStack(Material.IRON_HOE); 33 | 34 | private final ItemSetting exoticGardenIntegration = new ItemSetting<>(this, "exotic-garden-integration", true); 35 | 36 | public SeedPlucker(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 37 | super(itemGroup, item, recipeType, recipe); 38 | 39 | addItemSetting(exoticGardenIntegration); 40 | } 41 | 42 | public void registerDefaultRecipes() { 43 | recipes.add(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.CHORUS_FRUIT, 4)}, new ItemStack[] {new ItemStack(Material.CHORUS_FLOWER)})); 44 | recipes.add(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.WHEAT)}, new ItemStack[] {new ItemStack(Material.WHEAT_SEEDS)})); 45 | recipes.add(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.BEETROOT)}, new ItemStack[] {new ItemStack(Material.BEETROOT_SEEDS)})); 46 | recipes.add(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.PUMPKIN)}, new ItemStack[] {new ItemStack(Material.PUMPKIN_SEEDS)})); 47 | recipes.add(new MachineRecipe(10, new ItemStack[] {new ItemStack(Material.MELON_SLICE)}, new ItemStack[] {new ItemStack(Material.MELON_SEEDS)})); 48 | } 49 | 50 | @Override 51 | protected ItemStack getProgressBar() { 52 | return PROGRESS_ITEM; 53 | } 54 | 55 | @Override 56 | public void postRegister() { 57 | super.postRegister(); 58 | registerDefaultRecipes(); 59 | } 60 | 61 | @Override 62 | protected void setupMenu(BlockMenuPreset preset) { 63 | for (int slot : BACKGROUND_SLOTS) { 64 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 65 | } 66 | 67 | for (int slot : INPUT_BORDER_SLOTS) { 68 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 69 | } 70 | 71 | for (int slot : OUTPUT_BORDER_SLOTS) { 72 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 73 | } 74 | 75 | preset.addItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); 76 | 77 | for (int slot : getOutputSlots()) { 78 | preset.addMenuClickHandler(slot,new ChestMenu.AdvancedMenuClickHandler() { 79 | @Override 80 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { 81 | return cursor.getType().isAir(); 82 | } 83 | 84 | @Override 85 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 86 | return false; 87 | } 88 | }); 89 | } 90 | } 91 | 92 | @Override 93 | protected int[] getInputSlots() { 94 | return INPUT_SLOTS; 95 | } 96 | 97 | @Override 98 | protected int[] getOutputSlots() { 99 | return OUTPUT_SLOTS; 100 | } 101 | 102 | @Override 103 | public List getDisplayRecipes() { 104 | List display = new ArrayList<>(); 105 | 106 | 107 | 108 | for (MachineRecipe recipe : recipes) { 109 | 110 | if (recipe.getInput().length != 1) { 111 | break; 112 | } 113 | 114 | display.add(recipe.getInput()[0]); 115 | display.add(recipe.getOutput()[0]); 116 | } 117 | 118 | return display; 119 | } 120 | 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/WeatherController.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.RecipeDisplayItem; 8 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 9 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 10 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; 11 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 12 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 13 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 14 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 15 | import me.mrCookieSlime.Slimefun.api.item_transport.ItemTransportFlow; 16 | import me.profelements.dynatech.DynaTech; 17 | import me.profelements.dynatech.items.abstracts.AbstractElectricTicker; 18 | 19 | import org.bukkit.Location; 20 | import org.bukkit.Material; 21 | import org.bukkit.block.Block; 22 | import org.bukkit.entity.Player; 23 | import org.bukkit.event.block.BlockBreakEvent; 24 | import org.bukkit.inventory.ItemStack; 25 | 26 | import javax.annotation.Nonnull; 27 | import java.util.ArrayList; 28 | import java.util.List; 29 | 30 | public class WeatherController extends AbstractElectricTicker implements RecipeDisplayItem { 31 | 32 | private static final int[] BACKGROUND_SLOTS = new int[] {0,1,2,3,5,6,7,8}; 33 | private static final int[] INPUT_BORDER_SLOTS = new int[] {}; 34 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {}; 35 | 36 | public WeatherController(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 37 | super(itemGroup, item, recipeType, recipe); 38 | 39 | new BlockMenuPreset(getId(), getItemName()) { 40 | @Override 41 | public void init() { 42 | setupMenu(this); 43 | } 44 | 45 | @Override 46 | public boolean canOpen(Block b, Player p) { 47 | return p.hasPermission("slimefun.inventory.bypass") || Slimefun.getProtectionManager().hasPermission(p, b.getLocation(), Interaction.INTERACT_BLOCK); 48 | } 49 | 50 | @Nonnull 51 | @Override 52 | public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) { 53 | return new int[] {}; 54 | } 55 | 56 | }; 57 | 58 | } 59 | 60 | protected void setupMenu(BlockMenuPreset preset) { 61 | for (int slot : BACKGROUND_SLOTS) { 62 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 63 | } 64 | 65 | for (int slot : INPUT_BORDER_SLOTS) { 66 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 67 | } 68 | 69 | for (int slot : OUTPUT_BORDER_SLOTS) { 70 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 71 | } 72 | 73 | } 74 | 75 | public void tick(Block b, SlimefunItem sfItem) { 76 | if (getCharge(b.getLocation()) < getEnergyConsumption()) { 77 | return; 78 | } 79 | 80 | BlockMenu menu = BlockStorage.getInventory(b); 81 | ItemStack item = menu.getItemInSlot(4); 82 | 83 | if (item != null && (item.getType() == Material.SUNFLOWER || item.getType() == Material.LILAC || item.getType() == Material.CREEPER_HEAD)) { 84 | if (item.getType() == Material.SUNFLOWER) { 85 | if (b.getWorld().isClearWeather()) { 86 | return; 87 | } 88 | DynaTech.runSync(() -> { 89 | b.getWorld().setClearWeatherDuration(1200); 90 | removeCharge(b.getLocation(), getEnergyConsumption()); 91 | }); 92 | } 93 | 94 | if (item.getType() == Material.LILAC) { 95 | if (b.getWorld().hasStorm()) { 96 | return; 97 | } 98 | DynaTech.runSync(() -> { 99 | b.getWorld().setStorm(true); 100 | b.getWorld().setWeatherDuration(1200); 101 | removeCharge(b.getLocation(), getEnergyConsumption()); 102 | }); 103 | } 104 | 105 | if (item.getType() == Material.CREEPER_HEAD) { 106 | if (b.getWorld().isThundering()) { 107 | return; 108 | } 109 | DynaTech.runSync(()-> { 110 | b.getWorld().setThundering(true); 111 | b.getWorld().setThunderDuration(1200); 112 | removeCharge(b.getLocation(), getEnergyConsumption()); 113 | }); 114 | } 115 | } 116 | } 117 | 118 | @Override 119 | protected void onBreak(BlockBreakEvent e, Location l) { 120 | l.getWorld().setClearWeatherDuration(60); 121 | } 122 | 123 | @Nonnull 124 | @Override 125 | public List getDisplayRecipes() { 126 | List items = new ArrayList<>(); 127 | items.add(new ItemStack(Material.SUNFLOWER)); 128 | items.add(new CustomItemStack(Material.DIAMOND, "&fMakes its sunny in philadelphia.")); 129 | 130 | items.add(new ItemStack(Material.LILAC)); 131 | items.add(new CustomItemStack(Material.DIAMOND, "&fMakes its rain while the old man snores")); 132 | 133 | items.add(new ItemStack(Material.CREEPER_HEAD)); 134 | items.add(new CustomItemStack(Material.DIAMOND, "&fMakes it thunder.")); 135 | 136 | return items; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/WirelessCharger.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; 8 | import me.profelements.dynatech.items.abstracts.AbstractElectricTicker; 9 | import org.bukkit.block.Block; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | public class WirelessCharger extends AbstractElectricTicker { 14 | 15 | private final double radius; 16 | 17 | public WirelessCharger(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, double radius) { 18 | super(itemGroup, item, recipeType, recipe); 19 | this.radius = radius; 20 | } 21 | 22 | @Override 23 | protected boolean checkTickPreconditions(Block b) { 24 | return true; 25 | } 26 | 27 | @Override 28 | protected void tick(Block b, SlimefunItem slimefunItem) { 29 | if (getCharge(b.getLocation()) < getEnergyConsumption()) { 30 | return; 31 | } 32 | 33 | for (Player p : b.getWorld().getPlayers()) { 34 | double distance = p.getLocation().distance(b.getLocation()); 35 | 36 | if (distance <= radius) { 37 | for (ItemStack item : p.getInventory()) { 38 | SlimefunItem sfItem = SlimefunItem.getByItem(item); 39 | 40 | if (sfItem instanceof Rechargeable rcItem && rcItem.getItemCharge(item) != rcItem.getMaxItemCharge(item)) { 41 | 42 | removeCharge(b.getLocation(), getEnergyConsumption()); 43 | rcItem.addItemCharge(item, getEnergyConsumption()); 44 | p.updateInventory(); 45 | 46 | } 47 | } 48 | } 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/DragonEggGenerator.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; 8 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 9 | import org.bukkit.Location; 10 | import org.bukkit.Material; 11 | import org.bukkit.block.Block; 12 | import org.bukkit.block.BlockFace; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | import javax.annotation.Nonnull; 16 | 17 | public class DragonEggGenerator extends SlimefunItem implements EnergyNetProvider { 18 | 19 | public DragonEggGenerator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 20 | super(itemGroup, item, recipeType, recipe); 21 | } 22 | 23 | @Override 24 | public int getGeneratedOutput(@Nonnull Location location, @Nonnull Config config) { 25 | Block dragonEgg = location.getBlock().getRelative(BlockFace.UP); 26 | if (dragonEgg.getType() == Material.DRAGON_EGG) { 27 | return 32; 28 | } 29 | 30 | return 0; 31 | } 32 | 33 | @Override 34 | public int getCapacity() { 35 | return 512; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/EggMill.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.Material; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.block.BlockFace; 9 | import org.bukkit.event.block.BlockBreakEvent; 10 | import org.bukkit.event.block.BlockPlaceEvent; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 14 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 15 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 16 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; 17 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 18 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; 19 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 20 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 21 | import me.profelements.dynatech.utils.Recipe; 22 | 23 | public class EggMill extends SlimefunItem implements EnergyNetProvider { 24 | 25 | private static final String DURABILITY_STRING = "dynatech:durability"; 26 | 27 | private final int durabilityMax; 28 | private final int energyRate; 29 | private final int energyMax; 30 | 31 | public EggMill(ItemGroup group, SlimefunItemStack stack, Recipe recipe, int durabilityMax, int energyRate, 32 | int energyMax) { 33 | super(group, stack, recipe.getRecipeType(), recipe.getInput()); 34 | 35 | this.durabilityMax = durabilityMax; 36 | this.energyRate = energyRate; 37 | this.energyMax = energyMax; 38 | 39 | addItemHandler(onBlockPlace()); 40 | addItemHandler(onBlockBreak()); 41 | } 42 | 43 | private final BlockPlaceHandler onBlockPlace() { 44 | return new BlockPlaceHandler(false) { 45 | @Override 46 | public void onPlayerPlace(BlockPlaceEvent event) { 47 | BlockStorage.addBlockInfo(event.getBlock(), DURABILITY_STRING, String.valueOf(durabilityMax)); 48 | 49 | } 50 | }; 51 | } 52 | 53 | private final BlockBreakHandler onBlockBreak() { 54 | return new BlockBreakHandler(false, false) { 55 | 56 | @Override 57 | public void onPlayerBreak(BlockBreakEvent event, ItemStack tool, List drops) { 58 | Location l = event.getBlock().getLocation(); 59 | 60 | int currDurability = Integer 61 | .parseInt(BlockStorage.getLocationInfo(l, DURABILITY_STRING)); 62 | 63 | if (currDurability <= 0) { 64 | event.setDropItems(false); 65 | String id = BlockStorage.getLocationInfo(l, "id"); 66 | if (id != null && SlimefunItem.getById(id + "_DEGRADED") != null) { 67 | ItemStack item = SlimefunItem.getById(id + "_DEGRADED").getItem(); 68 | l.getWorld().dropItemNaturally(l, item); 69 | } 70 | } 71 | 72 | BlockStorage.clearBlockInfo(l); 73 | } 74 | 75 | }; 76 | 77 | } 78 | 79 | @Override 80 | public int getCapacity() { 81 | return this.energyMax; 82 | } 83 | 84 | @Override 85 | public int getGeneratedOutput(Location l, Config cfg) { 86 | int energy = 0; 87 | int currDurability = Integer 88 | .parseInt(BlockStorage.getLocationInfo(l, DURABILITY_STRING)); 89 | 90 | if (currDurability > 0) { 91 | Block block = l.getBlock().getRelative(BlockFace.UP); 92 | if (block.getType().equals(Material.DRAGON_EGG)) { 93 | energy = this.energyRate; 94 | } 95 | } 96 | 97 | BlockStorage.addBlockInfo(l, DURABILITY_STRING, String.valueOf(Math.max(currDurability - 1, 0))); 98 | return energy; 99 | 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/HydroGenerator.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 8 | import me.profelements.dynatech.registries.Items; 9 | 10 | import java.util.List; 11 | 12 | import org.bukkit.event.block.BlockBreakEvent; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | public class HydroGenerator extends SlimefunItem { 16 | 17 | private final int energy; 18 | 19 | public HydroGenerator(ItemGroup itemGroup, int energy, SlimefunItemStack item, RecipeType recipeType, 20 | ItemStack[] recipe) { 21 | super(itemGroup, item, recipeType, recipe); 22 | 23 | this.energy = energy; 24 | 25 | addItemHandler(onBlockBreak()); 26 | } 27 | 28 | private BlockBreakHandler onBlockBreak() { 29 | return new BlockBreakHandler(false, false) { 30 | @Override 31 | public void onPlayerBreak(BlockBreakEvent event, ItemStack arg1, List arg2) { 32 | arg2.clear(); 33 | event.getBlock().getWorld().dropItemNaturally(event.getBlock().getLocation(), 34 | Items.DEGRADED_WATER_MILL.stack()); 35 | } 36 | }; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/StardustReactor.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.common.ChatColors; 7 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 8 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 9 | import io.github.thebusybiscuit.slimefun4.utils.NumberUtils; 10 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 11 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 12 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineFuel; 13 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 14 | import me.profelements.dynatech.items.abstracts.AbstractGenerator; 15 | import me.profelements.dynatech.registries.Items; 16 | 17 | import org.bukkit.Material; 18 | import org.bukkit.entity.Player; 19 | import org.bukkit.event.inventory.InventoryClickEvent; 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | import javax.annotation.Nonnull; 27 | 28 | public class StardustReactor extends AbstractGenerator { 29 | 30 | private static final int[] INPUT_SLOTS = new int[] { 19, 20 }; 31 | private static final int[] OUTPUT_SLOTS = new int[] { 24, 25 }; 32 | 33 | private static final int[] INPUT_BORDER_SLOTS = new int[] { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; 34 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] { 14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; 35 | private static final int[] BACKGROUND_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 36 | 42, 43, 44 }; 37 | 38 | private static final ItemStack PROGRESS_ITEM = new ItemStack(Material.IRON_CHESTPLATE); 39 | 40 | public StardustReactor(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 41 | super(itemGroup, item, recipeType, recipe); 42 | 43 | } 44 | 45 | @Override 46 | public void postRegister() { 47 | registerDefaultFuelTypes(); 48 | } 49 | 50 | protected void registerDefaultFuelTypes() { 51 | fuels.add(new MachineFuel(32, Items.STAR_DUST.stack())); 52 | } 53 | 54 | @Nonnull 55 | @Override 56 | public ItemStack getProgressBar() { 57 | return PROGRESS_ITEM; 58 | } 59 | 60 | @Override 61 | protected void setupMenu(BlockMenuPreset preset) { 62 | for (int slot : BACKGROUND_SLOTS) { 63 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 64 | } 65 | 66 | for (int slot : INPUT_BORDER_SLOTS) { 67 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 68 | } 69 | 70 | for (int slot : OUTPUT_BORDER_SLOTS) { 71 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 72 | } 73 | 74 | preset.addItem(22, new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), 75 | ChestMenuUtils.getEmptyClickHandler()); 76 | for (int slot : getOutputSlots()) { 77 | preset.addMenuClickHandler(slot, new ChestMenu.AdvancedMenuClickHandler() { 78 | @Override 79 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, 80 | ClickAction action) { 81 | return cursor.getType().isAir(); 82 | } 83 | 84 | @Override 85 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 86 | return false; 87 | } 88 | }); 89 | } 90 | } 91 | 92 | @Override 93 | protected int[] getInputSlots() { 94 | return INPUT_SLOTS; 95 | } 96 | 97 | @Override 98 | protected int[] getOutputSlots() { 99 | return OUTPUT_SLOTS; 100 | } 101 | 102 | @Override 103 | public List getDisplayRecipes() { 104 | List list = new ArrayList<>(); 105 | 106 | for (MachineFuel fuel : fuels) { 107 | ItemStack item = fuel.getInput().clone(); 108 | ItemMeta im = item.getItemMeta(); 109 | List lore = new ArrayList<>(); 110 | lore.add(ChatColors.color("&8\u21E8 &7Lasts " + NumberUtils.getTimeLeft(fuel.getTicks() / 2))); 111 | lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" + getEnergyProduction() * 2) + " J/s"); 112 | lore.add(ChatColors.color("&8\u21E8 &e\u26A1 &7" 113 | + NumberUtils.getCompactDouble((double) fuel.getTicks() * getEnergyProduction()) + " J in total")); 114 | im.setLore(lore); 115 | item.setItemMeta(im); 116 | list.add(item); 117 | } 118 | 119 | return list; 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/WaterMill.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import java.util.HashMap; 4 | import java.util.List; 5 | 6 | import org.bukkit.Location; 7 | import org.bukkit.Material; 8 | import org.bukkit.block.Block; 9 | import org.bukkit.block.data.BlockData; 10 | import org.bukkit.block.data.Waterlogged; 11 | import org.bukkit.event.block.BlockBreakEvent; 12 | import org.bukkit.event.block.BlockPlaceEvent; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | import io.github.bakedlibs.dough.blocks.BlockPosition; 16 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 17 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 18 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 19 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; 20 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 21 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; 22 | import io.github.thebusybiscuit.slimefun4.libraries.paperlib.PaperLib; 23 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 24 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 25 | import me.profelements.dynatech.DynaTech; 26 | import me.profelements.dynatech.utils.Recipe; 27 | 28 | public class WaterMill extends SlimefunItem implements EnergyNetProvider { 29 | 30 | private static final String durabilityString = "durability"; 31 | 32 | private final HashMap durabilityMap = new HashMap<>(); 33 | private final HashMap hasWaterMap = new HashMap<>(); 34 | private final int energyCapacity; 35 | private final int energyOutAmount; 36 | private final int durabilityDefault; 37 | 38 | public WaterMill(ItemGroup group, SlimefunItemStack stack, Recipe recipe, int energyCapacity, int energyOutAmount, 39 | int durabilityDefault) { 40 | super(group, stack, recipe.getRecipeType(), recipe.getInput()); 41 | 42 | this.energyCapacity = energyCapacity; 43 | this.energyOutAmount = energyOutAmount; 44 | this.durabilityDefault = durabilityDefault; 45 | 46 | addItemHandler(onBlockPlace()); 47 | addItemHandler(onBlockBreak()); 48 | } 49 | 50 | private BlockPlaceHandler onBlockPlace() { 51 | return new BlockPlaceHandler(false) { 52 | 53 | @Override 54 | public void onPlayerPlace(BlockPlaceEvent event) { 55 | BlockStorage.addBlockInfo(event.getBlock(), durabilityString, String.valueOf(durabilityDefault)); 56 | } 57 | 58 | }; 59 | } 60 | 61 | private BlockBreakHandler onBlockBreak() { 62 | return new BlockBreakHandler(false, false) { 63 | @Override 64 | public void onPlayerBreak(BlockBreakEvent event, ItemStack arg1, List arg2) { 65 | 66 | final Location l = event.getBlock().getLocation(); 67 | final BlockPosition p = new BlockPosition(l); 68 | int durability = durabilityMap.get(p); 69 | 70 | if (durability == 0) { 71 | event.setDropItems(false); 72 | String id = BlockStorage.getLocationInfo(l, "id"); 73 | if (id != null && SlimefunItem.getById(id + "_DEGRADED") != null) { 74 | l.getWorld().dropItemNaturally(l, SlimefunItem.getById(id + "_DEGRADED").getItem()); 75 | 76 | } 77 | } 78 | 79 | durabilityMap.remove(p); 80 | hasWaterMap.remove(p); 81 | BlockStorage.clearBlockInfo(l); 82 | } 83 | }; 84 | } 85 | 86 | @Override 87 | public int getGeneratedOutput(Location l, Config c) { 88 | final BlockPosition pos = new BlockPosition(l); 89 | final Block block = pos.getBlock(); 90 | int energyAmount = 0; 91 | 92 | int durabilityDef = this.durabilityDefault; 93 | String durabilityStr = BlockStorage.getLocationInfo(l, durabilityString); 94 | 95 | if (durabilityStr != null) { 96 | durabilityDef = Integer.parseInt(durabilityStr); 97 | } 98 | 99 | int durability = durabilityMap.getOrDefault(pos, durabilityDef); 100 | boolean hasWater = hasWaterMap.getOrDefault(pos, false); 101 | if (DynaTech.getInstance().getTickInterval() % 600 == 0 || (durability == 2500 && hasWater == false)) { 102 | if (durability > 0 && block.getType() == Material.COBBLESTONE_WALL 103 | || block.getType() == Material.PRISMARINE_WALL) { 104 | final BlockData data = PaperLib.getBlockState(block, false).getState().getBlockData(); 105 | if (data instanceof Waterlogged wl && wl.isWaterlogged()) { 106 | hasWaterMap.put(pos, true); 107 | energyAmount = this.energyOutAmount; 108 | } else { 109 | hasWaterMap.put(pos, false); 110 | } 111 | } 112 | } else { 113 | if (hasWater == true && durability > 0) { 114 | energyAmount = this.energyOutAmount; 115 | } else { 116 | hasWaterMap.put(pos, false); 117 | } 118 | } 119 | 120 | int storageDurability = Math.max(durability - 1, 0); 121 | BlockStorage.addBlockInfo(l, durabilityString, String.valueOf(storageDurability)); 122 | durabilityMap.put(pos, storageDurability); 123 | 124 | return energyAmount; 125 | } 126 | 127 | @Override 128 | public int getCapacity() { 129 | return this.energyCapacity; 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/generators/WindMill.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.generators; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.Location; 6 | import org.bukkit.event.block.BlockBreakEvent; 7 | import org.bukkit.event.block.BlockPlaceEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 11 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 12 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 13 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetProvider; 14 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockBreakHandler; 15 | import io.github.thebusybiscuit.slimefun4.core.handlers.BlockPlaceHandler; 16 | import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config; 17 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 18 | import me.profelements.dynatech.utils.Recipe; 19 | 20 | public class WindMill extends SlimefunItem implements EnergyNetProvider { 21 | 22 | private final int energyMax; 23 | private final int energyMin; 24 | private final int energyCap; 25 | private final int durability; 26 | 27 | private static final String dura = "durability"; 28 | 29 | public WindMill(ItemGroup group, SlimefunItemStack stack, Recipe recipe, 30 | int energyMax, 31 | int energyMin, 32 | int energyCap, 33 | int durability) { 34 | super(group, stack, recipe.getRecipeType(), recipe.getInput()); 35 | 36 | this.energyMax = energyMax; 37 | this.energyMin = energyMin; 38 | this.energyCap = energyCap; 39 | this.durability = durability; 40 | 41 | addItemHandler(onBlockPlace()); 42 | addItemHandler(onBlockBreak()); 43 | } 44 | 45 | public BlockPlaceHandler onBlockPlace() { 46 | return new BlockPlaceHandler(false) { 47 | 48 | @Override 49 | public void onPlayerPlace(BlockPlaceEvent e) { 50 | BlockStorage.addBlockInfo(e.getBlock(), dura, String.valueOf(durability)); 51 | } 52 | 53 | }; 54 | } 55 | 56 | public BlockBreakHandler onBlockBreak() { 57 | return new BlockBreakHandler(false, false) { 58 | 59 | @Override 60 | public void onPlayerBreak(BlockBreakEvent e, ItemStack item, List drops) { 61 | 62 | Location l = e.getBlock().getLocation(); 63 | int durability = Integer.parseInt(BlockStorage.getLocationInfo(l, dura)); 64 | if (durability <= 0) { 65 | 66 | e.setDropItems(false); 67 | String id = BlockStorage.getLocationInfo(l, "id"); 68 | if (id != null && SlimefunItem.getById(id + "_DEGRADED") != null) { 69 | l.getWorld().dropItemNaturally(l, SlimefunItem.getById(id + "_DEGRADED").getItem()); 70 | } 71 | } 72 | 73 | BlockStorage.clearBlockInfo(l); 74 | } 75 | 76 | }; 77 | } 78 | 79 | @Override 80 | public int getCapacity() { 81 | return energyCap; 82 | } 83 | 84 | @Override 85 | public int getGeneratedOutput(Location l, Config cfg) { 86 | int energy = 0; 87 | 88 | int durability = this.durability; 89 | String locDurability = BlockStorage.getLocationInfo(l, dura); 90 | if (locDurability != null) { 91 | durability = Integer.parseInt(BlockStorage.getLocationInfo(l, dura)); 92 | } 93 | 94 | if (durability > 0) { 95 | final int y = Math.max(l.getBlockY(), 1); 96 | final float percent = (float) y / (float) l.getWorld().getMaxHeight(); 97 | 98 | final float yEnergy = Math.round((1 - percent) * (float) energyMin + percent * (float) energyMax); 99 | 100 | energy = (int) yEnergy; 101 | } 102 | durability = Math.max(durability - 1, 0); 103 | BlockStorage.addBlockInfo(l, dura, String.valueOf(durability)); 104 | 105 | return energy; 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/growthchambers/GrowthChamberEnd.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.growthchambers; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 7 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 8 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 9 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 10 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 12 | import me.profelements.dynatech.items.abstracts.AbstractElectricMachine; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import org.bukkit.Material; 18 | import org.bukkit.entity.Player; 19 | import org.bukkit.event.inventory.InventoryClickEvent; 20 | import org.bukkit.inventory.ItemStack; 21 | 22 | public class GrowthChamberEnd extends AbstractElectricMachine { 23 | 24 | private static final int[] INPUT_SLOTS = new int[] { 19, 20 }; 25 | private static final int[] OUTPUT_SLOTS = new int[] { 24, 25 }; 26 | 27 | private static final int[] INPUT_BORDER_SLOTS = new int[] { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; 28 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; 29 | private static final int[] BACKGROUND_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44 }; 30 | 31 | public static final ItemStack PROGRESS_ITEM = new ItemStack(Material.CHORUS_FLOWER); 32 | 33 | public GrowthChamberEnd(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 34 | super(itemGroup, item, recipeType, recipe); 35 | 36 | } 37 | 38 | @Override 39 | public void postRegister() { 40 | registerDefaultRecipes(); 41 | } 42 | 43 | protected void registerDefaultRecipes() { 44 | 45 | registerRecipe(9, new ItemStack[] {new ItemStack(Material.CHORUS_FLOWER)}, new ItemStack[] {new ItemStack(Material.CHORUS_FLOWER , 2), new ItemStack(Material.CHORUS_FRUIT, 8)}); 46 | 47 | } 48 | 49 | @Override 50 | public List getDisplayRecipes() { 51 | List display = new ArrayList<>(); 52 | for (MachineRecipe recipe : recipes) { 53 | display.add(recipe.getInput()[0]); 54 | if (recipe.getOutput().length > 1) { 55 | display.add(recipe.getOutput()[1]); 56 | } else { 57 | display.add(recipe.getOutput()[0]); 58 | } 59 | } 60 | return display; 61 | } 62 | 63 | @Override 64 | protected void setupMenu(BlockMenuPreset preset) { 65 | for (int slot : BACKGROUND_SLOTS) { 66 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 67 | } 68 | 69 | for (int slot : INPUT_BORDER_SLOTS) { 70 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 71 | } 72 | 73 | for (int slot : OUTPUT_BORDER_SLOTS) { 74 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 75 | } 76 | 77 | preset.addItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); 78 | 79 | for (int slot : getOutputSlots()) { 80 | preset.addMenuClickHandler(slot,new ChestMenu.AdvancedMenuClickHandler() { 81 | @Override 82 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { 83 | return cursor.getType().isAir(); 84 | } 85 | 86 | @Override 87 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 88 | return false; 89 | } 90 | }); 91 | } 92 | } 93 | 94 | @Override 95 | protected int[] getInputSlots() { 96 | return INPUT_SLOTS; 97 | } 98 | 99 | @Override 100 | protected int[] getOutputSlots() { 101 | return OUTPUT_SLOTS; 102 | } 103 | 104 | @Override 105 | protected ItemStack getProgressBar() { 106 | return PROGRESS_ITEM; 107 | } 108 | 109 | 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/growthchambers/GrowthChamberEndMK2.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.growthchambers; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 7 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 8 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 9 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 10 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 12 | import me.profelements.dynatech.items.abstracts.AbstractElectricMachine; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import org.bukkit.Material; 18 | import org.bukkit.entity.Player; 19 | import org.bukkit.event.inventory.InventoryClickEvent; 20 | import org.bukkit.inventory.ItemStack; 21 | 22 | public class GrowthChamberEndMK2 extends AbstractElectricMachine { 23 | 24 | private static final int[] INPUT_SLOTS = new int[] {1,2,3,4,5,6,7}; 25 | private static final int[] OUTPUT_SLOTS = new int[] {28,29,30,31,32,33,34,37,38,39,40,41,42,43,46,47,48,49,50,51,52}; 26 | 27 | private static final int[] INPUT_BORDER_SLOTS = new int[] {0,8,9,10,11,12,14,15,16,17}; 28 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {18,19,20,21,22,23,24,25,26,27,35,36,44,45,53}; 29 | private static final int[] BACKGROUND_SLOTS = new int[] {}; 30 | 31 | private static final ItemStack PROGRESS_ITEM = new ItemStack(Material.CHORUS_FLOWER); 32 | 33 | public GrowthChamberEndMK2(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 34 | super(itemGroup, item, recipeType, recipe); 35 | 36 | } 37 | 38 | @Override 39 | public void postRegister() { 40 | registerDefaultRecipes(); 41 | } 42 | 43 | protected void registerDefaultRecipes() { 44 | 45 | registerRecipe(9, new ItemStack[] {new ItemStack(Material.CHORUS_FLOWER)}, new ItemStack[] {new ItemStack(Material.CHORUS_FLOWER , 6), new ItemStack(Material.CHORUS_FRUIT, 24)}); 46 | 47 | } 48 | 49 | @Override 50 | public ItemStack getProgressBar() { 51 | return PROGRESS_ITEM; 52 | } 53 | 54 | @Override 55 | public int getProgressSlot() { 56 | return 13; 57 | } 58 | 59 | @Override 60 | public List getDisplayRecipes() { 61 | List display = new ArrayList<>(); 62 | for (MachineRecipe recipe : recipes) { 63 | display.add(recipe.getInput()[0]); 64 | if (recipe.getOutput().length > 1) { 65 | display.add(recipe.getOutput()[1]); 66 | } else { 67 | display.add(recipe.getOutput()[0]); 68 | } 69 | } 70 | return display; 71 | } 72 | 73 | @Override 74 | protected void setupMenu(BlockMenuPreset preset) { 75 | for (int slot : BACKGROUND_SLOTS) { 76 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 77 | } 78 | 79 | for (int slot : INPUT_BORDER_SLOTS) { 80 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 81 | } 82 | 83 | for (int slot : OUTPUT_BORDER_SLOTS) { 84 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 85 | } 86 | 87 | preset.addItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); 88 | for (int slot : getOutputSlots()) { 89 | preset.addMenuClickHandler(slot,new ChestMenu.AdvancedMenuClickHandler() { 90 | @Override 91 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { 92 | return cursor.getType().isAir(); 93 | } 94 | 95 | @Override 96 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 97 | return false; 98 | } 99 | }); 100 | } 101 | } 102 | 103 | @Override 104 | protected int[] getInputSlots() { 105 | return INPUT_SLOTS; 106 | } 107 | 108 | @Override 109 | protected int[] getOutputSlots() { 110 | return OUTPUT_SLOTS; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/growthchambers/GrowthChamberNether.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.growthchambers; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 7 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 8 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 9 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 10 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 12 | import me.profelements.dynatech.items.abstracts.AbstractElectricMachine; 13 | 14 | import java.util.ArrayList; 15 | import java.util.List; 16 | 17 | import org.bukkit.Material; 18 | import org.bukkit.entity.Player; 19 | import org.bukkit.event.inventory.InventoryClickEvent; 20 | import org.bukkit.inventory.ItemStack; 21 | 22 | public class GrowthChamberNether extends AbstractElectricMachine { 23 | private static final int[] INPUT_SLOTS = new int[] { 19, 20 }; 24 | private static final int[] OUTPUT_SLOTS = new int[] { 24, 25 }; 25 | 26 | private static final int[] INPUT_BORDER_SLOTS = new int[] { 9, 10, 11, 12, 18, 21, 27, 28, 29, 30 }; 27 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {14, 15, 16, 17, 23, 26, 32, 33, 34, 35 }; 28 | private static final int[] BACKGROUND_SLOTS = new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 13, 31, 36, 37, 38, 39, 40, 41, 42, 43, 44 }; 29 | 30 | private static final ItemStack PROGRESS_ITEM = new ItemStack(Material.NETHERRACK); 31 | 32 | public GrowthChamberNether(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 33 | super(itemGroup, item, recipeType, recipe); 34 | 35 | } 36 | 37 | @Override 38 | public void postRegister() { 39 | registerDefaultRecipes(); 40 | } 41 | 42 | protected void registerDefaultRecipes() { 43 | 44 | registerRecipe(12, new ItemStack(Material.NETHER_WART), new ItemStack(Material.NETHER_WART, 4)); 45 | registerRecipe(9, new ItemStack(Material.WEEPING_VINES), new ItemStack(Material.WEEPING_VINES, 4)); 46 | registerRecipe(9, new ItemStack(Material.TWISTING_VINES), new ItemStack(Material.TWISTING_VINES, 4)); 47 | registerRecipe(9, new ItemStack(Material.CRIMSON_ROOTS), new ItemStack(Material.CRIMSON_ROOTS, 4)); 48 | registerRecipe(9, new ItemStack(Material.WARPED_ROOTS), new ItemStack(Material.WARPED_ROOTS, 4)); 49 | registerRecipe(9, new ItemStack(Material.NETHER_SPROUTS), new ItemStack(Material.NETHER_SPROUTS, 4)); 50 | 51 | registerRecipe(30, new ItemStack[] {new ItemStack(Material.CRIMSON_FUNGUS)}, new ItemStack[] {new ItemStack(Material.CRIMSON_FUNGUS, 2), new ItemStack(Material.CRIMSON_STEM, 6)}); 52 | registerRecipe(30, new ItemStack[] {new ItemStack(Material.WARPED_FUNGUS)}, new ItemStack[] {new ItemStack(Material.WARPED_FUNGUS, 2), new ItemStack(Material.WARPED_STEM, 6)}); 53 | 54 | } 55 | 56 | @Override 57 | public List getDisplayRecipes() { 58 | List display = new ArrayList<>(); 59 | for (MachineRecipe recipe : recipes) { 60 | display.add(recipe.getInput()[0]); 61 | if (recipe.getOutput().length > 1) { 62 | display.add(recipe.getOutput()[1]); 63 | } else { 64 | display.add(recipe.getOutput()[0]); 65 | } 66 | } 67 | return display; 68 | } 69 | 70 | @Override 71 | protected void setupMenu(BlockMenuPreset preset) { 72 | for (int slot : BACKGROUND_SLOTS) { 73 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 74 | } 75 | 76 | for (int slot : INPUT_BORDER_SLOTS) { 77 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 78 | } 79 | 80 | for (int slot : OUTPUT_BORDER_SLOTS) { 81 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 82 | } 83 | 84 | preset.addItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); 85 | 86 | for (int slot : getOutputSlots()) { 87 | preset.addMenuClickHandler(slot,new ChestMenu.AdvancedMenuClickHandler() { 88 | @Override 89 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { 90 | return cursor.getType().isAir(); 91 | } 92 | 93 | @Override 94 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 95 | return false; 96 | } 97 | }); 98 | } 99 | } 100 | 101 | @Override 102 | protected int[] getInputSlots() { 103 | return INPUT_SLOTS; 104 | } 105 | 106 | @Override 107 | protected int[] getOutputSlots() { 108 | return OUTPUT_SLOTS; 109 | } 110 | 111 | 112 | @Override 113 | public ItemStack getProgressBar() { 114 | return PROGRESS_ITEM; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/growthchambers/GrowthChamberNetherMK2.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.growthchambers; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.libraries.dough.items.CustomItemStack; 7 | import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils; 8 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 9 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 10 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 11 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenuPreset; 12 | import me.profelements.dynatech.items.abstracts.AbstractElectricMachine; 13 | import org.bukkit.Material; 14 | import org.bukkit.entity.Player; 15 | import org.bukkit.event.inventory.InventoryClickEvent; 16 | import org.bukkit.inventory.ItemStack; 17 | 18 | import java.util.ArrayList; 19 | import java.util.List; 20 | 21 | public class GrowthChamberNetherMK2 extends AbstractElectricMachine { 22 | 23 | private static final int[] INPUT_SLOTS = new int[] {1,2,3,4,5,6,7}; 24 | private static final int[] OUTPUT_SLOTS = new int[] {28,29,30,31,32,33,34,37,38,39,40,41,42,43,46,47,48,49,50,51,52}; 25 | 26 | private static final int[] INPUT_BORDER_SLOTS = new int[] {0,8,9,10,11,12,14,15,16,17}; 27 | private static final int[] OUTPUT_BORDER_SLOTS = new int[] {18,19,20,21,22,23,24,25,26,27,35,36,44,45,53}; 28 | private static final int[] BACKGROUND_SLOTS = new int[] {}; 29 | 30 | private static final ItemStack PROGRESS_ITEM = new ItemStack(Material.NETHERRACK); 31 | 32 | public GrowthChamberNetherMK2(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 33 | super(itemGroup, item, recipeType, recipe); 34 | 35 | } 36 | 37 | @Override 38 | public void postRegister() { 39 | registerDefaultRecipes(); 40 | } 41 | 42 | protected void registerDefaultRecipes() { 43 | 44 | registerRecipe(12, new ItemStack(Material.NETHER_WART), new ItemStack(Material.NETHER_WART, 12)); 45 | registerRecipe(9, new ItemStack(Material.WEEPING_VINES), new ItemStack(Material.WEEPING_VINES, 12)); 46 | registerRecipe(9, new ItemStack(Material.TWISTING_VINES), new ItemStack(Material.TWISTING_VINES, 12)); 47 | registerRecipe(9, new ItemStack(Material.CRIMSON_ROOTS), new ItemStack(Material.CRIMSON_ROOTS, 12)); 48 | registerRecipe(9, new ItemStack(Material.WARPED_ROOTS), new ItemStack(Material.WARPED_ROOTS, 12)); 49 | registerRecipe(9, new ItemStack(Material.NETHER_SPROUTS), new ItemStack(Material.NETHER_SPROUTS, 12)); 50 | 51 | registerRecipe(30, new ItemStack[] {new ItemStack(Material.CRIMSON_FUNGUS)}, new ItemStack[] {new ItemStack(Material.CRIMSON_FUNGUS, 6), new ItemStack(Material.CRIMSON_STEM, 18), new ItemStack(Material.SHROOMLIGHT, 6), new ItemStack(Material.NETHER_WART_BLOCK, 12)}); 52 | registerRecipe(30, new ItemStack[] {new ItemStack(Material.WARPED_FUNGUS)}, new ItemStack[] {new ItemStack(Material.WARPED_FUNGUS, 6), new ItemStack(Material.WARPED_STEM, 18), new ItemStack(Material.SHROOMLIGHT, 6), new ItemStack(Material.WARPED_WART_BLOCK, 12)}); 53 | 54 | } 55 | 56 | @Override 57 | public int[] getInputSlots() { 58 | return INPUT_SLOTS; 59 | } 60 | @Override 61 | public int[] getOutputSlots() { 62 | return OUTPUT_SLOTS; 63 | } 64 | 65 | @Override 66 | public ItemStack getProgressBar() { 67 | return PROGRESS_ITEM; 68 | } 69 | 70 | @Override 71 | public int getProgressSlot() { 72 | return 13; 73 | } 74 | 75 | @Override 76 | public List getDisplayRecipes() { 77 | List display = new ArrayList<>(); 78 | for (MachineRecipe recipe : recipes) { 79 | display.add(recipe.getInput()[0]); 80 | if (recipe.getOutput().length > 1) { 81 | display.add(recipe.getOutput()[1]); 82 | } else { 83 | display.add(recipe.getOutput()[0]); 84 | } 85 | } 86 | return display; 87 | } 88 | 89 | @Override 90 | protected void setupMenu(BlockMenuPreset preset) { 91 | for (int slot : BACKGROUND_SLOTS) { 92 | preset.addItem(slot, ChestMenuUtils.getBackground(), ChestMenuUtils.getEmptyClickHandler()); 93 | } 94 | 95 | for (int slot : INPUT_BORDER_SLOTS) { 96 | preset.addItem(slot, ChestMenuUtils.getInputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 97 | } 98 | 99 | for (int slot : OUTPUT_BORDER_SLOTS) { 100 | preset.addItem(slot, ChestMenuUtils.getOutputSlotTexture(), ChestMenuUtils.getEmptyClickHandler()); 101 | } 102 | 103 | preset.addItem(getProgressSlot(), new CustomItemStack(Material.BLACK_STAINED_GLASS_PANE, " "), ChestMenuUtils.getEmptyClickHandler()); 104 | 105 | for (int slot : getOutputSlots()) { 106 | preset.addMenuClickHandler(slot,new ChestMenu.AdvancedMenuClickHandler() { 107 | @Override 108 | public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) { 109 | return cursor.getType().isAir(); 110 | } 111 | 112 | @Override 113 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 114 | return false; 115 | } 116 | }); 117 | } 118 | } 119 | 120 | 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/electric/transfer/WirelessEnergyBank.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.electric.transfer; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.EnergyNetComponent; 8 | import io.github.thebusybiscuit.slimefun4.core.networks.energy.EnergyNetComponentType; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | import javax.annotation.Nonnull; 12 | import javax.annotation.ParametersAreNonnullByDefault; 13 | 14 | public class WirelessEnergyBank extends SlimefunItem implements EnergyNetComponent { 15 | 16 | private final int capacity; 17 | 18 | @ParametersAreNonnullByDefault 19 | public WirelessEnergyBank(ItemGroup itemGroup, int capacity, SlimefunItemStack item, RecipeType recipeType, 20 | ItemStack[] recipe) { 21 | super(itemGroup, item, recipeType, recipe); 22 | 23 | this.capacity = capacity; 24 | } 25 | 26 | @Override 27 | @Nonnull 28 | public EnergyNetComponentType getEnergyComponentType() { 29 | return EnergyNetComponentType.CAPACITOR; 30 | } 31 | 32 | @Override 33 | public int getCapacity() { 34 | return capacity; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/Bee.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; 7 | 8 | import com.google.common.base.Preconditions; 9 | 10 | import org.bukkit.inventory.ItemStack; 11 | 12 | public class Bee extends UnplaceableBlock { 13 | 14 | private int speedMultiplier; 15 | 16 | public Bee(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, 17 | int speedMulitplier) { 18 | super(itemGroup, item, recipeType, recipe); 19 | this.speedMultiplier = speedMulitplier; 20 | } 21 | 22 | public float getSpeedMultipler() { 23 | return speedMultiplier; 24 | } 25 | 26 | public void setSpeedMultiplier(int speedMultiplier) { 27 | Preconditions.checkArgument(speedMultiplier > 0, " The Speed multipler must be greater then 0"); 28 | this.speedMultiplier = speedMultiplier; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/DimensionalHomeDimension.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import org.bukkit.Material; 4 | import org.bukkit.World; 5 | import org.bukkit.generator.ChunkGenerator; 6 | 7 | import javax.annotation.Nonnull; 8 | import javax.annotation.ParametersAreNonnullByDefault; 9 | import java.util.Random; 10 | 11 | public class DimensionalHomeDimension extends ChunkGenerator { 12 | 13 | @Nonnull 14 | @Override 15 | @ParametersAreNonnullByDefault 16 | public ChunkData generateChunkData(World world, Random random, int chunkx, int chunkz, BiomeGrid biomeGrid) { 17 | ChunkData chunkData = createChunkData(world); 18 | 19 | chunkData.setRegion(0, 59, 0, 16, 60, 16, Material.BEDROCK); 20 | for (int y = 60; y < 180; y++) { 21 | for (int x = 0; x < 16; x++) { 22 | chunkData.setBlock(x, y, 0, Material.BARRIER); 23 | chunkData.setBlock(x, y, 16, Material.BARRIER); 24 | } 25 | for (int z = 0; z < 16; z++) { 26 | chunkData.setBlock(0, y, z, Material.BARRIER); 27 | chunkData.setBlock(16, y, z, Material.BARRIER); 28 | } 29 | 30 | } 31 | for (int x2 = 0; x2 < 16; x2++) { 32 | for (int y2 = 0; y2 < 16; y2++) { 33 | chunkData.setBlock(x2, 180, y2, Material.BARRIER); 34 | } 35 | } 36 | return chunkData; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/ItemBand.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI; 8 | import me.profelements.dynatech.DynaTech; 9 | import org.bukkit.ChatColor; 10 | import org.bukkit.Material; 11 | import org.bukkit.NamespacedKey; 12 | import org.bukkit.inventory.ItemStack; 13 | import org.bukkit.inventory.meta.ItemMeta; 14 | import org.bukkit.potion.PotionEffect; 15 | 16 | import javax.annotation.Nullable; 17 | import java.util.ArrayList; 18 | import java.util.List; 19 | 20 | public class ItemBand extends SlimefunItem { 21 | 22 | public static final NamespacedKey KEY = new NamespacedKey(DynaTech.getInstance(), "item_band"); 23 | private final PotionEffect[] potionEffects; 24 | 25 | public ItemBand(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, PotionEffect[] potionEffects) { 26 | super(itemGroup, item, recipeType, recipe); 27 | 28 | this.potionEffects = potionEffects; 29 | } 30 | 31 | public PotionEffect[] getPotionEffects() { 32 | return potionEffects; 33 | } 34 | 35 | public static boolean containsItemBand(ItemStack item) { 36 | if (item != null && item.getType() != Material.AIR && item.hasItemMeta()) { 37 | return PersistentDataAPI.getString(item.getItemMeta(), KEY) != null; 38 | } else { 39 | return false; 40 | } 41 | } 42 | 43 | @Nullable 44 | public ItemStack applyToItem(@Nullable ItemStack item) { 45 | if (item != null && item.getType() != Material.AIR) { 46 | 47 | 48 | ItemMeta im = item.getItemMeta(); 49 | List lore = im.hasLore() ? im.getLore() : new ArrayList<>(); 50 | 51 | lore.add(ChatColor.WHITE + "Bandaid: " + getPotionEffects()[0].getType().getKey().getKey()); 52 | PersistentDataAPI.setString(im, KEY, this.getId()); 53 | 54 | im.setLore(lore); 55 | item.setItemMeta(im); 56 | return item; 57 | } 58 | return null; 59 | } 60 | 61 | @Nullable 62 | public static ItemStack removeFromItem(@Nullable ItemStack item) { 63 | if (item != null && item.getType() != Material.AIR) { 64 | ItemMeta im = item.getItemMeta(); 65 | List lore = im.getLore(); 66 | 67 | im.getPersistentDataContainer().remove(KEY); 68 | 69 | lore.removeIf(line -> line.contains(ChatColor.WHITE + "Bandaid: ")); 70 | 71 | im.setLore(lore); 72 | item.setItemMeta(im); 73 | 74 | return item; 75 | } 76 | return null; 77 | } 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/MobDropItem.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 8 | import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class MobDropItem extends SlimefunItem implements RandomMobDrop { 12 | 13 | private final ItemSetting dropSetting = new ItemSetting<>(this, "drop-from-mob", true); 14 | private int dropChance = 0; 15 | 16 | public MobDropItem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, int dropChance) { 17 | super(itemGroup, item, recipeType, recipe); 18 | this.dropChance = dropChance; 19 | 20 | addItemSetting(dropSetting); 21 | } 22 | 23 | public boolean isDroppedFromMob() { 24 | return dropSetting.getValue(); 25 | } 26 | 27 | @Override 28 | public int getMobDropChance() { 29 | return dropChance; 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/StarDustMeteor.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.geo.GEOResource; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; 8 | import io.github.thebusybiscuit.slimefun4.libraries.dough.skins.PlayerHead; 9 | import io.github.thebusybiscuit.slimefun4.libraries.dough.skins.PlayerSkin; 10 | import me.profelements.dynatech.DynaTech; 11 | import org.bukkit.NamespacedKey; 12 | import org.bukkit.World.Environment; 13 | import org.bukkit.block.Biome; 14 | import org.bukkit.inventory.ItemStack; 15 | 16 | import javax.annotation.Nonnull; 17 | 18 | public class StarDustMeteor extends UnplaceableBlock implements GEOResource { 19 | 20 | public static final SlimefunItemStack STARDUST_METEOR = new SlimefunItemStack( 21 | "STARDUST_METEOR", 22 | PlayerHead.getItemStack(PlayerSkin.fromHashCode("c482d1ba4bdac990f6ea987703587fd79fe55555363251984679d4f279cc0c2a")), 23 | "&6Stardust Meteor", 24 | "", 25 | "&fGeomined from Mountain or Badlands Biomes" 26 | ); 27 | 28 | private final NamespacedKey key = new NamespacedKey(DynaTech.getInstance(), "stardust_meteor"); 29 | 30 | public StarDustMeteor(ItemGroup itemGroup) { 31 | super(itemGroup, STARDUST_METEOR, RecipeType.GEO_MINER, new ItemStack[0]); 32 | register(); 33 | } 34 | 35 | @Nonnull 36 | @Override 37 | public NamespacedKey getKey() { 38 | return key; 39 | } 40 | 41 | @Nonnull 42 | @Override 43 | public ItemStack getItem() { 44 | return STARDUST_METEOR.clone(); 45 | } 46 | 47 | @Nonnull 48 | @Override 49 | public String getName() { 50 | return "Stardust Meteor"; 51 | } 52 | 53 | @Override 54 | public boolean isObtainableFromGEOMiner() { 55 | return true; 56 | } 57 | 58 | @Override 59 | public int getDefaultSupply(@Nonnull Environment environment, @Nonnull Biome biome) { 60 | if (biome == Biome.MEADOW || biome == Biome.BADLANDS) { 61 | return 16; 62 | } else { 63 | return 0; 64 | } 65 | } 66 | 67 | @Override 68 | public int getMaxDeviation() { 69 | return 4; 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/VexGem.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 7 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 8 | import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting; 9 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 10 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 11 | import io.github.thebusybiscuit.slimefun4.core.attributes.RandomMobDrop; 12 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 13 | import org.bukkit.inventory.ItemStack; 14 | 15 | public class VexGem extends SlimefunItem implements NotPlaceable, RandomMobDrop { 16 | 17 | private final ItemSetting dropSetting = new ItemSetting<>(this, " drop-from-vexs", true); 18 | private final ItemSetting chance = new IntRangeSetting(this ,"vex-drop-chance", 0, 10, 100); 19 | 20 | public VexGem(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 21 | super(itemGroup, item, recipeType, recipe); 22 | 23 | addItemSetting(dropSetting); 24 | addItemSetting(chance); 25 | 26 | addItemHandler(getItemHandler()); 27 | } 28 | 29 | @Override 30 | public int getMobDropChance() { 31 | return chance.getValue(); 32 | } 33 | 34 | public boolean isDroppedFromVexs() { 35 | return dropSetting.getValue(); 36 | } 37 | 38 | public ItemUseHandler getItemHandler() { 39 | return PlayerRightClickEvent::cancel; 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/misc/WitherGolem.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.misc; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.core.multiblocks.MultiBlockMachine; 6 | import org.bukkit.Material; 7 | import org.bukkit.block.Block; 8 | import org.bukkit.block.BlockFace; 9 | import org.bukkit.entity.EntityType; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import javax.annotation.Nonnull; 14 | 15 | public class WitherGolem extends MultiBlockMachine { 16 | 17 | public WitherGolem(ItemGroup itemGroup, SlimefunItemStack item) { 18 | super(itemGroup, item, new ItemStack[] {null, new ItemStack(Material.CARVED_PUMPKIN), null, null, new ItemStack(Material.POLISHED_BLACKSTONE), null, null, new ItemStack(Material. POLISHED_BLACKSTONE), null}, BlockFace.SELF); 19 | } 20 | 21 | @Override 22 | public void onInteract(@Nonnull Player p, @Nonnull Block b) { 23 | Block pumpkinHead = b.getRelative(BlockFace.UP); 24 | Block bottomBlackstone = b.getRelative(BlockFace.DOWN); 25 | 26 | p.getWorld().spawnEntity(b.getLocation().add(0.5, -1, 0.5), EntityType.WITHER_SKELETON); 27 | 28 | pumpkinHead.setType(Material.AIR); 29 | b.setType(Material.AIR); 30 | bottomBlackstone.setType(Material.AIR); 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/AutoInputUpgrade.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import java.util.Optional; 4 | 5 | import org.bukkit.block.Block; 6 | import org.bukkit.inventory.ItemStack; 7 | 8 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 9 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 10 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 11 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 12 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 13 | import me.profelements.dynatech.utils.Recipe; 14 | 15 | public class AutoInputUpgrade extends SlimefunItem { 16 | public AutoInputUpgrade(ItemGroup group, SlimefunItemStack item, Recipe recipe) { 17 | super(group, item, recipe.getRecipeType(), recipe.getInput()); 18 | 19 | addItemHandler(onUse()); 20 | } 21 | 22 | public ItemUseHandler onUse() { 23 | return e -> { 24 | Optional optBlock = e.getClickedBlock(); 25 | if (optBlock.isPresent()) { 26 | Block block = optBlock.get(); 27 | 28 | String upgrades = BlockStorage.getLocationInfo(block.getLocation(), "upgrades"); 29 | 30 | if (upgrades != null && upgrades.contains("id:auto_input")) { 31 | return; 32 | } 33 | 34 | String blockFaceString = AutoOutputUpgrade.blockFaceToString(e.getClickedFace()); 35 | if (blockFaceString == "invalid") { 36 | return; 37 | } 38 | if (upgrades != null) { 39 | BlockStorage.addBlockInfo(block, "upgrades", 40 | upgrades + "," + "{id:auto_input,face:" + blockFaceString + "}"); 41 | } else { 42 | 43 | BlockStorage.addBlockInfo(block, "upgrades", "{id:auto_input,face:" + blockFaceString + "}"); 44 | } 45 | } 46 | 47 | ItemStack stack = e.getItem(); 48 | int amount = stack.getAmount(); 49 | 50 | if (amount > 1) { 51 | stack.setAmount(amount - 1); 52 | } else { 53 | e.getPlayer().getInventory().remove(stack); 54 | } 55 | }; 56 | } 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/AutoOutputUpgrade.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import java.util.Optional; 4 | 5 | import org.bukkit.block.Block; 6 | import org.bukkit.block.BlockFace; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 10 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 11 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 12 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 13 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 14 | import me.profelements.dynatech.DynaTech; 15 | import me.profelements.dynatech.utils.Recipe; 16 | 17 | public class AutoOutputUpgrade extends SlimefunItem { 18 | 19 | public AutoOutputUpgrade(ItemGroup group, SlimefunItemStack item, Recipe recipe) { 20 | super(group, item, recipe.getRecipeType(), recipe.getInput()); 21 | 22 | addItemHandler(onUse()); 23 | } 24 | 25 | public ItemUseHandler onUse() { 26 | return e -> { 27 | Optional optBlock = e.getClickedBlock(); 28 | if (optBlock.isPresent()) { 29 | Block block = optBlock.get(); 30 | 31 | String upgrades = BlockStorage.getLocationInfo(block.getLocation(), "upgrades"); 32 | 33 | if (upgrades != null && upgrades.contains("id:auto_output")) { 34 | return; 35 | } 36 | 37 | String blockFaceString = blockFaceToString(e.getClickedFace()); 38 | if (blockFaceString == "invalid") { 39 | return; 40 | } 41 | if (upgrades != null) { 42 | BlockStorage.addBlockInfo(block, "upgrades", 43 | upgrades + "," + "{id:auto_output,face:" + blockFaceString + "}"); 44 | } else { 45 | 46 | BlockStorage.addBlockInfo(block, "upgrades", "{id:auto_output,face:" + blockFaceString + "}"); 47 | } 48 | } 49 | 50 | ItemStack stack = e.getItem(); 51 | int amount = stack.getAmount(); 52 | 53 | if (amount > 1) { 54 | stack.setAmount(amount - 1); 55 | } else { 56 | e.getPlayer().getInventory().remove(stack); 57 | } 58 | }; 59 | } 60 | 61 | public static String blockFaceToString(BlockFace face) { 62 | String blockFaceString; 63 | 64 | switch (face) { 65 | case UP: 66 | blockFaceString = "up"; 67 | break; 68 | case DOWN: 69 | blockFaceString = "down"; 70 | break; 71 | case NORTH: 72 | blockFaceString = "north"; 73 | break; 74 | case SOUTH: 75 | blockFaceString = "south"; 76 | break; 77 | case EAST: 78 | blockFaceString = "east"; 79 | break; 80 | case WEST: 81 | blockFaceString = "west"; 82 | break; 83 | default: 84 | blockFaceString = "invalid"; 85 | break; 86 | } 87 | 88 | return blockFaceString; 89 | } 90 | 91 | public static BlockFace stringToBlockFace(String blockFaceString) { 92 | BlockFace face; 93 | DynaTech.getInstance().getLogger().info(blockFaceString); 94 | switch (blockFaceString) { 95 | case "face:up": 96 | face = BlockFace.UP; 97 | break; 98 | case "face:down": 99 | face = BlockFace.DOWN; 100 | break; 101 | case "face:north": 102 | face = BlockFace.NORTH; 103 | break; 104 | case "face:south": 105 | face = BlockFace.SOUTH; 106 | break; 107 | case "face:east": 108 | face = BlockFace.EAST; 109 | break; 110 | case "face:west": 111 | face = BlockFace.WEST; 112 | break; 113 | default: 114 | face = BlockFace.SELF; 115 | break; 116 | } 117 | 118 | return face; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/DimensionalHome.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 4 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 8 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 9 | import io.github.thebusybiscuit.slimefun4.libraries.dough.config.Config; 10 | import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI; 11 | import io.github.thebusybiscuit.slimefun4.libraries.paperlib.PaperLib; 12 | import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; 13 | import me.profelements.dynatech.DynaTech; 14 | import me.profelements.dynatech.registries.Items; 15 | 16 | import org.bukkit.Bukkit; 17 | import org.bukkit.Location; 18 | import org.bukkit.NamespacedKey; 19 | import org.bukkit.World; 20 | import org.bukkit.entity.Player; 21 | import org.bukkit.inventory.ItemStack; 22 | import org.bukkit.inventory.meta.ItemMeta; 23 | 24 | import javax.annotation.Nonnull; 25 | import java.util.List; 26 | 27 | public class DimensionalHome extends SlimefunItem { 28 | 29 | private static final NamespacedKey CHUNK_KEY = new NamespacedKey(DynaTech.getInstance(), "chunk-key"); 30 | private static final World DIM_HOME_WORLD = Bukkit.getServer().getWorld("dimensionalhome"); 31 | private static final Config CURRENT_HIGHEST_CHUNK_ID = new Config("plugins/DynaTech/current-chunk-highest.yml"); 32 | private int id = CURRENT_HIGHEST_CHUNK_ID.getInt("current-chunk-highest-id"); 33 | 34 | public DimensionalHome(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 35 | super(itemGroup, item, recipeType, recipe); 36 | addItemHandler(onRightClick()); 37 | } 38 | 39 | public ItemUseHandler onRightClick() { 40 | return new ItemUseHandler() { 41 | @Override 42 | public void onRightClick(PlayerRightClickEvent e) { 43 | e.cancel(); 44 | 45 | Player p = e.getPlayer(); 46 | ItemStack item = e.getItem(); 47 | int chunkKey = PersistentDataAPI.getInt(item.getItemMeta(), CHUNK_KEY); 48 | 49 | if (SlimefunUtils.isItemSimilar(item, Items.DIMENSIONAL_HOME.stack(), true)) { 50 | if (chunkKey > 0) { 51 | if (p.getLocation().getWorld() != DIM_HOME_WORLD) { 52 | Location dimHomeLocation = new Location(DIM_HOME_WORLD, 16 * chunkKey + 8d, 65, 8); 53 | PaperLib.teleportAsync(p, dimHomeLocation); 54 | } else { 55 | if (p.getRespawnLocation() != null) { 56 | PaperLib.teleportAsync(p, p.getRespawnLocation()); 57 | } else { 58 | PaperLib.teleportAsync(p, Bukkit.getServer().getWorlds().get(0).getSpawnLocation()); 59 | } 60 | } 61 | } else { 62 | // Setup ChunkKey 63 | updateLore(item); 64 | } 65 | } 66 | } 67 | }; 68 | } 69 | 70 | private void updateLore(@Nonnull ItemStack item) { 71 | ItemMeta im = item.getItemMeta(); 72 | List lore = im.getLore(); 73 | 74 | for (int line = 0; line < lore.size(); line++) { 75 | if (lore.get(line).contains("CHUNK ID: ")) { 76 | id++; 77 | lore.set(line, lore.get(line).replace("", String.valueOf(id))); 78 | PersistentDataAPI.setInt(im, CHUNK_KEY, id); 79 | 80 | // THIS IS PROBABLY BAD AND A BAD WAY TO KEEP AN CHUNK ID 81 | CURRENT_HIGHEST_CHUNK_ID.setValue("current-chunk-highest-id", id); 82 | CURRENT_HIGHEST_CHUNK_ID.save(); 83 | } 84 | 85 | } 86 | 87 | im.setLore(lore); 88 | item.setItemMeta(im); 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/ElectricalStimulator.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; 7 | import io.github.thebusybiscuit.slimefun4.implementation.items.blocks.UnplaceableBlock; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public class ElectricalStimulator extends UnplaceableBlock implements Rechargeable { 11 | 12 | public ElectricalStimulator(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 13 | super(itemGroup, item, recipeType, recipe); 14 | } 15 | 16 | @Override 17 | public float getMaxItemCharge(ItemStack item) { 18 | return 1024; 19 | } 20 | 21 | public float getEnergyComsumption() { 22 | return 32f; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/InventoryFilter.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 5 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 6 | import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack; 7 | import org.bukkit.inventory.ItemStack; 8 | 9 | public class InventoryFilter extends SlimefunBackpack { 10 | 11 | public InventoryFilter(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 12 | super(9, itemGroup, item, recipeType, recipe); 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/LiquidContainerItem.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import org.bukkit.inventory.ItemStack; 4 | 5 | import io.github.thebusybiscuit.slimefun4.api.events.PlayerRightClickEvent; 6 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 7 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 8 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 9 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 10 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 11 | import me.profelements.dynatech.interfaces.LiquidContainer; 12 | import me.profelements.dynatech.utils.Liquid; 13 | 14 | public class LiquidContainerItem extends SlimefunItem implements LiquidContainer { 15 | 16 | private final Liquid liquid; 17 | private final int liquidCapacity; 18 | 19 | public LiquidContainerItem(ItemGroup group, SlimefunItemStack stack, RecipeType recipeType, ItemStack[] input, 20 | Liquid liquid, int liquidCapacity) { 21 | super(group, stack, recipeType, input); 22 | 23 | this.liquid = liquid; 24 | this.liquidCapacity = liquidCapacity; 25 | 26 | addItemHandler(onItemUse()); 27 | } 28 | 29 | private ItemUseHandler onItemUse() { 30 | return new ItemUseHandler() { 31 | @Override 32 | public void onRightClick(PlayerRightClickEvent event) { 33 | event.cancel(); 34 | } 35 | 36 | }; 37 | } 38 | 39 | @Override 40 | public Liquid getLiquid() { 41 | return this.liquid; 42 | } 43 | 44 | @Override 45 | public int getLiquidCapacity() { 46 | return this.liquidCapacity; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/Scoop.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable; 8 | import io.github.thebusybiscuit.slimefun4.core.attributes.Rechargeable; 9 | import io.github.thebusybiscuit.slimefun4.core.handlers.EntityInteractHandler; 10 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 11 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; 12 | import me.profelements.dynatech.registries.Items; 13 | 14 | import org.bukkit.Sound; 15 | import org.bukkit.entity.Bee; 16 | import org.bukkit.entity.Entity; 17 | import org.bukkit.entity.Player; 18 | import org.bukkit.inventory.ItemStack; 19 | 20 | public class Scoop extends SlimefunItem implements Rechargeable, NotPlaceable { 21 | 22 | public Scoop(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 23 | super(itemGroup, item, recipeType, recipe); 24 | 25 | addItemHandler(getItemHandler()); 26 | } 27 | 28 | public EntityInteractHandler getItemHandler() { 29 | return (e, item, offhand) -> { 30 | if (getItemCharge(item) < 8) { 31 | return; 32 | } 33 | 34 | Entity entity = e.getRightClicked(); 35 | 36 | if (e.isCancelled() || !Slimefun.getProtectionManager().hasPermission(e.getPlayer(), entity.getLocation(), 37 | Interaction.INTERACT_ENTITY)) { 38 | return; 39 | } 40 | 41 | Player p = e.getPlayer(); 42 | 43 | if (entity instanceof Bee) { 44 | 45 | entity.getWorld().dropItemNaturally(entity.getLocation(), Items.BEE.stack()); 46 | entity.remove(); 47 | removeItemCharge(item, 8); 48 | 49 | p.playSound(p.getLocation(), Sound.BLOCK_ANVIL_FALL, 1, 1); 50 | } 51 | }; 52 | 53 | } 54 | 55 | @Override 56 | public float getMaxItemCharge(ItemStack item) { 57 | return 512; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/items/tools/TesseractBinder.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.items.tools; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 7 | import io.github.thebusybiscuit.slimefun4.core.handlers.ItemUseHandler; 8 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 9 | import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI; 10 | import io.github.thebusybiscuit.slimefun4.libraries.dough.protection.Interaction; 11 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 12 | import me.profelements.dynatech.items.electric.transfer.Tesseract; 13 | import me.profelements.dynatech.registries.Items; 14 | import net.md_5.bungee.api.ChatColor; 15 | import net.md_5.bungee.api.ChatMessageType; 16 | import net.md_5.bungee.api.chat.TextComponent; 17 | 18 | import org.bukkit.Location; 19 | import org.bukkit.block.Block; 20 | import org.bukkit.inventory.ItemStack; 21 | import org.bukkit.inventory.meta.ItemMeta; 22 | 23 | import java.util.Optional; 24 | 25 | public class TesseractBinder extends SlimefunItem { 26 | public TesseractBinder(ItemGroup itemGroup, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) { 27 | super(itemGroup, item, recipeType, recipe); 28 | 29 | addItemHandler(bindTesseract()); 30 | } 31 | 32 | private ItemUseHandler bindTesseract() { 33 | return e -> { 34 | e.cancel(); 35 | 36 | Optional block = e.getClickedBlock(); 37 | Optional sfBlock = e.getSlimefunBlock(); 38 | if (block.isPresent() && sfBlock.isPresent()) { 39 | Location blockLocation = block.get().getLocation(); 40 | SlimefunItem sfItem = sfBlock.get(); 41 | ItemStack item = e.getItem(); 42 | Boolean hasPermision = Slimefun.getProtectionManager().hasPermission(e.getPlayer(), blockLocation, 43 | Interaction.INTERACT_BLOCK); 44 | 45 | if (e.getPlayer().isSneaking()) { 46 | String locString = PersistentDataAPI.getString(item.getItemMeta(), Tesseract.WIRELESS_LOCATION_KEY); 47 | if (item != null && hasPermision 48 | && BlockStorage.checkID(blockLocation).equals(Items.TESSERACT.stack().getItemId()) 49 | && item.hasItemMeta() && locString != null) { 50 | BlockStorage.addBlockInfo(blockLocation, "tesseract-pair-location", locString); 51 | e.getPlayer().spigot().sendMessage(ChatMessageType.ACTION_BAR, 52 | TextComponent.fromLegacy(ChatColor.WHITE + "Tesseract Connected!")); 53 | } 54 | } else if (Boolean.TRUE.equals(hasPermision) 55 | && sfItem.getId().equals(Items.TESSERACT.stack().getItemId()) && blockLocation != null) { 56 | ItemMeta im = item.getItemMeta(); 57 | String locString = Tesseract.locationToString(blockLocation); 58 | 59 | PersistentDataAPI.setString(im, Tesseract.WIRELESS_LOCATION_KEY, locString); 60 | item.setItemMeta(im); 61 | Tesseract.setItemLore(item, blockLocation); 62 | } 63 | 64 | } 65 | }; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/BlockBreakBlockListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import java.util.List; 4 | 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | import org.bukkit.inventory.ItemStack; 8 | import org.bukkit.plugin.Plugin; 9 | 10 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 11 | import io.papermc.paper.event.block.BlockBreakBlockEvent; 12 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 13 | 14 | public class BlockBreakBlockListener implements Listener { 15 | 16 | public BlockBreakBlockListener(Plugin plugin) { 17 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 18 | } 19 | 20 | @EventHandler 21 | public void onBlockBreakBlock(BlockBreakBlockEvent event) { 22 | 23 | SlimefunItem sfItem = BlockStorage.check(event.getBlock()); 24 | 25 | if (sfItem != null) { 26 | BlockStorage.clearBlockInfo(event.getBlock()); 27 | 28 | List drops = event.getDrops(); 29 | drops.clear(); 30 | 31 | drops.add(sfItem.getItem()); 32 | } 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/CoalCokeListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.Listener; 5 | import org.bukkit.event.inventory.FurnaceBurnEvent; 6 | import org.bukkit.plugin.Plugin; 7 | 8 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 9 | import me.profelements.dynatech.DynaTech; 10 | import me.profelements.dynatech.registries.Items; 11 | 12 | public class CoalCokeListener implements Listener { 13 | 14 | public CoalCokeListener(Plugin plugin) { 15 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 16 | } 17 | 18 | @EventHandler 19 | public void onBurn(FurnaceBurnEvent event) { 20 | SlimefunItem sfItem = SlimefunItem.getByItem(event.getFuel()); 21 | 22 | if (sfItem != null && sfItem.getId().equals(Items.COAL_COKE.stack().getItemId())) { 23 | int burnTime = event.getBurnTime(); 24 | DynaTech.getInstance().getLogger().info("Found Coal Coke, burnTime Original: " + String.valueOf(burnTime) 25 | + " burnTime * 8 " + String.valueOf(burnTime * 8)); 26 | event.setBurnTime(burnTime * 8); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/ElectricalStimulatorListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.utils.ChargeUtils; 4 | import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; 5 | import me.profelements.dynatech.DynaTech; 6 | import me.profelements.dynatech.registries.Items; 7 | import me.profelements.dynatech.items.tools.ElectricalStimulator; 8 | 9 | import org.bukkit.Sound; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.event.EventHandler; 12 | import org.bukkit.event.Listener; 13 | import org.bukkit.event.entity.EntityDamageEvent; 14 | import org.bukkit.event.entity.FoodLevelChangeEvent; 15 | import org.bukkit.inventory.ItemStack; 16 | 17 | import javax.annotation.Nonnull; 18 | 19 | public class ElectricalStimulatorListener implements Listener { 20 | 21 | private final ElectricalStimulator electricalStimulator; 22 | 23 | public ElectricalStimulatorListener(@Nonnull DynaTech plugin, @Nonnull ElectricalStimulator electricalStimulator) { 24 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 25 | this.electricalStimulator = electricalStimulator; 26 | } 27 | 28 | @EventHandler 29 | public void onHungerLoss(FoodLevelChangeEvent e) { 30 | if (e.getEntity() instanceof Player p && p.getFoodLevel() < 20 && feedPlayer(p)) { 31 | e.setFoodLevel(20); 32 | } 33 | } 34 | 35 | @EventHandler 36 | public void onHungerDamage(EntityDamageEvent e) { 37 | if (e.getEntity() instanceof Player p && e.getCause() == EntityDamageEvent.DamageCause.STARVATION 38 | && feedPlayer(p)) { 39 | p.setFoodLevel(20); 40 | p.setSaturation(20f); 41 | } 42 | } 43 | 44 | private boolean feedPlayer(Player p) { 45 | if (electricalStimulator == null || electricalStimulator.isDisabled()) { 46 | return false; 47 | } 48 | 49 | for (ItemStack item : p.getInventory().getStorageContents()) { 50 | if (item != null && item.getType() == electricalStimulator.getItem().getType() 51 | && SlimefunUtils.isItemSimilar(item, Items.ELECTRICAL_STIMULATOR.stack(), false, false) 52 | && ChargeUtils.getCharge(item.getItemMeta()) > electricalStimulator.getEnergyComsumption()) { 53 | if (SlimefunUtils.canPlayerUseItem(p, item, true)) { 54 | p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1F, 1F); 55 | electricalStimulator.removeItemCharge(item, electricalStimulator.getEnergyComsumption()); 56 | return true; 57 | } 58 | } 59 | } 60 | return false; 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/ExoticGardenIntegrationListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.inventory.ItemStack; 7 | import org.bukkit.plugin.Plugin; 8 | 9 | import io.github.bakedlibs.dough.collections.Pair; 10 | import io.github.thebusybiscuit.exoticgarden.ExoticGardenRecipeTypes; 11 | import io.github.thebusybiscuit.exoticgarden.items.CustomFood; 12 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 13 | import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemRegistryFinalizedEvent; 14 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 15 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 16 | import me.profelements.dynatech.items.backpacks.PicnicBasket; 17 | import me.profelements.dynatech.items.electric.SeedPlucker; 18 | import me.profelements.dynatech.items.electric.generators.CulinaryGenerator; 19 | import me.profelements.dynatech.items.electric.growthchambers.GrowthChamber; 20 | import me.profelements.dynatech.items.electric.growthchambers.GrowthChamberMK2; 21 | import me.profelements.dynatech.registries.Items; 22 | 23 | public class ExoticGardenIntegrationListener implements Listener { 24 | 25 | public ExoticGardenIntegrationListener(Plugin plugin) { 26 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 27 | } 28 | 29 | @EventHandler 30 | public void onSlimefunRegistyFinalized(SlimefunItemRegistryFinalizedEvent e) { 31 | boolean exoticGardenInstalled = Bukkit.getServer().getPluginManager().isPluginEnabled("ExoticGarden"); 32 | SlimefunItem item1 = SlimefunItem.getByItem(Items.FOOD_GENERATOR.stack()); 33 | SlimefunItem item2 = SlimefunItem.getByItem(Items.SEED_PLUCKER.stack()); 34 | SlimefunItem item3 = SlimefunItem.getByItem(Items.GROWTH_CHAMBER.stack()); 35 | SlimefunItem item4 = SlimefunItem.getByItem(Items.GROWTH_CHAMBER_MK2.stack()); 36 | /* 37 | * if (item1 instanceof CulinaryGenerator cg && item2 instanceof SeedPlucker sp 38 | * && gastronomiconInstalled) { 39 | * for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { 40 | * if (item.getItem() instanceof FoodItemStack food && 41 | * !food.getTexture().equals(HeadTextures.NONE) && 42 | * !item.getId().contains("GN_PERFECT")) { 43 | * cg.registerFuel(food, food.getHunger() * 4); 44 | * PicnicBasket.registerFood(food, new Pair<>(food.getHunger(), (float) 45 | * food.getSaturation())); 46 | * } 47 | * 48 | * if (item.getRecipeType() == GastroRecipeType.HARVEST) { 49 | * sp.registerRecipe(new MachineRecipe(10, new ItemStack[] { 50 | * item.getRecipeOutput() }, new ItemStack[] { item.getRecipe()[4] })); 51 | * } 52 | * } 53 | * } 54 | */ 55 | if (item1 instanceof CulinaryGenerator cg1 && item3 instanceof GrowthChamber gc 56 | && item4 instanceof GrowthChamberMK2 gc2 && item2 instanceof SeedPlucker sp1 && exoticGardenInstalled) { 57 | for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { 58 | if (item instanceof CustomFood cfItem) { 59 | cg1.registerFuel(cfItem.getItem(), cfItem.getFoodValue() * 4); 60 | PicnicBasket.registerFood(cfItem.getItem(), new Pair<>(cfItem.getFoodValue(), 10F)); 61 | } 62 | 63 | if (item.getRecipeType() == ExoticGardenRecipeTypes.HARVEST_BUSH 64 | || item.getRecipeType() == ExoticGardenRecipeTypes.HARVEST_TREE) { 65 | gc.registerRecipe(new MachineRecipe(30, new ItemStack[] { item.getRecipe()[4] }, 66 | new ItemStack[] { item.getRecipe()[4], item.getRecipeOutput() })); 67 | gc2.registerRecipe(new MachineRecipe(30, new ItemStack[] { item.getRecipe()[4] }, 68 | new ItemStack[] { item.getRecipe()[4], item.getRecipeOutput() })); 69 | sp1.registerRecipe(new MachineRecipe(10, new ItemStack[] { item.getRecipeOutput() }, 70 | new ItemStack[] { item.getRecipe()[4] })); 71 | } 72 | 73 | if (item.getId().contains("_ESSENCE")) { 74 | SlimefunItem orePlant = SlimefunItem.getById(item.getId().replace("_ESSENCE", "_PLANT")); 75 | if (orePlant != null) { 76 | gc.registerRecipe(new MachineRecipe(30, new ItemStack[] { orePlant.getItem() }, 77 | new ItemStack[] { orePlant.getItem(), item.getItem() })); 78 | gc2.registerRecipe(new MachineRecipe(30, new ItemStack[] { orePlant.getItem() }, 79 | new ItemStack[] { orePlant.getItem(), item.getItem(), })); 80 | } 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/GastronomiconIntegrationListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.EventHandler; 5 | import org.bukkit.event.Listener; 6 | import org.bukkit.inventory.ItemStack; 7 | import org.bukkit.plugin.Plugin; 8 | 9 | import io.github.bakedlibs.dough.collections.Pair; 10 | import io.github.schntgaispock.gastronomicon.api.items.FoodItemStack; 11 | import io.github.schntgaispock.gastronomicon.core.slimefun.recipes.GastroRecipeType; 12 | import io.github.schntgaispock.gastronomicon.util.item.HeadTextures; 13 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 14 | import io.github.thebusybiscuit.slimefun4.api.events.SlimefunItemRegistryFinalizedEvent; 15 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun; 16 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 17 | import me.profelements.dynatech.items.backpacks.PicnicBasket; 18 | import me.profelements.dynatech.items.electric.SeedPlucker; 19 | import me.profelements.dynatech.items.electric.generators.CulinaryGenerator; 20 | import me.profelements.dynatech.registries.Items; 21 | 22 | public class GastronomiconIntegrationListener implements Listener { 23 | 24 | public GastronomiconIntegrationListener(Plugin plugin) { 25 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 26 | } 27 | 28 | @EventHandler 29 | public void onSlimefunRegistyFinalized(SlimefunItemRegistryFinalizedEvent e) { 30 | boolean gastronomiconInstalled = Bukkit.getServer().getPluginManager().isPluginEnabled("Gastronomicon"); 31 | SlimefunItem item1 = SlimefunItem.getByItem(Items.FOOD_GENERATOR.stack()); 32 | SlimefunItem item2 = SlimefunItem.getByItem(Items.SEED_PLUCKER.stack()); 33 | 34 | if (item1 instanceof CulinaryGenerator cg && item2 instanceof SeedPlucker sp && gastronomiconInstalled) { 35 | for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { 36 | if (item.getItem() instanceof FoodItemStack food && !food.getTexture().equals(HeadTextures.NONE) 37 | && !item.getId().contains("GN_PERFECT")) { 38 | cg.registerFuel(food, food.getHunger() * 4); 39 | PicnicBasket.registerFood(food, new Pair<>(food.getHunger(), (float) food.getSaturation())); 40 | } 41 | 42 | if (item.getRecipeType() == GastroRecipeType.HARVEST) { 43 | sp.registerRecipe(new MachineRecipe(10, new ItemStack[] { item.getRecipeOutput() }, 44 | new ItemStack[] { item.getRecipe()[4] })); 45 | } 46 | } 47 | } 48 | /* 49 | * if (item1 instanceof CulinaryGenerator cg1 && item3 instanceof GrowthChamber 50 | * gc && item4 instanceof GrowthChamberMK2 gc2 && item2 instanceof SeedPlucker 51 | * sp1 && exoticGardenInstalled) { 52 | * for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) { 53 | * if (item instanceof CustomFood cfItem) { 54 | * cg1.registerFuel(cfItem.getItem(), cfItem.getFoodValue() * 4); 55 | * PicnicBasket.registerFood(cfItem.getItem(), new Pair<>(cfItem.getFoodValue(), 56 | * 10F)); 57 | * } 58 | * 59 | * if (item.getRecipeType() == ExoticGardenRecipeTypes.HARVEST_BUSH || 60 | * item.getRecipeType() == ExoticGardenRecipeTypes.HARVEST_TREE) { 61 | * gc.registerRecipe(new MachineRecipe(30, new ItemStack[] 62 | * {item.getRecipe()[4]}, new ItemStack[] { item.getRecipe()[4], 63 | * item.getRecipeOutput() })); 64 | * gc2.registerRecipe(new MachineRecipe(30, new ItemStack[] 65 | * {item.getRecipe()[4]}, new ItemStack[] { item.getRecipe()[4], 66 | * item.getRecipeOutput() })); 67 | * sp1.registerRecipe(new MachineRecipe(10, new ItemStack[] 68 | * {item.getRecipeOutput() }, new ItemStack[] {item.getRecipe()[4] })); 69 | * } 70 | * 71 | * if (item.getId().contains("_ESSENCE")) { 72 | * SlimefunItem orePlant = SlimefunItem.getById(item.getId().replace("_ESSENCE", 73 | * "_PLANT")); 74 | * if (orePlant != null) { 75 | * gc.registerRecipe(new MachineRecipe(30, new ItemStack[] { orePlant.getItem() 76 | * }, new ItemStack[] {orePlant.getItem(), item.getItem() })); 77 | * gc2.registerRecipe(new MachineRecipe(30, new ItemStack[] { orePlant.getItem() 78 | * }, new ItemStack[] { orePlant.getItem(), item.getItem(), })); 79 | * } 80 | * } 81 | * } 82 | * } 83 | */ 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/InventoryFilterListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import me.profelements.dynatech.DynaTech; 4 | import me.profelements.dynatech.items.tools.InventoryFilter; 5 | 6 | import org.bukkit.entity.Item; 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.event.EventHandler; 9 | import org.bukkit.event.Listener; 10 | import org.bukkit.event.entity.EntityPickupItemEvent; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 14 | import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; 15 | 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | import javax.annotation.Nonnull; 20 | 21 | public class InventoryFilterListener implements Listener { 22 | 23 | public InventoryFilterListener(@Nonnull DynaTech plugin) { 24 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 25 | } 26 | 27 | @EventHandler 28 | private void onPlayerAttemptPickup(EntityPickupItemEvent e) { 29 | if (e.getEntity() instanceof Player p) { 30 | filterInventory(p, e); 31 | } 32 | } 33 | 34 | private void filterInventory(Player player, EntityPickupItemEvent event) { 35 | List slimefunItems = new ArrayList<>(); 36 | List regItems = new ArrayList<>(); 37 | for (ItemStack stack : player.getInventory().getContents()) { 38 | if (SlimefunItem.getByItem(stack) instanceof InventoryFilter) { 39 | PlayerProfile.getBackpack(stack, backpack -> { 40 | for (ItemStack bpStack : backpack.getInventory().getContents()) { 41 | SlimefunItem item = SlimefunItem.getByItem(bpStack); 42 | if (item != null) { 43 | slimefunItems.add(item.getId()); 44 | } else { 45 | regItems.add(bpStack); 46 | } 47 | } 48 | }); 49 | } 50 | } 51 | 52 | Item itemEntity = event.getItem(); 53 | ItemStack itemEntityStack = itemEntity.getItemStack(); 54 | 55 | for (ItemStack checkStack : regItems) { 56 | if (checkStack != null && checkStack.isSimilar(itemEntityStack)) { 57 | itemEntity.remove(); 58 | event.setCancelled(true); 59 | break; 60 | } 61 | } 62 | 63 | SlimefunItem item = SlimefunItem.getByItem(itemEntityStack); 64 | if (item != null 65 | && slimefunItems.contains(item.getId())) { 66 | itemEntity.remove(); 67 | event.setCancelled(true); 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/PicnicBasketListener.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 4 | import io.github.thebusybiscuit.slimefun4.api.player.PlayerBackpack; 5 | import io.github.thebusybiscuit.slimefun4.api.player.PlayerProfile; 6 | import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils; 7 | import me.profelements.dynatech.DynaTech; 8 | import me.profelements.dynatech.events.PicnicBasketFeedPlayerEvent; 9 | import me.profelements.dynatech.items.backpacks.PicnicBasket; 10 | 11 | import org.bukkit.Sound; 12 | import org.bukkit.entity.Player; 13 | import org.bukkit.event.EventHandler; 14 | import org.bukkit.event.Listener; 15 | import org.bukkit.event.entity.EntityDamageEvent; 16 | import org.bukkit.event.entity.FoodLevelChangeEvent; 17 | import org.bukkit.event.entity.EntityDamageEvent.DamageCause; 18 | import org.bukkit.inventory.Inventory; 19 | import org.bukkit.inventory.ItemStack; 20 | 21 | import javax.annotation.Nonnull; 22 | import javax.annotation.ParametersAreNonnullByDefault; 23 | 24 | public class PicnicBasketListener implements Listener { 25 | 26 | private final DynaTech plugin; 27 | private final PicnicBasket picnicBasket; 28 | 29 | @ParametersAreNonnullByDefault 30 | public PicnicBasketListener(DynaTech plugin,PicnicBasket picnicBasket) { 31 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 32 | 33 | this.plugin = plugin; 34 | this.picnicBasket = picnicBasket; 35 | } 36 | 37 | @EventHandler 38 | public void onHungerLoss(FoodLevelChangeEvent e) { 39 | if (e.getEntity() instanceof Player player && e.getFoodLevel() < player.getFoodLevel()) { 40 | checkAndConsume(player); 41 | } 42 | } 43 | 44 | @EventHandler 45 | public void onHungerDamage(EntityDamageEvent e) { 46 | if (e.getEntity() instanceof Player player && e.getCause() == DamageCause.STARVATION) { 47 | checkAndConsume(player); 48 | } 49 | } 50 | 51 | private void checkAndConsume(@Nonnull Player p) { 52 | if (picnicBasket == null || picnicBasket.isDisabled()) { 53 | return; 54 | } 55 | 56 | for (ItemStack item : p.getInventory().getContents()) { 57 | if (picnicBasket.isItem(item) || SlimefunItem.getByItem(item) instanceof PicnicBasket) { 58 | if (picnicBasket.canUse(p, true)) { 59 | takeFoodFromPicnicBasket(p, item); 60 | } else { 61 | return; 62 | } 63 | } 64 | } 65 | } 66 | 67 | private void takeFoodFromPicnicBasket(@Nonnull Player p, @Nonnull ItemStack picnicBasket) { 68 | PlayerProfile.getBackpack(picnicBasket, backpack -> { 69 | if (backpack != null) { 70 | DynaTech.runSync(() -> consumeFood(p, picnicBasket, backpack)); 71 | } 72 | }); 73 | 74 | } 75 | 76 | private boolean consumeFood(@Nonnull Player p, @Nonnull ItemStack picnicBasketItem, @Nonnull PlayerBackpack backpack) { 77 | Inventory inv = backpack.getInventory(); 78 | int slot = -1; 79 | 80 | for (int i = 0; i < inv.getSize(); i++) { 81 | ItemStack item = inv.getItem(i); 82 | 83 | if (item != null) { 84 | slot = i; 85 | } 86 | } 87 | 88 | if (slot >= 0) { 89 | ItemStack item = inv.getItem(slot); 90 | PicnicBasketFeedPlayerEvent event = new PicnicBasketFeedPlayerEvent(p, picnicBasket, picnicBasketItem, item); 91 | plugin.getServer().getPluginManager().callEvent(event); 92 | 93 | if (!event.isCancelled()) { 94 | for (ItemStack food : PicnicBasket.getFoods().keySet()) { 95 | if (SlimefunUtils.isItemSimilar(food, item, false, false) && (p.getFoodLevel() + PicnicBasket.getFoods().get(food).getFirstValue()) <= 20) { 96 | p.setFoodLevel(p.getFoodLevel() + PicnicBasket.getFoods().get(food).getFirstValue()); 97 | p.setSaturation(p.getSaturation() + PicnicBasket.getFoods().get(food).getSecondValue()); 98 | p.playSound(p.getLocation(), Sound.ENTITY_PLAYER_BURP, 1F, 1F); 99 | 100 | if (item.getAmount() > 1) { 101 | item.setAmount(item.getAmount() - 1); 102 | } else { 103 | inv.setItem(slot, null); 104 | } 105 | 106 | backpack.markDirty(); 107 | return true; 108 | } 109 | } 110 | } 111 | } 112 | return false; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/listeners/RegistryListeners.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.listeners; 2 | 3 | import org.bukkit.event.EventHandler; 4 | import org.bukkit.event.Listener; 5 | 6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 7 | import me.profelements.dynatech.DynaTech; 8 | import me.profelements.dynatech.registries.Items; 9 | import me.profelements.dynatech.registries.Registries; 10 | import me.profelements.dynatech.registries.Registry; 11 | import me.profelements.dynatech.registries.events.RegistryFreezeEvent; 12 | import me.profelements.dynatech.utils.ItemWrapper; 13 | 14 | public class RegistryListeners implements Listener { 15 | 16 | public RegistryListeners(DynaTech plugin) { 17 | plugin.getServer().getPluginManager().registerEvents(this, plugin); 18 | } 19 | 20 | @EventHandler 21 | public void confirmFreeze(RegistryFreezeEvent event) { 22 | 23 | if (event.getRegistryKey().equals(Registries.Keys.ITEMS)) { 24 | // GRAB STAINLESS STEEL 25 | Registry items = (Registry) Registry.getByKey(event.getRegistryKey()); 26 | if (items.getKeys().contains(Items.Keys.STAINLESS_STEEL_INGOT)) { 27 | ItemWrapper wrapped = items.entry(Items.Keys.STAINLESS_STEEL_INGOT); 28 | 29 | SlimefunItemStack itemStackToUse = wrapped.stack(); 30 | 31 | } 32 | 33 | if (items.getKeys().contains(Items.Keys.VEX_GEM)) { 34 | ItemWrapper wrapped = items.entry(Items.Keys.VEX_GEM); 35 | 36 | SlimefunItemStack itemStackToUse = wrapped.stack(); 37 | 38 | } 39 | } 40 | 41 | DynaTech.getInstance().getLogger().info(event.getRegistryKey().key().toString() + " is getting frozen"); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/ItemGroups.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries; 2 | 3 | import org.bukkit.Material; 4 | 5 | import io.github.bakedlibs.dough.items.CustomItemStack; 6 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 7 | import io.github.thebusybiscuit.slimefun4.api.items.groups.NestedItemGroup; 8 | import io.github.thebusybiscuit.slimefun4.api.items.groups.SubItemGroup; 9 | 10 | public class ItemGroups { 11 | 12 | public static final void init(Registry registry) { 13 | registry.register(Keys.GENERAL, GENERAL); 14 | registry.register(Keys.RESOURCES, RESOURCES); 15 | registry.register(Keys.TOOLS, TOOLS); 16 | registry.register(Keys.MACHINES, MACHINES); 17 | registry.register(Keys.GENERATORS, GENERATORS); 18 | registry.register(Keys.EXPERIMENTAL, EXPERIMENTAL); 19 | registry.register(Keys.APIARIES, HIVES); 20 | } 21 | 22 | public static final NestedItemGroup GENERAL = new NestedItemGroup( 23 | Keys.GENERAL.key(), 24 | new CustomItemStack(Material.CONDUIT, "&bDynaTech")); 25 | 26 | public static final SubItemGroup RESOURCES = new SubItemGroup( 27 | Keys.RESOURCES.key(), GENERAL, 28 | new CustomItemStack(Material.PUFFERFISH, "&bDynaTech Resources")); 29 | 30 | public static final SubItemGroup TOOLS = new SubItemGroup(Keys.TOOLS.key(), 31 | GENERAL, new CustomItemStack(Material.DIAMOND_AXE, "&bDynaTech Tools")); 32 | 33 | public static final SubItemGroup MACHINES = new SubItemGroup(Keys.MACHINES.key(), GENERAL, 34 | new CustomItemStack(Material.SEA_LANTERN, "&bDynaTech Machines")); 35 | 36 | public static final SubItemGroup GENERATORS = new SubItemGroup(Keys.GENERATORS.key(), GENERAL, 37 | new CustomItemStack(Material.PRISMARINE_BRICKS, "&bDynaTech Generators")); 38 | 39 | public static final SubItemGroup EXPERIMENTAL = new SubItemGroup(Keys.EXPERIMENTAL.key(), GENERAL, 40 | new CustomItemStack(Material.REDSTONE_LAMP, "&fDynaTech Experimental")); 41 | 42 | public static final SubItemGroup HIVES = new SubItemGroup(Keys.APIARIES.key(), 43 | GENERAL, new CustomItemStack(Material.BEEHIVE, "&bDynaTech Apiaries")); 44 | 45 | public static final class Keys { 46 | public static final TypedKey GENERAL = TypedKey.create("dynatech", "general"); 47 | public static final TypedKey RESOURCES = TypedKey.create("dynatech", "resources"); 48 | public static final TypedKey TOOLS = TypedKey.create("dynatech", "tools"); 49 | public static final TypedKey MACHINES = TypedKey.create("dynatech", "machines"); 50 | public static final TypedKey GENERATORS = TypedKey.create("dynatech", "generators"); 51 | public static final TypedKey EXPERIMENTAL = TypedKey.create("dynatech", "experimental"); 52 | public static final TypedKey APIARIES = TypedKey.create("dynatech", "apiaries"); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/RecipeTypes.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 4 | import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.RandomizedSet; 5 | import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe; 6 | import io.github.bakedlibs.dough.items.CustomItemStack; 7 | 8 | import me.profelements.dynatech.items.electric.MaterialHive; 9 | import me.profelements.dynatech.items.electric.machines.Orechid; 10 | 11 | import org.bukkit.Material; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | public class RecipeTypes { 15 | 16 | public static void init(Registry registry) { 17 | registry.register(Keys.SCOOPING, SCOOPING); 18 | registry.register(Keys.OVENING, OVENING); 19 | registry.register(Keys.BLOCK_DROP, BLOCK_DROP); 20 | registry.register(Keys.TREE_GROWTH_CHAMBER, TREE_GROWTH_CHAMBER); 21 | registry.register(Keys.MATERIAL_HIVE, MATERIAL_HIVE); 22 | registry.register(Keys.PETAL_APOTHECARY, PETAL_APOTHECARY); 23 | registry.register(Keys.ORECHID, ORECHID); 24 | } 25 | 26 | public static final RecipeType SCOOPING = new RecipeType(Keys.SCOOPING.key(), 27 | new CustomItemStack(Material.IRON_SHOVEL, "Use the Scoop to get this item.")); 28 | 29 | public static final RecipeType OVENING = new RecipeType(Keys.OVENING.key(), 30 | new CustomItemStack(Material.SMOKER, "Throw into the Coal Coke Oven multiblock")); 31 | 32 | public static final RecipeType BLOCK_DROP = new RecipeType(Keys.BLOCK_DROP.key(), 33 | new CustomItemStack(Material.COBWEB, "Drops from a block")); 34 | 35 | public static final RecipeType TREE_GROWTH_CHAMBER = new RecipeType(Keys.TREE_GROWTH_CHAMBER.key(), 36 | new CustomItemStack(Material.LIME_CONCRETE, "Throw into the Tree Growth Chamber machine")); 37 | 38 | public static final RecipeType MATERIAL_HIVE = new RecipeType(Keys.MATERIAL_HIVE.key(), 39 | Items.MATERIAL_HIVE.stack(), 40 | (recipe, output) -> { 41 | MaterialHive materialHive = ((MaterialHive) Items.MATERIAL_HIVE.stack().getItem()); 42 | materialHive.getMachineRecipes().add(new MachineRecipe(1800, recipe, new ItemStack[] { output })); 43 | }); 44 | 45 | public static final RecipeType PETAL_APOTHECARY = new RecipeType(Keys.PETAL_APOTHECARY.key(), 46 | Items.PETAL_APOTHECARY.stack(), 47 | (recipe, output) -> { 48 | 49 | }); 50 | 51 | public static final RecipeType ORECHID = new RecipeType(Keys.ORECHID.key(), Items.ORECHID.stack(), 52 | (recipe, output) -> { 53 | // Grab first item for input 54 | Material inputMaterial = recipe[0].getType(); 55 | RandomizedSet set = Orechid.oreMap.getOrDefault(inputMaterial, new RandomizedSet<>()); 56 | set.add(output, output.getAmount()); 57 | Orechid.oreMap.put(inputMaterial, set); 58 | }); 59 | 60 | public static final class Keys { 61 | public static final TypedKey SCOOPING = TypedKey.create("dynatech", "scooping"); 62 | public static final TypedKey OVENING = TypedKey.create("dynatech", "ovening"); 63 | public static final TypedKey BLOCK_DROP = TypedKey.create("dynatech", "block_drop"); 64 | public static final TypedKey TREE_GROWTH_CHAMBER = TypedKey.create("dynatech", 65 | "tree_growth_chamber"); 66 | public static final TypedKey MATERIAL_HIVE = TypedKey.create("dynatech", "material_hive"); 67 | public static final TypedKey PETAL_APOTHECARY = TypedKey.create("dynatech", "petal_apothecary"); 68 | public static final TypedKey ORECHID = TypedKey.create("dynatech", "orechid"); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/Registries.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup; 4 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 5 | import me.profelements.dynatech.utils.ItemWrapper; 6 | import me.profelements.dynatech.utils.Recipe; 7 | 8 | public class Registries { 9 | public static Registry ITEM_GROUPS = Registry.create(Keys.ITEM_GROUPS); 10 | public static Registry ITEMS = Registry.create(Keys.ITEMS); 11 | public static Registry RECIPE_TYPES = Registry.create(Keys.RECIPE_TYPES); 12 | public static Registry RECIPES = Registry.create(Keys.RECIPES); 13 | 14 | // FOR PEOPLE WHO WANT TO USE THESE listen to `RegistryFreezeEvent` 15 | // 16 | 17 | // public static final Registry BLOCKS = 18 | // Registry.create(Keys.BLOCKS); 19 | // public static final Registry FLUIDS = 20 | // Registry.create(Keys.FLUIDS); 21 | public static final class Keys { 22 | public static final TypedKey> RECIPE_TYPES = TypedKey.create("dynatech", "recipe_types"); 23 | public static final TypedKey> RECIPES = TypedKey.create("dynatech", "recipes"); 24 | public static final TypedKey> ITEM_GROUPS = TypedKey.create("dynatech", "item_groups"); 25 | public static final TypedKey> ITEMS = TypedKey.create("dynatech", "items"); 26 | // public static final TypedKey BLOCKS = TypedKey.create("dynatech", 27 | // "block"); 28 | // public static final TypedKey FLUIDS = TypedKey.create("dynatech", 29 | // "fluid"); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/Registry.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries; 2 | 3 | import java.util.Set; 4 | import java.util.Map; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | import java.util.function.Consumer; 7 | import java.util.function.Supplier; 8 | import java.util.stream.Collectors; 9 | 10 | import org.bukkit.Bukkit; 11 | import org.bukkit.NamespacedKey; 12 | 13 | import com.google.common.base.Preconditions; 14 | 15 | import me.profelements.dynatech.registries.events.RegistryAddEvent; 16 | import me.profelements.dynatech.registries.events.RegistryFreezeEvent; 17 | import me.profelements.dynatech.registries.events.RegistryRemoveEvent; 18 | 19 | public class Registry { 20 | public static final Map> registries = new ConcurrentHashMap<>(); 21 | private final Map, T> entries = new ConcurrentHashMap<>(); 22 | private final TypedKey> key; 23 | private boolean frozen; 24 | 25 | public Registry(TypedKey> key) { 26 | this.key = key; 27 | this.frozen = false; 28 | } 29 | 30 | static Registry create(TypedKey> key) { 31 | Preconditions.checkNotNull(key); 32 | var registry = new Registry(key); 33 | 34 | registries.put(key.key(), registry); 35 | 36 | return registry; 37 | } 38 | 39 | static Registry withFiller(TypedKey> key, Consumer> fillFunc) { 40 | Preconditions.checkNotNull(key); 41 | Registry registry = new Registry<>(key); 42 | 43 | fillFunc.accept(registry); 44 | 45 | return registry; 46 | } 47 | 48 | public void register(TypedKey key, T entry) { 49 | if (this.isFrozen()) { 50 | return; 51 | } 52 | 53 | Preconditions.checkNotNull(key); 54 | Preconditions.checkNotNull(entry); 55 | 56 | RegistryAddEvent event = RegistryAddEvent.create(this.getKey(), key, entry); 57 | Bukkit.getPluginManager().callEvent(event); 58 | 59 | if (!event.isCancelled()) { 60 | entries.putIfAbsent(event.getEntryKey(), event.getEntry()); 61 | } 62 | } 63 | 64 | public void unregister(TypedKey key) { 65 | if (this.isFrozen()) { 66 | return; 67 | } 68 | 69 | Preconditions.checkNotNull(key); 70 | 71 | RegistryRemoveEvent event = RegistryRemoveEvent.create(this.getKey(), key); 72 | Bukkit.getPluginManager().callEvent(event); 73 | 74 | if (!event.isCancelled()) { 75 | entries.remove(key); 76 | } 77 | } 78 | 79 | public boolean isFrozen() { 80 | return this.frozen; 81 | } 82 | 83 | void setFrozen(boolean frozen) { 84 | this.frozen = frozen; 85 | } 86 | 87 | public Registry freeze() { 88 | 89 | RegistryFreezeEvent event = RegistryFreezeEvent.create(this.getKey()); 90 | Bukkit.getPluginManager().callEvent(event); 91 | 92 | this.setFrozen(true); 93 | return this; 94 | } 95 | 96 | public void register(Supplier> key, Supplier entry) { 97 | register(key.get(), entry.get()); 98 | } 99 | 100 | public Set getEntries() { 101 | return entries.values().stream().collect(Collectors.toUnmodifiableSet()); 102 | } 103 | 104 | public Set> getKeys() { 105 | return entries.keySet().stream().collect(Collectors.toUnmodifiableSet()); 106 | } 107 | 108 | public T entry(TypedKey key) { 109 | Preconditions.checkNotNull(key); 110 | return entries.get(key); 111 | } 112 | 113 | public TypedKey> getKey() { 114 | Preconditions.checkNotNull(this.key); 115 | return this.key; 116 | } 117 | 118 | public static Registry getByKey(TypedKey> key) { 119 | return registries.get(key.key()); 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/TypedKey.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries; 2 | 3 | import java.util.Locale; 4 | 5 | import javax.annotation.Nonnull; 6 | 7 | import org.bukkit.NamespacedKey; 8 | 9 | public record TypedKey(@Nonnull NamespacedKey key) { 10 | public static TypedKey create(NamespacedKey key) { 11 | return new TypedKey<>(key); 12 | } 13 | 14 | public static TypedKey create(String namespace, String key) { 15 | return new TypedKey<>(new NamespacedKey(namespace, key)); 16 | } 17 | 18 | // THIS IS TEMPORARY TILL SLIMEFUN MOVES TO NamespacedKey 19 | public String asSlimefunId() { 20 | return this.key().toString().replace(':', '_').toUpperCase(Locale.ROOT); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/events/RegistryAddEvent.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries.events; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.ParametersAreNonnullByDefault; 5 | 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | import com.google.common.base.Preconditions; 11 | 12 | import me.profelements.dynatech.registries.Registry; 13 | import me.profelements.dynatech.registries.TypedKey; 14 | 15 | public class RegistryAddEvent extends Event implements Cancellable { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | 19 | private final TypedKey> registryKey; 20 | private TypedKey entryKey; 21 | private T entry; 22 | private boolean cancelled; 23 | 24 | @ParametersAreNonnullByDefault 25 | private RegistryAddEvent(TypedKey> registryKey, TypedKey entryKey, T entry) { 26 | this.registryKey = registryKey; 27 | this.entryKey = entryKey; 28 | this.entry = entry; 29 | } 30 | 31 | public static RegistryAddEvent create(TypedKey> registryKey, TypedKey entryKey, T entry) { 32 | Preconditions.checkNotNull(registryKey); 33 | Preconditions.checkNotNull(entryKey); 34 | Preconditions.checkNotNull(entry); 35 | 36 | return new RegistryAddEvent<>(registryKey, entryKey, entry); 37 | } 38 | 39 | @Nonnull 40 | public TypedKey> getRegistyKey() { 41 | return registryKey; 42 | } 43 | 44 | @Nonnull 45 | public TypedKey getEntryKey() { 46 | return entryKey; 47 | } 48 | 49 | public void setEntryKey(TypedKey entry) { 50 | Preconditions.checkNotNull(entry); 51 | entryKey = entry; 52 | } 53 | 54 | @Nonnull 55 | public T getEntry() { 56 | return entry; 57 | } 58 | 59 | public void setEntry(T entryKey) { 60 | Preconditions.checkNotNull(entryKey); 61 | entry = entryKey; 62 | } 63 | 64 | @Override 65 | public void setCancelled(boolean cancel) { 66 | cancelled = cancel; 67 | } 68 | 69 | @Override 70 | public boolean isCancelled() { 71 | return cancelled; 72 | } 73 | 74 | @Nonnull 75 | public static HandlerList getHandlerList() { 76 | return handlers; 77 | } 78 | 79 | @Override 80 | public HandlerList getHandlers() { 81 | return getHandlerList(); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/events/RegistryFreezeEvent.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries.events; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.ParametersAreNonnullByDefault; 5 | 6 | import org.bukkit.event.Event; 7 | import org.bukkit.event.HandlerList; 8 | 9 | import com.google.common.base.Preconditions; 10 | 11 | import me.profelements.dynatech.registries.Registry; 12 | import me.profelements.dynatech.registries.TypedKey; 13 | 14 | public class RegistryFreezeEvent extends Event { 15 | private static final HandlerList handlers = new HandlerList(); 16 | 17 | private final TypedKey> registryKey; 18 | 19 | @ParametersAreNonnullByDefault 20 | private RegistryFreezeEvent(TypedKey> registryKey) { 21 | this.registryKey = registryKey; 22 | } 23 | 24 | public static RegistryFreezeEvent create(TypedKey> registryKey) { 25 | Preconditions.checkNotNull(registryKey); 26 | 27 | return new RegistryFreezeEvent<>(registryKey); 28 | } 29 | 30 | public TypedKey> getRegistryKey() { 31 | return registryKey; 32 | } 33 | 34 | @Nonnull 35 | public static HandlerList getHandlerList() { 36 | return handlers; 37 | } 38 | 39 | @Override 40 | public HandlerList getHandlers() { 41 | return getHandlerList(); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/registries/events/RegistryRemoveEvent.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.registries.events; 2 | 3 | import javax.annotation.Nonnull; 4 | import javax.annotation.ParametersAreNonnullByDefault; 5 | 6 | import org.bukkit.event.Cancellable; 7 | import org.bukkit.event.Event; 8 | import org.bukkit.event.HandlerList; 9 | 10 | import com.google.common.base.Preconditions; 11 | 12 | import me.profelements.dynatech.registries.Registry; 13 | import me.profelements.dynatech.registries.TypedKey; 14 | 15 | public class RegistryRemoveEvent extends Event implements Cancellable { 16 | 17 | private static final HandlerList handlers = new HandlerList(); 18 | 19 | private final TypedKey> registryKey; 20 | private TypedKey entryKey; 21 | private boolean cancelled; 22 | 23 | @ParametersAreNonnullByDefault 24 | private RegistryRemoveEvent(TypedKey> registryKey, TypedKey entryKey) { 25 | this.registryKey = registryKey; 26 | this.entryKey = entryKey; 27 | } 28 | 29 | public static RegistryRemoveEvent create(TypedKey> registryKey, TypedKey entryKey) { 30 | Preconditions.checkNotNull(registryKey); 31 | Preconditions.checkNotNull(entryKey); 32 | 33 | return new RegistryRemoveEvent<>(registryKey, entryKey); 34 | } 35 | 36 | @Nonnull 37 | public TypedKey> getRegistyKey() { 38 | return registryKey; 39 | } 40 | 41 | @Nonnull 42 | public TypedKey getEntryKey() { 43 | return entryKey; 44 | } 45 | 46 | @Override 47 | public void setCancelled(boolean cancel) { 48 | cancelled = cancel; 49 | } 50 | 51 | @Override 52 | public boolean isCancelled() { 53 | return cancelled; 54 | } 55 | 56 | @Nonnull 57 | public static HandlerList getHandlerList() { 58 | return handlers; 59 | } 60 | 61 | @Override 62 | public HandlerList getHandlers() { 63 | return getHandlerList(); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/tasks/ItemBandTask.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.tasks; 2 | 3 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem; 4 | import io.github.thebusybiscuit.slimefun4.libraries.dough.data.persistent.PersistentDataAPI; 5 | import me.profelements.dynatech.DynaTech; 6 | import me.profelements.dynatech.items.misc.ItemBand; 7 | import org.bukkit.Bukkit; 8 | import org.bukkit.Material; 9 | import org.bukkit.attribute.Attribute; 10 | import org.bukkit.entity.Player; 11 | import org.bukkit.inventory.ItemStack; 12 | import org.bukkit.potion.PotionEffect; 13 | import org.bukkit.potion.PotionEffectType; 14 | 15 | import javax.annotation.Nonnull; 16 | import javax.annotation.Nullable; 17 | 18 | public class ItemBandTask implements Runnable { 19 | 20 | //The value if not null will be a SlIMEFUN_ID that is an Item 21 | 22 | public ItemBandTask() {} 23 | 24 | @Override 25 | public void run() { 26 | for (Player p : Bukkit.getOnlinePlayers()) { 27 | if (!p.isValid() || p.isDead()) { 28 | continue; 29 | } 30 | for (ItemStack item : p.getEquipment().getArmorContents()) { 31 | testItemBand(p, item); 32 | } 33 | testItemBand(p, p.getEquipment().getItemInMainHand()); 34 | } 35 | } 36 | 37 | private static void testItemBand(@Nonnull Player p, @Nullable ItemStack item) { 38 | if (item != null && item.getType() != Material.AIR && item.hasItemMeta()) { 39 | String id = PersistentDataAPI.getString(item.getItemMeta(), ItemBand.KEY); 40 | 41 | if (id != null) { 42 | SlimefunItem sfItem = SlimefunItem.getById(id); 43 | 44 | if (sfItem instanceof ItemBand) { 45 | ItemBand itemBand = (ItemBand) sfItem; 46 | 47 | DynaTech.runSync(() -> { 48 | for (PotionEffect pe : itemBand.getPotionEffects()) { 49 | if (pe.getType() == PotionEffectType.HEALTH_BOOST) 50 | { 51 | double health = p.getHealth(); 52 | p.addPotionEffect(pe); 53 | if (health > p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()) { 54 | p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); 55 | } else { 56 | p.setHealth(health); 57 | } 58 | 59 | } else { 60 | p.addPotionEffect(pe); 61 | } 62 | } 63 | }); 64 | } 65 | } 66 | } 67 | } 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/ChestMenuUtils.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import java.util.HashSet; 4 | import java.util.List; 5 | import java.util.Set; 6 | 7 | import org.bukkit.entity.Player; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu; 11 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler; 12 | import me.profelements.dynatech.DynaTech; 13 | import me.profelements.dynatech.registries.Registries; 14 | import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction; 15 | 16 | public class ChestMenuUtils { 17 | 18 | private static final ItemStack BACKGROUND_ITEM = io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils 19 | .getBackground(); 20 | private static final MenuClickHandler NO_CLICK = io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils 21 | .getEmptyClickHandler(); 22 | 23 | public static void openRecipeBook(Player p) { 24 | ChestMenu menu = new ChestMenu("Recipe Book"); 25 | menu.setEmptySlotsClickable(false); 26 | 27 | Set recipes = Registries.RECIPES.getEntries(); 28 | 29 | Set outputs = new HashSet<>(); 30 | 31 | for (Recipe recipe : recipes) { 32 | outputs.add(recipe.getOutput()[0]); 33 | } 34 | 35 | int iter = 0; 36 | for (ItemStack recipeOutput : outputs) { 37 | if (iter == 54) { 38 | break; 39 | } 40 | 41 | menu.addItem(iter, recipeOutput, new MenuClickHandler() { 42 | @Override 43 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 44 | openRecipeWithItem(p, menu.getItemInSlot(slot), 0); 45 | return false; 46 | } 47 | }); 48 | iter++; 49 | } 50 | 51 | menu.open(p); 52 | } 53 | 54 | private static void openRecipeWithItem(Player p, ItemStack item, int idx) { 55 | ChestMenu menu = new ChestMenu("Recipe"); 56 | menu.setEmptySlotsClickable(false); 57 | 58 | menu.addItem(0, io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils.getBackButton(p, ""), 59 | new MenuClickHandler() { 60 | @Override 61 | public boolean onClick(Player p, int slot, ItemStack item, ClickAction action) { 62 | openRecipeBook(p); 63 | return false; 64 | } 65 | }); 66 | 67 | for (int i = 1; i < 9; i++) { 68 | menu.addItem(i, BACKGROUND_ITEM, NO_CLICK); 69 | } 70 | 71 | List recipes = Registries.RECIPES.getEntries().stream() 72 | .filter((recipe) -> recipe.getOutput()[0].equals(item)).toList(); 73 | 74 | Recipe recipe = recipes.get(idx); 75 | 76 | int[] recipeSlots = new int[] { 12, 13, 14, 21, 22, 23, 30, 31, 32 }; 77 | int iter = 0; 78 | 79 | for (ItemStack recipeItem : recipe.getInput()) { 80 | if (RecipeRegistry.getInstance().getRecipesByOutput(recipeItem).toList().size() > 0) { 81 | menu.addItem(recipeSlots[iter], recipeItem, new MenuClickHandler() { 82 | 83 | @Override 84 | public boolean onClick(Player p, int slot, ItemStack itemS, ClickAction action) { 85 | openRecipeWithItem(p, recipeItem, 0); 86 | return false; 87 | } 88 | 89 | }); 90 | } else { 91 | menu.addItem(recipeSlots[iter], recipeItem, NO_CLICK); 92 | } 93 | iter++; 94 | } 95 | 96 | menu.addItem(19, recipe.getRecipeType().toItem(), NO_CLICK); 97 | menu.addItem(25, recipe.getOutput()[0], NO_CLICK); 98 | 99 | // air , air , air 100 | menu.addItem(36, 101 | io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils.getPreviousButton(p, idx + 1, recipes.size()), 102 | new MenuClickHandler() { 103 | 104 | @Override 105 | public boolean onClick(Player p, int slot, ItemStack itemS, ClickAction action) { 106 | openRecipeWithItem(p, item, Math.max(0, idx - 1)); 107 | return false; 108 | } 109 | 110 | }); 111 | 112 | menu.addItem(44, 113 | io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils.getNextButton(p, idx + 1, recipes.size()), 114 | new MenuClickHandler() { 115 | 116 | @Override 117 | public boolean onClick(Player p, int slot, ItemStack itemS, ClickAction action) { 118 | openRecipeWithItem(p, item, Math.min(recipes.size() - 1, idx + 1)); 119 | return false; 120 | } 121 | 122 | }); 123 | for (int i = 37; i < 44; i++) { 124 | menu.addItem(i, BACKGROUND_ITEM, NO_CLICK); 125 | } 126 | 127 | menu.open(p); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/EnergyUtils.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.Iterator; 6 | import java.util.List; 7 | import java.util.Map; 8 | 9 | import org.bukkit.Location; 10 | import org.bukkit.Material; 11 | import org.bukkit.inventory.ItemStack; 12 | 13 | import io.github.bakedlibs.dough.blocks.BlockPosition; 14 | import me.mrCookieSlime.Slimefun.api.BlockStorage; 15 | import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu; 16 | 17 | public class EnergyUtils { 18 | 19 | private EnergyUtils() { 20 | } 21 | 22 | public static final int moveEnergyFromTo(BlockPosition from, BlockPosition to, int fromEnergyRate, 23 | int toEnergyMax) { 24 | Location fromLocation = from.toLocation(); 25 | Location toLocation = to.toLocation(); 26 | String energyKey = "energy-charge"; 27 | 28 | String fromEnergyAmount = BlockStorage.getLocationInfo(fromLocation, energyKey); 29 | String toEnergyAmount = BlockStorage.getLocationInfo(toLocation, energyKey); 30 | if (fromEnergyAmount == null || toEnergyAmount == null) { 31 | return 0; 32 | } 33 | 34 | int fromEnergy = Integer.parseInt(fromEnergyAmount); 35 | int toEnergy = Integer.parseInt(toEnergyAmount); 36 | 37 | int energyToTransfer = Math.min(fromEnergyRate, Math.min(toEnergyMax - toEnergy, fromEnergy)); 38 | 39 | int newFromEnergy = fromEnergy - energyToTransfer; 40 | int newToEnergy = toEnergy + energyToTransfer; 41 | 42 | BlockStorage.addBlockInfo(fromLocation, energyKey, String.valueOf(newFromEnergy)); 43 | BlockStorage.addBlockInfo(toLocation, energyKey, String.valueOf(newToEnergy)); 44 | 45 | return energyToTransfer; 46 | } 47 | 48 | public static final void moveInventoryFromTo(BlockPosition from, BlockPosition to, int[] fromSlots, int[] toSlots) { 49 | BlockMenu fromMenu = BlockStorage.getInventory(from.toLocation()); 50 | BlockMenu toMenu = BlockStorage.getInventory(to.toLocation()); 51 | if (fromMenu == null || toMenu == null) { 52 | return; 53 | } 54 | 55 | Map itemsToTransfer = new HashMap(fromSlots.length); 56 | for (int slot : fromSlots) { 57 | ItemStack stack = fromMenu.getItemInSlot(slot); 58 | 59 | if (stack == null) { 60 | continue; 61 | } 62 | 63 | itemsToTransfer.put(slot, stack); 64 | } 65 | 66 | if (itemsToTransfer.isEmpty()) { 67 | return; 68 | } 69 | 70 | List emptySlots = new ArrayList<>(toSlots.length); 71 | for (int slot : toSlots) { 72 | ItemStack stack = toMenu.getItemInSlot(slot); 73 | // Skips currently occupied slots (should probably do this better 74 | if (stack != null) { 75 | continue; 76 | } 77 | 78 | emptySlots.add(slot); 79 | } 80 | 81 | Iterator> entryIter = itemsToTransfer.entrySet().iterator(); 82 | for (int slot : emptySlots) { 83 | if (!entryIter.hasNext()) { 84 | return; 85 | } 86 | 87 | Map.Entry entry = entryIter.next(); 88 | // if (entry == null) { 89 | // return; 90 | // } 91 | 92 | int fromSlot = entry.getKey(); 93 | ItemStack item = entry.getValue(); 94 | 95 | toMenu.toInventory().setItem(slot, item); 96 | fromMenu.replaceExistingItem(fromSlot, new ItemStack(Material.AIR, 0)); 97 | } 98 | 99 | fromMenu.markDirty(); 100 | toMenu.markDirty(); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/ItemWrapper.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import me.profelements.dynatech.registries.TypedKey; 4 | import me.profelements.dynatech.registries.Registries; 5 | 6 | import com.google.common.base.Preconditions; 7 | 8 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack; 9 | 10 | public record ItemWrapper(TypedKey key, SlimefunItemStack stack) { 11 | 12 | public static ItemWrapper create(TypedKey key, SlimefunItemStack stack) { 13 | Preconditions.checkNotNull(key); 14 | Preconditions.checkNotNull(stack); 15 | 16 | ItemWrapper item = new ItemWrapper(key, stack); 17 | Registries.ITEMS.register(key, item); 18 | 19 | return item; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/Liquid.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import org.bukkit.Color; 4 | import org.bukkit.Material; 5 | import org.bukkit.NamespacedKey; 6 | 7 | import com.google.common.base.Preconditions; 8 | 9 | public class Liquid { 10 | private NamespacedKey KEY; 11 | private String NAME; 12 | private Color LIQUID_COLOR; 13 | private Material LIQUID_MATERIAL; 14 | private Material STORAGE_MATERIAL; 15 | 16 | private Liquid() { 17 | } 18 | 19 | public static Liquid init() { 20 | return new Liquid(); 21 | } 22 | 23 | public Liquid setKey(NamespacedKey key) { 24 | Preconditions.checkNotNull(key, "The liquid's key should not be null!"); 25 | this.KEY = key; 26 | return this; 27 | } 28 | 29 | public final NamespacedKey getKey() { 30 | return this.KEY; 31 | } 32 | 33 | public Liquid setName(String name) { 34 | Preconditions.checkNotNull(name, "The liquid's name should not be null!"); 35 | this.NAME = name; 36 | return this; 37 | } 38 | 39 | public final String getName() { 40 | return this.NAME; 41 | } 42 | 43 | public Liquid setColor(Color color) { 44 | Preconditions.checkNotNull(color, " The Liquid's color should not be null!"); 45 | this.LIQUID_COLOR = color; 46 | return this; 47 | } 48 | 49 | public final Color getColor() { 50 | return this.LIQUID_COLOR; 51 | } 52 | 53 | public Liquid setLiquidMaterial(Material mat) { 54 | Preconditions.checkArgument(mat == Material.LAVA || mat == Material.WATER, 55 | "The liquid's liquid material should be a liquid!"); 56 | this.LIQUID_MATERIAL = mat; 57 | return this; 58 | } 59 | 60 | public final Material getLiquidMaterial() { 61 | return this.LIQUID_MATERIAL; 62 | } 63 | 64 | public Liquid setStorageMaterial(Material mat) { 65 | Preconditions.checkNotNull(mat, "The Liquid's storage material should not be null!"); 66 | this.STORAGE_MATERIAL = mat; 67 | return this; 68 | } 69 | 70 | public final Material getStorageMaterial() { 71 | return this.STORAGE_MATERIAL; 72 | } 73 | 74 | public final Liquid build() { 75 | Preconditions.checkNotNull(this.KEY, "The liquid's key should not be null!"); 76 | Preconditions.checkNotNull(this.NAME, "The liquid's name should not be null!"); 77 | Preconditions.checkNotNull(this.LIQUID_COLOR, " The Liquid's color should not be null!"); 78 | Preconditions.checkNotNull(this.LIQUID_MATERIAL, "The Liquid's liquid material should not be null!"); 79 | Preconditions.checkNotNull(this.STORAGE_MATERIAL, "The Liquid's storage material should not be null!"); 80 | return this; 81 | } 82 | 83 | public void register(LiquidRegistry registry) { 84 | Liquid liquid = this.build(); 85 | registry.addLiquid(liquid); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/LiquidRegistry.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.bukkit.NamespacedKey; 7 | 8 | public class LiquidRegistry { 9 | private static final ArrayList LIQUIDS = new ArrayList<>(); 10 | 11 | private static LiquidRegistry INSTANCE; 12 | 13 | private LiquidRegistry() { 14 | INSTANCE = this; 15 | } 16 | 17 | public static LiquidRegistry getInstance() { 18 | return INSTANCE; 19 | } 20 | 21 | public static LiquidRegistry init() { 22 | return new LiquidRegistry(); 23 | } 24 | 25 | public LiquidRegistry addLiquid(Liquid liquid) { 26 | LIQUIDS.add(liquid); 27 | return this; 28 | } 29 | 30 | public List getLiquids() { 31 | return LIQUIDS; 32 | } 33 | 34 | public final Liquid getByKey(NamespacedKey key) { 35 | return getLiquids().stream().filter(r -> r.getKey().equals(key)).toList().get(0); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/Recipe.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import org.bukkit.NamespacedKey; 4 | import org.bukkit.inventory.ItemStack; 5 | 6 | import com.google.common.base.Preconditions; 7 | 8 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 9 | import me.profelements.dynatech.registries.Registries; 10 | import me.profelements.dynatech.registries.TypedKey; 11 | 12 | public class Recipe { 13 | private NamespacedKey KEY; 14 | private RecipeType TYPE; 15 | private ItemStack[] INPUT; 16 | private ItemStack[] OUTPUT; 17 | 18 | protected Recipe() { 19 | } 20 | 21 | public static Recipe init() { 22 | return new Recipe(); 23 | } 24 | 25 | public Recipe setKey(NamespacedKey key) { 26 | Preconditions.checkNotNull(key, "The recipe's namespaced key should not be null"); 27 | this.KEY = key; 28 | return this; 29 | } 30 | 31 | public final NamespacedKey getKey() { 32 | return this.KEY; 33 | } 34 | 35 | public Recipe setRecipeType(RecipeType type) { 36 | Preconditions.checkNotNull(type, "The recipe's type should not be null"); 37 | this.TYPE = type; 38 | return this; 39 | } 40 | 41 | public final RecipeType getRecipeType() { 42 | return this.TYPE; 43 | } 44 | 45 | public Recipe setInput(ItemStack input) { 46 | Preconditions.checkNotNull(input, "This recipe's inputs should not be null"); 47 | this.INPUT = new ItemStack[] { input }; 48 | return this; 49 | } 50 | 51 | public Recipe setInput(ItemStack[] input) { 52 | Preconditions.checkNotNull(input, "This recipe's inputs should not be null"); 53 | this.INPUT = input; 54 | return this; 55 | } 56 | 57 | public final ItemStack[] getInput() { 58 | return this.INPUT; 59 | } 60 | 61 | public Recipe setOutput(ItemStack output) { 62 | Preconditions.checkNotNull(output, "This recipe's output should not be null"); 63 | this.OUTPUT = new ItemStack[] { output }; 64 | return this; 65 | } 66 | 67 | public Recipe setOutput(ItemStack output, int amount) { 68 | Preconditions.checkNotNull(output, "This recipe's output should not be null"); 69 | var actualOutput = output.clone(); 70 | actualOutput.setAmount(amount); 71 | this.OUTPUT = new ItemStack[] { actualOutput }; 72 | return this; 73 | } 74 | 75 | public Recipe setOutput(ItemStack[] output) { 76 | Preconditions.checkNotNull(output, "This recipe's output should not be null"); 77 | this.OUTPUT = output; 78 | return this; 79 | } 80 | 81 | public final ItemStack[] getOutput() { 82 | return this.OUTPUT; 83 | } 84 | 85 | public void validate() { 86 | Preconditions.checkNotNull(this.KEY, "The recipe's namespaced key should not be null"); 87 | Preconditions.checkNotNull(this.TYPE, "The recipe's type should not be null"); 88 | Preconditions.checkNotNull(this.INPUT, "This recipe's inputs should not be null"); 89 | Preconditions.checkNotNull(this.OUTPUT, "This recipe's output should not be null"); 90 | 91 | } 92 | 93 | public Recipe build() { 94 | this.validate(); 95 | return this; 96 | } 97 | 98 | public Recipe register() { 99 | Recipe res = this.build(); 100 | res.getRecipeType().register(res.getInput(), res.getOutput()[0]); 101 | Registries.RECIPES.register(TypedKey.create(res.getKey()), res); 102 | return res; 103 | } 104 | 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/RecipeRegistry.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import java.util.stream.Stream; 6 | 7 | import org.bukkit.NamespacedKey; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType; 11 | 12 | public class RecipeRegistry { 13 | private static final ArrayList RECIPES = new ArrayList<>(); 14 | private static RecipeRegistry INSTANCE; 15 | 16 | private RecipeRegistry() { 17 | INSTANCE = this; 18 | } 19 | 20 | public static RecipeRegistry getInstance() { 21 | return INSTANCE; 22 | } 23 | 24 | public static RecipeRegistry init() { 25 | return new RecipeRegistry(); 26 | } 27 | 28 | public RecipeRegistry addRecipe(Recipe recipe) { 29 | RECIPES.add(recipe); 30 | return this; 31 | } 32 | 33 | public final ArrayList getRecipes() { 34 | return RECIPES; 35 | } 36 | 37 | public final Recipe getRecipeByKey(NamespacedKey key) { 38 | return getRecipes().stream().filter(r -> r.getKey().equals(key)).toList().get(0); 39 | } 40 | 41 | public final Stream getRecipesByRecipeType(RecipeType type) { 42 | return getRecipes().stream().filter(r -> r.getRecipeType().equals(type)); 43 | } 44 | 45 | public final Stream getRecipesByInput(ItemStack[] input) { 46 | return getRecipes().stream().filter(r -> r.getInput().equals(input)); 47 | } 48 | 49 | public final Stream getRecipesByOutput(ItemStack output) { 50 | return getRecipes().stream().filter(r -> r.getOutput()[0].equals(output)); 51 | } 52 | 53 | public final Stream getRecipeByOutputs(ItemStack[] outputs) { 54 | return getRecipes().stream().filter(r -> r.getOutput().equals(outputs)); 55 | } 56 | 57 | public final boolean isMatching(RecipeType type, ItemStack[] input, ItemStack output) { 58 | List recipes = getRecipesByRecipeType(type).filter(r -> r.getOutput().equals(output)) 59 | .filter(r -> r.getInput().equals(input)).toList(); 60 | return !recipes.isEmpty(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/me/profelements/dynatech/utils/TimedRecipe.java: -------------------------------------------------------------------------------- 1 | package me.profelements.dynatech.utils; 2 | 3 | import com.google.common.base.Preconditions; 4 | 5 | import me.profelements.dynatech.registries.Registries; 6 | import me.profelements.dynatech.registries.TypedKey; 7 | 8 | public class TimedRecipe extends Recipe { 9 | private int TIME_IN_TICKS; 10 | 11 | protected TimedRecipe() { 12 | super(); 13 | } 14 | 15 | public static TimedRecipe init() { 16 | return new TimedRecipe(); 17 | } 18 | 19 | public final int getTimeInTicks() { 20 | return this.TIME_IN_TICKS; 21 | } 22 | 23 | public TimedRecipe setTimeInTicks(int ticks) { 24 | Preconditions.checkNotNull(ticks, "The recipe's time in ticks should not be null"); 25 | this.TIME_IN_TICKS = ticks; 26 | return this; 27 | } 28 | 29 | @Override 30 | public TimedRecipe build() { 31 | Preconditions.checkNotNull(this.TIME_IN_TICKS, "The recipe's time in ticks should not be null"); 32 | super.validate(); 33 | return this; 34 | } 35 | 36 | @Override 37 | public Recipe register() { 38 | TimedRecipe res = this.build(); 39 | res.getRecipeType().register(res.getInput(), res.getOutput()[0]); 40 | Registries.RECIPES.register(TypedKey.create(this.getKey()), res); 41 | return res; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/resources/config.yml: -------------------------------------------------------------------------------- 1 | options: 2 | auto-update: false 3 | disable-dimensionalhome-world: false 4 | -------------------------------------------------------------------------------- /src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | ## CHANGE this to the name of your plugin. 2 | name: DynaTech 3 | 4 | ## CHANGE this to your username. 5 | author: ProfElements 6 | 7 | ## CHANGE this to a meaninful but short description of your plugin. 8 | description: A slimefun addon that add random stuff I want 9 | 10 | ## CHANGE this to the path of the class that extends JavaPlugin. 11 | main: me.profelements.dynatech.DynaTech 12 | 13 | ## You can change this to link to your website or repository. You can also remove this line if you want to. 14 | website: https://github.com/ProfElements/DynaTech 15 | 16 | ## This is required and marks Slimefun as a plugin dependency. 17 | depend: [Slimefun] 18 | softdepend: [ExoticGarden, InfinityExpansion, Gastronomicon] 19 | 20 | ## This value is automatically replaced by the version specified in your pom.xml file, do not change this. 21 | version: ${project.version} 22 | 23 | ## This is the minimum minecraft version required to run your plugin. 24 | api-version: 1.19 25 | --------------------------------------------------------------------------------