Skip to content

Commit

Permalink
Add Recipes
Browse files Browse the repository at this point in the history
Add Materials
  • Loading branch information
PTOM76 committed Sep 18, 2021
1 parent 75eaf21 commit dcaf259
Show file tree
Hide file tree
Showing 30 changed files with 467 additions and 77 deletions.
11 changes: 11 additions & 0 deletions src/main/java/ml/pkom/enhancedquarries/Items.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ public class Items {
// 壁
public static Item fillerWALL = new FillerModule(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));

// 素材
public static Item REFINED_GEAR = new Item(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
public static Item ENHANCED_REFINED_GEAR = new Item(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));
public static Item ENHANCED_PANEL = new Item(new FabricItemSettings().group(EnhancedQuarries.FILLER_PLUS_GROUP));

// ----

public static void init() {
Registry.register(Registry.ITEM, EnhancedQuarries.id("normal_quarry"), NORMAL_QUARRY);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_quarry"), ENHANCED_QUARRY);
Expand All @@ -60,5 +67,9 @@ public static void init() {
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_leveling"), fillerLEVELING);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_create_box"), fillerBOX);
Registry.register(Registry.ITEM, EnhancedQuarries.id("filler_create_wall"), fillerWALL);

Registry.register(Registry.ITEM, EnhancedQuarries.id("refined_gear"), REFINED_GEAR);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_refined_gear"), ENHANCED_REFINED_GEAR);
Registry.register(Registry.ITEM, EnhancedQuarries.id("enhanced_panel"), ENHANCED_PANEL);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package ml.pkom.enhancedquarries.item;

import ml.pkom.enhancedquarries.block.base.Filler;
import ml.pkom.enhancedquarries.block.base.Quarry;
import ml.pkom.enhancedquarries.tile.base.FillerTile;
import ml.pkom.enhancedquarries.tile.base.QuarryTile;
import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext;
Expand All @@ -20,7 +22,6 @@ public ActionResult useOnBlock(ItemUsageContext context) {
if (world.isClient())
return super.useOnBlock(context);
BlockPos blockPos = context.getBlockPos();

if (world.getBlockState(blockPos).getBlock() instanceof Quarry) {
if (world.getBlockEntity(blockPos) != null && world.getBlockEntity(blockPos) instanceof QuarryTile) {
QuarryTile quarry = (QuarryTile) world.getBlockEntity(blockPos);
Expand All @@ -33,6 +34,18 @@ public ActionResult useOnBlock(ItemUsageContext context) {
return ActionResult.SUCCESS;
}
}
if (world.getBlockState(blockPos).getBlock() instanceof Filler) {
if (world.getBlockEntity(blockPos) != null && world.getBlockEntity(blockPos) instanceof FillerTile) {
FillerTile filler = (FillerTile) world.getBlockEntity(blockPos);
if (filler.canBedrockBreak()) {
context.getPlayer().sendMessage(new TranslatableText("message.enhanced_quarries.bedrock_break_module.1"), false);
return ActionResult.PASS;
}
filler.setBedrockBreak(true);
context.getStack().setCount(context.getStack().getCount() - 1);
return ActionResult.SUCCESS;
}
}
return super.useOnBlock(context);
}
}
112 changes: 71 additions & 41 deletions src/main/java/ml/pkom/enhancedquarries/tile/base/FillerTile.java
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
package ml.pkom.enhancedquarries.tile.base;

import ml.pkom.enhancedquarries.Items;
import ml.pkom.enhancedquarries.block.Frame;
import ml.pkom.enhancedquarries.block.base.Filler;
import ml.pkom.enhancedquarries.inventory.ImplementedInventory;
import ml.pkom.enhancedquarries.mixin.MachineBaseBlockEntityAccessor;
import net.minecraft.block.*;
import net.minecraft.block.entity.BlockEntityType;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.inventory.Inventories;
import net.minecraft.inventory.Inventory;
import net.minecraft.inventory.SidedInventory;
import net.minecraft.item.BlockItem;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NbtCompound;
import net.minecraft.predicate.entity.EntityPredicates;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.screen.ScreenHandler;
import net.minecraft.sound.SoundCategory;
import net.minecraft.text.Text;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import net.minecraft.world.WorldAccess;
import org.jetbrains.annotations.Nullable;
import net.minecraft.util.registry.Registry;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.SlotConfiguration;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;

import java.util.List;

public class FillerTile extends PowerAcceptorBlockEntity implements InventoryProvider {// implements IInventory {

// Container
Expand Down Expand Up @@ -65,6 +51,22 @@ public ItemStack getModule() {

// ----

// モジュール

// - 岩盤破壊モジュール
private boolean canBedrockBreak = false;

public boolean canBedrockBreak() {
return canBedrockBreak;
}

public void setBedrockBreak(boolean canBedrockBreak) {
this.canBedrockBreak = canBedrockBreak;
}

// ----


// TR
// デフォルトコスト
private double defaultEnergyCost = 30;
Expand Down Expand Up @@ -102,7 +104,6 @@ public NbtCompound writeNbt(NbtCompound tag) {
NbtCompound invTag = new NbtCompound();
Inventories.writeNbt(invTag, craftingInvItems);
tag.put("craftingInv", invTag);

tag.putDouble("coolTime", coolTime);
if (pos1 != null) {
tag.putInt("rangePos1X", getPos1().getX());
Expand All @@ -114,6 +115,9 @@ public NbtCompound writeNbt(NbtCompound tag) {
tag.putInt("rangePos2Y", getPos2().getY());
tag.putInt("rangePos2Z", getPos2().getZ());
}

if (canBedrockBreak)
tag.putBoolean("module_bedrock_break", true);
return super.writeNbt(tag);
}

Expand All @@ -132,6 +136,9 @@ public void fromTag(BlockState blockState, NbtCompound tag) {
setPos1(new BlockPos(tag.getInt("rangePos1X"), tag.getInt("rangePos1Y"), tag.getInt("rangePos1Z")));
setPos2(new BlockPos(tag.getInt("rangePos2X"), tag.getInt("rangePos2Y"), tag.getInt("rangePos2Z")));
}

if (tag.contains("module_bedrock_break"))
canBedrockBreak = tag.getBoolean("module_bedrock_break");
}

// ----
Expand Down Expand Up @@ -196,15 +203,54 @@ public void tick() {
}
}

private ItemStack latestGotStack = ItemStack.EMPTY;

public static boolean isStorageBox(ItemStack stack) {
return Registry.ITEM.getId(stack.getItem()).toString().equals("storagebox:storagebox");
}

public ItemStack getInventoryStack() {
for (ItemStack stack : getInventory().getStacks()) {
if (!stack.isEmpty() && stack.getItem() instanceof BlockItem) {
return stack;
latestGotStack = stack;
if (stack.isEmpty()) continue;
if (stack.getItem() instanceof BlockItem) return stack;
// StorageBox
if (isStorageBox(stack)) {
NbtCompound tag = stack.getTag();
if (tag.contains("item")) {
ItemStack itemInBox = ItemStack.fromNbt(tag.getCompound("item"));
if (itemInBox.getItem() instanceof BlockItem) return itemInBox;
}
}
// ---- StorageBox
}
return ItemStack.EMPTY;
}

public boolean tryPlacing(BlockPos blockPos, Block block, ItemStack stack) {
if (getWorld().setBlockState(blockPos, block.getDefaultState())) {
getWorld().playSound(null, blockPos, block.getSoundGroup(block.getDefaultState()).getPlaceSound(), SoundCategory.BLOCKS, 1F, 1F);
if (isStorageBox(latestGotStack)) {
NbtCompound tag = latestGotStack.getTag();
if (tag.contains("countInBox")) {
int countInBox = tag.getInt("countInBox");
countInBox--;
tag.putInt("countInBox", countInBox);
if (countInBox <= 0) {
tag.remove("item");
tag.remove("countInBox");
}
latestGotStack.setTag(tag);
}
return true;
}
latestGotStack.setCount(latestGotStack.getCount() - 1);
return true;
}
return false;

}

public boolean tryFilling(Item item) {
if (getWorld() == null || getWorld().isClient()) return false;
if (pos1 == null || pos2 == null)
Expand All @@ -226,26 +272,22 @@ public boolean tryFilling(Item item) {
if (stack.isEmpty()) return false;
Block block = Block.getBlockFromItem(stack.getItem());
if (block.is(procBlock)) continue;
if (getWorld().setBlockState(procPos, block.getDefaultState())) {
getWorld().playSound(null, procPos, block.getSoundGroup(block.getDefaultState()).getPlaceSound(), SoundCategory.BLOCKS, 1F, 1F);
stack.setCount(stack.getCount() - 1);
return true;
}
if (tryPlacing(procPos, block, stack)) return true;
}
}
// 消去モジュール
if (item.equals(Items.fillerALL_DELETE)) {
if (procBlock instanceof AirBlock) continue;
if (procBlock instanceof AirBlock || (procBlock.is(Blocks.BEDROCK) && !canBedrockBreak)) continue;
return getWorld().removeBlock(procPos, false);
}
// 撤去モジュール
if (item.equals(Items.fillerALL_REMOVE)) {
if (procBlock instanceof AirBlock) continue;
if (procBlock instanceof AirBlock || (procBlock.is(Blocks.BEDROCK) && !canBedrockBreak)) continue;
return getWorld().breakBlock(procPos, true);
}
// 整地モジュール
if (item.equals(Items.fillerLEVELING)) {
if (!(procBlock instanceof AirBlock))
if (!(procBlock instanceof AirBlock) && !(procBlock.is(Blocks.BEDROCK) && !canBedrockBreak))
return getWorld().breakBlock(procPos, true);
}
// 箱モジュール
Expand All @@ -258,11 +300,7 @@ public boolean tryFilling(Item item) {
if (stack.isEmpty()) return false;
Block block = Block.getBlockFromItem(stack.getItem());
if (block.is(procBlock)) continue;
if (getWorld().setBlockState(procPos, block.getDefaultState())) {
getWorld().playSound(null, procPos, block.getSoundGroup(block.getDefaultState()).getPlaceSound(), SoundCategory.BLOCKS, 1F, 1F);
stack.setCount(stack.getCount() - 1);
return true;
}
if (tryPlacing(procPos, block, stack)) return true;
}
}
// 壁モジュール
Expand All @@ -275,11 +313,7 @@ public boolean tryFilling(Item item) {
if (stack.isEmpty()) return false;
Block block = Block.getBlockFromItem(stack.getItem());
if (block.is(procBlock)) continue;
if (getWorld().setBlockState(procPos, block.getDefaultState())) {
getWorld().playSound(null, procPos, block.getSoundGroup(block.getDefaultState()).getPlaceSound(), SoundCategory.BLOCKS, 1F, 1F);
stack.setCount(stack.getCount() - 1);
return true;
}
if (tryPlacing(procPos, block, stack)) return true;
}
}
}
Expand All @@ -300,11 +334,7 @@ public boolean tryFilling(Item item) {
if (stack.isEmpty()) continue;
Block block = Block.getBlockFromItem(stack.getItem());
if (block.is(procBlock)) continue;
if (getWorld().setBlockState(procPos, block.getDefaultState())) {
getWorld().playSound(null, procPos, block.getSoundGroup(block.getDefaultState()).getPlaceSound(), SoundCategory.BLOCKS, 1F, 1F);
stack.setCount(stack.getCount() - 1);
return true;
}
if (tryPlacing(procPos, block, stack)) return true;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import net.minecraft.entity.EntityType;
import net.minecraft.entity.ItemEntity;
import net.minecraft.entity.mob.MobEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
Expand All @@ -20,9 +19,6 @@
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Direction;
import reborncore.api.blockentity.InventoryProvider;
import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
import reborncore.common.blockentity.SlotConfiguration;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
Expand Down
14 changes: 9 additions & 5 deletions src/main/resources/assets/enhanced_quarries/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,16 @@
"item.enhanced_quarries.filler_create_box": "Create Box Module",
"item.enhanced_quarries.filler_create_wall": "Create Wall Module",

"message.enhanced_quarries.bedrock_break_module.1": "The \"Bedrock Break Module\" has already been applied to the quarry.",
"message.enhanced_quarries.silk_touch_module.1": "The \"Silk Touch Module\" has already been applied to the quarry.",
"message.enhanced_quarries.luck_enchant_module.1": "The \"Luck Module\" has already been applied to the quarry.",
"message.enhanced_quarries.mob_delete_module.1": "The \"Mob Delete Module\" has already been applied to the quarry.",
"item.enhanced_quarries.refined_gear": "Refined Gear",
"item.enhanced_quarries.enhanced_refined_gear": "Enhanced / Refined Gear",
"item.enhanced_quarries.enhanced_panel": "Enhanced Panel",

"message.enhanced_quarries.bedrock_break_module.1": "The \"Bedrock Break Module\" has already been applied to the machine.",
"message.enhanced_quarries.silk_touch_module.1": "The \"Silk Touch Module\" has already been applied to the machine.",
"message.enhanced_quarries.luck_enchant_module.1": "The \"Luck Module\" has already been applied to the machine.",
"message.enhanced_quarries.mob_delete_module.1": "The \"Mob Delete Module\" has already been applied to the machine.",
"message.enhanced_quarries.mob_delete_module.2": "\"Mob Delete Module\" And \"Mob Kill Module\" cannot coexist.",
"message.enhanced_quarries.mob_kill_module.1": "The \"Mob Kill Module\" has already been applied to the quarry.",
"message.enhanced_quarries.mob_kill_module.1": "The \"Mob Kill Module\" has already been applied to the machine.",
"message.enhanced_quarries.mob_kill_module.2": "\"Mob Kill Module\" And \"Mob Delete Module\" cannot coexist.",

"screen.enhanced_quarries.filler.title": "Filler",
Expand Down
16 changes: 10 additions & 6 deletions src/main/resources/assets/enhanced_quarries/lang/ja_jp.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
"item.enhanced_quarries.filler_all_delete": "全て消去モジュール",
"item.enhanced_quarries.filler_all_remove": "全て撤去モジュール",
"item.enhanced_quarries.filler_leveling": "整地モジュール",
"item.enhanced_quarries.filler_create_box": "ボックス建設モジュール",
"item.enhanced_quarries.filler_create_box": "箱建設モジュール",
"item.enhanced_quarries.filler_create_wall": "壁建設モジュール",

"message.enhanced_quarries.bedrock_break_module.1": "そのクァーリーは既に岩盤破壊モジュールが適用されています。",
"message.enhanced_quarries.silk_touch_module.1": "そのクァーリーは既にシルクタッチモジュールが適用されています。",
"message.enhanced_quarries.luck_enchant_module.1": "そのクァーリーは既に幸運モジュールが適用されています。",
"message.enhanced_quarries.mob_delete_module.1": "そのクァーリーは既にモブ消去モジュールが適用されています。",
"item.enhanced_quarries.refined_gear": "洗練されたギア",
"item.enhanced_quarries.enhanced_refined_gear": "強化・洗練の歯車",
"item.enhanced_quarries.enhanced_gear": "強化されたパネル",

"message.enhanced_quarries.bedrock_break_module.1": "そのマシンは既に岩盤破壊モジュールが適用されています。",
"message.enhanced_quarries.silk_touch_module.1": "そのマシンは既にシルクタッチモジュールが適用されています。",
"message.enhanced_quarries.luck_enchant_module.1": "そのマシンは既に幸運モジュールが適用されています。",
"message.enhanced_quarries.mob_delete_module.1": "そのマシンは既にモブ消去モジュールが適用されています。",
"message.enhanced_quarries.mob_delete_module.2": "モブ消去モジュールとモブ殺害モジュールは共存できません。",
"message.enhanced_quarries.mob_kill_module.1": "そのクァーリーは既にモブ殺害モジュールが適用されています",
"message.enhanced_quarries.mob_kill_module.1": "そのマシンは既にモブ殺害モジュールが適用されています",
"message.enhanced_quarries.mob_kill_module.2": "モブ殺害モジュールとモブ消去モジュールは共存できません。"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "enhanced_quarries:item/enhanced_panel"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "enhanced_quarries:item/enhanced_refined_gear"
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"parent": "enhanced_quarries:block/normal_marker"
}
"parent": "item/generated",
"textures": {
"layer0": "enhanced_quarries:item/normal_marker"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "enhanced_quarries:item/refined_gear"
}
}
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.
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.
Loading

0 comments on commit dcaf259

Please sign in to comment.