Nope, not doing that!

This commit is contained in:
oitsjustjose 2015-12-11 10:28:09 -06:00
commit 578e437dbe
4 changed files with 0 additions and 316 deletions

View file

@ -1,299 +0,0 @@
package com.oitsjustjose.criss_cross.blocks;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockDirectional;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumWorldBlockLayer;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
public abstract class BlockTimer extends BlockDirectional
{
protected final boolean isRepeaterPowered;
protected BlockTimer(boolean powered)
{
super(Material.circuits);
this.isRepeaterPowered = powered;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.125F, 1.0F);
}
public boolean isFullCube()
{
return false;
}
public boolean canPlaceBlockAt(World worldIn, BlockPos pos)
{
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down()) ? super.canPlaceBlockAt(worldIn, pos) : false;
}
public boolean canBlockStay(World worldIn, BlockPos pos)
{
return World.doesBlockHaveSolidTopSurface(worldIn, pos.down());
}
/**
* Called randomly when setTickRandomly is set to true (used by e.g. crops to grow, etc.)
*/
public void randomTick(World worldIn, BlockPos pos, IBlockState state, Random random)
{
}
public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand)
{
if (!this.isLocked(worldIn, pos, state))
{
boolean flag = this.shouldBePowered(worldIn, pos, state);
if (this.isRepeaterPowered && !flag)
{
worldIn.setBlockState(pos, this.getUnpoweredState(state), 2);
}
else if (!this.isRepeaterPowered)
{
worldIn.setBlockState(pos, this.getPoweredState(state), 2);
if (!flag)
{
worldIn.updateBlockTick(pos, this.getPoweredState(state).getBlock(), this.getTickDelay(state), -1);
}
}
}
}
@SideOnly(Side.CLIENT)
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
return side.getAxis() != EnumFacing.Axis.Y;
}
protected boolean isPowered(IBlockState state)
{
return this.isRepeaterPowered;
}
public int isProvidingStrongPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return this.isProvidingWeakPower(worldIn, pos, state, side);
}
public int isProvidingWeakPower(IBlockAccess worldIn, BlockPos pos, IBlockState state, EnumFacing side)
{
return !this.isPowered(state) ? 0 : (state.getValue(FACING) == side ? this.getActiveSignal(worldIn, pos, state) : 0);
}
/**
* Called when a neighboring block changes.
*/
public void onNeighborBlockChange(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock)
{
if (this.canBlockStay(worldIn, pos))
{
this.updateState(worldIn, pos, state);
}
else
{
this.dropBlockAsItem(worldIn, pos, state, 0);
worldIn.setBlockToAir(pos);
for (EnumFacing enumfacing : EnumFacing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
}
protected void updateState(World worldIn, BlockPos pos, IBlockState state)
{
if (!this.isLocked(worldIn, pos, state))
{
boolean flag = this.shouldBePowered(worldIn, pos, state);
if ((this.isRepeaterPowered && !flag || !this.isRepeaterPowered && flag) && !worldIn.isBlockTickPending(pos, this))
{
int i = -1;
if (this.isFacingTowardsRepeater(worldIn, pos, state))
{
i = -3;
}
else if (this.isRepeaterPowered)
{
i = -2;
}
worldIn.updateBlockTick(pos, this, this.getDelay(state), i);
}
}
}
public boolean isLocked(IBlockAccess worldIn, BlockPos pos, IBlockState state)
{
return false;
}
protected boolean shouldBePowered(World worldIn, BlockPos pos, IBlockState state)
{
return this.calculateInputStrength(worldIn, pos, state) > 0;
}
protected int calculateInputStrength(World worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing);
int i = worldIn.getRedstonePower(blockpos, enumfacing);
if (i >= 15)
{
return i;
}
else
{
IBlockState iblockstate = worldIn.getBlockState(blockpos);
return Math.max(i, iblockstate.getBlock() == Blocks.redstone_wire ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : 0);
}
}
protected int getPowerOnSides(IBlockAccess worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
EnumFacing enumfacing1 = enumfacing.rotateY();
EnumFacing enumfacing2 = enumfacing.rotateYCCW();
return Math.max(this.getPowerOnSide(worldIn, pos.offset(enumfacing1), enumfacing1), this.getPowerOnSide(worldIn, pos.offset(enumfacing2), enumfacing2));
}
protected int getPowerOnSide(IBlockAccess worldIn, BlockPos pos, EnumFacing side)
{
IBlockState iblockstate = worldIn.getBlockState(pos);
Block block = iblockstate.getBlock();
return this.canPowerSide(block) ? (block == Blocks.redstone_wire ? ((Integer)iblockstate.getValue(BlockRedstoneWire.POWER)).intValue() : worldIn.getStrongPower(pos, side)) : 0;
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
/**
* Called by ItemBlocks just before a block is actually set in the world, to allow for adjustments to the
* IBlockstate
*/
public IBlockState onBlockPlaced(World worldIn, BlockPos pos, EnumFacing facing, float hitX, float hitY, float hitZ, int meta, EntityLivingBase placer)
{
return this.getDefaultState().withProperty(FACING, placer.getHorizontalFacing().getOpposite());
}
/**
* Called by ItemBlocks after a block is set in the world, to allow post-place logic
*/
public void onBlockPlacedBy(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack)
{
if (this.shouldBePowered(worldIn, pos, state))
{
worldIn.scheduleUpdate(pos, this, 1);
}
}
public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state)
{
this.notifyNeighbors(worldIn, pos, state);
}
protected void notifyNeighbors(World worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = (EnumFacing)state.getValue(FACING);
BlockPos blockpos = pos.offset(enumfacing.getOpposite());
if(net.minecraftforge.event.ForgeEventFactory.onNeighborNotify(worldIn, pos, worldIn.getBlockState(pos), java.util.EnumSet.of(enumfacing.getOpposite())).isCanceled())
return;
worldIn.notifyBlockOfStateChange(blockpos, this);
worldIn.notifyNeighborsOfStateExcept(blockpos, this, enumfacing);
}
/**
* Called when a player destroys this Block
*/
public void onBlockDestroyedByPlayer(World worldIn, BlockPos pos, IBlockState state)
{
if (this.isRepeaterPowered)
{
for (EnumFacing enumfacing : EnumFacing.values())
{
worldIn.notifyNeighborsOfStateChange(pos.offset(enumfacing), this);
}
}
super.onBlockDestroyedByPlayer(worldIn, pos, state);
}
/**
* Used to determine ambient occlusion and culling when rebuilding chunks for render
*/
public boolean isOpaqueCube()
{
return false;
}
protected boolean canPowerSide(Block blockIn)
{
return blockIn.canProvidePower();
}
protected int getActiveSignal(IBlockAccess worldIn, BlockPos pos, IBlockState state)
{
return 15;
}
public static boolean isRedstoneRepeaterBlockID(Block blockIn)
{
return Blocks.unpowered_repeater.isAssociated(blockIn) || Blocks.unpowered_comparator.isAssociated(blockIn);
}
public boolean isAssociated(Block other)
{
return other == this.getPoweredState(this.getDefaultState()).getBlock() || other == this.getUnpoweredState(this.getDefaultState()).getBlock();
}
public boolean isFacingTowardsRepeater(World worldIn, BlockPos pos, IBlockState state)
{
EnumFacing enumfacing = ((EnumFacing)state.getValue(FACING)).getOpposite();
BlockPos blockpos = pos.offset(enumfacing);
return isRedstoneRepeaterBlockID(worldIn.getBlockState(blockpos).getBlock()) ? worldIn.getBlockState(blockpos).getValue(FACING) != enumfacing : false;
}
protected int getTickDelay(IBlockState state)
{
return this.getDelay(state);
}
protected abstract int getDelay(IBlockState state);
protected abstract IBlockState getPoweredState(IBlockState unpoweredState);
protected abstract IBlockState getUnpoweredState(IBlockState poweredState);
public boolean isAssociatedBlock(Block other)
{
return this.isAssociated(other);
}
@SideOnly(Side.CLIENT)
public EnumWorldBlockLayer getBlockLayer()
{
return EnumWorldBlockLayer.CUTOUT;
}
}

View file

@ -1,13 +0,0 @@
package com.oitsjustjose.criss_cross.items;
import com.oitsjustjose.criss_cross.lib.LibBlocks;
import net.minecraft.item.ItemReed;
public class ItemTimer extends ItemReed
{
public ItemTimer()
{
super(LibBlocks.timer);
}
}

View file

@ -5,7 +5,6 @@ import com.oitsjustjose.criss_cross.blocks.BlockCobblegen;
import com.oitsjustjose.criss_cross.blocks.BlockCropomator;
import com.oitsjustjose.criss_cross.blocks.BlockElectroextractor;
import com.oitsjustjose.criss_cross.blocks.BlockStonegen;
import com.oitsjustjose.criss_cross.blocks.BlockTimer;
import com.oitsjustjose.criss_cross.blocks.BlockWoodchipper;
import com.oitsjustjose.criss_cross.gui.GUIHandler;
@ -29,7 +28,6 @@ public class LibBlocks
woodchipper = new BlockWoodchipper();
cobblegen = new BlockCobblegen();
stonegen = new BlockStonegen();
timer = new BlockTimer();
// mobGrinder = new BlockMobGrinder();
NetworkRegistry.INSTANCE.registerGuiHandler(CrissCross.instance, new GUIHandler());
}

View file

@ -5,7 +5,6 @@ import com.oitsjustjose.criss_cross.items.ItemInfiniApple;
import com.oitsjustjose.criss_cross.items.ItemMantleSmasher;
import com.oitsjustjose.criss_cross.items.ItemModBuckets;
import com.oitsjustjose.criss_cross.items.ItemPouch;
import com.oitsjustjose.criss_cross.items.ItemTimer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
@ -38,6 +37,5 @@ public class LibItems
pouch = new ItemPouch();
mantleSmasherMkI = new ItemMantleSmasher(mkI);
mantleSmasherMkII = new ItemMantleSmasher(mkII);
timer = new ItemTimer();
}
}