Moved some stuff around, and started on new gear network code
This commit is contained in:
parent
fd1a182cb2
commit
9b67a2d66d
18 changed files with 167 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gearshaft;
|
package resonantinduction.mechanica.gearshaft;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
@ -8,9 +8,9 @@ import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
import resonant.api.IMechanicalNode;
|
import resonant.api.IMechanicalNode;
|
||||||
import resonant.api.grid.INodeProvider;
|
import resonant.api.grid.INodeProvider;
|
||||||
import resonantinduction.mechanical.energy.gear.PartGear;
|
|
||||||
import resonantinduction.mechanical.energy.gear.PartGearShaft;
|
|
||||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||||
|
import resonantinduction.mechanical.gear.PartGear;
|
||||||
|
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||||
|
|
||||||
public class GearShaftNode extends MechanicalNode
|
public class GearShaftNode extends MechanicalNode
|
||||||
{
|
{
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gearshaft;
|
package resonantinduction.mechanica.gearshaft;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import resonantinduction.core.prefab.part.IHighlight;
|
import resonantinduction.core.prefab.part.IHighlight;
|
||||||
import resonantinduction.mechanical.energy.gear.PartGearShaft;
|
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.lib.vec.Vector3;
|
import codechicken.lib.vec.Vector3;
|
||||||
import codechicken.multipart.JItemMultiPart;
|
import codechicken.multipart.JItemMultiPart;
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gearshaft;
|
package resonantinduction.mechanica.gearshaft;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.glRotatef;
|
import static org.lwjgl.opengl.GL11.glRotatef;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
@ -11,7 +11,7 @@ import org.lwjgl.opengl.GL11;
|
||||||
import resonant.api.items.ISimpleItemRenderer;
|
import resonant.api.items.ISimpleItemRenderer;
|
||||||
import resonant.lib.render.RenderUtility;
|
import resonant.lib.render.RenderUtility;
|
||||||
import resonantinduction.core.Reference;
|
import resonantinduction.core.Reference;
|
||||||
import resonantinduction.mechanical.energy.gear.PartGearShaft;
|
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gearshaft;
|
package resonantinduction.mechanica.gearshaft;
|
||||||
|
|
||||||
import resonant.lib.grid.NodeGrid;
|
import resonant.lib.grid.NodeGrid;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package resonantinduction.mechanical.energy.gearshaft;
|
package resonantinduction.mechanica.gearshaft;
|
||||||
|
|
||||||
import resonant.api.grid.INodeProvider;
|
import resonant.api.grid.INodeProvider;
|
||||||
import resonant.lib.grid.Node;
|
import resonant.lib.grid.Node;
|
||||||
import resonantinduction.mechanical.energy.gear.PartGearShaft;
|
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||||
|
|
||||||
public class ShaftSubNode extends Node<INodeProvider, ShaftGrid, ShaftSubNode>
|
public class ShaftSubNode extends Node<INodeProvider, ShaftGrid, ShaftSubNode>
|
||||||
{
|
{
|
|
@ -1,9 +1,9 @@
|
||||||
package resonantinduction.mechanical;
|
package resonantinduction.mechanical;
|
||||||
|
|
||||||
import resonant.lib.render.item.GlobalItemRenderer;
|
import resonant.lib.render.item.GlobalItemRenderer;
|
||||||
import resonantinduction.mechanical.energy.gear.RenderGear;
|
import resonantinduction.mechanica.gearshaft.RenderGearShaft;
|
||||||
import resonantinduction.mechanical.energy.gearshaft.RenderGearShaft;
|
|
||||||
import resonantinduction.mechanical.fluid.pipe.RenderPipe;
|
import resonantinduction.mechanical.fluid.pipe.RenderPipe;
|
||||||
|
import resonantinduction.mechanical.gear.RenderGear;
|
||||||
|
|
||||||
public class ClientProxy extends CommonProxy
|
public class ClientProxy extends CommonProxy
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,10 +18,9 @@ import resonantinduction.core.Reference;
|
||||||
import resonantinduction.core.ResonantInduction;
|
import resonantinduction.core.ResonantInduction;
|
||||||
import resonantinduction.core.Settings;
|
import resonantinduction.core.Settings;
|
||||||
import resonantinduction.core.TabRI;
|
import resonantinduction.core.TabRI;
|
||||||
|
import resonantinduction.mechanica.gearshaft.ItemGearShaft;
|
||||||
import resonantinduction.mechanical.belt.BlockConveyorBelt;
|
import resonantinduction.mechanical.belt.BlockConveyorBelt;
|
||||||
import resonantinduction.mechanical.belt.TileConveyorBelt;
|
import resonantinduction.mechanical.belt.TileConveyorBelt;
|
||||||
import resonantinduction.mechanical.energy.gear.ItemGear;
|
|
||||||
import resonantinduction.mechanical.energy.gearshaft.ItemGearShaft;
|
|
||||||
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
import resonantinduction.mechanical.energy.grid.MechanicalNode;
|
||||||
import resonantinduction.mechanical.energy.turbine.BlockWaterTurbine;
|
import resonantinduction.mechanical.energy.turbine.BlockWaterTurbine;
|
||||||
import resonantinduction.mechanical.energy.turbine.BlockWindTurbine;
|
import resonantinduction.mechanical.energy.turbine.BlockWindTurbine;
|
||||||
|
@ -32,6 +31,7 @@ import resonantinduction.mechanical.energy.turbine.TileWindTurbine;
|
||||||
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
|
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
|
||||||
import resonantinduction.mechanical.fluid.pipe.ItemPipe;
|
import resonantinduction.mechanical.fluid.pipe.ItemPipe;
|
||||||
import resonantinduction.mechanical.fluid.transport.TilePump;
|
import resonantinduction.mechanical.fluid.transport.TilePump;
|
||||||
|
import resonantinduction.mechanical.gear.ItemGear;
|
||||||
import resonantinduction.mechanical.logistic.belt.BlockDetector;
|
import resonantinduction.mechanical.logistic.belt.BlockDetector;
|
||||||
import resonantinduction.mechanical.logistic.belt.BlockManipulator;
|
import resonantinduction.mechanical.logistic.belt.BlockManipulator;
|
||||||
import resonantinduction.mechanical.logistic.belt.TileDetector;
|
import resonantinduction.mechanical.logistic.belt.TileDetector;
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package resonantinduction.mechanical;
|
package resonantinduction.mechanical;
|
||||||
|
|
||||||
import resonantinduction.mechanical.energy.gear.PartGear;
|
|
||||||
import resonantinduction.mechanical.energy.gear.PartGearShaft;
|
|
||||||
import resonantinduction.mechanical.fluid.pipe.PartPipe;
|
import resonantinduction.mechanical.fluid.pipe.PartPipe;
|
||||||
|
import resonantinduction.mechanical.gear.PartGear;
|
||||||
|
import resonantinduction.mechanical.gear.PartGearShaft;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
import codechicken.multipart.MultiPartRegistry.IPartFactory;
|
||||||
import codechicken.multipart.MultipartGenerator;
|
import codechicken.multipart.MultipartGenerator;
|
||||||
|
|
|
@ -28,6 +28,7 @@ import codechicken.multipart.TMultiPart;
|
||||||
*
|
*
|
||||||
* @author Calclavia
|
* @author Calclavia
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
public class MechanicalNode extends Node<INodeProvider, TickingGrid, MechanicalNode>
|
public class MechanicalNode extends Node<INodeProvider, TickingGrid, MechanicalNode>
|
||||||
implements IMechanicalNode
|
implements IMechanicalNode
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -6,9 +6,9 @@ import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import resonantinduction.mechanica.gearshaft.GearShaftNode;
|
||||||
|
import resonantinduction.mechanica.gearshaft.RenderGearShaft;
|
||||||
import resonantinduction.mechanical.Mechanical;
|
import resonantinduction.mechanical.Mechanical;
|
||||||
import resonantinduction.mechanical.energy.gearshaft.GearShaftNode;
|
|
||||||
import resonantinduction.mechanical.energy.gearshaft.RenderGearShaft;
|
|
||||||
import resonantinduction.mechanical.energy.grid.PartMechanical;
|
import resonantinduction.mechanical.energy.grid.PartMechanical;
|
||||||
import codechicken.lib.raytracer.IndexedCuboid6;
|
import codechicken.lib.raytracer.IndexedCuboid6;
|
||||||
import codechicken.lib.vec.Cuboid6;
|
import codechicken.lib.vec.Cuboid6;
|
|
@ -1,4 +1,4 @@
|
||||||
package resonantinduction.mechanical.energy.gear;
|
package resonantinduction.mechanical.gear;
|
||||||
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraftforge.client.model.AdvancedModelLoader;
|
import net.minecraftforge.client.model.AdvancedModelLoader;
|
|
@ -0,0 +1,72 @@
|
||||||
|
package resonantinduction.mechanical.gear.dev;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import universalelectricity.api.net.IUpdate;
|
||||||
|
|
||||||
|
/** Network type only used by gear related mechanical machines
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public class GearNetwork implements IUpdate
|
||||||
|
{
|
||||||
|
/** Map of gears and how they related to each generator */
|
||||||
|
private final Set<NodeGear> nodes = Collections.newSetFromMap(new WeakHashMap<NodeGear, Boolean>());
|
||||||
|
private final Set<NodeGenerator> generators = Collections.newSetFromMap(new WeakHashMap<NodeGenerator, Boolean>());
|
||||||
|
private boolean doRemap = false;
|
||||||
|
|
||||||
|
/** Called by a gear when its added to the world */
|
||||||
|
public void onAdded(NodeGear gear)
|
||||||
|
{
|
||||||
|
if (gear instanceof NodeGenerator)
|
||||||
|
{
|
||||||
|
if (!generators.contains(gear))
|
||||||
|
{
|
||||||
|
generators.add((NodeGenerator) gear);
|
||||||
|
doRemap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!nodes.contains(gear))
|
||||||
|
{
|
||||||
|
nodes.add(gear);
|
||||||
|
doRemap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Called by a gear when its removed from the world */
|
||||||
|
public void onRemoved(NodeGear gear)
|
||||||
|
{
|
||||||
|
if (generators.remove(gear) || nodes.remove(gear))
|
||||||
|
{
|
||||||
|
doRemap = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update()
|
||||||
|
{
|
||||||
|
//If remap flag was set make sure to remap before doing anything else
|
||||||
|
if (doRemap)
|
||||||
|
{
|
||||||
|
doRemap = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUpdate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean continueUpdate()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
package resonantinduction.mechanical.gear.dev;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import resonant.api.grid.INode;
|
||||||
|
import resonant.lib.type.Pair;
|
||||||
|
|
||||||
|
/** Applied to any device that acts as part of a gear network using or supplying rotational force
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public class NodeGear implements INode
|
||||||
|
{
|
||||||
|
/** Used by the gear network to track the rotation effect each generator has on this gear */
|
||||||
|
public HashMap<NodeGenerator, Pair<Boolean, Float>> rotationEffectMap = new HashMap<NodeGenerator, Pair<Boolean, Float>>();
|
||||||
|
|
||||||
|
/** Speed by which this gear rotates */
|
||||||
|
protected float rotationSpeed = 0;
|
||||||
|
/** Force carried by this gear */
|
||||||
|
protected float force = 0;
|
||||||
|
/** Flag if the gear is rotating clockwise */
|
||||||
|
protected boolean clockwise = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(float deltaTime)
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void reconstruct()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deconstruct()
|
||||||
|
{
|
||||||
|
this.rotationEffectMap.clear();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void recache()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,19 @@
|
||||||
|
package resonantinduction.mechanical.gear.dev;
|
||||||
|
|
||||||
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
|
||||||
|
/** Added to any device that generates a mechanical rotational force as part of the network
|
||||||
|
*
|
||||||
|
* @author Darkguardsman */
|
||||||
|
public class NodeGenerator extends NodeGear
|
||||||
|
{
|
||||||
|
/** Should the generator supply a force to the network. Checked each tick before calling any
|
||||||
|
* force related methods.
|
||||||
|
*
|
||||||
|
* @param side - side the force is outputting to
|
||||||
|
* @return true if this node can */
|
||||||
|
public boolean shouldSupplyForce(ForgeDirection side)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue