mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-11 12:32:05 +01:00
Even more porty
This commit is contained in:
parent
83c64121eb
commit
fe92f8fb41
45 changed files with 259 additions and 254 deletions
|
@ -126,7 +126,6 @@ import com.simibubi.create.content.logistics.block.redstone.RedstoneContactBlock
|
|||
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkBlock;
|
||||
import com.simibubi.create.content.logistics.block.redstone.RedstoneLinkGenerator;
|
||||
import com.simibubi.create.content.logistics.block.redstone.StockpileSwitchBlock;
|
||||
import com.simibubi.create.content.palettes.MetalBlock;
|
||||
import com.simibubi.create.content.schematics.block.SchematicTableBlock;
|
||||
import com.simibubi.create.content.schematics.block.SchematicannonBlock;
|
||||
import com.simibubi.create.foundation.config.StressConfigDefaults;
|
||||
|
|
|
@ -44,6 +44,7 @@ import net.minecraft.util.math.AxisAlignedBB;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.common.util.LazyOptional;
|
||||
|
@ -277,7 +278,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
|
||||
private void spawnAirFlow(float verticalStart, float verticalEnd, float motion, float drag) {
|
||||
AirParticleData airParticleData = new AirParticleData(drag, motion);
|
||||
Vector3d origin = new Vector3d(pos);
|
||||
Vector3d origin = Vector3d.of(pos);
|
||||
float xOff = Create.random.nextFloat() * .5f + .25f;
|
||||
float zOff = Create.random.nextFloat() * .5f + .25f;
|
||||
Vector3d v = origin.add(xOff, verticalStart, zOff);
|
||||
|
@ -324,7 +325,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
|
||||
BlockState stateBelow = world.getBlockState(pos.down());
|
||||
if (stateBelow.getBlock() instanceof FunnelBlock) {
|
||||
if (stateBelow.has(BrassFunnelBlock.POWERED) && stateBelow.get(BrassFunnelBlock.POWERED))
|
||||
if (stateBelow.method_28500(BrassFunnelBlock.POWERED).orElse(false))
|
||||
return false;
|
||||
if (stateBelow.get(BrassFunnelBlock.FACING) != Direction.UP)
|
||||
return false;
|
||||
|
@ -373,7 +374,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
private boolean handleUpwardOutput(boolean simulate) {
|
||||
BlockState stateAbove = world.getBlockState(pos.up());
|
||||
if (stateAbove.getBlock() instanceof FunnelBlock) {
|
||||
boolean powered = stateAbove.has(BrassFunnelBlock.POWERED) && stateAbove.get(BrassFunnelBlock.POWERED);
|
||||
boolean powered = stateAbove.method_28500(BrassFunnelBlock.POWERED).orElse(false);
|
||||
if (!powered && stateAbove.get(BrassFunnelBlock.FACING) == Direction.DOWN) {
|
||||
ItemStack remainder = FunnelBlock.tryInsert(world, pos.up(), item, simulate);
|
||||
if (remainder.isEmpty()) {
|
||||
|
@ -414,7 +415,7 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
return remainder.isEmpty();
|
||||
}
|
||||
|
||||
if (Block.hasSolidSide(stateAbove, world, pos.up(), Direction.DOWN))
|
||||
if (BlockHelper.hasBlockSolidSide(stateAbove, world, pos.up(), Direction.DOWN))
|
||||
return false;
|
||||
if (!inputChutes.isEmpty())
|
||||
return false;
|
||||
|
@ -630,10 +631,10 @@ public class ChuteTileEntity extends SmartTileEntity implements IHaveGoggleInfor
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||
tooltip.add(spacing + TextFormatting.GOLD + "Pull: " + TextFormatting.WHITE + pull);
|
||||
tooltip.add(spacing + TextFormatting.GOLD + "Push: " + TextFormatting.WHITE + push);
|
||||
tooltip.add(TextFormatting.YELLOW + "-> Item Motion: " + TextFormatting.WHITE + getItemMotion());
|
||||
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
|
||||
tooltip.add(ITextComponent.of(spacing + TextFormatting.GOLD + "Pull: " + TextFormatting.WHITE + pull));
|
||||
tooltip.add(ITextComponent.of(spacing + TextFormatting.GOLD + "Push: " + TextFormatting.WHITE + push));
|
||||
tooltip.add(ITextComponent.of(TextFormatting.YELLOW + "-> Item Motion: " + TextFormatting.WHITE + getItemMotion()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public class DepotBlock extends Block implements ITE<DepotTileEntity> {
|
|||
@Override
|
||||
public void onLanded(IBlockReader worldIn, Entity entityIn) {
|
||||
super.onLanded(worldIn, entityIn);
|
||||
if (!AllBlocks.DEPOT.has(worldIn.getBlockState(entityIn.getPosition())))
|
||||
if (!AllBlocks.DEPOT.has(worldIn.getBlockState(entityIn.getBlockPos())))
|
||||
return;
|
||||
if (!(entityIn instanceof ItemEntity))
|
||||
return;
|
||||
|
@ -121,7 +121,7 @@ public class DepotBlock extends Block implements ITE<DepotTileEntity> {
|
|||
return;
|
||||
ItemEntity itemEntity = (ItemEntity) entityIn;
|
||||
DirectBeltInputBehaviour inputBehaviour =
|
||||
TileEntityBehaviour.get(worldIn, entityIn.getPosition(), DirectBeltInputBehaviour.TYPE);
|
||||
TileEntityBehaviour.get(worldIn, entityIn.getBlockPos(), DirectBeltInputBehaviour.TYPE);
|
||||
if (inputBehaviour == null)
|
||||
return;
|
||||
ItemStack remainder = inputBehaviour.handleInsertion(itemEntity.getItem(), Direction.DOWN, false);
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.simibubi.create.foundation.utility.VecHelper;
|
|||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.ItemRenderer;
|
||||
import net.minecraft.client.renderer.Vector3f;
|
||||
import net.minecraft.client.renderer.model.ItemCameraTransforms.TransformType;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -20,6 +19,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.Direction.Axis;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.math.vector.Vector3f;
|
||||
|
||||
public class DepotRenderer extends SafeTileEntityRenderer<DepotTileEntity> {
|
||||
|
||||
|
|
|
@ -94,11 +94,6 @@ public class AdjustableRepeaterTileEntity extends SmartTileEntity {
|
|||
updateState(powered, powering, atMax, atMin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected void updateState(boolean powered, boolean powering, boolean atMax, boolean atMin) {
|
||||
if (!charging && powered)
|
||||
charging = true;
|
||||
|
|
|
@ -34,9 +34,9 @@ public class BeltFunnelGenerator extends SpecialBlockStateGen {
|
|||
public <T extends Block> ModelFile getModel(DataGenContext<Block, T> ctx, RegistrateBlockstateProvider prov,
|
||||
BlockState state) {
|
||||
boolean pushing = state.get(BeltFunnelBlock.PUSHING);
|
||||
boolean powered = state.has(BlockStateProperties.POWERED) && state.get(BeltFunnelBlock.POWERED);
|
||||
boolean powered = state.method_28500(BlockStateProperties.POWERED).orElse(false);
|
||||
String shapeName = state.get(BeltFunnelBlock.SHAPE)
|
||||
.getName();
|
||||
.getString();
|
||||
|
||||
String pushingSuffix = (pushing ? "push" : "pull") ;
|
||||
String poweredSuffix = powered ? "_powered" : "";
|
||||
|
|
|
@ -10,6 +10,7 @@ import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
|||
import com.simibubi.create.foundation.tileEntity.TileEntityBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.filtering.FilteringBehaviour;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.inventory.InvManipulationBehaviour;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -177,9 +178,9 @@ public abstract class FunnelBlock extends ProperDirectionalBlock implements ITE<
|
|||
|
||||
@Nullable
|
||||
public static Direction getFunnelFacing(BlockState state) {
|
||||
if (state.has(FACING))
|
||||
if (BlockHelper.hasBlockStateProperty(state, FACING))
|
||||
return state.get(FACING);
|
||||
if (state.has(BlockStateProperties.HORIZONTAL_FACING))
|
||||
if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.HORIZONTAL_FACING))
|
||||
return state.get(BlockStateProperties.HORIZONTAL_FACING);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import net.minecraft.entity.item.ItemEntity;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.ItemHandlerHelper;
|
||||
|
||||
|
@ -31,8 +31,8 @@ public class FunnelMovementBehaviour extends MovementBehaviour {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getActiveAreaOffset(MovementContext context) {
|
||||
return new Vec3d(FunnelBlock.getFunnelFacing(context.state)
|
||||
public Vector3d getActiveAreaOffset(MovementContext context) {
|
||||
return Vector3d.of(FunnelBlock.getFunnelFacing(context.state)
|
||||
.getDirectionVec()).scale(.65);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ public class FunnelTileEntity extends SmartTileEntity {
|
|||
BlockState state = getBlockState();
|
||||
if (!FunnelBlock.isFunnel(state))
|
||||
return Mode.INVALID;
|
||||
if (state.has(BlockStateProperties.POWERED) && state.get(BlockStateProperties.POWERED))
|
||||
if (state.method_28500(BlockStateProperties.POWERED).orElse(false))
|
||||
return Mode.PAUSED;
|
||||
if (FunnelBlock.getFunnelFacing(state) == Direction.UP && autoExtractor.hasInventory())
|
||||
return Mode.HOPPER;
|
||||
|
|
|
@ -88,7 +88,7 @@ public abstract class HorizontalInteractionFunnelBlock extends HorizontalBlock i
|
|||
BlockPos pos, BlockPos p_196271_6_) {
|
||||
if (!canStillInteract(state, world, pos)) {
|
||||
BlockState parentState = parent.getDefaultState();
|
||||
if (state.has(POWERED) && state.get(POWERED))
|
||||
if (state.method_28500(POWERED).orElse(false))
|
||||
parentState = parentState.with(POWERED, true);
|
||||
return parentState.with(FunnelBlock.FACING, state.get(HORIZONTAL_FACING));
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ import static com.simibubi.create.foundation.gui.AllGuiTextures.PLAYER_INVENTORY
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.logistics.packet.ConfigureFlexcratePacket;
|
||||
import com.simibubi.create.foundation.gui.AbstractSimiContainerScreen;
|
||||
|
@ -64,7 +65,7 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
int crateLeft = guiLeft + 100;
|
||||
int crateTop = guiTop;
|
||||
int invLeft = guiLeft + 50;
|
||||
|
@ -78,14 +79,13 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
|
|||
} else
|
||||
FLEXCRATE.draw(this, crateLeft, crateTop);
|
||||
|
||||
font.drawStringWithShadow(title, crateLeft - 3 + (FLEXCRATE.width - font.getStringWidth(title)) / 2,
|
||||
textRenderer.drawWithShadow(matrixStack, title, crateLeft - 3 + (FLEXCRATE.width - textRenderer.getStringWidth(title)) / 2,
|
||||
crateTop + 10, hFontColor);
|
||||
String itemCount = "" + te.itemCount;
|
||||
font.drawString(itemCount, guiLeft + 100 + 53 - font.getStringWidth(itemCount), crateTop + 107, fontColor);
|
||||
textRenderer.draw(matrixStack, itemCount, guiLeft + 100 + 53 - textRenderer.getStringWidth(itemCount), crateTop + 107, fontColor);
|
||||
|
||||
PLAYER_INVENTORY.draw(this, invLeft, invTop);
|
||||
font.drawString(playerInventory.getDisplayName()
|
||||
.getFormattedText(), invLeft + 7, invTop + 6, 0x666666);
|
||||
textRenderer.draw(matrixStack, playerInventory.getDisplayName(), invLeft + 7, invTop + 6, 0x666666);
|
||||
|
||||
for (int slot = 0; slot < (container.doubleCrate ? 32 : 16); slot++) {
|
||||
if (allowedItems.getState() > slot * 64)
|
||||
|
@ -111,8 +111,8 @@ public class AdjustableCrateScreen extends AbstractSimiContainerScreen<Adjustabl
|
|||
public void tick() {
|
||||
super.tick();
|
||||
|
||||
if (!AllBlocks.ADJUSTABLE_CRATE.has(minecraft.world.getBlockState(te.getPos())))
|
||||
minecraft.displayGuiScreen(null);
|
||||
if (!AllBlocks.ADJUSTABLE_CRATE.has(client.world.getBlockState(te.getPos())))
|
||||
client.displayGuiScreen(null);
|
||||
|
||||
if (lastModification >= 0)
|
||||
lastModification++;
|
||||
|
|
|
@ -338,7 +338,7 @@ public abstract class ArmInteractionPoint {
|
|||
FilteringBehaviour filtering = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE);
|
||||
InvManipulationBehaviour inserter = TileEntityBehaviour.get(world, pos, InvManipulationBehaviour.TYPE);
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.has(BlockStateProperties.POWERED) && state.get(BlockStateProperties.POWERED))
|
||||
if (state.method_28500(BlockStateProperties.POWERED).orElse(false))
|
||||
return stack;
|
||||
if (inserter == null)
|
||||
return stack;
|
||||
|
|
|
@ -63,10 +63,9 @@ public class ArmInteractionPointHandler {
|
|||
if (player != null) {
|
||||
String key = selected.mode == Mode.DEPOSIT ? "mechanical_arm.deposit_to" : "mechanical_arm.extract_from";
|
||||
TextFormatting colour = selected.mode == Mode.DEPOSIT ? TextFormatting.GOLD : TextFormatting.AQUA;
|
||||
String translatedBlock = new TranslationTextComponent(selected.state.getBlock()
|
||||
.getTranslationKey()).getFormattedText();
|
||||
player.sendStatusMessage(
|
||||
new StringTextComponent(colour + Lang.translate(key, TextFormatting.WHITE + translatedBlock + colour)),
|
||||
TranslationTextComponent translatedBlock = new TranslationTextComponent(selected.state.getBlock()
|
||||
.getTranslationKey());
|
||||
player.sendStatusMessage((Lang.translate(key, translatedBlock.formatted(TextFormatting.WHITE, colour)).formatted(colour)),
|
||||
true);
|
||||
}
|
||||
|
||||
|
@ -101,8 +100,7 @@ public class ArmInteractionPointHandler {
|
|||
}
|
||||
|
||||
if (removed > 0)
|
||||
Minecraft.getInstance().player.sendStatusMessage(new StringTextComponent(
|
||||
TextFormatting.RED + Lang.translate("mechanical_arm.points_outside_range", removed)), true);
|
||||
Minecraft.getInstance().player.sendStatusMessage(Lang.translate("mechanical_arm.points_outside_range", removed).formatted(TextFormatting.RED), true);
|
||||
|
||||
AllPackets.channel.sendToServer(new ArmPlacementPacket(currentSelection, pos));
|
||||
currentSelection.clear();
|
||||
|
|
|
@ -85,7 +85,7 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
super.addBehaviours(behaviours);
|
||||
|
||||
selectionMode = new ScrollOptionBehaviour<>(SelectionMode.class,
|
||||
selectionMode = new ScrollOptionBehaviour<SelectionMode>(SelectionMode.class,
|
||||
Lang.translate("logistics.when_multiple_outputs_available"), this, new SelectionModeValueBox());
|
||||
selectionMode.requiresWrench();
|
||||
behaviours.add(selectionMode);
|
||||
|
@ -137,7 +137,7 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
if (!(armInteractionPoint instanceof Jukebox))
|
||||
continue;
|
||||
BlockState state = world.getBlockState(armInteractionPoint.pos);
|
||||
if (state.has(JukeboxBlock.HAS_RECORD) && state.get(JukeboxBlock.HAS_RECORD))
|
||||
if (state.method_28500(JukeboxBlock.HAS_RECORD).orElse(false))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -173,7 +173,7 @@ public class ArmTileEntity extends KineticTileEntity {
|
|||
|
||||
protected boolean isOnCeiling() {
|
||||
BlockState state = getBlockState();
|
||||
return hasWorld() && state != null && state.has(ArmBlock.CEILING) && state.get(ArmBlock.CEILING);
|
||||
return hasWorld() && state.method_28500(ArmBlock.CEILING).orElse(false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.simibubi.create.foundation.utility.Lang;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggleInformation {
|
||||
|
||||
|
@ -57,11 +58,6 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
|
|||
public void addBehaviours(List<TileEntityBehaviour> behaviours) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFastRenderer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void changeState(boolean back) {
|
||||
int prevState = state;
|
||||
state += back ? -1 : 1;
|
||||
|
@ -72,8 +68,8 @@ public class AnalogLeverTileEntity extends SmartTileEntity implements IHaveGoggl
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean addToGoggleTooltip(List<String> tooltip, boolean isPlayerSneaking) {
|
||||
tooltip.add(spacing + Lang.translate("tooltip.analogStrength", this.state));
|
||||
public boolean addToGoggleTooltip(List<ITextComponent> tooltip, boolean isPlayerSneaking) {
|
||||
tooltip.add(ITextComponent.of(spacing).copy().append(Lang.translate("tooltip.analogStrength", this.state)));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.renderer.IRenderTypeBuffer;
|
||||
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
|
||||
import net.minecraft.util.text.Style;
|
||||
|
||||
public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntity> {
|
||||
|
||||
|
@ -53,7 +54,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
|
|||
|
||||
private void drawTube(MatrixStack ms, IRenderTypeBuffer buffer, char c, float height) {
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
float charWidth = fontRenderer.getCharWidth(c);
|
||||
float charWidth = getCharWidth(c, fontRenderer);
|
||||
float shadowOffset = .5f;
|
||||
float flicker = r.nextFloat();
|
||||
int brightColor = 0xFF982B;
|
||||
|
@ -86,4 +87,7 @@ public class NixieTubeRenderer extends SafeTileEntityRenderer<NixieTubeTileEntit
|
|||
.getModel(), buffer, false, 0, 15728880);
|
||||
}
|
||||
|
||||
private static float getCharWidth(char p_211125_1_, FontRenderer fontRenderer) {
|
||||
return p_211125_1_ == 167 ? 0.0F : fontRenderer.getFontStorage(Style.DEFAULT_FONT_ID).getGlyph(p_211125_1_).getAdvance(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.simibubi.create.content.logistics.block.redstone;
|
|||
|
||||
import com.simibubi.create.foundation.tileEntity.SyncedTileEntity;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
|
||||
|
@ -32,10 +33,10 @@ public class NixieTubeTileEntity extends SyncedTileEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void read(CompoundNBT nbt) {
|
||||
public void fromTag(BlockState state, CompoundNBT nbt) {
|
||||
tube1 = (char) nbt.getInt("tube1");
|
||||
tube2 = (char) nbt.getInt("tube2");
|
||||
super.read(nbt);
|
||||
super.fromTag(state, nbt);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.simibubi.create.content.contraptions.wrench.IWrenchable;
|
|||
import com.simibubi.create.content.logistics.block.funnel.FunnelBlock;
|
||||
import com.simibubi.create.foundation.block.ITE;
|
||||
import com.simibubi.create.foundation.block.ProperDirectionalBlock;
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import com.simibubi.create.foundation.utility.Iterate;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
|
@ -167,7 +168,7 @@ public class RedstoneLinkBlock extends ProperDirectionalBlock implements ITE<Red
|
|||
BlockState neighbour = worldIn.getBlockState(neighbourPos);
|
||||
if (FunnelBlock.isFunnel(neighbour))
|
||||
return true;
|
||||
return Block.hasSolidSide(neighbour, worldIn, neighbourPos, state.get(FACING));
|
||||
return BlockHelper.hasBlockSolidSide(neighbour, worldIn, neighbourPos, state.get(FACING));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -113,8 +113,8 @@ public class RedstoneLinkTileEntity extends SmartTileEntity {
|
|||
if (receivedSignalChanged) {
|
||||
Direction attachedFace = blockState.get(RedstoneLinkBlock.FACING).getOpposite();
|
||||
BlockPos attachedPos = pos.offset(attachedFace);
|
||||
world.notifyNeighbors(pos, world.getBlockState(pos).getBlock());
|
||||
world.notifyNeighbors(attachedPos, world.getBlockState(attachedPos).getBlock());
|
||||
world.updateNeighbors(pos, world.getBlockState(pos).getBlock());
|
||||
world.updateNeighbors(attachedPos, world.getBlockState(attachedPos).getBlock());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import static com.simibubi.create.foundation.gui.AllGuiTextures.STOCKSWITCH;
|
|||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.AllBlocks;
|
||||
import com.simibubi.create.content.logistics.packet.ConfigureStockswitchPacket;
|
||||
|
@ -16,6 +17,8 @@ import com.simibubi.create.foundation.networking.AllPackets;
|
|||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class StockpileSwitchScreen extends AbstractSimiScreen {
|
||||
|
||||
|
@ -24,13 +27,13 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
|
|||
private ScrollInput onAbove;
|
||||
private Label onAboveLabel;
|
||||
|
||||
private final String title = Lang.translate("gui.stockpile_switch.title");
|
||||
private final String startAbove = Lang.translate("gui.stockpile_switch.startAbove");
|
||||
private final String startAt = Lang.translate("gui.stockpile_switch.startAt");
|
||||
private final String stopBelow = Lang.translate("gui.stockpile_switch.stopBelow");
|
||||
private final String stopAt = Lang.translate("gui.stockpile_switch.stopAt");
|
||||
private final String lowerLimit = Lang.translate("gui.stockpile_switch.lowerLimit");
|
||||
private final String upperLimit = Lang.translate("gui.stockpile_switch.upperLimit");
|
||||
private final IFormattableTextComponent title = Lang.translate("gui.stockpile_switch.title");
|
||||
private final IFormattableTextComponent startAbove = Lang.translate("gui.stockpile_switch.startAbove");
|
||||
private final IFormattableTextComponent startAt = Lang.translate("gui.stockpile_switch.startAt");
|
||||
private final IFormattableTextComponent stopBelow = Lang.translate("gui.stockpile_switch.stopBelow");
|
||||
private final IFormattableTextComponent stopAt = Lang.translate("gui.stockpile_switch.stopAt");
|
||||
private final IFormattableTextComponent lowerLimit = Lang.translate("gui.stockpile_switch.lowerLimit");
|
||||
private final IFormattableTextComponent upperLimit = Lang.translate("gui.stockpile_switch.upperLimit");
|
||||
private final ItemStack renderedItem = new ItemStack(AllBlocks.STOCKPILE_SWITCH.get());
|
||||
|
||||
private int lastModification;
|
||||
|
@ -83,26 +86,26 @@ public class StockpileSwitchScreen extends AbstractSimiScreen {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderWindow(int mouseX, int mouseY, float partialTicks) {
|
||||
protected void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
int hFontColor = 0xD3CBBE;
|
||||
int fontColor = 0x4B3A22;
|
||||
STOCKSWITCH.draw(this, guiLeft, guiTop);
|
||||
textRenderer.drawWithShadow(title, guiLeft - 3 + (STOCKSWITCH.width - textRenderer.getStringWidth(title)) / 2,
|
||||
textRenderer.drawWithShadow(matrixStack, title, guiLeft - 3 + (STOCKSWITCH.width - textRenderer.getWidth(title)) / 2,
|
||||
guiTop + 10, hFontColor);
|
||||
textRenderer.draw(onAbove.getState() == 100 ? startAt : startAbove, guiLeft + 13, guiTop + 55, fontColor);
|
||||
textRenderer.draw(offBelow.getState() == 0 ? stopAt : stopBelow, guiLeft + 13, guiTop + 72, fontColor);
|
||||
textRenderer.draw(matrixStack, onAbove.getState() == 100 ? startAt : startAbove, guiLeft + 13, guiTop + 55, fontColor);
|
||||
textRenderer.draw(matrixStack, offBelow.getState() == 0 ? stopAt : stopBelow, guiLeft + 13, guiTop + 72, fontColor);
|
||||
|
||||
AllGuiTextures sprite = AllGuiTextures.STOCKSWITCH_INTERVAL;
|
||||
float lowerBound = offBelow.getState() / 100f * (sprite.width - 20) + 10;
|
||||
float upperBound = onAbove.getState() / 100f * (sprite.width - 20) + 10;
|
||||
|
||||
sprite.bind();
|
||||
drawTexture((int) (guiLeft + lowerBound), guiTop + 26, (int) (sprite.startX + lowerBound), sprite.startY,
|
||||
drawTexture(matrixStack, (int) (guiLeft + lowerBound), guiTop + 26, (int) (sprite.startX + lowerBound), sprite.startY,
|
||||
(int) (upperBound - lowerBound), sprite.height);
|
||||
|
||||
sprite = AllGuiTextures.STOCKSWITCH_INTERVAL_END;
|
||||
sprite.bind();
|
||||
drawTexture((int) (guiLeft + upperBound), guiTop + 26, (int) (sprite.startX + upperBound), sprite.startY,
|
||||
drawTexture(matrixStack, (int) (guiLeft + upperBound), guiTop + 26, (int) (sprite.startX + upperBound), sprite.startY,
|
||||
(int) (sprite.width - upperBound), sprite.height);
|
||||
|
||||
AllGuiTextures.STOCKSWITCH_BOUND_LEFT.draw(this, (int) (guiLeft + lowerBound) - 1, guiTop + 24);
|
||||
|
|
|
@ -65,7 +65,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity {
|
|||
world.setBlockState(pos, getBlockState().with(StockpileSwitchBlock.INDICATOR, 0), 3);
|
||||
currentLevel = -1;
|
||||
powered = false;
|
||||
world.notifyNeighbors(pos, getBlockState().getBlock());
|
||||
world.updateNeighbors(pos, getBlockState().getBlock());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class StockpileSwitchTileEntity extends SmartTileEntity {
|
|||
displayLevel = (int) (currentLevel * 6);
|
||||
world.setBlockState(pos, getBlockState().with(StockpileSwitchBlock.INDICATOR, displayLevel), update ? 3 : 2);
|
||||
if (update)
|
||||
world.notifyNeighbors(pos, getBlockState().getBlock());
|
||||
world.updateNeighbors(pos, getBlockState().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -101,7 +101,7 @@ public class CardboardBoxItem extends Item {
|
|||
|
||||
if (compoundnbt.contains("Address", Constants.NBT.TAG_STRING)) {
|
||||
tooltip.add(new StringTextComponent("-> " + compoundnbt.getString("Address"))
|
||||
.applyTextStyle(TextFormatting.GOLD));
|
||||
.formatted(TextFormatting.GOLD));
|
||||
}
|
||||
|
||||
if (!compoundnbt.contains("Items", Constants.NBT.TAG_LIST))
|
||||
|
@ -117,16 +117,15 @@ public class CardboardBoxItem extends Item {
|
|||
++j;
|
||||
if (i <= 4) {
|
||||
++i;
|
||||
ITextComponent itextcomponent = itemstack.getDisplayName().deepCopy();
|
||||
itextcomponent.appendText(" x").appendText(String.valueOf(itemstack.getCount()))
|
||||
.applyTextStyle(TextFormatting.GRAY);
|
||||
tooltip.add(itextcomponent);
|
||||
ITextComponent itextcomponent = itemstack.getDisplayName();
|
||||
tooltip.add(itextcomponent.copy().append(" x").append(String.valueOf(itemstack.getCount()))
|
||||
.formatted(TextFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
if (j - i > 0) {
|
||||
tooltip.add((new TranslationTextComponent("container.shulkerBox.more", j - i))
|
||||
.applyTextStyle(TextFormatting.ITALIC));
|
||||
.formatted(TextFormatting.ITALIC));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,6 @@ import com.simibubi.create.foundation.gui.GuiGameElement;
|
|||
import com.simibubi.create.foundation.gui.widgets.IconButton;
|
||||
import com.simibubi.create.foundation.gui.widgets.Indicator;
|
||||
import com.simibubi.create.foundation.gui.widgets.Indicator.State;
|
||||
import com.simibubi.create.foundation.item.ItemDescription;
|
||||
import com.simibubi.create.foundation.item.ItemDescription.Palette;
|
||||
import com.simibubi.create.foundation.item.TooltipHelper;
|
||||
import com.simibubi.create.foundation.networking.AllPackets;
|
||||
|
@ -23,6 +22,7 @@ import com.simibubi.create.foundation.networking.AllPackets;
|
|||
import net.minecraft.client.gui.widget.Widget;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> extends AbstractSimiContainerScreen<F> {
|
||||
|
@ -106,12 +106,12 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
|
|||
for (IconButton button : tooltipButtons) {
|
||||
if (!button.getToolTip().isEmpty()) {
|
||||
button.setToolTip(button.getToolTip().get(0));
|
||||
button.getToolTip().add(ITextComponent.of(TooltipHelper.holdShift(Palette.Yellow, hasShiftDown())));
|
||||
button.getToolTip().add(TooltipHelper.holdShift(Palette.Yellow, hasShiftDown()));
|
||||
}
|
||||
}
|
||||
|
||||
if (hasShiftDown()) {
|
||||
List<String> tooltipDescriptions = getTooltipDescriptions();
|
||||
List<IFormattableTextComponent> tooltipDescriptions = getTooltipDescriptions();
|
||||
for (int i = 0; i < tooltipButtons.size(); i++)
|
||||
fillToolTip(tooltipButtons.get(i), tooltipDescriptions.get(i));
|
||||
}
|
||||
|
@ -121,11 +121,11 @@ public abstract class AbstractFilterScreen<F extends AbstractFilterContainer> ex
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
protected List<String> getTooltipDescriptions() {
|
||||
protected List<IFormattableTextComponent> getTooltipDescriptions() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private void fillToolTip(IconButton button, String tooltip) {
|
||||
private void fillToolTip(IconButton button, ITextComponent tooltip) {
|
||||
if (!button.isHovered())
|
||||
return;
|
||||
List<ITextComponent> tip = button.getToolTip();
|
||||
|
|
|
@ -51,7 +51,7 @@ public class AttributeFilterContainer extends AbstractFilterContainer {
|
|||
super.init();
|
||||
ItemStack stack = new ItemStack(Items.NAME_TAG);
|
||||
stack.setDisplayName(
|
||||
new StringTextComponent("Selected Tags").applyTextStyles(TextFormatting.RESET, TextFormatting.BLUE));
|
||||
new StringTextComponent("Selected Tags").formatted(TextFormatting.RESET, TextFormatting.BLUE));
|
||||
filterInventory.setStackInSlot(1, stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@ package com.simibubi.create.content.logistics.item.filter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.simibubi.create.content.logistics.item.filter.AttributeFilterContainer.WhitelistMode;
|
||||
import com.simibubi.create.content.logistics.item.filter.FilterScreenPacket.Option;
|
||||
import com.simibubi.create.foundation.gui.AllGuiTextures;
|
||||
|
@ -20,7 +21,9 @@ import com.simibubi.create.foundation.utility.Lang;
|
|||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterContainer> {
|
||||
|
@ -31,20 +34,20 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
private Indicator whitelistDisIndicator, whitelistConIndicator, blacklistIndicator;
|
||||
private IconButton add;
|
||||
|
||||
private String whitelistDisN = Lang.translate(PREFIX + "whitelist_disjunctive");
|
||||
private String whitelistDisDESC = Lang.translate(PREFIX + "whitelist_disjunctive.description");
|
||||
private String whitelistConN = Lang.translate(PREFIX + "whitelist_conjunctive");
|
||||
private String whitelistConDESC = Lang.translate(PREFIX + "whitelist_conjunctive.description");
|
||||
private String blacklistN = Lang.translate(PREFIX + "blacklist");
|
||||
private String blacklistDESC = Lang.translate(PREFIX + "blacklist.description");
|
||||
private ITextComponent whitelistDisN = Lang.translate(PREFIX + "whitelist_disjunctive");
|
||||
private ITextComponent whitelistDisDESC = Lang.translate(PREFIX + "whitelist_disjunctive.description");
|
||||
private ITextComponent whitelistConN = Lang.translate(PREFIX + "whitelist_conjunctive");
|
||||
private ITextComponent whitelistConDESC = Lang.translate(PREFIX + "whitelist_conjunctive.description");
|
||||
private ITextComponent blacklistN = Lang.translate(PREFIX + "blacklist");
|
||||
private ITextComponent blacklistDESC = Lang.translate(PREFIX + "blacklist.description");
|
||||
|
||||
private String referenceH = Lang.translate(PREFIX + "add_reference_item");
|
||||
private String noSelectedT = Lang.translate(PREFIX + "no_selected_attributes");
|
||||
private String selectedT = Lang.translate(PREFIX + "selected_attributes");
|
||||
private ITextComponent referenceH = Lang.translate(PREFIX + "add_reference_item");
|
||||
private ITextComponent noSelectedT = Lang.translate(PREFIX + "no_selected_attributes");
|
||||
private ITextComponent selectedT = Lang.translate(PREFIX + "selected_attributes");
|
||||
|
||||
private ItemStack lastItemScanned = ItemStack.EMPTY;
|
||||
private List<ItemAttribute> attributesOfItem = new ArrayList<>();
|
||||
private List<String> selectedAttributes = new ArrayList<>();
|
||||
private List<ITextComponent> selectedAttributes = new ArrayList<>();
|
||||
private SelectionScrollInput attributeSelector;
|
||||
private Label attributeSelectorLabel;
|
||||
|
||||
|
@ -78,7 +81,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
|
||||
attributeSelectorLabel = new Label(x + 40, y + 27, "").colored(0xF3EBDE).withShadow();
|
||||
attributeSelector = new SelectionScrollInput(x + 37, y + 24, 118, 14);
|
||||
attributeSelector.forOptions(Arrays.asList(""));
|
||||
attributeSelector.forOptions(Collections.singletonList(StringTextComponent.EMPTY));
|
||||
attributeSelector.calling(s -> {
|
||||
});
|
||||
referenceItemChanged(container.filterInventory.getStackInSlot(0));
|
||||
|
@ -88,8 +91,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
|
||||
selectedAttributes.clear();
|
||||
selectedAttributes
|
||||
.add(TextFormatting.YELLOW + (container.selectedAttributes.isEmpty() ? noSelectedT : selectedT));
|
||||
container.selectedAttributes.forEach(at -> selectedAttributes.add(TextFormatting.GRAY + "- " + at.format()));
|
||||
.add((container.selectedAttributes.isEmpty() ? noSelectedT : selectedT).copy().formatted(TextFormatting.YELLOW));
|
||||
container.selectedAttributes.forEach(at -> selectedAttributes.add(new StringTextComponent("- ").append(at.format()).formatted(TextFormatting.GRAY)));
|
||||
|
||||
}
|
||||
|
||||
|
@ -99,7 +102,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
if (stack.isEmpty()) {
|
||||
attributeSelector.active = false;
|
||||
attributeSelector.visible = false;
|
||||
attributeSelectorLabel.text = TextFormatting.ITALIC + referenceH;
|
||||
attributeSelectorLabel.text = referenceH.copy().formatted(TextFormatting.ITALIC);
|
||||
add.active = false;
|
||||
attributeSelector.calling(s -> {
|
||||
});
|
||||
|
@ -107,11 +110,11 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
}
|
||||
|
||||
add.active = true;
|
||||
attributeSelector.titled(stack.getDisplayName().getFormattedText() + "...");
|
||||
attributeSelector.titled(stack.getDisplayName().copy().append("..."));
|
||||
attributesOfItem.clear();
|
||||
for (ItemAttribute itemAttribute : ItemAttribute.types)
|
||||
attributesOfItem.addAll(itemAttribute.listAttributesOf(stack, this.minecraft.world));
|
||||
List<String> options = attributesOfItem.stream().map(ItemAttribute::format).collect(Collectors.toList());
|
||||
attributesOfItem.addAll(itemAttribute.listAttributesOf(stack, this.client.world));
|
||||
List<ITextComponent> options = attributesOfItem.stream().map(ItemAttribute::format).collect(Collectors.toList());
|
||||
attributeSelector.forOptions(options);
|
||||
attributeSelector.active = true;
|
||||
attributeSelector.visible = true;
|
||||
|
@ -135,19 +138,19 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
}
|
||||
|
||||
@Override
|
||||
public void renderWindowForeground(int mouseX, int mouseY, float partialTicks) {
|
||||
public void renderWindowForeground(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
ItemStack stack = container.filterInventory.getStackInSlot(1);
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(0.0F, 0.0F, 32.0F);
|
||||
this.setBlitOffset(200);
|
||||
matrixStack.push();
|
||||
matrixStack.translate(0.0F, 0.0F, 32.0F);
|
||||
this.setZOffset(200);
|
||||
this.itemRenderer.zLevel = 200.0F;
|
||||
this.itemRenderer.renderItemOverlayIntoGUI(font, stack, guiLeft + 59, guiTop + 56,
|
||||
this.itemRenderer.renderItemOverlayIntoGUI(textRenderer, stack, guiLeft + 59, guiTop + 56,
|
||||
String.valueOf(selectedAttributes.size() - 1));
|
||||
this.setBlitOffset(0);
|
||||
this.setZOffset(0);
|
||||
this.itemRenderer.zLevel = 0.0F;
|
||||
RenderSystem.popMatrix();
|
||||
matrixStack.pop();
|
||||
|
||||
super.renderWindowForeground(mouseX, mouseY, partialTicks);
|
||||
super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,16 +162,16 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void renderHoveredToolTip(int mouseX, int mouseY) {
|
||||
if (this.minecraft.player.inventory.getItemStack().isEmpty() && this.hoveredSlot != null
|
||||
protected void drawMouseoverTooltip(MatrixStack matrixStack, int mouseX, int mouseY) {
|
||||
if (this.client.player.inventory.getItemStack().isEmpty() && this.hoveredSlot != null
|
||||
&& this.hoveredSlot.getHasStack()) {
|
||||
if (this.hoveredSlot.slotNumber == 37) {
|
||||
renderTooltip(selectedAttributes, mouseX, mouseY, font);
|
||||
renderTooltip(matrixStack, selectedAttributes, mouseX, mouseY);
|
||||
return;
|
||||
}
|
||||
this.renderTooltip(this.hoveredSlot.getStack(), mouseX, mouseY);
|
||||
this.renderTooltip(matrixStack, this.hoveredSlot.getStack(), mouseX, mouseY);
|
||||
}
|
||||
super.renderHoveredToolTip(mouseX, mouseY);
|
||||
super.drawMouseoverTooltip(matrixStack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -177,8 +180,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTooltipDescriptions() {
|
||||
return Arrays.asList(blacklistDESC, whitelistConDESC, whitelistDisDESC);
|
||||
protected List<IFormattableTextComponent> getTooltipDescriptions() {
|
||||
return Arrays.asList(blacklistDESC.copy(), whitelistConDESC.copy(), whitelistDisDESC.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -216,8 +219,8 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
AllPackets.channel.sendToServer(new FilterScreenPacket(Option.ADD_TAG, tag));
|
||||
container.selectedAttributes.add(itemAttribute);
|
||||
if (container.selectedAttributes.size() == 1)
|
||||
selectedAttributes.set(0, TextFormatting.YELLOW + selectedT);
|
||||
selectedAttributes.add(TextFormatting.GRAY + "- " + itemAttribute.format());
|
||||
selectedAttributes.set(0, selectedT.copy().formatted(TextFormatting.YELLOW));
|
||||
selectedAttributes.add(new StringTextComponent("- ").append(itemAttribute.format()).formatted(TextFormatting.GRAY));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -228,7 +231,7 @@ public class AttributeFilterScreen extends AbstractFilterScreen<AttributeFilterC
|
|||
@Override
|
||||
protected void contentsCleared() {
|
||||
selectedAttributes.clear();
|
||||
selectedAttributes.add(TextFormatting.YELLOW + noSelectedT);
|
||||
selectedAttributes.add(noSelectedT.copy().formatted(TextFormatting.YELLOW));
|
||||
if (!lastItemScanned.isEmpty())
|
||||
add.active = true;
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ public class FilterItem extends Item implements INamedContainerProvider {
|
|||
@OnlyIn(Dist.CLIENT)
|
||||
public void addInformation(ItemStack stack, World worldIn, List<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
if (!AllKeys.shiftDown()) {
|
||||
List<String> makeSummary = makeSummary(stack);
|
||||
List<ITextComponent> makeSummary = makeSummary(stack);
|
||||
if (makeSummary.isEmpty())
|
||||
return;
|
||||
ItemDescription.add(tooltip, " ");
|
||||
|
@ -79,28 +79,26 @@ public class FilterItem extends Item implements INamedContainerProvider {
|
|||
}
|
||||
}
|
||||
|
||||
private List<String> makeSummary(ItemStack filter) {
|
||||
List<String> list = new ArrayList<>();
|
||||
private List<ITextComponent> makeSummary(ItemStack filter) {
|
||||
List<ITextComponent> list = new ArrayList<>();
|
||||
|
||||
if (type == FilterType.REGULAR) {
|
||||
ItemStackHandler filterItems = getFilterItems(filter);
|
||||
boolean blacklist = filter.getOrCreateTag()
|
||||
.getBoolean("Blacklist");
|
||||
|
||||
list.add(TextFormatting.GOLD
|
||||
+ (blacklist ? Lang.translate("gui.filter.blacklist") : Lang.translate("gui.filter.whitelist")));
|
||||
list.add((blacklist ? Lang.translate("gui.filter.blacklist") : Lang.translate("gui.filter.whitelist")).formatted(TextFormatting.GOLD));
|
||||
int count = 0;
|
||||
for (int i = 0; i < filterItems.getSlots(); i++) {
|
||||
if (count > 3) {
|
||||
list.add(TextFormatting.DARK_GRAY + "- ...");
|
||||
list.add(new StringTextComponent("- ...").formatted(TextFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
|
||||
ItemStack filterStack = filterItems.getStackInSlot(i);
|
||||
if (filterStack.isEmpty())
|
||||
continue;
|
||||
list.add(TextFormatting.GRAY + "- " + filterStack.getDisplayName()
|
||||
.getFormattedText());
|
||||
list.add(new StringTextComponent("- ").append(filterStack.getDisplayName()).formatted(TextFormatting.GRAY));
|
||||
count++;
|
||||
}
|
||||
|
||||
|
@ -111,11 +109,11 @@ public class FilterItem extends Item implements INamedContainerProvider {
|
|||
if (type == FilterType.ATTRIBUTE) {
|
||||
WhitelistMode whitelistMode = WhitelistMode.values()[filter.getOrCreateTag()
|
||||
.getInt("WhitelistMode")];
|
||||
list.add(TextFormatting.GOLD + (whitelistMode == WhitelistMode.WHITELIST_CONJ
|
||||
list.add((whitelistMode == WhitelistMode.WHITELIST_CONJ
|
||||
? Lang.translate("gui.attribute_filter.whitelist_conjunctive")
|
||||
: whitelistMode == WhitelistMode.WHITELIST_DISJ
|
||||
? Lang.translate("gui.attribute_filter.whitelist_disjunctive")
|
||||
: Lang.translate("gui.attribute_filter.blacklist")));
|
||||
: Lang.translate("gui.attribute_filter.blacklist")).formatted(TextFormatting.GOLD));
|
||||
|
||||
int count = 0;
|
||||
ListNBT attributes = filter.getOrCreateTag()
|
||||
|
@ -123,10 +121,10 @@ public class FilterItem extends Item implements INamedContainerProvider {
|
|||
for (INBT inbt : attributes) {
|
||||
ItemAttribute attribute = ItemAttribute.fromNBT((CompoundNBT) inbt);
|
||||
if (count > 3) {
|
||||
list.add(TextFormatting.DARK_GRAY + "- ...");
|
||||
list.add(new StringTextComponent("- ...").formatted(TextFormatting.DARK_GRAY));
|
||||
break;
|
||||
}
|
||||
list.add(TextFormatting.GRAY + "- " + attribute.format());
|
||||
list.add(new StringTextComponent("- ").append(attribute.format()));
|
||||
count++;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,21 +11,22 @@ import com.simibubi.create.foundation.gui.widgets.Indicator;
|
|||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.entity.player.PlayerInventory;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
|
||||
|
||||
private static final String PREFIX = "gui.filter.";
|
||||
|
||||
private String whitelistN = Lang.translate(PREFIX + "whitelist");
|
||||
private String whitelistDESC = Lang.translate(PREFIX + "whitelist.description");
|
||||
private String blacklistN = Lang.translate(PREFIX + "blacklist");
|
||||
private String blacklistDESC = Lang.translate(PREFIX + "blacklist.description");
|
||||
private ITextComponent whitelistN = Lang.translate(PREFIX + "whitelist");
|
||||
private ITextComponent whitelistDESC = Lang.translate(PREFIX + "whitelist.description");
|
||||
private ITextComponent blacklistN = Lang.translate(PREFIX + "blacklist");
|
||||
private ITextComponent blacklistDESC = Lang.translate(PREFIX + "blacklist.description");
|
||||
|
||||
private String respectDataN = Lang.translate(PREFIX + "respect_data");
|
||||
private String respectDataDESC = Lang.translate(PREFIX + "respect_data.description");
|
||||
private String ignoreDataN = Lang.translate(PREFIX + "ignore_data");
|
||||
private String ignoreDataDESC = Lang.translate(PREFIX + "ignore_data.description");
|
||||
private ITextComponent respectDataN = Lang.translate(PREFIX + "respect_data");
|
||||
private ITextComponent respectDataDESC = Lang.translate(PREFIX + "respect_data.description");
|
||||
private ITextComponent ignoreDataN = Lang.translate(PREFIX + "ignore_data");
|
||||
private ITextComponent ignoreDataDESC = Lang.translate(PREFIX + "ignore_data.description");
|
||||
|
||||
private IconButton whitelist, blacklist;
|
||||
private IconButton respectNBT, ignoreNBT;
|
||||
|
@ -100,8 +101,8 @@ public class FilterScreen extends AbstractFilterScreen<FilterContainer> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<String> getTooltipDescriptions() {
|
||||
return Arrays.asList(blacklistDESC, whitelistDESC, respectDataDESC, ignoreDataDESC);
|
||||
protected List<IFormattableTextComponent> getTooltipDescriptions() {
|
||||
return Arrays.asList(blacklistDESC.copy(), whitelistDESC.copy(), respectDataDESC.copy(), ignoreDataDESC.copy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.function.BiPredicate;
|
|||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import com.google.common.base.Predicates;
|
||||
|
@ -95,7 +96,7 @@ public interface ItemAttribute {
|
|||
}
|
||||
|
||||
@OnlyIn(value = Dist.CLIENT)
|
||||
default String format() {
|
||||
default TranslationTextComponent format() {
|
||||
return Lang.translate("item_attributes." + getTranslationKey(), getTranslationParameters());
|
||||
}
|
||||
|
||||
|
@ -250,8 +251,8 @@ public interface ItemAttribute {
|
|||
}
|
||||
|
||||
@OnlyIn(value = Dist.CLIENT)
|
||||
public String format() {
|
||||
return Lang.translate("item_attributes." + getTranslationKey(), I18n.format(group.getTranslationKey()));
|
||||
public TranslationTextComponent format() {
|
||||
return Lang.translate("item_attributes." + getTranslationKey(), group.getTranslationKey());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
package com.simibubi.create.content.palettes;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
|
||||
public class MetalBlock extends Block {
|
||||
private final boolean isBeaconBaseBlock;
|
||||
|
||||
public MetalBlock(Properties properties) {
|
||||
super(properties);
|
||||
isBeaconBaseBlock = false;
|
||||
}
|
||||
|
||||
public MetalBlock(Properties properties, boolean isBeaconBaseBlock) {
|
||||
super(properties);
|
||||
this.isBeaconBaseBlock = isBeaconBaseBlock;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeaconBase(BlockState state, IWorldReader world, BlockPos pos, BlockPos beacon) {
|
||||
return isBeaconBaseBlock ? true : super.isBeaconBase(state, world, pos, beacon);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import net.minecraft.block.WallBlock;
|
|||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tags.BlockTags;
|
||||
import net.minecraft.tags.ITag;
|
||||
import net.minecraft.tags.ItemTags;
|
||||
import net.minecraft.tags.Tag;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
@ -73,9 +74,9 @@ public abstract class PaletteBlockPartial<B extends Block> {
|
|||
return builder;
|
||||
}
|
||||
|
||||
protected abstract Iterable<Tag<Block>> getBlockTags();
|
||||
protected abstract Iterable<ITag.INamedTag<Block>> getBlockTags();
|
||||
|
||||
protected abstract Iterable<Tag<Item>> getItemTags();
|
||||
protected abstract Iterable<ITag.INamedTag<Item>> getItemTags();
|
||||
|
||||
protected abstract B createBlock(Supplier<? extends Block> block);
|
||||
|
||||
|
@ -104,12 +105,12 @@ public abstract class PaletteBlockPartial<B extends Block> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Block>> getBlockTags() {
|
||||
protected Iterable<ITag.INamedTag<Block>> getBlockTags() {
|
||||
return Arrays.asList(BlockTags.STAIRS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Item>> getItemTags() {
|
||||
protected Iterable<ITag.INamedTag<Item>> getItemTags() {
|
||||
return Arrays.asList(ItemTags.STAIRS);
|
||||
}
|
||||
|
||||
|
@ -164,12 +165,12 @@ public abstract class PaletteBlockPartial<B extends Block> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Block>> getBlockTags() {
|
||||
protected Iterable<ITag.INamedTag<Block>> getBlockTags() {
|
||||
return Arrays.asList(BlockTags.SLABS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Item>> getItemTags() {
|
||||
protected Iterable<ITag.INamedTag<Item>> getItemTags() {
|
||||
return Arrays.asList(ItemTags.SLABS);
|
||||
}
|
||||
|
||||
|
@ -209,12 +210,12 @@ public abstract class PaletteBlockPartial<B extends Block> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Block>> getBlockTags() {
|
||||
protected Iterable<ITag.INamedTag<Block>> getBlockTags() {
|
||||
return Arrays.asList(BlockTags.WALLS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Iterable<Tag<Item>> getItemTags() {
|
||||
protected Iterable<ITag.INamedTag<Item>> getItemTags() {
|
||||
return Arrays.asList(ItemTags.WALLS);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.content.contraptions.relays.belt.BeltPart;
|
|||
import com.simibubi.create.content.contraptions.relays.belt.item.BeltConnectorItem;
|
||||
import com.simibubi.create.content.contraptions.relays.elementary.ShaftBlock;
|
||||
|
||||
import com.simibubi.create.foundation.utility.BlockHelper;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -114,9 +115,9 @@ public abstract class LaunchedItem {
|
|||
@Override
|
||||
void place(World world) {
|
||||
// Piston
|
||||
if (state.has(BlockStateProperties.EXTENDED))
|
||||
if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.EXTENDED))
|
||||
state = state.with(BlockStateProperties.EXTENDED, Boolean.FALSE);
|
||||
if (state.has(BlockStateProperties.WATERLOGGED))
|
||||
if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.WATERLOGGED))
|
||||
state = state.with(BlockStateProperties.WATERLOGGED, Boolean.FALSE);
|
||||
|
||||
if (AllBlocks.BELT.has(state)) {
|
||||
|
|
|
@ -539,7 +539,7 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC
|
|||
schematicAnchor = anchor;
|
||||
blockReader = new SchematicWorld(schematicAnchor, world);
|
||||
PlacementSettings settings = SchematicItem.getSettings(blueprint);
|
||||
activeTemplate.addBlocksToWorld(blockReader, schematicAnchor, settings);
|
||||
activeTemplate.place(blockReader, schematicAnchor, settings);
|
||||
schematicLoaded = true;
|
||||
state = State.PAUSED;
|
||||
statusMsg = "ready";
|
||||
|
|
|
@ -5,11 +5,13 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.simibubi.create.foundation.gui.widgets.AbstractSimiWidget;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.screen.inventory.ContainerScreen;
|
||||
import net.minecraft.client.gui.widget.Widget;
|
||||
|
@ -26,6 +28,8 @@ import net.minecraftforge.api.distmarker.Dist;
|
|||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
public abstract class AbstractSimiContainerScreen<T extends Container> extends ContainerScreen<T> {
|
||||
|
||||
protected List<Widget> widgets;
|
||||
|
@ -41,14 +45,14 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground();
|
||||
renderWindow(mouseX, mouseY, partialTicks);
|
||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
renderBackground(matrixStack);
|
||||
renderWindow(matrixStack, mouseX, mouseY, partialTicks);
|
||||
|
||||
for (Widget widget : widgets)
|
||||
widget.render(mouseX, mouseY, partialTicks);
|
||||
widget.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||
|
||||
super.render(mouseX, mouseY, partialTicks);
|
||||
super.render(matrixStack, mouseX, mouseY, partialTicks);
|
||||
|
||||
RenderSystem.enableAlphaTest();
|
||||
RenderSystem.enableBlend();
|
||||
|
@ -56,9 +60,9 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
RenderHelper.disableStandardItemLighting();
|
||||
RenderSystem.disableLighting();
|
||||
RenderSystem.disableDepthTest();
|
||||
renderWindowForeground(mouseX, mouseY, partialTicks);
|
||||
renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks);
|
||||
for (Widget widget : widgets)
|
||||
widget.renderToolTip(mouseX, mouseY);
|
||||
widget.renderToolTip(matrixStack, mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -123,7 +127,8 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
protected abstract void renderWindow(MatrixStack ms, int mouseX, int mouseY, float partialTicks);
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
|
||||
protected void drawBackground(MatrixStack p_230450_1_, float p_230450_2_, int p_230450_3_, int p_230450_4_) {
|
||||
|
||||
}
|
||||
|
||||
protected void renderWindowForeground(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
|
@ -138,7 +143,7 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
}
|
||||
}
|
||||
|
||||
protected void renderItemOverlayIntoGUI(FontRenderer fr, ItemStack stack, int xPosition, int yPosition,
|
||||
protected void renderItemOverlayIntoGUI(MatrixStack matrixStack, FontRenderer fr, ItemStack stack, int xPosition, int yPosition,
|
||||
@Nullable String text, int textColor) {
|
||||
if (!stack.isEmpty()) {
|
||||
if (stack.getItem().showDurabilityBar(stack)) {
|
||||
|
@ -169,14 +174,14 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
RenderSystem.disableBlend();
|
||||
RenderSystem.pushMatrix();
|
||||
|
||||
int guiScaleFactor = (int) minecraft.getWindow().getGuiScaleFactor();
|
||||
int guiScaleFactor = (int) client.getWindow().getGuiScaleFactor();
|
||||
RenderSystem.translated((float) (xPosition + 16.5f), (float) (yPosition + 16.5f), 0);
|
||||
double scale = getItemCountTextScale();
|
||||
|
||||
RenderSystem.scaled(scale, scale, 0);
|
||||
RenderSystem.translated(-fr.getStringWidth(s) - (guiScaleFactor > 1 ? 0 : -.5f),
|
||||
-font.FONT_HEIGHT + (guiScaleFactor > 1 ? 1 : 1.75f), 0);
|
||||
fr.drawStringWithShadow(s, 0, 0, textColor);
|
||||
-textRenderer.FONT_HEIGHT + (guiScaleFactor > 1 ? 1 : 1.75f), 0);
|
||||
fr.drawWithShadow(matrixStack, s, 0, 0, textColor);
|
||||
|
||||
RenderSystem.popMatrix();
|
||||
RenderSystem.enableBlend();
|
||||
|
@ -188,7 +193,7 @@ public abstract class AbstractSimiContainerScreen<T extends Container> extends C
|
|||
}
|
||||
|
||||
public double getItemCountTextScale() {
|
||||
int guiScaleFactor = (int) minecraft.getWindow().getGuiScaleFactor();
|
||||
int guiScaleFactor = (int) client.getWindow().getGuiScaleFactor();
|
||||
double scale = 1;
|
||||
switch (guiScaleFactor) {
|
||||
case 1:
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
package com.simibubi.create.foundation.gui.widgets;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
|
||||
public class Label extends AbstractSimiWidget {
|
||||
|
||||
public String text;
|
||||
public ITextComponent text;
|
||||
public String suffix;
|
||||
protected boolean hasShadow;
|
||||
protected int color;
|
||||
|
@ -16,7 +19,7 @@ public class Label extends AbstractSimiWidget {
|
|||
public Label(int x, int y, String text) {
|
||||
super(x, y, Minecraft.getInstance().fontRenderer.getStringWidth(text), 10);
|
||||
font = Minecraft.getInstance().fontRenderer;
|
||||
this.text = "Label";
|
||||
this.text = ITextComponent.of("Label");
|
||||
color = 0xFFFFFF;
|
||||
hasShadow = false;
|
||||
suffix = "";
|
||||
|
@ -37,10 +40,10 @@ public class Label extends AbstractSimiWidget {
|
|||
return this;
|
||||
}
|
||||
|
||||
public void setTextAndTrim(String newText, boolean trimFront, int maxWidthPx) {
|
||||
public void setTextAndTrim(ITextComponent newText, boolean trimFront, int maxWidthPx) {
|
||||
FontRenderer fontRenderer = Minecraft.getInstance().fontRenderer;
|
||||
|
||||
if (fontRenderer.getStringWidth(newText) <= maxWidthPx) {
|
||||
if (fontRenderer.getWidth(newText) <= maxWidthPx) {
|
||||
text = newText;
|
||||
return;
|
||||
}
|
||||
|
@ -48,15 +51,16 @@ public class Label extends AbstractSimiWidget {
|
|||
String trim = "...";
|
||||
int trimWidth = fontRenderer.getStringWidth(trim);
|
||||
|
||||
StringBuilder builder = new StringBuilder(newText);
|
||||
int startIndex = trimFront ? 0 : newText.length() - 1;
|
||||
int endIndex = !trimFront ? 0 : newText.length() - 1;
|
||||
String raw = newText.getUnformattedComponentText();
|
||||
StringBuilder builder = new StringBuilder(raw);
|
||||
int startIndex = trimFront ? 0 : raw.length() - 1;
|
||||
int endIndex = !trimFront ? 0 : raw.length() - 1;
|
||||
int step = (int) Math.signum(endIndex - startIndex);
|
||||
|
||||
for (int i = startIndex; i != endIndex; i += step) {
|
||||
String sub = builder.substring(trimFront ? i : startIndex, trimFront ? endIndex + 1 : i + 1);
|
||||
if (fontRenderer.getStringWidth(sub) + trimWidth <= maxWidthPx) {
|
||||
text = trimFront ? trim + sub : sub + trim;
|
||||
if (fontRenderer.getWidth(new StringTextComponent(sub).setStyle(newText.getStyle())) + trimWidth <= maxWidthPx) {
|
||||
text = new StringTextComponent(trimFront ? trim + sub : sub + trim).setStyle(newText.getStyle());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -64,17 +68,17 @@ public class Label extends AbstractSimiWidget {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float partialTicks) {
|
||||
public void render(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) {
|
||||
if (!visible)
|
||||
return;
|
||||
if (text == null || text.isEmpty())
|
||||
if (text == null || text.toString().isEmpty())
|
||||
return;
|
||||
|
||||
RenderSystem.color4f(1, 1, 1, 1);
|
||||
if (hasShadow)
|
||||
font.drawStringWithShadow(text + suffix, x, y, color);
|
||||
font.drawWithShadow(matrixStack, text + suffix, x, y, color);
|
||||
else
|
||||
font.drawString(text + suffix, x, y, color);
|
||||
font.draw(matrixStack, text + suffix, x, y, color);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,15 +7,17 @@ import com.simibubi.create.AllKeys;
|
|||
import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour.StepContext;
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class ScrollInput extends AbstractSimiWidget {
|
||||
|
||||
protected Consumer<Integer> onScroll;
|
||||
protected int state;
|
||||
protected String title = Lang.translate("gui.scrollInput.defaultTitle");
|
||||
protected final String scrollToModify = Lang.translate("gui.scrollInput.scrollToModify");
|
||||
protected final String shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster");
|
||||
protected IFormattableTextComponent title = Lang.translate("gui.scrollInput.defaultTitle");
|
||||
protected final IFormattableTextComponent scrollToModify = Lang.translate("gui.scrollInput.scrollToModify");
|
||||
protected final IFormattableTextComponent shiftScrollsFaster = Lang.translate("gui.scrollInput.shiftScrollsFaster");
|
||||
protected Label displayLabel;
|
||||
|
||||
protected int min, max;
|
||||
|
@ -46,7 +48,7 @@ public class ScrollInput extends AbstractSimiWidget {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ScrollInput titled(String title) {
|
||||
public ScrollInput titled(IFormattableTextComponent title) {
|
||||
this.title = title;
|
||||
updateTooltip();
|
||||
return this;
|
||||
|
@ -83,7 +85,7 @@ public class ScrollInput extends AbstractSimiWidget {
|
|||
|
||||
@Override
|
||||
public boolean mouseScrolled(double mouseX, double mouseY, double delta) {
|
||||
if (!isHovered)
|
||||
if (!hovered)
|
||||
return false;
|
||||
|
||||
StepContext context = new StepContext();
|
||||
|
@ -124,14 +126,14 @@ public class ScrollInput extends AbstractSimiWidget {
|
|||
}
|
||||
|
||||
protected void writeToLabel() {
|
||||
displayLabel.text = "" + state;
|
||||
displayLabel.text = ITextComponent.of(String.valueOf(state));
|
||||
}
|
||||
|
||||
protected void updateTooltip() {
|
||||
toolTip.clear();
|
||||
toolTip.add(TextFormatting.BLUE + title);
|
||||
toolTip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + scrollToModify);
|
||||
toolTip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + shiftScrollsFaster);
|
||||
toolTip.add(title.formatted(TextFormatting.BLUE));
|
||||
toolTip.add(scrollToModify.formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY));
|
||||
toolTip.add(shiftScrollsFaster.formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,19 +5,22 @@ import java.util.List;
|
|||
|
||||
import com.simibubi.create.foundation.utility.Lang;
|
||||
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class SelectionScrollInput extends ScrollInput {
|
||||
|
||||
private final String scrollToSelect = Lang.translate("gui.scrollInput.scrollToSelect");
|
||||
protected List<String> options;
|
||||
private final IFormattableTextComponent scrollToSelect = Lang.translate("gui.scrollInput.scrollToSelect");
|
||||
protected List<ITextComponent> options;
|
||||
|
||||
public SelectionScrollInput(int xIn, int yIn, int widthIn, int heightIn) {
|
||||
super(xIn, yIn, widthIn, heightIn);
|
||||
options = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ScrollInput forOptions(List<String> options) {
|
||||
public ScrollInput forOptions(List<ITextComponent> options) {
|
||||
this.options = options;
|
||||
this.max = options.size();
|
||||
updateTooltip();
|
||||
|
@ -37,16 +40,14 @@ public class SelectionScrollInput extends ScrollInput {
|
|||
@Override
|
||||
protected void updateTooltip() {
|
||||
toolTip.clear();
|
||||
toolTip.add(TextFormatting.BLUE + title);
|
||||
toolTip.add(title.formatted(TextFormatting.BLUE));
|
||||
for (int i = min; i < max; i++) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
if (i == state)
|
||||
result.append(TextFormatting.WHITE).append("-> ").append(options.get(i));
|
||||
toolTip.add(StringTextComponent.EMPTY.copy().append("-> ").append(options.get(i)).formatted(TextFormatting.WHITE));
|
||||
else
|
||||
result.append(TextFormatting.GRAY).append("> ").append(options.get(i));
|
||||
toolTip.add(result.toString());
|
||||
toolTip.add(StringTextComponent.EMPTY.copy().append("> ").append(options.get(i)).formatted(TextFormatting.GRAY));
|
||||
}
|
||||
toolTip.add(TextFormatting.DARK_GRAY + "" + TextFormatting.ITALIC + scrollToSelect);
|
||||
toolTip.add( StringTextComponent.EMPTY.copy().append(scrollToSelect).formatted(TextFormatting.ITALIC, TextFormatting.DARK_GRAY));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import net.minecraft.client.Minecraft;
|
|||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraft.inventory.EquipmentSlotType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
@ -155,8 +156,8 @@ public class ItemDescription {
|
|||
add(linesOnShift, GRAY + Lang.translate("tooltip.capacityProvided"));
|
||||
add(linesOnShift, level);
|
||||
|
||||
String genSpeed = generatorSpeed(block, rpmUnit);
|
||||
if (!genSpeed.equals("")) {
|
||||
IFormattableTextComponent genSpeed = generatorSpeed(block, rpmUnit);
|
||||
if (!genSpeed.getUnformattedComponentText().equals("")) {
|
||||
add(linesOnShift, GREEN + " " + genSpeed);
|
||||
}
|
||||
}
|
||||
|
@ -251,10 +252,18 @@ public class ItemDescription {
|
|||
textLines.forEach(s -> add(infoList, s));
|
||||
}
|
||||
|
||||
public static void add(List<ITextComponent> infoList, List<ITextComponent> textLines) {
|
||||
infoList.addAll(textLines);
|
||||
}
|
||||
|
||||
public static void add(List<ITextComponent> infoList, String line) {
|
||||
infoList.add(new StringTextComponent(line));
|
||||
}
|
||||
|
||||
public static void add(List<ITextComponent> infoList, ITextComponent line) {
|
||||
infoList.add(line);
|
||||
}
|
||||
|
||||
public Palette getPalette() {
|
||||
return palette;
|
||||
}
|
||||
|
@ -286,7 +295,7 @@ public class ItemDescription {
|
|||
return linesOnShift;
|
||||
}
|
||||
|
||||
private String generatorSpeed(Block block, String unitRPM) {
|
||||
private IFormattableTextComponent generatorSpeed(Block block, String unitRPM) {
|
||||
String value = "";
|
||||
|
||||
if (block instanceof WaterWheelBlock) {
|
||||
|
@ -303,7 +312,7 @@ public class ItemDescription {
|
|||
value = baseSpeed + "-" + (baseSpeed * 2);
|
||||
}
|
||||
|
||||
return !value.equals("") ? Lang.translate("tooltip.generationSpeed", value, unitRPM) : "";
|
||||
return !value.equals("") ? Lang.translate("tooltip.generationSpeed", value, unitRPM) : StringTextComponent.EMPTY.copy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import net.minecraft.item.BlockItem;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.TieredItem;
|
||||
import net.minecraft.util.text.IFormattableTextComponent;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
|
||||
public class TooltipHelper {
|
||||
|
@ -34,14 +36,13 @@ public class TooltipHelper {
|
|||
public static Language cachedLanguage;
|
||||
private static boolean gogglesMode;
|
||||
|
||||
public static String holdShift(Palette color, boolean highlighted) {
|
||||
public static IFormattableTextComponent holdShift(Palette color, boolean highlighted) {
|
||||
TextFormatting colorFormat = highlighted ? color.hColor : color.color;
|
||||
return DARK_GRAY
|
||||
+ Lang.translate("tooltip.holdKey", colorFormat + Lang.translate("tooltip.keyShift") + DARK_GRAY);
|
||||
return Lang.translate("tooltip.holdKey", DARK_GRAY).append(Lang.translate("tooltip.keyShift").formatted(colorFormat));
|
||||
}
|
||||
|
||||
public static List<String> cutString(String s, TextFormatting defaultColor, TextFormatting highlightColor) {
|
||||
return cutString(s, defaultColor, highlightColor, 0);
|
||||
public static List<String> cutString(ITextComponent s, TextFormatting defaultColor, TextFormatting highlightColor) {
|
||||
return cutString(s.getUnformattedComponentText(), defaultColor, highlightColor, 0);
|
||||
}
|
||||
|
||||
public static List<String> cutString(String s, TextFormatting defaultColor, TextFormatting highlightColor,
|
||||
|
|
|
@ -18,11 +18,12 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ValueBox extends ChasingAABBOutline {
|
||||
|
||||
protected String label = "Value Box";
|
||||
protected String sublabel = "";
|
||||
protected ITextComponent label = ITextComponent.of("Value Box");
|
||||
protected ITextComponent sublabel = ITextComponent.of("");
|
||||
protected String scrollTooltip = "";
|
||||
protected Vector3d labelOffset = Vector3d.ZERO;
|
||||
|
||||
|
@ -34,7 +35,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
protected ValueBoxTransform transform;
|
||||
protected BlockState blockState;
|
||||
|
||||
public ValueBox(String label, AxisAlignedBB bb, BlockPos pos) {
|
||||
public ValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos) {
|
||||
super(bb);
|
||||
this.label = label;
|
||||
this.pos = pos;
|
||||
|
@ -51,7 +52,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ValueBox subLabel(String sublabel) {
|
||||
public ValueBox subLabel(ITextComponent sublabel) {
|
||||
this.sublabel = sublabel;
|
||||
return this;
|
||||
}
|
||||
|
@ -103,7 +104,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
ms.translate(labelOffset.x, labelOffset.y, labelOffset.z);
|
||||
|
||||
renderHoveringText(ms, buffer, label);
|
||||
if (!sublabel.isEmpty()) {
|
||||
if (!sublabel.toString().isEmpty()) {
|
||||
ms.translate(0, 10, 0);
|
||||
renderHoveringText(ms, buffer, sublabel);
|
||||
}
|
||||
|
@ -162,7 +163,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
public static class TextValueBox extends ValueBox {
|
||||
String text;
|
||||
|
||||
public TextValueBox(String label, AxisAlignedBB bb, BlockPos pos, String text) {
|
||||
public TextValueBox(ITextComponent label, AxisAlignedBB bb, BlockPos pos, String text) {
|
||||
super(label, bb, pos);
|
||||
this.text = text;
|
||||
}
|
||||
|
@ -185,7 +186,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
ms.scale(numberScale, numberScale, numberScale);
|
||||
ms.translate(singleDigit ? stringWidth / 2 : 0, singleDigit ? -verticalMargin : verticalMargin, 0);
|
||||
|
||||
renderHoveringText(ms, buffer, text, 0xEDEDED, 0x4f4f4f);
|
||||
renderHoveringText(ms, buffer, ITextComponent.of(text), 0xEDEDED, 0x4f4f4f);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -212,11 +213,11 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
|
||||
// util
|
||||
|
||||
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, String text) {
|
||||
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text) {
|
||||
renderHoveringText(ms, buffer, text, highlightColor, ColorHelper.mixColors(passiveColor, 0, 0.75f));
|
||||
}
|
||||
|
||||
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, String text, int color,
|
||||
protected void renderHoveringText(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, int color,
|
||||
int shadowColor) {
|
||||
ms.push();
|
||||
drawString(ms, buffer, text, 0, 0, color);
|
||||
|
@ -225,7 +226,7 @@ public class ValueBox extends ChasingAABBOutline {
|
|||
ms.pop();
|
||||
}
|
||||
|
||||
private static void drawString(MatrixStack ms, IRenderTypeBuffer buffer, String text, float x, float y, int color) {
|
||||
private static void drawString(MatrixStack ms, IRenderTypeBuffer buffer, ITextComponent text, float x, float y, int color) {
|
||||
Minecraft.getInstance().fontRenderer.draw(text, x, y, color, false, ms.peek()
|
||||
.getModel(), buffer, false, 0, 15728880);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,13 @@ package com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue;
|
|||
|
||||
import com.simibubi.create.foundation.tileEntity.SmartTileEntity;
|
||||
import com.simibubi.create.foundation.tileEntity.behaviour.ValueBoxTransform;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ScrollOptionBehaviour<E extends Enum<E> & INamedIconOptions> extends ScrollValueBehaviour {
|
||||
|
||||
private E[] options;
|
||||
|
||||
public ScrollOptionBehaviour(Class<E> enum_, String label, SmartTileEntity te, ValueBoxTransform slot) {
|
||||
public ScrollOptionBehaviour(Class<E> enum_, ITextComponent label, SmartTileEntity te, ValueBoxTransform slot) {
|
||||
super(label, te, slot);
|
||||
options = enum_.getEnumConstants();
|
||||
between(0, options.length - 1);
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ScrollValueBehaviour extends TileEntityBehaviour {
|
||||
|
||||
|
@ -27,7 +28,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour {
|
|||
public int scrollableValue;
|
||||
int ticksUntilScrollPacket;
|
||||
boolean forceClientState;
|
||||
String label;
|
||||
ITextComponent label;
|
||||
Consumer<Integer> callback;
|
||||
Consumer<Integer> clientCallback;
|
||||
Function<Integer, String> formatter;
|
||||
|
@ -35,7 +36,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour {
|
|||
Function<StepContext, Integer> step;
|
||||
boolean needsWrench;
|
||||
|
||||
public ScrollValueBehaviour(String label, SmartTileEntity te, ValueBoxTransform slot) {
|
||||
public ScrollValueBehaviour(ITextComponent label, SmartTileEntity te, ValueBoxTransform slot) {
|
||||
super(te);
|
||||
this.setLabel(label);
|
||||
slotPositioning = slot;
|
||||
|
@ -166,7 +167,7 @@ public class ScrollValueBehaviour extends TileEntityBehaviour {
|
|||
return slotPositioning.testHit(state, localHit);
|
||||
}
|
||||
|
||||
public void setLabel(String label) {
|
||||
public void setLabel(ITextComponent label) {
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.util.math.vector.Vector3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
|
||||
public class ScrollValueRenderer {
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class ScrollValueRenderer {
|
|||
AxisAlignedBB bb = new AxisAlignedBB(Vector3d.ZERO, Vector3d.ZERO).grow(.5f)
|
||||
.contract(0, 0, -.5f)
|
||||
.offset(0, 0, -.125f);
|
||||
String label = behaviour.label;
|
||||
ITextComponent label = behaviour.label;
|
||||
ValueBox box;
|
||||
|
||||
if (behaviour instanceof ScrollOptionBehaviour) {
|
||||
|
|
|
@ -11,8 +11,8 @@ import net.minecraft.util.text.TranslationTextComponent;
|
|||
|
||||
public class Lang {
|
||||
|
||||
public static String translate(String key, Object... args) {
|
||||
return createTranslationTextComponent(key, args).getFormattedText();
|
||||
public static TranslationTextComponent translate(String key, Object... args) {
|
||||
return createTranslationTextComponent(key, args);
|
||||
}
|
||||
|
||||
public static TranslationTextComponent createTranslationTextComponent(String key, Object... args) {
|
||||
|
@ -23,8 +23,8 @@ public class Lang {
|
|||
player.sendStatusMessage(createTranslationTextComponent(key, args), true);
|
||||
}
|
||||
|
||||
public static List<String> translatedOptions(String prefix, String... keys) {
|
||||
List<String> result = new ArrayList<>(keys.length);
|
||||
public static List<TranslationTextComponent> translatedOptions(String prefix, String... keys) {
|
||||
List<TranslationTextComponent> result = new ArrayList<>(keys.length);
|
||||
for (String key : keys) {
|
||||
result.add(translate(prefix + "." + key));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package com.simibubi.create.foundation.worldgen;
|
||||
|
||||
import com.simibubi.create.content.curiosities.tools.SandPaperItem;
|
||||
import com.simibubi.create.content.palettes.MetalBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
|
|
@ -13,4 +13,6 @@ public net.minecraft.world.server.ChunkManager field_219253_g #chunksToUnload
|
|||
# ChunkStatus
|
||||
public-f net.minecraft.world.chunk.ChunkStatus field_222617_m #FULL
|
||||
public net.minecraft.world.chunk.ChunkStatus$IGenerationWorker
|
||||
public net.minecraft.world.chunk.ChunkStatus$ILoadingWorker
|
||||
public net.minecraft.world.chunk.ChunkStatus$ILoadingWorker
|
||||
|
||||
public net.minecraft.client.gui.FontRenderer func_238419_a_(Lnet/minecraft/util/ResourceLocation;)Lnet/minecraft/client/gui/fonts/Font; # getFontStorage
|
Loading…
Reference in a new issue