Skip to content

Commit

Permalink
feat: sapphire ore drops xp
Browse files Browse the repository at this point in the history
  • Loading branch information
SiverDX authored and TheBv committed Dec 26, 2023
1 parent d9f4e1e commit 18500ec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,43 +0,0 @@
package com.github.alexthe666.iceandfire.block;

import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.util.RandomSource;
import net.minecraft.util.valueproviders.IntProvider;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.properties.NoteBlockInstrument;
import net.minecraft.world.level.material.MapColor;
import org.jetbrains.annotations.NotNull;


public class BlockIafOre extends Block {
public Item itemBlock;

public BlockIafOre(int toollevel, float hardness, float resistance) {
super(
Properties
.of()
.mapColor(MapColor.STONE)
.instrument(NoteBlockInstrument.BASEDRUM)
.strength(hardness, resistance)
.requiresCorrectToolForDrops()
);
}

@Override
public void tryDropExperience(@NotNull ServerLevel level, @NotNull BlockPos pos, @NotNull ItemStack heldItem, @NotNull IntProvider amount) {
super.tryDropExperience(level, pos, heldItem, amount);
}


// FIXME :: Unused -> popExperience(...)
protected int getExperience(RandomSource rand) {
if (this == IafBlockRegistry.SAPPHIRE_ORE.get()) {
return Mth.nextInt(rand, 3, 7);
}
return 0;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
import com.github.alexthe666.iceandfire.item.IafItemRegistry;
import com.github.alexthe666.iceandfire.item.IafTabRegistry;
import com.github.alexthe666.iceandfire.misc.IafSoundRegistry;
import net.minecraft.client.resources.model.Material;
import net.minecraft.core.Direction;
import net.minecraft.util.valueproviders.UniformInt;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.StandingAndWallBlockItem;
Expand Down Expand Up @@ -42,10 +44,10 @@ public class IafBlockRegistry {
public static final RegistryObject<Block> GOLD_PILE = register("gold_pile", BlockGoldPile::new);
public static final RegistryObject<Block> SILVER_PILE = register("silver_pile", BlockGoldPile::new);
public static final RegistryObject<Block> COPPER_PILE = register("copper_pile", BlockGoldPile::new);
public static final RegistryObject<Block> SILVER_ORE = register("silver_ore", () -> new BlockIafOre(2, 3.0F, 3.0F));
public static final RegistryObject<Block> DEEPSLATE_SILVER_ORE = register("deepslate_silver_ore", () -> new BlockIafOre(2, 3.0F, 3.0F));
public static final RegistryObject<Block> SILVER_ORE = register("silver_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).strength(3, 3).requiresCorrectToolForDrops()));
public static final RegistryObject<Block> DEEPSLATE_SILVER_ORE = register("deepslate_silver_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.DEEPSLATE).strength(3,3).requiresCorrectToolForDrops()));
public static final RegistryObject<Block> SILVER_BLOCK = register("silver_block", () -> BlockGeneric.builder(3.0F, 5.0F, SoundType.METAL, MapColor.METAL, null, null, false));
public static final RegistryObject<Block> SAPPHIRE_ORE = register("sapphire_ore", () -> new BlockIafOre(2, 4.0F, 3.0F));
public static final RegistryObject<Block> SAPPHIRE_ORE = register("sapphire_ore", () -> new DropExperienceBlock(BlockBehaviour.Properties.of().mapColor(MapColor.STONE).strength(4,3).requiresCorrectToolForDrops(), UniformInt.of(3,7)));
public static final RegistryObject<Block> SAPPHIRE_BLOCK = register("sapphire_block", () -> BlockGeneric.builder(3.0F, 6.0F, SoundType.METAL, MapColor.METAL, null, null, false));
public static final RegistryObject<Block> CHARRED_DIRT = register("chared_dirt", () -> BlockReturningState.builder(0.5F, 0.0F, SoundType.GRAVEL, MapColor.DIRT, null, null, false, Blocks.DIRT.defaultBlockState()));
public static final RegistryObject<Block> CHARRED_GRASS = register("chared_grass", () -> BlockReturningState.builder(0.6F, 0.0F, SoundType.GRAVEL, MapColor.GRASS, null, null, false, Blocks.GRASS_BLOCK.defaultBlockState()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static void destroyAreaCharge(final Level level, final BlockPos center, f
}

if (dragon.getRandom().nextBoolean()) {
attackBlock(level, dragon, position);
attackBlock(level, dragon, position, state);
}
});
} else {
Expand Down Expand Up @@ -206,9 +206,7 @@ private static DamageSource getDamageSource(final EntityDragonBase dragon) {
}
}

private static void attackBlock(final Level level, final EntityDragonBase dragon, final BlockPos position) {
BlockState state = level.getBlockState(position);

private static void attackBlock(final Level level, final EntityDragonBase dragon, final BlockPos position, final BlockState state) {
if (state.getBlock() instanceof IDragonProof || !DragonUtils.canDragonBreak(state, dragon)) {
return;
}
Expand Down Expand Up @@ -249,6 +247,10 @@ private static void attackBlock(final Level level, final EntityDragonBase dragon
}
}

private static void attackBlock(final Level level, final EntityDragonBase dragon, final BlockPos position) {
attackBlock(level, dragon, position, level.getBlockState(position));
}

private static void applyDragonEffect(final LivingEntity target, final EntityDragonBase dragon, int statusDuration) {
if (DragonType.getType(dragon.getType()) == DragonType.FIRE) {
target.setSecondsOnFire(statusDuration);
Expand Down

0 comments on commit 18500ec

Please sign in to comment.