Skip to content

Commit

Permalink
wip: Add Landing Stone
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Dec 15, 2023
1 parent ca7abd4 commit d2864bc
Show file tree
Hide file tree
Showing 15 changed files with 271 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public void generate() {
add(ModBlocks.sharestone, createDoubleBlockWaystoneLoot(ModBlocks.sharestone));
add(ModBlocks.portstone, createDoubleBlockWaystoneLoot(ModBlocks.portstone));
add(ModBlocks.warpPlate, createWaystoneLoot(ModBlocks.warpPlate));
add(ModBlocks.landingStone, createWaystoneLoot(ModBlocks.landingStone));
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
add(scopedSharestone, createDoubleBlockWaystoneLoot(scopedSharestone));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ protected void addTags(HolderLookup.Provider arg) {
ModBlocks.endStoneWaystone,
ModBlocks.warpPlate,
ModBlocks.portstone,
ModBlocks.landingStone,
ModBlocks.sharestone);
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
mineableBuilder.add(scopedSharestone);
Expand All @@ -43,6 +44,7 @@ protected void addTags(HolderLookup.Provider arg) {
ModBlocks.endStoneWaystone,
ModBlocks.warpPlate,
ModBlocks.portstone,
ModBlocks.landingStone,
ModBlocks.sharestone);
for (Block scopedSharestone : ModBlocks.scopedSharestones) {
isTeleportTargetBuilder.add(scopedSharestone);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public ModModelProvider(FabricDataOutput output) {
@Override
public void generateBlockStateModels(BlockModelGenerators blockStateModelGenerator) {
blockStateModelGenerator.createNonTemplateModelBlock(ModBlocks.warpPlate);
blockStateModelGenerator.createNonTemplateModelBlock(ModBlocks.landingStone);
createDoubleBlockWaystone(blockStateModelGenerator, ModBlocks.waystone);
createDoubleBlockWaystone(blockStateModelGenerator, ModBlocks.sandyWaystone);
createDoubleBlockWaystone(blockStateModelGenerator, ModBlocks.mossyWaystone);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "waystones:block/landing_stone"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"parent": "waystones:block/landing_stone"
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"waystones:end_stone_waystone",
"waystones:warp_plate",
"waystones:portstone",
"waystones:landing_stone",
"waystones:sharestone",
"waystones:white_sharestone",
"waystones:orange_sharestone",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"type": "minecraft:block",
"pools": [
{
"bonus_rolls": 0.0,
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
],
"entries": [
{
"type": "minecraft:item",
"name": "waystones:landing_stone"
}
],
"functions": [
{
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
],
"function": "minecraft:copy_nbt",
"ops": [
{
"op": "replace",
"source": "UUID",
"target": "UUID"
}
],
"source": "block_entity"
},
{
"conditions": [
{
"condition": "minecraft:match_tool",
"predicate": {
"enchantments": [
{
"enchantment": "minecraft:silk_touch",
"levels": {
"min": 1
}
}
]
}
}
],
"function": "minecraft:copy_name",
"source": "block_entity"
}
],
"rolls": 1.0
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"waystones:end_stone_waystone",
"waystones:warp_plate",
"waystones:portstone",
"waystones:landing_stone",
"waystones:sharestone",
"waystones:white_sharestone",
"waystones:orange_sharestone",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class WaystoneTypes {
public static final ResourceLocation WAYSTONE = new ResourceLocation(Waystones.MOD_ID, "waystone");
public static final ResourceLocation WARP_PLATE = new ResourceLocation(Waystones.MOD_ID, "warp_plate");
public static final ResourceLocation PORTSTONE = new ResourceLocation(Waystones.MOD_ID, "portstone");
public static final ResourceLocation LANDING_STONE = new ResourceLocation(Waystones.MOD_ID, "landing_stone");

public static final ResourceLocation SHARESTONE = new ResourceLocation(Waystones.MOD_ID, "sharestone");
public static final ResourceLocation[] DYED_SHARESTONES = new ResourceLocation[] {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package net.blay09.mods.waystones.block;

import net.blay09.mods.balm.api.Balm;
import net.blay09.mods.waystones.api.IWaystone;
import net.blay09.mods.waystones.block.entity.LandingStoneBlockEntity;
import net.blay09.mods.waystones.block.entity.WarpPlateBlockEntity;
import net.blay09.mods.waystones.block.entity.WaystoneBlockEntityBase;
import net.minecraft.core.BlockPos;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;

public class LandingStoneBlock extends WaystoneBlockBase {
private static final VoxelShape SHAPE = Shapes.or(
box(0.0, 0.0, 0.0, 16.0, 1.0, 16.0),
box(3.0, 1.0, 3.0, 13.0, 2.0, 13.0)
).optimize();

public LandingStoneBlock(Properties properties) {
super(properties);
registerDefaultState(this.stateDefinition.any()
.setValue(WATERLOGGED, false));
}

@Override
protected boolean canSilkTouch() {
return true;
}


@Override
public VoxelShape getShape(BlockState blockState, BlockGetter blockGetter, BlockPos blockPos, CollisionContext collisionContext) {
return SHAPE;
}


@Nullable
@Override
public BlockEntity newBlockEntity(BlockPos pos, BlockState state) {
return new LandingStoneBlockEntity(pos, state);
}

@Override
protected InteractionResult handleActivation(Level world, BlockPos pos, Player player, WaystoneBlockEntityBase tileEntity, IWaystone waystone) {
if (!world.isClientSide) {
Balm.getNetworking().openGui(player, tileEntity.getMenuProvider());
return InteractionResult.SUCCESS;
}

return InteractionResult.SUCCESS;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class ModBlocks {
public static Block sharestone;
public static Block warpPlate;
public static Block portstone;
public static Block landingStone;
public static Block[] scopedSharestones = new SharestoneBlock[DyeColor.values().length];

public static void initialize(BalmBlocks blocks) {
Expand All @@ -33,6 +34,7 @@ public static void initialize(BalmBlocks blocks) {
blocks.register(() -> sharestone = new SharestoneBlock(defaultProperties(), null), () -> itemBlock(sharestone), id("sharestone"));
blocks.register(() -> warpPlate = new WarpPlateBlock(defaultProperties()), () -> itemBlock(warpPlate), id("warp_plate"));
blocks.register(() -> portstone = new PortstoneBlock(defaultProperties()), () -> itemBlock(portstone), id("portstone"));
blocks.register(() -> landingStone = new LandingStoneBlock(defaultProperties()), () -> itemBlock(landingStone), id("landing_stone"));

DyeColor[] colors = DyeColor.values();
for (DyeColor color : colors) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package net.blay09.mods.waystones.block.entity;

import net.blay09.mods.balm.api.menu.BalmMenuProvider;
import net.blay09.mods.waystones.api.WaystoneTypes;
import net.blay09.mods.waystones.core.Waystone;
import net.blay09.mods.waystones.menu.ModMenus;
import net.blay09.mods.waystones.menu.WaystoneSettingsMenu;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.inventory.AbstractContainerMenu;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class LandingStoneBlockEntity extends WaystoneBlockEntityBase {

public LandingStoneBlockEntity(BlockPos worldPosition, BlockState state) {
super(ModBlockEntities.landingStone.get(), worldPosition, state);
}

@Override
protected ResourceLocation getWaystoneType() {
return WaystoneTypes.LANDING_STONE;
}

@Override
public MenuProvider getMenuProvider() {
return new BalmMenuProvider() {
@Override
public Component getDisplayName() {
return Component.translatable("container.waystones.waystone_settings");
}

@Override
public AbstractContainerMenu createMenu(int i, Inventory playerInventory, Player playerEntity) {
return new WaystoneSettingsMenu(ModMenus.waystoneSettings.get(), getWaystone(), i);
}

@Override
public void writeScreenOpeningData(ServerPlayer player, FriendlyByteBuf buf) {
Waystone.write(buf, getWaystone());
}
};
}

@Override
public @Nullable MenuProvider getSettingsMenuProvider() {
return getMenuProvider();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ModBlockEntities {
public static DeferredObject<BlockEntityType<SharestoneBlockEntity>> sharestone;
public static DeferredObject<BlockEntityType<WarpPlateBlockEntity>> warpPlate;
public static DeferredObject<BlockEntityType<PortstoneBlockEntity>> portstone;
public static DeferredObject<BlockEntityType<LandingStoneBlockEntity>> landingStone;

public static void initialize(BalmBlockEntities blockEntities) {
waystone = blockEntities.registerBlockEntity(id("waystone"),
Expand All @@ -24,6 +25,7 @@ public static void initialize(BalmBlockEntities blockEntities) {
() -> ArrayUtils.add(ModBlocks.scopedSharestones, ModBlocks.sharestone));
warpPlate = blockEntities.registerBlockEntity(id("warp_plate"), WarpPlateBlockEntity::new, () -> new Block[]{ModBlocks.warpPlate});
portstone = blockEntities.registerBlockEntity(id("portstone"), PortstoneBlockEntity::new, () -> new Block[]{ModBlocks.portstone});
landingStone = blockEntities.registerBlockEntity(id("landing_stone"), LandingStoneBlockEntity::new, () -> new Block[]{ModBlocks.landingStone});
}

private static ResourceLocation id(String name) {
Expand Down
1 change: 1 addition & 0 deletions shared/src/main/resources/assets/waystones/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"block.waystones.black_sharestone": "Black Sharestone",
"block.waystones.warp_plate": "Warp Plate",
"block.waystones.portstone": "Portstone",
"block.waystones.landing_stone": "Landing Stone",
"item.waystones.warp_scroll": "Warp Scroll",
"item.waystones.warp_scroll_bound": "Warp Scroll (Bound)",
"item.waystones.return_scroll": "Return Scroll",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
{
"parent": "block/block",
"credit": "Made with Blockbench",
"textures": {
"texture": "waystones:block/warp_plate",
"particle": "waystones:block/warp_plate",
"inner": "waystones:block/warp_plate_inner",
"base": "waystones:block/warp_plate_base"
},
"elements": [
{
"name": "diag",
"from": [2.5, 1, 2.5],
"to": [13.5, 1.5, 13.5],
"rotation": {"angle": -45, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 10, 0.5], "texture": "#texture"},
"east": {"uv": [0, 0, 10, 1], "texture": "#texture"},
"south": {"uv": [0, 0, 10, 0.5], "texture": "#texture"},
"west": {"uv": [0, 0, 10, 0.5], "texture": "#texture"},
"up": {"uv": [0, 0, 10, 10], "rotation": 270, "texture": "#texture"},
"down": {"uv": [0, 0, 10, 10], "rotation": 90, "texture": "#texture"}
}
},
{
"name": "bordersouth",
"from": [3, 1, 3],
"to": [13, 2, 13],
"rotation": {"angle": 0, "axis": "y", "origin": [8, 0, 8]},
"faces": {
"north": {"uv": [0, 0, 10, 1], "texture": "#texture"},
"east": {"uv": [0, 9, 10, 10], "texture": "#texture"},
"south": {"uv": [0, 9, 10, 10], "texture": "#texture"},
"west": {"uv": [0, 0, 10, 1], "texture": "#texture"},
"up": {"uv": [0, 0, 10, 10], "texture": "#texture"},
"down": {"uv": [0, 0, 10, 10], "texture": "#texture"}
}
},
{
"name": "inner",
"from": [5, 2, 5],
"to": [11, 2.01, 11],
"faces": {
"north": {"uv": [0, 0, 6, 0.01], "texture": "#inner"},
"east": {"uv": [0, 0, 6, 0.01], "texture": "#inner"},
"south": {"uv": [0, 0, 6, 0.01], "texture": "#inner"},
"west": {"uv": [0, 0, 6, 0.01], "texture": "#inner"},
"up": {"uv": [0, 0, 16, 16], "texture": "#inner"},
"down": {"uv": [0, 0, 6, 6], "texture": "#inner"}
}
},
{
"name": "base",
"from": [0, 0, 0],
"to": [16, 1, 16],
"faces": {
"north": {"uv": [0, 0, 16, 0.25], "texture": "#base"},
"east": {"uv": [0, 0, 16, 0.25], "texture": "#base"},
"south": {"uv": [0, 0, 16, 0.25], "texture": "#base"},
"west": {"uv": [0, 0, 16, 0.25], "texture": "#base"},
"up": {"uv": [0, 0, 16, 16], "texture": "#base"},
"down": {"uv": [0, 0, 16, 16], "texture": "#base"}
}
}
]
}

0 comments on commit d2864bc

Please sign in to comment.