use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class BlockValueGUI method addContent.
@Override
public void addContent(Inventory inventory) {
inventory.clear();
InventoryUtils.fillInventory(inventory, getNoItemGUI().background);
inventory.setItem(inventory.getSize() - 3, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().nextPage));
inventory.setItem(inventory.getSize() - 7, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().previousPage));
if (guiType == BlockValueType.BLOCK) {
IridiumSkyblock.getInstance().getBlockValues().blockValues.entrySet().stream().filter(valuableBlockEntry -> (page == 1 ? valuableBlockEntry.getValue().page <= 1 : valuableBlockEntry.getValue().page == page)).forEachOrdered(valuableBlock -> {
XMaterial material = valuableBlock.getKey();
ValuableBlock blockInfo = valuableBlock.getValue();
ItemStack blockItem = ItemStackUtils.makeItem(material, 1, StringUtils.color(blockInfo.name), getColoredValueLore(blockInfo.value));
inventory.setItem(blockInfo.slot, blockItem);
});
} else if (guiType == BlockValueType.SPAWNER) {
IridiumSkyblock.getInstance().getBlockValues().spawnerValues.entrySet().stream().filter(valuableSpawnerEntry -> (page == 1 ? valuableSpawnerEntry.getValue().page <= 1 : valuableSpawnerEntry.getValue().page == page)).forEachOrdered(valuableSpawner -> {
ValuableBlock spawnerInfo = valuableSpawner.getValue();
ItemStack spawnerItem = ItemStackUtils.makeItem(XMaterial.SPAWNER, 1, StringUtils.color(spawnerInfo.name), getColoredValueLore(spawnerInfo.value));
inventory.setItem(spawnerInfo.slot, spawnerItem);
});
}
if (IridiumSkyblock.getInstance().getConfiguration().backButtons && getPreviousInventory() != null) {
inventory.setItem(inventory.getSize() + IridiumSkyblock.getInstance().getInventories().backButton.slot, ItemStackUtils.makeItem(IridiumSkyblock.getInstance().getInventories().backButton));
}
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class ItemCraftListener method monitorItemCraft.
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void monitorItemCraft(CraftItemEvent event) {
if (!IridiumSkyblockAPI.getInstance().isIslandWorld(event.getWhoClicked().getWorld()))
return;
int amount = event.isShiftClick() ? Arrays.stream(event.getInventory().getMatrix()).filter(Objects::nonNull).map(ItemStack::getAmount).sorted().findFirst().orElse(1) * event.getRecipe().getResult().getAmount() : event.getRecipe().getResult().getAmount();
Player player = (Player) event.getWhoClicked();
User user = IridiumSkyblock.getInstance().getUserManager().getUser(player);
Optional<Island> island = user.getIsland();
XMaterial material = XMaterial.matchXMaterial(event.getRecipe().getResult().getType());
island.ifPresent(value -> IridiumSkyblock.getInstance().getMissionManager().handleMissionUpdates(value, "CRAFT", material.name(), amount));
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class OceanGenerator method generateWater.
public void generateWater(World world, int x, int z) {
SimplexOctaveGenerator generator = new SimplexOctaveGenerator(new Random(world.getSeed()), 8);
generator.setScale(0.005D);
XMaterial bottomMaterial = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.oceanFloorBottomMaterial;
XMaterial topMaterial = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.oceanFloorTopMaterial;
int waterHeight = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.waterHeight;
int maxOceanFloorLevel = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.maxOceanFloorLevel;
int minOceanFloorLevel = IridiumSkyblock.getInstance().getConfiguration().generatorSettings.minOceanFloorLevel;
int currentFloorHeight = (int) ((generator.noise(x, z, 1.5D, 0.5D, true) + 1) * (maxOceanFloorLevel - minOceanFloorLevel) + minOceanFloorLevel);
int minHeightWorld = LocationUtils.getMinHeight(world);
// Generate layer of bedrock
if (world.getBlockAt(x, minHeightWorld, z).getType() != XMaterial.BEDROCK.parseMaterial()) {
if (world.getBlockAt(x, minHeightWorld, z).getState() instanceof InventoryHolder) {
((InventoryHolder) world.getBlockAt(x, minHeightWorld, z).getState()).getInventory().clear();
}
world.getBlockAt(x, minHeightWorld, z).setType(Material.BEDROCK, false);
}
// Generate gravel layer
for (int y = minHeightWorld + 1; y < currentFloorHeight; y++) {
Block block = world.getBlockAt(x, y, z);
if (block.getType() != bottomMaterial.parseMaterial() && bottomMaterial.parseMaterial() != null) {
if (block.getState() instanceof InventoryHolder) {
((InventoryHolder) block.getState()).getInventory().clear();
}
block.setType(bottomMaterial.parseMaterial(), false);
}
}
// Generate sand on top of gravel
if (world.getBlockAt(x, currentFloorHeight, z).getType() != topMaterial.parseMaterial() && topMaterial.parseMaterial() != null) {
if (world.getBlockAt(x, currentFloorHeight, z).getState() instanceof InventoryHolder) {
((InventoryHolder) world.getBlockAt(x, currentFloorHeight, z).getState()).getInventory().clear();
}
world.getBlockAt(x, currentFloorHeight, z).setType(topMaterial.parseMaterial(), false);
}
// Generate water or lava on top of the floor
XMaterial oceanMaterial = world.getEnvironment() == Environment.NETHER ? XMaterial.LAVA : XMaterial.WATER;
for (int y = currentFloorHeight + 1; y <= waterHeight; y++) {
Block block = world.getBlockAt(x, y, z);
if (block.getType() != oceanMaterial.parseMaterial() && oceanMaterial.parseMaterial() != null) {
if (block.getState() instanceof InventoryHolder) {
((InventoryHolder) block.getState()).getInventory().clear();
}
block.setType(oceanMaterial.parseMaterial(), false);
}
}
// Replace everything else with air
for (int y = waterHeight + 1; y < world.getMaxHeight(); y++) {
Block block = world.getBlockAt(x, y, z);
if (block.getType() != Material.AIR) {
if (block.getState() instanceof InventoryHolder) {
((InventoryHolder) block.getState()).getInventory().clear();
}
block.setType(Material.AIR, false);
}
}
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class Schematic method paste.
@Override
public void paste(File file, Location location, Boolean ignoreAirBlock, CompletableFuture<Void> completableFuture) {
SchematicData schematicData;
try {
schematicData = schematicCache.getOrDefault(file, SchematicData.loadSchematic(file));
schematicCache.put(file, schematicData);
} catch (IOException e) {
e.printStackTrace();
return;
}
short length = schematicData.length;
short width = schematicData.width;
short height = schematicData.height;
// Centers the schematic
location.subtract(width / 2.00, height / 2.00, length / 2.00);
for (int x = 0; x < width; ++x) {
for (int y = 0; y < height; ++y) {
for (int z = 0; z < length; ++z) {
int index = y * width * length + z * width + x;
Block block = new Location(location.getWorld(), x + location.getX(), y + location.getY(), z + location.getZ()).getBlock();
for (String blockData : schematicData.palette.keySet()) {
int i = SchematicData.getChildTag(schematicData.palette, blockData, IntTag.class).getValue();
if (schematicData.blockdata[index] == i) {
block.setBlockData(Bukkit.createBlockData(blockData), false);
}
}
}
}
}
for (Tag tag : schematicData.tileEntities) {
if (!(tag instanceof CompoundTag))
continue;
CompoundTag t = (CompoundTag) tag;
Map<String, Tag> tags = t.getValue();
int[] pos = SchematicData.getChildTag(tags, "Pos", IntArrayTag.class).getValue();
int x = pos[0];
int y = pos[1];
int z = pos[2];
Block block = new Location(location.getWorld(), x + location.getX(), y + location.getY(), z + location.getZ()).getBlock();
String id = SchematicData.getChildTag(tags, "Id", StringTag.class).getValue().toLowerCase().replace("minecraft:", "");
if (id.equalsIgnoreCase("chest")) {
List<Tag> items = SchematicData.getChildTag(tags, "Items", ListTag.class).getValue();
if (block.getState() instanceof Chest) {
Chest chest = (Chest) block.getState();
for (Tag item : items) {
if (!(item instanceof CompoundTag))
continue;
Map<String, Tag> itemtag = ((CompoundTag) item).getValue();
byte slot = SchematicData.getChildTag(itemtag, "Slot", ByteTag.class).getValue();
String name = (SchematicData.getChildTag(itemtag, "id", StringTag.class).getValue()).toLowerCase().replace("minecraft:", "").replace("reeds", "sugar_cane");
Byte amount = SchematicData.getChildTag(itemtag, "Count", ByteTag.class).getValue();
Optional<XMaterial> optionalXMaterial = XMaterial.matchXMaterial(name.toUpperCase());
if (optionalXMaterial.isPresent()) {
XMaterial material = optionalXMaterial.get();
ItemStack itemStack = material.parseItem();
if (itemStack != null) {
itemStack.setAmount(amount);
chest.getBlockInventory().setItem(slot, itemStack);
}
}
}
}
}
}
completableFuture.complete(null);
}
use of com.iridium.iridiumcore.dependencies.xseries.XMaterial in project IridiumSkyblock by Iridium-Development.
the class IslandManager method recalculateIsland.
/**
* Recalculates the island async with specified ChunkSnapshots.
*
* @param island The specified Island
* @param chunks The Island's Chunks
*/
private void recalculateIsland(@NotNull Island island, @NotNull List<Chunk> chunks) {
chunks.stream().map(chunk -> chunk.getChunkSnapshot(true, false, false)).forEach(chunk -> {
World world = Bukkit.getWorld(chunk.getWorldName());
int maxHeight = world == null ? 255 : world.getMaxHeight() - 1;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
if (island.isInIsland(x + (chunk.getX() * 16), z + (chunk.getZ() * 16))) {
final int maxy = Math.min(maxHeight, chunk.getHighestBlockYAt(x, z));
for (int y = LocationUtils.getMinHeight(world); y <= maxy; y++) {
XMaterial material = XMaterial.matchXMaterial(chunk.getBlockType(x, y, z));
if (material.equals(XMaterial.AIR))
continue;
IslandBlocks islandBlock = IridiumSkyblock.getInstance().getIslandManager().getIslandBlock(island, material);
islandBlock.setAmount(islandBlock.getAmount() + 1);
}
}
}
}
});
if (!Bukkit.isPrimaryThread()) {
Bukkit.getScheduler().runTask(IridiumSkyblock.getInstance(), () -> getAllTileInIsland(island, chunks));
} else {
getAllTileInIsland(island, chunks);
}
}
Aggregations