Skip to content

Commit

Permalink
block fixes
Browse files Browse the repository at this point in the history
- Fixed a collision bug with blocks that prevented standing on top of them, and added some notes how to make complex collision shapes for blocks, a better system should be made later.
- Furnace and train workbench have been moved to the new block system
  • Loading branch information
EternalBlueFlame committed Jul 20, 2024
1 parent e4a90a3 commit 1a96497
Show file tree
Hide file tree
Showing 32 changed files with 136 additions and 264 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public RecipeBookHandler() {
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();
vanillaWorkTableRecipes[4] = TCBlocks.openFurnaceIdle.getUnlocalizedName();
vanillaWorkTableRecipes[5] = TCBlocks.trainWorkbench.getUnlocalizedName();
vanillaWorkTableRecipes[6] = ItemIDs.overalls.item.getUnlocalizedName();
vanillaWorkTableRecipes[7] = ItemIDs.jacket.item.getUnlocalizedName();
vanillaWorkTableRecipes[8] = ItemIDs.hat.item.getUnlocalizedName();
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/train/client/gui/GuiRecipeBook.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {
addPage("Welcome to the Traincraft guide! \nThis book contains everything you need to know about Traincraft.\n\nAuthors:\nSpitfire4466,\nMrbrutal\n\nBukkit port: \nDV8FromTheWorld\n\nThanks to CovertJaguar for his help and a great API.\n", "", "left", new ArrayList<StackToDraw>() {
{
add(new StackToDraw(new ItemStack(ItemIDs.minecartLocoBR80_DB.item), 20, 16));
add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 170, 16));
add(new StackToDraw(new ItemStack(TCBlocks.trainWorkbench), 170, 16));
add(new StackToDraw(new ItemStack(ItemIDs.minecartCabooseWork.item), 60, 175));
add(new StackToDraw(new ItemStack(ItemIDs.minecartTankWagon_DB.item), 80, 175));
add(new StackToDraw(new ItemStack(ItemIDs.minecartFlatCartRail_DB.item), 100, 175));
Expand Down Expand Up @@ -272,16 +272,16 @@ 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(TCBlocks.trainWorkbench), 20, 16));
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>() {
{
add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceIdle.block), 20, 16));
add(new StackToDraw(new ItemStack(BlockIDs.openFurnaceActive.block), 80, 155));
add(new StackToDraw(new ItemStack(TCBlocks.openFurnaceIdle), 20, 16));
add(new StackToDraw(new ItemStack(TCBlocks.openFurnaceActive), 80, 155));
add(new StackToDraw(new ItemStack(ItemIDs.graphite.item), 70, 135));
add(new StackToDraw(new ItemStack(Items.iron_ingot), 90, 135));
add(new StackToDraw(new ItemStack(Items.coal), 80, 175));
Expand Down Expand Up @@ -374,7 +374,7 @@ public GuiRecipeBook(EntityPlayer par1EntityPlayer, ItemStack par2ItemStack) {

addPage("On the following pages you will find all the train workbench recipes and assembly table recipes.\nIt is however strongly suggested to try to discover the recipes by yourself...\n\nWe hope you will enjoy the mod!\n\nSpitfire4466 and MrBrutal", "", "left", new ArrayList<StackToDraw>() {
{
add(new StackToDraw(new ItemStack(BlockIDs.trainWorkbench.block), 20, 16));
add(new StackToDraw(new ItemStack(TCBlocks.trainWorkbench), 20, 16));
add(new StackToDraw(new ItemStack(ItemIDs.hat.item), 40, 155));
add(new StackToDraw(new ItemStack(ItemIDs.jacket.item), 90, 155));
add(new StackToDraw(new ItemStack(ItemIDs.overalls.item), 140, 155));
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/train/common/api/blocks/BlockDynamic.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,14 @@ public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y,
@Override
public void addCollisionBoxesToList(World world, int x, int y, int z, AxisAlignedBB hitboxSelf, List p_149743_6_, Entity collidingEntity) {
this.setBlockBoundsBasedOnState(world, x, y, z);
p_149743_6_.add(this.getCollisionBoundingBoxFromPool(world, x, y, z));
//if there's multiple hitboxes, ex stairs, this needs to be done for each
if(hitboxSelf.intersectsWith(this.getCollisionBoundingBoxFromPool(world, x, y, z))) {
p_149743_6_.add(this.getCollisionBoundingBoxFromPool(world, x, y, z));
}
}
@Override
public boolean getBlocksMovement(IBlockAccess p_149655_1_, int p_149655_2_, int p_149655_3_, int p_149655_4_) {
return hitboxShape()[4]>1;
return hitboxShape()[4]>=1;
}

@Override
Expand Down
74 changes: 0 additions & 74 deletions src/main/java/train/common/blocks/BlockDistil.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,82 +35,18 @@ public class BlockDistil extends BlockDynamic {
private final boolean isActive;
private static boolean keepDistilInventory = false;
private Random distilRand;

private IIcon textureTop;
private IIcon textureBottom;
private IIcon textureFront_off;
private IIcon textureFront_on;
private IIcon textureSide;
private IIcon textureBack;

public BlockDistil(int j, boolean flag) {
super(Material.anvil,j);
isActive = flag;
distilRand = new Random();
//setRequiresSelfNotify();

if (isActive) {
setLightLevel(0.8F);
} else {
setCreativeTab(Traincraft.tcTab);
}
}

@Override
public Item getItemDropped(int i, Random random, int j) {
return Item.getItemFromBlock(TCBlocks.distilIdle);
}

@Override
public IIcon getIcon(int i, int j) {
if (!this.isActive) {
if (i == 1) {
return textureTop;
}
if (i == 0) {
return textureBottom;
}
if (i == 4) {
return textureBack;
}
if (i == 3) {
return textureFront_off;
}
else {
return textureSide;
}
}
else {
if (i == 1) {
return textureTop;
}
if (i == 0) {
return textureBottom;
}
if (i == 4) {
return textureBack;
}
if (i == 3) {
return textureFront_on;
}
else {
return textureSide;
}
}
}

@Override
public IIcon getIcon(IBlockAccess worldAccess, int i, int j, int k, int side) {
if (((TileEntityDistil) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileEntityDistil) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
if (!this.isActive) {
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 4 ? textureSide : side == 5 ? textureSide : side == 3 ? textureFront_off : textureBack;
}
else {
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 4 ? textureSide : side == 5 ? textureSide : side == 3 ? textureFront_on : textureBack;
}
}

@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
Expand Down Expand Up @@ -244,14 +180,4 @@ public TileEntity createTileEntity(World world, int metadata) {
return new TileEntityDistil();
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_bottom");
textureFront_off = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_off_front");
textureFront_on = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_on_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_side");
textureBack = iconRegister.registerIcon(Info.modID.toLowerCase() + ":distil_bottom");
}
}
87 changes: 18 additions & 69 deletions src/main/java/train/common/blocks/BlockOpenHearthFurnace.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import ebf.tim.utility.CommonUtil;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.item.EntityItem;
Expand All @@ -21,10 +23,12 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
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.BlockIDs;
import train.common.library.GuiIDs;
import train.common.library.Info;
Expand All @@ -33,80 +37,23 @@

import java.util.Random;

public class BlockOpenHearthFurnace extends BlockContainer {
public class BlockOpenHearthFurnace extends BlockDynamic {

private final boolean isActive;
private static boolean keepFurnaceInventory = false;
private Random furnaceRand;

private IIcon textureTop_off;
private IIcon textureTop_on;
private IIcon textureBottom;
private IIcon textureFront_off;
private IIcon textureFront_on;
private IIcon textureSide;

protected BlockOpenHearthFurnace(boolean active) {
super(Material.rock);
super(Material.rock,0);
furnaceRand = new Random();
//setRequiresSelfNotify();
isActive = active;
if (isActive) {
setLightLevel(0.8F);
} else {
setCreativeTab(Traincraft.tcTab);
}
}

@Override
public Item getItemDropped(int i, Random random, int j) {
return Item.getItemFromBlock(BlockIDs.openFurnaceIdle.block);
return Item.getItemFromBlock(TCBlocks.openFurnaceIdle);
}

@Override
public IIcon getIcon(int i, int j) {
if (!this.isActive) {
if (i == 1) {
return textureTop_off;
}
if (i == 0) {
return textureBottom;
}
if (i == 3) {
return textureFront_off;
}
else {
return textureSide;
}
}
else {
if (i == 1) {
return textureTop_on;
}
if (i == 0) {
return textureBottom;
}
if (i == 3) {
return textureFront_on;
}
else {
return textureSide;
}
}
}

@Override
public IIcon getIcon(IBlockAccess worldAccess, int i, int j, int k, int side) {
if (((TileEntityOpenHearthFurnace) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileEntityOpenHearthFurnace) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
if (!this.isActive) {
return side == 1 ? textureTop_off : side == 0 ? textureBottom : side == 3 ? textureFront_off : textureSide;
}
else {
return side == 1 ? textureTop_on : side == 0 ? textureBottom : side == 3 ? textureFront_on : textureSide;
}
}

public static void updateHearthFurnaceBlockState(boolean flag, World world, int i, int j, int k, Random random) {
int l = world.getBlockMetadata(i, j, k);
Expand All @@ -115,10 +62,10 @@ public static void updateHearthFurnaceBlockState(boolean flag, World world, int
keepFurnaceInventory = true;

if (flag) {
world.setBlock(i, j, k, BlockIDs.openFurnaceActive.block);
world.setBlock(i, j, k, TCBlocks.openFurnaceActive);
}
else {
world.setBlock(i, j, k, BlockIDs.openFurnaceIdle.block);
world.setBlock(i, j, k, TCBlocks.openFurnaceIdle);
}
keepFurnaceInventory = false;
world.setBlockMetadataWithNotify(i, j, k, l, 0);
Expand Down Expand Up @@ -198,14 +145,16 @@ public TileEntity createNewTileEntity(World var1, int i) {
return new TileEntityOpenHearthFurnace();
}

@Override
public TileEntity createTileEntity(World var1, int i) {
return new TileEntityOpenHearthFurnace();
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop_off = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_off_top");
textureTop_on = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_on_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_bottom");
textureFront_off = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_off_front");
textureFront_on = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_on_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":furnace_side");
public ResourceLocation getTexture(int x, int y, int z){
return new ResourceLocation(Info.modID,
((x==0&&y==0&&z==0)|| CommonUtil.getBlockAt(Minecraft.getMinecraft().theWorld,x,y,z)==TCBlocks.distilActive)?
"textures/blocks/furnace_on.png":"textures/blocks/furnace_off.png");
}

}
44 changes: 8 additions & 36 deletions src/main/java/train/common/blocks/BlockTrainWorkbench.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,52 +13,28 @@
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
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.TileHelper;
import train.common.tile.TileTrainWbench;

import java.util.Random;

public class BlockTrainWorkbench extends BlockContainer {
public class BlockTrainWorkbench extends BlockDynamic {

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

public BlockTrainWorkbench(int j) {
super(Material.wood);
super(Material.wood,0);
setCreativeTab(Traincraft.tcTab);
setHarvestLevel("axe", 0);
}

@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 (((TileTrainWbench) worldAccess.getTileEntity(i, j, k)).getFacing() != null) {
side = TileHelper.getOrientationFromSide(((TileTrainWbench) worldAccess.getTileEntity(i, j, k)).getFacing(), ForgeDirection.getOrientation(side)).ordinal();
}
return side == 1 ? textureTop : side == 0 ? textureBottom : side == 3 ? textureFront : textureSide;
}

@Override
public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer player, int par6, float par7, float par8, float par9) {
Expand Down Expand Up @@ -128,13 +104,9 @@ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase e
public TileEntity createNewTileEntity(World world, int meta) {
return new TileTrainWbench();
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Info.modID.toLowerCase() + ":train_table_top");
textureBottom = iconRegister.registerIcon(Info.modID.toLowerCase() + ":train_table_bottom");
textureFront = iconRegister.registerIcon(Info.modID.toLowerCase() + ":train_table_front");
textureSide = iconRegister.registerIcon(Info.modID.toLowerCase() + ":train_table_side");
public TileEntity createTileEntity(World world, int meta) {
return new TileTrainWbench();
}

}
Loading

0 comments on commit 1a96497

Please sign in to comment.