Skip to content

Commit

Permalink
Merge pull request #235 from way2muchnoise/1.7-update
Browse files Browse the repository at this point in the history
fixes fluid dupe with transposer, closes #217, thx @skyboy for the tip
  • Loading branch information
jakimfett committed Oct 9, 2014
2 parents 9a16dd3 + 025e43f commit e41a6a5
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 91 deletions.
19 changes: 19 additions & 0 deletions src/main/java/minechem/MinechemItemsRegistration.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package minechem;

import cpw.mods.fml.common.registry.GameRegistry;
import minechem.fluid.FluidHelper;
import minechem.item.ItemAtomicManipulator;
import minechem.item.OpticalMicroscopeLens;
import minechem.item.blueprint.ItemBlueprint;
Expand All @@ -12,6 +13,7 @@
import minechem.item.polytool.PolytoolItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.oredict.OreDictionary;

public class MinechemItemsRegistration
Expand Down Expand Up @@ -56,8 +58,25 @@ public static void init()
polytool = new PolytoolItem();
GameRegistry.registerItem(polytool, Minechem.ID + "Polytool");

registerFluidContainers();
}

private static void registerFluidContainers()
{
ItemStack emptyTube = new ItemStack(MinechemItemsRegistration.element, 1, ElementEnum.heaviestMass);
for (ElementEnum element : ElementEnum.values())
{
ItemStack tube = new ItemStack(MinechemItemsRegistration.element, 1, element.ordinal());
FluidContainerRegistry.registerFluidContainer(FluidHelper.elements.get(element), tube, emptyTube);
}

for (MoleculeEnum molecule : MoleculeEnum.values())
{
ItemStack tube = new ItemStack(MinechemItemsRegistration.molecule, 1, molecule.ordinal());
FluidContainerRegistry.registerFluidContainer(FluidHelper.molecule.get(molecule), tube, emptyTube);
}
}

public static void registerToOreDictionary()
{
for (ElementEnum element : ElementEnum.values())
Expand Down
1 change: 1 addition & 0 deletions src/main/java/minechem/fluid/FluidChemical.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import java.awt.*;

public class FluidChemical extends Fluid implements IMinechemFluid
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/minechem/fluid/FluidChemicalDispenser.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package minechem.fluid;

import java.util.Random;
import minechem.MinechemItemsRegistration;
import minechem.item.element.ElementEnum;
import minechem.item.element.ElementItem;
Expand All @@ -20,6 +19,8 @@
import net.minecraft.world.World;
import net.minecraftforge.fluids.IFluidBlock;

import java.util.Random;

public class FluidChemicalDispenser implements IBehaviorDispenseItem {

private static final Random ran=new Random();
Expand Down
1 change: 1 addition & 0 deletions src/main/java/minechem/fluid/FluidElement.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;

import java.awt.*;

public class FluidElement extends Fluid implements IMinechemFluid
Expand Down
1 change: 1 addition & 0 deletions src/main/java/minechem/fluid/FluidHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cpw.mods.fml.common.registry.GameRegistry;
import minechem.item.element.ElementEnum;
import minechem.item.molecule.MoleculeEnum;

import java.util.HashMap;

public class FluidHelper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package minechem.fluid;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import minechem.utils.Reference;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraftforge.client.event.TextureStitchEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;

public class FluidTextureStitchHandler {

Expand Down
7 changes: 4 additions & 3 deletions src/main/java/minechem/item/element/ElementEnum.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package minechem.item.element;

import static minechem.item.element.ElementClassificationEnum.*;
import static minechem.radiation.RadiationEnum.*;
import static minechem.item.ChemicalRoomStateEnum.*;
import minechem.item.ChemicalRoomStateEnum;
import minechem.radiation.RadiationEnum;
import net.minecraft.util.StatCollector;

import static minechem.item.ChemicalRoomStateEnum.*;
import static minechem.item.element.ElementClassificationEnum.*;
import static minechem.radiation.RadiationEnum.*;

public enum ElementEnum
{
H("Hydrogen", nonmetal, gas, stable),//Done
Expand Down
58 changes: 8 additions & 50 deletions src/main/java/minechem/item/element/ElementItem.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package minechem.item.element;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import minechem.MinechemItemsRegistration;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import minechem.Minechem;
import minechem.MinechemItemsRegistration;
import minechem.fluid.FluidChemicalDispenser;
import minechem.fluid.FluidHelper;
import minechem.item.ChemicalRoomStateEnum;
Expand All @@ -30,13 +29,13 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;
import org.lwjgl.input.Keyboard;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class ElementItem extends Item implements IFluidContainerItem
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ElementItem extends Item
{

private final static ElementEnum[] elements = ElementEnum.values();
Expand Down Expand Up @@ -336,47 +335,6 @@ public static RadiationInfo decay(ItemStack element, World world)
return initiateRadioactivity(element, world);
}

@Override
public FluidStack getFluid(ItemStack container)
{
if (container.getItemDamage() != ElementEnum.heaviestMass)
{
return new FluidStack(FluidHelper.elements.get(elements[container.getItemDamage()]), getCapacity(container));
}
return null;
}

@Override
public int getCapacity(ItemStack container)
{
if (container.getItemDamage() != ElementEnum.heaviestMass)
{
return 1000;
}
return 0;
}

@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
return 0;
}

@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
if (container.getItemDamage() != ElementEnum.heaviestMass)
{
FluidStack fluidStack = getFluid(container);
if (container.stackSize > 0)
{
--container.stackSize;
return fluidStack;
}
}
return null;
}

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/minechem/item/molecule/MoleculeEnum.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package minechem.item.molecule;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
import minechem.item.ChemicalRoomStateEnum;
import minechem.item.element.Element;
import minechem.potion.PotionChemical;
import net.minecraft.util.StatCollector;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;

import static minechem.item.ChemicalRoomStateEnum.*;
import static minechem.item.element.ElementEnum.*;

Expand Down
38 changes: 6 additions & 32 deletions src/main/java/minechem/item/molecule/MoleculeItem.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package minechem.item.molecule;

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

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import minechem.Minechem;
import minechem.MinechemItemsRegistration;
import minechem.fluid.FluidHelper;
Expand All @@ -21,12 +20,11 @@
import net.minecraft.util.IIcon;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.IFluidContainerItem;

public class MoleculeItem extends Item implements IFluidContainerItem
import java.util.ArrayList;
import java.util.List;

public class MoleculeItem extends Item
{
public IIcon render_pass1, render_pass2, filledMolecule;

Expand Down Expand Up @@ -171,30 +169,6 @@ public boolean isFull3D()
return true;
}

@Override
public FluidStack getFluid(ItemStack container)
{
return new FluidStack(FluidHelper.molecule.get(MoleculeEnum.getById(container.getItemDamage())), 100);
}

@Override
public int getCapacity(ItemStack container)
{
return 100;
}

@Override
public int fill(ItemStack container, FluidStack resource, boolean doFill)
{
return 0;
}

@Override
public FluidStack drain(ItemStack container, int maxDrain, boolean doDrain)
{
return getFluid(container);
}

@Override
public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraftforge.client.IItemRenderer;

import org.lwjgl.opengl.GL11;

public class MoleculeItemRenderer implements IItemRenderer
Expand Down

0 comments on commit e41a6a5

Please sign in to comment.