Skip to content

Commit

Permalink
moved assembly tables to new block API
Browse files Browse the repository at this point in the history
  • Loading branch information
EternalBlueFlame committed Jul 17, 2024
1 parent 4570512 commit 907e3ea
Show file tree
Hide file tree
Showing 43 changed files with 147 additions and 216 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public class RecipeBookHandler {
public static String[] vanillaWorkTableRecipes = new String[21];

public RecipeBookHandler() {
vanillaWorkTableRecipes[0] = BlockIDs.assemblyTableI.block.getUnlocalizedName();
vanillaWorkTableRecipes[1] = BlockIDs.assemblyTableII.block.getUnlocalizedName();
vanillaWorkTableRecipes[2] = BlockIDs.assemblyTableIII.block.getUnlocalizedName();
vanillaWorkTableRecipes[0] = TCBlocks.assemblyTableI.getUnlocalizedName();
vanillaWorkTableRecipes[1] = TCBlocks.assemblyTableII.getUnlocalizedName();
vanillaWorkTableRecipes[2] = TCBlocks.assemblyTableIII.getUnlocalizedName();
vanillaWorkTableRecipes[3] = TCBlocks.distilIdle.getUnlocalizedName();
vanillaWorkTableRecipes[4] = BlockIDs.openFurnaceIdle.block.getUnlocalizedName();
vanillaWorkTableRecipes[5] = BlockIDs.trainWorkbench.block.getUnlocalizedName();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/train/client/gui/GuiRecipeBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
addPage("Modelers:\nDAYdiecast,\nhelldiver,\nBlockStormTwo,\nChandlerBingUA.\n\nGitHub 1.7.10 port Team: \nEternal BlueFlame,\nNitroxydeX,\nFirEmerald,\nHagurd\n \nWebsite:\nhttp://traincraft-mod.\nblogspot.com", "", "right", new ArrayList<StackToDraw>() {
{
add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoSteamAdler.item), 20, 16));
add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 170, 16));
add(new StackToDraw(new ItemStack(TCBlocks.assemblyTableII), 170, 16));

add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoForneyRed.item), 20, 175));
add(new StackToDraw(new ItemStack(ItemIDs.minecartPassengerBlue.item), 40, 175));
Expand Down Expand Up @@ -273,9 +273,9 @@ public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
addPage("Crafting:\nAll train parts are crafted in the train workbench,\n\nthen trains have to be assembled in the assembly tables.\n\nThere are three assembly tables:\n\nTierI - Iron age\nTierII - Steel age\nTierIII - Advanced age\n", "", "right", new ArrayList<StackToDraw>() {
{
add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16));
add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableI.block), 40, 165));
add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableII.block), 80, 165));
add(new StackToDraw(new ItemStack(BlockIDs.assemblyTableIII.block), 140, 165));
add(new StackToDraw(new ItemStack(TCBlocks.assemblyTableI), 40, 165));
add(new StackToDraw(new ItemStack(TCBlocks.assemblyTableII), 80, 165));
add(new StackToDraw(new ItemStack(TCBlocks.assemblyTableIII), 140, 165));
}
});
addPage("Crafting steel:\nSteel is crafted in Open Hearth Furnace, supply iron ingots and graphite in the top slots, fuel in the bottom slot, \nand it will cook slowly into steel.\nYou can also use steel from other mods or use this steel in other mods.\n", "", "left", new ArrayList<StackToDraw>() {
Expand Down
41 changes: 6 additions & 35 deletions src/main/java/train/common/blocks/BlockAssemblyTableI.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,21 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import train.common.Traincraft;
import train.common.api.blocks.BlockDynamic;
import train.common.library.GuiIDs;
import train.common.library.Info;
import train.common.tile.TileCrafterTierI;
import train.common.tile.TileHelper;

import java.util.Random;

public class BlockAssemblyTableI extends BlockContainer {
public class BlockAssemblyTableI extends BlockDynamic {

private IIcon textureTop;
private IIcon textureBottom;
private IIcon textureFront;
private IIcon textureSide;

public BlockAssemblyTableI(Material material) {
super(material);
super(material,0);
setCreativeTab(Traincraft.tcTab);
setHarvestLevel("axe", 0);
}

@Override
Expand Down Expand Up @@ -62,29 +60,6 @@ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer p
return true;
}

@Override
public IIcon getIcon(int i, int j) {
if (i == 1) {
return textureTop;
}
if (i == 0) {
return textureBottom;
}
if (i == 3) {
return textureFront;
}
else {
return textureSide;
}
}

@Override
public IIcon getIcon(IBlockAccess worldAccess, int i, int j, int k, int side) {
if (((TileCrafterTierI) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileCrafterTierI) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 3 ? textureFront : textureSide;
}

@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int par6) {
Expand Down Expand Up @@ -142,11 +117,7 @@ public TileEntity createNewTileEntity(World var1, int meta) {
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
textureFront = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_side");
public TileEntity createTileEntity(World var1, int meta) {
return new TileCrafterTierI();
}
}
44 changes: 6 additions & 38 deletions src/main/java/train/common/blocks/BlockAssemblyTableII.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import train.common.Traincraft;
import train.common.api.blocks.BlockDynamic;
import train.common.library.GuiIDs;
import train.common.library.Info;
import train.common.tile.TileCrafterTierII;
import train.common.tile.TileHelper;

import java.util.Random;

public class BlockAssemblyTableII extends BlockContainer {

private IIcon textureTop;
private IIcon textureBottom;
private IIcon textureFront;
private IIcon textureSide;
public class BlockAssemblyTableII extends BlockDynamic {

public BlockAssemblyTableII(Material material) {
super(material);
super(material,0);
setCreativeTab(Traincraft.tcTab);
setHarvestLevel("axe", 0);
}

@Override
Expand All @@ -60,30 +57,6 @@ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer p
return true;
}

@Override
public IIcon getIcon(int i, int j) {
if (i == 1) {
return textureTop;
}
if (i == 0) {
return textureBottom;
}
if (i == 3) {
return textureFront;
}
else {
return textureSide;
}
}

@Override
public IIcon getIcon(IBlockAccess worldAccess, int i, int j, int k, int side) {
if (((TileCrafterTierII) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileCrafterTierII) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 3 ? textureFront : textureSide;
}

@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int par6) {
Random distilRand = new Random();
Expand Down Expand Up @@ -139,13 +112,8 @@ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase e
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileCrafterTierII();
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_2_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_2_bottom");
textureFront = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_2_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_2_side");
public TileEntity createTileEntity(World var1, int meta) {
return new TileCrafterTierII();
}
}
44 changes: 7 additions & 37 deletions src/main/java/train/common/blocks/BlockAssemblyTableIII.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import train.common.Traincraft;
import train.common.api.blocks.BlockDynamic;
import train.common.library.GuiIDs;
import train.common.library.Info;
import train.common.tile.TileCrafterTierIII;
import train.common.tile.TileHelper;

import java.util.Random;

public class BlockAssemblyTableIII extends BlockContainer {

private IIcon textureTop;
private IIcon textureBottom;
private IIcon textureFront;
private IIcon textureSide;
public class BlockAssemblyTableIII extends BlockDynamic {

public BlockAssemblyTableIII(Material material) {
super(material);
super(material,0);
setCreativeTab(Traincraft.tcTab);
setHarvestLevel("axe", 0);
}

@Override
Expand All @@ -60,29 +57,6 @@ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer p
return true;
}

@Override
public IIcon getIcon(int i, int j) {
if (i == 1) {
return textureTop;
}
if (i == 0) {
return textureBottom;
}
if (i == 3) {
return textureFront;
}
else {
return textureSide;
}
}

@Override
public IIcon getIcon(IBlockAccess worldAccess, int i, int j, int k, int side) {
if (((TileCrafterTierIII) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileCrafterTierIII) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 3 ? textureFront : textureSide;
}

@Override
public void breakBlock(World world, int i, int j, int k, Block par5, int par6) {
Expand Down Expand Up @@ -138,13 +112,9 @@ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase e
public TileEntity createNewTileEntity(World var1, int meta) {
return new TileCrafterTierIII();
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_3_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_3_bottom");
textureFront = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_3_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_3_side");
public TileEntity createTileEntity(World var1, int meta) {
return new TileCrafterTierIII();
}

}
17 changes: 11 additions & 6 deletions src/main/java/train/common/blocks/TCBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,25 @@ public static void init() {
public static Block bridgePillar=new BlockBridgePillar().setHardness(3.5F).setStepSound(Block.soundTypeWood);
public static Block distilIdle=new BlockDistil(2, false).setHardness(3.5F).setStepSound(Block.soundTypeStone);
public static Block distilActive=new BlockDistil(2,true).setHardness(3.5F).setStepSound(Block.soundTypeStone).setLightLevel(0.8F);
public static Block assemblyTableI=new BlockAssemblyTableI(Material.wood).setHardness(3.5F).setStepSound(Block.soundTypeWood);
public static Block assemblyTableII=new BlockAssemblyTableII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);
public static Block assemblyTableIII=new BlockAssemblyTableIII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);

public static void loadBlocks() {
TraincraftRegistry.registerBlock(bridgePillar,Traincraft.tcTab, Info.modID,"bridgePillar");
TraincraftRegistry.registerBlock(distilIdle,Traincraft.tcTab, Info.modID,"distilIdle");
TraincraftRegistry.registerBlock(distilActive,null, Info.modID,"distilActive");
TraincraftRegistry.registerBlock(assemblyTableI,null, Info.modID,"assemblyTableI");
TraincraftRegistry.registerBlock(assemblyTableII,null, Info.modID,"assemblyTableII");
TraincraftRegistry.registerBlock(assemblyTableIII,null, Info.modID,"assemblyTableIII");

//TCBlocks.distilIdle.block = new BlockDistil(2, false).setHardness(3.5F).setStepSound(Block.soundTypeStone);
//BlockIDs.distilActive.block = new BlockDistil(2, true).setHardness(3.5F).setStepSound(Block.soundTypeStone).setLightLevel(0.8F);
//BlockIDs.signal.block = new BlockSignal(BlockIDs.signal.block, 16).setHardness(1.7F).setStepSound(Block.soundTypeMetal);

BlockIDs.assemblyTableI.block = new BlockAssemblyTableI(Material.wood).setHardness(3.5F).setStepSound(Block.soundTypeWood);
BlockIDs.assemblyTableII.block = new BlockAssemblyTableII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);
BlockIDs.assemblyTableIII.block = new BlockAssemblyTableIII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);
//TCBlocks.assemblyTableI = new BlockAssemblyTableI(Material.wood).setHardness(3.5F).setStepSound(Block.soundTypeWood);
//TCBlocks.assemblyTableII = new BlockAssemblyTableII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);
//TCBlocks.assemblyTableIII = new BlockAssemblyTableIII(Material.rock).setHardness(3.5F).setStepSound(Block.soundTypeWood);

BlockIDs.trainWorkbench.block = new BlockTrainWorkbench(16).setHardness(1.7F).setStepSound(Block.soundTypeWood);
BlockIDs.stopper.block = new BlockStopper().setHardness(1.7F).setStepSound(Block.soundTypeWood);
Expand Down Expand Up @@ -137,9 +143,8 @@ public static void registerBlocks() {

public static void setHarvestLevels() {
BlockIDs.trainWorkbench.block.setHarvestLevel("axe", 0);
BlockIDs.assemblyTableI.block.setHarvestLevel("axe", 0);
BlockIDs.assemblyTableII.block.setHarvestLevel("axe", 0);
BlockIDs.assemblyTableIII.block.setHarvestLevel("axe", 0);
TCBlocks.assemblyTableII.setHarvestLevel("axe", 0);
TCBlocks.assemblyTableIII.setHarvestLevel("axe", 0);
BlockIDs.waterWheel.block.setHarvestLevel("axe", 0);
BlockIDs.windMill.block.setHarvestLevel("axe", 0);
BlockIDs.oreTC.block.setHarvestLevel("pickaxe", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void load() {

AchievementIDs.engineer.achievement = achievement("engineer", -2, -2, ItemIDs.overalls.item, null);

AchievementIDs.assemblyTable.achievement = achievement("assemblyTable", 6, 0, BlockIDs.assemblyTableI.block, null);
AchievementIDs.assemblyTable.achievement = achievement("assemblyTable", 6, 0, TCBlocks.assemblyTableI, null);
AchievementIDs.passenger.achievement = achievement("passenger", 5, 2, ItemIDs.minecartPassenger2.item, AchievementIDs.assemblyTable.achievement);
AchievementIDs.freight.achievement = achievement("freight", 7, 2, ItemIDs.minecartChest.item, AchievementIDs.assemblyTable.achievement);
AchievementIDs.liquid.achievement = achievement("liquid", 5, 4, ItemIDs.minecartWatertransp.item, AchievementIDs.assemblyTable.achievement);
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/train/common/core/handlers/RecipeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ public static void initBlockRecipes() {
TrainCraftingManager.instance.getRecipeList().add(new RecipesArmorDyes());
/* Assembly tables */
for (ItemStack ironingot : iron) {
GameRegistry.addRecipe(new ItemStack(BlockIDs.assemblyTableI.block, 1), "IPI", "S S", "SPS", 'I', ironingot, 'P', Blocks.piston, 'S', Blocks.stone);
GameRegistry.addRecipe(new ItemStack(TCBlocks.assemblyTableI, 1), "IPI", "S S", "SPS", 'I', ironingot, 'P', Blocks.piston, 'S', Blocks.stone);
}
GameRegistry.addRecipe(new ItemStack(BlockIDs.assemblyTableII.block, 1), "GPG", "O O", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'O', Blocks.obsidian);
GameRegistry.addRecipe(new ItemStack(BlockIDs.assemblyTableIII.block, 1), "GPG", "DLD", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'D', Items.diamond, 'L', Blocks.glowstone, 'O', Blocks.obsidian);
GameRegistry.addRecipe(new ItemStack(TCBlocks.assemblyTableII, 1), "GPG", "O O", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'O', Blocks.obsidian);
GameRegistry.addRecipe(new ItemStack(TCBlocks.assemblyTableIII, 1), "GPG", "DLD", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'D', Items.diamond, 'L', Blocks.glowstone, 'O', Blocks.obsidian);

if (!ConfigHandler.DISABLE_TRAIN_WORKBENCH) {
for (ItemStack ironingot : iron) {
Expand Down Expand Up @@ -333,10 +333,10 @@ public static void initItemRecipes() {
/* Assembly tables */

for (ItemStack ironingot : iron) {
TrainCraftingManager.instance.addRecipe(new ItemStack(BlockIDs.assemblyTableI.block, 1), "IPI", "S S", "SPS", 'I', ironingot, 'P', Blocks.piston, 'S', Blocks.stone);
TrainCraftingManager.instance.addRecipe(new ItemStack(TCBlocks.assemblyTableI, 1), "IPI", "S S", "SPS", 'I', ironingot, 'P', Blocks.piston, 'S', Blocks.stone);
}
TrainCraftingManager.instance.addRecipe(new ItemStack(BlockIDs.assemblyTableII.block, 1), "GPG", "O O", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'O', Blocks.obsidian);
TrainCraftingManager.instance.addRecipe(new ItemStack(BlockIDs.assemblyTableIII.block, 1), "GPG", "DLD", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'D', Items.diamond, 'L', Blocks.glowstone, 'O', Blocks.obsidian);
TrainCraftingManager.instance.addRecipe(new ItemStack(TCBlocks.assemblyTableII, 1), "GPG", "O O", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'O', Blocks.obsidian);
TrainCraftingManager.instance.addRecipe(new ItemStack(TCBlocks.assemblyTableIII, 1), "GPG", "DLD", "OPO", 'G', Items.gold_ingot, 'P', Blocks.piston, 'D', Items.diamond, 'L', Blocks.glowstone, 'O', Blocks.obsidian);

/* Open Hearth Furnace */
TrainCraftingManager.instance.addRecipe(new ItemStack(BlockIDs.openFurnaceIdle.block, 1), "#L#", "#B#", "#I#", '#', Blocks.nether_brick, 'L', Items.lava_bucket, 'B', Items.bucket, 'I', Blocks.iron_block);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/train/common/library/AchievementIDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ public enum AchievementIDs {

openHearth(new Item[] { Item.getItemFromBlock(BlockIDs.openFurnaceIdle.block) }),
trainWB(new Item[] { Item.getItemFromBlock(BlockIDs.trainWorkbench.block) }),
assemblyTable(new Item[] { Item.getItemFromBlock(BlockIDs.assemblyTableI.block),
Item.getItemFromBlock(BlockIDs.assemblyTableII.block),
Item.getItemFromBlock(BlockIDs.assemblyTableIII.block) }),
assemblyTable(new Item[] { Item.getItemFromBlock(TCBlocks.assemblyTableI),
Item.getItemFromBlock(TCBlocks.assemblyTableII),
Item.getItemFromBlock(TCBlocks.assemblyTableIII) }),
engineer(new Item[] { ItemIDs.overalls.item, ItemIDs.hat.item, ItemIDs.jacket.item }),
woodenParts(new Item[] { ItemIDs.woodenBogie.item, ItemIDs.woodenCab.item, ItemIDs.woodenFrame.item,
ItemIDs.seats.item }),
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/train/common/library/BlockIDs.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@

public enum BlockIDs {

assemblyTableI(false, null),
assemblyTableII(false, null),
assemblyTableIII(false, null),

signal(false, null),

//book(true, ItemBlockBook.class),
Expand Down
Loading

0 comments on commit 907e3ea

Please sign in to comment.