Skip to content

Commit

Permalink
Amber Rendering Changes + Amber Fluid Freezing
Browse files Browse the repository at this point in the history
  • Loading branch information
KekeCreations committed Aug 26, 2024
1 parent d93415c commit eb64ff6
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.uraneptus.sullysmod.core.other.tags.SMBlockTags;
import com.uraneptus.sullysmod.core.registry.SMBlocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.particles.BlockParticleOption;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -48,6 +49,21 @@ public RenderShape getRenderShape(BlockState pState) {
return RenderShape.MODEL;
}

@Override
public boolean skipRendering(BlockState pState, BlockState pAdjacentBlockState, Direction pSide) {
return pAdjacentBlockState.is(this) || super.skipRendering(pState, pAdjacentBlockState, pSide);
}

@Override
public float getShadeBrightness(BlockState pState, BlockGetter pLevel, BlockPos pPos) {
return 1.0F;
}

@Override
public boolean propagatesSkylightDown(BlockState pState, BlockGetter pReader, BlockPos pPos) {
return true;
}

public VoxelShape getCollisionShape(BlockState pState, BlockGetter pLevel, BlockPos pPos, CollisionContext pContext) {
BlockEntity blockEntity = pLevel.getBlockEntity(pPos);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,33 +55,6 @@ public Item getBucket() {
return SMItems.MOLTEN_AMBER_BUCKET.get();
}

@Override
public void tick(Level pLevel, BlockPos pPos, FluidState pState) {
super.tick(pLevel, pPos, pState);
RandomSource random = pLevel.getRandom();
int k = 5;
if (pState.isSource()) {
k = 15;
}
if (random.nextInt(k) == 0) {
boolean cooldown = true;
if (pLevel.dimension() == Level.NETHER) {
cooldown = false;
} else {
for (BlockPos pos : BlockPos.betweenClosed(pPos.offset(-1, -1, -1), pPos.offset(1, 1, 1))) {
if (pLevel.getBlockState(pos).is(SMBlockTags.MELTS_AMBER)) {
cooldown = false;
break;
}
}
}
if (cooldown) {
if (pLevel.getBlockState(pPos).getBlock() instanceof LiquidBlock) {
pLevel.setBlock(pPos, ForgeEventFactory.fireFluidPlaceBlockEvent(pLevel, pPos, pPos, SMBlocks.AMBER.get().defaultBlockState()), 3);
}
}
}
}

public void animateTick(Level pLevel, BlockPos pPos, FluidState pState, RandomSource pRandom) {
BlockPos blockpos = pPos.above();
Expand Down Expand Up @@ -135,7 +108,28 @@ public void randomTick(Level pLevel, BlockPos pPos, FluidState pState, RandomSou
}
}
}

int k = 2;
if (pState.isSource()) {
k = 15;
}
if (pRandom.nextInt(k) == 0) {
boolean cooldown = true;
if (pLevel.dimension() == Level.NETHER) {
cooldown = false;
} else {
for (BlockPos pos : BlockPos.betweenClosed(pPos.offset(-1, -1, -1), pPos.offset(1, 1, 1))) {
if (pLevel.getBlockState(pos).is(SMBlockTags.MELTS_AMBER) && !pLevel.getBlockState(pos).is(SMBlocks.MOLTEN_AMBER_BLOCK.get())) {
cooldown = false;
break;
}
}
}
if (cooldown) {
if (pLevel.getBlockState(pPos).getBlock() instanceof LiquidBlock) {
pLevel.setBlock(pPos, ForgeEventFactory.fireFluidPlaceBlockEvent(pLevel, pPos, pPos, SMBlocks.AMBER.get().defaultBlockState()), 3);
}
}
}
}

private boolean hasFlammableNeighbours(LevelReader pLevel, BlockPos pPos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public void addTags(HolderLookup.Provider pProvider) {
Blocks.CAMPFIRE,
Blocks.SOUL_CAMPFIRE,
Blocks.LAVA,
SMBlocks.AMBER_LANTERN.get()
SMBlocks.MOLTEN_AMBER_BLOCK.get()
);

//Forge Tags
Expand Down

0 comments on commit eb64ff6

Please sign in to comment.