Added XP for ores, fixes #2759

The ore XP drop is not done by JSON but by hard-coding as a second parameter to OreBlock.
This commit is contained in:
Ayutac 2022-01-20 02:34:33 +01:00
parent 55eb70742f
commit b7a42f0a01
2 changed files with 16 additions and 5 deletions

View file

@ -432,7 +432,8 @@ public class TRContent {
block = new OreBlock(FabricBlockSettings.of(Material.STONE) block = new OreBlock(FabricBlockSettings.of(Material.STONE)
.requiresTool() .requiresTool()
.sounds(name.startsWith("deepslate") ? BlockSoundGroup.DEEPSLATE : BlockSoundGroup.STONE) .sounds(name.startsWith("deepslate") ? BlockSoundGroup.DEEPSLATE : BlockSoundGroup.STONE)
.strength(2f, 2f) .strength(2f, 2f),
distribution.experienceDropped
); );
InitUtils.setup(block, name + "_ore"); InitUtils.setup(block, name + "_ore");

View file

@ -24,7 +24,11 @@
package techreborn.world; package techreborn.world;
import net.minecraft.util.math.intprovider.UniformIntProvider;
import net.minecraft.world.gen.YOffset; import net.minecraft.world.gen.YOffset;
import org.jetbrains.annotations.NotNull;
import java.util.Objects;
public enum OreDistribution { public enum OreDistribution {
BAUXITE(6, 12, YOffset.aboveBottom(0), 20, TargetDimension.OVERWORLD), BAUXITE(6, 12, YOffset.aboveBottom(0), 20, TargetDimension.OVERWORLD),
@ -32,10 +36,10 @@ public enum OreDistribution {
GALENA(8, 12, YOffset.aboveBottom(25), 40, TargetDimension.OVERWORLD), GALENA(8, 12, YOffset.aboveBottom(25), 40, TargetDimension.OVERWORLD),
IRIDIUM(3, 4, YOffset.aboveBottom(0), 0, TargetDimension.OVERWORLD), IRIDIUM(3, 4, YOffset.aboveBottom(0), 0, TargetDimension.OVERWORLD),
LEAD(6, 16, YOffset.aboveBottom(40), 40, TargetDimension.OVERWORLD), LEAD(6, 16, YOffset.aboveBottom(40), 40, TargetDimension.OVERWORLD),
PERIDOT(6, 6, YOffset.aboveBottom(0), 360, TargetDimension.END), PERIDOT(6, 6, YOffset.aboveBottom(0), 360, TargetDimension.END, UniformIntProvider.create(2,6)),
PYRITE(6, 6, YOffset.aboveBottom(0), 128, TargetDimension.NETHER), PYRITE(6, 6, YOffset.aboveBottom(0), 128, TargetDimension.NETHER),
RUBY(6, 8, YOffset.fixed(20), 120, TargetDimension.OVERWORLD), RUBY(6, 8, YOffset.fixed(20), 120, TargetDimension.OVERWORLD, UniformIntProvider.create(2,6)),
SAPPHIRE(6, 7, YOffset.fixed(20), 120, TargetDimension.OVERWORLD), SAPPHIRE(6, 7, YOffset.fixed(20), 120, TargetDimension.OVERWORLD, UniformIntProvider.create(2,6)),
SHELDONITE(6, 4, YOffset.aboveBottom(0), 360, TargetDimension.END), SHELDONITE(6, 4, YOffset.aboveBottom(0), 360, TargetDimension.END),
SILVER(6, 16, YOffset.aboveBottom(40), 60,TargetDimension.OVERWORLD), SILVER(6, 16, YOffset.aboveBottom(40), 60,TargetDimension.OVERWORLD),
SODALITE(6, 4, YOffset.aboveBottom(0), 360, TargetDimension.END), SODALITE(6, 4, YOffset.aboveBottom(0), 360, TargetDimension.END),
@ -47,13 +51,19 @@ public enum OreDistribution {
public final int veinsPerChunk; public final int veinsPerChunk;
public final YOffset minOffset; public final YOffset minOffset;
public final int maxY; // Max height of ore in numbers of blocks from the bottom of the world public final int maxY; // Max height of ore in numbers of blocks from the bottom of the world
public @NotNull final UniformIntProvider experienceDropped;
public final TargetDimension dimension; public final TargetDimension dimension;
OreDistribution(int veinSize, int veinsPerChunk, YOffset minOffset, int maxY, TargetDimension dimension) { OreDistribution(int veinSize, int veinsPerChunk, YOffset minOffset, int maxY, TargetDimension dimension, UniformIntProvider experienceDropped) {
this.veinSize = veinSize; this.veinSize = veinSize;
this.veinsPerChunk = veinsPerChunk; this.veinsPerChunk = veinsPerChunk;
this.minOffset = minOffset; this.minOffset = minOffset;
this.maxY = maxY; this.maxY = maxY;
this.experienceDropped = Objects.requireNonNullElse(experienceDropped, UniformIntProvider.create(0,0));
this.dimension = dimension; this.dimension = dimension;
} }
OreDistribution(int veinSize, int veinsPerChunk, YOffset minOffset, int maxY, TargetDimension dimension) {
this(veinSize, veinsPerChunk, minOffset, maxY, dimension, null);
}
} }