Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding carpet base structure #2

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/main/java/tyra314/inca/IncaMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import tyra314.inca.block.Blocks;
import tyra314.inca.item.ModItems;
import tyra314.inca.network.SpitPacket;

Expand All @@ -33,6 +34,7 @@ public void onInitialize()
LOG.info("Initializing Inca Mod...");

ModItems.init();
Blocks.init();

ServerSidePacketRegistry.INSTANCE.register(SpitPacket.ID, new SpitPacket.Handler());
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/tyra314/inca/block/BaseBlock.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package tyra314.inca.block;

import net.minecraft.block.Block;

public class BaseBlock extends Block
{
private final String registry_key;

public BaseBlock(String registry_key, Block.Settings settings)
{
super(settings);

this.registry_key = registry_key;
}


@SuppressWarnings("WeakerAccess")
public String getRegistryKey()
{
return registry_key;
}
}
28 changes: 28 additions & 0 deletions src/main/java/tyra314/inca/block/Blocks.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package tyra314.inca.block;

import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry;
import tyra314.inca.IncaMod;

public class Blocks
{
public static BaseBlock CARPET = new Carpet("foo_carpet");
public static BaseBlock CARPET2 = new Carpet("inti_carpet");

public static void init()
{
register(CARPET);
register(CARPET2);
}

private static void register(BaseBlock block)
{
Registry.register(Registry.BLOCK, new Identifier(IncaMod.MOD_ID, block.getRegistryKey()), block);

Registry.register(Registry.ITEM,
new Identifier(IncaMod.MOD_ID, block.getRegistryKey()),
new BlockItem(block, new Item.Settings().itemGroup(IncaMod.ITEM_GROUP)));
}
}
51 changes: 51 additions & 0 deletions src/main/java/tyra314/inca/block/Carpet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package tyra314.inca.block;

import net.fabricmc.fabric.api.block.BlockSettingsExtensions;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor;
import net.minecraft.entity.EntityContext;
import net.minecraft.sound.BlockSoundGroup;
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.IWorld;
import net.minecraft.world.ViewableWorld;

public class Carpet extends BaseBlock
{
protected static final VoxelShape SHAPE = Block.createCuboidShape(0.0D, 0.0D, 0.0D, 16.0D, 1.0D, 16.0D);

public Carpet(String key)
{
super(key, get_settings());
}

private static Settings get_settings()
{
Settings settings = Block.Settings.of(Material.CARPET, MaterialColor.RED).strength(0.1f, 0.1f);

BlockSettingsExtensions.sounds(settings, BlockSoundGroup.WOOL);

return settings;
}

public VoxelShape getOutlineShape(BlockState blockState_1,
BlockView blockView_1,
BlockPos blockPos_1,
EntityContext entityContext_1)
{
return SHAPE;
}

public BlockState getStateForNeighborUpdate(BlockState blockState_1, Direction direction_1, BlockState blockState_2, IWorld iWorld_1, BlockPos blockPos_1, BlockPos blockPos_2) {
return !blockState_1.canPlaceAt(iWorld_1, blockPos_1) ? Blocks.AIR.getDefaultState() : super.getStateForNeighborUpdate(blockState_1, direction_1, blockState_2, iWorld_1, blockPos_1, blockPos_2);
}

public boolean canPlaceAt(BlockState blockState_1, ViewableWorld viewableWorld_1, BlockPos blockPos_1) {
return !viewableWorld_1.isAir(blockPos_1.down());
}
}
6 changes: 6 additions & 0 deletions src/main/resources/assets/inca/blockstates/foo_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"variants": {
"": { "model": "inca:block/foo_carpet" }
}
}

6 changes: 6 additions & 0 deletions src/main/resources/assets/inca/blockstates/inti_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"variants": {
"": { "model": "inca:block/inti_carpet" }
}
}

8 changes: 8 additions & 0 deletions src/main/resources/assets/inca/models/block/foo_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/carpet",
"textures": {
"particle": "inca:block/foo_carpet",
"wool": "inca:block/foo_carpet"
}
}

8 changes: 8 additions & 0 deletions src/main/resources/assets/inca/models/block/inti_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"parent": "block/carpet",
"textures": {
"particle": "inca:block/inti_carpet",
"wool": "inca:block/inti_carpet"
}
}

3 changes: 3 additions & 0 deletions src/main/resources/assets/inca/models/item/foo_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "inca:block/foo_carpet"
}
3 changes: 3 additions & 0 deletions src/main/resources/assets/inca/models/item/inti_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "inca:block/inti_carpet"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions src/main/resources/data/inca/loot_tables/blocks/foo_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inca:foo_carpet"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}

20 changes: 20 additions & 0 deletions src/main/resources/data/inca/loot_tables/blocks/inti_carpet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item",
"name": "inca:inti_carpet"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}