Added redstone upgrade and made cheaper the diamond storage upgrade, closes #7

This commit is contained in:
Buuz135 2022-08-07 18:32:02 +02:00
parent ac5826ebb2
commit 9e6a44f3a2
11 changed files with 181 additions and 10 deletions

View File

@ -49,8 +49,11 @@
"item.functionalstorage.puller_upgrade": "Puller Upgrade",
"item.functionalstorage.pusher_upgrade": "Pusher Upgrade",
"item.functionalstorage.void_upgrade": "Void Upgrade",
"item.functionalstorage.redstone_upgrade": "Redstone Upgrade",
"item.utility.direction": "Direction: ",
"item.utility.slot": "Slot: ",
"item.utility.direction.desc": "Right click in a GUI to change direction",
"item.utility.slot.desc": "Right click in a GUI to change slot",
"item.utility.downgrade": "Downgrades the slots to a max of 64 items",
"itemGroup.functionalstorage": "Functional Storage",
"key.categories.storage": "Storage",

View File

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "functionalstorage:items/redstone_upgrade"
}
}

View File

@ -18,7 +18,7 @@
"pattern": [
"IBI",
"CDC",
"BBB"
"IBI"
],
"key": {
"I": {

View File

@ -0,0 +1,43 @@
{
"type": "forge:conditional",
"recipes": [
{
"conditions": [
{
"values": [
{
"item": "functionalstorage:redstone_upgrade",
"type": "forge:item_exists"
}
],
"type": "forge:and"
}
],
"recipe": {
"type": "minecraft:crafting_shaped",
"pattern": [
"IBI",
"CDC",
"IBI"
],
"key": {
"I": {
"item": "minecraft:redstone"
},
"B": {
"item": "minecraft:redstone_block"
},
"C": {
"item": "minecraft:comparator"
},
"D": {
"tag": "functionalstorage:drawer"
}
},
"result": {
"item": "functionalstorage:redstone_upgrade"
}
}
}
]
}

View File

@ -13,10 +13,7 @@ import com.buuz135.functionalstorage.data.FunctionalStorageItemTagsProvider;
import com.buuz135.functionalstorage.data.FunctionalStorageLangProvider;
import com.buuz135.functionalstorage.inventory.BigInventoryHandler;
import com.buuz135.functionalstorage.inventory.item.DrawerStackItemHandler;
import com.buuz135.functionalstorage.item.ConfigurationToolItem;
import com.buuz135.functionalstorage.item.LinkingToolItem;
import com.buuz135.functionalstorage.item.StorageUpgradeItem;
import com.buuz135.functionalstorage.item.UpgradeItem;
import com.buuz135.functionalstorage.item.*;
import com.buuz135.functionalstorage.network.EnderDrawerSyncMessage;
import com.buuz135.functionalstorage.recipe.DrawerlessWoodIngredient;
import com.buuz135.functionalstorage.recipe.FramedDrawerRecipe;
@ -109,6 +106,7 @@ public class FunctionalStorage extends ModuleController {
public static RegistryObject<Item> PUSHING_UPGRADE;
public static RegistryObject<Item> VOID_UPGRADE;
public static RegistryObject<Item> CONFIGURATION_TOOL;
public static RegistryObject<Item> REDSTONE_UPGRADE;
public static AdvancedTitaniumTab TAB = new AdvancedTitaniumTab("functionalstorage", true);
@ -182,6 +180,7 @@ public class FunctionalStorage extends ModuleController {
ARMORY_CABINET = getRegistries().registerBlockWithTile("armory_cabinet", ArmoryCabinetBlock::new);
CONFIGURATION_TOOL = getRegistries().registerGeneric(Item.class, "configuration_tool", ConfigurationToolItem::new);
ENDER_DRAWER = getRegistries().registerBlockWithTile("ender_drawer", EnderDrawerBlock::new);
REDSTONE_UPGRADE = getRegistries().registerGeneric(Item.class, "redstone_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
}
public enum DrawerType {
@ -313,6 +312,7 @@ public class FunctionalStorage extends ModuleController {
item(PULLING_UPGRADE.get());
item(PUSHING_UPGRADE.get());
item(VOID_UPGRADE.get());
item(REDSTONE_UPGRADE.get());
}
private void item(Item item) {
@ -378,12 +378,19 @@ public class FunctionalStorage extends ModuleController {
.define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.COPPER).get())
.save(consumer);
TitaniumShapedRecipeBuilder.shapedRecipe(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get())
.pattern("IBI").pattern("CDC").pattern("BBB")
.pattern("IBI").pattern("CDC").pattern("IBI")
.define('I', Tags.Items.GEMS_DIAMOND)
.define('B', Tags.Items.STORAGE_BLOCKS_DIAMOND)
.define('C', Tags.Items.CHESTS_WOODEN)
.define('D', STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.GOLD).get())
.save(consumer);
TitaniumShapedRecipeBuilder.shapedRecipe(REDSTONE_UPGRADE.get())
.pattern("IBI").pattern("CDC").pattern("IBI")
.define('I', Items.REDSTONE)
.define('B', Items.REDSTONE_BLOCK)
.define('C', Items.COMPARATOR)
.define('D', StorageTags.DRAWER)
.save(consumer);
UpgradeRecipeBuilder.smithing(Ingredient.of(STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.DIAMOND).get()), Ingredient.of(Items.NETHERITE_INGOT), STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get())
.unlocks("has_netherite_ingot", has(Items.NETHERITE_INGOT))
.save(consumer, STORAGE_UPGRADES.get(StorageUpgradeItem.StorageTier.NETHERITE).get().getRegistryName());

View File

@ -215,4 +215,32 @@ public class CompactingDrawerBlock extends RotatableBlock<CompactingDrawerTile>
}
super.onRemove(state, worldIn, pos, newState, isMoving);
}
@Override
public boolean canConnectRedstone(BlockState state, BlockGetter level, BlockPos pos, @Nullable Direction direction) {
return true;
}
@Override
public boolean isSignalSource(BlockState p_60571_) {
return true;
}
@Override
public int getSignal(BlockState p_60483_, BlockGetter blockGetter, BlockPos blockPos, Direction p_60486_) {
ControllableDrawerTile tile = TileUtil.getTileEntity(blockGetter, blockPos, ControllableDrawerTile.class).orElse(null);
if (tile != null){
for (int i = 0; i < tile.getUtilityUpgrades().getSlots(); i++) {
ItemStack stack = tile.getUtilityUpgrades().getStackInSlot(i);
if (stack.getItem().equals(FunctionalStorage.REDSTONE_UPGRADE.get())){
int redstoneSlot = stack.getOrCreateTag().getInt("Slot");
if (redstoneSlot < tile.getStorage().getSlots()){
return (int) ((tile.getStorage().getStackInSlot(redstoneSlot).getCount() / (double)tile.getStorage().getSlotLimit(redstoneSlot)) * 15);
}
}
}
}
return 0;
}
}

View File

@ -1,6 +1,7 @@
package com.buuz135.functionalstorage.block;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
import com.buuz135.functionalstorage.block.tile.DrawerControllerTile;
import com.buuz135.functionalstorage.block.tile.DrawerTile;
import com.buuz135.functionalstorage.inventory.item.DrawerCapabilityProvider;
@ -24,6 +25,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.LivingEntity;
@ -59,10 +61,7 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@ -329,6 +328,33 @@ public class DrawerBlock extends RotatableBlock<DrawerTile> {
}
}
@Override
public boolean canConnectRedstone(BlockState state, BlockGetter level, BlockPos pos, @Nullable Direction direction) {
return true;
}
@Override
public boolean isSignalSource(BlockState p_60571_) {
return true;
}
@Override
public int getSignal(BlockState p_60483_, BlockGetter blockGetter, BlockPos blockPos, Direction p_60486_) {
ControllableDrawerTile tile = TileUtil.getTileEntity(blockGetter, blockPos, ControllableDrawerTile.class).orElse(null);
if (tile != null){
for (int i = 0; i < tile.getUtilityUpgrades().getSlots(); i++) {
ItemStack stack = tile.getUtilityUpgrades().getStackInSlot(i);
if (stack.getItem().equals(FunctionalStorage.REDSTONE_UPGRADE.get())){
int redstoneSlot = stack.getOrCreateTag().getInt("Slot");
if (redstoneSlot < tile.getStorage().getSlots()){
return (int) ((tile.getStorage().getStackInSlot(redstoneSlot).getCount() / (double)tile.getStorage().getSlotLimit(redstoneSlot)) * 15);
}
}
}
}
return 0;
}
public static class DrawerItem extends BlockItem{
private DrawerBlock drawerBlock;

View File

@ -1,6 +1,7 @@
package com.buuz135.functionalstorage.block;
import com.buuz135.functionalstorage.FunctionalStorage;
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
import com.buuz135.functionalstorage.block.tile.DrawerControllerTile;
import com.buuz135.functionalstorage.block.tile.EnderDrawerTile;
import com.buuz135.functionalstorage.item.LinkingToolItem;
@ -183,4 +184,31 @@ public class EnderDrawerBlock extends RotatableBlock<EnderDrawerTile> {
}
}
@Override
public boolean canConnectRedstone(BlockState state, BlockGetter level, BlockPos pos, @Nullable Direction direction) {
return true;
}
@Override
public boolean isSignalSource(BlockState p_60571_) {
return true;
}
@Override
public int getSignal(BlockState p_60483_, BlockGetter blockGetter, BlockPos blockPos, Direction p_60486_) {
ControllableDrawerTile tile = TileUtil.getTileEntity(blockGetter, blockPos, ControllableDrawerTile.class).orElse(null);
if (tile != null){
for (int i = 0; i < tile.getUtilityUpgrades().getSlots(); i++) {
ItemStack stack = tile.getUtilityUpgrades().getStackInSlot(i);
if (stack.getItem().equals(FunctionalStorage.REDSTONE_UPGRADE.get())){
int redstoneSlot = stack.getOrCreateTag().getInt("Slot");
if (redstoneSlot < tile.getStorage().getSlots()){
return (int) ((tile.getStorage().getStackInSlot(redstoneSlot).getCount() / (double)tile.getStorage().getSlotLimit(redstoneSlot)) * 15);
}
}
}
}
return 0;
}
}

View File

@ -133,6 +133,18 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
@Override
public void serverTick(Level level, BlockPos pos, BlockState state, T blockEntity) {
super.serverTick(level, pos, state, blockEntity);
if (level.getGameTime() % 20 == 0) {
for (int i = 0; i < this.utilityUpgrades.getSlots(); i++) {
ItemStack stack = this.utilityUpgrades.getStackInSlot(i);
if (!stack.isEmpty()) {
Item item = stack.getItem();
if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get())) {
level.updateNeighborsAt(this.getBlockPos(), this.getBasicTileBlock());
break;
}
}
}
}
if (level.getGameTime() % 4 == 0) {
for (int i = 0; i < this.utilityUpgrades.getSlots(); i++) {
ItemStack stack = this.utilityUpgrades.getStackInSlot(i);

View File

@ -51,6 +51,7 @@ public class FunctionalStorageLangProvider extends LanguageProvider {
this.add(FunctionalStorage.PULLING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PULLING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.PUSHING_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.PUSHING_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.VOID_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.VOID_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.REDSTONE_UPGRADE.get(), WordUtils.capitalize(FunctionalStorage.REDSTONE_UPGRADE.get().getRegistryName().getPath().replace('_', ' ').toLowerCase()) );
this.add(FunctionalStorage.ARMORY_CABINET.getLeft().get(), "Armory Cabinet");
this.add(FunctionalStorage.CONFIGURATION_TOOL.get(), "Configuration Tool");
this.add("item.utility.downgrade", "Downgrades the slots to a max of 64 items");
@ -69,5 +70,7 @@ public class FunctionalStorageLangProvider extends LanguageProvider {
this.add("linkingtool.ender.clear", "Sneak + Right Click in the air to clear frequency.");
this.add("drawer.block.contents", "Contents: ");
this.add("frameddrawer.use", "How 2 Change Texture: \nInside a crafting window place the block you want use the texture of for the outside of the drawer in the first slot of the crafting window, on the second slot put the block that will be used for the texture on the inside of the framed drawer and on the third slot put a framed drawer. \n");
this.add("item.utility.slot", "Slot: ");
this.add("item.utility.slot.desc", "Right click in a GUI to change slot");
}
}

View File

@ -26,6 +26,7 @@ import java.util.Locale;
public class UpgradeItem extends BasicItem {
public static int MAX_SLOT = 4;
public static Direction getDirection(ItemStack stack){
if (stack.hasTag()){
@ -55,6 +56,9 @@ public class UpgradeItem extends BasicItem {
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){
stack.getOrCreateTag().putString("Direction", Direction.values()[0].name());
}
if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get())){
stack.getOrCreateTag().putInt("Slot", 0);
}
return stack;
}
@ -81,6 +85,12 @@ public class UpgradeItem extends BasicItem {
p_150896_.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5f, 1);
return true;
}
if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get())){
int slot = first.getOrCreateTag().getInt("Slot");
first.getOrCreateTag().putInt("Slot", (slot + 1) % MAX_SLOT);
p_150896_.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5f, 1);
return true;
}
}
return super.overrideOtherStackedOnMe(first, second, p_150894_, clickAction, p_150896_, p_150897_);
}
@ -95,6 +105,11 @@ public class UpgradeItem extends BasicItem {
tooltip.add(new TextComponent(""));
tooltip.add(new TranslatableComponent("item.utility.direction.desc").withStyle(ChatFormatting.GRAY));
}
if (item.equals(FunctionalStorage.REDSTONE_UPGRADE.get()) ){
tooltip.add(new TranslatableComponent("item.utility.slot").withStyle(ChatFormatting.YELLOW).append(new TextComponent(stack.getOrCreateTag().getInt("Slot") + "").withStyle(ChatFormatting.WHITE)));
tooltip.add(new TextComponent(""));
tooltip.add(new TranslatableComponent("item.utility.direction.desc").withStyle(ChatFormatting.GRAY));
}
}