Creative Bins? Creative Bins.

This commit is contained in:
aidancbrady committed 2016-08-10 14:37:45 -04:00
1 parent 6de798356f
commit 5a573b7d44
22 files changed
+149 -50

No files matched your search

@@ -255,7 +255,7 @@ public class ClientProxy extends CommonProxy
public static final String[] CUSTOM_RENDERS = new String[] {"fluid_tank", "bin_basic", "bin_advanced", "bin_elite", "bin_ultimate",
"Jetpack", "FreeRunners", "AtomicDisassembler", "ScubaTank", "GasMask", "ArmoredJetpack", "Flamethrower", "personal_chest",
"solar_neutron_activator", "chemical_dissolution_chamber", "chemical_crystallizer", "seismic_vibrator", "security_desk",
"quantum_entangloporter", "resistive_heater", "EnergyCube", "digital_miner"};
"quantum_entangloporter", "resistive_heater", "EnergyCube", "digital_miner", "bin_creative"};
private static final IStateMapper machineMapper = new MachineBlockStateMapper();
private static final IStateMapper basicMapper = new BasicBlockStateMapper();
@@ -575,7 +575,7 @@ public class ClientProxy extends CommonProxy
{
tierPointer = BaseTier.values()[tierPointer.ordinal()+1];
if(tierPointer.isObtainable())
if(type == BasicBlockType.BIN || tierPointer.isObtainable())
{
resource = "mekanism:" + type.getName() + "_" + tierPointer.getName();
@@ -2,6 +2,7 @@ package mekanism.client.render.tileentity;
import mekanism.api.Coord4D;
import mekanism.common.tile.TileEntityBin;
import mekanism.common.util.LangUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.renderer.GlStateManager;
@@ -39,6 +40,11 @@ public class RenderBin extends TileEntitySpecialRenderer<TileEntityBin>
if(itemType != null)
{
amount = Integer.toString(clientAmount);
if(clientAmount == Integer.MAX_VALUE)
{
amount = LangUtils.localize("gui.infinite");
}
}
if(itemType != null)
+2 -1
View File
@@ -678,7 +678,8 @@ public final class Tier
BASIC(4096),
ADVANCED(8192),
ELITE(32768),
ULTIMATE(262144);
ULTIMATE(262144),
CREATIVE(Integer.MAX_VALUE);
public int storage;
private int baseStorage;
@@ -312,7 +312,7 @@ public abstract class BlockBasic extends Block implements ICTMBlock
case BIN:
for(BaseTier tier : BaseTier.values())
{
if(tier.isObtainable())
if(type == BasicBlockType.BIN || tier.isObtainable())
{
ItemStack stack = new ItemStack(item, 1, type.meta);
((ItemBlockBasic)stack.getItem()).setBaseTier(stack, tier);
@@ -44,7 +44,7 @@ import com.google.common.base.Predicates;
public class BlockStateBasic extends ExtendedBlockState
{
public static final PropertyBool activeProperty = PropertyBool.create("active");
public static final PropertyEnum<BaseTier> tierProperty = PropertyEnum.create("tier", BaseTier.class, BaseTier.BASIC, BaseTier.ADVANCED, BaseTier.ELITE, BaseTier.ULTIMATE);
public static final PropertyEnum<BaseTier> tierProperty = PropertyEnum.create("tier", BaseTier.class);
public static final PropertyCTMRenderContext ctmProperty = new PropertyCTMRenderContext();
public BlockStateBasic(BlockBasic block, PropertyEnum<BasicBlockType> typeProperty)
@@ -278,6 +278,11 @@ public class BlockStateBasic extends ExtendedBlockState
{
BaseTier tier = state.getValue(tierProperty);
if(tier == BaseTier.CREATIVE && type != BasicBlockType.BIN)
{
tier = BaseTier.ULTIMATE;
}
nameOverride = type.getName() + "_" + tier.getName();
}
@@ -39,31 +39,41 @@ public class InventoryBin
return null;
}
setItemCount(getItemCount() - stack.stackSize);
if(getTier() != BinTier.CREATIVE)
{
setItemCount(getItemCount() - stack.stackSize);
}
return stack.copy();
}
public ItemStack add(ItemStack stack)
{
if(isValid(stack) && getItemCount() != getMaxStorage())
if(isValid(stack) && (getTier() == BinTier.CREATIVE || getItemCount() != getMaxStorage()))
{
if(getItemType() == null)
{
setItemType(stack);
}
if(getItemCount() + stack.stackSize <= getMaxStorage())
if(getTier() != BinTier.CREATIVE)
{
setItemCount(getItemCount() + stack.stackSize);
return null;
if(getItemCount() + stack.stackSize <= getMaxStorage())
{
setItemCount(getItemCount() + stack.stackSize);
return null;
}
else {
ItemStack rejects = getItemType().copy();
rejects.stackSize = (getItemCount()+stack.stackSize) - getMaxStorage();
setItemCount(getMaxStorage());
return rejects;
}
}
else {
ItemStack rejects = getItemType().copy();
rejects.stackSize = (getItemCount()+stack.stackSize) - getMaxStorage();
setItemCount(getMaxStorage());
return rejects;
setItemCount(Integer.MAX_VALUE);
}
}
@@ -97,7 +107,12 @@ public class InventoryBin
public int getMaxStorage()
{
return BinTier.values()[((ITierItem)bin.getItem()).getBaseTier(bin).ordinal()].storage;
return getTier().storage;
}
public BinTier getTier()
{
return BinTier.values()[((ITierItem)bin.getItem()).getBaseTier(bin).ordinal()];
}
public int getItemCount()
@@ -155,13 +155,15 @@ public class ItemBlockBasic extends ItemBlock implements IEnergizedItem, ITierIt
if(inv.getItemCount() > 0)
{
list.add(EnumColor.BRIGHT_GREEN + inv.getItemType().getDisplayName());
list.add(EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + ": " + EnumColor.GREY + inv.getItemCount());
String amountStr = inv.getItemCount() == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : "" + inv.getItemCount();
list.add(EnumColor.PURPLE + LangUtils.localize("tooltip.itemAmount") + ": " + EnumColor.GREY + amountStr);
}
else {
list.add(EnumColor.DARK_RED + LangUtils.localize("gui.empty"));
}
list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + BinTier.values()[getBaseTier(itemstack).ordinal()].storage + " " + LangUtils.localize("transmission.Items"));
int cap = BinTier.values()[getBaseTier(itemstack).ordinal()].storage;
list.add(EnumColor.INDIGO + LangUtils.localize("tooltip.capacity") + ": " + EnumColor.GREY + (cap == Integer.MAX_VALUE ? LangUtils.localize("gui.infinite") : cap) + " " + LangUtils.localize("transmission.Items"));
}
else if(type == BasicBlockType.INDUCTION_CELL)
{
@@ -1,6 +1,7 @@
package mekanism.common.recipe;
import mekanism.common.MekanismItems;
import mekanism.common.Tier.BinTier;
import mekanism.common.block.states.BlockStateBasic.BasicBlockType;
import mekanism.common.inventory.InventoryBin;
import mekanism.common.item.ItemProxy;
@@ -95,12 +96,15 @@ public class BinRecipe implements IRecipe
if(addStack != null)
{
if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack))
if(!(addStack.getItem() instanceof ItemProxy))
{
return null;
if(binInv.getItemType() != null && !binInv.getItemType().isItemEqual(addStack))
{
return null;
}
binInv.add(addStack);
}
binInv.add(addStack);
return bin;
}
@@ -144,8 +148,14 @@ public class BinRecipe implements IRecipe
int size = inv.getItemCount();
ItemStack testRemove = inv.removeStack();
int newCount = size-(testRemove != null ? testRemove.stackSize : 0);
if(inv.getTier() == BinTier.CREATIVE)
{
newCount = size;
}
ItemDataUtils.setInt(bin, "newCount", size-(testRemove != null ? testRemove.stackSize : 0));
ItemDataUtils.setInt(bin, "newCount", newCount);
}
}
}
@@ -179,8 +189,6 @@ public class BinRecipe implements IRecipe
else {
event.craftMatrix.setInventorySlotContents(other, null);
}
event.craftMatrix.setInventorySlotContents(bin, null);
}
}
}
@@ -36,6 +36,7 @@ import net.minecraft.util.EnumFacing;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.TextComponentString;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Optional.Interface;
import powercrystals.minefactoryreloaded.api.IDeepStorageUnit;
@@ -82,12 +83,6 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
return true;
}
@Override
public void update()
{
super.update();
}
public void sortStacks()
{
if(getItemCount() == 0 || itemType == null)
@@ -149,25 +144,31 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
public ItemStack add(ItemStack stack)
{
if(isValid(stack) && getItemCount() != tier.storage)
if(isValid(stack) && (tier == BinTier.CREATIVE || getItemCount() != tier.storage))
{
if(itemType == null)
{
setItemType(stack);
}
if(getItemCount() + stack.stackSize <= tier.storage)
if(tier != BinTier.CREATIVE)
{
setItemCount(getItemCount() + stack.stackSize);
return null;
if(getItemCount() + stack.stackSize <= tier.storage)
{
setItemCount(getItemCount() + stack.stackSize);
return null;
}
else {
ItemStack rejects = itemType.copy();
rejects.stackSize = (getItemCount()+stack.stackSize) - tier.storage;
setItemCount(tier.storage);
return rejects;
}
}
else {
ItemStack rejects = itemType.copy();
rejects.stackSize = (getItemCount()+stack.stackSize) - tier.storage;
setItemCount(tier.storage);
return rejects;
setItemCount(Integer.MAX_VALUE);
}
}
@@ -193,8 +194,11 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
ItemStack ret = itemType.copy();
ret.stackSize = Math.min(Math.min(amount, itemType.getMaxStackSize()), getItemCount());
setItemCount(getItemCount() - ret.stackSize);
if(tier != BinTier.CREATIVE)
{
setItemCount(getItemCount() - ret.stackSize);
}
return ret;
}
@@ -395,12 +399,15 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
return;
}
if(itemstack == null)
if(tier != BinTier.CREATIVE)
{
setItemCount(getItemCount() - bottomStack.stackSize);
}
else {
setItemCount(getItemCount() - (bottomStack.stackSize-itemstack.stackSize));
if(itemstack == null)
{
setItemCount(getItemCount() - bottomStack.stackSize);
}
else {
setItemCount(getItemCount() - (bottomStack.stackSize-itemstack.stackSize));
}
}
}
else if(i == 1)
@@ -410,7 +417,7 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
topStack = null;
}
else {
if(isValid(itemstack) && itemstack.stackSize > StackUtils.getSize(topStack))
if(isValid(itemstack) && itemstack.stackSize > StackUtils.getSize(topStack) && tier != BinTier.CREATIVE)
{
add(StackUtils.size(itemstack, itemstack.stackSize-StackUtils.getSize(topStack)));
}
@@ -643,4 +650,21 @@ public class TileEntityBin extends TileEntityBasicBlock implements ISidedInvento
{
return EnumActionResult.PASS;
}
@Override
public boolean hasCapability(Capability<?> capability, EnumFacing side)
{
return capability == Capabilities.CONFIGURABLE_CAPABILITY || super.hasCapability(capability, side);
}
@Override
public <T> T getCapability(Capability<T> capability, EnumFacing side)
{
if(capability == Capabilities.CONFIGURABLE_CAPABILITY)
{
return (T)this;
}
return super.getCapability(capability, side);
}
}