Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 0.3.9.110021

Grass steps and corners use the same snow appearance as grass slabs. Exposed grass beneath snowy pieces also gains a matching snowy side.

- Directional slab placement can be turned off from the Mods menu.
- Vanilla items stay in their usual creative tabs.

## 0.3.7.110021

- Use a shovel to turn dirt and grass steps and corners into matching path
Expand Down
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ Pieces doesn't generate terrain.
pieces; corners are eighth-block pieces.
- Matching pieces can join into supported larger shapes or a full block.
Different materials don't combine.
- Find the pieces, including the vanilla items the mod reuses, in the
**Sky's Building Pieces** creative tab.
- Find the new pieces in the **Sky's Building Pieces** creative tab. Vanilla
pieces stay in their usual tabs.
- To use ordinary horizontal placement for regular slabs, open **Mods → Sky's
Building Pieces → Config** and turn off **Directional slab placement**. Restart
Minecraft after saving.

Walls have lower panels with posts at ends, corners and junctions. A torch or
block above keeps a supporting post. Matching glass walls form a continuous
Expand All @@ -32,6 +35,10 @@ matching path piece. Its footprint stays the same, with a one-pixel lower top.
Flattening a grass piece also turns an ordinary grass block directly beneath
it into a path, using the same shovel action.

Snow caps follow nearby snow, including snow on the next terrace up. Exposed
ground in cold biomes also gets a cap, while roofs and strong block light block
that weather effect. Piece orientations stay unchanged.

## Crafting

Craft pieces from matching full blocks, slabs and steps. For example, three
Expand Down
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ plugins {
id 'net.minecraftforge.gradle' version '7.0.34'
}

apply from: 'gradle/legacy-tools.gradle'

group = project.mod_group
version = project.mod_version
base.archivesName = 'SkysBuildingPieces'
Expand All @@ -34,6 +36,7 @@ ext.functional_version = versionParts[0..2].join('.')
ext.display_version = project.mod_version
ext.release_tag = project.mod_version
def pinnedJava8 = providers.environmentVariable('SBP_JAVA8_HOME')
.orElse(providers.environmentVariable('JAVA_HOME_8_X64'))
// Gradle 9.6.1's ordinary language-level selector prefers the newest cached
// Java 8. This opt-in specific installation keeps local/CI qualification exact.
def exactJava8Spec = pinnedJava8.isPresent() ?
Expand Down
9 changes: 8 additions & 1 deletion docs/CONFIGURATION.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# Configuration

Forge creates `config/skysbuildingpieces.cfg`. Stop the game or server before
editing it, then restart.
editing it, then restart. On the client, the same settings are in
**Mods → Sky's Building Pieces → Config**.

`gameplay.directionalSlabPlacement=true`

Click the centre or edge of a face to choose which way a regular slab sits.
Turn this off for normal horizontal placement, then restart. Existing pieces
and separately crafted vertical slabs keep their shape and behaviour.

`compat.forceReplaceBuildingBricksPieces=false`

Expand Down
10 changes: 10 additions & 0 deletions docs/RELEASE-0.3.9.110021.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# SkysBuildingPieces 0.3.9.110021

Grass steps and corners now match snowy terraces and cold, exposed ground.
Exposed vanilla and BOP grass beneath touching snowy pieces has matching snowy
sides and a snow-covered top. Directional slab placement can be turned off in
Mods > Config; normal placement remains enabled by default.

Back up your world before updating. Install the main jar on the client and
server. Saved pieces retain their materials and orientations; new smoothing
applies only to newly generated chunks.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ release_enabled=true
curseforge_project_id=1754162
mod_name=Sky's Building Pieces
mod_license=LGPL-2.1-only
mod_version=0.3.7.110021
mod_version=0.3.9.110021
mod_group=zone.moddev.mc.skysbuildingpieces
mod_authors=SkyBlade1978
mod_description=Extra building shapes for vanilla materials, with built-in Mineralogy support when installed. No world generation.
58 changes: 58 additions & 0 deletions gradle/legacy-tools.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import java.nio.file.Files
import java.nio.file.StandardCopyOption
import java.security.MessageDigest
import java.util.jar.JarFile

// The old MCP download URL can return HTML. Use the identical, pinned tool from Maven Central.
def toolSha256 = '9105207CC68FBBA768B314FA8584F7C63DE2CF664F1FD50AAAB4A386975A88BD'
def toolSha1 = 'a70987737b33a1d828713fb7cec4622455618fd9'
def toolUrl = 'https://repo.maven.apache.org/maven2/net/md-5/SpecialSource/1.8.3/SpecialSource-1.8.3-shaded.jar'
def cacheRoot = providers.gradleProperty('legacyToolCacheRoot').map { file(it) }.getOrElse(
new File(gradle.gradleUserHomeDir, 'caches/minecraftforge/forgegradle/mavenizer'))
def tool = new File(cacheRoot, 'caches/maven/mcp-tools/net/md-5/SpecialSource/1.8.3/SpecialSource-1.8.3-shaded.jar')
def checksum = new File(tool.path + '.sha1')
def digest = { byte[] bytes -> MessageDigest.getInstance('SHA-256').digest(bytes).encodeHex().toString().toUpperCase() }

tool.parentFile.mkdirs()
new RandomAccessFile(new File(tool.parentFile, 'specialsource-bootstrap.lock'), 'rw').withCloseable { lockFile ->
def lock = lockFile.channel.lock()
try {
byte[] existing = tool.isFile() ? tool.bytes : null
if (existing == null || digest(existing) != toolSha256) {
if (gradle.startParameter.offline) {
throw new GradleException('The pinned legacy SpecialSource tool is missing or invalid. Run once online to restore it.')
}
def connection = new URL(toolUrl).openConnection()
connection.connectTimeout = 15000
connection.readTimeout = 30000
byte[] downloaded = connection.inputStream.withCloseable { it.bytes }
if (digest(downloaded) != toolSha256) {
throw new GradleException('The legacy SpecialSource download did not match its pinned SHA-256.')
}
// Preserve a rejected cache entry before replacing only this one tool.
if (existing != null) {
File rejected = new File(projectDir, '.gradle/legacy-tools/rejected/' + digest(existing) + '.jar')
rejected.parentFile.mkdirs()
if (!rejected.exists()) rejected.bytes = existing
}
def temporary = Files.createTempFile(tool.parentFile.toPath(), 'specialsource-', '.tmp')
try {
Files.write(temporary, downloaded)
new JarFile(temporary.toFile()).withCloseable { archive ->
if (archive.manifest.mainAttributes.getValue('Main-Class') != 'net.md_5.specialsource.SpecialSource') {
throw new GradleException('The legacy build tool has no expected entry point.')
}
}
Files.move(temporary, tool.toPath(), StandardCopyOption.REPLACE_EXISTING)
} finally {
Files.deleteIfExists(temporary)
}
logger.lifecycle('Restored the verified legacy SpecialSource build tool from Maven Central.')
}
if (!checksum.isFile() || checksum.getText('UTF-8').trim() != toolSha1) {
checksum.setText(toolSha1, 'UTF-8')
}
} finally {
lock.release()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ public void tick(TickEvent.ClientTickEvent event) {
ran = true;

try {
SnowVisualChecks.run(minecraft);
for (net.minecraft.item.Item retired : Pieces.RETIRED_TEMPLATES.values()) {
if (retired.getCreativeTab() != null) {
throw new AssertionError("Retired template appears in creative inventory");
Expand Down Expand Up @@ -127,8 +128,8 @@ public void tick(TickEvent.ClientTickEvent event) {
throw new AssertionError("Retired template in mod tab");
}
}
if (!entries.contains("minecraft:wooden_slab:0")) {
throw new AssertionError("Reused oak slab missing from mod tab");
if (entries.stream().anyMatch(key -> key.startsWith("minecraft:"))) {
throw new AssertionError("Vanilla content appears in the Building Pieces tab");
}
if (entries.contains("skysbuildingpieces:legacy_piece_holder:0")) {
throw new AssertionError("Recovery holder in mod tab");
Expand All @@ -140,6 +141,7 @@ public void tick(TickEvent.ClientTickEvent event) {

System.out.println("BUILDING_PIECES_CREATIVE_TAB_PASS entries=" + creative.size());

ConfigScreenChecks.run(minecraft);
int checked = 0;

for (PieceBlock block : Pieces.BLOCKS.values()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package zone.moddev.mc.skysbuildingpieces.probe;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import net.minecraftforge.fml.client.FMLClientHandler;
import net.minecraftforge.fml.client.IModGuiFactory;
import net.minecraftforge.fml.client.config.GuiConfig;
import net.minecraftforge.fml.client.config.IConfigElement;
import net.minecraftforge.fml.client.event.ConfigChangedEvent;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.ModContainer;
import zone.moddev.mc.skysbuildingpieces.SkysBuildingPieces;
import zone.moddev.mc.skysbuildingpieces.config.BuildingPiecesConfig;

final class ConfigScreenChecks {
private ConfigScreenChecks() {
}

static void run(Minecraft minecraft) throws ReflectiveOperationException {
ModContainer mod = Loader.instance().getIndexedModList().get(SkysBuildingPieces.ID);
IModGuiFactory factory = FMLClientHandler.instance().getGuiFactoryFor(mod);
GuiConfig screen = (GuiConfig) factory.mainConfigGuiClass().getConstructor(GuiScreen.class).newInstance(minecraft.currentScreen);
if (!screen.allRequireMcRestart || screen.configElements.size() != 2) {
throw new AssertionError("Building Pieces should have two restart-required settings");
}

for (IConfigElement entry : screen.configElements) {
String key = entry.getLanguageKey();
if (I18n.format(key).equals(key) || I18n.format(key + ".tooltip").equals(key + ".tooltip")) {
throw new AssertionError("Missing Building Pieces setting label or tooltip " + key);
}
}

Configuration configuration = BuildingPiecesConfig.configuration();
Property placement = configuration.getCategory("gameplay").get("directionalSlabPlacement");
if (!placement.getBoolean() || !BuildingPiecesConfig.directionalSlabPlacement()) {
throw new AssertionError("Directional slab placement must default to on");
}
try {
placement.set(false);
MinecraftForge.EVENT_BUS.post(new ConfigChangedEvent.OnConfigChangedEvent(
SkysBuildingPieces.ID, null, false, true));
Configuration saved = new Configuration(configuration.getConfigFile());
saved.load();
if (saved.get("gameplay", "directionalSlabPlacement", true).getBoolean()
|| !BuildingPiecesConfig.directionalSlabPlacement()) {
throw new AssertionError("The placement option should save for the next restart");
}
} finally {
placement.set(true);
BuildingPiecesConfig.saveChanges();
}
System.out.println("BUILDING_PIECES_CONFIG_SCREEN_PASS default_on=true saves_off=true restores_on=true");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public void tick(TickEvent.ServerTickEvent event) {
return;
}

SnowChecks.run(world);
GameplayChecks.run(world);
PathChecks.run(world);
MineralogyChecks.run();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package zone.moddev.mc.skysbuildingpieces.probe;

import net.minecraft.block.Block;
import net.minecraft.block.BlockGrass;
import net.minecraft.block.state.IBlockState;
import net.minecraft.init.Biomes;
import net.minecraft.init.Blocks;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.ChunkCache;
import net.minecraft.world.WorldServer;
import zone.moddev.mc.skysbuildingpieces.catalogue.Shape;
import zone.moddev.mc.skysbuildingpieces.content.PieceBlock;
import zone.moddev.mc.skysbuildingpieces.content.Pieces;

/** Checks real calculated states, including the native grass hook and render chunk cache. */
final class SnowChecks {
static void run(WorldServer world) throws ReflectiveOperationException {
BlockPos support = new BlockPos(1500, 220, 1500);
BlockPos position = support.up();
for (int chunkX = -1; chunkX <= 1; chunkX++) {
for (int chunkZ = -1; chunkZ <= 1; chunkZ++) {
world.getChunkFromChunkCoords((support.getX() >> 4) + chunkX, (support.getZ() >> 4) + chunkZ);
}
}
world.setBlockState(position.up(3), Blocks.GLASS.getDefaultState(), 2);
world.setBlockState(support, Blocks.GRASS.getDefaultState(), 2);
int checked = 0;
for (PieceBlock piece : Pieces.BLOCKS.values()) {
if (!piece.palette.group.equals("snow") && !piece.palette.group.equals("grass")
&& !piece.palette.group.equals("dirt")) {
continue;
}
for (int orientation = 0; orientation < piece.palette.shape.states; orientation++) {
IBlockState state = state(piece, orientation);
world.setBlockState(position, state, 2);
boolean touches = piece.palette.shape != Shape.WALL && piece.palette.shape != Shape.PANE
&& (piece.mask(state) & 15) != 0;
boolean physicalSnow = piece.palette.group.equals("snow");
require(snowy(world, support) == (physicalSnow && touches),
"physical snow support " + piece.palette.shape + "/" + orientation);
if (!physicalSnow) {
world.setBlockState(position.east(), Blocks.SNOW.getDefaultState(), 2);
require(actual(piece, state, world, position).getValue(BlockGrass.SNOWY),
"adjacent physical snow reaches grass/dirt piece");
require(snowy(world, support) == touches, "calculated cap reaches touching support");
world.setBlockToAir(position.east());
require(!actual(piece, state, world, position).getValue(BlockGrass.SNOWY),
"removed snow clears the piece");
}
require(world.getBlockState(position).equals(state), "snow appearance preserves saved metadata");
require(!world.getBlockState(support).getValue(BlockGrass.SNOWY), "support cap is not saved");
world.setBlockToAir(position);
require(!snowy(world, support), "removed cover clears the support");
checked++;
}
}
IBlockState grass = Pieces.state("minecraft:grass", Shape.HORIZONTAL_STEP, 0);
Block block = grass.getBlock();
world.setBlockState(position, grass, 2);
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
BlockPos higher = position.offset(direction);
world.setBlockState(higher, Blocks.GRASS.getDefaultState(), 2);
world.setBlockState(higher.up(), Blocks.SNOW_LAYER.getDefaultState(), 2);
require(actual(block, grass, world, position).getValue(BlockGrass.SNOWY), "upper terrace " + direction);
world.setBlockToAir(higher.up());
world.setBlockToAir(higher);
require(!actual(block, grass, world, position).getValue(BlockGrass.SNOWY), "upper snow removal");
}
byte[] biomes = world.getChunkFromBlockCoords(position).getBiomeArray();
int biomeIndex = (position.getZ() & 15) << 4 | position.getX() & 15;
byte originalBiome = biomes[biomeIndex];
try {
biomes[biomeIndex] = (byte) net.minecraft.world.biome.Biome.getIdForBiome(Biomes.ICE_PLAINS);
world.setBlockToAir(position.up(3));
require(actual(block, grass, world, position).getValue(BlockGrass.SNOWY), "exposed cold piece");
ChunkCache cache = new ChunkCache(world, position.add(-2, -2, -2), position.add(2, 4, 2), 0);
require(block.getActualState(grass, cache, position).getValue(BlockGrass.SNOWY), "render cache uses its world");
world.setBlockState(position.up(3), Blocks.GLASS.getDefaultState(), 2);
require(!actual(block, grass, world, position).getValue(BlockGrass.SNOWY), "glass roof blocks weather cap");
} finally {
biomes[biomeIndex] = originalBiome;
world.setBlockToAir(position.up(3));
world.setBlockToAir(position);
world.setBlockToAir(support);
}
BlockPos edge = new BlockPos(5007, 220, 5007);
world.getChunkFromBlockCoords(edge);
world.setBlockState(edge, Blocks.GRASS.getDefaultState(), 2);
world.setBlockState(edge.up(), grass, 2);
// Placement may populate adjacent chunks. Unload the eastern one before reading visuals.
net.minecraft.world.chunk.Chunk neighbour = world.getChunkProvider().getLoadedChunk(
(edge.getX() >> 4) + 1, edge.getZ() >> 4);
if (neighbour != null) {
world.getChunkProvider().unload(neighbour);
world.getChunkProvider().tick();
}
int loaded = world.getChunkProvider().getLoadedChunkCount();
boolean unavailable = false;
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
unavailable |= !world.isBlockLoaded(edge.offset(direction));
}
require(unavailable, "the snow border test has an unloaded neighbour");
snowy(world, edge);
require(world.getChunkProvider().getLoadedChunkCount() == loaded, "snow visuals do not load a neighbouring chunk");
world.setBlockToAir(edge.up());
world.setBlockToAir(edge);
System.out.println("BUILDING_PIECES_SNOW_PASS orientations=" + checked
+ " metadata=true removal=true cache=true loaded_halo=true");
}

private static IBlockState state(Block block, int metadata) {
return block.getStateFromMeta(metadata);
}

private static IBlockState actual(Block block, IBlockState state, WorldServer world, BlockPos position) {
return block.getActualState(state, world, position);
}

private static boolean snowy(WorldServer world, BlockPos position) {
return actual(Blocks.GRASS, world.getBlockState(position), world, position).getValue(BlockGrass.SNOWY);
}

private static void require(boolean condition, String message) {
if (!condition) {
throw new AssertionError(message);
}
}

private SnowChecks() {
}
}
Loading
Loading