Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BlockSilver extends BlockMetal {
- public BlockSilver(String unlocalizedName, String registryName, MapColor mapcolor, int harvestLevel) {
- super(unlocalizedName, registryName, mapcolor, harvestLevel);
- }
- public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
- {
- Console.println("Collided with silver block"); // <---This never prints, even when it should
- if (entityIn instanceof EntityLiving)
- {
- if (((EntityLiving) entityIn).isEntityUndead())
- {
- entityIn.attackEntityFrom(DamageSource.GENERIC, 1.0F);
- }
- }
- }
- }
- //-------------------------------------------------------------------------------------------------------
- public class BlockTrapFlamePad extends Block {
- public static final PropertyBool PRESSED = PropertyBool.create("pressed");
- public BlockTrapFlamePad() {
- super(Material.ROCK);
- this.setUnlocalizedName(Reference.ToSBlocks.TRAP_FLAME_PAD.getUnlocalizedName());
- this.setRegistryName(Reference.ToSBlocks.TRAP_FLAME_PAD.getRegistryName());
- this.setTickRandomly(true);
- this.setHardness(1.5F);
- this.setResistance(10.0F);
- this.setSoundType(SoundType.STONE);
- this.setDefaultState(this.blockState.getBaseState().withProperty(PRESSED, false));
- }
- public int tickRate(World worldIn)
- {
- return 20;
- }
- public void updateTick(World worldIn, BlockPos pos, IBlockState state, Random rand) {
- Console.println("Update tick called"); // <---- THIS NEVER FIRES EITHER
- if (worldIn.getBlockState(pos.up()).getBlock() == Blocks.FIRE) {
- worldIn.setBlockState(pos, state.withProperty(PRESSED, false), 2);
- worldIn.setBlockState(pos.up(), Blocks.AIR.getDefaultState(), 2);
- worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_OFF, SoundCategory.BLOCKS, 0.3F, 0.5F);
- }
- }
- public void onEntityCollidedWithBlock(World worldIn, BlockPos pos, IBlockState state, Entity entityIn)
- {
- Console.println("Touched the flame pad"); // <----THIS NEVER PRINTS OMG WHAT IS GOING ON!!!
- if (pos.up().getY() == entityIn.getPosition().getY()) {
- Console.println("Walked over flame pad!");
- if (worldIn.getBlockState(pos.up()).getBlock() == Blocks.AIR || worldIn.getBlockState(pos.up()).getBlock() == Blocks.FIRE) {
- if (state.getValue(PRESSED) == false) {
- boolean lightFire = false;
- if (entityIn instanceof EntityPlayer) {
- if (!((EntityPlayer)entityIn).isSneaking()) {
- lightFire = true;
- }
- }
- else {
- lightFire = true;
- }
- if (lightFire) {
- worldIn.setBlockState(pos, state.withProperty(PRESSED, true), 2);
- worldIn.setBlockState(pos.up(), Blocks.FIRE.getDefaultState(), 2);
- worldIn.playSound((EntityPlayer)null, pos, SoundEvents.BLOCK_STONE_PRESSPLATE_CLICK_ON, SoundCategory.BLOCKS, 0.3F, 0.6F);
- worldIn.scheduleUpdate(new BlockPos(pos), this, this.tickRate(worldIn));
- }
- }
- }
- }
- }
- public IBlockState getStateFromMeta(int meta)
- {
- return this.getDefaultState().withProperty(PRESSED, Boolean.valueOf(meta == 1));
- }
- public int getMetaFromState(IBlockState state)
- {
- return ((Boolean)state.getValue(PRESSED)).booleanValue() ? 1 : 0;
- }
- protected BlockStateContainer createBlockState()
- {
- return new BlockStateContainer(this, new IProperty[] {PRESSED});
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement