started implementing mailbox

This commit is contained in:
DaniTheSkunk 2022-10-31 22:37:34 +00:00
parent 77524a86b0
commit 4b2ca83d2b
16 changed files with 412 additions and 2 deletions

Binary file not shown.

View File

@ -0,0 +1 @@
{"meta":{"format_version":"4.0","model_format":"java_block","box_uv":false},"name":"mailbox","parent":"","ambientocclusion":true,"front_gui_light":false,"visible_box":[1,1,0],"variable_placeholders":"","variable_placeholder_buttons":[],"resolution":{"width":64,"height":64},"elements":[{"name":"cube","rescale":false,"locked":false,"from":[4,0,0],"to":[12,8,16],"autouv":0,"color":3,"origin":[0,0,0],"faces":{"north":{"uv":[0,24,8,32],"texture":0},"east":{"uv":[0,0,16,8],"texture":0},"south":{"uv":[16,20,24,28],"texture":0},"west":{"uv":[0,8,16,16],"texture":0},"up":{"uv":[16,24,0,16],"rotation":90,"texture":0},"down":{"uv":[32,0,16,8],"rotation":270,"texture":0}},"type":"cube","uuid":"da5a9119-359e-4439-cb14-efc7a71a6b49"},{"name":"cube","rescale":false,"locked":false,"from":[5,8,0],"to":[11,10,16],"autouv":0,"color":1,"origin":[0,0,0],"faces":{"north":{"uv":[8,26,14,28],"texture":0},"east":{"uv":[8,28,24,30],"texture":0},"south":{"uv":[8,24,14,26],"texture":0},"west":{"uv":[24,28,40,30],"texture":0},"up":{"uv":[32,14,16,8],"rotation":90,"texture":0},"down":{"uv":[32,14,16,20],"rotation":270,"texture":0}},"type":"cube","uuid":"04c2fe3d-fa39-bdc9-f749-c641507581ad"},{"name":"cube","rescale":false,"locked":false,"from":[6,10,0],"to":[10,11,16],"autouv":0,"color":1,"origin":[0,0,0],"faces":{"north":{"uv":[32,1,36,2],"texture":0},"east":{"uv":[8,30,24,31],"texture":0},"south":{"uv":[32,0,36,1],"texture":0},"west":{"uv":[24,30,40,31],"texture":0},"up":{"uv":[40,24,24,20],"rotation":90,"texture":0},"down":{"uv":[40,24,24,28],"rotation":270,"texture":0}},"type":"cube","uuid":"7bf9cc3d-5698-f5dd-6f57-d5fbb02cf393"},{"name":"cube","rescale":false,"locked":false,"from":[3,5,1],"to":[4,6,9],"autouv":0,"color":2,"origin":[0,0,0],"faces":{"north":{"uv":[15,27,16,28],"texture":0},"east":{"uv":[8,31,16,32],"texture":0},"south":{"uv":[14,27,15,28],"texture":0},"west":{"uv":[16,31,24,32],"texture":0},"up":{"uv":[32,32,24,31],"rotation":90,"texture":0},"down":{"uv":[8,32,0,33],"rotation":270,"texture":0}},"type":"cube","uuid":"97ac315c-b4c7-304d-e971-1bf060f57e6f"},{"name":"cube","rescale":false,"locked":false,"from":[3,4,8],"to":[4,5,9],"autouv":0,"color":2,"origin":[0,0,0],"faces":{"north":{"uv":[15,25,16,26],"texture":0},"east":{"uv":[14,24,15,25],"texture":0},"south":{"uv":[15,24,16,25],"texture":0},"west":{"uv":[14,25,15,26],"texture":0},"up":{"uv":[15,27,14,26],"rotation":90,"texture":0},"down":{"uv":[16,26,15,27],"rotation":270,"texture":0}},"type":"cube","uuid":"5db61ae3-c617-6ecb-fe23-e4907bbc0181"}],"outliner":["da5a9119-359e-4439-cb14-efc7a71a6b49","04c2fe3d-fa39-bdc9-f749-c641507581ad","7bf9cc3d-5698-f5dd-6f57-d5fbb02cf393","97ac315c-b4c7-304d-e971-1bf060f57e6f","5db61ae3-c617-6ecb-fe23-e4907bbc0181"],"textures":[{"path":"C:\\dev\\skunkstuff\\assets\\model\\mailbox.png","name":"mailbox.png","folder":"block","namespace":"skunkstuff","id":"0","particle":true,"render_mode":"default","visible":true,"mode":"bitmap","saved":true,"uuid":"c66af65e-d859-545b-af83-b46e68831f46","relative_path":"../mailbox.png","source":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAAAi1JREFUeF7tmTFLw1AQgF+ki4izgkFBhEJJkXZy7yrBuZv07+gkCJ2KINmKEgQH6VAnp3RoKBS6KAp2KsU6R1JMaWObNO8uvh69bCW54953373Xplqz2fTy+byQudrttqhWqzKhk5hKpTITXyqVNFDChMEaA1BsgGVZ/9rxsCDKDWAAbACPgPo9IOHJMfM49BhUvgfYtu3lcjkpBp1OR4xGI5HNZqXiu92uKJfLag2AAtg4PBYnR7oUgJfeuzg1DhiAFD2kII0NAO4Baz8Cuq6LQqEgJWSr1RLFYpH2HnBz9yy1+CCoXrtQDwCyAh/A3s6uVIqP/qdQDsCyLA9yjtefHNoAHtxXD3KO1y6vGADpEcAwQGoD+A1SvgdAAWz2e+OlGIYxw8F13cnn8L1lgfk50n5HqGEAWLTAAAIDCNmxUgY4juNBvskNBoM/+gcLJGFAo9Hw4mZ4+n6wqC/zfLzObbsWCeD69nHZhs99Lu1NUvMBJJ1hH0ISAKt8TC4FAGoAeQDzjrhpA6IcJz8CmUxGQP47HA6HAvLO0TTNVH8txo4AA1gHA6JmOJh10FkWEXz2/Zaq4nF1a/db++PvAYsu1QXGLQB6Xyl9aPEY8QwAgyLlHGwA5e5h1M4GYFCknIMNoNw9jNrZAAyKlHOwAZS7h1E7G4BBkXIONoBy9zBqZwMwKFLOwQZQ7h5G7WwABkXKOdgAyt3DqJ0NwKBIOQcbQLl7GLWzARgUKef4AR59mFBeGSKmAAAAAElFTkSuQmCC"}]}

70
assets/model/mailbox.json Normal file
View File

@ -0,0 +1,70 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"0": "mailbox",
"particle": "mailbox"
},
"elements": [
{
"from": [0, 0, 4],
"to": [16, 8, 12],
"faces": {
"north": {"uv": [0, 0, 4, 2], "texture": "#0"},
"east": {"uv": [4, 5, 6, 7], "texture": "#0"},
"south": {"uv": [0, 2, 4, 4], "texture": "#0"},
"west": {"uv": [0, 6, 2, 8], "texture": "#0"},
"up": {"uv": [4, 6, 0, 4], "texture": "#0"},
"down": {"uv": [8, 0, 4, 2], "texture": "#0"}
}
},
{
"from": [0, 8, 5],
"to": [16, 10, 11],
"faces": {
"north": {"uv": [2, 7, 6, 7.5], "texture": "#0"},
"east": {"uv": [2, 6, 3.5, 6.5], "texture": "#0"},
"south": {"uv": [6, 7, 10, 7.5], "texture": "#0"},
"west": {"uv": [2, 6.5, 3.5, 7], "texture": "#0"},
"up": {"uv": [8, 3.5, 4, 2], "texture": "#0"},
"down": {"uv": [8, 3.5, 4, 5], "texture": "#0"}
}
},
{
"from": [0, 10, 6],
"to": [16, 11, 10],
"faces": {
"north": {"uv": [2, 7.5, 6, 7.75], "texture": "#0"},
"east": {"uv": [8, 0, 9, 0.25], "texture": "#0"},
"south": {"uv": [6, 7.5, 10, 7.75], "texture": "#0"},
"west": {"uv": [8, 0.25, 9, 0.5], "texture": "#0"},
"up": {"uv": [10, 6, 6, 5], "texture": "#0"},
"down": {"uv": [10, 6, 6, 7], "texture": "#0"}
}
},
{
"from": [1, 5, 12],
"to": [9, 6, 13],
"faces": {
"north": {"uv": [2, 7.75, 4, 8], "texture": "#0"},
"east": {"uv": [3.5, 6.75, 3.75, 7], "texture": "#0"},
"south": {"uv": [4, 7.75, 6, 8], "texture": "#0"},
"west": {"uv": [3.75, 6.75, 4, 7], "texture": "#0"},
"up": {"uv": [8, 8, 6, 7.75], "texture": "#0"},
"down": {"uv": [2, 8, 0, 8.25], "texture": "#0"}
}
},
{
"from": [8, 4, 12],
"to": [9, 5, 13],
"faces": {
"north": {"uv": [3.5, 6, 3.75, 6.25], "texture": "#0"},
"east": {"uv": [3.75, 6, 4, 6.25], "texture": "#0"},
"south": {"uv": [3.5, 6.25, 3.75, 6.5], "texture": "#0"},
"west": {"uv": [3.75, 6.25, 4, 6.5], "texture": "#0"},
"up": {"uv": [3.75, 6.75, 3.5, 6.5], "texture": "#0"},
"down": {"uv": [4, 6.5, 3.75, 6.75], "texture": "#0"}
}
}
]
}

BIN
assets/model/mailbox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

View File

@ -0,0 +1,100 @@
package com.danitheskunk.skunkstuff.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.core.NonNullList;
import net.minecraft.network.chat.Component;
import net.minecraft.world.ContainerHelper;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.entity.BaseContainerBlockEntity;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.entity.ShulkerBoxBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import java.util.stream.IntStream;
public class BlockEntityMailbox extends BaseContainerBlockEntity {
private static final int[] SLOTS = IntStream.range(0, 9).toArray();
private NonNullList<ItemStack> itemStacks;
public BlockEntityMailbox(BlockPos pos, BlockState state) {
super(BlockEntityTypes.MAILBOX, pos, state);
this.itemStacks = NonNullList.withSize(SLOTS.length, ItemStack.EMPTY);
}
@Override
protected Component getDefaultName() {
return Component.translatable("block.skunkstuff.mailbox");
}
@Override
protected AbstractContainerMenu createMenu(int syncId,
Inventory playerInventory) {
return null;
}
@Override
public int getContainerSize() {
return SLOTS.length;
}
@Override
public boolean isEmpty() {
return itemStacks.isEmpty();
}
@Override
public ItemStack getItem(int slot) {
return itemStacks.get(slot);
}
@Override
public ItemStack removeItem(int slot, int amount) {
var itemStack = ContainerHelper.removeItem(itemStacks, slot, amount);
if(!itemStack.isEmpty()) {
this.setChanged();
}
return itemStack;
}
@Override
public ItemStack removeItemNoUpdate(int slot) {
return ContainerHelper.takeItem(itemStacks, slot);
}
@Override
public void setItem(int slot, ItemStack stack) {
itemStacks.set(slot, stack);
if(stack.getCount() > this.getMaxStackSize()) {
stack.setCount(this.getMaxStackSize());
}
this.setChanged();
}
@Override
public boolean stillValid(Player player) {
if(this.level.getBlockEntity(this.worldPosition) != this) {
return false;
} else {
return !(
player.distanceToSqr(
(double) this.worldPosition.getX() +
0.5,
(double) this.worldPosition.getY() + 0.5,
(double) this.worldPosition.getZ() + 0.5
) > 64.0
);
}
}
@Override
public void clearContent() {
itemStacks.clear();
}
}

View File

@ -0,0 +1,30 @@
package com.danitheskunk.skunkstuff.Blocks;
import com.danitheskunk.skunkstuff.SkunkStuff;
import com.google.common.collect.ImmutableSet;
import com.mojang.datafixers.types.Type;
import net.minecraft.Util;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.datafix.fixes.References;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.quiltmc.qsl.block.entity.api.QuiltBlockEntityTypeBuilder;
import java.util.Set;
public class BlockEntityTypes {
public static final BlockEntityType<BlockEntityMailbox> MAILBOX =
QuiltBlockEntityTypeBuilder.create(BlockEntityMailbox::new,
SkunkStuff.MAILBOX_BLOCK).build();
public static void register() {
Registry.register(
Registry.BLOCK_ENTITY_TYPE,
new ResourceLocation(Blocks.namespace, "mailbox"),
MAILBOX
);
}
}

View File

@ -0,0 +1,74 @@
package com.danitheskunk.skunkstuff.Blocks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.context.BlockPlaceContext;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.*;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.state.StateDefinition;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;
public class BlockMailbox extends BaseEntityBlock {
private static final VoxelShape AABB_EASTWEST = Block.box(0.0,
0.0,
4.0,
16.0,
11.0,
12.0
);
private static final VoxelShape AABB_NORTHSOUTH = Block.box(4.0,
0.0,
0.0,
12.0,
11.0,
16.0
);
private static final VoxelShape AABB_NOPE = Block.box(0.0,
0.0,
0.0,
0.0,
0.0,
0.0
);
public BlockMailbox(Properties properties) {
super(properties);
}
@Override
public VoxelShape getShape(BlockState state, BlockGetter world,
BlockPos pos, CollisionContext context) {
return switch(state.getValue(DirectionalBlock.FACING)) {
case NORTH, SOUTH -> AABB_NORTHSOUTH;
case WEST, EAST -> AABB_EASTWEST;
case UP, DOWN -> AABB_NOPE;
};
}
protected void createBlockStateDefinition(StateDefinition.Builder<Block,
BlockState> builder) {
builder.add(DirectionalBlock.FACING);
}
public BlockState getStateForPlacement(BlockPlaceContext ctx) {
return (BlockState) this.defaultBlockState().setValue(
DirectionalBlock.FACING,
ctx.getNearestLookingDirection().getOpposite()
);
}
@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new BlockEntityMailbox(pos, state);
}
@Override
public RenderShape getRenderShape(BlockState state) {
return RenderShape.MODEL;
}
}

View File

@ -12,7 +12,7 @@ import java.util.List;
public class Blocks { public class Blocks {
private static final List<BlockBuilder> deferred = new ArrayList<>(); private static final List<BlockBuilder> deferred = new ArrayList<>();
private static final String namespace = "skunkstuff"; public static final String namespace = "skunkstuff";
public static BlockBuilder register() { public static BlockBuilder register() {
return new BlockBuilder(); return new BlockBuilder();

View File

@ -1,8 +1,10 @@
package com.danitheskunk.skunkstuff; package com.danitheskunk.skunkstuff;
import com.danitheskunk.skunkstuff.Blocks.BlockGoban; import com.danitheskunk.skunkstuff.Blocks.BlockGoban;
import com.danitheskunk.skunkstuff.Blocks.BlockMailbox;
import com.danitheskunk.skunkstuff.Blocks.Blocks; import com.danitheskunk.skunkstuff.Blocks.Blocks;
import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.DispenserBlock;
import org.quiltmc.loader.api.ModContainer; import org.quiltmc.loader.api.ModContainer;
import org.quiltmc.qsl.base.api.entrypoint.ModInitializer; import org.quiltmc.qsl.base.api.entrypoint.ModInitializer;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -29,6 +31,8 @@ public class SkunkStuff implements ModInitializer {
"crimson_goban").type(BlockGoban.class).build(); "crimson_goban").type(BlockGoban.class).build();
public static final Block MANGROVE_GOBAN_BLOCK = Blocks.register().name( public static final Block MANGROVE_GOBAN_BLOCK = Blocks.register().name(
"mangrove_goban").type(BlockGoban.class).build(); "mangrove_goban").type(BlockGoban.class).build();
public static final Block MAILBOX_BLOCK = Blocks.register().name("mailbox").type(
BlockMailbox.class).build();
@Override @Override
public void onInitialize(ModContainer mod) { public void onInitialize(ModContainer mod) {

View File

@ -0,0 +1,19 @@
{
"variants": {
"facing=north": {
"model": "skunkstuff:block/mailbox"
},
"facing=east": {
"model": "skunkstuff:block/mailbox",
"y": 90
},
"facing=south": {
"model": "skunkstuff:block/mailbox",
"y": 180
},
"facing=west": {
"model": "skunkstuff:block/mailbox",
"y": 270
}
}
}

View File

@ -16,5 +16,8 @@
"block.skunkstuff.mangrove.goban": "Mangrove Goban", "block.skunkstuff.mangrove.goban": "Mangrove Goban",
"block.skunkstuff.oak_goban": "Oak Goban", "block.skunkstuff.oak_goban": "Oak Goban",
"block.skunkstuff.spruce_goban": "Spruce Goban", "block.skunkstuff.spruce_goban": "Spruce Goban",
"block.skunkstuff.warped_goban": "Warped Goban" "block.skunkstuff.warped_goban": "Warped Goban",
"item.skunkstuff.mailbox": "Mailbox",
"block.skunkstuff.mailbox": "Mailbox"
} }

View File

@ -0,0 +1,70 @@
{
"credit": "Made with Blockbench",
"texture_size": [64, 64],
"textures": {
"0": "skunkstuff:block/mailbox",
"particle": "skunkstuff:block/mailbox"
},
"elements": [
{
"from": [4, 0, 0],
"to": [12, 8, 16],
"faces": {
"north": {"uv": [0, 6, 2, 8], "texture": "#0"},
"east": {"uv": [0, 0, 4, 2], "texture": "#0"},
"south": {"uv": [4, 5, 6, 7], "texture": "#0"},
"west": {"uv": [0, 2, 4, 4], "texture": "#0"},
"up": {"uv": [4, 6, 0, 4], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 0, 4, 2], "rotation": 270, "texture": "#0"}
}
},
{
"from": [5, 8, 0],
"to": [11, 10, 16],
"faces": {
"north": {"uv": [2, 6.5, 3.5, 7], "texture": "#0"},
"east": {"uv": [2, 7, 6, 7.5], "texture": "#0"},
"south": {"uv": [2, 6, 3.5, 6.5], "texture": "#0"},
"west": {"uv": [6, 7, 10, 7.5], "texture": "#0"},
"up": {"uv": [8, 3.5, 4, 2], "rotation": 90, "texture": "#0"},
"down": {"uv": [8, 3.5, 4, 5], "rotation": 270, "texture": "#0"}
}
},
{
"from": [6, 10, 0],
"to": [10, 11, 16],
"faces": {
"north": {"uv": [8, 0.25, 9, 0.5], "texture": "#0"},
"east": {"uv": [2, 7.5, 6, 7.75], "texture": "#0"},
"south": {"uv": [8, 0, 9, 0.25], "texture": "#0"},
"west": {"uv": [6, 7.5, 10, 7.75], "texture": "#0"},
"up": {"uv": [10, 6, 6, 5], "rotation": 90, "texture": "#0"},
"down": {"uv": [10, 6, 6, 7], "rotation": 270, "texture": "#0"}
}
},
{
"from": [3, 5, 1],
"to": [4, 6, 9],
"faces": {
"north": {"uv": [3.75, 6.75, 4, 7], "texture": "#0"},
"east": {"uv": [2, 7.75, 4, 8], "texture": "#0"},
"south": {"uv": [3.5, 6.75, 3.75, 7], "texture": "#0"},
"west": {"uv": [4, 7.75, 6, 8], "texture": "#0"},
"up": {"uv": [8, 8, 6, 7.75], "rotation": 90, "texture": "#0"},
"down": {"uv": [2, 8, 0, 8.25], "rotation": 270, "texture": "#0"}
}
},
{
"from": [3, 4, 8],
"to": [4, 5, 9],
"faces": {
"north": {"uv": [3.75, 6.25, 4, 6.5], "texture": "#0"},
"east": {"uv": [3.5, 6, 3.75, 6.25], "texture": "#0"},
"south": {"uv": [3.75, 6, 4, 6.25], "texture": "#0"},
"west": {"uv": [3.5, 6.25, 3.75, 6.5], "texture": "#0"},
"up": {"uv": [3.75, 6.75, 3.5, 6.5], "rotation": 90, "texture": "#0"},
"down": {"uv": [4, 6.5, 3.75, 6.75], "rotation": 270, "texture": "#0"}
}
}
]
}

View File

@ -0,0 +1,3 @@
{
"parent": "skunkstuff:block/mailbox"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 536 B

View File

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "skunkstuff:mailbox"
}
],
"rolls": 1.0
}
]
}

View File

@ -0,0 +1,16 @@
{
"type": "minecraft:crafting_shaped",
"key": {
".": {
"item": "minecraft:iron_ingot"
}
},
"pattern": [
" . ",
". .",
"..."
],
"result": {
"item": "skunkstuff:mailbox"
}
}