-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
146 additions
and
1 deletion.
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
59 changes: 59 additions & 0 deletions
59
src/com/jaquadro/minecraft/gardenstuff/block/BlockHoop.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 com.jaquadro.minecraft.gardenstuff.block; | ||
|
||
import com.jaquadro.minecraft.gardencore.api.block.IChainAttachable; | ||
import com.jaquadro.minecraft.gardencore.core.ModCreativeTabs; | ||
import com.jaquadro.minecraft.gardenstuff.GardenStuff; | ||
import com.jaquadro.minecraft.gardenstuff.core.ClientProxy; | ||
import com.jaquadro.minecraft.gardenstuff.core.ModBlocks; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraft.util.Vec3; | ||
|
||
public class BlockHoop extends Block implements IChainAttachable | ||
{ | ||
public BlockHoop (String name) { | ||
super(Material.iron); | ||
|
||
setBlockName(name); | ||
setHardness(2.5f); | ||
setResistance(5f); | ||
setStepSound(soundTypeMetal); | ||
setBlockBounds(0, .0625f, 0, 1, .375f, 1); | ||
setBlockTextureName(GardenStuff.MOD_ID + "hoop"); | ||
setCreativeTab(ModCreativeTabs.tabGardenCore); | ||
} | ||
|
||
@Override | ||
public boolean isOpaqueCube () { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean renderAsNormalBlock () { | ||
return false; | ||
} | ||
|
||
@Override | ||
public int getRenderType () { | ||
return ClientProxy.hoopRenderID; | ||
} | ||
|
||
@Override | ||
public IIcon getIcon (int side, int meta) { | ||
return ModBlocks.metalBlock.getIcon(side, meta); | ||
} | ||
|
||
private Vec3[] attachPoints = new Vec3[] { | ||
Vec3.createVectorHelper(.03125, .375f, .03125), Vec3.createVectorHelper(.03125, .375f, 1 - .03125), | ||
Vec3.createVectorHelper(1 - .03125, .375f, .03125), Vec3.createVectorHelper(1 - .03125, .375f, 1 - .03125), | ||
}; | ||
|
||
@Override | ||
public Vec3[] getChainAttachPoints (int side) { | ||
if (side == 1) | ||
return attachPoints; | ||
|
||
return null; | ||
} | ||
} |
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
64 changes: 64 additions & 0 deletions
64
src/com/jaquadro/minecraft/gardenstuff/renderer/HoopRenderer.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,64 @@ | ||
package com.jaquadro.minecraft.gardenstuff.renderer; | ||
|
||
import com.jaquadro.minecraft.gardencore.client.renderer.support.ModularBoxRenderer; | ||
import com.jaquadro.minecraft.gardenstuff.block.BlockHoop; | ||
import com.jaquadro.minecraft.gardenstuff.core.ClientProxy; | ||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; | ||
import net.minecraft.block.Block; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.world.IBlockAccess; | ||
import org.lwjgl.opengl.GL11; | ||
|
||
public class HoopRenderer implements ISimpleBlockRenderingHandler | ||
{ | ||
private ModularBoxRenderer boxrender = new ModularBoxRenderer(); | ||
|
||
@Override | ||
public void renderInventoryBlock (Block block, int metadata, int modelId, RenderBlocks renderer) { | ||
if (!(block instanceof BlockHoop)) | ||
return; | ||
|
||
renderInventoryBlock((BlockHoop) block, metadata, modelId, renderer); | ||
} | ||
|
||
private void renderInventoryBlock (BlockHoop block, int metadata, int modelId, RenderBlocks renderer) { | ||
GL11.glRotatef(90, 0, 1, 0); | ||
GL11.glTranslatef(-.5f, -.5f, -.5f); | ||
|
||
boxrender.setUnit(0.0625f); | ||
boxrender.setIcon(block.getIcon(0, 0)); | ||
boxrender.setColor(ModularBoxRenderer.COLOR_WHITE); | ||
|
||
boxrender.renderBox(null, block, 0, 0, 0, 0, .0625f, 0, 1, .375f, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS); | ||
|
||
GL11.glTranslatef(.5f, .5f, .5f); | ||
} | ||
|
||
@Override | ||
public boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { | ||
if (!(block instanceof BlockHoop)) | ||
return false; | ||
|
||
return renderWorldBlock(world, x, y, z, (BlockHoop) block, modelId, renderer); | ||
} | ||
|
||
private boolean renderWorldBlock (IBlockAccess world, int x, int y, int z, BlockHoop block, int modelId, RenderBlocks renderer) { | ||
boxrender.setUnit(0.0625f); | ||
boxrender.setIcon(block.getIcon(0, 0)); | ||
boxrender.setColor(ModularBoxRenderer.COLOR_WHITE); | ||
|
||
boxrender.renderBox(world, block, x, y, z, 0, .0625f, 0, 1, .375f, 1, 0, ModularBoxRenderer.CUT_YNEG | ModularBoxRenderer.CUT_YPOS); | ||
|
||
return true; | ||
} | ||
|
||
@Override | ||
public boolean shouldRender3DInInventory (int modelId) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int getRenderId () { | ||
return ClientProxy.hoopRenderID; | ||
} | ||
} |
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