parent
bd811b861c
commit
1441cf69fe
|
@ -12,7 +12,7 @@ buildscript {
|
|||
apply plugin: 'net.minecraftforge.gradle'
|
||||
|
||||
group = 'com.buuz135'
|
||||
version = '1.18.1-0.0.2'
|
||||
version = '1.18.1-0.0.4'
|
||||
|
||||
java {
|
||||
archivesBaseName = 'functionalstorage'
|
||||
|
|
|
@ -9,8 +9,8 @@ import com.buuz135.functionalstorage.client.ControllerRenderer;
|
|||
import com.buuz135.functionalstorage.client.DrawerRenderer;
|
||||
import com.buuz135.functionalstorage.data.FunctionalStorageBlockTagsProvider;
|
||||
import com.buuz135.functionalstorage.data.FunctionalStorageBlockstateProvider;
|
||||
import com.buuz135.functionalstorage.data.FunctionalStorageLangProvider;
|
||||
import com.buuz135.functionalstorage.data.FunctionalStorageItemTagsProvider;
|
||||
import com.buuz135.functionalstorage.data.FunctionalStorageLangProvider;
|
||||
import com.buuz135.functionalstorage.item.ConfigurationToolItem;
|
||||
import com.buuz135.functionalstorage.item.LinkingToolItem;
|
||||
import com.buuz135.functionalstorage.item.StorageUpgradeItem;
|
||||
|
@ -57,8 +57,8 @@ import org.apache.logging.log4j.LogManager;
|
|||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class FunctionalStorage extends ModuleController {
|
|||
DRAWER_CONTROLLER = getRegistries().register(Block.class, "storage_controller", DrawerControllerBlock::new);
|
||||
LINKING_TOOL = getRegistries().register(Item.class, "linking_tool", LinkingToolItem::new);
|
||||
for (StorageUpgradeItem.StorageTier value : StorageUpgradeItem.StorageTier.values()) {
|
||||
STORAGE_UPGRADES.put(value, getRegistries().register(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"),() -> new StorageUpgradeItem(value)));
|
||||
STORAGE_UPGRADES.put(value, getRegistries().register(Item.class, value.name().toLowerCase(Locale.ROOT) + (value == StorageUpgradeItem.StorageTier.IRON ? "_downgrade" : "_upgrade"), () -> new StorageUpgradeItem(value)));
|
||||
}
|
||||
COLLECTOR_UPGRADE = getRegistries().register(Item.class, "collector_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
|
||||
PULLING_UPGRADE = getRegistries().register(Item.class, "puller_upgrade", () -> new UpgradeItem(new Item.Properties(), UpgradeItem.Type.UTILITY));
|
||||
|
@ -117,7 +117,7 @@ public class FunctionalStorage extends ModuleController {
|
|||
CONFIGURATION_TOOL = getRegistries().register(Item.class, "configuration_tool", ConfigurationToolItem::new);
|
||||
}
|
||||
|
||||
public enum DrawerType{
|
||||
public enum DrawerType {
|
||||
X_1(1, 32 * 64, "1x1"),
|
||||
X_2(2, 16 * 64, "1x2"),
|
||||
X_4(4, 8 * 64, "2x2");
|
||||
|
@ -126,7 +126,7 @@ public class FunctionalStorage extends ModuleController {
|
|||
private final int slotAmount;
|
||||
private final String displayName;
|
||||
|
||||
private DrawerType(int slots, int slotAmount, String displayName){
|
||||
private DrawerType(int slots, int slotAmount, String displayName) {
|
||||
this.slots = slots;
|
||||
this.slotAmount = slotAmount;
|
||||
this.displayName = displayName;
|
||||
|
@ -146,41 +146,36 @@ public class FunctionalStorage extends ModuleController {
|
|||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public void onClient(){
|
||||
public void onClient() {
|
||||
EventManager.mod(EntityRenderersEvent.RegisterRenderers.class).process(registerRenderers -> {
|
||||
for (DrawerType value : DrawerType.values()) {
|
||||
DRAWER_TYPES.get(value).forEach(blockRegistryObject -> {
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock)blockRegistryObject.get()).getTileEntityType(), p_173571_ -> new DrawerRenderer());
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) blockRegistryObject.get()).getTileEntityType(), p_173571_ -> new DrawerRenderer());
|
||||
});
|
||||
}
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock)COMPACTING_DRAWER.get()).getTileEntityType(), p_173571_ -> new CompactingDrawerRenderer());
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock)DRAWER_CONTROLLER.get()).getTileEntityType(), p -> new ControllerRenderer());
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) COMPACTING_DRAWER.get()).getTileEntityType(), p_173571_ -> new CompactingDrawerRenderer());
|
||||
registerRenderers.registerBlockEntityRenderer(((BasicTileBlock) DRAWER_CONTROLLER.get()).getTileEntityType(), p -> new ControllerRenderer());
|
||||
}).subscribe();
|
||||
EventManager.mod(ColorHandlerEvent.Item.class).process(item -> {
|
||||
item.getItemColors().register((stack, tint) -> {
|
||||
if(stack.hasTag()){
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
LinkingToolItem.LinkingMode linkingMode = LinkingToolItem.LinkingMode.valueOf(tag.getString(LinkingToolItem.NBT_MODE));
|
||||
LinkingToolItem.ActionMode linkingAction = LinkingToolItem.ActionMode.valueOf(tag.getString(LinkingToolItem.NBT_ACTION));
|
||||
if (tint == 3 && tag.contains(LinkingToolItem.NBT_CONTROLLER)){
|
||||
return Color.RED.getRGB();
|
||||
}
|
||||
if (tint == 1){
|
||||
return linkingMode.getColor().getValue();
|
||||
}
|
||||
if (tint == 2){
|
||||
return linkingAction.getColor().getValue();
|
||||
}
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
LinkingToolItem.LinkingMode linkingMode = LinkingToolItem.getLinkingMode(stack);
|
||||
LinkingToolItem.ActionMode linkingAction = LinkingToolItem.getActionMode(stack);
|
||||
if (tint == 3 && tag.contains(LinkingToolItem.NBT_CONTROLLER)) {
|
||||
return Color.RED.getRGB();
|
||||
}
|
||||
if (tint == 1) {
|
||||
return linkingMode.getColor().getValue();
|
||||
}
|
||||
if (tint == 2) {
|
||||
return linkingAction.getColor().getValue();
|
||||
}
|
||||
return 0xffffff;
|
||||
}, LINKING_TOOL.get());
|
||||
item.getItemColors().register((stack, tint) -> {
|
||||
if (stack.hasTag()){
|
||||
CompoundTag tag = stack.getOrCreateTag();
|
||||
ConfigurationToolItem.ConfigurationAction action = ConfigurationToolItem.ConfigurationAction.valueOf(tag.getString(ConfigurationToolItem.NBT_MODE));
|
||||
if (tint == 1){
|
||||
return action.getColor().getValue();
|
||||
}
|
||||
ConfigurationToolItem.ConfigurationAction action = ConfigurationToolItem.getAction(stack);
|
||||
if (tint == 1) {
|
||||
return action.getColor().getValue();
|
||||
}
|
||||
return 0xffffff;
|
||||
}, CONFIGURATION_TOOL.get());
|
||||
|
@ -298,7 +293,7 @@ public class FunctionalStorage extends ModuleController {
|
|||
.save(consumer);
|
||||
}
|
||||
});
|
||||
event.getGenerator().addProvider(new FunctionalStorageItemTagsProvider(event.getGenerator(),new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new FunctionalStorageItemTagsProvider(event.getGenerator(), new BlockTagsProvider(event.getGenerator()), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new FunctionalStorageLangProvider(event.getGenerator(), MOD_ID, "en_us"));
|
||||
event.getGenerator().addProvider(new FunctionalStorageBlockTagsProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()));
|
||||
event.getGenerator().addProvider(new ItemModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
|
@ -313,8 +308,8 @@ public class FunctionalStorage extends ModuleController {
|
|||
item(VOID_UPGRADE.get());
|
||||
}
|
||||
|
||||
private void item(Item item){
|
||||
singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0" ,new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath()));
|
||||
private void item(Item item) {
|
||||
singleTexture(item.getRegistryName().getPath(), new ResourceLocation("minecraft:item/generated"), "layer0", new ResourceLocation(MOD_ID, "items/" + item.getRegistryName().getPath()));
|
||||
}
|
||||
});
|
||||
event.getGenerator().addProvider(new BlockModelProvider(event.getGenerator(), MOD_ID, event.getExistingFileHelper()) {
|
||||
|
|
|
@ -132,7 +132,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
|||
if (!stack.isEmpty()){
|
||||
Item item = stack.getItem();
|
||||
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get())){
|
||||
Direction direction = Direction.byName(stack.getOrCreateTag().getString("Direction"));
|
||||
Direction direction = UpgradeItem.getDirection(stack);
|
||||
TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> {
|
||||
blockEntity1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).ifPresent(iItemHandler -> {
|
||||
for (int otherSlot = 0; otherSlot < iItemHandler.getSlots(); otherSlot++) {
|
||||
|
@ -153,7 +153,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
|||
});
|
||||
}
|
||||
if (item.equals(FunctionalStorage.PUSHING_UPGRADE.get())){
|
||||
Direction direction = Direction.byName(stack.getOrCreateTag().getString("Direction"));
|
||||
Direction direction = UpgradeItem.getDirection(stack);
|
||||
TileUtil.getTileEntity(level, pos.relative(direction)).ifPresent(blockEntity1 -> {
|
||||
blockEntity1.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, direction.getOpposite()).ifPresent(otherHandler -> {
|
||||
for (int otherSlot = 0; otherSlot < getStorage().getSlots(); otherSlot++) {
|
||||
|
@ -174,7 +174,7 @@ public abstract class ControllableDrawerTile<T extends ControllableDrawerTile<T>
|
|||
});
|
||||
}
|
||||
if (item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){
|
||||
Direction direction = Direction.byName(stack.getOrCreateTag().getString("Direction"));
|
||||
Direction direction = UpgradeItem.getDirection(stack);
|
||||
AABB box = new AABB(pos.relative(direction));
|
||||
for (ItemEntity entitiesOfClass : level.getEntitiesOfClass(ItemEntity.class, box)) {
|
||||
ItemStack pulledStack = ItemHandlerHelper.copyStackWithSize(entitiesOfClass.getItem(), Math.min(entitiesOfClass.getItem().getCount(), 4));
|
||||
|
|
|
@ -2,12 +2,10 @@ package com.buuz135.functionalstorage.item;
|
|||
|
||||
import com.buuz135.functionalstorage.FunctionalStorage;
|
||||
import com.buuz135.functionalstorage.block.tile.ControllableDrawerTile;
|
||||
import com.buuz135.functionalstorage.block.tile.DrawerControllerTile;
|
||||
import com.hrznstudio.titanium.item.BasicItem;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.*;
|
||||
|
@ -32,6 +30,13 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
|
||||
public static final String NBT_MODE = "Mode";
|
||||
|
||||
public static ConfigurationAction getAction(ItemStack stack) {
|
||||
if (stack.hasTag()) {
|
||||
return ConfigurationAction.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
}
|
||||
return ConfigurationAction.LOCKING;
|
||||
}
|
||||
|
||||
public ConfigurationToolItem() {
|
||||
super(new Properties().tab(FunctionalStorage.TAB).stacksTo(1));
|
||||
}
|
||||
|
@ -42,7 +47,7 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
initNbt(p_41447_);
|
||||
}
|
||||
|
||||
private ItemStack initNbt(ItemStack stack){
|
||||
private ItemStack initNbt(ItemStack stack) {
|
||||
stack.getOrCreateTag().putString(NBT_MODE, ConfigurationAction.LOCKING.name());
|
||||
return stack;
|
||||
}
|
||||
|
@ -60,14 +65,14 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
ItemStack stack = context.getItemInHand();
|
||||
Level level = context.getLevel();
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
ConfigurationAction configuractionAction = ConfigurationAction.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
if (blockEntity instanceof ControllableDrawerTile){
|
||||
if (configuractionAction == ConfigurationAction.LOCKING){
|
||||
ConfigurationAction configuractionAction = getAction(stack);
|
||||
if (blockEntity instanceof ControllableDrawerTile) {
|
||||
if (configuractionAction == ConfigurationAction.LOCKING) {
|
||||
((ControllableDrawerTile<?>) blockEntity).toggleLocking();
|
||||
}else{
|
||||
} else {
|
||||
((ControllableDrawerTile<?>) blockEntity).toggleOption(configuractionAction);
|
||||
}
|
||||
return InteractionResult.SUCCESS;
|
||||
return InteractionResult.SUCCESS;
|
||||
}
|
||||
return super.useOn(context);
|
||||
}
|
||||
|
@ -75,10 +80,10 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level p_41432_, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
if (!stack.isEmpty() && stack.hasTag()){
|
||||
if (player.isShiftKeyDown()){
|
||||
ConfigurationAction action = ConfigurationAction.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
ConfigurationAction newAction = ConfigurationAction.values()[(Arrays.asList(ConfigurationAction.values()).indexOf(action) + 1 ) % ConfigurationAction.values().length];
|
||||
if (!stack.isEmpty()) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
ConfigurationAction action = getAction(stack);
|
||||
ConfigurationAction newAction = ConfigurationAction.values()[(Arrays.asList(ConfigurationAction.values()).indexOf(action) + 1) % ConfigurationAction.values().length];
|
||||
stack.getOrCreateTag().putString(NBT_MODE, newAction.name());
|
||||
player.displayClientMessage(new TextComponent("Swapped mode to ").setStyle(Style.EMPTY.withColor(newAction.getColor()))
|
||||
.append(new TranslatableComponent("configurationtool.configmode." + newAction.name().toLowerCase(Locale.ROOT))), true);
|
||||
|
@ -92,14 +97,12 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
@Override
|
||||
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
|
||||
super.addTooltipDetails(key, stack, tooltip, advanced);
|
||||
if (stack.hasTag()){
|
||||
ConfigurationAction linkingMode = ConfigurationAction.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
if (key == null){
|
||||
tooltip.add(new TranslatableComponent("configurationtool.configmode").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("configurationtool.configmode." + linkingMode.name().toLowerCase(Locale.ROOT) ).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
|
||||
tooltip.add(new TextComponent("").withStyle(ChatFormatting.GRAY));
|
||||
tooltip.add(new TranslatableComponent("configurationtool.use").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
ConfigurationAction linkingMode = getAction(stack);
|
||||
if (key == null) {
|
||||
tooltip.add(new TranslatableComponent("configurationtool.configmode").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("configurationtool.configmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
|
||||
tooltip.add(new TextComponent("").withStyle(ChatFormatting.GRAY));
|
||||
tooltip.add(new TranslatableComponent("configurationtool.use").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +111,7 @@ public class ConfigurationToolItem extends BasicItem {
|
|||
return key == null;
|
||||
}
|
||||
|
||||
public enum ConfigurationAction{
|
||||
public enum ConfigurationAction {
|
||||
LOCKING(TextColor.fromRgb(new Color(40, 131, 250).getRGB())),
|
||||
TOGGLE_NUMBERS(TextColor.fromRgb(new Color(250, 145, 40).getRGB())),
|
||||
TOGGLE_RENDER(TextColor.fromRgb(new Color(100, 250, 40).getRGB())),
|
||||
|
|
|
@ -9,11 +9,8 @@ import net.minecraft.core.BlockPos;
|
|||
import net.minecraft.core.NonNullList;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.Style;
|
||||
import net.minecraft.network.chat.TextColor;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.sounds.SoundEvent;
|
||||
import net.minecraft.network.chat.*;
|
||||
import net.minecraft.sounds.SoundEvents;
|
||||
import net.minecraft.world.InteractionHand;
|
||||
import net.minecraft.world.InteractionResult;
|
||||
|
@ -39,6 +36,20 @@ public class LinkingToolItem extends BasicItem {
|
|||
public static final String NBT_ACTION = "Action";
|
||||
public static final String NBT_FIRST = "First";
|
||||
|
||||
public static LinkingMode getLinkingMode(ItemStack stack) {
|
||||
if (stack.hasTag() && stack.getTag().contains(NBT_MODE)) {
|
||||
return LinkingMode.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
}
|
||||
return LinkingMode.SINGLE;
|
||||
}
|
||||
|
||||
public static ActionMode getActionMode(ItemStack stack) {
|
||||
if (stack.hasTag() && stack.getTag().contains(NBT_ACTION)) {
|
||||
return ActionMode.valueOf(stack.getOrCreateTag().getString(NBT_ACTION));
|
||||
}
|
||||
return ActionMode.ADD;
|
||||
}
|
||||
|
||||
public LinkingToolItem() {
|
||||
super(new Properties().tab(FunctionalStorage.TAB).stacksTo(1));
|
||||
}
|
||||
|
@ -49,7 +60,7 @@ public class LinkingToolItem extends BasicItem {
|
|||
initNbt(p_41447_);
|
||||
}
|
||||
|
||||
private ItemStack initNbt(ItemStack stack){
|
||||
private ItemStack initNbt(ItemStack stack) {
|
||||
stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.SINGLE.name());
|
||||
stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.ADD.name());
|
||||
return stack;
|
||||
|
@ -68,9 +79,9 @@ public class LinkingToolItem extends BasicItem {
|
|||
ItemStack stack = context.getItemInHand();
|
||||
Level level = context.getLevel();
|
||||
BlockEntity blockEntity = level.getBlockEntity(pos);
|
||||
LinkingMode linkingMode = LinkingMode.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
ActionMode linkingAction = ActionMode.valueOf(stack.getOrCreateTag().getString(NBT_ACTION));
|
||||
if (blockEntity instanceof DrawerControllerTile){
|
||||
LinkingMode linkingMode = getLinkingMode(stack);
|
||||
ActionMode linkingAction = getActionMode(stack);
|
||||
if (blockEntity instanceof DrawerControllerTile) {
|
||||
CompoundTag controller = new CompoundTag();
|
||||
controller.putInt("X", pos.getX());
|
||||
controller.putInt("Y", pos.getY());
|
||||
|
@ -79,19 +90,19 @@ public class LinkingToolItem extends BasicItem {
|
|||
context.getPlayer().playSound(SoundEvents.ITEM_FRAME_ADD_ITEM, 0.5f, 1);
|
||||
context.getPlayer().displayClientMessage(new TextComponent("Controller configured to the tool").withStyle(ChatFormatting.GREEN), true);
|
||||
return InteractionResult.SUCCESS;
|
||||
} else if (blockEntity instanceof ControllableDrawerTile && stack.getOrCreateTag().contains(NBT_CONTROLLER)){
|
||||
} else if (blockEntity instanceof ControllableDrawerTile && stack.getOrCreateTag().contains(NBT_CONTROLLER)) {
|
||||
CompoundTag controllerNBT = stack.getOrCreateTag().getCompound(NBT_CONTROLLER);
|
||||
BlockEntity controller = level.getBlockEntity(new BlockPos(controllerNBT.getInt("X"), controllerNBT.getInt("Y"), controllerNBT.getInt("Z")));
|
||||
if (controller instanceof DrawerControllerTile){
|
||||
if (linkingMode == LinkingMode.SINGLE){
|
||||
if (controller instanceof DrawerControllerTile) {
|
||||
if (linkingMode == LinkingMode.SINGLE) {
|
||||
((ControllableDrawerTile<?>) blockEntity).setControllerPos(controller.getBlockPos());
|
||||
((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, pos);
|
||||
context.getPlayer().displayClientMessage(new TextComponent("Linked drawer to the controller").setStyle(Style.EMPTY.withColor(linkingMode.color)), true);
|
||||
}else{
|
||||
if (stack.getOrCreateTag().contains(NBT_FIRST)){
|
||||
} else {
|
||||
if (stack.getOrCreateTag().contains(NBT_FIRST)) {
|
||||
CompoundTag firstpos = stack.getOrCreateTag().getCompound(NBT_FIRST);
|
||||
BlockPos firstPos = new BlockPos(firstpos.getInt("X"), firstpos.getInt("Y"), firstpos.getInt("Z"));
|
||||
AABB aabb = new AABB(Math.min(firstPos.getX(), pos.getX()),Math.min(firstPos.getY(), pos.getY()),Math.min(firstPos.getZ(), pos.getZ()), Math.max(firstPos.getX(), pos.getX()) + 1,Math.max(firstPos.getY(), pos.getY())+1,Math.max(firstPos.getZ(), pos.getZ())+1) ;
|
||||
AABB aabb = new AABB(Math.min(firstPos.getX(), pos.getX()), Math.min(firstPos.getY(), pos.getY()), Math.min(firstPos.getZ(), pos.getZ()), Math.max(firstPos.getX(), pos.getX()) + 1, Math.max(firstPos.getY(), pos.getY()) + 1, Math.max(firstPos.getZ(), pos.getZ()) + 1);
|
||||
((DrawerControllerTile) controller).addConnectedDrawers(linkingAction, getBlockPosInAABB(aabb).toArray(BlockPos[]::new));
|
||||
stack.getOrCreateTag().remove(NBT_FIRST);
|
||||
} else {
|
||||
|
@ -112,10 +123,10 @@ public class LinkingToolItem extends BasicItem {
|
|||
@Override
|
||||
public InteractionResultHolder<ItemStack> use(Level p_41432_, Player player, InteractionHand hand) {
|
||||
ItemStack stack = player.getItemInHand(hand);
|
||||
if (!stack.isEmpty() && stack.hasTag()){
|
||||
if (player.isShiftKeyDown()){
|
||||
LinkingMode linkingMode = LinkingMode.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
if (linkingMode == LinkingMode.SINGLE){
|
||||
if (!stack.isEmpty()) {
|
||||
if (player.isShiftKeyDown()) {
|
||||
LinkingMode linkingMode = getLinkingMode(stack);
|
||||
if (linkingMode == LinkingMode.SINGLE) {
|
||||
stack.getOrCreateTag().putString(NBT_MODE, LinkingMode.MULTIPLE.name());
|
||||
player.displayClientMessage(new TextComponent("Swapped mode to " + LinkingMode.MULTIPLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.MULTIPLE.getColor())), true);
|
||||
} else {
|
||||
|
@ -123,8 +134,8 @@ public class LinkingToolItem extends BasicItem {
|
|||
player.displayClientMessage(new TextComponent("Swapped mode to " + LinkingMode.SINGLE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(LinkingMode.SINGLE.getColor())), true);
|
||||
}
|
||||
} else {
|
||||
ActionMode linkingMode = ActionMode.valueOf(stack.getOrCreateTag().getString(NBT_ACTION));
|
||||
if (linkingMode == ActionMode.ADD){
|
||||
ActionMode linkingMode = getActionMode(stack);
|
||||
if (linkingMode == ActionMode.ADD) {
|
||||
stack.getOrCreateTag().putString(NBT_ACTION, ActionMode.REMOVE.name());
|
||||
player.displayClientMessage(new TextComponent("Swapped action to " + ActionMode.REMOVE.name().toLowerCase(Locale.ROOT)).setStyle(Style.EMPTY.withColor(ActionMode.REMOVE.getColor())), true);
|
||||
} else {
|
||||
|
@ -141,25 +152,22 @@ public class LinkingToolItem extends BasicItem {
|
|||
@Override
|
||||
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
|
||||
super.addTooltipDetails(key, stack, tooltip, advanced);
|
||||
if (stack.hasTag()){
|
||||
LinkingMode linkingMode = LinkingMode.valueOf(stack.getOrCreateTag().getString(NBT_MODE));
|
||||
ActionMode linkingAction = ActionMode.valueOf(stack.getOrCreateTag().getString(NBT_ACTION));
|
||||
if (key == null){
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingmode").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT) ).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingaction").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("linkingtool.linkingaction." + linkingAction.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingAction.getColor()))));
|
||||
if (stack.getOrCreateTag().contains(NBT_CONTROLLER)){
|
||||
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TextComponent(stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("X") +""+ ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Y") + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Z")).withStyle(ChatFormatting.DARK_AQUA)));
|
||||
} else {
|
||||
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW).append(new TextComponent("???").withStyle(ChatFormatting.DARK_AQUA)));
|
||||
}
|
||||
tooltip.add(new TextComponent(""));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT) + ".desc").withStyle(ChatFormatting.GRAY));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.use").withStyle(ChatFormatting.GRAY));
|
||||
|
||||
LinkingMode linkingMode = getLinkingMode(stack);
|
||||
ActionMode linkingAction = getActionMode(stack);
|
||||
if (key == null) {
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingmode").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingMode.getColor()))));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingaction").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TranslatableComponent("linkingtool.linkingaction." + linkingAction.name().toLowerCase(Locale.ROOT)).withStyle(Style.EMPTY.withColor(linkingAction.getColor()))));
|
||||
if (stack.getOrCreateTag().contains(NBT_CONTROLLER)) {
|
||||
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW)
|
||||
.append(new TextComponent(stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("X") + "" + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Y") + ChatFormatting.WHITE + ", " + ChatFormatting.DARK_AQUA + stack.getOrCreateTag().getCompound(NBT_CONTROLLER).getInt("Z")).withStyle(ChatFormatting.DARK_AQUA)));
|
||||
} else {
|
||||
tooltip.add(new TranslatableComponent("linkingtool.controller").withStyle(ChatFormatting.YELLOW).append(new TextComponent("???").withStyle(ChatFormatting.DARK_AQUA)));
|
||||
}
|
||||
tooltip.add(new TextComponent(""));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.linkingmode." + linkingMode.name().toLowerCase(Locale.ROOT) + ".desc").withStyle(ChatFormatting.GRAY));
|
||||
tooltip.add(new TranslatableComponent("linkingtool.use").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -180,7 +188,7 @@ public class LinkingToolItem extends BasicItem {
|
|||
return key == null;
|
||||
}
|
||||
|
||||
public enum LinkingMode{
|
||||
public enum LinkingMode {
|
||||
SINGLE(TextColor.fromRgb(Color.cyan.getRGB())),
|
||||
MULTIPLE(TextColor.fromRgb(Color.GREEN.getRGB()));
|
||||
|
||||
|
@ -195,7 +203,7 @@ public class LinkingToolItem extends BasicItem {
|
|||
}
|
||||
}
|
||||
|
||||
public enum ActionMode{
|
||||
public enum ActionMode {
|
||||
ADD(TextColor.fromRgb(new Color(40, 131, 250).getRGB())),
|
||||
REMOVE(TextColor.fromRgb(new Color(250, 145, 40).getRGB()));
|
||||
|
||||
|
|
|
@ -26,6 +26,17 @@ import java.util.Locale;
|
|||
|
||||
public class UpgradeItem extends BasicItem {
|
||||
|
||||
|
||||
public static Direction getDirection(ItemStack stack){
|
||||
if (stack.hasTag()){
|
||||
Item item = stack.getItem();
|
||||
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){
|
||||
return Direction.byName(stack.getOrCreateTag().getString("Direction"));
|
||||
}
|
||||
}
|
||||
return Direction.NORTH;
|
||||
}
|
||||
|
||||
private final Type type;
|
||||
|
||||
public UpgradeItem(Properties properties, Type type) {
|
||||
|
@ -61,10 +72,10 @@ public class UpgradeItem extends BasicItem {
|
|||
|
||||
@Override
|
||||
public boolean overrideOtherStackedOnMe(ItemStack first, ItemStack second, Slot p_150894_, ClickAction clickAction, Player p_150896_, SlotAccess p_150897_) {
|
||||
if (clickAction == ClickAction.SECONDARY && first.getCount() == 1 && first.hasTag()){
|
||||
if (clickAction == ClickAction.SECONDARY && first.getCount() == 1){
|
||||
Item item = first.getItem();
|
||||
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){
|
||||
Direction direction = Direction.byName(first.getOrCreateTag().getString("Direction"));
|
||||
Direction direction = getDirection(first);
|
||||
Direction next = Direction.values()[(Arrays.asList(Direction.values()).indexOf(direction) + 1 ) % Direction.values().length];
|
||||
first.getOrCreateTag().putString("Direction", next.name());
|
||||
p_150896_.playSound(SoundEvents.UI_BUTTON_CLICK, 0.5f, 1);
|
||||
|
@ -78,10 +89,9 @@ public class UpgradeItem extends BasicItem {
|
|||
public void addTooltipDetails(@Nullable BasicItem.Key key, ItemStack stack, List<Component> tooltip, boolean advanced) {
|
||||
super.addTooltipDetails(key, stack, tooltip, advanced);
|
||||
tooltip.add(new TranslatableComponent("upgrade.type").withStyle(ChatFormatting.YELLOW).append(new TranslatableComponent("upgrade.type." + getType().name().toLowerCase(Locale.ROOT)).withStyle(ChatFormatting.WHITE)));
|
||||
if (!stack.hasTag()) return;
|
||||
Item item = stack.getItem();
|
||||
if (item.equals(FunctionalStorage.PULLING_UPGRADE.get()) || item.equals(FunctionalStorage.PUSHING_UPGRADE.get()) || item.equals(FunctionalStorage.COLLECTOR_UPGRADE.get())){
|
||||
tooltip.add(new TranslatableComponent("item.utility.direction").withStyle(ChatFormatting.YELLOW).append(new TranslatableComponent(WordUtils.capitalize(stack.getTag().getString("Direction").toLowerCase(Locale.ROOT))).withStyle(ChatFormatting.WHITE)));
|
||||
tooltip.add(new TranslatableComponent("item.utility.direction").withStyle(ChatFormatting.YELLOW).append(new TranslatableComponent(WordUtils.capitalize(getDirection(stack).name().toLowerCase(Locale.ROOT))).withStyle(ChatFormatting.WHITE)));
|
||||
tooltip.add(new TextComponent(""));
|
||||
tooltip.add(new TranslatableComponent("item.utility.direction.desc").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user