mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Merge remote-tracking branch 'origin/mc1.20.1/dev' into mc1.21.1/dev
# Conflicts: # src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelBlock.java
This commit is contained in:
commit
6d464d61d7
6 changed files with 72 additions and 10 deletions
|
@ -145,16 +145,16 @@ public class FactoryPanelBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||||
if (blockState.is(this) && location != null && fpbe != null) {
|
if (blockState.is(this) && location != null && fpbe != null) {
|
||||||
if (!level.isClientSide()) {
|
if (!level.isClientSide()) {
|
||||||
PanelSlot targetedSlot = getTargetedSlot(pos, blockState, location);
|
PanelSlot targetedSlot = getTargetedSlot(pos, blockState, location);
|
||||||
UUID networkFromStack = LogisticallyLinkedBlockItem.networkFromStack(pContext.getItemInHand());
|
ItemStack panelItem = FactoryPanelBlockItem.fixCtrlCopiedStack(pContext.getItemInHand());
|
||||||
|
UUID networkFromStack = LogisticallyLinkedBlockItem.networkFromStack(panelItem);
|
||||||
Player pPlayer = pContext.getPlayer();
|
Player pPlayer = pContext.getPlayer();
|
||||||
|
|
||||||
if (fpbe.addPanel(targetedSlot, networkFromStack) && pPlayer != null) {
|
if (fpbe.addPanel(targetedSlot, networkFromStack) && pPlayer != null) {
|
||||||
pPlayer.displayClientMessage(CreateLang.translateDirect("logistically_linked.connected"), true);
|
pPlayer.displayClientMessage(CreateLang.translateDirect("logistically_linked.connected"), true);
|
||||||
|
|
||||||
if (!pPlayer.isCreative()) {
|
if (!pPlayer.isCreative()) {
|
||||||
ItemStack item = pContext.getItemInHand();
|
panelItem.shrink(1);
|
||||||
item.shrink(1);
|
if (panelItem.isEmpty())
|
||||||
if (item.isEmpty())
|
|
||||||
pPlayer.setItemInHand(pContext.getHand(), ItemStack.EMPTY);
|
pPlayer.setItemInHand(pContext.getHand(), ItemStack.EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -237,7 +237,7 @@ public class FactoryPanelBlock extends FaceAttachedHorizontalDirectionalBlock
|
||||||
|
|
||||||
PanelSlot newSlot = getTargetedSlot(pos, state, location);
|
PanelSlot newSlot = getTargetedSlot(pos, state, location);
|
||||||
withBlockEntityDo(level, pos, fpbe -> {
|
withBlockEntityDo(level, pos, fpbe -> {
|
||||||
if (!fpbe.addPanel(newSlot, LogisticallyLinkedBlockItem.networkFromStack(stack)))
|
if (!fpbe.addPanel(newSlot, LogisticallyLinkedBlockItem.networkFromStack(FactoryPanelBlockItem.fixCtrlCopiedStack(stack))))
|
||||||
return;
|
return;
|
||||||
player.displayClientMessage(CreateLang.translateDirect("logistically_linked.connected"), true);
|
player.displayClientMessage(CreateLang.translateDirect("logistically_linked.connected"), true);
|
||||||
level.playSound(null, pos, soundType.getPlaceSound(), SoundSource.BLOCKS);
|
level.playSound(null, pos, soundType.getPlaceSound(), SoundSource.BLOCKS);
|
||||||
|
|
|
@ -133,6 +133,7 @@ public class FactoryPanelBlockEntity extends SmartBlockEntity {
|
||||||
FactoryPanelBehaviour behaviour = panels.get(slot);
|
FactoryPanelBehaviour behaviour = panels.get(slot);
|
||||||
if (behaviour != null && !behaviour.isActive()) {
|
if (behaviour != null && !behaviour.isActive()) {
|
||||||
behaviour.enable();
|
behaviour.enable();
|
||||||
|
if (frequency != null)
|
||||||
behaviour.setNetwork(frequency);
|
behaviour.setNetwork(frequency);
|
||||||
redraw = true;
|
redraw = true;
|
||||||
lastShape = null;
|
lastShape = null;
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
package com.simibubi.create.content.logistics.factoryBoard;
|
package com.simibubi.create.content.logistics.factoryBoard;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.simibubi.create.AllSoundEvents;
|
import com.simibubi.create.AllSoundEvents;
|
||||||
|
import com.simibubi.create.content.logistics.factoryBoard.FactoryPanelBlock.PanelSlot;
|
||||||
import com.simibubi.create.content.logistics.packagerLink.LogisticallyLinkedBlockItem;
|
import com.simibubi.create.content.logistics.packagerLink.LogisticallyLinkedBlockItem;
|
||||||
|
import com.simibubi.create.foundation.block.IBE;
|
||||||
import com.simibubi.create.foundation.utility.CreateLang;
|
import com.simibubi.create.foundation.utility.CreateLang;
|
||||||
|
|
||||||
|
import net.minecraft.core.BlockPos;
|
||||||
|
import net.minecraft.core.component.DataComponents;
|
||||||
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.world.InteractionResult;
|
import net.minecraft.world.InteractionResult;
|
||||||
|
import net.minecraft.world.entity.player.Player;
|
||||||
|
import net.minecraft.world.item.BlockItem;
|
||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
|
import net.minecraft.world.item.component.CustomData;
|
||||||
import net.minecraft.world.item.context.BlockPlaceContext;
|
import net.minecraft.world.item.context.BlockPlaceContext;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
import net.minecraft.world.level.block.Block;
|
import net.minecraft.world.level.block.Block;
|
||||||
|
import net.minecraft.world.level.block.entity.BlockEntity;
|
||||||
|
import net.minecraft.world.level.block.state.BlockState;
|
||||||
|
|
||||||
public class FactoryPanelBlockItem extends LogisticallyLinkedBlockItem {
|
public class FactoryPanelBlockItem extends LogisticallyLinkedBlockItem {
|
||||||
|
|
||||||
|
@ -30,4 +43,32 @@ public class FactoryPanelBlockItem extends LogisticallyLinkedBlockItem {
|
||||||
return super.place(pContext);
|
return super.place(pContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean updateCustomBlockEntityTag(BlockPos pos, Level level, Player player, ItemStack stack,
|
||||||
|
BlockState state) {
|
||||||
|
return super.updateCustomBlockEntityTag(pos, level, player, fixCtrlCopiedStack(stack), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ItemStack fixCtrlCopiedStack(ItemStack stack) {
|
||||||
|
// Salvage frequency data from one of the panel slots
|
||||||
|
if (isTuned(stack) && networkFromStack(stack) == null) {
|
||||||
|
CompoundTag bet = stack.getOrDefault(DataComponents.BLOCK_ENTITY_DATA, CustomData.EMPTY).copyTag();
|
||||||
|
UUID frequency = UUID.randomUUID();
|
||||||
|
|
||||||
|
for (PanelSlot slot : PanelSlot.values()) {
|
||||||
|
CompoundTag panelTag = bet.getCompound(CreateLang.asId(slot.name()));
|
||||||
|
if (panelTag.hasUUID("Freq"))
|
||||||
|
frequency = panelTag.getUUID("Freq");
|
||||||
|
}
|
||||||
|
|
||||||
|
bet = new CompoundTag();
|
||||||
|
bet.putUUID("Freq", frequency);
|
||||||
|
|
||||||
|
BlockEntity.addEntityType(bet, ((IBE<?>) ((BlockItem) stack.getItem()).getBlock()).getBlockEntityType());
|
||||||
|
stack.set(DataComponents.BLOCK_ENTITY_DATA, CustomData.of(bet));
|
||||||
|
}
|
||||||
|
|
||||||
|
return stack;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ import com.simibubi.create.content.trains.station.NoShadowFontWrapper;
|
||||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||||
import com.simibubi.create.foundation.gui.ScreenWithStencils;
|
import com.simibubi.create.foundation.gui.ScreenWithStencils;
|
||||||
import com.simibubi.create.foundation.gui.menu.AbstractSimiContainerScreen;
|
import com.simibubi.create.foundation.gui.menu.AbstractSimiContainerScreen;
|
||||||
|
import com.simibubi.create.foundation.gui.widget.ScrollInput;
|
||||||
import com.simibubi.create.foundation.utility.CreateLang;
|
import com.simibubi.create.foundation.utility.CreateLang;
|
||||||
|
|
||||||
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
import dev.engine_room.flywheel.lib.model.baked.PartialModel;
|
||||||
|
@ -487,8 +488,11 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
|
||||||
|
|
||||||
// Render text input hints
|
// Render text input hints
|
||||||
if (addressBox.getValue()
|
if (addressBox.getValue()
|
||||||
.isBlank())
|
.isBlank() && !addressBox.isFocused()) {
|
||||||
graphics.drawString(font, addressBox.getMessage(), addressBox.getX(), addressBox.getY(), 0x88dddddd);
|
graphics.drawString(Minecraft.getInstance().font, CreateLang.translate("gui.stock_keeper.package_adress")
|
||||||
|
.style(ChatFormatting.ITALIC)
|
||||||
|
.component(), addressBox.getX(), addressBox.getY(), 0xff_CDBCA8, false);
|
||||||
|
}
|
||||||
|
|
||||||
// Render keeper
|
// Render keeper
|
||||||
int entitySizeOffset = 0;
|
int entitySizeOffset = 0;
|
||||||
|
@ -807,6 +811,19 @@ public class StockKeeperRequestScreen extends AbstractSimiContainerScreen<StockK
|
||||||
.component()),
|
.component()),
|
||||||
mouseX, mouseY);
|
mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Render tooltip of address input
|
||||||
|
if (addressBox.getValue()
|
||||||
|
.isBlank() && !addressBox.isFocused() && addressBox.isHovered()) {
|
||||||
|
graphics.renderComponentTooltip(font, List.of(CreateLang.translate("gui.factory_panel.restocker_address")
|
||||||
|
.color(ScrollInput.HEADER_RGB)
|
||||||
|
.component(),
|
||||||
|
CreateLang.translate("gui.schedule.lmb_edit")
|
||||||
|
.style(ChatFormatting.DARK_GRAY)
|
||||||
|
.style(ChatFormatting.ITALIC)
|
||||||
|
.component()),
|
||||||
|
mouseX, mouseY);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderItemEntry(GuiGraphics graphics, float scale, BigItemStack entry, boolean isStackHovered,
|
private void renderItemEntry(GuiGraphics graphics, float scale, BigItemStack entry, boolean isStackHovered,
|
||||||
|
|
|
@ -47,6 +47,9 @@ public class DestinationSuggestions extends CommandSuggestions {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateCommandInfo() {
|
public void updateCommandInfo() {
|
||||||
|
if (textBox.getValue().length() < textBox.getCursorPosition())
|
||||||
|
return;
|
||||||
|
|
||||||
String trimmed = textBox.getValue()
|
String trimmed = textBox.getValue()
|
||||||
.substring(0, textBox.getCursorPosition());
|
.substring(0, textBox.getCursorPosition());
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class AllCommands {
|
||||||
.then(CameraDistanceCommand.register())
|
.then(CameraDistanceCommand.register())
|
||||||
.then(CameraAngleCommand.register())
|
.then(CameraAngleCommand.register())
|
||||||
//.then(DebugValueCommand.register())
|
//.then(DebugValueCommand.register())
|
||||||
.then(KillTPSCommand.register())
|
//.then(KillTPSCommand.register())
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue