Skip to content

Commit

Permalink
Added clockwork machine with a controller GUI. Mostly placeholder stuff.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lumaceon committed Dec 23, 2015
1 parent acb8957 commit 9521bdf
Show file tree
Hide file tree
Showing 84 changed files with 2,090 additions and 210 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ buildscript {

apply plugin: 'forge'

version = "DEV"
version = "DEV1"
group= "lumaceon.mods.clockworkphase2" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "clockworkphase2"

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package lumaceon.mods.clockworkphase2.api.block.clockwork;

import lumaceon.mods.clockworkphase2.api.clockworknetwork.ClockworkNetworkContainer;

public interface IClockworkNetworkMachine extends IClockworkNetworkTile
{
/**
* Go through a proxy to separate client and server code here.
* @return A Clockwork Network GUI class representing this gui.
*/
public ClockworkNetworkContainer getGui();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package lumaceon.mods.clockworkphase2.api.block.clockwork;

import lumaceon.mods.clockworkphase2.api.util.ClockworkNetwork;

/**
* Tiles implementing this are marked as being part of a clockwork network.
*/
public interface IClockworkNetworkTile
{
public ClockworkNetwork getClockworkNetwork();
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package lumaceon.mods.clockworkphase2.api.block.clockwork;

public interface IMainspringTile extends IClockworkNetworkTile
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package lumaceon.mods.clockworkphase2.api.clockworknetwork;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ICrafting;
import net.minecraft.inventory.Slot;
import net.minecraft.tileentity.TileEntity;

public abstract class ClockworkNetworkContainer
{
public TileEntity te;
protected int xSize, ySize;

public ClockworkNetworkContainer(TileEntity te, int xSize, int ySize) {
this.te = te;
this.xSize = xSize;
this.ySize = ySize;
}
/**
* Gets a list of slots for the corresponding container, coordinates should be local (based on this GUI).
* @return A list of slots or null if the gui has none.
*/
public abstract Slot[] getSlots();

public int getSizeX() { return xSize; }
public int getSizeY() { return ySize; }

/**
* @return The number of values this container needs to update.
*/
public int getUpdateCount() {
return 0;
}

/**
* Called for initial GUI parameter updates.
*/
public void initialCraftingUpdate(ICrafting crafting, int startingIndex, Container container) {}

public void detectAndSendChanges(ICrafting crafting, int startingIndex, Container container) {}

@SideOnly(Side.CLIENT)
public void updateProgressBar(int id, int value) {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package lumaceon.mods.clockworkphase2.api.clockworknetwork;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.tileentity.TileEntity;

import java.util.List;

public abstract class ClockworkNetworkGuiClient extends ClockworkNetworkContainer
{
public ClockworkNetworkGuiClient(TileEntity te, int xSize, int ySize) {
super(te, xSize, ySize);
}

/**
* Called to get buttons to initialize every time the master gui is initialized. Buttons should be created with
* local IDs starting from 0 and going up like a standard gui.
* @param guiLeft Left coordinate of this gui.
* @param guiTop Top coordinate of this gui.
* @return A list of buttons which will be added to the master gui.
*/
public List<GuiButton> getButtonsToAdd(int guiLeft, int guiTop) { return null; }

/**
* Similar to actionPerformed in GuiScreen, except that the id parameter passed in should be used rather than the
* id of the button itself.
* @param button The button clicked.
* @param id The id of the button in relation to this gui.
*/
public void actionPerformed(GuiButton button, int id) {}

public abstract void drawBackground(int left, int top, float zLevel);
public abstract void drawForeground(int left, int top, float zLevel);

public void drawTexturedModalRect(int left, int top, int xSize, int ySize, float zLevel)
{
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV((double) left, (double)(top + ySize), (double) zLevel, 0, 1);
tessellator.addVertexWithUV((double)(left + xSize), (double)(top + ySize), (double) zLevel, 1, 1);
tessellator.addVertexWithUV((double) (left + xSize), (double) top, (double) zLevel, 1, 0);
tessellator.addVertexWithUV((double) left, (double) top, (double) zLevel, 0, 0);
tessellator.draw();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,18 @@ public interface IToolUpgrade
{
/**
* Called to activate or deactivate this tool upgrade
* @param item A stack representing the tool upgrade.
* @param upgradeStack A stack representing the tool upgrade.
* @param toolStack A stack representing the tool this is upgrade is in.
* @param active True to set this to active, false to turn it off.
*/
public void setActive(ItemStack item, boolean active);
public void setActive(ItemStack upgradeStack, ItemStack toolStack, boolean active);

/**
* @param item The tool upgrade stack.
* @param upgradeStack The tool upgrade stack.
* @param toolStack The tool this upgrade is in.
* @return Whether or not this itemstack is active.
*/
public boolean getActive(ItemStack item);
public boolean getActive(ItemStack upgradeStack, ItemStack toolStack);

public float getQualityMultiplier(ItemStack item);
public float getSpeedMultiplier(ItemStack item);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package lumaceon.mods.clockworkphase2.api.util;

import lumaceon.mods.clockworkphase2.api.block.clockwork.IClockworkNetworkMachine;
import lumaceon.mods.clockworkphase2.api.block.clockwork.IMainspringTile;

import java.util.ArrayList;

public class ClockworkNetwork
{
private ArrayList<IMainspringTile> mainsprings = new ArrayList<IMainspringTile>(2);
private ArrayList<IClockworkNetworkMachine> machines = new ArrayList<IClockworkNetworkMachine>(5);

public void addMainspring(IMainspringTile mainspring) {
for(IMainspringTile m : mainsprings)
if(m.equals(mainspring))
return;
mainsprings.add(mainspring);
}

public void addMachine(IClockworkNetworkMachine clockworkMachine) {
for(IClockworkNetworkMachine m : machines)
if(m.equals(clockworkMachine))
return;
machines.add(clockworkMachine);
}

public ArrayList<IMainspringTile> getMainsprings() { return mainsprings; }
public ArrayList<IClockworkNetworkMachine> getMachines() { return machines; }

public void joinNetworks(ClockworkNetwork clockworkNetwork)
{
ArrayList<IMainspringTile> newNetworkMainsprings = clockworkNetwork.getMainsprings();
ArrayList<IClockworkNetworkMachine> newNetworkMachines = clockworkNetwork.getMachines();
for(IMainspringTile m : newNetworkMainsprings)
addMainspring(m);

for(IClockworkNetworkMachine m : newNetworkMachines)
addMachine(m);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public class BlockMoonFlower extends BlockClockworkPhase implements IPlantable,
@SideOnly(Side.CLIENT)
private IIcon[] blockIcons;

public BlockMoonFlower(Material blockMaterial, String unlocalizedName)
{
public BlockMoonFlower(Material blockMaterial, String unlocalizedName) {
super(blockMaterial, unlocalizedName);
this.setHardness(0.0F);
this.setTickRandomly(true);
Expand All @@ -48,8 +47,7 @@ protected boolean canPlaceBlockOn(Block block) {
}

@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block)
{
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
this.checkAndDropBlock(world, x, y, z);
}
Expand All @@ -59,22 +57,23 @@ public void updateTick(World world, int x, int y, int z, Random random)
{
this.checkAndDropBlock(world, x, y, z);
int meta = world.getBlockMetadata(x, y, z);
if(meta < 3)
if(world.canBlockSeeTheSky(x, y, z))
{
if(world.canBlockSeeTheSky(x, y, z) && !world.isDaytime() && random.nextInt(2) == 0)
if(!world.isDaytime()) //It's nighttime, plant can grow taller if lucky.
{
++meta;
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
if(meta <= 3 && random.nextInt(5) == 0)
{
++meta;
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
}
}
else if(meta == 3)
{
if(world.canBlockSeeTheSky(x, y, z) && !world.isDaytime())
else //It's daytime, plant WILL grow backwards if possible
{
if(Phases.isPhaseActive(world, x, y, z, Phases.elysianComet))
world.setBlockMetadataWithNotify(x, y, z, 5, 2); //Set meta to 5 (temporal material)
else
world.setBlockMetadataWithNotify(x, y, z, 4, 2); //Set meta to 4 (moon pearl)
if(meta > 0)
{
--meta;
world.setBlockMetadataWithNotify(x, y, z, meta, 2);
}
}
}
}
Expand Down Expand Up @@ -117,14 +116,7 @@ protected Item getSeeds() {
}

protected Item getProduce(int metadata) {
switch(metadata)
{
case 4:
return ModItems.moonPearl;
case 5:
return ModItems.elysianGem;
}
return null;
return metadata == 4 ? ModItems.temporalPearl : null;
}

public void dropBlockAsItemWithChance(World world, int x, int y, int z, int p_149690_5_, float p_149690_6_, int p_149690_7_) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package lumaceon.mods.clockworkphase2.block.clockwork;

import lumaceon.mods.clockworkphase2.block.BlockClockworkPhase;
import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkBrewery;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockClockworkBrewery extends BlockClockworkPhase implements ITileEntityProvider
{
public BlockClockworkBrewery(Material blockMaterial, String unlocalizedName) {
super(blockMaterial, unlocalizedName);
}

@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileClockworkBrewery();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package lumaceon.mods.clockworkphase2.block.clockwork;

import lumaceon.mods.clockworkphase2.ClockworkPhase2;
import lumaceon.mods.clockworkphase2.block.BlockClockworkPhase;
import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkController;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockClockworkController extends BlockClockworkPhase implements ITileEntityProvider
{
public BlockClockworkController(Material blockMaterial, String unlocalizedName) {
super(blockMaterial, unlocalizedName);
}

@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int meta, float f0, float f1, float f2)
{
if(player.isSneaking())
return false;
if(!world.isRemote)
player.openGui(ClockworkPhase2.instance, 5, world, x, y, z);
return true;
}

@Override
public TileEntity createNewTileEntity(World world, int p_149915_2_) {
return new TileClockworkController();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package lumaceon.mods.clockworkphase2.block.clockwork;

import lumaceon.mods.clockworkphase2.block.BlockClockworkPhase;
import lumaceon.mods.clockworkphase2.tile.clockwork.TileClockworkMixer;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;

public class BlockClockworkMixer extends BlockClockworkPhase implements ITileEntityProvider
{
public BlockClockworkMixer(Material blockMaterial, String unlocalizedName) {
super(blockMaterial, unlocalizedName);
}

@Override
public TileEntity createNewTileEntity(World p_149915_1_, int p_149915_2_) {
return new TileClockworkMixer();
}
}
Loading

0 comments on commit 9521bdf

Please sign in to comment.