Add some basic spotless formatting rules.
This commit is contained in:
parent
d2e4b92984
commit
4c037bd80b
127 changed files with 590 additions and 654 deletions
|
@ -40,84 +40,84 @@ import java.nio.file.Paths
|
|||
import java.util.List
|
||||
|
||||
class OreDistributionVisualiser {
|
||||
private static final Color[] colors = new Color[] {
|
||||
Color.black,
|
||||
Color.red,
|
||||
Color.pink,
|
||||
Color.orange,
|
||||
Color.yellow,
|
||||
Color.green,
|
||||
Color.magenta,
|
||||
Color.cyan,
|
||||
Color.blue
|
||||
}
|
||||
private static final Color[] colors = new Color[] {
|
||||
Color.black,
|
||||
Color.red,
|
||||
Color.pink,
|
||||
Color.orange,
|
||||
Color.yellow,
|
||||
Color.green,
|
||||
Color.magenta,
|
||||
Color.cyan,
|
||||
Color.blue
|
||||
}
|
||||
|
||||
static void main(String[] args) {
|
||||
// Start the game up enough
|
||||
SharedConstants.createGameVersion()
|
||||
Bootstrap.initialize()
|
||||
static void main(String[] args) {
|
||||
// Start the game up enough
|
||||
SharedConstants.createGameVersion()
|
||||
Bootstrap.initialize()
|
||||
|
||||
generateOreDistributionVisualization()
|
||||
}
|
||||
generateOreDistributionVisualization()
|
||||
}
|
||||
|
||||
static void generateOreDistributionVisualization() throws IOException {
|
||||
def heightContext = new FixedHeightContext(-64, 360)
|
||||
static void generateOreDistributionVisualization() throws IOException {
|
||||
def heightContext = new FixedHeightContext(-64, 360)
|
||||
|
||||
BufferedImage bi = new BufferedImage(450, 220, BufferedImage.TYPE_INT_ARGB)
|
||||
Graphics2D png = bi.createGraphics()
|
||||
Font font = new Font("TimesRoman", Font.BOLD, 20)
|
||||
png.setFont(font)
|
||||
BufferedImage bi = new BufferedImage(450, 220, BufferedImage.TYPE_INT_ARGB)
|
||||
Graphics2D png = bi.createGraphics()
|
||||
Font font = new Font("TimesRoman", Font.BOLD, 20)
|
||||
png.setFont(font)
|
||||
|
||||
png.setPaint(Color.black)
|
||||
// Draw 0
|
||||
png.drawLine(0, -heightContext.minY, (overworldOres().size() * 10) + 20, -heightContext.minY)
|
||||
png.setPaint(Color.black)
|
||||
// Draw 0
|
||||
png.drawLine(0, -heightContext.minY, (overworldOres().size() * 10) + 20, -heightContext.minY)
|
||||
|
||||
png.setPaint(Color.blue)
|
||||
// Draw ground
|
||||
png.drawLine(0, -heightContext.minY + 64, (overworldOres().size() * 10) + 20, -heightContext.minY + 64)
|
||||
png.setPaint(Color.blue)
|
||||
// Draw ground
|
||||
png.drawLine(0, -heightContext.minY + 64, (overworldOres().size() * 10) + 20, -heightContext.minY + 64)
|
||||
|
||||
int c = 1
|
||||
for (OreDistribution value : overworldOres()) {
|
||||
png.setPaint(colors[c])
|
||||
int c = 1
|
||||
for (OreDistribution value : overworldOres()) {
|
||||
png.setPaint(colors[c])
|
||||
|
||||
def yMin = value.minOffset.getY(heightContext) + -heightContext.minY
|
||||
def yMax = -heightContext.minY + value.maxY
|
||||
def yMin = value.minOffset.getY(heightContext) + -heightContext.minY
|
||||
def yMax = -heightContext.minY + value.maxY
|
||||
|
||||
png.fill3DRect(c * 10, yMin, 10, yMax - yMin, true)
|
||||
png.fill3DRect(c * 10, yMin, 10, yMax - yMin, true)
|
||||
|
||||
png.drawString(value.name() + "(%d -> %d)".formatted(value.minOffset.getY(heightContext), value.maxY), 190, 25 * c)
|
||||
png.drawString(value.name() + "(%d -> %d)".formatted(value.minOffset.getY(heightContext), value.maxY), 190, 25 * c)
|
||||
|
||||
c += 1
|
||||
}
|
||||
c += 1
|
||||
}
|
||||
|
||||
ImageIO.write(bi, "PNG", Paths.get("ore_distribution.png").toFile())
|
||||
}
|
||||
ImageIO.write(bi, "PNG", Paths.get("ore_distribution.png").toFile())
|
||||
}
|
||||
|
||||
private static List<OreDistribution> overworldOres() {
|
||||
return Arrays.stream(OreDistribution.values())
|
||||
.filter(ore -> ore.dimension == TargetDimension.OVERWORLD)
|
||||
.toList()
|
||||
}
|
||||
private static List<OreDistribution> overworldOres() {
|
||||
return Arrays.stream(OreDistribution.values())
|
||||
.filter(ore -> ore.dimension == TargetDimension.OVERWORLD)
|
||||
.toList()
|
||||
}
|
||||
|
||||
private static class FixedHeightContext extends HeightContext {
|
||||
final int minY
|
||||
final int height
|
||||
private static class FixedHeightContext extends HeightContext {
|
||||
final int minY
|
||||
final int height
|
||||
|
||||
FixedHeightContext(int minY, int height) {
|
||||
super(new DebugChunkGenerator(BuiltinRegistries.BIOME), EmptyBlockView.INSTANCE)
|
||||
FixedHeightContext(int minY, int height) {
|
||||
super(new DebugChunkGenerator(BuiltinRegistries.BIOME), EmptyBlockView.INSTANCE)
|
||||
|
||||
this.minY = minY
|
||||
this.height = height
|
||||
}
|
||||
this.minY = minY
|
||||
this.height = height
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMinY() {
|
||||
return minY
|
||||
}
|
||||
@Override
|
||||
int getMinY() {
|
||||
return minY
|
||||
}
|
||||
|
||||
@Override
|
||||
int getHeight() {
|
||||
return height
|
||||
}
|
||||
}
|
||||
@Override
|
||||
int getHeight() {
|
||||
return height
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,9 +37,9 @@ import java.lang.reflect.Method
|
|||
*/
|
||||
@Slf4j
|
||||
abstract class TRGameTest implements FabricGameTest {
|
||||
@Override
|
||||
void invokeTestMethod(TestContext context, Method method) {
|
||||
try {
|
||||
@Override
|
||||
void invokeTestMethod(TestContext context, Method method) {
|
||||
try {
|
||||
method.invoke(this, new TRTestContext(context))
|
||||
} catch (TRGameTestException gameTestException) {
|
||||
log.error("Test ${method.name} failed with message ${gameTestException.message}", gameTestException.cause)
|
||||
|
@ -49,7 +49,7 @@ abstract class TRGameTest implements FabricGameTest {
|
|||
log.error("Test ${method.name} failed", throwable)
|
||||
throw throwable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static class TRGameTestException extends AssertionError {
|
||||
TRGameTestException(String message, Throwable cause) {
|
||||
|
|
|
@ -32,28 +32,28 @@ import reborncore.common.blockentity.MachineBaseBlockEntity
|
|||
import techreborn.init.TRContent
|
||||
|
||||
class TRTestContext extends TestContext {
|
||||
TRTestContext(TestContext parentContext) {
|
||||
//noinspection GroovyAccessibility
|
||||
super(parentContext.test)
|
||||
}
|
||||
TRTestContext(TestContext parentContext) {
|
||||
//noinspection GroovyAccessibility
|
||||
super(parentContext.test)
|
||||
}
|
||||
|
||||
/**
|
||||
* Place a machine with a creative solar panel
|
||||
*/
|
||||
def poweredMachine(TRContent.Machine machine, @DelegatesTo(MachineContext) Closure machineContextClosure) {
|
||||
def machinePos = new BlockPos(0, 2, 0)
|
||||
setBlockState(machinePos, machine.block)
|
||||
setBlockState(machinePos.down(), TRContent.SolarPanels.CREATIVE.block)
|
||||
/**
|
||||
* Place a machine with a creative solar panel
|
||||
*/
|
||||
def poweredMachine(TRContent.Machine machine, @DelegatesTo(MachineContext) Closure machineContextClosure) {
|
||||
def machinePos = new BlockPos(0, 2, 0)
|
||||
setBlockState(machinePos, machine.block)
|
||||
setBlockState(machinePos.down(), TRContent.SolarPanels.CREATIVE.block)
|
||||
|
||||
waitAndRun(5) {
|
||||
try {
|
||||
new MachineContext(machinePos).with(machineContextClosure)
|
||||
} catch (e) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
waitAndRun(5) {
|
||||
try {
|
||||
new MachineContext(machinePos).with(machineContextClosure)
|
||||
} catch (e) {
|
||||
e.printStackTrace()
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def machine(TRContent.Machine machine, @DelegatesTo(MachineContext) Closure machineContextClosure) {
|
||||
def machinePos = new BlockPos(0, 1, 0)
|
||||
|
@ -69,59 +69,59 @@ class TRTestContext extends TestContext {
|
|||
}
|
||||
}
|
||||
|
||||
class MachineContext {
|
||||
final BlockPos machinePos
|
||||
class MachineContext {
|
||||
final BlockPos machinePos
|
||||
|
||||
MachineContext(BlockPos machinePos) {
|
||||
this.machinePos = machinePos
|
||||
}
|
||||
MachineContext(BlockPos machinePos) {
|
||||
this.machinePos = machinePos
|
||||
}
|
||||
|
||||
def input(ItemConvertible item, int slot = -1) {
|
||||
this.input(new ItemStack(item), slot)
|
||||
}
|
||||
def input(ItemConvertible item, int slot = -1) {
|
||||
this.input(new ItemStack(item), slot)
|
||||
}
|
||||
|
||||
def input(ItemStack stack, int slot = -1) {
|
||||
if (slot == -1) {
|
||||
// If not slot is provided use the first input slot
|
||||
slot = blockEntity.crafter.inputSlots[0]
|
||||
}
|
||||
def input(ItemStack stack, int slot = -1) {
|
||||
if (slot == -1) {
|
||||
// If not slot is provided use the first input slot
|
||||
slot = blockEntity.crafter.inputSlots[0]
|
||||
}
|
||||
|
||||
blockEntity.inventory.setStack(slot, stack)
|
||||
}
|
||||
blockEntity.inventory.setStack(slot, stack)
|
||||
}
|
||||
|
||||
def expectOutput(ItemConvertible item, int ticks, int slot = -1) {
|
||||
expectOutput(new ItemStack(item), ticks, slot)
|
||||
}
|
||||
def expectOutput(ItemConvertible item, int ticks, int slot = -1) {
|
||||
expectOutput(new ItemStack(item), ticks, slot)
|
||||
}
|
||||
|
||||
def expectOutput(ItemStack stack, int ticks, int slot = -1) {
|
||||
if (slot == -1) {
|
||||
// If not slot is provided use the first output slot
|
||||
slot = blockEntity.crafter.outputSlots[0]
|
||||
}
|
||||
def expectOutput(ItemStack stack, int ticks, int slot = -1) {
|
||||
if (slot == -1) {
|
||||
// If not slot is provided use the first output slot
|
||||
slot = blockEntity.crafter.outputSlots[0]
|
||||
}
|
||||
|
||||
addFinalTaskWithDuration(ticks) {
|
||||
if (!blockEntity.inventory.getStack(slot).isItemEqual(stack)) {
|
||||
throwGameTestException("Failed to find $stack in slot $slot")
|
||||
}
|
||||
}
|
||||
}
|
||||
addFinalTaskWithDuration(ticks) {
|
||||
if (!blockEntity.inventory.getStack(slot).isItemEqual(stack)) {
|
||||
throwGameTestException("Failed to find $stack in slot $slot")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def withUpgrades(TRContent.Upgrades upgrade, int count = -1) {
|
||||
count = (count != -1 ? count : blockEntity.getUpgradeSlotCount()) -1
|
||||
def withUpgrades(TRContent.Upgrades upgrade, int count = -1) {
|
||||
count = (count != -1 ? count : blockEntity.getUpgradeSlotCount()) -1
|
||||
|
||||
(0..count).each {
|
||||
blockEntity.upgradeInventory.setStack(it, new ItemStack(upgrade))
|
||||
}
|
||||
}
|
||||
(0..count).each {
|
||||
blockEntity.upgradeInventory.setStack(it, new ItemStack(upgrade))
|
||||
}
|
||||
}
|
||||
|
||||
MachineBaseBlockEntity getBlockEntity() {
|
||||
def be = getBlockEntity(machinePos)
|
||||
def be = getBlockEntity(machinePos)
|
||||
|
||||
if (!be) {
|
||||
throwPositionedException("Failed to get machine block entity", machinePos)
|
||||
}
|
||||
if (!be) {
|
||||
throwPositionedException("Failed to get machine block entity", machinePos)
|
||||
}
|
||||
|
||||
return be as MachineBaseBlockEntity
|
||||
}
|
||||
}
|
||||
return be as MachineBaseBlockEntity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,17 +31,17 @@ import techreborn.test.TRGameTest
|
|||
import techreborn.test.TRTestContext
|
||||
|
||||
class GrinderTest extends TRGameTest {
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 150)
|
||||
def testGrind2OCs(TRTestContext context) {
|
||||
/**
|
||||
* Test that grinder with 2 overclocker upgrades grinds coal into coal dust in 116 ticks
|
||||
*/
|
||||
context.poweredMachine(TRContent.Machine.GRINDER) {
|
||||
input(Items.COAL)
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 150)
|
||||
def testGrind2OCs(TRTestContext context) {
|
||||
/**
|
||||
* Test that grinder with 2 overclocker upgrades grinds coal into coal dust in 116 ticks
|
||||
*/
|
||||
context.poweredMachine(TRContent.Machine.GRINDER) {
|
||||
input(Items.COAL)
|
||||
|
||||
withUpgrades(TRContent.Upgrades.OVERCLOCKER, 2)
|
||||
withUpgrades(TRContent.Upgrades.OVERCLOCKER, 2)
|
||||
|
||||
expectOutput(TRContent.Dusts.COAL, 116)
|
||||
}
|
||||
}
|
||||
expectOutput(TRContent.Dusts.COAL, 116)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,18 +33,18 @@ import techreborn.test.TRGameTest
|
|||
import techreborn.test.TRTestContext
|
||||
|
||||
class IronAlloyFurnaceTest extends TRGameTest {
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 2000)
|
||||
def testIronAlloyFurnaceElectrumAlloyIngot(TRTestContext context) {
|
||||
/**
|
||||
* Test that the Iron Alloy Furnace smelts a gold ingot and a silver ingot into an electrum alloy ingot in 200
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 2000)
|
||||
def testIronAlloyFurnaceElectrumAlloyIngot(TRTestContext context) {
|
||||
/**
|
||||
* Test that the Iron Alloy Furnace smelts a gold ingot and a silver ingot into an electrum alloy ingot in 200
|
||||
* Verifies: Issue #2850
|
||||
*/
|
||||
context.machine(TRContent.Machine.IRON_ALLOY_FURNACE) {
|
||||
*/
|
||||
context.machine(TRContent.Machine.IRON_ALLOY_FURNACE) {
|
||||
input(Items.COAL_BLOCK, IronAlloyFurnaceBlockEntity.FUEL_SLOT)
|
||||
input(Items.GOLD_INGOT, IronAlloyFurnaceBlockEntity.INPUT_SLOT_1)
|
||||
input(TRContent.Ingots.SILVER, IronAlloyFurnaceBlockEntity.INPUT_SLOT_2)
|
||||
input(Items.GOLD_INGOT, IronAlloyFurnaceBlockEntity.INPUT_SLOT_1)
|
||||
input(TRContent.Ingots.SILVER, IronAlloyFurnaceBlockEntity.INPUT_SLOT_2)
|
||||
|
||||
expectOutput(TRContent.Ingots.ELECTRUM, (int) (200 / TechRebornConfig.cookingScale), IronAlloyFurnaceBlockEntity.OUTPUT_SLOT)
|
||||
}
|
||||
}
|
||||
expectOutput(TRContent.Ingots.ELECTRUM, (int) (200 / TechRebornConfig.cookingScale), IronAlloyFurnaceBlockEntity.OUTPUT_SLOT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,17 @@ class IronFurnaceTest extends TRGameTest {
|
|||
}
|
||||
}
|
||||
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 2000)
|
||||
def testIronFurnaceSmeltRawIronBlock(TRTestContext context) {
|
||||
/**
|
||||
* Test that the Iron Furnace smelts a raw iron block into an iron block in 1500 ticks instead of 200
|
||||
@GameTest(templateName = "fabric-gametest-api-v1:empty", tickLimit = 2000)
|
||||
def testIronFurnaceSmeltRawIronBlock(TRTestContext context) {
|
||||
/**
|
||||
* Test that the Iron Furnace smelts a raw iron block into an iron block in 1500 ticks instead of 200
|
||||
* Verifies: Issue #2850
|
||||
*/
|
||||
context.machine(TRContent.Machine.IRON_FURNACE) {
|
||||
*/
|
||||
context.machine(TRContent.Machine.IRON_FURNACE) {
|
||||
input(Items.COAL_BLOCK, IronFurnaceBlockEntity.FUEL_SLOT)
|
||||
input(Items.RAW_IRON_BLOCK, IronFurnaceBlockEntity.INPUT_SLOT)
|
||||
input(Items.RAW_IRON_BLOCK, IronFurnaceBlockEntity.INPUT_SLOT)
|
||||
|
||||
expectOutput(Items.IRON_BLOCK, (int) (1500 / TechRebornConfig.cookingScale), IronFurnaceBlockEntity.OUTPUT_SLOT)
|
||||
}
|
||||
}
|
||||
expectOutput(Items.IRON_BLOCK, (int) (1500 / TechRebornConfig.cookingScale), IronFurnaceBlockEntity.OUTPUT_SLOT)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue