Skip to content

Commit

Permalink
Merge pull request #42 from GallowsDove/master
Browse files Browse the repository at this point in the history
Small changes, item band bug fix
  • Loading branch information
ProfElements committed Mar 9, 2021
2 parents b3ef792 + 9a267a4 commit 167758c
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 112 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
A set of item and machines that I made to make things easier for me and just for fun.
Most of these could possibly be overpowered or heavily underpowered.

### [Download](https://thebusybiscuit.github.io/builds/ProfElements/DynaTech/master/)
[![Build Status](https://thebusybiscuit.github.io/builds/ProfElements/DynaTech/master/badge.svg)](https://thebusybiscuit.github.io/builds/ProfElements/DynaTech/master)

## Machines
- **Auto-Kitchen** - If you have ExoticGarden installed, this machine will become available. It automatically crafts any Kitchen recipe inserted into it.
- **Growth Chambers** - Automatically grow some plants. We have multiple variants for all your needs. Supports Exotic Garden saplings, plants, and bushes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -30,7 +32,7 @@ public PicnicBasket(int size, Category category, SlimefunItemStack item, RecipeT
}

@Override
public boolean isItemAllowed(ItemStack item, SlimefunItem itemAsSlimefunItem) {
public boolean isItemAllowed(@Nonnull ItemStack item, @Nullable SlimefunItem itemAsSlimefunItem) {
if (DynaTech.isExoticGardenInstalled()) {
if (itemAsSlimefunItem instanceof CustomFood) {
return true;
Expand Down Expand Up @@ -68,5 +70,4 @@ private List<String> ToStringList(List<Material> mats) {

return materials;
}

}
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
package me.profelements.dynatech.items.electric;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;

import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.profelements.dynatech.items.electric.abstracts.AMachine;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
import me.profelements.dynatech.items.electric.abstracts.AMachine;
import java.util.*;

public class AntigravityBubble extends AMachine {

Expand Down Expand Up @@ -98,7 +92,7 @@ protected void doFlightIfAvailable(Block block) {
}
plrsToRemove.clear();
}
};
}

@Override
public boolean isGraphical() {
Expand All @@ -110,7 +104,6 @@ public String getMachineIdentifier() {
return "ANTIGRAVITY_BUBBLE";
}


@Override
public List<int[]> getBorders() {
List<int[]> borders = new ArrayList<>();
Expand All @@ -125,6 +118,7 @@ public List<int[]> getBorders() {
public int[] getInputSlots() {
return new int[] {13};
}

@Override
public int[] getOutputSlots() {
return new int[] {13};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,11 @@ public MachineRecipe findNextRecipe(BlockMenu inv) {
if (sfBand instanceof ItemBand) {
ItemBand band = (ItemBand) sfBand;
ItemStack result = band.applyToItem(target).clone();

if(result == null) {
return null;
}

inv.consumeItem(getInputSlots()[0]);
inv.consumeItem(getInputSlots()[1]);

MachineRecipe recipe = new MachineRecipe(30, new ItemStack[] {target, itemBand}, new ItemStack[] {result});

return recipe;
return new MachineRecipe(30, new ItemStack[] {target, itemBand}, new ItemStack[] {result});
}

}
Expand All @@ -51,10 +45,6 @@ public MachineRecipe findNextRecipe(BlockMenu inv) {
SlimefunItem sfItem = SlimefunItem.getByID(id);
ItemStack result = ItemBand.removeFromItem(target).clone();

if(result == null) {
return null;
}

inv.consumeItem(getInputSlots()[0]);

return new MachineRecipe(60, new ItemStack[] {target}, new ItemStack[] {result, sfItem.getItem()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import me.profelements.dynatech.DynaTech;
import me.profelements.dynatech.items.electric.abstracts.AMachine;

import javax.annotation.Nonnull;

public class BarbedWire extends AMachine {

public BarbedWire(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
Expand All @@ -36,7 +38,7 @@ public void tick(Block b) {

}

public void sendEntitiesFlying(Location loc, World w) {
public void sendEntitiesFlying(@Nonnull Location loc, @Nonnull World w) {
List<Entity> shotEntities = new ArrayList<>();
int waitTime = 0;
for (Entity e : w.getNearbyEntities(loc, 9, 9, 9)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import io.github.thebusybiscuit.slimefun4.api.items.ItemSetting;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactive;
import io.github.thebusybiscuit.slimefun4.core.attributes.Radioactivity;
import io.github.thebusybiscuit.slimefun4.utils.ChestMenuUtils;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void tick(Block b) {

if (item != null && item.getType() == Material.POTION && item.hasItemMeta()) {
PotionMeta potionMeta = (PotionMeta) item.getItemMeta();
if (potionMeta.getBasePotionData() != null) {
if (potionMeta != null) {
PotionData pd = potionMeta.getBasePotionData();
for (Player p : b.getWorld().getPlayers()) {
double distance = b.getLocation().distance(p.getLocation());
Expand Down Expand Up @@ -115,6 +115,4 @@ public int getProgressBarSlot() {
return 4;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

public class SeedPlucker extends AMachine {

private final ItemSetting<Boolean> exoticGardenIntegration = new ItemSetting<Boolean>("exotic-garden-integration", true);
private final ItemSetting<Boolean> exoticGardenIntegration = new ItemSetting<>("exotic-garden-integration", true);

public SeedPlucker(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
super(category, item, recipeType, recipe);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public List<ItemStack> getDisplayRecipes() {
return items;
}


@Override
public String getMachineIdentifier() {
return "WEATHER_CONTROLLER";
Expand Down Expand Up @@ -118,6 +117,5 @@ public ItemStack getProgressBar() {
public int getProgressBarSlot() {
return 4;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
import io.github.thebusybiscuit.slimefun4.utils.SlimefunUtils;
import io.github.thebusybiscuit.slimefun4.utils.itemstack.ItemStackWrapper;
import me.mrCookieSlime.CSCoreLibPlugin.Configuration.Config;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu;
import me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ClickAction;
import me.mrCookieSlime.Slimefun.Lists.RecipeType;
import me.mrCookieSlime.Slimefun.Objects.Category;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.SlimefunItem;
Expand All @@ -29,7 +27,6 @@
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;

import javax.annotation.Nonnull;
Expand Down Expand Up @@ -115,11 +112,9 @@ public int[] getSlotsAccessedByItemTransport(DirtyChestMenu menu, ItemTransportF
});
}

public void blockExtras(Block b) {
}
public void blockExtras(Block b) { }

public void newMachineInstance(BlockMenu menu, Block b) {
}
public void newMachineInstance(BlockMenu menu, Block b) { }

@ParametersAreNonnullByDefault
public AMachine(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe, ItemStack recipeOutput) {
Expand Down Expand Up @@ -312,6 +307,7 @@ public String getInventoryTitle() {

public abstract String getMachineIdentifier();

@Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.CONSUMER;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public int[] getSlotsAccessedByItemTransport(ItemTransportFlow flow) {
}

public void newMachineInstance(BlockMenu menu, Block b) {
};
}

protected void constructMenu(BlockMenuPreset preset) {
for (int i : getBorders().get(0)) {
Expand Down Expand Up @@ -146,7 +146,7 @@ public boolean onClick(Player p, int slot, ItemStack cursor, ClickAction action)

@Override
public boolean onClick(InventoryClickEvent e, Player p, int slot, ItemStack cursor, ClickAction action) {
return cursor == null || cursor.getType() == null || cursor.getType() == Material.AIR;
return cursor == null || cursor.getType() == Material.AIR;
}

});
Expand All @@ -167,7 +167,7 @@ public boolean isProcessing(Block b) {
}

@Override
public int getGeneratedOutput(Location l, Config data) {
public int getGeneratedOutput(Location l, @Nonnull Config data) {
BlockMenu inv = BlockStorage.getInventory(l.getBlock());

if (isProcessing(l.getBlock())) {
Expand Down Expand Up @@ -242,7 +242,7 @@ public MachineFuel findRecipe(BlockMenu menu, Map<Integer, Integer> found) {
return null;
}

protected void registerDefaultFuelTypes() {};
protected void registerDefaultFuelTypes() {}

public void registerFuel(@Nonnull MachineFuel fuel) {
Validate.notNull(fuel, "Machine fuel cannot be null.");
Expand All @@ -254,6 +254,7 @@ public Set<MachineFuel> getFuelTypes() {
return fuelTypes;
}

@Nonnull
@Override
public List<ItemStack> getDisplayRecipes() {
List<ItemStack> list = new ArrayList<>();
Expand All @@ -280,6 +281,7 @@ public String getInventoryTitle() {

public abstract String getMachineIdentifier();

@Nonnull
@Override
public EnergyNetComponentType getEnergyComponentType() {
return EnergyNetComponentType.GENERATOR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import me.profelements.dynatech.DynaTech;
import me.profelements.dynatech.items.electric.abstracts.AMachineGenerator;

import javax.annotation.Nonnull;

public class CulinaryGenerator extends AMachineGenerator {

private ItemSetting<Boolean> exoticGardenIntegration = new ItemSetting<Boolean>("exotic-garden-integration", true);
Expand Down Expand Up @@ -97,6 +99,7 @@ public String getMachineIdentifier() {
return "CULINARY_GENERATOR";
}

@Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.IRON_SHOVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import me.profelements.dynatech.DynaTechItems;
import me.profelements.dynatech.items.electric.abstracts.AMachineGenerator;

import javax.annotation.Nonnull;

public class StardustReactor extends AMachineGenerator {

public StardustReactor(Category category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
Expand All @@ -22,6 +24,7 @@ protected void registerDefaultFuelTypes() {
registerFuel(new MachineFuel(32, DynaTechItems.STAR_DUST));
}

@Nonnull
@Override
public ItemStack getProgressBar() {
return new ItemStack(Material.IRON_CHESTPLATE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@
import org.bukkit.generator.ChunkGenerator;

import javax.annotation.Nonnull;
import javax.annotation.ParametersAreNonnullByDefault;

public class DimensionalHomeDimension extends ChunkGenerator {

@Nonnull
@Override
public ChunkData generateChunkData(@Nonnull World world, @Nonnull Random random, int chunkx, int chunkz, @Nonnull BiomeGrid biomeGrid) {
@ParametersAreNonnullByDefault
public ChunkData generateChunkData(World world, Random random, int chunkx, int chunkz, BiomeGrid biomeGrid) {
ChunkData chunkData = createChunkData(world);

chunkData.setRegion(0, 59, 0, 16, 60, 16, Material.BEDROCK);
Expand Down
17 changes: 8 additions & 9 deletions src/main/java/me/profelements/dynatech/items/misc/ItemBand.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import me.mrCookieSlime.Slimefun.cscorelib2.data.PersistentDataAPI;
import me.profelements.dynatech.DynaTech;

import javax.annotation.Nullable;

public class ItemBand extends SlimefunItem {

public static final NamespacedKey KEY = new NamespacedKey(DynaTech.getInstance(), "item_band");
Expand All @@ -40,7 +42,8 @@ public static boolean containsItemBand(ItemStack item) {
}
}

public ItemStack applyToItem(ItemStack item) {
@Nullable
public ItemStack applyToItem(@Nullable ItemStack item) {
if (item != null && item.getType() != Material.AIR) {


Expand All @@ -57,26 +60,22 @@ public ItemStack applyToItem(ItemStack item) {
return null;
}

public static ItemStack removeFromItem( ItemStack item) {
@Nullable
public static ItemStack removeFromItem(@Nullable ItemStack item) {
if (item != null && item.getType() != Material.AIR) {
ItemMeta im = item.getItemMeta();
List<String> lore = im.getLore();

im.getPersistentDataContainer().remove(KEY);


for (int line = 0; line < lore.size(); line++ ) {
if (lore.get(line).contains(ChatColor.WHITE + "Bandaid: ")) {
lore.remove(line);
}
}
lore.removeIf(line -> line.contains(ChatColor.WHITE + "Bandaid: "));

im.setLore(lore);
item.setItemMeta(im);

return item;
}
return null;
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public ItemStack getItem() {
return STARDUST_METEOR.clone();
}

@Nonnull
@Override
public String getName() {
return "Stardust Meteor";
Expand Down
Loading

0 comments on commit 167758c

Please sign in to comment.