Added flare, still needs some textures
This commit is contained in:
parent
d75120bb00
commit
d9d8845d6d
4 changed files with 165 additions and 0 deletions
102
src/main/java/techreborn/blocks/BlockFlare.java
Normal file
102
src/main/java/techreborn/blocks/BlockFlare.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package techreborn.blocks;
|
||||
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.material.MapColor;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.PropertyEnum;
|
||||
import net.minecraft.block.state.BlockStateContainer;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.BlockRenderLayer;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.tiles.TileEntityFlare;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 06/11/2016.
|
||||
*/
|
||||
public class BlockFlare extends BlockContainer {
|
||||
|
||||
public static final AxisAlignedBB FLARE_BB = new AxisAlignedBB(0.0D, 0.0D, 0.0D, 1.0D, 0.1D, 1.0D);
|
||||
|
||||
public static final PropertyEnum<EnumDyeColor> COLOR = PropertyEnum.create("color", EnumDyeColor.class);
|
||||
|
||||
public BlockFlare() {
|
||||
super(Material.REDSTONE_LIGHT);
|
||||
setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
setUnlocalizedName("techreborn.flare");
|
||||
this.setDefaultState(this.blockState.getBaseState().withProperty(COLOR, EnumDyeColor.WHITE));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||
if (worldIn.isRemote) { //Only needed on the client
|
||||
return new TileEntityFlare();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public int damageDropped(IBlockState state) {
|
||||
return (state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubBlocks(Item itemIn, CreativeTabs tab, List<ItemStack> list) {
|
||||
for (EnumDyeColor enumdyecolor : EnumDyeColor.values()) {
|
||||
list.add(new ItemStack(itemIn, 1, enumdyecolor.getMetadata()));
|
||||
}
|
||||
}
|
||||
|
||||
public MapColor getMapColor(IBlockState state) {
|
||||
return (state.getValue(COLOR)).getMapColor();
|
||||
}
|
||||
|
||||
public IBlockState getStateFromMeta(int meta) {
|
||||
return this.getDefaultState().withProperty(COLOR, EnumDyeColor.byMetadata(meta));
|
||||
}
|
||||
|
||||
public int getMetaFromState(IBlockState state) {
|
||||
return (state.getValue(COLOR)).getMetadata();
|
||||
}
|
||||
|
||||
protected BlockStateContainer createBlockState() {
|
||||
return new BlockStateContainer(this, COLOR);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOpaqueCube(IBlockState state) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public BlockRenderLayer getBlockLayer() {
|
||||
return BlockRenderLayer.CUTOUT;
|
||||
}
|
||||
|
||||
public boolean isFullCube() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos) {
|
||||
return FLARE_BB;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
|
||||
return FLARE_BB;
|
||||
}
|
||||
}
|
11
src/main/java/techreborn/client/particle/ParticleSmoke.java
Normal file
11
src/main/java/techreborn/client/particle/ParticleSmoke.java
Normal file
|
@ -0,0 +1,11 @@
|
|||
package techreborn.client.particle;
|
||||
|
||||
import net.minecraft.client.particle.ParticleSmokeLarge;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ParticleSmoke extends ParticleSmokeLarge {
|
||||
|
||||
public ParticleSmoke(World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double p_i1201_8_, double p_i1201_10_, double p_i1201_12_) {
|
||||
super(worldIn, xCoordIn, yCoordIn, zCoordIn, p_i1201_8_, p_i1201_10_, p_i1201_12_);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package techreborn.init;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockColored;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemColored;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
@ -21,6 +23,7 @@ import techreborn.blocks.tier1.*;
|
|||
import techreborn.blocks.transformers.BlockHVTransformer;
|
||||
import techreborn.blocks.transformers.BlockLVTransformer;
|
||||
import techreborn.blocks.transformers.BlockMVTransformer;
|
||||
import techreborn.client.TechRebornCreativeTabMisc;
|
||||
import techreborn.itemblocks.*;
|
||||
import techreborn.tiles.*;
|
||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||
|
@ -114,6 +117,7 @@ public class ModBlocks {
|
|||
public static Block rubberPlanks;
|
||||
|
||||
public static Block ironFence;
|
||||
public static Block flare;
|
||||
|
||||
public static void init() {
|
||||
thermalGenerator = new BlockThermalGenerator();
|
||||
|
@ -379,6 +383,14 @@ public class ModBlocks {
|
|||
registerBlock(scrapboxinator, "scrapboxinator");
|
||||
GameRegistry.registerTileEntity(TileScrapboxinator.class, "TileScrapboxinatorTR");
|
||||
|
||||
flare = new BlockFlare();
|
||||
registerBlock(flare, "flare");
|
||||
ItemBlock itemBlock = new ItemColored(flare, true);
|
||||
itemBlock.setRegistryName("flareItemBlock");
|
||||
itemBlock.setCreativeTab(TechRebornCreativeTabMisc.instance);
|
||||
GameRegistry.register(itemBlock);
|
||||
GameRegistry.registerTileEntity(TileEntityFlare.class, "TileEntityFlareTR");
|
||||
|
||||
registerOreDict();
|
||||
Core.logHelper.info("TechReborns Blocks Loaded");
|
||||
}
|
||||
|
|
40
src/main/java/techreborn/tiles/TileEntityFlare.java
Normal file
40
src/main/java/techreborn/tiles/TileEntityFlare.java
Normal file
|
@ -0,0 +1,40 @@
|
|||
package techreborn.tiles;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.entity.passive.EntitySheep;
|
||||
import net.minecraft.item.EnumDyeColor;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import techreborn.blocks.BlockFlare;
|
||||
import techreborn.client.particle.ParticleSmoke;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 06/11/2016.
|
||||
*/
|
||||
public class TileEntityFlare extends TileEntity implements ITickable {
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
EnumDyeColor color = worldObj.getBlockState(pos).getValue(BlockFlare.COLOR);
|
||||
if(worldObj.isRemote && worldObj.isAirBlock(getPos().up())){
|
||||
ParticleSmoke particleSmokeLarge = new ParticleSmoke(worldObj , pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 0, 0.0D, 0);
|
||||
particleSmokeLarge.setMaxAge(250);
|
||||
if(color != EnumDyeColor.WHITE){
|
||||
float[] rgb = EntitySheep.getDyeRgb(color);
|
||||
particleSmokeLarge.setRBGColorF(rgb[0] + (random.nextFloat() /20), rgb[1] + (random.nextFloat() /20), rgb[2] + (random.nextFloat() /20));
|
||||
}
|
||||
particleSmokeLarge.multipleParticleScaleBy(0.5F);
|
||||
|
||||
Minecraft.getMinecraft().effectRenderer.addEffect(particleSmokeLarge);
|
||||
|
||||
worldObj.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5, pos.getY() + 0.3, pos.getZ() + 0.5, 0.0D, 0.0D, 0.0D);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in a new issue