Jump to content

Sinsei

Members
  • Posts

    7
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Sinsei's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. I got a custom type of block and in that block i need to check the textures that come from the model.json So for example from the crafting_table.json i would need to get the texture "minecraft:block/crafting_table_top" from the texture "up": { "parent": "minecraft:block/cube", "textures": { "down": "minecraft:block/oak_planks", "east": "minecraft:block/crafting_table_side", "north": "minecraft:block/crafting_table_front", "particle": "minecraft:block/crafting_table_front", "south": "minecraft:block/crafting_table_side", "up": "minecraft:block/crafting_table_top", "west": "minecraft:block/crafting_table_front" } } Is this possible to get inside the block?
  2. I created an item that i can use to check if the player can see the center of a specific block like this: public static boolean lineOfSight(int maxRange, Entity player, BlockPos pos) { Vec3 vec3 = player.getEyePosition(); Vec3 vec31 = pos.getCenter(); if (vec31.distanceTo(vec3) > maxRange) { return false; } else { BlockHitResult result = player.level().clip(new ClipContext(vec3, vec31, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, player)); return result.getBlockPos().getCenter().equals(pos.getCenter()); } } This works as far as i need it. Now i wanted to create a block that can do the same. In this case: If the block can see the center of a specific block. I tried it in a similar way: public static boolean lineOfSight(int maxRange, Level pLevel, Vec3 posFrom, BlockPos posTo) { Vec3 vec31 = posTo.getCenter(); if (vec31.distanceTo(posFrom) > maxRange) { return false; } else { BlockHitResult result = pLevel.clip(new ClipContext(posFrom, vec31, ClipContext.Block.COLLIDER, ClipContext.Fluid.NONE, null)); return result.getBlockPos().getCenter().equals(posTo.getCenter()); } } But obviously this does not work, because this method always returns false. The explanation is simple: The block only can see itself, because i raycast/clip from inside of my block. Is there a simple way to use clip and skip this initial block where the raycast is coming from?
  3. I'm creating a custom staff, that can be used like a bow, meaning i can use it and it should "load" the staff. As far as i can see the interaction is pretty simple: activate the "draw" stage via overriding use and then when the mouse is released the "releaseUsing" and "useOnRelease" methods are called. What i want to achieve is between the activation and the release: I want to do stuff while it is drawn. For example i want to create particles and i want to stop the "drawn" stage in certain conditions. Is something like this possible and if so, where can i look? I'm also happy with examples from other mods. (For example i think that mana and artifice has something like that with the beam spells, but that mod is not open source).
  4. I created an item with different modes. To cycle through those modes i wanted to use shift left and right clicks with the item in hand. But i cant seem to find a way to hook myself into left clicks. Right clicks are easy: For right clicks on a Block i can use: @Override public InteractionResult useOn(UseOnContext pContext) For right clicks in the air i can use: @Override public InteractionResult useOn(UseOnContext pContext) For left clicks on block it also is kinda similar. I can just override this: @Override public boolean canAttackBlock(BlockState pState, Level pLevel, BlockPos pPos, Player pPlayer) But what about left clicks in the air? Obviously i can just say that you can only cycle through the modes when you look at a block, but that feels iffy to me.
  5. Okay, i went a little bit further down the rabbit hole.. For the randomtick method to be called in the serverlevel.java it needs to check the fluidstate.isRandomlyTicking(): FluidState fluidstate = blockstate2.getFluidState(); if (fluidstate.isRandomlyTicking()) { fluidstate.randomTick(this, blockpos3, this.random); } This is calling the isRandomlyTicking() method of the fluid that is associated (Fluidstate.java): public boolean isRandomlyTicking() { return this.getType().isRandomlyTicking(); } Now here comes the problem. The Fluid.java isRandomlyTicking method is always returning false, no matter the properties you gave it. So yeah, after overwriting that method it works now.
  6. I implemented a custom fluid like this: The registering of the Fluids public static final RegistryObject<ForgeFlowingFluid> LIQUID_SUGAR_FLUID_SOURCE = register("liquid_sugar_fluid_source", LiquidSugar.Source::new); public static final RegistryObject<ForgeFlowingFluid> LIQUID_SUGAR_FLUID_FLOW = register("liquid_sugar_fluid_flow", LiquidSugar.Flowing::new); The registering of the Sourceblock public static final RegistryObject<LiquidBlock> LIQUID_SUGAR_BLOCK = BLOCKS.register("liquid_sugar_block", () -> new LiquidSugarFluidBlock(ModFluids.LIQUID_SUGAR_FLUID_SOURCE, BlockBehaviour.Properties.copy(Blocks.WATER).randomTicks().noLootTable())); Now i tried adding randomTicks (i want the fluid to change blocks around it) but i cannot seem to get it to work: @Override public void randomTick(Level pLevel, BlockPos pPos, FluidState pState, RandomSource pRandom) { DevUtil.outputDevMessage("randomTick0"); if(!pLevel.isClientSide()) { DevUtil.outputDevMessage("randomTick1"); for (int x = RADIUS; x >= -RADIUS; x -= 1) { for (int y = RADIUS; y >= -RADIUS; y -= 1) { for (int z = RADIUS; z >= -RADIUS; z -= 1) { if ((Math.abs(x * x) + Math.abs(y * y) + Math.abs(z * z)) <= (RADIUS * RADIUS) + RADIUS) { DevUtil.outputDevMessage("randomTick2"); BlockPos pos = pPos.offset(x, y, z); BlockState state = pLevel.getBlockState(pos); changeBlock(pLevel, pos, state); } } } } } } To test why it doesnt work i added those outputDevMessage calls. They work in other functions that are called, but not in this one. So i assume that the randomTicks are not called at all. I had this randomTick method in the Block class of the fluid as well as in the liquid class, no sucess with both. Anyone know what i'm doing wrong?
  7. Hi, i made a custom crop (melon/pumpkin like plant that grows cakes) and would like to change the block it can grow on from Farmland to another one (custom block as well, a muffin block). But i cannot get it to work 100%. I tried creating my own custom SweetAttachedStemBlock and SweetStemBlock classes which extend the vanilla AttachedStemBlock and Stemblock classes. In those i have overridden the protected boolean mayPlaceOn(BlockState pState, BlockGetter pLevel, BlockPos pPos) { return pState.is(Blocks.FARMLAND); } method to protected boolean mayPlaceOn(BlockState pState, BlockGetter pLevel, BlockPos pPos) { return pState.is(Blocks.Stone); } (Stone just to try it out). And it works that i can plant my seeds on stone. But i still can plant the seeds on farmland. Is there a way to remove the possibility to plant it on a farmland?
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.