summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2015-05-03 00:43:52 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2015-05-03 00:43:52 +0100
commit82febe33f0799f97fbc9f0426d893a5b64cfdd8d (patch)
tree53c84f1e9bc5b6fb205d866362dc92dc4056f17e
parent9ae044f48baa6afa4be5f3efafb64508ab1b1103 (diff)
downloadkinniutils-82febe33f0799f97fbc9f0426d893a5b64cfdd8d.tar.bz2
Initial bits for particle filter items with recipesHEADmaster
-rw-r--r--src/main/java/net/flarn/kinniutils/KinniUtils.java6
-rw-r--r--src/main/java/net/flarn/kinniutils/creative/CreativeTabKinniUtils.java19
-rw-r--r--src/main/java/net/flarn/kinniutils/init/FilterRecipes.java77
-rw-r--r--src/main/java/net/flarn/kinniutils/init/ModItems.java3
-rw-r--r--src/main/java/net/flarn/kinniutils/init/ModTiles.java13
-rw-r--r--src/main/java/net/flarn/kinniutils/item/BaseItem.java43
-rw-r--r--src/main/java/net/flarn/kinniutils/item/ItemParticleFilter.java101
-rw-r--r--src/main/java/net/flarn/kinniutils/recipe/ShapedFilterRecipe.java33
-rw-r--r--src/main/java/net/flarn/kinniutils/refs/Names.java4
-rw-r--r--src/main/java/net/flarn/kinniutils/refs/ParticleGroup.java15
-rw-r--r--src/main/java/net/flarn/kinniutils/refs/Textures.java8
-rw-r--r--src/main/resources/assets/kinniutils/textures/items/particleFilter.pngbin0 -> 233 bytes
12 files changed, 322 insertions, 0 deletions
diff --git a/src/main/java/net/flarn/kinniutils/KinniUtils.java b/src/main/java/net/flarn/kinniutils/KinniUtils.java
index 86c7faa..b6c8df5 100644
--- a/src/main/java/net/flarn/kinniutils/KinniUtils.java
+++ b/src/main/java/net/flarn/kinniutils/KinniUtils.java
@@ -5,11 +5,15 @@ import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
+import net.flarn.kinniutils.init.FilterRecipes;
import net.flarn.kinniutils.init.ModBlocks;
import net.flarn.kinniutils.init.ModItems;
+import net.flarn.kinniutils.init.ModTiles;
import net.flarn.kinniutils.proxy.IProxy;
import net.flarn.kinniutils.refs.Core;
+import java.util.logging.Filter;
+
@Mod(modid= Core.MOD_ID, name=Core.MOD_NAME, version=Core.MOD_VERSION)
public class KinniUtils {
@@ -26,11 +30,13 @@ public class KinniUtils {
proxy.registerParticleFilters();
ModBlocks.init();
ModItems.init();
+ ModTiles.init();
}
@Mod.EventHandler
public void init(FMLInitializationEvent envent) {
// Guis, TileEntity, recipes, etc. (general event handlers)
+ FilterRecipes.init();
}
@Mod.EventHandler
diff --git a/src/main/java/net/flarn/kinniutils/creative/CreativeTabKinniUtils.java b/src/main/java/net/flarn/kinniutils/creative/CreativeTabKinniUtils.java
new file mode 100644
index 0000000..474da02
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/creative/CreativeTabKinniUtils.java
@@ -0,0 +1,19 @@
+package net.flarn.kinniutils.creative;
+
+import net.flarn.kinniutils.init.ModItems;
+import net.flarn.kinniutils.refs.Names;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.item.Item;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class CreativeTabKinniUtils {
+ public static final CreativeTabs kinniutilsTab = new CreativeTabs(Names.CREATIVE_TAB_NAME_MAIN) {
+ @Override
+ public Item getTabIconItem() {
+ return ModItems.particleFilter;
+ }
+ };
+
+}
diff --git a/src/main/java/net/flarn/kinniutils/init/FilterRecipes.java b/src/main/java/net/flarn/kinniutils/init/FilterRecipes.java
new file mode 100644
index 0000000..41bfd96
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/init/FilterRecipes.java
@@ -0,0 +1,77 @@
+package net.flarn.kinniutils.init;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import net.flarn.kinniutils.item.ItemParticleFilter;
+import net.flarn.kinniutils.recipe.ShapedFilterRecipe;
+import net.flarn.kinniutils.refs.ParticleGroup;
+import net.minecraft.init.Blocks;
+import net.minecraft.init.Items;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class FilterRecipes {
+
+ private static void registerSingleIngredientRecipe(ParticleGroup grp, Object ingredient, boolean expensive) {
+ ItemStack output = ItemParticleFilter.getItemStackSingleFilter(ModItems.particleFilter, grp);
+ if (expensive) {
+ GameRegistry.addRecipe(new ShapedFilterRecipe(output, "idi", "dfd", "idi", 'i', ingredient, 'd', new ItemStack(Items.redstone), 'f', new ItemStack(ModItems.particleFilter)));
+ } else {
+ GameRegistry.addRecipe(new ShapedFilterRecipe(output, "d d", "ifi", "d d", 'i', ingredient, 'd', new ItemStack(Items.redstone), 'f', new ItemStack(ModItems.particleFilter)));
+ }
+ }
+
+ private static void registerDualIngredientRecipe(ParticleGroup grp, Object ingredient1, Object ingredient2, boolean expensive) {
+ ItemStack output = ItemParticleFilter.getItemStackSingleFilter(ModItems.particleFilter, grp);
+ if (expensive) {
+ GameRegistry.addRecipe(new ShapedFilterRecipe(output, "idj", "dfd", "jdi", 'i', ingredient1, 'j', ingredient2, 'd', new ItemStack(Items.redstone), 'f', new ItemStack(ModItems.particleFilter)));
+ } else {
+ GameRegistry.addRecipe(new ShapedFilterRecipe(output, "d d", "ifj", "d d", 'i', ingredient1, 'j', ingredient2, 'd', new ItemStack(Items.redstone), 'f', new ItemStack(ModItems.particleFilter)));
+ }
+ }
+
+ public static void init() {
+ registerSingleIngredientRecipe(ParticleGroup.HUGEEXPLOSION, new ItemStack(Blocks.tnt), true);
+ registerSingleIngredientRecipe(ParticleGroup.LARGEEXPLOSION, new ItemStack(Blocks.tnt), false);
+ registerDualIngredientRecipe(ParticleGroup.FIREWORKSPARK, new ItemStack(Items.gunpowder), "dye", false);
+ registerDualIngredientRecipe(ParticleGroup.BUBBLE, new ItemStack(Items.water_bucket), new ItemStack(Items.fishing_rod), false);
+ registerDualIngredientRecipe(ParticleGroup.SUSPENDED, new ItemStack(Items.water_bucket), new ItemStack(Items.string), false);
+ registerSingleIngredientRecipe(ParticleGroup.DEPTHSUSPEND, new ItemStack(Items.diamond), true);
+ registerSingleIngredientRecipe(ParticleGroup.TOWNAURA, new ItemStack(Blocks.mycelium), false);
+ registerSingleIngredientRecipe(ParticleGroup.CRIT, new ItemStack(Items.diamond_sword), false);
+ registerDualIngredientRecipe(ParticleGroup.MAGICCRIT, new ItemStack(Items.diamond_sword), new ItemStack(Items.potionitem), false);
+ registerDualIngredientRecipe(ParticleGroup.SMOKE, new ItemStack(Blocks.torch), new ItemStack(Items.blaze_powder), true);
+ /*
+ ParticleGroup.MOBSPELL
+ ParticleGroup.MOBSPELLAMBIENT
+ ParticleGroup.SPELL
+ ParticleGroup.INSTANTSPELL
+ ParticleGroup.WITCHMAGIC
+ ParticleGroup.NOTE
+ ParticleGroup.PORTAL
+ ParticleGroup.ENCHANTMENTTABLE
+ ParticleGroup.EXPLODE
+ ParticleGroup.FLAME
+ ParticleGroup.LAVA
+ ParticleGroup.FOOTSTEP
+ ParticleGroup.SPLASH
+ ParticleGroup.WAKE
+ ParticleGroup.LARGESMOKE
+ ParticleGroup.CLOUD
+ ParticleGroup.REDDUST
+ ParticleGroup.SNOWBALLPOOF
+ ParticleGroup.DRIPWATER
+ ParticleGroup.DRIPLAVA
+ ParticleGroup.SNOWSHOVEL
+ ParticleGroup.SLIME
+ ParticleGroup.HEART
+ ParticleGroup.ANGRYVILLAGER
+ ParticleGroup.HAPPYVILLAGER
+ ParticleGroup.ICONCRACK
+ ParticleGroup.BLOCKCRACK
+ ParticleGroup.BLOCKDUST
+ */
+ }
+}
diff --git a/src/main/java/net/flarn/kinniutils/init/ModItems.java b/src/main/java/net/flarn/kinniutils/init/ModItems.java
index 8d42020..41d7dc5 100644
--- a/src/main/java/net/flarn/kinniutils/init/ModItems.java
+++ b/src/main/java/net/flarn/kinniutils/init/ModItems.java
@@ -1,6 +1,7 @@
package net.flarn.kinniutils.init;
import cpw.mods.fml.common.registry.GameRegistry;
+import net.flarn.kinniutils.item.ItemParticleFilter;
import net.flarn.kinniutils.item.ItemTestFilter;
import net.flarn.kinniutils.refs.Names;
@@ -9,8 +10,10 @@ import net.flarn.kinniutils.refs.Names;
*/
public class ModItems {
public static final ItemTestFilter testFilter = new ItemTestFilter();
+ public static final ItemParticleFilter particleFilter = new ItemParticleFilter();
public static void init() {
GameRegistry.registerItem(testFilter, Names.Items.TEST_FILTER);
+ GameRegistry.registerItem(particleFilter, Names.Items.PARTICLE_FILTER);
}
}
diff --git a/src/main/java/net/flarn/kinniutils/init/ModTiles.java b/src/main/java/net/flarn/kinniutils/init/ModTiles.java
new file mode 100644
index 0000000..46873e7
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/init/ModTiles.java
@@ -0,0 +1,13 @@
+package net.flarn.kinniutils.init;
+
+import cpw.mods.fml.common.registry.GameRegistry;
+import net.flarn.kinniutils.tileentity.TileParticleFilter;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class ModTiles {
+ public static void init() {
+ GameRegistry.registerTileEntity(TileParticleFilter.class, "particleFilter");
+ }
+}
diff --git a/src/main/java/net/flarn/kinniutils/item/BaseItem.java b/src/main/java/net/flarn/kinniutils/item/BaseItem.java
new file mode 100644
index 0000000..a1a5b5c
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/item/BaseItem.java
@@ -0,0 +1,43 @@
+package net.flarn.kinniutils.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.flarn.kinniutils.creative.CreativeTabKinniUtils;
+import net.flarn.kinniutils.refs.Textures;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class BaseItem extends Item {
+ public BaseItem() {
+ super();
+ this.maxStackSize = 1;
+ this.setNoRepair();
+ this.setCreativeTab(CreativeTabKinniUtils.kinniutilsTab);
+
+ }
+
+ @Override
+ public String getUnlocalizedName() {
+ return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
+ }
+
+ @Override
+ public String getUnlocalizedName(ItemStack itemStack) {
+ return String.format("item.%s%s", Textures.RESOURCE_PREFIX, getUnwrappedUnlocalizedName(super.getUnlocalizedName()));
+ }
+
+ @Override
+ @SideOnly(Side.CLIENT)
+ protected String getIconString()
+ {
+ return this.getUnlocalizedName().substring(this.getUnlocalizedName().indexOf(".") + 1);
+ }
+
+ protected String getUnwrappedUnlocalizedName(String unLocalizedName) {
+ return unLocalizedName.substring(unLocalizedName.indexOf(".") + 1);
+ }
+
+}
diff --git a/src/main/java/net/flarn/kinniutils/item/ItemParticleFilter.java b/src/main/java/net/flarn/kinniutils/item/ItemParticleFilter.java
new file mode 100644
index 0000000..126aead
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/item/ItemParticleFilter.java
@@ -0,0 +1,101 @@
+package net.flarn.kinniutils.item;
+
+import cpw.mods.fml.relauncher.Side;
+import cpw.mods.fml.relauncher.SideOnly;
+import net.flarn.kinniutils.refs.ParticleGroup;
+import net.minecraft.creativetab.CreativeTabs;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.item.Item;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTBase;
+import net.minecraft.nbt.NBTTagCompound;
+import net.minecraft.nbt.NBTTagList;
+import net.minecraft.nbt.NBTTagString;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class ItemParticleFilter extends BaseItem {
+ public ItemParticleFilter() {
+ super();
+ setUnlocalizedName("particleFilter");
+ setHasSubtypes(true);
+ }
+
+ public static ItemStack getItemStackSingleFilter(Item item, ParticleGroup grp) {
+ ItemStack ret = new ItemStack(item, 1, 0);
+ NBTTagCompound comp = new NBTTagCompound();
+ NBTTagList complist = new NBTTagList();
+ complist.appendTag(new NBTTagString(grp.groupName));
+ comp.setTag("filterSet", complist);
+ ret.setTagCompound(comp);
+ return ret;
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void getSubItems(Item item, CreativeTabs tab, List out)
+ {
+ out.add(new ItemStack(item, 1, 0));
+ for (ParticleGroup grp : ParticleGroup.allGroups()) {
+ out.add(getItemStackSingleFilter(item, grp));
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ public void addInformation(ItemStack stack, EntityPlayer player, List out, boolean unknown) {
+ NBTTagCompound comp = stack.getTagCompound();
+ if (comp == null) {
+ out.add("Does not filter anything");
+ return;
+ }
+ NBTTagList complist = comp.getTagList("filterSet", new NBTTagString("").getId());
+ if (complist.tagCount() == 0) {
+ out.add("Does not filter anything");
+ return;
+ }
+ for (int i = 0; i < complist.tagCount(); ++i) {
+ String groupName = complist.getStringTagAt(i);
+ ParticleGroup grp = ParticleGroup.getByName(groupName);
+ if (grp != null) {
+ out.add("Filters: " + grp.groupName);
+ }
+ }
+ }
+
+ @SideOnly(Side.CLIENT)
+ @Override
+ public boolean hasEffect(ItemStack stack) {
+ NBTTagCompound comp = stack.getTagCompound();
+ return comp != null && comp.hasKey("filterSet");
+ }
+
+ public static Set<ParticleGroup> getParticleGroups(ItemStack stack) {
+ Set<ParticleGroup> ret = new HashSet<ParticleGroup>();
+ NBTTagCompound comp = stack.getTagCompound();
+ if (comp == null) { return ret; }
+ NBTTagList complist = comp.getTagList("filterSet", new NBTTagString("").getId());
+ if (complist == null) { return ret; }
+ for (int i = 0; i < complist.tagCount(); ++i) {
+ ParticleGroup grp = ParticleGroup.getByName(complist.getStringTagAt(i));
+ if (grp != null) { ret.add(grp); }
+ }
+ return ret;
+ }
+
+ public static void setParticleGroups(ItemStack stack, Collection<ParticleGroup> groups) {
+ NBTTagCompound comp = stack.getTagCompound();
+ if (comp == null) { comp = new NBTTagCompound(); }
+ NBTTagList filterSet = new NBTTagList();
+ for (ParticleGroup grp : groups) {
+ filterSet.appendTag(new NBTTagString(grp.groupName));
+ }
+ comp.setTag("filterSet", filterSet);
+ stack.setTagCompound(comp);
+ }
+
+}
diff --git a/src/main/java/net/flarn/kinniutils/recipe/ShapedFilterRecipe.java b/src/main/java/net/flarn/kinniutils/recipe/ShapedFilterRecipe.java
new file mode 100644
index 0000000..ed45f04
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/recipe/ShapedFilterRecipe.java
@@ -0,0 +1,33 @@
+package net.flarn.kinniutils.recipe;
+
+import net.flarn.kinniutils.item.ItemParticleFilter;
+import net.flarn.kinniutils.refs.ParticleGroup;
+import net.minecraft.inventory.InventoryCrafting;
+import net.minecraft.item.ItemStack;
+import net.minecraftforge.oredict.ShapedOreRecipe;
+
+import java.util.Set;
+
+/**
+ * Created by dsilvers on 03/05/15.
+ */
+public class ShapedFilterRecipe extends ShapedOreRecipe {
+ ItemStack goal;
+ public ShapedFilterRecipe(ItemStack goal, Object... args) {
+ super(goal, args);
+ this.goal = goal;
+ }
+
+ @Override
+ public ItemStack getCraftingResult(InventoryCrafting var1){
+ ItemStack ret = goal.copy();
+ ItemStack inputFilter = var1.getStackInRowAndColumn(1, 1);
+ if (!(inputFilter.getItem() instanceof ItemParticleFilter)) { return null; }
+ /* merge the input and goal filters */
+ Set<ParticleGroup> filter1 = ItemParticleFilter.getParticleGroups(ret);
+ Set<ParticleGroup> filter2 = ItemParticleFilter.getParticleGroups(inputFilter);
+ filter1.addAll(filter2);
+ ItemParticleFilter.setParticleGroups(ret, filter1);
+ return ret;
+ }
+}
diff --git a/src/main/java/net/flarn/kinniutils/refs/Names.java b/src/main/java/net/flarn/kinniutils/refs/Names.java
index c1cea25..652abf1 100644
--- a/src/main/java/net/flarn/kinniutils/refs/Names.java
+++ b/src/main/java/net/flarn/kinniutils/refs/Names.java
@@ -4,10 +4,14 @@ package net.flarn.kinniutils.refs;
* Created by dsilvers on 28/04/15.
*/
public class Names {
+ public static final String CREATIVE_TAB_NAME_MAIN = "kinniutils";
+ public static final String CREATIVE_TAB_NAME_CREATIVE = "kinniutils.creative";
+
public static final class Blocks {
public static final String PARTICLE_FILTER = "particlefilter";
}
public static final class Items {
public static final String TEST_FILTER = "testfilter";
+ public static final String PARTICLE_FILTER = "particleFilter";
}
}
diff --git a/src/main/java/net/flarn/kinniutils/refs/ParticleGroup.java b/src/main/java/net/flarn/kinniutils/refs/ParticleGroup.java
index 42e3182..3aeeb75 100644
--- a/src/main/java/net/flarn/kinniutils/refs/ParticleGroup.java
+++ b/src/main/java/net/flarn/kinniutils/refs/ParticleGroup.java
@@ -1,5 +1,9 @@
package net.flarn.kinniutils.refs;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* Created by dsilvers on 29/04/15.
*/
@@ -7,9 +11,20 @@ public class ParticleGroup {
public final String groupName;
public final ParticleGroup subGroups[];
+ private static Map<String, ParticleGroup> nameToGroup = new HashMap<String, ParticleGroup>();
+
ParticleGroup(String groupName, ParticleGroup... subGroups) {
this.groupName = groupName;
this.subGroups = subGroups;
+ nameToGroup.put(groupName, this);
+ }
+
+ public static ParticleGroup getByName(String groupName) {
+ return nameToGroup.get(groupName);
+ }
+
+ public static Collection<ParticleGroup> allGroups() {
+ return nameToGroup.values();
}
public String toString() {
diff --git a/src/main/java/net/flarn/kinniutils/refs/Textures.java b/src/main/java/net/flarn/kinniutils/refs/Textures.java
new file mode 100644
index 0000000..4420019
--- /dev/null
+++ b/src/main/java/net/flarn/kinniutils/refs/Textures.java
@@ -0,0 +1,8 @@
+package net.flarn.kinniutils.refs;
+
+/**
+ * Created by dsilvers on 02/05/15.
+ */
+public class Textures {
+ public static final String RESOURCE_PREFIX = Core.MOD_ID.toLowerCase() + ":";
+}
diff --git a/src/main/resources/assets/kinniutils/textures/items/particleFilter.png b/src/main/resources/assets/kinniutils/textures/items/particleFilter.png
new file mode 100644
index 0000000..3fbfa8d
--- /dev/null
+++ b/src/main/resources/assets/kinniutils/textures/items/particleFilter.png
Binary files differ