Initial Commit

This commit is contained in:
2021-04-27 18:00:20 -04:00
commit ca919dbcad
277 changed files with 5028 additions and 0 deletions
@@ -0,0 +1,18 @@
package me.parsell.glowstonedust;
import me.parsell.glowstonedust.core.glowBlocks;
import me.parsell.glowstonedust.core.glowItems;
import net.fabricmc.api.ModInitializer;
public class GlowstoneDust implements ModInitializer {
@Override
public void onInitialize() {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
System.out.println("Hello Fabric world!");
glowBlocks.init();
glowItems.init();
}
}
@@ -0,0 +1,17 @@
package me.parsell.glowstonedust;
import me.parsell.glowstonedust.core.glowBlocks;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
import net.fabricmc.fabric.api.client.rendering.v1.ColorProviderRegistry;
import net.minecraft.client.render.RenderLayer;
public class GlowstoneDustClient implements ClientModInitializer {
@Override
public void onInitializeClient(){
BlockRenderLayerMap.INSTANCE.putBlock(glowBlocks.GLOWSTONEWIRE, RenderLayer.getCutout());
ColorProviderRegistry.BLOCK.register((state, world, pos, tintIndex) -> {
return 0xFFFF00;
}, glowBlocks.GLOWSTONEWIRE);
}
}
@@ -0,0 +1,145 @@
package me.parsell.glowstonedust.common;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.ShapeContext;
import net.minecraft.block.enums.WireConnection;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.state.property.Properties;
import net.minecraft.util.ActionResult;
import net.minecraft.util.BlockMirror;
import net.minecraft.util.BlockRotation;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class GlowstoneWireBlock extends Block{
// These are the states of the wires coming off our block
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_NORTH;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_EAST;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_SOUTH;
public static final net.minecraft.state.property.EnumProperty<net.minecraft.block.enums.WireConnection> WIRE_CONNECTION_WEST;
// Locally defined DIRECTION <-> WIRE_CONNECTION_DIRECTION
public static final Map<Direction, EnumProperty<WireConnection>> DIRECTION_TO_WIRE_CONNECTION_PROPERTY;
// Determines the hitbox for our block
public static final VoxelShape DOT_SHAPE;
// Full sided state
private BlockState FULL_STATE;
public GlowstoneWireBlock(Settings settings) {
super(settings);
// Set these properties to be none as start, so we start with a dot
this.setDefaultState((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)((BlockState)this.stateManager.getDefaultState()).with(WIRE_CONNECTION_NORTH, WireConnection.NONE)).with(WIRE_CONNECTION_EAST, WireConnection.NONE)).with(WIRE_CONNECTION_SOUTH, WireConnection.NONE)).with(WIRE_CONNECTION_WEST, WireConnection.NONE)));
this.FULL_STATE = (BlockState)((BlockState)((BlockState)((BlockState)this.getDefaultState().with(WIRE_CONNECTION_NORTH, WireConnection.SIDE)).with(WIRE_CONNECTION_EAST, WireConnection.SIDE)).with(WIRE_CONNECTION_SOUTH, WireConnection.SIDE)).with(WIRE_CONNECTION_WEST, WireConnection.SIDE);
}
// Make sure out block has the properties for us to manage
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
builder.add(WIRE_CONNECTION_NORTH, WIRE_CONNECTION_EAST, WIRE_CONNECTION_SOUTH, WIRE_CONNECTION_WEST);
}
private static boolean isFullyConnected(BlockState state) {
return ((WireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() &&
((WireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected();
}
private static boolean isNotConnected(BlockState state) {
return !((WireConnection)state.get(WIRE_CONNECTION_NORTH)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_SOUTH)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_EAST)).isConnected() &&
!((WireConnection)state.get(WIRE_CONNECTION_WEST)).isConnected();
}
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, ShapeContext context) {
return DOT_SHAPE;
}
public BlockState getPlacecmentState(ItemPlacementContext ctx){
return this.getDefaultState();
}
public BlockState rotate(BlockState state, BlockRotation rotation) {
switch(rotation) {
case CLOCKWISE_180:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
case COUNTERCLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_NORTH));
case CLOCKWISE_90:
return (BlockState)((BlockState)((BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_NORTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_EAST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_SOUTH));
default:
return state;
}
}
public BlockState mirror(BlockState state, BlockMirror mirror) {
switch(mirror) {
case LEFT_RIGHT:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_NORTH, state.get(WIRE_CONNECTION_SOUTH))).with(WIRE_CONNECTION_SOUTH, state.get(WIRE_CONNECTION_NORTH));
case FRONT_BACK:
return (BlockState)((BlockState)state.with(WIRE_CONNECTION_EAST, state.get(WIRE_CONNECTION_WEST))).with(WIRE_CONNECTION_WEST, state.get(WIRE_CONNECTION_EAST));
default:
return super.mirror(state, mirror);
}
}
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit){
if(isNotConnected(state))
world.setBlockState(pos, FULL_STATE, 3);
else
world.setBlockState(pos, this.getDefaultState(), 3);
System.out.println("onUse");
return ActionResult.SUCCESS;
}
public void update(World world, BlockPos pos, BlockState state){
System.out.println("Update");
}
public void updateNeighbors(World world, BlockPos pos){
System.out.println("Update neighbors");
if (world.getBlockState(pos).isOf(this)) {
world.updateNeighborsAlways(pos, this);
Direction[] var3 = Direction.values();
int var4 = var3.length;
for(int var5 = 0; var5 < var4; ++var5) {
Direction direction = var3[var5];
world.updateNeighborsAlways(pos.offset(direction), this);
}
}
}
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify){
System.out.println("Neighbor update");
}
static {
WIRE_CONNECTION_NORTH = Properties.NORTH_WIRE_CONNECTION;
WIRE_CONNECTION_EAST = Properties.EAST_WIRE_CONNECTION;
WIRE_CONNECTION_SOUTH = Properties.SOUTH_WIRE_CONNECTION;
WIRE_CONNECTION_WEST = Properties.WEST_WIRE_CONNECTION;
DIRECTION_TO_WIRE_CONNECTION_PROPERTY = Maps.newEnumMap((Map)ImmutableMap.of(Direction.NORTH, WIRE_CONNECTION_NORTH, Direction.EAST, WIRE_CONNECTION_EAST, Direction.SOUTH, WIRE_CONNECTION_SOUTH, Direction.WEST, WIRE_CONNECTION_WEST));
DOT_SHAPE = Block.createCuboidShape(3.0D, 0.0D, 3.0D, 13.0D, 1.0D, 13.0D);
}
}
@@ -0,0 +1,17 @@
package me.parsell.glowstonedust.core;
import me.parsell.glowstonedust.common.GlowstoneWireBlock;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.minecraft.block.Block;
import net.minecraft.block.Material;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class glowBlocks {
public static final Block GLOWSTONEWIRE = new GlowstoneWireBlock(FabricBlockSettings.of(Material.SUPPORTED).breakInstantly().noCollision().luminance(8));
public static void init(){
Registry.register(Registry.BLOCK, new Identifier("glowstonedust", "glowstone_wire"), GLOWSTONEWIRE);
}
}
@@ -0,0 +1,13 @@
package me.parsell.glowstonedust.core;
import net.fabricmc.fabric.api.item.v1.FabricItemSettings;
import net.minecraft.item.BlockItem;
import net.minecraft.item.ItemGroup;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
public class glowItems {
public static void init(){
Registry.register(Registry.ITEM, new Identifier("glowstonedust", "glowstone_wire"), new BlockItem(glowBlocks.GLOWSTONEWIRE, new FabricItemSettings().group(ItemGroup.MISC)));
};
}
@@ -0,0 +1,144 @@
{
"multipart": [
{
"when": {
"OR": [
{
"south": "none",
"north": "none",
"west": "none",
"east": "none"
},
{
"north": "side|up",
"east": "side|up"
},
{
"south": "side|up",
"east": "side|up"
},
{
"south": "side|up",
"west": "side|up"
},
{
"north": "side|up",
"west": "side|up"
}
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_dot"
}
},
{
"when": {
"OR": [
{
"north": "side|up"
},
{
"south": "side|up",
"north": "none",
"west": "none",
"east": "none"
}
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_side0"
}
},
{
"when": {
"OR": [
{
"south": "side|up"
},
{
"south": "none",
"north": "side|up",
"west": "none",
"east": "none"
}
]
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_side_alt0"
}
},
{
"when": {
"OR": [
{
"east": "side|up"
},
{
"south": "none",
"north": "none",
"west": "side|up",
"east": "none"
}
]
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_side_alt1"
}
},
{
"when": {
"OR": [
{
"west": "side|up"
},
{
"south": "none",
"north": "none",
"west": "none",
"east": "side|up"
}
]
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_side1"
}
},
{
"when": {
"north": "up"
},
"apply": {
"model": "glowstonedust:block/glowstone_dust_up"
}
},
{
"when": {
"east": "up"
},
"apply": {
"y": 90,
"model": "glowstonedust:block/glowstone_dust_up"
}
},
{
"when": {
"south": "up"
},
"apply": {
"y": 180,
"model": "glowstonedust:block/glowstone_dust_up"
}
},
{
"when": {
"west": "up"
},
"apply": {
"y": 270,
"model": "glowstonedust:block/glowstone_dust_up"
}
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

@@ -0,0 +1,26 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"line": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 0 ],
"to": [ 16, 0.25, 16 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#line", "tintindex": 0 },
"down": { "uv": [ 0, 16, 16, 0 ], "texture": "#line", "tintindex": 0 }
}
},
{ "from": [ 0, 0.25, 0 ],
"to": [ 16, 0.25, 16 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay" },
"down": { "uv": [ 0, 16, 16, 0 ], "texture": "#overlay" }
}
}
]
}
@@ -0,0 +1,25 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 0 ],
"to": [ 16, 0.25, 8 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 0, 16, 8 ], "texture": "#line", "tintindex": 0 },
"down": { "uv": [ 0, 8, 16, 0 ], "texture": "#line", "tintindex": 0 }
}
},
{ "from": [ 0, 0.25, 0 ],
"to": [ 16, 0.25, 8 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 0, 16, 8 ], "texture": "#overlay" },
"down": { "uv": [ 0, 8, 16, 0 ], "texture": "#overlay" }
}
}
]
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonedust:block/glowstone_dust_side",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line0"
}
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonedust:block/glowstone_dust_side",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line1"
}
}
@@ -0,0 +1,25 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0.25, 8 ],
"to": [ 16, 0.25, 16 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 8, 16, 16 ], "texture": "#line", "tintindex": 0 },
"down": { "uv": [ 0, 16, 16, 8 ], "texture": "#line", "tintindex": 0 }
}
},
{ "from": [ 0, 0.25, 8 ],
"to": [ 16, 0.25, 16 ],
"shade": false,
"faces": {
"up": { "uv": [ 0, 8, 16, 16 ], "texture": "#overlay" },
"down": { "uv": [ 0, 16, 16, 8 ], "texture": "#overlay" }
}
}
]
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonedust:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line0"
}
}
@@ -0,0 +1,6 @@
{
"parent": "glowstonedust:block/glowstone_dust_side_alt",
"textures": {
"line": "glowstonedust:block/glowstone_dust_line1"
}
}
@@ -0,0 +1,26 @@
{
"ambientocclusion": false,
"textures": {
"particle": "glowstonedust:block/glowstone_dust_dot",
"line": "glowstonedust:block/glowstone_dust_line0",
"overlay": "glowstonedust:block/glowstone_dust_overlay"
},
"elements": [
{ "from": [ 0, 0, 0.25 ],
"to": [ 16, 16, 0.25 ],
"shade": false,
"faces": {
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#line", "tintindex": 0 },
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#line", "tintindex": 0 }
}
},
{ "from": [ 0, 0, 0.25 ],
"to": [ 16, 16, 0.25 ],
"shade": false,
"faces": {
"south": { "uv": [ 0, 0, 16, 16 ], "texture": "#overlay" },
"north": { "uv": [ 16, 0, 0, 16 ], "texture": "#overlay" }
}
}
]
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 130 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 B

+40
View File
@@ -0,0 +1,40 @@
{
"schemaVersion": 1,
"id": "glowstonedust",
"version": "${version}",
"name": "Glowstone Dust",
"description": "This is an example description! Tell everyone what your mod is about!",
"authors": [
"Me!"
],
"contact": {
"homepage": "https://fabricmc.net/",
"sources": "https://github.com/FabricMC/fabric-example-mod"
},
"license": "CC0-1.0",
"icon": "assets/glowstonedust/icon.png",
"environment": "*",
"entrypoints": {
"client": [
"me.parsell.glowstonedust.GlowstoneDustClient"
],
"main": [
"me.parsell.glowstonedust.GlowstoneDust"
]
},
"mixins": [
"glowstonedust.mixins.json"
],
"depends": {
"fabricloader": ">=0.7.4",
"fabric": "*",
"minecraft": "1.16.x"
},
"suggests": {
"another-mod": "*"
}
}
@@ -0,0 +1,14 @@
{
"required": true,
"minVersion": "0.8",
"package": "me.parsell.glowstonedust.mixin",
"compatibilityLevel": "JAVA_8",
"mixins": [
],
"client": [
],
"injectors": {
"defaultRequire": 1
}
}