• Recently Browsing

    No registered users viewing this page.

  • Posts

    • 1.12 is no longer supported on these forums due to age. Please update to a modern version to receive support here.   More information on supported versions can be found in the LTS link at the top of every page.
    • package drachenbauer32.yellowredstonemod.blocks; import java.util.Random; import net.minecraft.block.BlockState; import net.minecraft.block.RedstoneOreBlock; import net.minecraft.entity.Entity; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.particles.RedstoneParticleData; import net.minecraft.util.ActionResultType; import net.minecraft.util.Direction; import net.minecraft.util.Hand; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockRayTraceResult; import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.server.ServerWorld; public class YellowRedstoneOreBlock extends RedstoneOreBlock { public YellowRedstoneOreBlock(Properties properties) { super(properties); } public void onBlockClicked(BlockState state, World worldIn, BlockPos pos, PlayerEntity player) { activate(state, worldIn, pos); } @Override public void onEntityWalk(World worldIn, BlockPos pos, Entity entityIn) { activate(worldIn.getBlockState(pos), worldIn, pos); } @Override public ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand handIn, BlockRayTraceResult hit) { activate(state, world, pos); if (world.isRemote) { return ActionResultType.SUCCESS; } else { return ActionResultType.PASS; } } private static void activate(BlockState state, World world, BlockPos pos) { spawnParticles(world, pos); if (!state.get(LIT)) { ITickList tickList = world.getPendingBlockTicks(); tickList.scheduleTick(pos, itemIn, 80); world.setBlockState(pos, state.with(LIT, Boolean.valueOf(true)), 3); } } @Override public void animateTick(BlockState state, World world, BlockPos pos, Random rand) { if(state.get(LIT)) { spawnParticles(world, pos); } } private static void spawnParticles(World world, BlockPos pos) { Random random = world.rand; for(Direction direction : Direction.values()) { BlockPos blockpos = pos.offset(direction); if (!world.getBlockState(blockpos).isOpaqueCube(world, blockpos)) { Direction.Axis direction$axis = direction.getAxis(); double d1 = direction$axis == Direction.Axis.X ? 0.5D + 0.5625D * (double)direction.getXOffset() : (double)random.nextFloat(); double d2 = direction$axis == Direction.Axis.Y ? 0.5D + 0.5625D * (double)direction.getYOffset() : (double)random.nextFloat(); double d3 = direction$axis == Direction.Axis.Z ? 0.5D + 0.5625D * (double)direction.getZOffset() : (double)random.nextFloat(); world.addParticle(new RedstoneParticleData(1.0F, 0.875F, 0.0F, 1.0F), (double)pos.getX() + d1, (double)pos.getY() + d2, (double)pos.getZ() + d3, 0.0D, 0.0D, 0.0D); } } } @Override public void tick(BlockState state, ServerWorld worldIn, BlockPos pos, Random rand) { } }   It´s in the method "activate".
    • 1.12 is no longer supported on these forums due to age. Please update to a modern version to receive support here.   More information on supported versions can be found in the LTS link at the top of every page.
    • 1.7 is no longer supported on these forums due to age. Please update to a modern version to receive support here.   More information on supported versions can be found in the LTS link at the top of every page.
    • It's random because when the Blocks.REDSTONE_ORE instance is created it looks like this new RedstoneOreBlock(Block.Properties.create(...).tickRandomly()...)... That tick randomly lets the game know to call the tick function randomly. Show all of your code.
  • Topics

  • Who's Online (See full list)