Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added battlesign blocks (WIP - no way to edit text) - Fixed the material not loading client side
- Loading branch information
Showing
8 changed files
with
315 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/tconstruct/tools/blocks/BattlesignBlock.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package tconstruct.tools.blocks; | ||
|
||
import java.util.List; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.entity.*; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.tileentity.TileEntity; | ||
import net.minecraft.util.*; | ||
import net.minecraft.world.*; | ||
import tconstruct.tools.logic.BattlesignLogic; | ||
import tconstruct.tools.model.BattlesignRender; | ||
|
||
public class BattlesignBlock extends EquipBlock | ||
{ | ||
|
||
public BattlesignBlock(Material material) | ||
{ | ||
super(material); | ||
|
||
this.setBlockBounds(0.45F, 0F, 0.45F, 0.55F, 1F, 0.55F); | ||
} | ||
|
||
@Override | ||
public int getRenderType () | ||
{ | ||
return BattlesignRender.battlesignModelID; | ||
} | ||
|
||
@Override | ||
public TileEntity createNewTileEntity (World world, int metadata) | ||
{ | ||
return new BattlesignLogic(); | ||
} | ||
|
||
@Override | ||
public void onBlockPlacedBy (World par1World, int par2, int par3, int par4, EntityLivingBase par5EntityLivingBase, ItemStack par6ItemStack) | ||
{ | ||
super.onBlockPlacedBy(par1World, par2, par3, par4, par5EntityLivingBase, par6ItemStack); | ||
int i3 = MathHelper.floor_double((par5EntityLivingBase.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3; | ||
|
||
int newMeta = 0; | ||
|
||
switch (i3) | ||
{ | ||
case 3: | ||
newMeta = 0; | ||
break; | ||
case 0: | ||
newMeta = 3; | ||
break; | ||
case 1: | ||
newMeta = 1; | ||
break; | ||
case 2: | ||
newMeta = 2; | ||
break; | ||
} | ||
par1World.setBlockMetadataWithNotify(par2, par3, par4, newMeta, 2); | ||
} | ||
|
||
@Override | ||
public void setBlockBoundsBasedOnState (IBlockAccess blockAccess, int x, int y, int z) | ||
{ | ||
switch (blockAccess.getBlockMetadata(x, y, z)) | ||
{ | ||
case 0: | ||
setBlockBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F); | ||
break; | ||
case 1: | ||
setBlockBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F); | ||
break; | ||
case 2: | ||
setBlockBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F); | ||
break; | ||
case 3: | ||
setBlockBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB aabb, List list, Entity entity) | ||
{ | ||
setBlockBoundsBasedOnState(world, x, y, z); | ||
|
||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); | ||
setBlockBounds(0.45F, 0F, 0.45F, 0.55F, 1F, 0.55F); | ||
super.addCollisionBoxesToList(world, x, y, z, aabb, list, entity); | ||
|
||
this.setBlockBoundsForItemRender(); | ||
} | ||
|
||
@Override | ||
public TileEntity createTileEntity (World world, int metadata) | ||
{ | ||
return new BattlesignLogic(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
src/main/java/tconstruct/tools/model/BattlesignRender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package tconstruct.tools.model; | ||
|
||
import cpw.mods.fml.client.registry.*; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.world.IBlockAccess; | ||
|
||
public class BattlesignRender implements ISimpleBlockRenderingHandler | ||
{ | ||
public static int battlesignModelID = RenderingRegistry.getNextAvailableRenderId(); | ||
|
||
@Override | ||
public void renderInventoryBlock (Block block, int metadata, int modelID, RenderBlocks renderer) | ||
{ | ||
// Inventory should be an item. This is not here! | ||
} | ||
|
||
@Override | ||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelID, RenderBlocks renderer) | ||
{ | ||
renderer.setRenderBounds(0.45F, 0.0F, 0.45F, 0.55F, 1.125F, 0.55F); | ||
renderer.renderStandardBlock(block, x, y, z); | ||
renderFace(world, x, y, z, block, renderer); | ||
return true; | ||
} | ||
|
||
public void renderFace (IBlockAccess world, int x, int y, int z, Block block, RenderBlocks renderer) | ||
{ | ||
switch (world.getBlockMetadata(x, y, z)) | ||
{ | ||
case 0: | ||
renderer.setRenderBounds(0.42F, 0.5F, 0F, 0.50F, 1.1F, 1F); | ||
break; | ||
case 1: | ||
renderer.setRenderBounds(0.50F, 0.5F, 0F, 0.58F, 1.1F, 1F); | ||
break; | ||
case 2: | ||
renderer.setRenderBounds(0F, 0.5F, 0.50F, 1F, 1.1F, 0.58F); | ||
break; | ||
case 3: | ||
renderer.setRenderBounds(0F, 0.5F, 0.42F, 1F, 1.1F, 0.50F); | ||
break; | ||
} | ||
|
||
renderer.renderStandardBlock(block, x, y, z); | ||
} | ||
|
||
@Override | ||
public boolean shouldRender3DInInventory (int modelid) | ||
{ | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getRenderId () | ||
{ | ||
return battlesignModelID; | ||
} | ||
} |
Oops, something went wrong.
4c4b3f0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might close #920?