Skip to content

Commit

Permalink
Merge pull request #16 from Sefiraat/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Sefiraat authored Nov 8, 2021
2 parents 23118b0 + 7e41116 commit 461d6f9
Show file tree
Hide file tree
Showing 31 changed files with 689 additions and 232 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import io.github.sefiraat.crystamaehistoria.slimefun.Materials;
import io.github.sefiraat.crystamaehistoria.slimefun.Mechanisms;
import io.github.sefiraat.crystamaehistoria.slimefun.Tools;
import io.github.sefiraat.crystamaehistoria.stories.StoriedBlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.BlockDefinition;
import io.github.sefiraat.crystamaehistoria.stories.StoriesManager;
import io.github.sefiraat.crystamaehistoria.utils.CrystaTag;
import io.github.sefiraat.crystamaehistoria.utils.PlayerStatUtils;
Expand Down Expand Up @@ -182,7 +182,7 @@ private void setupBstats() {

AdvancedPie storiesChronicled = new AdvancedPie("stories_chronicled", () -> {
Map<String, Integer> values = new HashMap<>();
for (StoriedBlockDefinition definition : CrystamaeHistoria.getStoriesManager().getStoriedBlockDefinitionMap().values()) {
for (BlockDefinition definition : CrystamaeHistoria.getStoriesManager().getBlockDefinitionMap().values()) {
int timesChronicled = 0;
for (String string : CrystamaeHistoria.getConfigManager().getPlayerStats().getKeys(false)) {
UUID uuid = UUID.fromString(string);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.realisationaltar.RealisationAltarCache;
import io.github.sefiraat.crystamaehistoria.stories.Story;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryRarity;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryShardProfile;
import io.github.thebusybiscuit.slimefun4.libraries.dough.blocks.BlockPosition;
import io.github.thebusybiscuit.slimefun4.libraries.dough.collections.Pair;
import org.bukkit.Material;
Expand All @@ -28,16 +27,16 @@ public void onBreakCrystal(BlockBreakEvent event) {
}

private void handleCrystal(Block block) {
BlockPosition blockPosition = new BlockPosition(block);
final BlockPosition blockPosition = new BlockPosition(block);
for (RealisationAltarCache cache : RealisationAltar.getCaches().values()) {
Pair<StoryRarity, String> pair = cache.getCrystalStoryMap().get(blockPosition);
final Pair<StoryRarity, String> pair = cache.getCrystalStoryMap().remove(blockPosition);
if (pair != null) {
StoryRarity rarity = pair.getFirstValue();
String id = pair.getSecondValue();
Story story = CrystamaeHistoria.getStoriesManager().getStory(id, rarity);
StoryShardProfile shardProfile = story.getStoryShardProfile();
shardProfile.dropShards(rarity, block.getLocation());
final StoryRarity rarity = pair.getFirstValue();
final String id = pair.getSecondValue();
final Story story = CrystamaeHistoria.getStoriesManager().getStory(id, rarity);
story.getStoryShardProfile().dropShards(rarity, block.getLocation());
}
cache.saveMap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public ListenerManager() {
addListener(new CrystalBreakListener());
addListener(new BlockRemovalListener());
addListener(new MaintenanceListener());
addListener(new RefractingLensListener());
}

private void addListener(Listener listener) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package io.github.sefiraat.crystamaehistoria.listeners;

import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.gadgets.ExpCollector;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasin;
import io.github.sefiraat.crystamaehistoria.slimefun.mechanisms.liquefactionbasin.LiquefactionBasinCache;
import io.github.sefiraat.crystamaehistoria.slimefun.tools.RefactingLens;
import io.github.sefiraat.crystamaehistoria.stories.definition.StoryType;
import io.github.sefiraat.crystamaehistoria.utils.theme.ThemeType;
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
import me.mrCookieSlime.Slimefun.api.BlockStorage;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.TextComponent.Builder;
import net.kyori.adventure.text.format.TextDecoration;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.Map;

public class RefractingLensListener implements Listener {

@EventHandler
public void onInteract(PlayerInteractEvent e) {
final Player player = e.getPlayer();
final SlimefunItem slimefunItem = SlimefunItem.getByItem(player.getInventory().getItemInMainHand());
final Block block = e.getClickedBlock();
if (block != null
&& e.getAction() == Action.RIGHT_CLICK_BLOCK
&& slimefunItem instanceof RefactingLens
) {
e.setCancelled(true);
SlimefunItem item = BlockStorage.check(block);
if (item instanceof LiquefactionBasin) {
liquefactionBasin(player, item, block);
} else if (item instanceof ExpCollector) {
expCollector(player, item, block);
}
}
}

private void liquefactionBasin(Player player, SlimefunItem blockItem, Block clickedBlock) {
final LiquefactionBasin basin = (LiquefactionBasin) blockItem;
final LiquefactionBasinCache cache = basin.getCacheMap().get(clickedBlock.getLocation());
final Builder component = Component.text();
boolean first = true;
for (Map.Entry<StoryType, Integer> entry : cache.getContentMap().entrySet()) {
if (first) {
first = false;
} else {
component.append(
Component.text()
.content(" | ")
.color(ThemeType.PASSIVE.getComponentColor()));
}
component.append(
Component.text()
.content(String.valueOf(entry.getValue()))
.color(ThemeType.getByType(entry.getKey()).getComponentColor())
);
}
player.sendActionBar(component.build());
}

private void expCollector(Player player, SlimefunItem blockItem, Block clickedBlock) {
final ExpCollector collector = (ExpCollector) blockItem;
final int volume = collector.getVolumeMap().get(clickedBlock.getLocation());
final TextComponent component = Component.text()
.append(Component.text("Exp Stored: ")
.color(ThemeType.CLICK_INFO.getComponentColor())
.decoration(TextDecoration.BOLD, true))
.append(Component.text(String.valueOf(volume))
.color(ThemeType.PASSIVE.getComponentColor()))
.build();
player.sendActionBar(component);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import javax.annotation.ParametersAreNonnullByDefault;

public class FloatingHeadAnimation extends BukkitRunnable {
public static final double Y_VARIATION = 0.2;
public static final double Y_DEVIANCY = 0.2;
public static final long SPEED = 1;

private final ArmorStand armorStand;
Expand All @@ -24,12 +24,12 @@ public FloatingHeadAnimation(ArmorStand armorStand) {
public void run() {
if (directionUp) {
ArmourStandUtils.panelAnimationStep(armorStand, true);
if (armorStand.getLocation().getY() >= (baseY + Y_VARIATION)) {
if (armorStand.getLocation().getY() >= (baseY + Y_DEVIANCY)) {
directionUp = false;
}
} else {
ArmourStandUtils.panelAnimationStep(armorStand, false);
if (armorStand.getLocation().getY() <= (baseY - Y_VARIATION)) {
if (armorStand.getLocation().getY() <= (baseY - Y_DEVIANCY)) {
directionUp = true;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
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.ExpCollector;
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;
Expand Down Expand Up @@ -48,6 +49,10 @@ public class Gadgets {
private static MobMat doomedPlate;
@Getter
private static MobMat evisceratingPlate;
@Getter
private static ExpCollector basicExpCollector;
@Getter
private static ExpCollector infusedExpCollector;

public static void setup() {

Expand Down Expand Up @@ -285,7 +290,7 @@ public static void setup() {
true
);

// Doomed Plate
// Eviscerating Plate
RecipeItem evisceratingPlateRecipe = new RecipeItem(
doomedPlate.getItem(),
StoryType.ALCHEMICAL, 480,
Expand All @@ -312,6 +317,59 @@ public static void setup() {
true
);

// Basic Exp Collector Plate
RecipeItem basicExpCollectorRecipe = new RecipeItem(
SlimefunItems.EXP_COLLECTOR,
StoryType.MECHANICAL, 150,
StoryType.HUMAN, 200,
StoryType.ANIMAL, 250
);
basicExpCollector = new ExpCollector(
ItemGroups.GADGETS,
ThemeType.themedSlimefunItemStack(
"CRY_EXP_COLLECTOR_1",
new ItemStack(Material.LIGHTNING_ROD),
ThemeType.MECHANISM,
"Basic Exp Collector",
"Infusing the Exp Collector with",
"magic now allows it to work",
"without electricity and flasks.",
"",
ThemeType.CLICK_INFO.getColor() + "Range: " + ThemeType.PASSIVE.getColor() + "4",
ThemeType.CLICK_INFO.getColor() + "Capacity: " + ThemeType.PASSIVE.getColor() + "2500"
),
DummyLiquefactionBasinCrafting.TYPE,
basicExpCollectorRecipe.getDisplayRecipe(),
2500,
4
);

// Infused Exp Collector Plate
RecipeItem infusedExpCollectorRecipe = new RecipeItem(
basicExpCollector.getItem(),
StoryType.MECHANICAL, 740,
StoryType.HUMAN, 560,
StoryType.ANIMAL, 885
);
infusedExpCollector = new ExpCollector(
ItemGroups.GADGETS,
ThemeType.themedSlimefunItemStack(
"CRY_EXP_COLLECTOR_2",
new ItemStack(Material.LIGHTNING_ROD),
ThemeType.MECHANISM,
"Infused Exp Collector",
"Further infusion has made the",
"collector even more powerful.",
"",
ThemeType.CLICK_INFO.getColor() + "Range: " + ThemeType.PASSIVE.getColor() + "8",
ThemeType.CLICK_INFO.getColor() + "Capacity: " + ThemeType.PASSIVE.getColor() + "10000"
),
DummyLiquefactionBasinCrafting.TYPE,
infusedExpCollectorRecipe.getDisplayRecipe(),
10000,
8
);

// Slimefun Registry
abstractionLamp.register(plugin);
dispersionLamp.register(plugin);
Expand All @@ -322,6 +380,8 @@ public static void setup() {
searingPlate.register(plugin);
doomedPlate.register(plugin);
evisceratingPlate.register(plugin);
basicExpCollector.register(plugin);
infusedExpCollector.register(plugin);

// Liquefaction Recipes
LiquefactionBasinCache.addCraftingRecipe(abstractionLamp, abstractionLampRecipe);
Expand All @@ -335,5 +395,8 @@ public static void setup() {
LiquefactionBasinCache.addCraftingRecipe(searingPlate, searingPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(doomedPlate, doomedPlateRecipe);
LiquefactionBasinCache.addCraftingRecipe(evisceratingPlate, evisceratingPlateRecipe);

LiquefactionBasinCache.addCraftingRecipe(basicExpCollector, basicExpCollectorRecipe);
LiquefactionBasinCache.addCraftingRecipe(infusedExpCollector, infusedExpCollectorRecipe);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public static void setup() {
Skulls.getByType(type).getPlayerHead(),
ThemeType.CRYSTAL,
theme.getColor() + TextUtils.toTitleCase(rarity.toString() + " " + type.toString()) + " Crystal",
"Magical Crystamae in it's physical form"
"Magical Crystamae in it's physical form",
"Higher tier blocks are more likely to",
"provide rarer Crystal types.",
"",
"Provides " + Crystal.getRarityValueMap().get(rarity) + " Crysta."
),
DummyRealisationAltar.TYPE,
new ItemStack[]{null, null, null, null, new ItemStack(Material.AMETHYST_CLUSTER), null, null, null, null},
Expand All @@ -106,8 +110,6 @@ public static void setup() {
}
}



// Amalgamate Dust Common
amalgamateDustCommon = new SlimefunItem(
ItemGroups.MATERIALS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ null, new ItemStack(Material.BOOK), null,
SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), SlimefunItems.REINFORCED_ALLOY_INGOT,
SlimefunItems.REINFORCED_ALLOY_INGOT, SlimefunItems.COMMON_TALISMAN, SlimefunItems.REINFORCED_ALLOY_INGOT
},
500
500,
Color.fromRGB(150, 150, 150)
);

// Liquefaction T2
Expand All @@ -300,7 +301,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
amalgamateDustRare, liquefactionBasin1.getItem(), amalgamateDustRare,
amalgamateDustRare, SlimefunItems.ENCHANTMENT_RUNE, amalgamateDustRare
},
1000
1000,
Color.fromRGB(195, 195, 150)
);

// Liquefaction T3
Expand All @@ -325,7 +327,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
),
DummyLiquefactionBasinCrafting.TYPE,
liquefactionT3Recipe.getDisplayRecipe(),
2500
2500,
Color.fromRGB(215, 200, 110)
);

// Liquefaction T4
Expand All @@ -350,7 +353,8 @@ SlimefunItems.REINFORCED_ALLOY_INGOT, new ItemStack(Material.CAULDRON), Slimefun
),
DummyLiquefactionBasinCrafting.TYPE,
liquefactionT4Recipe.getDisplayRecipe(),
5000
5000,
Color.fromRGB(240, 220, 26)
);

// Stave Configurator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,12 @@ null, new ItemStack(Material.STICK), null,
"This magical lens has glass that can",
"the lights of Crysta into it's",
"individual elements.",
ThemeType.CLICK_INFO.getColor() + "Right Click: " + ThemeType.PASSIVE.getColor() + "Shows the contents",
ThemeType.PASSIVE.getColor() + "of a Liquefaction Basin."
"",
"Right click on a Crystamae Block for",
"details if avilable.",
ThemeType.CLICK_INFO.getColor() + "Works with;",
ThemeType.PASSIVE.getColor() + "Liquefaction Basin",
ThemeType.PASSIVE.getColor() + "Exp Collector"
),
RecipeType.MAGIC_WORKBENCH,
new ItemStack[]{
Expand Down
Loading

0 comments on commit 461d6f9

Please sign in to comment.