diff --git a/libraries/blocks/README.md b/libraries/blocks/README.md new file mode 100644 index 00000000..d50704aa --- /dev/null +++ b/libraries/blocks/README.md @@ -0,0 +1,41 @@ +# Blocks API + +The Blocks API provides events and utilities for registering and working with blocks. + +## Registering Custom Blocks + +Block registration should be done in a listener to the `REGISTER_BLOCKS` event. The `BlockRegistry` class provides utility methods for registering blocks. + +An example is shown below. + +```java +package com.example; + +import net.ornithemc.osl.blocks.api.BlockEvents; +import net.ornithemc.osl.entrypoints.api.ModInitializer; + +public class ExampleInitializer implements ModInitializer { + + @Override + public void init() { + BlockEvents.REGISTER_BLOCKS.register(ExampleBlocks::init); + } +} +``` + +```java +package com.example; + +import net.minecraft.block.Block; + +import net.ornithemc.osl.blocks.api.BlockRegistry; +import net.ornithemc.osl.core.util.NamespacedIdentifiers; + +public final class ExampleBlocks { + + public static final CookieBlock COOKIE = BlockRegistry.register(NamespacedIdentifiers.from("example", "cookie"), new CookieBlock()); + + public static void init() { + } +} +``` diff --git a/libraries/blocks/blocks-mc13w36a-mc14w26c/build.gradle b/libraries/blocks/blocks-mc13w36a-mc14w26c/build.gradle new file mode 100644 index 00000000..0a350fdb --- /dev/null +++ b/libraries/blocks/blocks-mc13w36a-mc14w26c/build.gradle @@ -0,0 +1 @@ +setUpModule(project) diff --git a/libraries/blocks/blocks-mc13w36a-mc14w26c/gradle.properties b/libraries/blocks/blocks-mc13w36a-mc14w26c/gradle.properties new file mode 100644 index 00000000..1cad83f5 --- /dev/null +++ b/libraries/blocks/blocks-mc13w36a-mc14w26c/gradle.properties @@ -0,0 +1,8 @@ +min_mc_version = 13w36a +max_mc_version = 14w26c +minecraft_dependency = >=1.7-alpha.13.36.a <=1.8-alpha.14.26.c + +minecraft_version = 1.7.2 +raven_build = 1 +sparrow_build = 1 +nests_build = 3 diff --git a/libraries/blocks/blocks-mc13w36a-mc14w26c/src/main/java/net/ornithemc/osl/blocks/api/BlockEvents.java b/libraries/blocks/blocks-mc13w36a-mc14w26c/src/main/java/net/ornithemc/osl/blocks/api/BlockEvents.java new file mode 100644 index 00000000..c2d7af63 --- /dev/null +++ b/libraries/blocks/blocks-mc13w36a-mc14w26c/src/main/java/net/ornithemc/osl/blocks/api/BlockEvents.java @@ -0,0 +1,34 @@ +package net.ornithemc.osl.blocks.api; + +import net.ornithemc.osl.core.api.events.Event; + +/** + * Events related to the blocks lifecycle. + */ +public final class BlockEvents { + + /** + * This event is invoked upon game start-up, after Vanilla block registration is finished. + * + *
+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(99, NamespacedIdentifiers.from("example", "cookie"), new CookieBlock());
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(99, NamespacedIdentifiers.from("example", "cookie"), new CookieBlock());
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(NamespacedIdentifiers.from("example", "cookie"), new CookieBlock());
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(NamespacedIdentifiers.from("example", "cookie"), new CookieBlock());
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(NamespacedIdentifiers.from("example", "cookie"), new CookieBlock());
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event+ * Custom block registration should be done in a listener of this event. + * Helper methods for registering blocks can be found in the {@linkplain + * BlockRegistry} class. + * + *
+ * Listeners to this event should be registered in your mod's entrypoint, + * and can be done as follows: + * + *
+ * {@code
+ * BlockEvents.REGISTER_BLOCKS.register(() -> {
+ * BlockRegistry.register(99, NamespacedIdentifiers.from("example", "cookie"), new CookieBlock(99));
+ * });
+ * }
+ *
+ *
+ * @see BlockRegistry
+ */
+ public static final Event
+ * Note that in 1.7 snapshots the IDs went through several changes.
+ * The IDs used here match those used in Release 1.7.2.
+ */
+ private static final String[] IDENTIFIERS = {
+ // grouped per 10 for easier lookup
+
+ "air",
+ "stone",
+ "grass",
+ "dirt",
+ "cobblestone",
+ "planks",
+ "sapling",
+ "bedrock",
+ "flowing_water",
+ "water",
+
+ "flowing_lava",
+ "lava",
+ "sand",
+ "gravel",
+ "gold_ore",
+ "iron_ore",
+ "coal_ore",
+ "log",
+ "leaves",
+ "sponge",
+
+ "glass",
+ "lapis_ore",
+ "lapis_block",
+ "dispenser",
+ "sandstone",
+ "noteblock",
+ "bed",
+ "golden_rail",
+ "detector_rail",
+ "sticky_piston",
+
+ "web",
+ "tallgrass",
+ "deadbush",
+ "piston",
+ "piston_head",
+ "wool",
+ "piston_extension",
+ "yellow_flower",
+ "red_flower",
+ "brown_mushroom",
+
+ "red_mushroom",
+ "gold_block",
+ "iron_block",
+ "double_stone_slab",
+ "stone_slab",
+ "brick_block",
+ "tnt",
+ "bookshelf",
+ "mossy_cobblestone",
+ "obsidian",
+
+ "torch",
+ "fire",
+ "mob_spawner",
+ "oak_stairs",
+ "chest",
+ "redstone_wire",
+ "diamond_ore",
+ "diamond_block",
+ "crafting_table",
+ "wheat",
+
+ "farmland",
+ "furnace",
+ "lit_furnace",
+ "standing_sign",
+ "wooden_door",
+ "ladder",
+ "rail",
+ "stone_stairs",
+ "wall_sign",
+ "lever",
+
+ "stone_pressure_plate",
+ "iron_door",
+ "wooden_pressure_plate",
+ "redstone_ore",
+ "lit_redstone_ore",
+ "unlit_redstone_torch",
+ "redstone_torch",
+ "stone_button",
+ "snow_layer",
+ "ice",
+
+ "snow",
+ "cactus",
+ "clay",
+ "reeds",
+ "jukebox",
+ "fence",
+ "pumpkin",
+ "netherrack",
+ "soul_sand",
+ "glowstone",
+
+ "portal",
+ "lit_pumpkin",
+ "cake",
+ "unpowered_repeater",
+ "powered_repeater",
+ "april_fools_locked_chest",
+ "trapdoor",
+ "monster_egg",
+ "stonebrick",
+ "brown_mushroom_block",
+
+ "red_mushroom_block",
+ "iron_bars",
+ "glass_pane",
+ "melon_block",
+ "pumpkin_stem",
+ "melon_stem",
+ "vine",
+ "fence_gate",
+ "brick_stairs",
+ "stone_brick_stairs",
+
+ "mycelium",
+ "waterlily",
+ "nether_brick",
+ "nether_brick_fence",
+ "nether_brick_stairs",
+ "nether_wart",
+ "enchanting_table",
+ "brewing_stand",
+ "cauldron",
+ "end_portal",
+
+ "end_portal_frame",
+ "end_stone",
+ "dragon_egg",
+ "redstone_lamp",
+ "lit_redstone_lamp",
+ "double_wooden_slab",
+ "wooden_slab",
+ "cocoa",
+ "sandstone_stairs",
+ "emerald_ore",
+
+ "ender_chest",
+ "tripwire_hook",
+ "tripwire",
+ "emerald_block",
+ "spruce_stairs",
+ "birch_stairs",
+ "jungle_stairs",
+ "command_block",
+ "beacon",
+ "cobblestone_wall",
+
+ "flower_pot",
+ "carrots",
+ "potatoes",
+ "wooden_button",
+ "skull",
+ "anvil",
+ "trapped_chest",
+ "light_weighted_pressure_plate",
+ "heavey_weighted_pressure_plate",
+ "unpowered_comparator",
+
+ "powered_comparator",
+ "daylight_detector",
+ "redstone_block",
+ "quartz_ore",
+ "hopper",
+ "quartz_block",
+ "quartz_stairs",
+ "activator_rail",
+ "dropper",
+ "stained_hardened_clay",
+
+// IDs 160 to 169 were unused
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+ null,
+
+ "hay",
+ "carpet",
+ "hardened_clay",
+ "coal_block"
+ };
+
+ static void init() {
+ // Air block added by OSL
+ register(Blocks.AIR);
+
+ for (Field f : Block.class.getDeclaredFields()) {
+ if (Modifier.isStatic(f.getModifiers()) && Block.class.isAssignableFrom(f.getType())) {
+ try {
+ Block block = (Block) f.get(null);
+
+ if (block != null) {
+ register(block);
+ }
+ } catch (Throwable t) {
+ }
+ }
+ }
+ }
+
+ private static void register(Block block) {
+ if (block.id >= 0 && block.id < IDENTIFIERS.length) {
+ String identifier = IDENTIFIERS[block.id];
+
+ if (identifier != null) {
+ BlockRegistryImpl.register(block.id, NamespacedIdentifiers.from(identifier), block);
+ }
+ }
+ }
+}
diff --git a/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/AirBlock.java b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/AirBlock.java
new file mode 100644
index 00000000..1aed2f62
--- /dev/null
+++ b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/AirBlock.java
@@ -0,0 +1,38 @@
+package net.ornithemc.osl.blocks.impl.block;
+
+import net.minecraft.block.Block;
+import net.minecraft.block.material.Material;
+import net.minecraft.util.math.Box;
+import net.minecraft.world.World;
+
+public class AirBlock extends Block {
+
+ public AirBlock() {
+ super(0, Material.AIR);
+ }
+
+ @Override
+ public boolean isAir() {
+ return true;
+ }
+
+ @Override
+ public int getRenderType() {
+ return -1;
+ }
+
+ @Override
+ public Box getCollisionShape(World world, int x, int y, int z) {
+ return null;
+ }
+
+ @Override
+ public boolean isSolidRender() {
+ return false;
+ }
+
+ @Override
+ public boolean canRayTrace(int metadata, boolean allowLiquids) {
+ return false;
+ }
+}
diff --git a/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/BlockExtensionImpl.java b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/BlockExtensionImpl.java
new file mode 100644
index 00000000..a34f0259
--- /dev/null
+++ b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/block/BlockExtensionImpl.java
@@ -0,0 +1,18 @@
+package net.ornithemc.osl.blocks.impl.block;
+
+import net.minecraft.block.Block;
+
+import net.ornithemc.osl.blocks.api.block.BlockExtension;
+
+public interface BlockExtensionImpl extends BlockExtension {
+
+ @Override
+ default boolean isAir() {
+ throw new AbstractMethodError();
+ }
+
+ @Override
+ default boolean is(Block block) {
+ throw new AbstractMethodError();
+ }
+}
diff --git a/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/mixin/common/BlockMixin.java b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/mixin/common/BlockMixin.java
new file mode 100644
index 00000000..9a9de523
--- /dev/null
+++ b/libraries/blocks/blocks-mca1.0.1_01-mc1.6.4/src/main/java/net/ornithemc/osl/blocks/impl/mixin/common/BlockMixin.java
@@ -0,0 +1,52 @@
+package net.ornithemc.osl.blocks.impl.mixin.common;
+
+import org.objectweb.asm.Opcodes;
+
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Slice;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
+
+import net.minecraft.block.Block;
+
+import net.ornithemc.osl.blocks.impl.BlockRegistryImpl;
+
+@Mixin(Block.class)
+public class BlockMixin {
+
+ @Inject(
+ method = "