Skip to content

Commit

Permalink
Dev (#12)
Browse files Browse the repository at this point in the history
* Gadgets and Mechanisms

* Mob Utils
  • Loading branch information
Sefiraat authored Nov 4, 2021
1 parent 9442179 commit 31fa3f4
Show file tree
Hide file tree
Showing 3 changed files with 386 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,33 @@

import io.github.sefiraat.crystamaehistoria.CrystamaeHistoria;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.chroniclerpanel.ChroniclerPanel;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.CursedEarth;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobFan;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobLamp;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.MobMat;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.DummyLiquefactionBasinCrafting;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasin;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.RecipeItem;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.realisationaltar.RealisationAltar;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.staveconfigurator.StaveConfigurator;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryRarity;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.theme.ThemeType;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import io.github.thebusybiscuit.slimefun4.implementation.SlimefunItems;
import io.papermc.paper.tag.EntityTags;
import lombok.Getter;
import lombok.experimental.UtilityClass;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;

import javax.swing.text.html.parser.Entity;
import java.util.ArrayList;
import java.util.List;

@UtilityClass
public class Mechanisms {

Expand Down Expand Up @@ -56,11 +66,25 @@ public class Mechanisms {
private static MobFan inversionVacuum;
@Getter
private static MobFan antipodalVacuum;
@Getter
private static CursedEarth cursedEarth;
@Getter
private static CursedEarth dreadfulDirt;
@Getter
private static MobMat searingPlate;
@Getter
private static MobMat doomedPlate;
@Getter
private static MobMat evisceratingPlate;

public static void setup() {

final CrystamaeHistoria plugin = CrystamaeHistoria.getInstance();

final ItemStack uniqueVoid = Materials.CRYSTAL_MAP.get(StoryRarity.UNIQUE).get(StoryType.VOID).getItem();
final ItemStack amalgamateDustRare = Materials.getAmalgamateDustRare().getItem();
final ItemStack amalgamateIngotUncommon = Materials.getAmalgamateIngotUncommon().getItem();

// Chronicler Tier 1
chroniclerPanel1 = new ChroniclerPanel(
ItemGroups.MECHANISMS,
Expand Down Expand Up @@ -100,9 +124,9 @@ SlimefunItems.CORINTHIAN_BRONZE_INGOT, new ItemStack(Material.AMETHYST_CLUSTER),
),
RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[]{
new ItemStack(Material.DEEPSLATE_BRICKS), new ItemStack(Material.DEEPSLATE_BRICKS), new ItemStack(Material.DEEPSLATE_BRICKS),
Materials.getAmalgamateIngotUncommon().getItem(), chroniclerPanel1.getItem(), Materials.getAmalgamateIngotUncommon().getItem(),
SlimefunItems.MAGIC_LUMP_3, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.MAGIC_LUMP_3,
new ItemStack(Material.DEEPSLATE_BRICKS), new ItemStack(Material.DEEPSLATE_BRICKS), new ItemStack(Material.DEEPSLATE_BRICKS),
amalgamateIngotUncommon, chroniclerPanel1.getItem(), amalgamateIngotUncommon,
SlimefunItems.MAGIC_LUMP_3, SlimefunItems.MAGIC_LUMP_3, SlimefunItems.MAGIC_LUMP_3,
},
2
);
Expand Down Expand Up @@ -196,9 +220,9 @@ SlimefunItems.CORINTHIAN_BRONZE_INGOT, new ItemStack(Material.AMETHYST_CLUSTER),
),
RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[]{
null, new ItemStack(Material.BOOK), null,
Materials.getAmalgamateIngotUncommon().getItem(), realisationAltar1.getItem(), Materials.getAmalgamateIngotUncommon().getItem(),
SlimefunItems.MAGIC_LUMP_3, SlimefunItems.SOULBOUND_RUNE, SlimefunItems.MAGIC_LUMP_3,
null, new ItemStack(Material.BOOK), null,
amalgamateIngotUncommon, realisationAltar1.getItem(), amalgamateIngotUncommon,
SlimefunItems.MAGIC_LUMP_3, SlimefunItems.SOULBOUND_RUNE, SlimefunItems.MAGIC_LUMP_3,
},
2
);
Expand Down Expand Up @@ -292,9 +316,9 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
),
RecipeType.ENHANCED_CRAFTING_TABLE,
new ItemStack[]{
Materials.getAmalgamateDustRare().getItem(), null, Materials.getAmalgamateDustRare().getItem(),
Materials.getAmalgamateDustRare().getItem(), liquefactionBasin1.getItem(), Materials.getAmalgamateDustRare().getItem(),
Materials.getAmalgamateDustRare().getItem(), SlimefunItems.ENCHANTMENT_RUNE, Materials.getAmalgamateDustRare().getItem()
amalgamateDustRare, null, amalgamateDustRare,
amalgamateDustRare, liquefactionBasin1.getItem(), amalgamateDustRare,
amalgamateDustRare, SlimefunItems.ENCHANTMENT_RUNE, amalgamateDustRare
},
1000
);
Expand Down Expand Up @@ -448,7 +472,6 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
5
);


// Antipodal Vacuum
RecipeItem antipodalVacuumRecipe = new RecipeItem(
dispersionLamp.getItem(),
Expand All @@ -474,6 +497,160 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
10
);

// Cursed Earth
final List<EntityType> cursedEarthSpawns = new ArrayList<>();

cursedEarthSpawns.add(EntityType.SKELETON);
cursedEarthSpawns.add(EntityType.ZOMBIE);
cursedEarthSpawns.add(EntityType.ENDERMAN);
cursedEarthSpawns.add(EntityType.CREEPER);
cursedEarthSpawns.add(EntityType.CAVE_SPIDER);
cursedEarthSpawns.add(EntityType.SILVERFISH);

cursedEarth = new CursedEarth(
ItemGroups.MECHANISMS,
ThemeType.themedSlimefunItemStack(
"CRY_MOB_DIRT_1",
new ItemStack(Material.BROWN_WOOL),
ThemeType.MECHANISM,
"Cursed Earth",
"Dark magics seep from this dirt giving",
"a very ominous vibe!",
"",
ThemeType.CLICK_INFO.getColor() + "Tick Rate: " + ThemeType.PASSIVE.getColor() + "20",
ThemeType.CLICK_INFO.getColor() + "Light Level: " + ThemeType.PASSIVE.getColor() + "7",
ThemeType.CLICK_INFO.getColor() + "Spawns: " + ThemeType.PASSIVE.getColor() + "Basic"
),
RecipeType.MAGIC_WORKBENCH,
new ItemStack[] {
uniqueVoid, uniqueVoid, uniqueVoid,
new ItemStack(Material.DIRT), new ItemStack(Material.DIRT), new ItemStack(Material.DIRT),
amalgamateDustRare, amalgamateDustRare, amalgamateDustRare
},
20,
7,
cursedEarthSpawns,
Color.fromRGB(95, 50, 15)
);

// Dreadful Dirt
final List<EntityType> dreadfulDirtSpawns = new ArrayList<>(cursedEarthSpawns);

dreadfulDirtSpawns.add(EntityType.WITHER_SKELETON);
dreadfulDirtSpawns.add(EntityType.HUSK);
dreadfulDirtSpawns.add(EntityType.STRAY);
dreadfulDirtSpawns.add(EntityType.BLAZE);
dreadfulDirtSpawns.add(EntityType.ZOMBIE_VILLAGER);

RecipeItem dreadfulDirtRecipe = new RecipeItem(
cursedEarth.getItem(),
StoryType.VOID, 700,
StoryType.ANIMAL, 200,
StoryType.HISTORICAL, 100
);
dreadfulDirt = new CursedEarth(
ItemGroups.MECHANISMS,
ThemeType.themedSlimefunItemStack(
"CRY_MOB_DIRT_2",
new ItemStack(Material.BLACK_WOOL),
ThemeType.MECHANISM,
"Dreadful Dirt",
"Dark magics seep from this dirt giving",
"a very ominous vibe!",
"",
ThemeType.CLICK_INFO.getColor() + "Tick Rate: " + ThemeType.PASSIVE.getColor() + "10",
ThemeType.CLICK_INFO.getColor() + "Light Level: " + ThemeType.PASSIVE.getColor() + "15",
ThemeType.CLICK_INFO.getColor() + "Spawns: " + ThemeType.PASSIVE.getColor() + "Advanced"
),
DummyLiquefactionBasinCrafting.TYPE,
dreadfulDirtRecipe.getDisplayRecipe(),
10,
15,
dreadfulDirtSpawns,
Color.BLACK
);

// Searing Plate
RecipeItem searingPlateRecipe = new RecipeItem(
new ItemStack(Material.STONE_PRESSURE_PLATE),
StoryType.ALCHEMICAL, 120,
StoryType.VOID, 220,
StoryType.MECHANICAL, 180
);
searingPlate = new MobMat(
ItemGroups.MECHANISMS,
ThemeType.themedSlimefunItemStack(
"CRY_MOB_PLATE_1",
new ItemStack(Material.CRIMSON_PRESSURE_PLATE),
ThemeType.MECHANISM,
"Searing Plate",
"A plate that is magically super-heated.",
"Anything standing on this plate gets",
"damaged.",
"",
ThemeType.CLICK_INFO.getColor() + "Damage: " + ThemeType.PASSIVE.getColor() + "1",
ThemeType.CLICK_INFO.getColor() + "Player Drops: " + ThemeType.PASSIVE.getColor() + "No"
),
DummyLiquefactionBasinCrafting.TYPE,
searingPlateRecipe.getDisplayRecipe(),
1,
false
);

// Doomed Plate
RecipeItem doomedPlateRecipe = new RecipeItem(
searingPlate.getItem(),
StoryType.ALCHEMICAL, 240,
StoryType.VOID, 440,
StoryType.MECHANICAL, 360
);
doomedPlate = new MobMat(
ItemGroups.MECHANISMS,
ThemeType.themedSlimefunItemStack(
"CRY_MOB_PLATE_2",
new ItemStack(Material.WARPED_PRESSURE_PLATE),
ThemeType.MECHANISM,
"Doomed Plate",
"A plate that is magically super-heated.",
"Anything standing on this plate gets",
"damaged.",
"",
ThemeType.CLICK_INFO.getColor() + "Damage: " + ThemeType.PASSIVE.getColor() + "1",
ThemeType.CLICK_INFO.getColor() + "Player Drops: " + ThemeType.PASSIVE.getColor() + "Yes"
),
DummyLiquefactionBasinCrafting.TYPE,
doomedPlateRecipe.getDisplayRecipe(),
1,
true
);

// Doomed Plate
RecipeItem evisceratingPlateRecipe = new RecipeItem(
doomedPlate.getItem(),
StoryType.ALCHEMICAL, 480,
StoryType.VOID, 880,
StoryType.MECHANICAL, 720
);
evisceratingPlate = new MobMat(
ItemGroups.MECHANISMS,
ThemeType.themedSlimefunItemStack(
"CRY_MOB_PLATE_3",
new ItemStack(Material.POLISHED_BLACKSTONE_PRESSURE_PLATE),
ThemeType.MECHANISM,
"Eviscerating Plate",
"A plate that is magically super-heated.",
"Anything standing on this plate gets",
"damaged.",
"",
ThemeType.CLICK_INFO.getColor() + "Damage: " + ThemeType.PASSIVE.getColor() + "2",
ThemeType.CLICK_INFO.getColor() + "Player Drops: " + ThemeType.PASSIVE.getColor() + "Yes"
),
DummyLiquefactionBasinCrafting.TYPE,
evisceratingPlateRecipe.getDisplayRecipe(),
2,
true
);

// Slimefun Registry
chroniclerPanel1.register(plugin);
chroniclerPanel2.register(plugin);
Expand All @@ -492,6 +669,11 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
dispersionLamp.register(plugin);
inversionVacuum.register(plugin);
antipodalVacuum.register(plugin);
cursedEarth.register(plugin);
dreadfulDirt.register(plugin);
searingPlate.register(plugin);
doomedPlate.register(plugin);
evisceratingPlate.register(plugin);

// Liquefaction Recipes
LiquefactionBasinCache.addCraftingRecipe(chroniclerPanel3, chroniclerT3Recipe);
Expand All @@ -510,6 +692,11 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun

LiquefactionBasinCache.addCraftingRecipe(inversionVacuum, inversionVacuumRecipe);
LiquefactionBasinCache.addCraftingRecipe(antipodalVacuum, antipodalVacuumRecipe);
}

LiquefactionBasinCache.addCraftingRecipe(dreadfulDirt, dreadfulDirtRecipe);

LiquefactionBasinCache.addCraftingRecipe(searingPlate, searingPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(doomedPlate, doomedPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(evisceratingPlate, evisceratingPlateRecipe);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets;

import io.github.sefiraat.crystamaehistoria.utils.ParticleUtils;
import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
import lombok.Getter;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.Slimefun.Objects.handlers.BlockTicker;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Horse;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster;
import org.bukkit.inventory.ItemStack;

import javax.annotation.ParametersAreNonnullByDefault;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;

public class CursedEarth extends SlimefunItem {



@Getter
private final double ticksToSpawn;
@Getter
private final int lightLevel;
@Getter
private final List<EntityType> monsters;
@Getter
private final Color color;
@Getter
private int currentTick = 0;

@ParametersAreNonnullByDefault
public CursedEarth(ItemGroup category,
SlimefunItemStack item,
RecipeType recipeType,
ItemStack[] recipe,
double ticksToSpawn,
int lightLevel,
List<EntityType> spawns,
Color color
) {
super(category, item, recipeType, recipe);
this.ticksToSpawn = ticksToSpawn;
this.lightLevel = lightLevel;
this.monsters = spawns;
this.color = color;
this.addItemHandler(
new BlockTicker() {
@Override
public boolean isSynchronized() {
return true;
}

@Override
public void tick(Block block, SlimefunItem slimefunItem, Config config) {
final Location location = block.getLocation().add(0.5, 1.5, 0.5);
final Block blockA = block.getRelative(BlockFace.UP);
final Block blockB = blockA.getRelative(BlockFace.UP);
if (currentTick == ticksToSpawn) {
if (blockA.getLightLevel() <= lightLevel
&& (blockA.getType().isAir() && blockB.getType().isAir())
&& location.getWorld().getNearbyEntities(location, 0.5, 0.5, 0.5).isEmpty()
&& location.getWorld().getNearbyEntities(location, 4, 4, 4, LivingEntity.class::isInstance).size() < 10
) {
location.getWorld().spawnEntity(
location,
monsters.get(ThreadLocalRandom.current().nextInt(monsters.size())),
true
);
}
currentTick = 0;
} else {
currentTick++;
}
Particle.DustOptions dustOptions = new Particle.DustOptions(color, 1);
ParticleUtils.displayParticleEffect(location, 1, 3, dustOptions);
}
}
);
}
}
Loading

0 comments on commit 31fa3f4

Please sign in to comment.