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

Kriptarus

Members
  • Posts

    9
  • Joined

  • Last visited

Recent Profile Visitors

313 profile views

Kriptarus's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. Thanks, i'll take a look. Seems the DayLightDetector works very similar Lamps too. That's a lot of good stuff in your project! Thanks.
  2. I researched for TileEntity and ITickableTileEntity, and i made it work with my custom block. But i still trying to update textures, properties, redstone power, ligth according some conditions. I was thinking in use TileEntityRender, is that the only option? Is there some simple examples using it?
  3. Hello, everyone. I searched in the forum about that, but i didn't find similar topics. So i decided to ask. I'm trying to do a bunch of things that i still don't know if it is possible for Blocks. Basically, i need to make the block changes it's own properties/instance variables/textures dynamically, based in some conditions. - Is each block posted in the world a completely new instance of it's class? - Is it possible for the same block already posted to keep being updated constantly? - I don't want to make the block keep values after it being broke, but in i'll need to manipulate variables while it exists in the world.
  4. /** * Verify if the current block is near by some block */ protected boolean isNearBy(IBlockReader blockReader, BlockPos blockPos, List<Block> arBlocks) { Stream<BlockPos> blocksAround = BlockPos.getAllInBox( new BlockPos(blockPos.getX() -1, blockPos.getY() -1, blockPos.getZ() -1), new BlockPos(blockPos.getX() +1, blockPos.getY() +1, blockPos.getZ() +1)); long count = blocksAround.filter(ba -> arBlocks.contains(blockReader.getBlockState(ba).getBlock())).count(); return count > 0; } I looked around about getAllInBox(), seems that the two parameters are the beginning and end of the volume. About comparing blocks, it was so simple that a didn't think on that. ._. Thanks!
  5. Both of then. I need to undertand how to check all blocks around (including diagonals), and compare if they are equal to one of the blocks in the array. (my TODO) Probably i'll need to check diagonals for fluids as well... (the overloaded method)
  6. Sorry if i'm resurrecting this topic, but i'm looking exactly for a solution very similar to that. I tried to adapt to my logic, but i'm doing something wrong. Basically, i need to verify if there's at least one of an array of blocks around my Custom Block. package com.ouroboros.plantae.objects.blocks; import java.util.Random; import javax.annotation.Nullable; import com.ouroboros.plantae.init.BlockInit; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; import net.minecraft.fluid.Fluid; import net.minecraft.fluid.IFluidState; import net.minecraft.item.BlockItemUseContext; import net.minecraft.tags.FluidTags; import net.minecraft.tags.Tag; import net.minecraft.util.Direction; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockReader; import net.minecraft.world.IWorld; import net.minecraft.world.server.ServerWorld; public class VibraniumBlock extends Block { public VibraniumBlock(Block.Properties properties) { super(properties); } /** * Change the block */ @Override public void func_225534_a_(BlockState blockState, ServerWorld serverWorld, BlockPos blockPos, Random random) { boolean absorbingHeat = this.isNearBy(serverWorld, blockPos, FluidTags.LAVA) || this.isNearBy(serverWorld, serverWorld, blockPos, Blocks.MAGMA_BLOCK); boolean losingHeat = this.isNearBy(serverWorld, blockPos, FluidTags.WATER) || this.isNearBy(serverWorld, serverWorld, blockPos, Blocks.ICE, Blocks.BLUE_ICE, Blocks.FROSTED_ICE ,Blocks.PACKED_ICE, Blocks.SNOW); if(absorbingHeat && losingHeat) { serverWorld.setBlockState(blockPos, BlockInit.vibranium_block.getDefaultState(), 2); } else if(absorbingHeat) { serverWorld.setBlockState(blockPos, BlockInit.vibranium_heated_block.getDefaultState(), 2); } else if(losingHeat) { //serverWorld.setBlockState(blockPos, BlockInit.vibranium_frozen_block.getDefaultState(), 2); } } @Override @Nullable public BlockState getStateForPlacement(BlockItemUseContext context) { scheduleTick(context.getWorld(), context.getPos()); return this.getDefaultState(); } /** * Update the provided state given the provided neighbor facing and neighbor state, returning a new state. * For example, fences make their connections to the passed in state if possible, and wet concrete powder immediately * returns its solidified counterpart. * Note that this method should ideally consider only the specific face passed in. */ @Override public BlockState updatePostPlacement(BlockState stateIn, Direction facing, BlockState facingState, IWorld worldIn, BlockPos currentPos, BlockPos facingPos) { scheduleTick(worldIn, currentPos); return stateIn; } private void scheduleTick(IWorld worldIn, BlockPos currentPos) { if(this.isNearBy(worldIn, currentPos, FluidTags.LAVA)) worldIn.getPendingBlockTicks().scheduleTick(currentPos, this, 60 + worldIn.getRandom().nextInt(40)); } /** * Verify if the current block is near by facing some fluid */ protected boolean isNearBy(IBlockReader blockReader, BlockPos blockPos, Tag<Fluid> fluid) { IFluidState iFluidState; for(Direction direction : Direction.values()) { iFluidState = blockReader.getFluidState(blockPos.offset(direction)); if(iFluidState.isTagged(fluid)) return true; } return false; } /** * Verify if the current block is near by facing some block */ protected boolean isNearBy(ServerWorld serverWorld, IBlockReader blockReader, BlockPos blockPos, Block ...arBlocks) { BlockState blockState; for(Direction direction : Direction.values()) { blockState = blockReader.getBlockState(blockPos.offset(direction)); for(Block block: arBlocks) { //TODO: Verify if, at least, one of the blocks are placed around this block } } return false; } }
  7. I found the problem! Looking better at the villagerTrades and comparing with your suggestion, i notice that i forgot to add @subscribeEvent at the method. So, basically, every new kind of event that i create, i must use @subscribeEvent for Forge recognizes then, right?
  8. Thank you for the explanation, It help me a lot. I'm starting to understand how Forge/MC works. After adapting and testing i finally made Villagers recognizes my custom PointOfView and changes Profession. For some reason i still stuck on setting trades for that new Profession, seems like the villagerTrades method is not been called (even when initialized in the mod constructor). Their GUI for trades doesn't appear and they shake heads like an Unemployed Villager. Is there something that i need to pay more attention to understand it better?
  9. I'm getting the same issue about PointOfInterestType and VillagerProfession. I wonder why the constructor modifier was changed to private in [1.15.2], there are some codes i saw in [1.14.*] that uses those constructors like they was public. I found this topic interesting: [1.14.4] Villagers Professions (Fix) & Trades
×
×
  • Create New...

Important Information

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