diff --git a/.idea/modules/tastytoasters.main.iml b/.idea/modules/tastytoasters.main.iml
index 31ee599..2e14514 100644
--- a/.idea/modules/tastytoasters.main.iml
+++ b/.idea/modules/tastytoasters.main.iml
@@ -4,9 +4,9 @@
+ FABRIC
MIXIN
MCP
- FABRIC
diff --git a/.idea/modules/tastytoasters.test.iml b/.idea/modules/tastytoasters.test.iml
index 31ee599..2e14514 100644
--- a/.idea/modules/tastytoasters.test.iml
+++ b/.idea/modules/tastytoasters.test.iml
@@ -4,9 +4,9 @@
+ FABRIC
MIXIN
MCP
- FABRIC
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index fcf3805..94795df 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,14 +4,16 @@
-
-
-
+
+
+
+
+
-
-
-
+
+
+
@@ -51,13 +53,7 @@
-
-
-
-
-
-
-
+
@@ -99,18 +95,62 @@
-
+
-
+
+
+
+ true
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+ true
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
true
@@ -162,9 +202,11 @@
+
+
+
-
@@ -191,7 +233,14 @@
1638614632820
-
+
+ 1638615794540
+
+
+
+ 1638615794540
+
+
@@ -209,6 +258,7 @@
-
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 59806e8..ae2706f 100644
--- a/build.gradle
+++ b/build.gradle
@@ -3,6 +3,10 @@ plugins {
id 'maven-publish'
}
+sourceCompatibility = JavaVersion.VERSION_17
+targetCompatibility = JavaVersion.VERSION_17
+
+archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
@@ -29,31 +33,18 @@ dependencies {
processResources {
inputs.property "version", project.version
- filteringCharset "UTF-8"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
-def targetJavaVersion = 17
tasks.withType(JavaCompile).configureEach {
- // ensure that the encoding is set to UTF-8, no matter what the system default is
- // this fixes some edge cases with special characters not displaying correctly
- // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html
- // If Javadoc is generated, this must be specified in that task too.
- it.options.encoding = "UTF-8"
- if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) {
- it.options.release = targetJavaVersion
- }
+ // Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
+ it.options.release = 17
}
java {
- def javaVersion = JavaVersion.toVersion(targetJavaVersion)
- if (JavaVersion.current() < javaVersion) {
- toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion)
- }
- archivesBaseName = project.archives_base_name
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
@@ -62,7 +53,7 @@ java {
jar {
from("LICENSE") {
- rename { "${it}_${project.archivesBaseName}" }
+ rename { "${it}_${project.archivesBaseName}"}
}
}
@@ -70,13 +61,7 @@ jar {
publishing {
publications {
mavenJava(MavenPublication) {
- // add all the jars that should be included when publishing to maven
- artifact(remapJar) {
- builtBy remapJar
- }
- artifact(sourcesJar) {
- builtBy remapSourcesJar
- }
+ from components.java
}
}
@@ -87,4 +72,4 @@ publishing {
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/blackfur/tastytoasters/Tastytoasters.java b/src/main/java/blackfur/tastytoasters/Tastytoasters.java
index b0b0b42..7a9bfd5 100644
--- a/src/main/java/blackfur/tastytoasters/Tastytoasters.java
+++ b/src/main/java/blackfur/tastytoasters/Tastytoasters.java
@@ -1,10 +1,13 @@
package blackfur.tastytoasters;
import blackfur.tastytoasters.block.ToasterBlock;
+import blackfur.tastytoasters.block.ToasterBlockEntity;
import blackfur.tastytoasters.items.*;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
+import net.fabricmc.fabric.api.object.builder.v1.block.entity.FabricBlockEntityTypeBuilder;
import net.minecraft.block.Material;
+import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
@@ -20,6 +23,8 @@ public class Tastytoasters implements ModInitializer {
public static final Item BUTTERED_TOAST_ITEM = new ButteredToastItem();
public static final ToasterBlock TOASTER_BLOCK = new ToasterBlock(FabricBlockSettings.of(Material.METAL).hardness(4.0f).requiresTool());
+
+ public static BlockEntityType TOASTER_BLOCK_ENTITY;
@Override
public void onInitialize() {
@@ -31,5 +36,7 @@ public class Tastytoasters implements ModInitializer {
Registry.register(Registry.BLOCK, new Identifier("tastytoasters", "toaster"), TOASTER_BLOCK);
Registry.register(Registry.ITEM, new Identifier("tastytoasters", "toaster"), new BlockItem(TOASTER_BLOCK, new Item.Settings().group(ItemGroup.FOOD)));
+
+ TOASTER_BLOCK_ENTITY = Registry.register(Registry.BLOCK_ENTITY_TYPE, new Identifier("tastytoasters", "toaster_entity"), FabricBlockEntityTypeBuilder.create(ToasterBlockEntity::new, TOASTER_BLOCK).build(null));
}
}
diff --git a/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java b/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java
index a50f802..84aab61 100644
--- a/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java
+++ b/src/main/java/blackfur/tastytoasters/block/ToasterBlock.java
@@ -1,9 +1,80 @@
package blackfur.tastytoasters.block;
-import net.minecraft.block.Block;
+import net.minecraft.block.*;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.item.ItemPlacementContext;
+import net.minecraft.state.StateManager;
+import net.minecraft.state.property.BooleanProperty;
+import net.minecraft.state.property.DirectionProperty;
+import net.minecraft.util.function.BooleanBiFunction;
+import net.minecraft.util.math.BlockPos;
+import net.minecraft.util.math.Direction;
+import net.minecraft.util.shape.VoxelShape;
+import net.minecraft.util.shape.VoxelShapes;
+import net.minecraft.world.BlockView;
+import org.jetbrains.annotations.Nullable;
+
+public class ToasterBlock extends HorizontalFacingBlock implements BlockEntityProvider {
+ public static final DirectionProperty FACING = HorizontalFacingBlock.FACING;
+ public static final BooleanProperty TOASTING = BooleanProperty.of("toasting");
-public class ToasterBlock extends Block {
public ToasterBlock(Settings settings) {
super(settings);
+ this.setDefaultState(this.stateManager.getDefaultState().with(FACING, Direction.NORTH));
+ this.setDefaultState(this.stateManager.getDefaultState().with(TOASTING, false));
+ }
+
+ public BlockState getPlacementState(ItemPlacementContext ctx) {
+ return this.getDefaultState().with(FACING, ctx.getPlayerFacing().getOpposite());
+ }
+
+ @Override
+ protected void appendProperties(StateManager.Builder builder) {
+ builder.add(FACING).add(TOASTING);
+ }
+
+ @Override
+ public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext context) {
+ if (state.get(TOASTING)) {
+ switch (state.get(FACING)) {
+ case NORTH:
+ case SOUTH: return VoxelShapes.combine(
+ VoxelShapes.cuboid((1f / 16f * 3), (1f / 16f * 0), (1f / 16f * 1), (1f / 16f * 13), (1f / 16f * 8), (1f / 16f * 15)),
+ VoxelShapes.combine(
+ VoxelShapes.cuboid((1f / 16f * 5), (1f / 16f * 8), (1f / 16f * 3), (1f / 16f * 7), (1f / 16f * 10), (1f / 16f * 13)),
+ VoxelShapes.cuboid((1f / 16f * 9), (1f / 16f * 8), (1f / 16f * 3), (1f / 16f * 11), (1f / 16f * 10), (1f / 16f * 13)),
+ BooleanBiFunction.OR
+ ),
+ BooleanBiFunction.OR
+ );
+ case WEST:
+ case EAST: return VoxelShapes.combine(
+ VoxelShapes.cuboid((1f / 16f * 1), (1f / 16f * 0), (1f / 16f * 3), (1f / 16f * 15), (1f / 16f * 8), (1f / 16f * 13)),
+ VoxelShapes.combine(
+ VoxelShapes.cuboid((1f / 16f * 3), (1f / 16f * 8), (1f / 16f * 5), (1f / 16f * 13), (1f / 16f * 10), (1f / 16f * 7)),
+ VoxelShapes.cuboid((1f / 16f * 3), (1f / 16f * 8), (1f / 16f * 9), (1f / 16f * 13), (1f / 16f * 10), (1f / 16f * 11)),
+ BooleanBiFunction.OR
+ ),
+ BooleanBiFunction.OR
+ );
+ }
+ } else {
+ switch (state.get(FACING)) {
+ case NORTH:
+ case SOUTH:
+ return VoxelShapes.cuboid((1f / 16f * 3), (1f / 16f * 0), (1f / 16f * 1), (1f / 16f * 13), (1f / 16f * 8), (1f / 16f * 15));
+ case EAST:
+ case WEST:
+ return VoxelShapes.cuboid((1f / 16f * 1), (1f / 16f * 0), (1f / 16f * 3), (1f / 16f * 15), (1f / 16f * 8), (1f / 16f * 13));
+ }
+
+ }
+ return null;
+ }
+
+ @Nullable
+ @Override
+ public BlockEntity createBlockEntity(BlockPos pos, BlockState state) {
+ return null;
}
}
diff --git a/src/main/java/blackfur/tastytoasters/block/ToasterBlockEntity.java b/src/main/java/blackfur/tastytoasters/block/ToasterBlockEntity.java
new file mode 100644
index 0000000..ded8cc0
--- /dev/null
+++ b/src/main/java/blackfur/tastytoasters/block/ToasterBlockEntity.java
@@ -0,0 +1,12 @@
+package blackfur.tastytoasters.block;
+
+import blackfur.tastytoasters.Tastytoasters;
+import net.minecraft.block.BlockState;
+import net.minecraft.block.entity.BlockEntity;
+import net.minecraft.util.math.BlockPos;
+
+public class ToasterBlockEntity extends BlockEntity {
+ public ToasterBlockEntity(BlockPos pos, BlockState state) {
+ super(Tastytoasters.TOASTER_BLOCK_ENTITY, pos, state);
+ }
+}
diff --git a/src/main/resources/assets/tastytoasters/blockstates/toaster.json b/src/main/resources/assets/tastytoasters/blockstates/toaster.json
index e3d73f5..6782c93 100644
--- a/src/main/resources/assets/tastytoasters/blockstates/toaster.json
+++ b/src/main/resources/assets/tastytoasters/blockstates/toaster.json
@@ -1,5 +1,34 @@
{
"variants": {
- "": { "model": "tastytoasters:block/toaster"}
+ "facing=east,toasting=false": {
+ "model": "tastytoasters:block/toaster",
+ "y": 90
+ },
+ "facing=north,toasting=false": {
+ "model": "tastytoasters:block/toaster"
+ },
+ "facing=south,toasting=false": {
+ "model": "tastytoasters:block/toaster",
+ "y": 180
+ },
+ "facing=west,toasting=false": {
+ "model": "tastytoasters:block/toaster",
+ "y": 270
+ },
+ "facing=east,toasting=true": {
+ "model": "tastytoasters:block/toaster_filled",
+ "y": 90
+ },
+ "facing=north,toasting=true": {
+ "model": "tastytoasters:block/toaster_filled"
+ },
+ "facing=south,toasting=true": {
+ "model": "tastytoasters:block/toaster_filled",
+ "y": 180
+ },
+ "facing=west,toasting=true": {
+ "model": "tastytoasters:block/toaster_filled",
+ "y": 270
+ }
}
}
\ No newline at end of file
diff --git a/src/main/resources/assets/tastytoasters/models/block/toaster_filled.json b/src/main/resources/assets/tastytoasters/models/block/toaster_filled.json
new file mode 100644
index 0000000..ddc64dd
--- /dev/null
+++ b/src/main/resources/assets/tastytoasters/models/block/toaster_filled.json
@@ -0,0 +1,80 @@
+{
+ "credit": "Made with Blockbench",
+ "textures": {
+ "0": "tastytoasters:block/toaster_filled",
+ "particle": "tastytoasters:block/toaster"
+ },
+ "elements": [
+ {
+ "from": [3, 0, 1],
+ "to": [13, 8, 15],
+ "faces": {
+ "north": {"uv": [0, 0, 5, 4], "texture": "#0"},
+ "east": {"uv": [10, 4, 14, 11], "rotation": 270, "texture": "#0"},
+ "south": {"uv": [5, 0, 10, 4], "texture": "#0"},
+ "west": {"uv": [10, 4, 14, 11], "rotation": 270, "texture": "#0"},
+ "up": {"uv": [0, 4, 5, 11], "texture": "#0"},
+ "down": {"uv": [5, 4, 10, 11], "texture": "#0"}
+ }
+ },
+ {
+ "from": [9, 8, 3],
+ "to": [11, 10, 13],
+ "faces": {
+ "north": {"uv": [1, 5, 2, 6], "texture": "#0"},
+ "east": {"uv": [1, 5, 2, 10], "rotation": 270, "texture": "#0"},
+ "south": {"uv": [1, 9, 2, 10], "texture": "#0"},
+ "west": {"uv": [1, 5, 2, 10], "rotation": 90, "texture": "#0"},
+ "up": {"uv": [1, 5, 2, 10], "texture": "#0"},
+ "down": {"uv": [1, 5, 2, 10], "texture": "#0"}
+ }
+ },
+ {
+ "from": [5, 8, 3],
+ "to": [7, 10, 13],
+ "faces": {
+ "north": {"uv": [1, 9, 2, 10], "texture": "#0"},
+ "east": {"uv": [1, 5, 2, 10], "rotation": 90, "texture": "#0"},
+ "south": {"uv": [1, 5, 2, 6], "texture": "#0"},
+ "west": {"uv": [1, 5, 2, 10], "rotation": 270, "texture": "#0"},
+ "up": {"uv": [1, 5, 2, 10], "rotation": 180, "texture": "#0"},
+ "down": {"uv": [1, 5, 2, 10], "rotation": 180, "texture": "#0"}
+ }
+ }
+ ],
+ "display": {
+ "thirdperson_righthand": {
+ "rotation": [75, 45, 0],
+ "translation": [0, 2.5, 0],
+ "scale": [0.375, 0.375, 0.375]
+ },
+ "thirdperson_lefthand": {
+ "rotation": [75, 45, 0],
+ "translation": [0, 2.5, 0],
+ "scale": [0.375, 0.375, 0.375]
+ },
+ "firstperson_righthand": {
+ "rotation": [0, 45, 0],
+ "scale": [0.4, 0.4, 0.4]
+ },
+ "firstperson_lefthand": {
+ "rotation": [0, 225, 0],
+ "scale": [0.4, 0.4, 0.4]
+ },
+ "ground": {
+ "translation": [0, 3, 0],
+ "scale": [0.25, 0.25, 0.25]
+ },
+ "gui": {
+ "rotation": [30, 225, 0],
+ "scale": [0.625, 0.625, 0.625]
+ },
+ "head": {
+ "rotation": [0, 180, 0],
+ "translation": [0, 13, 7]
+ },
+ "fixed": {
+ "scale": [0.5, 0.5, 0.5]
+ }
+ }
+}
\ No newline at end of file