Skip to content

Commit

Permalink
Add compression overrides for bricks, snowballs, glowstone, clay, and…
Browse files Browse the repository at this point in the history
… quartz
  • Loading branch information
jaquadro committed Sep 15, 2014
1 parent dc1b8e1 commit 0a4df5f
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/com/jaquadro/minecraft/storagedrawers/StorageDrawers.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jaquadro.minecraft.storagedrawers;

import com.jaquadro.minecraft.storagedrawers.config.CompTierRegistry;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import com.jaquadro.minecraft.storagedrawers.core.*;
import com.jaquadro.minecraft.storagedrawers.network.BlockClickMessage;
Expand Down Expand Up @@ -34,6 +35,7 @@ public class StorageDrawers

public static SimpleNetworkWrapper network;
public static ConfigManager config;
public static CompTierRegistry compRegistry;

@Mod.Instance(MOD_ID)
public static StorageDrawers instance;
Expand All @@ -48,6 +50,8 @@ public void preInit (FMLPreInitializationEvent event) {
network = NetworkRegistry.INSTANCE.newSimpleChannel(MOD_ID);
network.registerMessage(BlockClickMessage.Handler.class, BlockClickMessage.class, 0, Side.SERVER);

compRegistry = new CompTierRegistry();

blocks.init();
items.init();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.jaquadro.minecraft.storagedrawers.block.tile;

import com.jaquadro.minecraft.storagedrawers.StorageDrawers;
import com.jaquadro.minecraft.storagedrawers.config.CompTierRegistry;
import com.jaquadro.minecraft.storagedrawers.config.ConfigManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.*;
Expand Down Expand Up @@ -329,6 +330,12 @@ private void populateSlot (int slot, ItemStack stack, int conversion) {
}

private ItemStack findHigherTier (ItemStack stack) {
CompTierRegistry.Record record = StorageDrawers.compRegistry.findHigherTier(stack);
if (record != null) {
lookupSizeResult = record.convRate;
return record.upper;
}

CraftingManager cm = CraftingManager.getInstance();

setupLookup(lookup3, stack);
Expand All @@ -354,6 +361,12 @@ private ItemStack findHigherTier (ItemStack stack) {
}

private ItemStack findLowerTier (ItemStack stack) {
CompTierRegistry.Record record = StorageDrawers.compRegistry.findLowerTier(stack);
if (record != null) {
lookupSizeResult = record.convRate;
return record.lower;
}

CraftingManager cm = CraftingManager.getInstance();
List recipeList = cm.getRecipeList();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package com.jaquadro.minecraft.storagedrawers.config;

import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;

import java.util.ArrayList;
import java.util.List;

public class CompTierRegistry
{
public class Record {
public ItemStack upper;
public ItemStack lower;
public int convRate;
}

private List<Record> records = new ArrayList<Record>();

public CompTierRegistry () {
register(new ItemStack(Blocks.clay), new ItemStack(Items.clay_ball), 4);
register(new ItemStack(Blocks.snow), new ItemStack(Items.snowball), 4);
register(new ItemStack(Blocks.glowstone), new ItemStack(Items.glowstone_dust), 4);
register(new ItemStack(Blocks.brick_block), new ItemStack(Items.brick), 4);
register(new ItemStack(Blocks.nether_brick), new ItemStack(Items.netherbrick), 4);
register(new ItemStack(Blocks.quartz_block), new ItemStack(Items.quartz), 4);
}

public void register (ItemStack upper, ItemStack lower, int convRate) {
Record r = new Record();
r.upper = upper;
r.lower = lower;
r.convRate = convRate;

records.add(r);
}

public Record findHigherTier (ItemStack stack) {
if (stack == null || stack.getItem() == null)
return null;

for (Record r : records) {
if (stack.isItemEqual(r.lower) && ItemStack.areItemStackTagsEqual(stack, r.lower))
return r;
}

return null;
}

public Record findLowerTier (ItemStack stack) {
if (stack == null || stack.getItem() == null)
return null;

for (Record r : records) {
if (stack.isItemEqual(r.upper) && ItemStack.areItemStackTagsEqual(stack, r.upper))
return r;
}

return null;
}
}

0 comments on commit 0a4df5f

Please sign in to comment.