Added the shaping bench

This commit is contained in:
Sollace 2023-11-20 22:30:21 +00:00
parent b8e88a16ad
commit 63243e254d
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
32 changed files with 429 additions and 1 deletions

View file

@ -12,6 +12,7 @@ import com.minelittlepony.unicopia.block.cloud.CompactedCloudBlock;
import com.minelittlepony.unicopia.block.cloud.NaturalCloudBlock;
import com.minelittlepony.unicopia.block.cloud.OrientedCloudBlock;
import com.minelittlepony.unicopia.block.cloud.PoreousCloudStairsBlock;
import com.minelittlepony.unicopia.block.cloud.ShapingBenchBlock;
import com.minelittlepony.unicopia.block.cloud.CloudBedBlock;
import com.minelittlepony.unicopia.block.cloud.CloudBlock;
import com.minelittlepony.unicopia.block.cloud.SoggyCloudBlock;
@ -147,6 +148,7 @@ public interface UBlocks {
Block MYSTERIOUS_EGG = register("mysterious_egg", new PileBlock(Settings.copy(Blocks.SLIME_BLOCK), PileBlock.MYSTERIOUS_EGG_SHAPES), ItemGroups.NATURAL);
Block SLIME_PUSTULE = register("slime_pustule", new SlimePustuleBlock(Settings.copy(Blocks.SLIME_BLOCK)), ItemGroups.NATURAL);
Block SHAPING_BENCH = register("shaping_bench", new ShapingBenchBlock(Settings.create().mapColor(MapColor.OFF_WHITE).hardness(0.3F).resistance(0).sounds(BlockSoundGroup.WOOL)), ItemGroups.FUNCTIONAL);
Block CLOUD = register("cloud", new NaturalCloudBlock(Settings.create().mapColor(MapColor.OFF_WHITE).hardness(0.3F).resistance(0).sounds(BlockSoundGroup.WOOL), true,
() -> UBlocks.SOGGY_CLOUD,
() -> UBlocks.COMPACTED_CLOUD), ItemGroups.NATURAL);

View file

@ -0,0 +1,41 @@
package com.minelittlepony.unicopia.block.cloud;
import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.container.ShapingBenchScreenHandler;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
import net.minecraft.stat.Stats;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class ShapingBenchBlock extends CloudBlock {
public ShapingBenchBlock(Settings settings) {
super(settings, false);
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (world.isClient) {
return ActionResult.SUCCESS;
}
player.openHandledScreen(state.createScreenHandlerFactory(world, pos));
player.incrementStat(Stats.INTERACT_WITH_STONECUTTER);
return ActionResult.CONSUME;
}
@Override
@Nullable
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
return new SimpleNamedScreenHandlerFactory((syncId, playerInventory, player) -> {
return new ShapingBenchScreenHandler(syncId, playerInventory, ScreenHandlerContext.create(world, pos));
}, getName());
}
}

View file

@ -59,6 +59,10 @@ public class UnstableCloudBlock extends CloudBlock {
}
world.playSound(null, pos, SoundEvents.BLOCK_WOOL_HIT, SoundCategory.BLOCKS, 1, 1);
if (world.isClient) {
return;
}
if (fallDistance > 3) {
world.breakBlock(pos, true);
return;

View file

@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.InteractionManager;
import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.Unicopia;
import com.minelittlepony.unicopia.client.gui.LanSettingsScreen;
import com.minelittlepony.unicopia.client.gui.ShapingBenchScreen;
import com.minelittlepony.unicopia.client.gui.UHud;
import com.minelittlepony.unicopia.client.gui.spellbook.SpellbookScreen;
import com.minelittlepony.unicopia.client.minelittlepony.MineLPDelegate;
@ -101,6 +102,7 @@ public class UnicopiaClient implements ClientModInitializer {
URenderers.bootstrap();
HandledScreens.register(UScreenHandlers.SPELL_BOOK, SpellbookScreen::new);
HandledScreens.register(UScreenHandlers.SHAPING_BENCH, ShapingBenchScreen::new);
ClientTickEvents.END_CLIENT_TICK.register(this::onTick);
ClientTickEvents.END_WORLD_TICK.register(this::onWorldTick);

View file

@ -0,0 +1,12 @@
package com.minelittlepony.unicopia.client.gui;
import net.minecraft.client.gui.screen.ingame.StonecutterScreen;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.screen.StonecutterScreenHandler;
import net.minecraft.text.Text;
public class ShapingBenchScreen extends StonecutterScreen {
public ShapingBenchScreen(StonecutterScreenHandler handler, PlayerInventory inventory, Text title) {
super(handler, inventory, title);
}
}

View file

@ -0,0 +1,96 @@
package com.minelittlepony.unicopia.container;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.item.URecipes;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SimpleInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.screen.ScreenHandlerContext;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.screen.StonecutterScreenHandler;
import net.minecraft.screen.slot.Slot;
import net.minecraft.world.World;
public class ShapingBenchScreenHandler extends StonecutterScreenHandler {
private final ScreenHandlerContext context;
private final World world;
private ItemStack inputStack = ItemStack.EMPTY;
public ShapingBenchScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext context) {
super(syncId, playerInventory, context);
this.context = context;
this.world = playerInventory.player.getWorld();
}
public ShapingBenchScreenHandler(int syncId, PlayerInventory playerInventory) {
super(syncId, playerInventory);
this.context = ScreenHandlerContext.EMPTY;
this.world = playerInventory.player.getWorld();
}
@Override
public ScreenHandlerType<?> getType() {
return UScreenHandlers.SHAPING_BENCH;
}
@Override
public boolean canUse(PlayerEntity player) {
return canUse(context, player, UBlocks.SHAPING_BENCH);
}
@Override
public void onContentChanged(Inventory inventory) {
ItemStack stack = slots.get(0).getStack();
if (!stack.isOf(inputStack.getItem())) {
inputStack = stack.copy();
getAvailableRecipes().clear();
setProperty(0, -1);
slots.get(1).setStackNoCallbacks(ItemStack.EMPTY);
if (!stack.isEmpty()) {
getAvailableRecipes().addAll(world.getRecipeManager().getAllMatches(URecipes.CLOUD_SHAPING, input, world));
}
}
}
@Override
public ItemStack quickMove(PlayerEntity player, int slot) {
ItemStack originalStack = ItemStack.EMPTY;
Slot srcSlot = slots.get(slot);
if (srcSlot != null && srcSlot.hasStack()) {
ItemStack movingStack = srcSlot.getStack();
Item item = movingStack.getItem();
originalStack = movingStack.copy();
if (slot == 1) {
item.onCraft(movingStack, player.getWorld(), player);
if (!insertItem(movingStack, 2, 38, true)) {
return ItemStack.EMPTY;
}
srcSlot.onQuickTransfer(movingStack, originalStack);
} else if (slot == 0
? !insertItem(movingStack, 2, 38, false)
: (world.getRecipeManager().getFirstMatch(URecipes.CLOUD_SHAPING, new SimpleInventory(movingStack), world).isPresent()
? !insertItem(movingStack, 0, 1, false)
: (slot >= 2 && slot < 29
? !insertItem(movingStack, 29, 38, false)
: slot >= 29 && slot < 38 && !insertItem(movingStack, 2, 29, false)))) {
return ItemStack.EMPTY;
}
if (movingStack.isEmpty()) {
srcSlot.setStack(ItemStack.EMPTY);
}
srcSlot.markDirty();
if (movingStack.getCount() == originalStack.getCount()) {
return ItemStack.EMPTY;
}
srcSlot.onTakeItem(player, movingStack);
this.sendContentUpdates();
}
return originalStack;
}
}

View file

@ -6,10 +6,12 @@ import net.fabricmc.fabric.api.screenhandler.v1.ExtendedScreenHandlerType;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.screen.ScreenHandlerType;
import net.minecraft.registry.Registry;
import net.minecraft.resource.featuretoggle.FeatureFlags;
import net.minecraft.registry.Registries;
public interface UScreenHandlers {
ScreenHandlerType<SpellbookScreenHandler> SPELL_BOOK = register("spell_book", new ExtendedScreenHandlerType<>(SpellbookScreenHandler::new));
ScreenHandlerType<ShapingBenchScreenHandler> SHAPING_BENCH = register("shaping_bench", new ScreenHandlerType<>(ShapingBenchScreenHandler::new, FeatureFlags.VANILLA_FEATURES));
static <T extends ScreenHandler> ScreenHandlerType<T> register(String name, ScreenHandlerType<T> type) {
return Registry.register(Registries.SCREEN_HANDLER, Unicopia.id(name), type);

View file

@ -4,21 +4,25 @@ import java.util.List;
import com.google.gson.JsonArray;
import com.minelittlepony.unicopia.ability.magic.spell.crafting.*;
import com.minelittlepony.unicopia.item.cloud.CloudShapingRecipe;
import net.fabricmc.fabric.api.loot.v2.LootTableEvents;
import net.minecraft.loot.LootTable;
import net.minecraft.loot.context.LootContextTypes;
import net.minecraft.recipe.CuttingRecipe;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.ShapedRecipe;
import net.minecraft.recipe.ShapelessRecipe;
import net.minecraft.recipe.SpecialRecipeSerializer;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.util.Identifier;
import net.minecraft.util.collection.DefaultedList;
public interface URecipes {
RecipeType<SpellbookRecipe> SPELLBOOK = RecipeType.register("unicopia:spellbook");
RecipeType<StonecuttingRecipe> CLOUD_SHAPING = RecipeType.register("unicopia:cloud_shaping");
RecipeSerializer<ShapelessRecipe> ZAP_APPLE_SERIALIZER = RecipeSerializer.register("unicopia:crafting_zap_apple", new ZapAppleRecipe.Serializer());
RecipeSerializer<GlowingRecipe> GLOWING_SERIALIZER = RecipeSerializer.register("unicopia:crafting_glowing", new SpecialRecipeSerializer<>(GlowingRecipe::new));
@ -28,6 +32,7 @@ public interface URecipes {
RecipeSerializer<SpellCraftingRecipe> TRAIT_REQUIREMENT = RecipeSerializer.register("unicopia:spellbook/crafting", new SpellCraftingRecipe.Serializer());
RecipeSerializer<SpellEnhancingRecipe> TRAIT_COMBINING = RecipeSerializer.register("unicopia:spellbook/combining", new SpellEnhancingRecipe.Serializer());
RecipeSerializer<SpellDuplicatingRecipe> SPELL_DUPLICATING = RecipeSerializer.register("unicopia:spellbook/duplicating", new SpellDuplicatingRecipe.Serializer());
RecipeSerializer<CloudShapingRecipe> CLOUD_SHAPING_SERIALIZER = RecipeSerializer.register("unicopia:cloud_shaping", new CuttingRecipe.Serializer<>(CloudShapingRecipe::new) {});
static DefaultedList<Ingredient> getIngredients(JsonArray json) {
DefaultedList<Ingredient> defaultedList = DefaultedList.of();

View file

@ -0,0 +1,32 @@
package com.minelittlepony.unicopia.item.cloud;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.item.URecipes;
import net.minecraft.item.ItemStack;
import net.minecraft.recipe.Ingredient;
import net.minecraft.recipe.RecipeSerializer;
import net.minecraft.recipe.RecipeType;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.util.Identifier;
public class CloudShapingRecipe extends StonecuttingRecipe {
public CloudShapingRecipe(Identifier id, String group, Ingredient input, ItemStack output) {
super(id, group, input, output);
}
@Override
public RecipeType<?> getType() {
return URecipes.CLOUD_SHAPING;
}
@Override
public RecipeSerializer<?> getSerializer() {
return URecipes.CLOUD_SHAPING_SERIALIZER;
}
@Override
public ItemStack createIcon() {
return new ItemStack(UBlocks.SHAPING_BENCH);
}
}

View file

@ -0,0 +1,7 @@
{
"variants": {
"": {
"model": "unicopia:block/shaping_bench"
}
}
}

View file

@ -271,6 +271,7 @@
"block.unicopia.chiselled_chitin_slab": "Chiselled Chitin Slab",
"block.unicopia.chiselled_chitin_stairs": "Chiselled Chitin Stairs",
"block.unicopia.shaping_bench": "Shaping Bench",
"block.unicopia.cloud": "Cloud",
"block.unicopia.cloud_slab": "Cloud Slab",
"block.unicopia.cloud_stairs": "Cloud Stairs",

View file

@ -0,0 +1,130 @@
{
"parent": "minecraft:block/cube_all",
"textures": {
"3": "unicopia:block/shaping_bench_rim",
"4": "unicopia:block/shaping_bench_inside",
"side": "unicopia:block/shaping_bench_side",
"bottom": "unicopia:block/shaping_bench_bottom",
"particle": "unicopia:block/shaping_bench_top",
"top": "unicopia:block/shaping_bench_top"
},
"elements": [
{
"from": [0, 0, 0],
"to": [16, 4, 16],
"faces": {
"north": {"uv": [0, 12, 16, 16], "texture": "#side"},
"east": {"uv": [0, 12, 16, 16], "texture": "#side"},
"south": {"uv": [0, 12, 16, 16], "texture": "#side"},
"west": {"uv": [0, 12, 16, 16], "texture": "#side"},
"up": {"uv": [0, 0, 16, 16], "texture": "#3"},
"down": {"uv": [0, 0, 16, 16], "texture": "#bottom"}
}
},
{
"from": [2, 4, 2],
"to": [14, 13, 14],
"faces": {
"north": {"uv": [2, 3, 14, 12], "texture": "#side"},
"east": {"uv": [2, 3, 14, 12], "texture": "#side"},
"south": {"uv": [2, 3, 14, 12], "texture": "#side"},
"west": {"uv": [2, 3, 14, 12], "texture": "#side"}
}
},
{
"from": [2, 16, 2],
"to": [14, 17, 14],
"faces": {
"north": {"uv": [2, 2, 14, 3], "texture": "#top"},
"east": {"uv": [2, 2, 14, 3], "texture": "#top"},
"south": {"uv": [2, 2, 14, 3], "texture": "#top"},
"west": {"uv": [2, 2, 14, 3], "texture": "#top"},
"up": {"uv": [2, 2, 14, 14], "texture": "#top"}
}
},
{
"from": [0, 13, 14],
"to": [16, 16, 16],
"faces": {
"east": {"uv": [0, 2, 2, 5], "texture": "#side"},
"south": {"uv": [0, 2, 16, 5], "texture": "#side"},
"west": {"uv": [14, 2, 16, 5], "texture": "#side"},
"up": {"uv": [0, 14, 16, 16], "texture": "#top"},
"down": {"uv": [0, 0, 16, 2], "texture": "#3"}
}
},
{
"from": [0, 13, 0],
"to": [16, 16, 2],
"faces": {
"north": {"uv": [0, 2, 16, 5], "texture": "#side"},
"east": {"uv": [14, 2, 16, 5], "texture": "#side"},
"west": {"uv": [0, 2, 2, 5], "texture": "#side"},
"up": {"uv": [0, 1, 16, 3], "texture": "#top"},
"down": {"uv": [0, 14, 16, 16], "texture": "#3"}
}
},
{
"from": [0, 13, 2],
"to": [2, 16, 14],
"faces": {
"west": {"uv": [2, 2, 14, 5], "texture": "#side"},
"up": {"uv": [1, 2, 3, 14], "texture": "#top"},
"down": {"uv": [0, 2, 2, 14], "texture": "#3"}
}
},
{
"from": [14, 13, 2],
"to": [16, 16, 14],
"faces": {
"east": {"uv": [2, 2, 14, 5], "texture": "#side"},
"up": {"uv": [13, 2, 15, 14], "texture": "#top"},
"down": {"uv": [14, 2, 16, 14], "texture": "#3"}
}
},
{
"from": [13, 16, 0],
"to": [16, 18, 3],
"faces": {
"north": {"uv": [0, 0, 3, 2], "texture": "#side"},
"east": {"uv": [13, 0, 16, 2], "texture": "#side"},
"south": {"uv": [2, 12, 5, 14], "texture": "#top"},
"west": {"uv": [11, 12, 14, 14], "texture": "#top"},
"up": {"uv": [13, 0, 16, 3], "texture": "#4"}
}
},
{
"from": [0, 16, 0],
"to": [3, 18, 3],
"faces": {
"north": {"uv": [13, 0, 16, 2], "texture": "#side"},
"east": {"uv": [2, 12, 5, 14], "texture": "#top"},
"south": {"uv": [11, 12, 14, 14], "texture": "#top"},
"west": {"uv": [0, 0, 3, 2], "texture": "#side"},
"up": {"uv": [0, 0, 3, 3], "texture": "#4"}
}
},
{
"from": [13, 16, 13],
"to": [16, 18, 16],
"faces": {
"north": {"uv": [11, 12, 14, 14], "texture": "#top"},
"east": {"uv": [0, 0, 3, 2], "texture": "#side"},
"south": {"uv": [13, 0, 16, 2], "texture": "#side"},
"west": {"uv": [2, 12, 5, 14], "texture": "#top"},
"up": {"uv": [13, 13, 16, 16], "texture": "#4"}
}
},
{
"from": [0, 16, 13],
"to": [3, 18, 16],
"faces": {
"north": {"uv": [2, 12, 5, 14], "texture": "#top"},
"east": {"uv": [11, 12, 14, 14], "texture": "#top"},
"south": {"uv": [0, 0, 3, 2], "texture": "#side"},
"west": {"uv": [13, 0, 16, 2], "texture": "#side"},
"up": {"uv": [0, 13, 3, 16], "texture": "#4"}
}
}
]
}

View file

@ -0,0 +1,3 @@
{
"parent": "unicopia:block/shaping_bench"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 654 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:carved_cloud",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud_bricks" },
"result": "unicopia:cloud_brick_slab",
"count": 2
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud_bricks" },
"result": "unicopia:cloud_brick_stairs",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:cloud_bricks",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:cloud_pillar",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud_planks" },
"result": "unicopia:cloud_plank_slab",
"count": 2
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud_planks" },
"result": "unicopia:cloud_plank_stairs",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:cloud_planks",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:cloud_slab",
"count": 2
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:cloud_stairs",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:dense_cloud" },
"result": "unicopia:dense_cloud_slab",
"count": 2
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:dense_cloud" },
"result": "unicopia:dense_cloud_stairs",
"count": 1
}

View file

@ -0,0 +1,6 @@
{
"type": "unicopia:cloud_shaping",
"ingredient": { "item": "unicopia:cloud" },
"result": "unicopia:unstable_cloud",
"count": 1
}

View file

@ -0,0 +1,13 @@
{
"type": "minecraft:crafting_shaped",
"pattern": [
"##",
"##"
],
"key": {
"#": [
{ "item": "unicopia:dense_cloud" }
]
},
"result": { "item": "unicopia:shaping_bench", "count": 1 }
}