Advertisement
SforzandoCF

another btwce thingk

Oct 25th, 2024
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.16 KB | None | 0 0
  1. package com.sforzando.btwce;
  2.  
  3. public class BonusBasketFeature extends Feature<DefaultFeatureConfig> {
  4.     public BonusBasketFeature (Codec<DefaultFeatureConfig> codec) {
  5.         super (codec);
  6.     }
  7.    
  8.     public boolean generate (FeatureContext<DefaultFeatureConfig> ctx) {
  9.         RandomSource random = ctx.getRandom();
  10.         StructureWorldAccess world = ctx.getWorld();
  11.         ChunkPos chunk = new ChunkPos(ctx.origin());
  12.         IntArrayList chunkXList = Util.toShuffledList(IntStream.rangeClosed(chunk.getMinBlockX(), chunk.getMaxBlockX()), random);
  13.         IntArrayList chunkZList = Util.toShuffledList(IntStream.rangeClosed(chunk.getMinBlockZ(), chunk.getMaxBlockZ()), random);
  14.         BlockPos.MutableBlockPos pos = new BlockPos.MutableBlockPos();
  15.         IntListIterator xIterator = chunkXList.iterator();
  16.        
  17.         while (xIterator.hasNext()) {
  18.             Integer x = (Integer)xIterator.next();
  19.             IntListIterator zIterator = zIterator.iterator();
  20.            
  21.             while (zIterator.hasNext()) {
  22.                 Integer z = (Integer)zIterator.next();
  23.                 pos.set(x, 0, z);
  24.                 BlockPos heightmapPos = world.getTopPosition(Heightmap.Type.MOTION_BLOCKING_NO_LEAVES, pos);
  25.                 if (world.isAir(heightmapPos) || world.getBlockState(pos).getCollisionShape(world, heightmapPos).isEmpty()) {
  26.                     world.setBlockState(heightmapPos, BTWBlocks.WICKER_BASKET.getDefaultState(), 2);
  27.                     if (world.getBlockEntity(heightmapPos) instanceof FCContainer fcc) fcc.add(new ItemStack(BTWItems.GOLDEN_DUNG));
  28.                     return true;
  29.                 }
  30.             }
  31.         }
  32.        
  33.         return false;
  34.     }
  35. }
  36.  
  37. public class BrickOvenRenderer implements BlockEntityRenderer<BrickOvenBlockEntity> {
  38.     private final ItemRenderer item;
  39.    
  40.     public BrickOvenRenderer (ItemRenderer ir) {
  41.         this.item = ir;
  42.     }
  43.    
  44.     public void render (BrickOvenBlockEntity entity, float tickDelta, MatrixStack matrices, VertexConsumerProvider vertexConsumers, int light, int overlay) {
  45.         matrices.push();
  46.         Item held = entity.getItem();
  47.         this.item.renderItem(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement