forked from KryptonCaptain/Et-Futurum
-
Notifications
You must be signed in to change notification settings - Fork 47
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
1 parent
336ae79
commit 85ed813
Showing
20 changed files
with
523 additions
and
33 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
50 changes: 50 additions & 0 deletions
50
src/main/java/ganymedes01/etfuturum/blocks/BlockMangroveRoots.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,50 @@ | ||
package ganymedes01.etfuturum.blocks; | ||
|
||
import ganymedes01.etfuturum.client.sound.ModSounds; | ||
import ganymedes01.etfuturum.lib.RenderIDs; | ||
import net.minecraft.block.material.Material; | ||
import net.minecraft.client.renderer.texture.IIconRegister; | ||
import net.minecraft.util.IIcon; | ||
|
||
public class BlockMangroveRoots extends BaseBlock { | ||
|
||
private IIcon sideIcon; | ||
|
||
public BlockMangroveRoots() { | ||
super(Material.wood); | ||
setLightOpacity(1); | ||
setResistance(0.7F); | ||
setHardness(0.7F); | ||
setNames("mangrove_roots"); | ||
setBlockSound(ModSounds.soundMangroveRoots); | ||
} | ||
|
||
@Override | ||
public boolean renderAsNormalBlock() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public boolean isOpaqueCube() { | ||
return false; | ||
} | ||
|
||
@Override | ||
public IIcon getIcon(int side, int meta) { | ||
if (side < 2) { | ||
return blockIcon; | ||
} | ||
return sideIcon; | ||
} | ||
|
||
@Override | ||
public void registerBlockIcons(IIconRegister reg) { | ||
blockIcon = reg.registerIcon(getTextureName() + "_top"); | ||
sideIcon = reg.registerIcon(getTextureName() + "_side"); | ||
} | ||
|
||
@Override | ||
public int getRenderType() { | ||
return RenderIDs.MANGROVE_ROOTS; | ||
} | ||
} |
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
121 changes: 121 additions & 0 deletions
121
src/main/java/ganymedes01/etfuturum/blocks/BlockPinkPetals.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,121 @@ | ||
package ganymedes01.etfuturum.blocks; | ||
|
||
import ganymedes01.etfuturum.client.sound.ModSounds; | ||
import ganymedes01.etfuturum.core.utils.Utils; | ||
import ganymedes01.etfuturum.lib.RenderIDs; | ||
import net.minecraft.block.IGrowable; | ||
import net.minecraft.client.renderer.IconFlipped; | ||
import net.minecraft.client.renderer.texture.IIconRegister; | ||
import net.minecraft.entity.EntityLivingBase; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.item.Item; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.AxisAlignedBB; | ||
import net.minecraft.util.IIcon; | ||
import net.minecraft.util.MathHelper; | ||
import net.minecraft.world.IBlockAccess; | ||
import net.minecraft.world.World; | ||
|
||
import java.util.Random; | ||
|
||
public class BlockPinkPetals extends BaseFlower implements IGrowable { | ||
|
||
private IIcon stemIcon; | ||
|
||
public BlockPinkPetals() { | ||
super(); | ||
setNames("pink_petals"); | ||
Utils.setBlockSound(this, ModSounds.soundPinkPetals); | ||
} | ||
|
||
@Override | ||
public boolean isReplaceable(IBlockAccess world, int x, int y, int z) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public void registerBlockIcons(IIconRegister reg) { | ||
blockIcon = new IconFlipped(reg.registerIcon(getTextureName()), true, false); | ||
stemIcon = reg.registerIcon(getTextureName() + "_stem"); | ||
} | ||
|
||
@Override | ||
public IIcon getIcon(int side, int meta) { | ||
return side == 7 ? stemIcon : blockIcon; | ||
} | ||
|
||
@Override | ||
public void onBlockPlacedBy(World p_149689_1_, int p_149689_2_, int p_149689_3_, int p_149689_4_, EntityLivingBase p_149689_5_, ItemStack p_149689_6_) { | ||
int ordinal = MathHelper.floor_double((double) (p_149689_5_.rotationYaw / 90.0F) + 0.5D) & 3; | ||
switch (ordinal) { | ||
case 1: | ||
ordinal = 8; | ||
break; | ||
case 2: | ||
ordinal = 12; | ||
break; | ||
case 3: | ||
ordinal = 4; | ||
break; | ||
} | ||
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, ordinal, 2); | ||
} | ||
|
||
@Override | ||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_) { | ||
if (player.getHeldItem() != null && player.getHeldItem().getItem() == Item.getItemFromBlock(this)) { | ||
int meta = world.getBlockMetadata(x, y, z); | ||
if (meta % 4 < 3) { | ||
world.playSound((float) x + 0.5F, (float) y + 0.5F, (float) z + 0.5F, stepSound.func_150496_b(), (stepSound.getVolume() + 1.0F) / 2.0F, stepSound.getPitch() * 0.8F, false); | ||
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 3); | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
@Override | ||
public int quantityDropped(int meta, int fortune, Random random) { | ||
return (meta % 4) + 1; | ||
} | ||
|
||
@Override | ||
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) { | ||
setBlockBounds(0, 0, 0, 1, 0.1875F, 1); | ||
} | ||
|
||
@Override | ||
public AxisAlignedBB getSelectedBoundingBoxFromPool(World p_149633_1_, int p_149633_2_, int p_149633_3_, int p_149633_4_) { | ||
return AxisAlignedBB.getBoundingBox(p_149633_2_, p_149633_3_, p_149633_4_, 1 + p_149633_2_, 0.1875 + p_149633_3_, 1 + p_149633_4_); | ||
} | ||
|
||
@Override | ||
public String getItemIconName() { | ||
return getTextureName(); | ||
} | ||
|
||
@Override | ||
public int getRenderType() { | ||
return RenderIDs.PINK_PETALS; | ||
} | ||
|
||
@Override | ||
public boolean func_149851_a(World world, int x, int y, int z, boolean p_149851_5_) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public boolean func_149852_a(World world, Random random, int x, int y, int z) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public void func_149853_b(World world, Random random, int x, int y, int z) { | ||
int meta = world.getBlockMetadata(x, y, z); | ||
if (meta % 4 < 3) { | ||
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 3); | ||
} else { | ||
dropBlockAsItem(world, x, y, z, new ItemStack(getItemDropped(meta, random, 0), 1, quantityDropped(meta, 0, random))); | ||
} | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
src/main/java/ganymedes01/etfuturum/client/renderer/block/BlockMangroveRootsRenderer.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,44 @@ | ||
package ganymedes01.etfuturum.client.renderer.block; | ||
|
||
import net.minecraft.block.Block; | ||
import net.minecraft.client.renderer.RenderBlocks; | ||
import net.minecraft.world.IBlockAccess; | ||
|
||
public class BlockMangroveRootsRenderer extends BlockModelBase { | ||
public BlockMangroveRootsRenderer(int renderID) { | ||
super(renderID); | ||
} | ||
|
||
@Override | ||
protected void renderInventoryModel(Block block, int meta, int modelId, RenderBlocks renderer, double minX, double minY, double minZ, double maxX, double maxY, double maxZ) { | ||
super.renderInventoryModel(block, meta, modelId, renderer, minX, minY, minZ, maxX, maxY, maxZ); | ||
boolean prev = renderer.renderFromInside; | ||
renderer.renderFromInside = true; | ||
super.renderInventoryModel(block, meta, modelId, renderer, minX, minY, minZ, maxX, maxY, maxZ); | ||
renderer.renderFromInside = prev; | ||
|
||
renderer.setRenderBounds(0.5, 0, 0, 0.5, 1, 1); | ||
tessellator.setNormal(0.0F, 0.0F, -1.0F); | ||
renderer.renderFaceXNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 2, meta)); | ||
tessellator.setNormal(0.0F, 0.0F, 1.0F); | ||
renderer.renderFaceXPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 3, meta)); | ||
|
||
renderer.setRenderBounds(0, 0, 0.5, 1, 1, 0.5); | ||
tessellator.setNormal(-1.0F, 0.0F, 0.0F); | ||
renderer.renderFaceZNeg(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 4, meta)); | ||
tessellator.setNormal(1.0F, 0.0F, 0.0F); | ||
renderer.renderFaceZPos(block, 0.0D, 0.0D, 0.0D, renderer.getBlockIconFromSideAndMetadata(block, 5, meta)); | ||
} | ||
|
||
@Override | ||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { | ||
if (super.renderWorldBlock(world, x, y, z, block, modelId, renderer)) { | ||
boolean prev = renderer.renderAllFaces; | ||
renderer.renderAllFaces = true; | ||
drawStraightCrossedSquares(renderer, block, x, y, z); | ||
renderer.renderAllFaces = prev; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
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
Oops, something went wrong.