mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Phosphor vines
This commit is contained in:
parent
f2574fc232
commit
705f051c50
@ -492,6 +492,12 @@ public class ModBlocks {
|
||||
public static Block plant_tall;
|
||||
public static Block plant_dead;
|
||||
public static Block reeds;
|
||||
public static Block vine_phosphor;
|
||||
public static final Material thick_foliage = new MaterialLogic(MapColor.foliageColor) {
|
||||
@Override public boolean getCanBurn() { return true; }
|
||||
@Override public boolean isToolNotRequired() { return false; }
|
||||
@Override public int getMaterialMobility() { return 1; }
|
||||
};
|
||||
|
||||
public static Block waste_earth;
|
||||
public static Block waste_mycelium;
|
||||
@ -1669,7 +1675,8 @@ public class ModBlocks {
|
||||
plant_tall = new BlockTallPlant().setBlockName("plant_tall").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.0F);
|
||||
plant_dead = new BlockDeadPlant().setBlockName("plant_dead").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.0F);
|
||||
reeds = new BlockReeds().setBlockName("plant_reeds").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.0F);
|
||||
|
||||
vine_phosphor = new BlockHangingVine(thick_foliage).setBlockName("vine_phosphor").setCreativeTab(MainRegistry.blockTab).setStepSound(Block.soundTypeGrass).setHardness(0.5F);
|
||||
|
||||
waste_earth = new WasteEarth(Material.ground, true).setBlockName("waste_earth").setStepSound(Block.soundTypeGrass).setCreativeTab(MainRegistry.blockTab).setHardness(0.6F).setBlockTextureName(RefStrings.MODID + ":waste_earth");
|
||||
waste_mycelium = new WasteEarth(Material.ground, true).setBlockName("waste_mycelium").setStepSound(Block.soundTypeGrass).setLightLevel(1F).setCreativeTab(MainRegistry.blockTab).setHardness(0.6F).setBlockTextureName(RefStrings.MODID + ":waste_mycelium_side");
|
||||
waste_trinitite = new BlockOre(Material.sand).noFortune().setBlockName("waste_trinitite").setStepSound(Block.soundTypeSand).setCreativeTab(MainRegistry.blockTab).setHardness(0.5F).setResistance(2.5F).setBlockTextureName(RefStrings.MODID + ":waste_trinitite");
|
||||
@ -2783,6 +2790,7 @@ public class ModBlocks {
|
||||
register(plant_tall);
|
||||
register(plant_dead);
|
||||
register(reeds);
|
||||
register(vine_phosphor);
|
||||
GameRegistry.registerBlock(mush, mush.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(mush_block, mush_block.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(mush_block_stem, mush_block_stem.getUnlocalizedName());
|
||||
|
||||
120
src/main/java/com/hbm/blocks/generic/BlockHangingVine.java
Normal file
120
src/main/java/com/hbm/blocks/generic/BlockHangingVine.java
Normal file
@ -0,0 +1,120 @@
|
||||
package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import com.hbm.lib.RefStrings;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IShearable;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class BlockHangingVine extends Block implements IShearable {
|
||||
|
||||
public BlockHangingVine(Material mat) {
|
||||
super(mat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) {
|
||||
if(world.getBlock(x, y - 1, z).isSideSolid(world, x, y - 1, z, ForgeDirection.UP))
|
||||
entity.setInWeb();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
|
||||
return this.canBlockStay(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBlockStay(World world, int x, int y, int z) {
|
||||
Block b = world.getBlock(x, y + 1, z);
|
||||
return b.isSideSolid(world, x, y + 1, z, ForgeDirection.UP) || b == this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
|
||||
super.onNeighborBlockChange(world, x, y, z, block);
|
||||
this.checkAndDropBlock(world, x, y, z);
|
||||
}
|
||||
|
||||
protected void checkAndDropBlock(World world, int x, int y, int z) {
|
||||
if(!this.canBlockStay(world, x, y, z)) {
|
||||
world.setBlock(x, y, z, Blocks.air);
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected boolean canSilkHarvest() { return true; }
|
||||
|
||||
@Override
|
||||
public boolean isShearable(ItemStack item, IBlockAccess world, int x, int y, int z) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune) {
|
||||
ArrayList<ItemStack> ret = new ArrayList<ItemStack>();
|
||||
ret.add(new ItemStack(this)); //placeholder
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderAsNormalBlock() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT) public IIcon iconGround; //when touching a solid face below
|
||||
@SideOnly(Side.CLIENT) public IIcon iconHang; //when hanging mid-air
|
||||
@SideOnly(Side.CLIENT) public IIcon iconGlow; //regular phosphor
|
||||
@SideOnly(Side.CLIENT) public IIcon iconHangGlow; //phosphor in different position when hanging for variety
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister reg) {
|
||||
this.blockIcon = reg.registerIcon(RefStrings.MODID + ":vine_phosphor");
|
||||
this.iconGround = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_ground");
|
||||
this.iconHang = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_hang");
|
||||
this.iconGlow = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_spots");
|
||||
this.iconHangGlow = reg.registerIcon(RefStrings.MODID + ":vine_phosphor_spots_hang");
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(IBlockAccess world, int x, int y, int z, boolean pass) {
|
||||
Block b = world.getBlock(x, y - 1, z);
|
||||
|
||||
if(!pass)
|
||||
return b.isSideSolid(world, x, y, z, ForgeDirection.UP) ? iconGround : b == this ? blockIcon : iconHang;
|
||||
else
|
||||
return b.isAir(world, x, y, z) ? iconHangGlow : iconGlow;
|
||||
}
|
||||
|
||||
public static int renderID = RenderingRegistry.getNextAvailableRenderId();
|
||||
|
||||
@Override
|
||||
public int getRenderType() {
|
||||
return renderID;
|
||||
}
|
||||
}
|
||||
@ -773,6 +773,7 @@ public class ClientProxy extends ServerProxy {
|
||||
RenderingRegistry.registerBlockHandler(new RenderBoxDuct());
|
||||
RenderingRegistry.registerBlockHandler(new RenderBlockDecoModel(ModBlocks.deco_computer.getRenderType(), ResourceManager.deco_computer));
|
||||
RenderingRegistry.registerBlockHandler(new RenderReeds());
|
||||
RenderingRegistry.registerBlockHandler(new RenderHangingVine());
|
||||
RenderingRegistry.registerBlockHandler(new RenderRTTY());
|
||||
RenderingRegistry.registerBlockHandler(new RenderDiFurnaceExtension());
|
||||
RenderingRegistry.registerBlockHandler(new RenderSplitter());
|
||||
|
||||
94
src/main/java/com/hbm/render/block/RenderHangingVine.java
Normal file
94
src/main/java/com/hbm/render/block/RenderHangingVine.java
Normal file
@ -0,0 +1,94 @@
|
||||
package com.hbm.render.block;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.blocks.generic.BlockHangingVine;
|
||||
|
||||
import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.RenderBlocks;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class RenderHangingVine implements ISimpleBlockRenderingHandler {
|
||||
|
||||
@Override
|
||||
public void renderInventoryBlock(Block block, int metadata, int modelId, RenderBlocks renderer) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
int colorMult = block.colorMultiplier(world, x, y, z);
|
||||
float r = (float) (colorMult >> 16 & 255) / 255.0F;
|
||||
float g = (float) (colorMult >> 8 & 255) / 255.0F;
|
||||
float b = (float) (colorMult & 255) / 255.0F;
|
||||
|
||||
tess.setColorOpaque_F(r, g, b);
|
||||
|
||||
BlockHangingVine vine = (BlockHangingVine) block;
|
||||
|
||||
int brightness = block.getMixedBrightnessForBlock(world, x, y, z);
|
||||
tess.setBrightness(brightness);
|
||||
|
||||
IIcon icon = vine.getIcon(world, x, y, z, false);
|
||||
renderCrossedSquares(icon, x, y, z, 1.0D);
|
||||
|
||||
tess.setBrightness(240);
|
||||
|
||||
icon = vine.getIcon(world, x, y, z, true); //glow pass
|
||||
renderCrossedSquares(icon, x, y, z, 1.0D);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//fixed implementation of drawCrossedSquares
|
||||
public void renderCrossedSquares(IIcon icon, double x, double y, double z, double height) {
|
||||
Tessellator tess = Tessellator.instance;
|
||||
|
||||
double minU = icon.getMinU();
|
||||
double minV = icon.getMinV();
|
||||
double maxU = icon.getMaxU();
|
||||
double maxV = icon.getMaxV();
|
||||
|
||||
double factor = 0.45D * height;
|
||||
double minX = x + 0.5D - factor;
|
||||
double maxX = x + 0.5D + factor;
|
||||
double minZ = z + 0.5D - factor;
|
||||
double maxZ = z + 0.5D + factor;
|
||||
|
||||
tess.addVertexWithUV(minX, y, minZ, maxU, maxV);
|
||||
tess.addVertexWithUV(minX, y + height, minZ, maxU, minV);
|
||||
tess.addVertexWithUV(maxX, y + height, maxZ, minU, minV);
|
||||
tess.addVertexWithUV(maxX, y, maxZ, minU, maxV);
|
||||
|
||||
tess.addVertexWithUV(maxX, y, maxZ, maxU, maxV);
|
||||
tess.addVertexWithUV(maxX, y + height, maxZ, maxU, minV);
|
||||
tess.addVertexWithUV(minX, y + height, minZ, minU, minV);
|
||||
tess.addVertexWithUV(minX, y, minZ, minU, maxV);
|
||||
|
||||
tess.addVertexWithUV(maxX, y, minZ, maxU, maxV);
|
||||
tess.addVertexWithUV(maxX, y + height, minZ, maxU, minV);
|
||||
tess.addVertexWithUV(minX, y + height, maxZ, minU, minV);
|
||||
tess.addVertexWithUV(minX, y, maxZ, minU, maxV);
|
||||
|
||||
tess.addVertexWithUV(minX, y, maxZ, maxU, maxV);
|
||||
tess.addVertexWithUV(minX, y + height, maxZ, maxU, minV);
|
||||
tess.addVertexWithUV(maxX, y + height, minZ, minU, minV);
|
||||
tess.addVertexWithUV(maxX, y, minZ, minU, maxV);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldRender3DInInventory(int modelId) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRenderId() {
|
||||
return BlockHangingVine.renderID;
|
||||
}
|
||||
}
|
||||
BIN
src/main/resources/assets/hbm/textures/blocks/vine_phosphor.png
Normal file
BIN
src/main/resources/assets/hbm/textures/blocks/vine_phosphor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 294 B |
Binary file not shown.
|
After Width: | Height: | Size: 316 B |
Binary file not shown.
|
After Width: | Height: | Size: 295 B |
Binary file not shown.
|
After Width: | Height: | Size: 476 B |
@ -0,0 +1,16 @@
|
||||
{
|
||||
"animation": {
|
||||
"interpolate": true,
|
||||
"frametime": 8,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 370 B |
@ -0,0 +1,16 @@
|
||||
{
|
||||
"animation": {
|
||||
"interpolate": true,
|
||||
"frametime": 8,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user