mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Fence blocks can be converted into posts
This commit is contained in:
parent
5241ff661b
commit
27cf5ca091
@ -2934,7 +2934,7 @@ public class ModBlocks {
|
||||
GameRegistry.registerBlock(hev_battery, hev_battery.getUnlocalizedName());
|
||||
|
||||
//Chainlink Fence
|
||||
GameRegistry.registerBlock(fence_metal, fence_metal.getUnlocalizedName());
|
||||
GameRegistry.registerBlock(fence_metal, ItemBlockBase.class, fence_metal.getUnlocalizedName());
|
||||
|
||||
//Sands, Glass
|
||||
GameRegistry.registerBlock(ash_digamma, ash_digamma.getUnlocalizedName());
|
||||
|
||||
@ -2,18 +2,23 @@ package com.hbm.blocks.generic;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.block.BlockFence;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class BlockMetalFence extends BlockFence {
|
||||
public class BlockMetalFence extends BlockFence implements IBlockMulti {
|
||||
|
||||
public IIcon postIcon;
|
||||
|
||||
@ -38,6 +43,21 @@ public class BlockMetalFence extends BlockFence {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int damageDropped(int meta) {
|
||||
return rectify(meta);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon(int side, int meta) {
|
||||
return meta == 0 ? this.blockIcon : this.postIcon;
|
||||
}
|
||||
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
return stack.getItemDamage() == 1 ? getUnlocalizedName() + "_post" : getUnlocalizedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerBlockIcons(IIconRegister iconRegister) {
|
||||
@ -104,4 +124,17 @@ public class BlockMetalFence extends BlockFence {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item item, CreativeTabs tab, List list) {
|
||||
for(int i = 0; i < getSubCount(); ++i) {
|
||||
list.add(new ItemStack(item, 1, i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubCount() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import com.hbm.blocks.BlockMulti;
|
||||
import com.hbm.blocks.IBlockMulti;
|
||||
import com.hbm.blocks.IPersistentInfoProvider;
|
||||
import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.blocks.generic.BlockMetalFence;
|
||||
import com.hbm.tileentity.IPersistentNBT;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@ -42,6 +43,8 @@ public class ItemBlockBase extends ItemBlock {
|
||||
|
||||
if(field_150939_a instanceof BlockMulti) {
|
||||
return ((BlockMulti)field_150939_a).getUnlocalizedName(stack);
|
||||
} else if(field_150939_a instanceof BlockMetalFence) {
|
||||
return ((BlockMetalFence)field_150939_a).getUnlocalizedName(stack); // I considered reworking IBlockMulti instead but there are like a bajillion implementers
|
||||
} else {
|
||||
return super.getUnlocalizedName(stack);
|
||||
}
|
||||
|
||||
@ -740,6 +740,8 @@ public class CraftingManager {
|
||||
addRecipeAuto(new ItemStack(ModBlocks.obj_tester, 1), new Object[] { "P", "I", "S", 'P', ModItems.polaroid, 'I', ModItems.flame_pony, 'S', STEEL.plate() });
|
||||
|
||||
addRecipeAuto(new ItemStack(ModBlocks.fence_metal, 6), new Object[] { "BIB", "BIB", 'B', Blocks.iron_bars, 'I', Items.iron_ingot });
|
||||
addShapelessAuto(new ItemStack(ModBlocks.fence_metal, 1, 1), new Object[] { new ItemStack(ModBlocks.fence_metal, 1, 0) });
|
||||
addShapelessAuto(new ItemStack(ModBlocks.fence_metal, 1, 0), new Object[] { new ItemStack(ModBlocks.fence_metal, 1, 1) });
|
||||
|
||||
addShapelessAuto(new ItemStack(ModBlocks.waste_trinitite), new Object[] { new ItemStack(Blocks.sand, 1, 0), ModItems.trinitite });
|
||||
addShapelessAuto(new ItemStack(ModBlocks.waste_trinitite_red), new Object[] { new ItemStack(Blocks.sand, 1, 1), ModItems.trinitite });
|
||||
|
||||
@ -19,6 +19,7 @@ public class RenderFence implements ISimpleBlockRenderingHandler {
|
||||
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
|
||||
|
||||
BlockMetalFence fence = (BlockMetalFence) ModBlocks.fence_metal;
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
|
||||
boolean xNeg = fence.canConnectFenceTo(world, x - 1, y, z);
|
||||
boolean xPos = fence.canConnectFenceTo(world, x + 1, y, z);
|
||||
@ -28,7 +29,9 @@ public class RenderFence implements ISimpleBlockRenderingHandler {
|
||||
boolean flag1 = xNeg || xPos;
|
||||
boolean flag2 = zNeg || zPos;
|
||||
|
||||
boolean hidePost = (xNeg && xPos) || (zNeg && zPos);
|
||||
boolean straightX = xNeg && xPos;
|
||||
boolean straightZ = zNeg && zPos;
|
||||
boolean showPost = meta == 1 || (!straightX && !straightZ);
|
||||
|
||||
if (!flag1 && !flag2) {
|
||||
flag1 = true;
|
||||
@ -52,7 +55,7 @@ public class RenderFence implements ISimpleBlockRenderingHandler {
|
||||
renderer.renderStandardBlock(fence, x, y, z);
|
||||
}
|
||||
|
||||
if(!hidePost) {
|
||||
if(showPost) {
|
||||
f = 0.375F;
|
||||
f1 = 0.625F;
|
||||
renderer.setOverrideBlockTexture(fence.postIcon);
|
||||
|
||||
@ -5066,6 +5066,7 @@ tile.fallout.name=Fallout
|
||||
tile.fan.name=Fan
|
||||
tile.fan.desc=Activates using redstone$Will push entities up to 10 blocks$Right-click with screwdriver to flip
|
||||
tile.fence_metal.name=Chainlink Fence
|
||||
tile.fence_metal_post.name=Chainlink Fence Post
|
||||
tile.field_disturber.name=High Energy Field Jammer
|
||||
tile.filing_cabinet.green.name=Dusty Filing Cabinet
|
||||
tile.filing_cabinet.steel.name=Steel Filing Cabinet
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user