-
Posts
727 -
Joined
-
Last visited
Everything posted by Drachenbauer
-
Now i created a collision-shape (applyed in getCollisionShape), that i slightly inside the block at the sides and botom. Now the thing with the collision works. Arrows at vertical side and from below work correctly, too. but the arrows, sticking in the side or bottom of the block, turn black, if the block switches off. And i cannot more place objects like torches and redstone wire at the block. It seems like it has not more all required properties of a solid block now. How can i keep it as a solid block and have onEntityCollision work? And i still wonder why leftclick with a sword and arrows, wich hit the top of the block, do not activate it.
-
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)
-
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?
-
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?
-
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".
-
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.
-
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?
-
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?
-
[1.15.1] Block - texture, model, blockstate - understanding
Drachenbauer replied to KillBill61's topic in Modder Support
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. -
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?