Skip to content

Commit

Permalink
minor fixesw + nitra buff
Browse files Browse the repository at this point in the history
  • Loading branch information
MBatt1 committed Oct 11, 2024
1 parent f1a2e95 commit e09b95d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import net.id.paradiselost.world.feature.tree.ParadiseLostSaplingGenerators;
import net.minecraft.block.*;
import net.minecraft.block.AbstractBlock.Settings;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.registry.Registries;
import net.minecraft.registry.Registry;
import net.minecraft.sound.BlockSoundGroup;
Expand Down Expand Up @@ -43,6 +44,10 @@ static class ParadiseLostFarmlandBlock extends FarmlandBlock {
ParadiseLostFarmlandBlock(Settings settings) {
super(settings);
}

public BlockState getPlacementState(ItemPlacementContext ctx) {
return !this.getDefaultState().canPlaceAt(ctx.getWorld(), ctx.getBlockPos()) ? ParadiseLostBlocks.DIRT.getDefaultState() : super.getPlacementState(ctx);
}
}

static class ParadiseLostPaneBlock extends PaneBlock {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private static Settings amberTiles() {
public static final SlabBlock GOLDEN_AMBER_TILE_SLAB = add("golden_amber_tile_slab", new SlabBlock(amberTiles()));
public static final ParadiseLostStairsBlock GOLDEN_AMBER_TILE_STAIRS = add("golden_amber_tile_stairs", new ParadiseLostStairsBlock(GOLDEN_AMBER_TILE.getDefaultState(), amberTiles()));

public static final Block BLOOMED_CALCITE = add("bloomed_calcite", new CropGrowthBlock(copy(CALCITE).ticksRandomly(), 2));
public static final CropGrowthBlock BLOOMED_CALCITE = add("bloomed_calcite", new CropGrowthBlock(copy(CALCITE).ticksRandomly(), 2));

protected static Settings flowerPot() {
return copy(POTTED_OAK_SAPLING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

public class NitraBlock extends Block {

private static final float BASE_EXPLOSIVE_POWER = 2.5F;

public NitraBlock(Settings settings) {
super(settings);
}
Expand Down Expand Up @@ -56,7 +58,7 @@ public void onDestroyedByExplosion(World world, BlockPos pos, Explosion explosio
}

public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
ignite(world, pos, 2F, null);
ignite(world, pos, BASE_EXPLOSIVE_POWER, null);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
world.spawnParticles(ParticleTypes.EXPLOSION_EMITTER, pos.getX(), pos.getY(), pos.getZ(), 1, 0.0, 0.0, 0.0, 0.0);
world.playSound(null, pos.getX(), pos.getY(), pos.getZ(), SoundEvents.ENTITY_GENERIC_EXPLODE, SoundCategory.BLOCKS, 4.0F, (1.0F + (world.random.nextFloat() - world.random.nextFloat()) * 0.2F) * 0.7F, random.nextLong());
Expand All @@ -80,7 +82,7 @@ protected ItemActionResult onUseWithItem(ItemStack stack, BlockState state, Worl
if (!itemStack.isOf(Items.FLINT_AND_STEEL) && !itemStack.isOf(Items.FIRE_CHARGE)) {
return super.onUseWithItem(stack, state, world, pos, player, hand, hit);
} else {
ignite(world, pos, 2F, player);
ignite(world, pos, BASE_EXPLOSIVE_POWER, player);
world.setBlockState(pos, Blocks.AIR.getDefaultState(), 11);
Item item = itemStack.getItem();
if (!player.isCreative()) {
Expand All @@ -101,7 +103,7 @@ public void onProjectileHit(World world, BlockState state, BlockHitResult hit, P
BlockPos blockPos = hit.getBlockPos();
Entity entity = projectile.getOwner();
if (projectile.isOnFire() && projectile.canModifyAt(world, blockPos)) {
ignite(world, blockPos, 2F, entity instanceof LivingEntity ? (LivingEntity) entity : null);
ignite(world, blockPos, BASE_EXPLOSIVE_POWER, entity instanceof LivingEntity ? (LivingEntity) entity : null);
world.removeBlock(blockPos, false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FarmlandBlockMixin {
@Inject(method = "setToDirt", at = @At("HEAD"), cancellable = true)
private static void onSetToDirt(@Nullable Entity entity, BlockState state, World world, BlockPos pos, CallbackInfo ci) {
if (state.isOf(ParadiseLostBlocks.FARMLAND)) {
BlockState blockState = pushEntitiesUpBeforeBlockChange(state, Blocks.DIRT.getDefaultState(), world, pos);
BlockState blockState = pushEntitiesUpBeforeBlockChange(state, ParadiseLostBlocks.DIRT.getDefaultState(), world, pos);
world.setBlockState(pos, blockState);
world.emitGameEvent(GameEvent.BLOCK_CHANGE, pos, GameEvent.Emitter.of(entity, blockState));
ci.cancel();
Expand Down

0 comments on commit e09b95d

Please sign in to comment.