Skip to content

Commit ac28eac

Browse files
Merge pull request #1 from Turnip-Labs/bb-7.2
Updated to 7.2
2 parents ab673e9 + 07f7a01 commit ac28eac

16 files changed

+137
-83
lines changed

build.gradle

+2-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'babric-loom' version '1.1.+'
2+
id 'babric-loom' version '1.4.+'
33
id 'java'
44
}
55

@@ -32,22 +32,6 @@ repositories {
3232
}
3333
metadataSources { artifact() }
3434
}
35-
ivy {
36-
url = "https://github.com/Turnip-Labs"
37-
patternLayout {
38-
artifact "[organisation]/releases/download/v[revision]/[module]-[revision].jar"
39-
m2compatible = true
40-
}
41-
metadataSources { artifact() }
42-
}
43-
ivy {
44-
url = "https://github.com/Turnip-Labs"
45-
patternLayout {
46-
artifact "[organisation]/releases/download/[revision]/[module]-[revision].jar"
47-
m2compatible = true
48-
}
49-
metadataSources { artifact() }
50-
}
5135
ivy {
5236
url = "https://github.com/Turnip-Labs"
5337
patternLayout {
@@ -84,8 +68,7 @@ dependencies {
8468
// Helper library
8569
// If you do not need Halplibe you can comment this line out or delete this line
8670
modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}"
87-
88-
modImplementation "ModMenu:ModMenu:2.0.3"
71+
compileOnly(modRuntimeOnly "com.github.Turnip-Labs:ModMenu:${project.modmenu_version}")
8972

9073
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
9174
implementation "org.apache.logging.log4j:log4j-slf4j18-impl:2.16.0"

gradle.properties

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
org.gradle.jvmargs=-Xmx2G
22

33
# BTA
4-
bta_version=7.1-pre1a
4+
bta_version=7.2-pre1
55

66
# Loader
7-
loader_version=0.14.19-babric.3-bta
7+
loader_version=0.15.6-babric.6-bta
88

99
# HalpLibe
10-
halplibe_version=3.2.1
10+
halplibe_version=4.0.4
11+
modmenu_version=2.0.6
1112

1213
# Mod
1314
mod_version=1.0.0
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package turniplabs.examplemod;
2+
3+
import net.minecraft.core.block.Block;
4+
import net.minecraft.core.block.material.Material;
5+
import net.minecraft.core.util.phys.AABB;
6+
import net.minecraft.core.world.World;
7+
import net.minecraft.core.world.WorldSource;
8+
9+
import java.util.ArrayList;
10+
11+
public class BlockCustomShape extends Block {
12+
public BlockCustomShape(String key, int id, Material material) {
13+
super(key, id, material);
14+
}
15+
@Override
16+
// Determines if the block pushes you out and can suffocate you
17+
public boolean isSolidRender() {
18+
return false;
19+
}
20+
21+
@Override
22+
// Determines if neighboring blocks should cull their sides, among many other things
23+
public boolean renderAsNormalBlock() {
24+
return false;
25+
}
26+
@Override
27+
public void setBlockBoundsBasedOnState(WorldSource world, int x, int y, int z) {
28+
// Resets block bounds
29+
this.setBlockBounds(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
30+
}
31+
@Override
32+
public void getCollidingBoundingBoxes(World world, int x, int y, int z, AABB aabb, ArrayList<AABB> aabbList) {
33+
// Adds the collision box for the bottom section of the block
34+
setBlockBounds(0, 0, 0, 1, 0.5, 1);
35+
super.getCollidingBoundingBoxes(world, x, y, z, aabb, aabbList);
36+
37+
// Adds the collision box for the top section of the block
38+
setBlockBounds(0.25, 0.5, 0.25, 0.75, 1, 0.75);
39+
super.getCollidingBoundingBoxes(world, x, y, z, aabb, aabbList);
40+
setBlockBounds(0, 0, 0, 1, 1, 1);
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package turniplabs.examplemod;
2+
3+
import net.minecraft.client.render.block.model.BlockModelStandard;
4+
import net.minecraft.client.render.tessellator.Tessellator;
5+
import net.minecraft.core.block.Block;
6+
7+
public class CustomBlockModel<T extends Block> extends BlockModelStandard<T> {
8+
public CustomBlockModel(Block block) {
9+
super(block);
10+
}
11+
@Override
12+
public boolean render(Tessellator tessellator, int x, int y, int z) {
13+
boolean flag = false;
14+
// Draw the lower cube of the model
15+
block.setBlockBounds(0, 0, 0, 1, 0.5, 1);
16+
flag |= this.renderStandardBlock(tessellator, this.block, x, y, z);
17+
18+
// Draw the upper cube of the model
19+
block.setBlockBounds(0.25, 0.5, 0.25, 0.75, 1, 0.75);
20+
flag |= this.renderStandardBlock(tessellator, this.block, x, y, z);
21+
22+
this.block.setBlockBoundsBasedOnState(BlockModelStandard.renderBlocks.blockAccess, x, y, z);
23+
return flag;
24+
}
25+
26+
@Override
27+
public void renderBlockOnInventory(Tessellator tessellator, int metadata, float brightness, float alpha) {
28+
// Draw the lower cube of the model
29+
block.setBlockBounds(0, 0, 0, 1, 0.5, 1);
30+
super.renderBlockOnInventory(tessellator, metadata, brightness, alpha);
31+
32+
// Draw the upper cube of the model
33+
block.setBlockBounds(0.25, 0.5, 0.25, 0.75, 1, 0.75);
34+
super.renderBlockOnInventory(tessellator, metadata, brightness, alpha);
35+
}
36+
}

src/main/java/turniplabs/examplemod/CustomItemBlockExample.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ public CustomItemBlockExample(Block block) {
1313
}
1414
@Override
1515
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int blockX, int blockY, int blockZ, Side side, double xPlaced, double yPlaced) {
16+
// Success is true if the block actually placed, otherwise its false
1617
boolean success = super.onItemUse(stack, player, world, blockX, blockY, blockZ, side, xPlaced, yPlaced);
17-
player.addChatMessage("You " + (success ? "succeeded" : "failed") + " at placing the block");
18+
19+
// Tell the player they succeeded at placing the block if the did infact place the block
20+
player.sendMessage("You " + (success ? "succeeded" : "failed") + " at placing the block");
1821
return success;
1922
}
2023
}

src/main/java/turniplabs/examplemod/ExampleMod.java

+44-58
Original file line numberDiff line numberDiff line change
@@ -1,111 +1,97 @@
11
package turniplabs.examplemod;
22

33
import net.fabricmc.api.ModInitializer;
4-
import net.minecraft.client.render.block.model.BlockModelRenderBlocks;
4+
import net.minecraft.client.render.block.model.BlockModelStandard;
5+
import net.minecraft.client.render.block.model.BlockModelTorch;
56
import net.minecraft.core.block.Block;
67
import net.minecraft.core.block.BlockTorch;
78
import net.minecraft.core.block.material.Material;
8-
import net.minecraft.core.item.block.ItemBlock;
99
import org.slf4j.Logger;
1010
import org.slf4j.LoggerFactory;
1111
import turniplabs.halplibe.helper.BlockBuilder;
1212
import turniplabs.halplibe.util.GameStartEntrypoint;
13-
import turniplabs.halplibe.util.RecipeEntrypoint;
1413

1514

1615
public class ExampleMod implements ModInitializer, GameStartEntrypoint {
1716
public static final String MOD_ID = "examplemod";
1817
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
1918
public static BlockBuilder standardBlockBuilder = new BlockBuilder(MOD_ID)
20-
.setNorthTexture(16, 8) // the coordinates of the blue N texture from the terrain atlas
21-
.setSouthTexture(17, 8) // the coordinates of the green S texture from the terrain atlas
22-
.setBottomTexture(18, 8) // the coordinates of the purple D texture from the terrain atlas
23-
.setEastTexture(16, 9) // the coordinates of the red E texture from the terrain atlas
24-
.setWestTexture(17, 9) // the coordinates of the yellow W texture from the terrain atlas
25-
.setTopTexture(18, 9) // the coordinates of the orange U texture from the terrain atlas
2619
.setHardness(5f); // Sets the hardness which affects the time to mine the blocks
2720
public static Block directionCube;
2821
public static Block grassTop;
2922
public static Block stoneSide;
3023
public static Block customBlockItem;
3124
public static Block customBlockModel;
25+
public static Block customBlockModel2;
3226
@Override
3327
public void onInitialize() {
3428
LOGGER.info("ExampleMod initialized.");
3529
}
3630

3731
@Override
3832
public void beforeGameStart() {
39-
// Vanilla BTA blocks range from 0 to about 1000,
33+
// Vanilla BTA blocks range from 0 to about 1100,
4034
// and block ids can only exist within the 0 to 16000 range
4135
// you need to make sure to pick ids that aren't being used by the vanilla game
4236
// or other mods, a good way to deal with the potential of conflicting ids
4337
// is to make your ids user configurable
4438
int startingBlockId = 2000;
4539

4640
// Creates and assigns directionCube a new block with the language key 'tile.examplemod.direction' with an id of 2000
47-
directionCube = standardBlockBuilder.build(new Block("direction", startingBlockId++, Material.stone));
41+
directionCube = standardBlockBuilder
42+
.setBlockModel(block -> new BlockModelStandard<>(block).withTextures(
43+
"examplemod:block/up", // Set top texture to up.png
44+
"examplemod:block/down", // Set down texture to down.png
45+
"examplemod:block/north", // Set north texture to north.png
46+
"examplemod:block/east", // Set east texture to east.png
47+
"examplemod:block/south", // Set south texture to south.png
48+
"examplemod:block/west")) // Set west texture to west.png
49+
.build(new Block("direction", startingBlockId++, Material.stone));
4850

4951
// Creates and assigns grassTop a new block with the language key 'tile.examplemod.grassTop' with an id of 2001 with the top texture changed to grass
50-
grassTop = standardBlockBuilder.setTopTexture(8, 1).build(new Block("grassTop", startingBlockId++, Material.grass));
52+
grassTop = standardBlockBuilder
53+
.setBlockModel(block -> new BlockModelStandard<>(block).withTextures(
54+
"minecraft:block/grass_top",
55+
"examplemod:block/down",
56+
"examplemod:block/north",
57+
"examplemod:block/east",
58+
"examplemod:block/south",
59+
"examplemod:block/west"))
60+
.build(new Block("grassTop", startingBlockId++, Material.grass));
5161

5262
// Creates and assigns stoneSide a new block with the language key 'tile.examplemod.stoneSide' with an id of 2002 with the side textures changed to stone
53-
stoneSide = standardBlockBuilder.setSideTextures(0, 1).build(new Block("stoneSide", startingBlockId++, Material.grass));
63+
stoneSide = standardBlockBuilder
64+
.setBlockModel(block -> new BlockModelStandard<>(block).withTextures(
65+
"examplemod:block/up",
66+
"examplemod:block/down",
67+
"minecraft:block/stone"))
68+
.build(new Block("stoneSide", startingBlockId++, Material.grass));
5469

5570
// Creates and assigns customBlockItem a new block with the language key 'tile.examplemod.customItem' with an id of 2003 with a custom Item class
5671
customBlockItem = standardBlockBuilder
57-
.setSideTextures(6, 3) // Grass side texture
58-
.setTopTexture(8, 1) // Grass Top texture
59-
.setBottomTexture(2, 0) // Dirt texture
72+
.setBlockModel(block -> new BlockModelStandard<>(block).withTextures(
73+
"minecraft:block/grass_top",
74+
"minecraft:block/dirt",
75+
"minecraft:block/grass_side"))
6076
.setItemBlock((Block b) -> new CustomItemBlockExample(b)) // Sets the item version of the block to our custom class
6177
.build(new Block("customItem", startingBlockId++, Material.dirt));
6278

63-
// renderType ids, the vanilla game uses id numbers to specify the model a block should render with
64-
// type | Model
65-
// 0 | Standard Block
66-
// 1 | Cross block (like flowers and sugarcane)
67-
// 2 | Torch
68-
// 3 | Fire
69-
// 4 | Fluids
70-
// 5 | Redstone wire
71-
// 6 | Crops (like wheat)
72-
// 7 | Door Block
73-
// 8 | Ladder
74-
// 9 | Minecart Rail
75-
// 10 | Stairs
76-
// 11 | Fence
77-
// 12 | Lever
78-
// 13 | Cactus??
79-
// 14 | Block Bed
80-
// 15 | Redstone repeater
81-
// 16 | Piston Base
82-
// 17 | Piston Head
83-
// 18 | Fence Gate
84-
// 19 | Spikes
85-
// 20 | Standard Block again (might do something special but is currently not used by anything)
86-
// 21 | Mossy Stone
87-
// 22 | Legacy Painted Chest model (unused as of 7.1)
88-
// 23 | Flowering Cherry Leaves
89-
// 24 | Algae
90-
// 25 | Candle (For the currently implemented soulwax candle)
91-
// 26 | Firefly lanterns
92-
// 27 | Axis aligned (Used by logs and the marble pillar etc)
93-
// 28 | Basket
94-
// 29 | Pebbles
95-
// 30 | Trapdoors
96-
// 31 | Chainlink Fence
97-
// 32 | Crops Pumpkin
98-
// 33 | Cacao Leaves
99-
// 34 | Flower Jar (rendering is split between the block and the tile entity)
100-
// 35 | Seat
101-
10279
// Creates and assigns customBlockModel a new block with the language key 'tile.examplemod.customModel' with an id of 2004 with a custom texture and the torch model
10380
customBlockModel = new BlockBuilder(MOD_ID)
104-
.setTextures("customTorchTexture.png") // Sets the block texture to the one stored in '/assets/examplemod/block/customTorchTexture.png'
105-
.setBlockModel(new BlockModelRenderBlocks(2))
106-
.setLuminance(14) // Sets the block light output of the block, range from [0 - 15] its converted to a float internally by dividing the value by 15f
81+
.setBlockModel(
82+
block -> new BlockModelTorch<>(block)
83+
.withTextures("examplemod:block/customTorchTexture")) // Sets the block texture to the one stored in '/assets/examplemod/textures/block/customTorchTexture.png'
84+
.setLuminance(14) // Sets the block light output of the block, range from [0 - 15] it's converted to a float internally by dividing the value by 15f
10785
.build(new BlockTorch("customModel", startingBlockId++));
10886

87+
// Creates and assigns customBlockModel a new block with the language key 'tile.examplemod.customModel2' with an id of 2006 with a custom texture and the model we created CustomBlockModel
88+
customBlockModel2 = new BlockBuilder(MOD_ID)
89+
.setBlockModel(
90+
block -> new CustomBlockModel<>(block) // Assing our custom model to the block
91+
.withTextures("minecraft:block/sponge")) // Sets the block texture to sponge
92+
.build(new BlockCustomShape("customModel2", startingBlockId++, Material.sponge)) // Set out custom block that goes with our custom model
93+
.withLitInteriorSurface(true); // Makes it sample light from within itself rather than from neighboring blocks
94+
10995
// Make sure to assign names and descriptions to your blocks in your mods .lang file
11096

11197
// everytime you set parameters on the blockbuilder it returns a new blockbuilder object, this prevents later modifications to the builder from
Loading
Loading
Loading
Loading
Loading
Loading

src/main/resources/fabric.mod.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
],
3131

3232
"depends": {
33-
"fabricloader": ">=0.13.3"
33+
"fabricloader": ">=0.13.3",
34+
"halplibe": ">=4.0.4"
3435
},
3536
"suggests": {
3637
}

src/main/resources/lang/examplemod/en_US.lang

+2
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ tile.examplemod.customItem.name=Custom Item
88
tile.examplemod.customItem.desc=Sends a message in chat when to try to place it
99
tile.examplemod.customModel.name=Custom Model
1010
tile.examplemod.customModel.desc=A Torch with custom textures
11+
tile.examplemod.customModel2.name=Custom Model 2
12+
tile.examplemod.customModel2.desc=A custom block model with a sponge texture

0 commit comments

Comments
 (0)