Skip to content

Commit

Permalink
misc fixes
Browse files Browse the repository at this point in the history
- Moved a couple more blocks to the new API
- Removed some unused texture registrations
- Fixed a couple errors during initialization, they didn't cause any real problems but the errors slowed init a lot and flooded the game logs.
  • Loading branch information
EternalBlueFlame committed Jul 20, 2024
1 parent 8831451 commit 94346f5
Show file tree
Hide file tree
Showing 37 changed files with 99 additions and 227 deletions.
7 changes: 4 additions & 3 deletions src/main/java/train/client/core/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import train.common.adminbook.GUIAdminBook;
import train.common.api.EntityBogie;
import train.common.api.EntityRollingStock;
import train.common.blocks.TCBlocks;
import train.common.core.CommonProxy;
import train.common.core.Traincraft_EventSounds;
import train.common.core.handlers.ConfigHandler;
Expand Down Expand Up @@ -183,13 +184,13 @@ public void registerRenderInformation() {
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.signal.block), new ItemRenderSignal());

ClientRegistry.bindTileEntitySpecialRenderer(TileLantern.class, new RenderLantern());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.lantern.block), new ItemRenderLantern());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(TCBlocks.lantern), new ItemRenderLantern());

ClientRegistry.bindTileEntitySpecialRenderer(TileSwitchStand.class, new RenderSwitchStand());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.switchStand.block), new ItemRenderSwitchStand());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(TCBlocks.switchStand), new ItemRenderSwitchStand());

ClientRegistry.bindTileEntitySpecialRenderer(TileMFPBWigWag.class, new RenderMFPBWigWag());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.MFPBWigWag.block), new ItemRenderMFPBWigWag());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(TCBlocks.MFPBWigWag), new ItemRenderMFPBWigWag());

ClientRegistry.bindTileEntitySpecialRenderer(TileWaterWheel.class, new RenderWaterWheel());
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(BlockIDs.waterWheel.block), new ItemRenderWaterWheel());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ public RecipeBookHandler() {
vanillaWorkTableRecipes[7] = ItemIDs.jacket.item.getUnlocalizedName();
vanillaWorkTableRecipes[8] = ItemIDs.hat.item.getUnlocalizedName();
vanillaWorkTableRecipes[11] = ItemIDs.recipeBook.item.getUnlocalizedName();
vanillaWorkTableRecipes[12] = BlockIDs.lantern.block.getUnlocalizedName();
vanillaWorkTableRecipes[12] = TCBlocks.lantern.getUnlocalizedName();
vanillaWorkTableRecipes[14] = ItemIDs.pants_driver_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[15] = ItemIDs.pants_ticketMan_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[16] = ItemIDs.hat_driver_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[17] = ItemIDs.hat_ticketMan_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[18] = ItemIDs.jacket_driver_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[19] = ItemIDs.jacket_ticketMan_paintable.item.getUnlocalizedName();
vanillaWorkTableRecipes[20] = BlockIDs.switchStand.block.getUnlocalizedName();
vanillaWorkTableRecipes[20] = TCBlocks.switchStand.getUnlocalizedName();
}

// TODO: Make parameters more specific than List
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/train/common/blocks/BlockBridgePillar.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int






@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}

@Override
public IIcon getIcon(int i, int j) {
return texture;
Expand Down
25 changes: 14 additions & 11 deletions src/main/java/train/common/blocks/BlockLantern.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,26 @@
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import train.common.Traincraft;
import train.common.api.blocks.BlockDynamic;
import train.common.items.ItemWrench;
import train.common.library.GuiIDs;
import train.common.library.Info;
import train.common.tile.TileLantern;

import java.util.Random;

public class BlockLantern extends Block {
public class BlockLantern extends BlockDynamic {
private IIcon texture;

public BlockLantern() {
super(Material.rock);
setCreativeTab(Traincraft.tcTab);
super(Material.rock,0);
this.setTickRandomly(true);
float f = 0.3F;
this.setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f * 3.0F, 0.5F + f);
setLightLevel(0.98F);
}

@Override
public float[] hitboxShape(){return new float[]{0.3f,0,0.3f,0.7f,0.9f,0.7f};}

@Override
public boolean hasTileEntity(int metadata) {
return true;
Expand All @@ -47,6 +49,10 @@ public boolean isOpaqueCube() {
public TileEntity createTileEntity(World world, int metadata) {
return new TileLantern();
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileLantern();
}

@Override
public int getRenderType() {
Expand All @@ -59,12 +65,9 @@ public int getRenderType() {
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {
double d0 = (double) ((float) par2 + 0.5F);
double d2 = (double) ((float) par4 + 0.5F);
double d3 = 0.2199999988079071D;

par1World.spawnParticle("smoke", d0, par3 + d3, d2, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", d0, par3 + d3, d2, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("smoke", par2 + 0.5F, par3 + 0.2199999988079071D, par4 + 0.5F, 0.0D, 0.0D, 0.0D);
par1World.spawnParticle("flame", par2 + 0.5F, par3 + 0.2199999988079071D, par4 + 0.5F, 0.0D, 0.0D, 0.0D);

}
@Override
Expand All @@ -74,7 +77,7 @@ public boolean onBlockActivated(World world, int i, int j, int k, EntityPlayer p
return false;
}
if(player!=null && player.getCurrentEquippedItem()!=null && player.getCurrentEquippedItem().getItem() instanceof ItemWrench)
if (te != null && te instanceof TileLantern) {
if (te instanceof TileLantern) {
player.openGui(Traincraft.instance, GuiIDs.LANTERN, world, i, j, k);
}
return true;
Expand Down
30 changes: 4 additions & 26 deletions src/main/java/train/common/blocks/BlockMFPBWigWag.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,23 @@
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.Info;
import train.common.tile.TileMFPBWigWag;

import java.util.List;
import java.util.Random;

public class BlockMFPBWigWag extends Block {
private IIcon texture;
public class BlockMFPBWigWag extends BlockDynamic {

public BlockMFPBWigWag() {
super(Material.rock);
super(Material.rock,0);
setCreativeTab(Traincraft.tcTab);
this.setTickRandomly(true);
//this.setBlockBounds(0.5F , 0.0F, 0.5F , 0.5F , 2.0F, 0.5F);
}

@Override
public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
{
}
public float[] hitboxShape(){return new float[]{0,0,0,1,2,1};}

@Override
public boolean hasTileEntity(int metadata) {
Expand All @@ -61,14 +58,6 @@ public int getRenderType() {
return -1;
}

@SideOnly(Side.CLIENT)
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {

}


@Override
Expand All @@ -81,15 +70,4 @@ public void onBlockPlacedBy(World world, int i, int j, int k, EntityLivingBase e
world.markBlockForUpdate(i, j, k);
}
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}

@Override
public IIcon getIcon(int i, int j) {
return texture;
}
}
6 changes: 1 addition & 5 deletions src/main/java/train/common/blocks/BlockMetroMadridPole.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,7 @@ public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int



@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
34 changes: 11 additions & 23 deletions src/main/java/train/common/blocks/BlockSwitchStand.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockLever;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
Expand All @@ -14,26 +15,25 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import train.common.Traincraft;
import train.common.api.blocks.BlockDynamic;
import train.common.api.blocks.BlockSwitch;
import train.common.library.Info;
import train.common.tile.TileSwitchStand;

import java.util.List;
import java.util.Random;

public class BlockSwitchStand extends BlockLever {
private IIcon texture;
public class BlockSwitchStand extends BlockSwitch {

public BlockSwitchStand() {
super();
super(Material.wood, 0);
setCreativeTab(Traincraft.tcTab);
this.setTickRandomly(true);
//this.setBlockBounds(0.5F , 0.0F, 0.5F , 0.5F , 2.0F, 0.5F);
}

@Override
public void addCollisionBoxesToList(World p_149743_1_, int p_149743_2_, int p_149743_3_, int p_149743_4_, AxisAlignedBB p_149743_5_, List p_149743_6_, Entity p_149743_7_)
{
}
public float[] hitboxShape(){return new float[]{0,0,0,1,2,1};}


@Override
public boolean hasTileEntity(int metadata) {
Expand All @@ -54,20 +54,18 @@ public boolean isOpaqueCube() {
public TileEntity createTileEntity(World world, int metadata) {
return new TileSwitchStand();
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileSwitchStand();
}

@Override
public int getRenderType() {
return -1;
}

@SideOnly(Side.CLIENT)
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random) {

}


@Override
Expand All @@ -89,14 +87,4 @@ public boolean canProvidePower()
return true;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}

@Override
public IIcon getIcon(int i, int j) {
return texture;
}
}
10 changes: 6 additions & 4 deletions src/main/java/train/common/blocks/TCBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ public static void init() {
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 Block trainWorkbench=new BlockTrainWorkbench(16).setHardness(1.7F).setStepSound(Block.soundTypeWood);
public static Block lantern=new BlockLantern().setHardness(1.7F).setStepSound(Block.soundTypeMetal);
public static Block switchStand=new BlockSwitchStand().setHardness(1.7F).setStepSound(Block.soundTypeMetal);
public static Block MFPBWigWag=new BlockMFPBWigWag().setHardness(2.5F).setStepSound(Block.soundTypeMetal);

public static void loadBlocks() {
TraincraftRegistry.registerBlock(bridgePillar,Traincraft.tcTab, Info.modID,"bridgePillar");
Expand All @@ -49,13 +52,12 @@ public static void loadBlocks() {
TraincraftRegistry.registerBlock(trainWorkbench,Traincraft.tcTab, Info.modID,"trainWorkbench");
TraincraftRegistry.registerBlock(openFurnaceIdle,Traincraft.tcTab, Info.modID,"openFurnaceIdle");
TraincraftRegistry.registerBlock(openFurnaceActive,null, Info.modID,"openFurnaceActive");
TraincraftRegistry.registerBlock(lantern,Traincraft.tcTab, Info.modID,"lantern");
TraincraftRegistry.registerBlock(switchStand,Traincraft.tcTab, Info.modID,"switchStand");
TraincraftRegistry.registerBlock(MFPBWigWag,Traincraft.tcTab, Info.modID,"MFPBWigWag");




BlockIDs.lantern.block = new BlockLantern().setHardness(1.7F).setStepSound(Block.soundTypeMetal).setLightLevel(0.98F);
BlockIDs.switchStand.block = new BlockSwitchStand().setHardness(1.7F).setStepSound(Block.soundTypeMetal);
BlockIDs.MFPBWigWag.block = new BlockMFPBWigWag().setHardness(2.5F).setStepSound(Block.soundTypeMetal);
BlockIDs.waterWheel.block = new BlockWaterWheel().setHardness(1.7F).setStepSound(Block.soundTypeWood);
BlockIDs.windMill.block = new BlockWindMill().setHardness(1.7F).setStepSound(Block.soundTypeWood);
BlockIDs.generatorDiesel.block = new BlockGeneratorDiesel().setHardness(1.7F).setStepSound(Block.soundTypeMetal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,6 @@ public boolean canProvidePower()
return true;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}

@Override
public IIcon getIcon(int i, int j) {
return texture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int



@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}

@Override
public IIcon getIcon(int i, int j) {
return texture;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ public boolean canProvidePower()
return true;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ public boolean canProvidePower()
return true;
}

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,7 @@ public void updateTick(World world, int i, int j, int k) {
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ else if (i1 != 5 && i1 != 6)
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/

@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
texture = iconRegister.registerIcon(Info.modID.toLowerCase() + ":assembly_1_bottom");
}


@Override
public IIcon getIcon(int i, int j) {
Expand Down
Loading

0 comments on commit 94346f5

Please sign in to comment.