Tiny Torch.

This commit is contained in:
Ellpeck 2016-07-14 22:04:24 +02:00
parent 84c6549c86
commit 64c152e8da
11 changed files with 383 additions and 2 deletions

View file

@ -0,0 +1,272 @@
/*
* This file ("BlockTinyTorch.java") is part of the Actually Additions mod for Minecraft.
* It is created and owned by Ellpeck and distributed
* under the Actually Additions License to be found at
* http://ellpeck.de/actaddlicense
* View the source code at https://github.com/Ellpeck/ActuallyAdditions
*
* © 2015-2016 Ellpeck
*/
package de.ellpeck.actuallyadditions.mod.blocks;
import com.google.common.base.Predicate;
import de.ellpeck.actuallyadditions.mod.blocks.base.BlockBase;
import net.minecraft.block.Block;
import net.minecraft.block.BlockTorch;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.PropertyDirection;
import net.minecraft.block.state.BlockStateContainer;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.*;
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 javax.annotation.Nullable;
import java.util.Random;
//Copied from BlockTorch.
//I have no idea what all of this means.
public class BlockTinyTorch extends BlockBase{
//Thanks to xdjackiexd for these.
//Man, I hate numbers.
private static final AxisAlignedBB STANDING_AABB = new AxisAlignedBB(0.4375D, 0.0D, 0.4375D, 0.5625D, 0.3125D, 0.5625D);
private static final AxisAlignedBB TORCH_NORTH_AABB = new AxisAlignedBB(0.4375D, 0.25D, 0.8125D, 0.5625D, 0.5625D, 1.0D);
private static final AxisAlignedBB TORCH_SOUTH_AABB = new AxisAlignedBB(0.4375D, 0.25D, 0.0D, 0.5625D, 0.5625D, 0.1875D);
private static final AxisAlignedBB TORCH_WEST_AABB = new AxisAlignedBB(0.8125D, 0.25D, 0.4375D, 1.0D, 0.5625D, 0.5625D);
private static final AxisAlignedBB TORCH_EAST_AABB = new AxisAlignedBB(0.0D, 0.25D, 0.4375D, 0.1875D, 0.5625D, 0.5625D);
public BlockTinyTorch(String name){
super(Material.CIRCUITS, name);
this.setDefaultState(this.blockState.getBaseState().withProperty(BlockTorch.FACING, EnumFacing.UP));
this.setTickRandomly(true);
this.setCreativeTab(CreativeTabs.DECORATIONS);
this.setHardness(0.0F);
this.setLightLevel(0.67F);
this.setSoundType(SoundType.WOOD);
}
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
switch(state.getValue(BlockTorch.FACING)){
case EAST:
return TORCH_EAST_AABB;
case WEST:
return TORCH_WEST_AABB;
case SOUTH:
return TORCH_SOUTH_AABB;
case NORTH:
return TORCH_NORTH_AABB;
default:
return STANDING_AABB;
}
}
@Override
@Nullable
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, World worldIn, BlockPos pos){
return NULL_AABB;
}
@Override
public boolean isOpaqueCube(IBlockState state){
return false;
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
private boolean canPlaceOn(World worldIn, BlockPos pos){
IBlockState state = worldIn.getBlockState(pos);
return state.isSideSolid(worldIn, pos, EnumFacing.UP) || state.getBlock().canPlaceTorchOnTop(state, worldIn, pos);
}
@Override
public boolean canPlaceBlockAt(World worldIn, BlockPos pos){
for(EnumFacing enumfacing : BlockTorch.FACING.getAllowedValues()){
if(this.canPlaceAt(worldIn, pos, enumfacing)){
return true;
}
}
return false;
}
private boolean canPlaceAt(World worldIn, BlockPos pos, EnumFacing facing){
BlockPos blockpos = pos.offset(facing.getOpposite());
boolean flag = facing.getAxis().isHorizontal();
return flag && worldIn.isSideSolid(blockpos, facing, true) || facing.equals(EnumFacing.UP) && this.canPlaceOn(worldIn, blockpos);
}
@Override
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer){
if(this.canPlaceAt(worldIn, pos, facing)){
return this.getDefaultState().withProperty(BlockTorch.FACING, facing);
}
else{
for(EnumFacing enumfacing : EnumFacing.Plane.HORIZONTAL){
if(worldIn.isSideSolid(pos.offset(enumfacing.getOpposite()), enumfacing, true)){
return this.getDefaultState().withProperty(BlockTorch.FACING, enumfacing);
}
}
return this.getDefaultState();
}
}
@Override
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state){
this.checkForDrop(worldIn, pos, state);
}
@Override
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn){
this.onNeighborChangeInternal(worldIn, pos, state);
}
protected boolean onNeighborChangeInternal(World worldIn, BlockPos pos, IBlockState state){
if(!this.checkForDrop(worldIn, pos, state)){
return true;
}
else{
EnumFacing enumfacing = state.getValue(BlockTorch.FACING);
EnumFacing.Axis axis = enumfacing.getAxis();
EnumFacing enumfacing1 = enumfacing.getOpposite();
boolean flag = false;
if(axis.isHorizontal() && !worldIn.isSideSolid(pos.offset(enumfacing1), enumfacing, true)){
flag = true;
}
else if(axis.isVertical() && !this.canPlaceOn(worldIn, pos.offset(enumfacing1))){
flag = true;
}
if(flag){
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
return true;
}
else{
return false;
}
}
}
protected boolean checkForDrop(World worldIn, BlockPos pos, IBlockState state){
if(state.getBlock() == this && this.canPlaceAt(worldIn, pos, state.getValue(BlockTorch.FACING))){
return true;
}
else{
if(worldIn.getBlockState(pos).getBlock() == this){
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
}
return false;
}
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(IBlockState stateIn, World worldIn, BlockPos pos, Random rand){
if(rand.nextBoolean()){
EnumFacing enumfacing = stateIn.getValue(BlockTorch.FACING);
double d0 = (double)pos.getX()+0.5D;
double d1 = (double)pos.getY()+0.4D;
double d2 = (double)pos.getZ()+0.5D;
if(enumfacing.getAxis().isHorizontal()){
EnumFacing enumfacing1 = enumfacing.getOpposite();
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0+0.35D*(double)enumfacing1.getFrontOffsetX(), d1+0.22D, d2+0.35D*(double)enumfacing1.getFrontOffsetZ(), 0.0D, 0.0D, 0.0D, new int[0]);
}
else{
worldIn.spawnParticle(EnumParticleTypes.SMOKE_NORMAL, d0, d1, d2, 0.0D, 0.0D, 0.0D);
worldIn.spawnParticle(EnumParticleTypes.FLAME, d0, d1, d2, 0.0D, 0.0D, 0.0D);
}
}
}
@Override
public IBlockState getStateFromMeta(int meta){
IBlockState iblockstate = this.getDefaultState();
switch(meta){
case 1:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.EAST);
break;
case 2:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.WEST);
break;
case 3:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.SOUTH);
break;
case 4:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.NORTH);
break;
case 5:
default:
iblockstate = iblockstate.withProperty(BlockTorch.FACING, EnumFacing.UP);
}
return iblockstate;
}
@Override
@SideOnly(Side.CLIENT)
public BlockRenderLayer getBlockLayer(){
return BlockRenderLayer.CUTOUT;
}
@Override
public int getMetaFromState(IBlockState state){
int i = 0;
switch(state.getValue(BlockTorch.FACING)){
case EAST:
i = i | 1;
break;
case WEST:
i = i | 2;
break;
case SOUTH:
i = i | 3;
break;
case NORTH:
i = i | 4;
break;
case DOWN:
case UP:
default:
i = i | 5;
}
return i;
}
@Override
public IBlockState withRotation(IBlockState state, Rotation rot){
return state.withProperty(BlockTorch.FACING, rot.rotate(state.getValue(BlockTorch.FACING)));
}
@Override
public IBlockState withMirror(IBlockState state, Mirror mirrorIn){
return state.withRotation(mirrorIn.toRotation(state.getValue(BlockTorch.FACING)));
}
@Override
protected BlockStateContainer createBlockState(){
return new BlockStateContainer(this, BlockTorch.FACING);
}
}

View file

@ -124,9 +124,12 @@ public final class InitBlocks{
public static Block blockDisplayStand;
public static Block blockShockSuppressor;
public static Block blockTinyTorch;
public static void init(){
ModUtil.LOGGER.info("Initializing Blocks...");
blockTinyTorch = new BlockTinyTorch("blockTinyTorch");
blockShockSuppressor = new BlockShockSuppressor("blockShockSuppressor");
blockDisplayStand = new BlockDisplayStand("blockDisplayStand");
blockPlayerInterface = new BlockPlayerInterface("blockPlayerInterface");

View file

@ -405,15 +405,17 @@ public class GuiBooklet extends GuiScreen implements IBookletGui{
BookletUtils.openLastBookPage(this, data.theCompound.getCompoundTag("BookletData"));
}
}
this.shouldSaveDataNextClose = false;
}
else{
//Open forced entry
BookletUtils.openIndexEntry(this, ItemBooklet.forcedEntry.entry, ItemBooklet.forcedEntry.pageInIndex, true);
BookletUtils.openChapter(this, ItemBooklet.forcedEntry.chapter, ItemBooklet.forcedEntry.page);
ItemBooklet.forcedEntry = null;
this.shouldSaveDataNextClose = true;
}
this.shouldSaveDataNextClose = false;
}
@Override

View file

@ -88,6 +88,7 @@ public final class InitBooklet{
new BookletChapter("hairBalls", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemHairyBall), new PagePicture(1, "pageFurBalls", 110).setStacks(new ItemStack(InitItems.itemHairyBall)), new PageTextOnly(2)).setSpecial();
new BookletChapter("blackLotus", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockBlackLotus), new PageTextOnly(1).setStacks(new ItemStack(InitBlocks.blockBlackLotus)), new PageCrafting(2, ItemCrafting.recipeBlackDye));
new BookletChapter("waterBowl", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitItems.itemWaterBowl), new PageTextOnly(1).setStacks(new ItemStack(InitItems.itemWaterBowl)));
new BookletChapter("tinyTorch", ActuallyAdditionsAPI.entryMisc, new ItemStack(InitBlocks.blockTinyTorch), new PageCrafting(1, BlockCrafting.recipesTinyTorch).setPageStacksWildcard()).setSpecial();
//No RF Using Blocks
new BookletChapter("itemStorage", ActuallyAdditionsAPI.entryFunctionalNonRF, new ItemStack(InitBlocks.blockLaserRelayItemWhitelist), new PageTextOnly(1), new PageTextOnly(2), new PageCrafting(3, BlockCrafting.recipeLaserRelayItem).setNoText().setPageStacksWildcard(), new PageCrafting(4, BlockCrafting.recipeLaserRelayItemWhitelist).setNoText().setPageStacksWildcard(), new PageCrafting(5, BlockCrafting.recipeItemInterface).setNoText()).setImportant();

View file

@ -90,9 +90,24 @@ public final class BlockCrafting{
public static IRecipe recipePlayerInterface;
public static IRecipe recipeDisplayStand;
public static IRecipe recipeShockSuppressor;
public static IRecipe[] recipesTinyTorch = new IRecipe[2];
public static void init(){
//Tiny Torch
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2),
"C",
"W",
'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_COAL.ordinal()),
'W', "stickWood"));
recipesTinyTorch[0] = RecipeUtil.lastIRecipe();
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockTinyTorch, 2),
"C",
"W",
'C', new ItemStack(InitItems.itemMisc, 1, TheMiscItems.TINY_CHAR.ordinal()),
'W', "stickWood"));
recipesTinyTorch[1] = RecipeUtil.lastIRecipe();
//Firework Box
if(ConfigCrafting.FIREWORK_BOX.isEnabled()){
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(InitBlocks.blockFireworkBox),

View file

@ -0,0 +1,9 @@
{
"variants": {
"facing=up": { "model": "actuallyadditions:blockTinyTorch" },
"facing=east": { "model": "actuallyadditions:blockTinyTorchWall" },
"facing=south": { "model": "actuallyadditions:blockTinyTorchWall", "y": 90 },
"facing=west": { "model": "actuallyadditions:blockTinyTorchWall", "y": 180 },
"facing=north": { "model": "actuallyadditions:blockTinyTorchWall", "y": 270 }
}
}

View file

@ -215,6 +215,7 @@ tile.actuallyadditions.blockImpureIron.name=Impure Iron
tile.actuallyadditions.blockBookletStand.name=Wall-Mount Manual
tile.actuallyadditions.blockDisplayStand.name=Display Stand
tile.actuallyadditions.blockShockSuppressor.name=Shock Absorber
tile.actuallyadditions.blockTinyTorch.name=Tiny Torch
#ESD
tile.actuallyadditions.blockInputter.name=ESD
@ -928,4 +929,7 @@ booklet.actuallyadditions.chapter.videoGuide.page.1.button=Watch Video
booklet.actuallyadditions.chapter.shockSuppressor.name=Shock Absorber
booklet.actuallyadditions.chapter.shockSuppressor.text.1=The <item>Shock Absorber<r> is a block that, when supplied with <imp>RF<r>, it will protect an area of <imp>up to <range> blocks around it<r> from any type of <imp>Explosion<r>, be it ghasts, TNT or creepers. <n>Every block that is protected will result in a loss of <imp><rf> RF<r>.
booklet.actuallyadditions.chapter.shockSuppressor.text.2=<i>Credit where credit is due: <r><n><n>Or something like that. <n>Anyways, this thing was thought up and suggested to me by <imp>praetoras<r>. Thanks for that brilliant idea! <n><n><i>What's a fourth wall..?
booklet.actuallyadditions.chapter.shockSuppressor.text.2=<i>Credit where credit is due: <r><n><n>Or something like that. <n>Anyways, this thing was thought up and suggested to me by <imp>praetoras<r>. Thanks for that brilliant idea! <n><n><i>What's a fourth wall..?
booklet.actuallyadditions.chapter.tinyTorch.name=Tiny Torch
booklet.actuallyadditions.chapter.tinyTorch.text.1=<i>Yea.

View file

@ -0,0 +1,33 @@
{
"ambientocclusion": false,
"textures": {
"particle": "actuallyadditions:blocks/blockTinyTorch",
"torch": "actuallyadditions:blocks/blockTinyTorch"
},
"elements": [
{ "from": [ 7, 0, 7 ],
"to": [ 9, 5, 9 ],
"shade": false,
"faces": {
"down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
"up": { "uv": [ 7, 11, 9, 13 ], "texture": "#torch" }
}
},
{ "from": [ 7, 0, 0 ],
"to": [ 9, 16, 16 ],
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
}
},
{ "from": [ 0, 0, 7 ],
"to": [ 16, 16, 9 ],
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
}
}
]
}

View file

@ -0,0 +1,36 @@
{
"ambientocclusion": false,
"textures": {
"particle": "actuallyadditions:blocks/blockTinyTorch",
"torch": "actuallyadditions:blocks/blockTinyTorch"
},
"elements": [
{ "from": [ -1, 3.5, 7 ],
"to": [ 1, 8.5, 9 ],
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
"shade": false,
"faces": {
"down": { "uv": [ 7, 13, 9, 15 ], "texture": "#torch" },
"up": { "uv": [ 7, 11, 9, 13 ], "texture": "#torch" }
}
},
{ "from": [ -1, 3.5, 0 ],
"to": [ 1, 19.5, 16 ],
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
}
},
{ "from": [ -8, 3.5, 7 ],
"to": [ 8, 19.5, 9 ],
"rotation": { "origin": [ 0, 3.5, 8 ], "axis": "z", "angle": -22.5 },
"shade": false,
"faces": {
"north": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" },
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#torch" }
}
}
]
}

View file

@ -0,0 +1,6 @@
{
"parent": "actuallyadditions:item/standardItem",
"textures": {
"layer0": "actuallyadditions:blocks/blockTinyTorch"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B