Skip to content

Commit 3833e64

Browse files
mineLdiverThexXTURBOXxcalmilamsy
authored
2.0.0-alpha.4.1 (#203)
* Switched from HMI to RetroCommands * Removed broken reimplementation of Divisor's old PlayerAPI. (#139) * Removed Indigo renderer (#140) * Updated UnsafeEvents * ContextVariable * ContextVariable#get * Feature/register helper (#146) * Added register helper methods to RegistryEvent * Remove unused BulkConsumer. * Updated all registries to be entry type bound. * Updated all usages of Registry#register to new helper methods where applicable. * Moved bulk registration helpers implementation to Registry interface and redirected event method helpers to that. * Swapped namespace and rawIdGetter placements so they better reflect the original method arguments. * cleanup/java-hacks (#145) * Cleaned up Java hacks related to entrypoints * Removed EnumFactory. * Removed NativeImage Unsafe buffer cleaner invocation. * Replaced fake BlockItem with null, since MixinExtras allows that, unlike vanilla Mixin's Redirect. * Removed UnsafeProvider. * Updated javadoc for EntrypointManager#registerLookup * Fix a NPE in shears override * Fix a NPE in FuelRegistry * Added StationFlatteningBlock#onStateReplaced * Fixed #159 * Change version * Merge pull request #165 from ThexXTURBOXx/develop Don't close filesystems when resolving mod namespaces * Update modmenu * Merge pull request #168 * Yeet * Wait this is wrong * Merge branch 'develop' into namespace-change * Make stapi get angree (#169) * Update BiomeMixin.java (#196) * Add Block Support to CustomTooltipProvider (#187) * Add Block support to CustomTooltipProvider * Add some documentation to the interface * Make Leaves' Log Check Work With Modded Logs and Leaves (#186) * Fix * And comment this out cause it's ugly * Fix (#185) * FUCK (#200) * Why mine (#197) * Potentially make mine scream (#188) * Implement onBonemealUse on Vanilla Crops (#170) * Yeet * Also do sapling, also fix multiplayer * Use the appropriate random --------- Co-authored-by: mineLdiver <aabesedin@mail.ru> * Fixed cal L moment (cascaded test worldgen) * Change version --------- Co-authored-by: Nico Mexis <nico.mexis@kabelmail.de> Co-authored-by: calmilamsy <bumbill00@gmail.com>
1 parent 3cc9a4a commit 3833e64

File tree

25 files changed

+176
-53
lines changed

25 files changed

+176
-53
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@ fabric.loom.multiProjectOptimisation=true
2222
spasm_version = 0.2.2
2323

2424
# Mod Properties
25-
mod_version = 2.0.0-alpha.4
25+
mod_version = 2.0.0-alpha.4.1
2626
maven_group = net.modificationstation
2727
archives_base_name = StationAPI
2828

2929
# Test properties
30-
modmenu_version = 1.8.5-beta.9
30+
modmenu_version = 1.8.5-beta.11
3131
rc_version = 0.5.4

src/test/java/net/modificationstation/sltest/block/Blocks.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import net.modificationstation.stationapi.api.event.registry.BlockRegistryEvent;
88
import net.modificationstation.stationapi.api.mod.entrypoint.EntrypointManager;
99
import net.modificationstation.stationapi.api.template.block.TemplateBlock;
10+
import net.modificationstation.stationapi.api.template.block.TemplateLeavesBlock;
11+
import net.modificationstation.stationapi.api.template.block.TemplateLogBlock;
1012
import net.modificationstation.stationapi.api.util.Identifier;
1113

1214
import java.lang.invoke.MethodHandles;
@@ -25,7 +27,9 @@ public enum Blocks {
2527
ALTAR("altar", "altar", id -> new BlockAltar(id, Material.STONE).setHardness(3)),
2628
VARIATION_BLOCK("variation_block", "variationBlock", id -> new VariationBlock(id, Material.STONE).setHardness(.5F).setSoundGroup(Block.DEFAULT_SOUND_GROUP).disableAutoItemRegistration()),
2729
EMISSION_CHECKER("emission_checker", "emissionChecker", LampBlock::new),
28-
INDISPENSABLE_BLOCK("indispensable_block", "indispensableBlock", IndispensableBlock::new);
30+
INDISPENSABLE_BLOCK("indispensable_block", "indispensableBlock", IndispensableBlock::new),
31+
MODDED_LEAVES("modded_leaves", "moddedLeaves", id -> new TemplateLeavesBlock(id, 52)),
32+
MODDED_LOG("modded_log", "moddedLog", TemplateLogBlock::new);
2933

3034
private final Runnable register;
3135
private Block block;

src/test/java/net/modificationstation/sltest/level/gen/ChunkListener.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package net.modificationstation.sltest.level.gen;
22

33
import net.mine_diver.unsafeevents.listener.EventListener;
4+
import net.minecraft.block.Block;
5+
import net.modificationstation.sltest.block.Blocks;
46
import net.modificationstation.stationapi.api.event.world.gen.WorldGenEvent;
57

68
public class ChunkListener {
@@ -11,5 +13,10 @@ public void populate(WorldGenEvent.ChunkDecoration event) {
1113
// for (int z = 0; z < 16; z++)
1214
// if ((event.biome == Biome.FOREST || event.biome == Biome.SEASONAL_FOREST) && event.random.nextBoolean())
1315
// event.level.setTile(event.x + x, 90, event.z + z, BlockBase.DIAMOND_BLOCK.id);
16+
// Modded leaves and log test
17+
event.world.setBlock(event.x + 8, 100, event.z + 8, Blocks.MODDED_LOG.get().id);
18+
// event.world.setBlock(event.x + 1, 100, event.z, Block.LEAVES.id);
19+
// event.world.setBlock(event.x + 2, 100, event.z, Blocks.MODDED_LEAVES.get().id);
20+
// event.world.setBlock(event.x + 3, 100, event.z, Block.LEAVES.id);
1421
}
1522
}

station-api-base/src/main/java/net/modificationstation/stationapi/api/util/Namespace.java

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,18 @@
2525
import java.io.IOException;
2626
import java.net.URI;
2727
import java.net.URISyntaxException;
28-
import java.nio.file.FileSystems;
29-
import java.nio.file.Files;
30-
import java.nio.file.Path;
31-
import java.nio.file.Paths;
28+
import java.nio.file.*;
29+
import java.util.Collections;
30+
import java.util.Map;
3231
import java.util.function.Function;
3332
import java.util.function.Supplier;
3433
import java.util.stream.Stream;
34+
import java.util.zip.ZipError;
3535

3636
@Slf4j
3737
public final class Namespace implements Comparable<@NotNull Namespace> {
3838
private static final boolean CHECK_MISSING_MODS = false;
39+
private static final Map<String, String> CREATE_FILESYSTEM_ARGS = Collections.singletonMap("create", "true");
3940

4041
@NotNull
4142
private static final Cache<@NotNull String, @NotNull Namespace> CACHE = Caffeine.newBuilder().softValues().build();
@@ -77,9 +78,24 @@ public final class Namespace implements Comparable<@NotNull Namespace> {
7778
// i'm so sorry
7879
if (Files.isRegularFile(callerPath)) { // regular case
7980
final URI callerRoot;
80-
try (val fs = FileSystems.newFileSystem(callerPath)) {
81+
val uri = callerPath.toUri();
82+
try {
83+
FileSystem fs;
84+
boolean created = false;
85+
val jarUri = new URI("jar:" + uri.getScheme(), uri.getHost(), uri.getPath(), uri.getFragment());
86+
try {
87+
fs = FileSystems.newFileSystem(jarUri, CREATE_FILESYSTEM_ARGS);
88+
created = true;
89+
} catch (FileSystemAlreadyExistsException ignore2) {
90+
fs = FileSystems.getFileSystem(jarUri);
91+
} catch (IOException | ZipError e) {
92+
throw new IOException("Error accessing " + uri + ": " + e, e);
93+
}
8194
callerRoot = fs.getPath("/").toUri();
82-
} catch (IOException e) {
95+
if (created) {
96+
fs.close();
97+
}
98+
} catch (IOException | URISyntaxException e) {
8399
throw new RuntimeException(e);
84100
}
85101
candidates = mods

station-blocks-v0/src/main/java/net/modificationstation/stationapi/api/registry/tag/BlockTags.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
public final class BlockTags {
1212
public static final TagKey<Block>
1313
LOGS = of("logs"),
14+
LEAVES = of("leaves"),
1415
PLANKS = of("planks"),
1516
INFINIBURN = of("infiniburn");
1617

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package net.modificationstation.stationapi.mixin.block;
2+
3+
import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
4+
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
5+
import net.minecraft.block.Block;
6+
import net.minecraft.block.LeavesBlock;
7+
import net.minecraft.world.World;
8+
import net.modificationstation.stationapi.api.block.BlockState;
9+
import net.modificationstation.stationapi.api.registry.tag.BlockTags;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
13+
@Mixin(LeavesBlock.class)
14+
public class LeavesBlockMixin {
15+
16+
@WrapOperation(method = "onTick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/World;getBlockId(III)I"))
17+
private int makeModdedLogsAndLeavesWork(World instance, int x, int y, int z, Operation<Integer> original) {
18+
BlockState state = instance.getBlockState(x, y, z);
19+
if (state.isIn(BlockTags.LOGS)) {
20+
return Block.LOG.id;
21+
}
22+
if (state.isIn(BlockTags.LEAVES)) {
23+
return Block.LEAVES.id;
24+
}
25+
26+
return original.call(instance, x, y, z);
27+
}
28+
}

station-blocks-v0/src/main/resources/station-blocks-v0.mixins.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"BlockItemMixin",
88
"BlockMixin",
99
"FireBlockMixin",
10+
"LeavesBlockMixin",
1011
"SecondaryBlockItemMixin",
1112
"StatsMixin"
1213
],
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package net.modificationstation.stationapi.impl.world;
2+
3+
public interface StationClientWorld {
4+
boolean stationAPI$isModded();
5+
}

station-flattening-v0/src/main/java/net/modificationstation/stationapi/impl/world/chunk/FlattenedChunk.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import net.minecraft.world.LightType;
1212
import net.minecraft.world.World;
1313
import net.minecraft.world.chunk.Chunk;
14+
import net.minecraft.world.dimension.Dimension;
1415
import net.modificationstation.stationapi.api.StationAPI;
1516
import net.modificationstation.stationapi.api.block.BlockState;
1617
import net.modificationstation.stationapi.api.block.States;
@@ -144,7 +145,7 @@ public void setLight(LightType type, int x, int y, int z, int light) {
144145
@Override
145146
public int getLight(int x, int y, int z, int light) {
146147
ChunkSection section = getSection(y);
147-
int lightLevel = section == null ? 15 : section.getLight(LightType.SKY, x, y & 15, z);
148+
int lightLevel = section == null ? (world.dimension.field_2177 /* hasCeiling */ ? 0 : 15) : section.getLight(LightType.SKY, x, y & 15, z);
148149
if (lightLevel > 0) {
149150
field_953 = true;
150151
}

station-flattening-v0/src/main/java/net/modificationstation/stationapi/mixin/flattening/CaveGenBaseMixin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ public void stationapi_setWorld(World world) {
2020
@Override
2121
@Unique
2222
public World stationapi_getWorld() {
23+
if (stationapi_world == null) {
24+
throw new RuntimeException("stationapi_world is null, use CaveGenBaseImpl.stationapi_setWorld in your custom ChunkSource constructor to fix.");
25+
}
2326
return stationapi_world;
2427
}
2528
}

0 commit comments

Comments
 (0)