Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Drachenbauer

Members
  • Posts

    724
  • Joined

  • Last visited

Everything posted by Drachenbauer

  1. And i sayd, i already use onBlockClicked I saw, the cactus uses onEntityCollision to deal damage. So i thaught, this one can use it to activate.
  2. I have this all. tick is alright from the vanilla redstone ore. It activates , if i walk on it or right click it. But not if i run against it´s vertical side or leftvlick it with a weapon or tool. And i notice, it activates, if an arrow hit´s it´s vertical side, but not if it hit´s it´s top. and stays activated forever. It activates correctly at: -walking on it -rightclick it It scould activate, too at -leftclicking it with a sword(in creative for not braking it) or something else in survival (while the braking-process) -walking against a vertical wall out of theese blocks. -jump under such a block in a two block high gap -shooting projectiles at it (no matter if side or top)
  3. And how can i make it activate, if i run into it (if i use onEntityCollision, nothing happens): And how do i activate it on leftclick it with a sword or other tool?
  4. package drachenbauer32.yellowredstonemod.blocks; import java.util.Random; import net.minecraft.block.Block; 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; 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); ITickList<Block> tickList = world.getPendingBlockTicks(); tickList.scheduleTick(pos, state.getBlock(), 80); if (!state.get(LIT)) { 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); } } } } And how can i make it activate, if i run into it, or leftclick it with a sword or other tool?
  5. Now i have a platform of theese blocks and as i walked multiple times diagonally over them. At one try two blocks stayed activated. Why this could happen?
  6. Now it stays activated all the time. In thr RedstoneOreBlock there is already the deacttivation in the method "thick". so atfirst i removed that method override. Must i override it and put something more into it? Edit if i activate them in the actual test, it works, but there are some activated from a prvious test. Why they stay activated?
  7. Then it must be fine, if i delete it from my registration for overriding the block.
  8. I found this in just this seccond. But i still cannot put the name of my block class in there. Should i use the name from the registration of this block (in my case with .get(), because it is a RegistryObject)?
  9. 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".
  10. You sayd: But for me the middle parameter is not Block, it´s Object. What must i put there? And to the thing, what you don´t understand: For the original redstone ore, it goes a bit random, how long it waits until it switches off. But that random value is not given in the RedstoneOreBlock class, it´s, where tick is called. tick is called by randomTick of the basic Block class. And because of that name i think, that one is called randomly, what gives the random effect of the vanilla RedstoneOre.
  11. In the method tick of this block holds only the command switch it off. But if i go deeper with call hirachy or show references, i find something, that adds a random value. How do i set the numberOfTicks to 80 ticks?
  12. I´m not sure, how exactly to use World#getPendingBlockTicks. For te redstone ore, it seems like the tick method is called a bit randomly... How do i make it call this method exactly 80 ticks after activate?
  13. why not? In my AngryBirdsMod i use a siminar way to count ticks until deflating for the inflatable bird. Now i thaught, every block of this type, that actually exist in the world, uses it´s own instance of this class. What else should i do?
  14. Hello I want to make the redstone ore glow for exact 4 secconds (80 ticks). So i tried this in my overridden class for the redstone ore: But it does not exactly, what i want. If i activate some blocks of that redstone ore with a few secconds delay, they switch off almost in the same moment. If i stand on one of them and some more are activated, they all stay activated, until i leave them and wait a few secconds. If i strike one with a sword, it only blinks short (only if one is already activated, the striked one stays activated until the other one switches off). I want them glow for 4 secconds after last activating, no matter, how they are activated (step on them, rightclick them, place something on them, strike them with a weapon). What one of them does, should not have an effect on others. What must i change in my code?
  15. Now i´ve overridden the blockitems the same way as the blocks. Now they are back in the sceative iinventory and placing the redstone-torch at walls works too.
  16. About the blockitems: I think, he just meaned, i don´ have to create blockitems with custom registrynames, i have to override them like the blocks, giving them the existing vanilla registrynames. Now they appear in the creative inventory and i can place redstone torches successfully at walls, too.
  17. I know, that they are items there. How do i fix this? Animefan8888 sayd in the other thread, that there is no need to override the blockitems too... With a give-command i get working blockitems. Just, if i try to place the wall-type of the redstone-torch, a weird bug-block with name "air" and red particles appears. And i wonder why torches and heads are coded as two blocks, one for wall and one for ground? What about just choosing a model by blockstate-json?
  18. May try your model without the "blocks/" part in the blockstates. in a ForgeDokumentation about this, i saw this part only at textures, not at models.
  19. Hello I overrided some minecraft-blocks (register with original vanilla registrynames) to change theil particles. Now their blockitems are disappeared from the creative menu... Why this?
  20. push i still need help with the things i told in the last two posts. If i point towards that bugged wall-torch and have the screen-infos active (f3), it says targeted block:air And nothing happens in the output-console, if i place this thing...
  21. Now i noticed two weird things: 1. the Redstone-components, that i registered this way, are removed from the creative inventory. I can get them with a command and most of them work normal, but their slots in the creative inventory are empty 2. if i try to place a redstone-torch at the side of a block (for a wall-torch), it appears as a black-purple bug-block and with red dust particles. I registered the redstone wall torch tha same way, as the vertical standing one. I extended it´s own class and made the registry with it´s specific registry name. Why this happens?
  22. is there any way to make the particles "glow" in exact the choosen color (without any shading or something like that)?
  23. I know. i just sayd, there is some little random effect, that makes the particles appear in slightly different shades of yellow now. I want to know how to get rid of this effect.
  24. what are the numbers at the end of your post? i see only the four colour-parameters in the constructor, if i open the class...
×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.