Cleaning up

- Fixed some immediately noticeable issues from the port
This commit is contained in:
simibubi 2023-06-30 02:25:04 +02:00
parent e94fddadf3
commit 8d042b08aa
39 changed files with 190 additions and 102 deletions

View file

@ -1,4 +1,4 @@
// 1.20.1 2023-06-29T19:34:04.0054837 Tags for minecraft:damage_type mod id create
98cc73dad40a3d36d74ba9b9134c1ad52a9390c3 data/minecraft/tags/damage_type/bypasses_armor.json
// 1.20.1 2023-06-29T22:04:50.9792131 Tags for minecraft:damage_type mod id create
55371872b65f63a4b7508599d18a9a5e029ed353 data/minecraft/tags/damage_type/bypasses_armor.json
62231dbbc4e6a21bafe1b3cdb3c86d06ff647ec7 data/minecraft/tags/damage_type/is_explosion.json
ad45c55a9cc7883cfcd8b208f735c739f599e1d0 data/minecraft/tags/damage_type/is_fire.json
25913dd7c9ec6de04eac0f77ff764e1c48ca651d data/minecraft/tags/damage_type/is_fire.json

View file

@ -1396,18 +1396,18 @@
"create.tooltip.holdForControls": "Hold [%1$s] for Controls",
"create.tooltip.keyShift": "Shift",
"create.tooltip.keyCtrl": "Ctrl",
"create.tooltip.speedRequirement": "Speed Requirement: %1$s",
"create.tooltip.speedRequirement": "Speed Requirement:",
"create.tooltip.speedRequirement.none": "None",
"create.tooltip.speedRequirement.slow": "Slow",
"create.tooltip.speedRequirement.medium": "Moderate",
"create.tooltip.speedRequirement.fast": "Fast",
"create.tooltip.stressImpact": "Kinetic Stress Impact: %1$s",
"create.tooltip.stressImpact": "Kinetic Stress Impact:",
"create.tooltip.stressImpact.low": "Low",
"create.tooltip.stressImpact.medium": "Moderate",
"create.tooltip.stressImpact.high": "High",
"create.tooltip.stressImpact.overstressed": "Overstressed",
"create.tooltip.up_to": "Up to %1$s",
"create.tooltip.capacityProvided": "Kinetic Stress Capacity: %1$s",
"create.tooltip.capacityProvided": "Kinetic Stress Capacity:",
"create.tooltip.capacityProvided.low": "Small",
"create.tooltip.capacityProvided.medium": "Medium",
"create.tooltip.capacityProvided.high": "Large",

View file

@ -1,11 +1,15 @@
{
"values": [
{
"id": "create:fan_lava",
"required": false
},
{
"id": "create:fan_fire",
"required": false
},
{
"id": "create:fan_lava",
"id": "create:crush",
"required": false
},
{
@ -15,10 +19,6 @@
{
"id": "create:mechanical_saw",
"required": false
},
{
"id": "create:crush",
"required": false
}
]
}

View file

@ -1,11 +1,11 @@
{
"values": [
{
"id": "create:fan_fire",
"id": "create:fan_lava",
"required": false
},
{
"id": "create:fan_lava",
"id": "create:fan_fire",
"required": false
}
]

View file

@ -310,6 +310,8 @@ import net.minecraftforge.common.Tags;
import net.minecraftforge.common.util.ForgeSoundType;
public class AllBlocks {
static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.MAIN_TAB); }
// Schematics
@ -1994,6 +1996,8 @@ public class AllBlocks {
.register();
// Materials
static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.BUILDING_BLOCKS_TAB); }
public static final BlockEntry<MetalLadderBlock> ANDESITE_LADDER =
REGISTRATE.block("andesite_ladder", MetalLadderBlock::new)

View file

@ -34,6 +34,7 @@ import net.minecraft.world.item.CreativeModeTab.DisplayItemsGenerator;
import net.minecraft.world.item.CreativeModeTab.ItemDisplayParameters;
import net.minecraft.world.item.CreativeModeTab.Output;
import net.minecraft.world.item.CreativeModeTab.TabVisibility;
import net.minecraft.world.item.CreativeModeTabs;
import net.minecraft.world.item.DyeColor;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
@ -51,16 +52,18 @@ public class AllCreativeModeTabs {
private static final DeferredRegister<CreativeModeTab> TAB_REGISTER =
DeferredRegister.create(Registries.CREATIVE_MODE_TAB, Create.ID);
public static RegistryObject<CreativeModeTab> MAIN_TAB = TAB_REGISTER.register("base",
public static final RegistryObject<CreativeModeTab> MAIN_TAB = TAB_REGISTER.register("base",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup.create.base"))
.withTabsBefore(CreativeModeTabs.SPAWN_EGGS)
.icon(() -> AllBlocks.COGWHEEL.asStack())
.displayItems(new RegistrateDisplayItemsGenerator(true))
.build());
public static RegistryObject<CreativeModeTab> BUILDING_BLOCKS_TAB = TAB_REGISTER.register("palettes",
public static final RegistryObject<CreativeModeTab> BUILDING_BLOCKS_TAB = TAB_REGISTER.register("palettes",
() -> CreativeModeTab.builder()
.title(Component.translatable("itemGroup.create.palettes"))
.withTabsBefore(MAIN_TAB.getKey())
.icon(() -> AllPaletteBlocks.ORNATE_IRON_WINDOW.asStack())
.displayItems(new RegistrateDisplayItemsGenerator(false))
.build());
@ -78,12 +81,11 @@ public class AllCreativeModeTabs {
}
public static class RegistrateDisplayItemsGenerator implements DisplayItemsGenerator {
// private final EnumSet<AllSections> sections;
private final boolean addItems;
private final boolean mainTab;
public RegistrateDisplayItemsGenerator(boolean addItems) {
// this.sections = sections;
this.addItems = addItems;
public RegistrateDisplayItemsGenerator(boolean mainTab) {
this.mainTab = mainTab;
}
private static Predicate<Item> makeExclusionPredicate() {
Set<Item> exclusions = new ReferenceOpenHashSet<>();
@ -96,6 +98,7 @@ public class AllCreativeModeTabs {
AllItems.SHADOW_STEEL,
AllItems.REFINED_RADIANCE,
AllItems.COPPER_BACKTANK_PLACEABLE,
AllItems.NETHERITE_BACKTANK_PLACEABLE,
AllItems.MINECART_CONTRAPTION,
AllItems.FURNACE_MINECART_CONTRAPTION,
AllItems.CHEST_MINECART_CONTRAPTION,
@ -107,6 +110,7 @@ public class AllCreativeModeTabs {
AllBlocks.ANDESITE_ENCASED_LARGE_COGWHEEL,
AllBlocks.BRASS_ENCASED_LARGE_COGWHEEL,
AllBlocks.MYSTERIOUS_CUCKOO_CLOCK,
AllBlocks.ELEVATOR_CONTACT,
AllBlocks.SHADOW_STEEL_CASING,
AllBlocks.REFINED_RADIANCE_CASING
);
@ -168,6 +172,11 @@ public class AllCreativeModeTabs {
ItemStack stack = new ItemStack(item);
stack.getOrCreateTag().putInt("Air", BacktankUtil.maxAirWithoutEnchants());
return stack;
},
AllItems.NETHERITE_BACKTANK, item -> {
ItemStack stack = new ItemStack(item);
stack.getOrCreateTag().putInt("Air", BacktankUtil.maxAirWithoutEnchants());
return stack;
}
);
@ -229,54 +238,52 @@ public class AllCreativeModeTabs {
List<ItemOrdering> orderings = makeOrderings();
Function<Item, ItemStack> stackFunc = makeStackFunc();
Function<Item, TabVisibility> visibilityFunc = makeVisibilityFunc();
RegistryObject<CreativeModeTab> tab = mainTab ? MAIN_TAB : BUILDING_BLOCKS_TAB;
List<Item> items = new LinkedList<>();
if (addItems) {
items.addAll(collectItems(itemRenderer, true, exclusionPredicate));
}
items.addAll(collectBlocks(exclusionPredicate));
if (addItems) {
items.addAll(collectItems(itemRenderer, false, exclusionPredicate));
}
items.addAll(collectItems(tab, itemRenderer, true, exclusionPredicate));
items.addAll(collectBlocks(tab, exclusionPredicate));
items.addAll(collectItems(tab, itemRenderer, false, exclusionPredicate));
applyOrderings(items, orderings);
outputAll(output, items, stackFunc, visibilityFunc);
}
private List<Item> collectBlocks(Predicate<Item> exclusionPredicate) {
private List<Item> collectBlocks(RegistryObject<CreativeModeTab> tab, Predicate<Item> exclusionPredicate) {
List<Item> items = new ReferenceArrayList<>();
// for (AllSections section : sections) {
for (RegistryEntry<Block> entry : Create.REGISTRATE.getAll(Registries.BLOCK)) {
Item item = entry.get().asItem();
if (item != Items.AIR) {
if (!exclusionPredicate.test(item)) {
items.add(item);
}
}
}
// }
for (RegistryEntry<Block> entry : Create.REGISTRATE.getAll(Registries.BLOCK)) {
if (!Create.REGISTRATE.isInCreativeTab(entry, tab))
continue;
Item item = entry.get()
.asItem();
if (item == Items.AIR)
continue;
if (!exclusionPredicate.test(item))
items.add(item);
}
items = new ReferenceArrayList<>(new ReferenceLinkedOpenHashSet<>(items));
return items;
}
private List<Item> collectItems(ItemRenderer itemRenderer, boolean special, Predicate<Item> exclusionPredicate) {
private List<Item> collectItems(RegistryObject<CreativeModeTab> tab, ItemRenderer itemRenderer, boolean special,
Predicate<Item> exclusionPredicate) {
List<Item> items = new ReferenceArrayList<>();
// for (AllSections section : sections) {
for (RegistryEntry<Item> entry : Create.REGISTRATE.getAll(Registries.ITEM)) {
Item item = entry.get();
if (!(item instanceof BlockItem)) {
BakedModel model = itemRenderer.getModel(new ItemStack(item), null, null, 0);
if (model.isGui3d() == special) {
if (!exclusionPredicate.test(item)) {
items.add(item);
}
}
}
}
// }
if (!mainTab)
return items;
for (RegistryEntry<Item> entry : Create.REGISTRATE.getAll(Registries.ITEM)) {
if (!Create.REGISTRATE.isInCreativeTab(entry, tab))
continue;
Item item = entry.get();
if (item instanceof BlockItem)
continue;
BakedModel model = itemRenderer.getModel(new ItemStack(item), null, null, 0);
if (model.isGui3d() != special)
continue;
if (!exclusionPredicate.test(item))
items.add(item);
}
return items;
}

View file

@ -66,6 +66,8 @@ import net.minecraft.world.item.Rarity;
import net.minecraftforge.common.Tags;
public class AllItems {
static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.MAIN_TAB); }
public static final ItemEntry<Item> WHEAT_FLOUR =
taggedIngredient("wheat_flour", forgeItemTag("flour/wheat"), forgeItemTag("flour")),

View file

@ -23,7 +23,6 @@ import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.renderer.entity.ItemRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.world.entity.player.Player;
@ -152,13 +151,11 @@ public class MechanicalCraftingCategory extends CreateRecipeCategory<CraftingRec
if (ingredient != null) {
PoseStack modelViewStack = RenderSystem.getModelViewStack();
modelViewStack.pushPose();
modelViewStack.mulPoseMatrix(matrixStack.last()
.pose());
RenderSystem.applyModelViewMatrix();
RenderSystem.enableDepthTest();
Minecraft minecraft = Minecraft.getInstance();
Font font = getFontRenderer(minecraft, ingredient);
graphics.renderFakeItem(ingredient, 0, 0);
graphics.renderItem(ingredient, 0, 0);
graphics.renderItemDecorations(font, ingredient, 0, 0, null);
RenderSystem.disableBlend();
modelViewStack.popPose();

View file

@ -37,12 +37,11 @@ public class AnimatedItemDrain extends AnimatedKinetics {
BufferSource buffer = MultiBufferSource.immediate(Tesselator.getInstance()
.getBuilder());
PoseStack ms = new PoseStack();
UIRenderHelper.flipForGuiRender(matrixStack);
ms.scale(scale, scale, scale);
matrixStack.scale(scale, scale, scale);
float from = 2/16f;
float to = 1f - from;
FluidRenderer.renderFluidBox(fluid, from, from, from, to, 3/4f, to, buffer, ms, LightTexture.FULL_BRIGHT, false);
FluidRenderer.renderFluidBox(fluid, from, from, from, to, 3/4f, to, buffer, matrixStack, LightTexture.FULL_BRIGHT, false);
buffer.endBatch();
matrixStack.popPose();

View file

@ -11,7 +11,6 @@ import com.simibubi.create.foundation.blockEntity.behaviour.BehaviourType;
import com.simibubi.create.foundation.blockEntity.behaviour.BlockEntityBehaviour;
import com.simibubi.create.foundation.utility.NBTHelper;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.Level;
@ -124,7 +123,7 @@ public class BracketedBlockEntityBehaviour extends BlockEntityBehaviour {
@Override
public void read(CompoundTag nbt, boolean clientPacket) {
if (nbt.contains("Bracket"))
bracket = NbtUtils.readBlockState(getWorld().holderLookup(Registries.BLOCK), nbt.getCompound("Bracket"));
bracket = NbtUtils.readBlockState(blockEntity.blockHolderGetter(), nbt.getCompound("Bracket"));
if (clientPacket && nbt.contains("Redraw"))
getWorld().sendBlockUpdated(getPos(), blockEntity.getBlockState(), blockEntity.getBlockState(), 16);
super.read(nbt, clientPacket);

View file

@ -145,7 +145,7 @@ public class CopycatBlockEntity extends SmartBlockEntity
return;
}
material = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), tag.getCompound("Material"));
material = NbtUtils.readBlockState(blockHolderGetter(), tag.getCompound("Material"));
// Validate Material
if (material != null && !clientPacket) {

View file

@ -8,6 +8,7 @@ import static com.simibubi.create.foundation.data.WindowGen.framedGlassPane;
import static com.simibubi.create.foundation.data.WindowGen.woodenWindowBlock;
import static com.simibubi.create.foundation.data.WindowGen.woodenWindowPane;
import com.simibubi.create.AllCreativeModeTabs;
import com.simibubi.create.AllSpriteShifts;
import com.simibubi.create.Create;
import com.simibubi.create.foundation.block.connected.HorizontalCTBehaviour;
@ -30,6 +31,8 @@ import net.minecraftforge.common.Tags;
public class AllPaletteBlocks {
static { REGISTRATE.useCreativeTab(AllCreativeModeTabs.BUILDING_BLOCKS_TAB); }
// Windows and Glass
public static final BlockEntry<GlassBlock> TILED_GLASS = REGISTRATE.block("tiled_glass", GlassBlock::new)

View file

@ -574,7 +574,7 @@ public class ClipboardScreen extends AbstractSimiScreen {
return true;
if (pButton != 0)
return true;
if (hoveredEntry != -1) {
if (hoveredCheck) {
editingIndex = -1;
@ -601,6 +601,13 @@ public class ClipboardScreen extends AbstractSimiScreen {
if (editingIndex == -1)
return false;
if (pMouseX < guiLeft + 50 || pMouseX > guiLeft + 220 || pMouseY < guiTop + 30 || pMouseY > guiTop + 230) {
setFocused(null);
clearDisplayCache();
editingIndex = -1;
return false;
}
long i = Util.getMillis();
DisplayCache cache = getDisplayCache();
int j = cache.getIndexAtPosition(font, convertScreenToLocal(new Pos2i((int) pMouseX, (int) pMouseY)));

View file

@ -48,6 +48,7 @@ public class ToolboxScreen extends AbstractSimiContainerScreen<ToolboxMenu> {
setWindowSize(30 + BG.width, BG.height + PLAYER.height - 24);
setWindowOffset(-11, 0);
super.init();
clearWidgets();
color = menu.contentHolder.getColor();

View file

@ -19,7 +19,6 @@ import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.Direction.AxisDirection;
import net.minecraft.core.Vec3i;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.tags.BlockTags;
@ -192,7 +191,7 @@ public class WaterWheelBlockEntity extends GeneratingKineticBlockEntity {
if (!compound.contains("Material"))
return;
material = NbtUtils.readBlockState(level.holderLookup(Registries.BLOCK), compound.getCompound("Material"));
material = NbtUtils.readBlockState(blockHolderGetter(), compound.getCompound("Material"));
if (material.isAir())
material = Blocks.SPRUCE_PLANKS.defaultBlockState();

View file

@ -40,7 +40,7 @@ public class WaterWheelRenderer<T extends WaterWheelBlockEntity> extends Kinetic
public static final StitchedSprite OAK_LOG_TEMPLATE = new StitchedSprite(new ResourceLocation("block/oak_log"));
public static final StitchedSprite OAK_LOG_TOP_TEMPLATE = new StitchedSprite(new ResourceLocation("block/oak_log_top"));
private static final String[] LOG_SUFFIXES = new String[] { "_log", "_stem" };
private static final String[] LOG_SUFFIXES = new String[] { "_log", "_stem", "_block" };
protected final boolean large;

View file

@ -15,7 +15,7 @@ import com.simibubi.create.foundation.utility.BlockHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.HolderGetter;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.Tag;
@ -24,6 +24,7 @@ import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public abstract class LaunchedItem {
@ -71,16 +72,16 @@ public abstract class LaunchedItem {
return c;
}
public static LaunchedItem fromNBT(CompoundTag c) {
public static LaunchedItem fromNBT(CompoundTag c, HolderGetter<Block> holderGetter) {
LaunchedItem launched = c.contains("Length") ? new LaunchedItem.ForBelt()
: c.contains("BlockState") ? new LaunchedItem.ForBlockState() : new LaunchedItem.ForEntity();
launched.readNBT(c);
launched.readNBT(c, holderGetter);
return launched;
}
abstract void place(Level world);
void readNBT(CompoundTag c) {
void readNBT(CompoundTag c, HolderGetter<Block> holderGetter) {
target = NbtUtils.readBlockPos(c.getCompound("Target"));
ticksRemaining = c.getInt("TicksLeft");
totalTicks = c.getInt("TotalTicks");
@ -113,11 +114,10 @@ public abstract class LaunchedItem {
return serializeNBT;
}
@SuppressWarnings("deprecation")
@Override
void readNBT(CompoundTag nbt) {
super.readNBT(nbt);
state = NbtUtils.readBlockState(BuiltInRegistries.BLOCK.asLookup(), nbt.getCompound("BlockState"));
void readNBT(CompoundTag nbt, HolderGetter<Block> holderGetter) {
super.readNBT(nbt, holderGetter);
state = NbtUtils.readBlockState(holderGetter, nbt.getCompound("BlockState"));
if (nbt.contains("Data", Tag.TAG_COMPOUND)) {
data = nbt.getCompound("Data");
}
@ -147,14 +147,14 @@ public abstract class LaunchedItem {
}
@Override
void readNBT(CompoundTag nbt) {
void readNBT(CompoundTag nbt, HolderGetter<Block> holderGetter) {
length = nbt.getInt("Length");
int[] intArray = nbt.getIntArray("Casing");
casings = new CasingType[length];
for (int i = 0; i < casings.length; i++)
casings[i] = i >= intArray.length ? CasingType.NONE
: CasingType.values()[Mth.clamp(intArray[i], 0, CasingType.values().length - 1)];
super.readNBT(nbt);
super.readNBT(nbt, holderGetter);
}
public ForBelt(BlockPos start, BlockPos target, ItemStack stack, BlockState state, CasingType[] casings) {
@ -225,8 +225,8 @@ public abstract class LaunchedItem {
}
@Override
void readNBT(CompoundTag nbt) {
super.readNBT(nbt);
void readNBT(CompoundTag nbt, HolderGetter<Block> holderGetter) {
super.readNBT(nbt, holderGetter);
if (nbt.contains("Entity"))
deferredTag = nbt.getCompound("Entity");
}

View file

@ -189,7 +189,7 @@ public class SchematicannonBlockEntity extends SmartBlockEntity implements MenuP
for (int i = 0; i < tagBlocks.size(); i++) {
CompoundTag c = tagBlocks.getCompound(i);
LaunchedItem launched = LaunchedItem.fromNBT(c);
LaunchedItem launched = LaunchedItem.fromNBT(c, blockHolderGetter());
BlockPos readBlockPos = launched.target;
// Always write to Server block entity

View file

@ -259,7 +259,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen<Schematica
}
private void fillToolTip(IconButton button, Indicator indicator, String tooltipKey) {
if (!button.isHoveredOrFocused())
if (!button.isHovered())
return;
boolean enabled = indicator.state == State.ON;
List<Component> tip = button.getToolTip();

View file

@ -117,6 +117,7 @@ public class SchematicRenderer {
BakedModel model = dispatcher.getBlockModel(state);
BlockEntity blockEntity = renderWorld.getBlockEntity(localPos);
ModelData modelData = blockEntity != null ? blockEntity.getModelData() : ModelData.EMPTY;
modelData = model.getModelData(renderWorld, pos, state, modelData);
long seed = state.getSeed(pos);
random.setSeed(seed);
if (model.getRenderTypes(state, random, modelData).contains(layer)) {

View file

@ -111,13 +111,16 @@ public class ToolSelectionScreen extends Screen {
} else {
x += 65;
}
for (int i = 0; i < tools.size(); i++) {
RenderSystem.enableBlend();
matrixStack.pushPose();
float alpha = focused ? 1 : .2f;
if (i == selection) {
matrixStack.translate(0, -10, 0);
RenderSystem.setShaderColor(1, 1, 1, 1);
graphics.drawCenteredString(minecraft.font, tools.get(i)
.getDisplayName()
.getString(), x + i * 50 + 24, y + 28, 0xCCDDFF);

View file

@ -379,7 +379,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleMenu> {
PoseStack matrixStack = graphics.pose();
UIRenderHelper.swapAndBlitColor(minecraft.getMainRenderTarget(), UIRenderHelper.framebuffer);
UIRenderHelper.drawStretched(graphics, leftPos + 33, topPos + 16, 3, 173, -100, AllGuiTextures.SCHEDULE_STRIP_DARK);
UIRenderHelper.drawStretched(graphics, leftPos + 33, topPos + 16, 3, 173, 200, AllGuiTextures.SCHEDULE_STRIP_DARK);
int yOffset = 25;
List<ScheduleEntry> entries = schedule.entries;
@ -613,6 +613,7 @@ public class ScheduleScreen extends AbstractSimiContainerScreen<ScheduleMenu> {
AllGuiTextures item = AllGuiTextures.SCHEDULE_CONDITION_ITEM;
AllGuiTextures right = AllGuiTextures.SCHEDULE_CONDITION_RIGHT;
matrixStack.translate(x, y, 0);
UIRenderHelper.drawStretched(graphics, 0, 0, fieldSize, 16, -100, middle);
left.render(graphics, clean ? 0 : -3, 0);
right.render(graphics, fieldSize - 2, 0);

View file

@ -120,7 +120,7 @@ public abstract class CargoThresholdCondition extends LazyTickedScheduleConditio
public void initConfigurationWidgets(ModularGuiLineBuilder builder) {
builder.addSelectionScrollInput(0, 24, (i, l) -> {
i.forOptions(Ops.translatedOptions())
.titled(Lang.translateDirect("schedule.condition.threshold.train_holds"))
.titled(Lang.translateDirect("schedule.condition.threshold.train_holds", ""))
.format(state -> Components.literal(" " + Ops.values()[state].formatted));
}, "Operator");
builder.addIntegerTextInput(29, 41, (e, t) -> {

View file

@ -4,10 +4,14 @@ import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.HolderGetter;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.Connection;
import net.minecraft.network.protocol.game.ClientboundBlockEntityDataPacket;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
@ -71,4 +75,11 @@ public abstract class SyncedBlockEntity extends BlockEntity {
public LevelChunk containedChunk() {
return level.getChunkAt(worldPosition);
}
@SuppressWarnings("deprecation")
public HolderGetter<Block> blockHolderGetter() {
return (HolderGetter<Block>) (level != null ? level.holderLookup(Registries.BLOCK)
: BuiltInRegistries.BLOCK.asLookup());
}
}

View file

@ -7,6 +7,19 @@ public class ConfigTextField extends HintableTextFieldWidget {
public ConfigTextField(Font font, int x, int y, int width, int height) {
super(font, x, y, width, height);
}
@Override
public boolean mouseClicked(double x, double y, int button) {
if (!isMouseOver(x, y))
setFocused(false);
return super.mouseClicked(x, y, button);
}
@Override
public void onClick(double pMouseX, double pMouseY) {
super.onClick(pMouseX, pMouseY);
setFocused(true);
}
@Override
public void setFocused(boolean focus) {

View file

@ -2,6 +2,8 @@ package com.simibubi.create.foundation.data;
import static com.simibubi.create.foundation.data.TagGen.pickaxeOnly;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
@ -36,6 +38,7 @@ import net.minecraft.tags.BlockTags;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntity;
@ -75,6 +78,18 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
public CreateRegistrate registerEventListeners(IEventBus bus) {
return super.registerEventListeners(bus);
}
private static Map<RegistryEntry<?>, RegistryObject<CreativeModeTab>> tabLookup = new IdentityHashMap<>();
private RegistryObject<CreativeModeTab> currentTab;
public CreateRegistrate useCreativeTab(RegistryObject<CreativeModeTab> tab) {
this.currentTab = tab;
return this;
}
public boolean isInCreativeTab(RegistryEntry<?> entry, RegistryObject<CreativeModeTab> tab) {
return tabLookup.get(entry) == tab;
}
@Override
protected <R, T extends R> RegistryEntry<T> accept(String name, ResourceKey<? extends Registry<R>> type,
@ -86,6 +101,8 @@ public class CreateRegistrate extends AbstractRegistrate<CreateRegistrate> {
TooltipModifier.REGISTRY.registerDeferred(entry.getId(), currentTooltipModifierFactory);
}
}
if (currentTab != null)
tabLookup.put(entry, currentTab);
return entry;
}

View file

@ -10,6 +10,7 @@ import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
@ -66,6 +67,13 @@ public abstract class AbstractSimiScreen extends Screen {
}
}
@Override
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
if (getFocused() != null && !getFocused().isMouseOver(pMouseX, pMouseY))
setFocused(null);
return super.mouseClicked(pMouseX, pMouseY, pButton);
}
@Override
public boolean isPauseScreen() {
return false;
@ -118,7 +126,7 @@ public abstract class AbstractSimiScreen extends Screen {
@Override
public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
boolean keyPressed = super.keyPressed(keyCode, scanCode, modifiers);
if (keyPressed || getFocused() != null)
if (keyPressed || getFocused() instanceof EditBox)
return keyPressed;
InputConstants.Key mouseKey = InputConstants.getKey(keyCode, scanCode);
@ -140,7 +148,7 @@ public abstract class AbstractSimiScreen extends Screen {
protected void renderWindowForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
for (Renderable widget : renderables) {
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)
&& simiWidget.visible) {
List<Component> tooltip = simiWidget.getToolTip();
if (tooltip.isEmpty())

View file

@ -275,6 +275,7 @@ public class GuiGameElement {
renderer.textureManager.getTexture(InventoryMenu.BLOCK_ATLAS).setFilter(false, false);
RenderSystem.setShaderTexture(0, InventoryMenu.BLOCK_ATLAS);
RenderSystem.enableBlend();
RenderSystem.enableCull();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
matrixStack.pushPose();
@ -288,7 +289,9 @@ public class GuiGameElement {
}
renderer.render(stack, ItemDisplayContext.GUI, false, matrixStack, buffer, LightTexture.FULL_BRIGHT, OverlayTexture.NO_OVERLAY, bakedModel);
RenderSystem.disableDepthTest();
buffer.endBatch();
RenderSystem.enableDepthTest();
if (useDefaultLighting && flatLighting) {
Lighting.setupFor3DItems();

View file

@ -1,7 +1,5 @@
package com.simibubi.create.foundation.gui.element;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.gui.GuiGraphics;
public abstract class RenderElement implements ScreenElement {

View file

@ -7,13 +7,13 @@ import java.util.List;
import javax.annotation.ParametersAreNonnullByDefault;
import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.AllGuiTextures;
import com.simibubi.create.foundation.gui.TickableGuiEventListener;
import com.simibubi.create.foundation.gui.widget.AbstractSimiWidget;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.Renderable;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.narration.NarratableEntry;
@ -115,7 +115,7 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
protected void renderForeground(GuiGraphics graphics, int mouseX, int mouseY, float partialTicks) {
renderTooltip(graphics, mouseX, mouseY);
for (Renderable widget : renderables) {
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isHoveredOrFocused()) {
if (widget instanceof AbstractSimiWidget simiWidget && simiWidget.isMouseOver(mouseX, mouseY)) {
List<Component> tooltip = simiWidget.getToolTip();
if (tooltip.isEmpty())
continue;
@ -138,11 +138,18 @@ public abstract class AbstractSimiContainerScreen<T extends AbstractContainerMen
@Override
public boolean keyPressed(int pKeyCode, int pScanCode, int pModifiers) {
InputConstants.Key mouseKey = InputConstants.getKey(pKeyCode, pScanCode);
if (getFocused() != null && this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey))
if (getFocused() instanceof EditBox && this.minecraft.options.keyInventory.isActiveAndMatches(mouseKey))
return false;
return super.keyPressed(pKeyCode, pScanCode, pModifiers);
}
@Override
public boolean mouseClicked(double pMouseX, double pMouseY, int pButton) {
if (getFocused() != null && !getFocused().isMouseOver(pMouseX, pMouseY))
setFocused(null);
return super.mouseClicked(pMouseX, pMouseY, pButton);
}
@Override
public GuiEventListener getFocused() {
GuiEventListener focused = super.getFocused();

View file

@ -12,6 +12,8 @@ import com.simibubi.create.foundation.utility.Components;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.narration.NarrationElementOutput;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
import net.minecraft.network.chat.Component;
public abstract class AbstractSimiWidget extends AbstractWidget implements TickableGuiEventListener {
@ -38,6 +40,11 @@ public abstract class AbstractSimiWidget extends AbstractWidget implements Ticka
protected AbstractSimiWidget(int x, int y, int width, int height, Component message) {
super(x, y, width, height, message);
}
@Override
protected ClientTooltipPositioner createTooltipPositioner() {
return DefaultTooltipPositioner.INSTANCE;
}
public <T extends AbstractSimiWidget> T withCallback(BiConsumer<Integer, Integer> cb) {
this.onClick = cb;

View file

@ -26,7 +26,7 @@ public class IconButton extends AbstractSimiWidget {
isHovered = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + width && mouseY < getY() + height;
AllGuiTextures button = !active ? AllGuiTextures.BUTTON_DOWN
: isHoveredOrFocused() ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON;
: isMouseOver(mouseX, mouseY) ? AllGuiTextures.BUTTON_HOVER : AllGuiTextures.BUTTON;
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
drawBg(graphics, button);

View file

@ -12,7 +12,7 @@ public class Indicator extends AbstractSimiWidget {
public Indicator(int x, int y, Component tooltip) {
super(x, y, AllGuiTextures.INDICATOR.width, AllGuiTextures.INDICATOR.height);
this.toolTip = ImmutableList.of(tooltip);
this.toolTip = toolTip.isEmpty() ? ImmutableList.of() : ImmutableList.of(tooltip);
this.state = State.OFF;
}

View file

@ -439,6 +439,7 @@ public class WorldSectionElement extends AnimatedSceneElement {
BakedModel model = dispatcher.getBlockModel(state);
BlockEntity blockEntity = world.getBlockEntity(pos);
ModelData modelData = blockEntity != null ? blockEntity.getModelData() : ModelData.EMPTY;
modelData = model.getModelData(world, pos, state, modelData);
long seed = state.getSeed(pos);
random.setSeed(seed);
if (model.getRenderTypes(state, random, modelData).contains(layer)) {

View file

@ -147,7 +147,8 @@ public abstract class NavigatableSimiScreen extends AbstractSimiScreen {
ms.translate(0, 0, -1000);
UIRenderHelper.framebuffer.bindWrite(true);
PonderTooltipHandler.enable = false;
lastScreen.render(graphics, mouseX, mouseY, partialTicks);
// Using 0,0 for mouse coords to hide tooltips
lastScreen.render(graphics, 0, 0, partialTicks);
PonderTooltipHandler.enable = true;
ms.popPose();

View file

@ -1,7 +1,5 @@
package com.simibubi.create.foundation.ponder.ui;
import javax.annotation.Nonnull;
import com.mojang.blaze3d.vertex.PoseStack;
import com.simibubi.create.foundation.gui.Theme;
import com.simibubi.create.foundation.gui.Theme.Key;

View file

@ -109,12 +109,12 @@ public abstract class GhostBlockRenderer {
for (Direction direction : Direction.values()) {
random.setSeed(42L);
renderQuadList(pose, consumer, red, green, blue, alpha,
model.getQuads(state, direction, random, modelData, renderType), packedLight, packedOverlay);
model.getQuads(state, direction, random, modelData, null), packedLight, packedOverlay);
}
random.setSeed(42L);
renderQuadList(pose, consumer, red, green, blue, alpha,
model.getQuads(state, null, random, modelData, renderType), packedLight, packedOverlay);
model.getQuads(state, null, random, modelData, null), packedLight, packedOverlay);
}
// ModelBlockRenderer

View file

@ -228,6 +228,7 @@ public class CreateMainMenuScreen extends AbstractSimiScreen {
@Override
protected void renderWidget(GuiGraphics graphics, int pMouseX, int pMouseY, float pt) {
super.renderWidget(graphics, pMouseX, pMouseY, pt);
PoseStack pPoseStack = graphics.pose();
pPoseStack.pushPose();
pPoseStack.translate(getX() + width / 2 - (icon.width * scale) / 2, getY() + height / 2 - (icon.height * scale) / 2, 0);

View file

@ -533,20 +533,20 @@
"create.tooltip.keyShift": "Shift",
"create.tooltip.keyCtrl": "Ctrl",
"create.tooltip.speedRequirement": "Speed Requirement: %1$s",
"create.tooltip.speedRequirement": "Speed Requirement:",
"create.tooltip.speedRequirement.none": "None",
"create.tooltip.speedRequirement.slow": "Slow",
"create.tooltip.speedRequirement.medium": "Moderate",
"create.tooltip.speedRequirement.fast": "Fast",
"create.tooltip.stressImpact": "Kinetic Stress Impact: %1$s",
"create.tooltip.stressImpact": "Kinetic Stress Impact:",
"create.tooltip.stressImpact.low": "Low",
"create.tooltip.stressImpact.medium": "Moderate",
"create.tooltip.stressImpact.high": "High",
"create.tooltip.stressImpact.overstressed": "Overstressed",
"create.tooltip.up_to": "Up to %1$s",
"create.tooltip.capacityProvided": "Kinetic Stress Capacity: %1$s",
"create.tooltip.capacityProvided": "Kinetic Stress Capacity:",
"create.tooltip.capacityProvided.low": "Small",
"create.tooltip.capacityProvided.medium": "Medium",
"create.tooltip.capacityProvided.high": "Large",