Skip to content

Commit

Permalink
Working backport to 1.18.2 FABRIC
Browse files Browse the repository at this point in the history
Working backport to 1.18.2 Tested only with fabric, implemented pama1234 fix TimStewartJ#11 for iris shaders
TimStewartJ#20
  • Loading branch information
lluminate committed Jul 12, 2024
1 parent ffd6a69 commit a301ce7
Show file tree
Hide file tree
Showing 49 changed files with 349 additions and 244 deletions.
1 change: 1 addition & 0 deletions .architectury-transformer/debug.log
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[Architectury Transformer DEBUG] Closed File Systems for /Users/victor/Documents/GitHub/TheMightyArchitectury/common/build/libs/mightyarchitect-0.8.0.jar
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,9 @@ classes/
.metadata
.vscode
.settings
*.launch
*.launch
*.log
common/.DS_Store
.DS_Store
*.log
.architectury-transformer/debug.log
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class MightyClient {
public static SchematicRenderer renderer = new SchematicRenderer();
public static Outliner outliner = new Outliner();

public static boolean irisEnabled;

public static void init() {
AllItems.initColorHandlers();
String modName = TheMightyArchitect.NAME;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.utils.EnvExecutor;
import net.fabricmc.api.EnvType;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.Registry;
import net.minecraft.world.item.Item;
import net.minecraft.world.level.block.Block;
import org.apache.logging.log4j.LogManager;
Expand All @@ -16,8 +16,8 @@ public class TheMightyArchitect {
public static final String ID = "mightyarchitect";
public static final String NAME = "The Mighty Architect";

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ID, Registries.ITEM);
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ID, Registries.BLOCK);
public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ID, Registry.ITEM_REGISTRY);
public static final DeferredRegister<Block> BLOCKS = DeferredRegister.create(ID, Registry.BLOCK_REGISTRY);

public static TheMightyArchitect instance;
public static Logger logger = LogManager.getLogger();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.timmie.mightyarchitect.control.design.DesignSlice.DesignSliceTrait;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction.Axis;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.InteractionResult;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -55,7 +55,7 @@ public InteractionResult use(BlockState state, Level worldIn, BlockPos pos, Play
DesignSliceTrait currentTrait = state.getValue(VARIANT);
DesignSliceTrait newTrait = currentTrait.cycle(player.isShiftKeyDown() ? -1 : 1);
worldIn.setBlockAndUpdate(pos, state.setValue(VARIANT, newTrait));
player.displayClientMessage(Component.literal(newTrait.getDescription()), true);
player.displayClientMessage(new TextComponent(newTrait.getDescription()), true);

return InteractionResult.SUCCESS;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.timmie.mightyarchitect.control.palette.Palette;
import com.timmie.mightyarchitect.networking.SetHotbarItemPacket;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -83,7 +83,7 @@ private static void setHotbarBlock(int slot, Palette palette) {
BlockState state = DesignExporter.theme.getDefaultPalette().get(palette);
ItemStack stack = new ItemStack(state.getBlock().asItem());
setHotbarItem(slot,
stack.setHoverName(Component.literal(ChatFormatting.RESET + "" + ChatFormatting.GOLD
stack.setHoverName(new TextComponent(ChatFormatting.RESET + "" + ChatFormatting.GOLD
+ palette.getDisplayName() + ChatFormatting.WHITE + " (" + ChatFormatting.GRAY
+ stack.getHoverName().getString() + ChatFormatting.WHITE + ")")));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtIo;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.InteractionHand;
import net.minecraft.world.entity.player.Player;
import org.apache.commons.io.IOUtils;
Expand Down Expand Up @@ -171,14 +171,14 @@ public static void writeToFile(String name) {
BlockPos pos = model.getAnchor()
.offset(((TemplateBlockAccess) model.getMaterializedSketch()).getBounds()
.getOrigin());
Component component = Component.literal("Deploy Schematic at: " + ChatFormatting.BLUE + "["
TextComponent component = new TextComponent("Deploy Schematic at: " + ChatFormatting.BLUE + "["
+ pos.getX() + "," + pos.getY() + "," + pos.getZ() + "]");
Minecraft.getInstance().player.displayClientMessage(component, false);
unload();
}

public static void status(String message) {
Minecraft.getInstance().player.displayClientMessage(Component.literal(message), true);
Minecraft.getInstance().player.displayClientMessage(new TextComponent(message), true);
}

public static void pickPalette() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.timmie.mightyarchitect.control;

import com.timmie.mightyarchitect.MightyClient;

import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
Expand Down Expand Up @@ -102,7 +104,9 @@ private void redraw(Minecraft minecraft) {
continue;

if (!buffers.containsKey(blockRenderLayer))
buffers.put(blockRenderLayer, new BufferBuilder(DefaultVertexFormat.BLOCK.getIntegerSize()));
{
buffers.put(blockRenderLayer, new BufferBuilder(MightyClient.irisEnabled?262144:DefaultVertexFormat.BLOCK.getIntegerSize()));
}

BufferBuilder bufferBuilder = buffers.get(blockRenderLayer);
if (startedBufferBuilders.add(blockRenderLayer))
Expand All @@ -124,8 +128,8 @@ private void redraw(Minecraft minecraft) {
if (!startedBufferBuilders.contains(layer))
continue;
BufferBuilder buf = buffers.get(layer);
var renderedBuffer = buf.end();
bufferCache.put(layer, new SuperByteBuffer(renderedBuffer));
buf.end();
bufferCache.put(layer, new SuperByteBuffer(buf));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import com.timmie.mightyarchitect.control.compose.Cuboid;
import com.timmie.mightyarchitect.foundation.WrappedWorld;
import com.timmie.mightyarchitect.foundation.utility.Iterate;
import net.minecraft.client.Minecraft;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.core.Holder;
import net.minecraft.core.particles.ParticleOptions;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.Registry;
import net.minecraft.sounds.SoundEvent;
import net.minecraft.sounds.SoundSource;
import net.minecraft.util.RandomSource;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.LightLayer;
Expand All @@ -22,7 +22,6 @@
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap.Types;
import net.minecraft.world.level.material.Fluid;
import net.minecraft.world.level.redstone.NeighborUpdater;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.ticks.BlackholeTickAccess;
import net.minecraft.world.ticks.LevelTickAccess;
Expand Down Expand Up @@ -55,16 +54,17 @@ private void updateBlockstates() {
BlockState blockState = blocks.get(pos);
if (blockState == null)
return;
blockState.updateNeighbourShapes(this, pos.offset(anchor), 16);
BlockPos targetPos = pos.offset(anchor);
BlockState newState = blockState;
for (Direction direction : Iterate.directions) {
BlockPos relative = targetPos.relative(direction);
newState = newState.updateShape(direction, getBlockState(relative), this, targetPos, relative);
}
if (newState != blockState)
setBlock(targetPos, newState, 0);
});
}

@Override
// revert to original neighbor shape behavior
public void neighborShapeChanged(Direction direction, BlockState blockState, BlockPos blockPos, BlockPos blockPos2, int i, int j) {
NeighborUpdater.executeShapeUpdate(this, direction, blockState, blockPos, blockPos2, i, j - 1);
}

public Set<BlockPos> getAllPositions() {
return blocks.keySet();
}
Expand All @@ -90,7 +90,7 @@ public Map<BlockPos, BlockState> getBlockMap() {

@Override
public Holder<Biome> getBiome(BlockPos pos) {
return Holder.direct(registryAccess().registryOrThrow(Registries.BIOME).get(Biomes.THE_VOID));
return Holder.direct(registryAccess().registryOrThrow(Registry.BIOME_REGISTRY).get(Biomes.THE_VOID));
}

@Override
Expand Down Expand Up @@ -166,8 +166,8 @@ public LevelTickAccess<Fluid> getFluidTicks() {
}

@Override
public RandomSource getRandom() {
return RandomSource.create();
public Random getRandom() {
return new Random();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.Mth;
import org.lwjgl.glfw.GLFW;

Expand Down Expand Up @@ -114,7 +114,7 @@ public void renderOverlay(PoseStack ms) {
}

protected void status(String message) {
Minecraft.getInstance().player.displayClientMessage(Component.literal(message), true);
Minecraft.getInstance().player.displayClientMessage(new TextComponent(message), true);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.SignBlockEntity;
Expand Down Expand Up @@ -112,7 +113,7 @@ public static String exportDesign(Level worldIn, BlockPos anchor) {

if (block == null && blockState.getBlock() != Blocks.AIR) {
Minecraft.getInstance().player.displayClientMessage(
Component.literal(blockState.getBlock()
new TextComponent(blockState.getBlock()
.getDescriptionId() + " @" + pos.getX() + "," + pos.getY() + "," + pos.getZ()
+ " does not belong to the Scanner Palette"), false);
return "Export failed";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.timmie.mightyarchitect.foundation.utility.DesignHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;

import java.util.Random;

Expand Down Expand Up @@ -177,7 +178,7 @@ public void sendToPlayer() {
}

private void chat(String message) {
Minecraft.getInstance().player.displayClientMessage(Component.literal(message), false);
Minecraft.getInstance().player.displayClientMessage(new TextComponent(message), false);
}

public DesignType fallbackRoof(Room room, boolean tower) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;

import java.util.ArrayList;
import java.util.LinkedList;
Expand All @@ -18,8 +19,8 @@ public class ThemeValidator {
public static void check(DesignTheme theme) {
LocalPlayer player = Minecraft.getInstance().player;
for (int i = 0; i < 3; i++)
player.displayClientMessage(Component.literal(" "), false);
player.displayClientMessage(Component.literal(ChatFormatting.AQUA + "--> Validation on "
player.displayClientMessage(new TextComponent(" "), false);
player.displayClientMessage(new TextComponent(ChatFormatting.AQUA + "--> Validation on "
+ ChatFormatting.BLUE + ChatFormatting.BOLD + theme.getDisplayName() + ChatFormatting.AQUA + " <--"),
false);
theme.clearDesigns();
Expand Down Expand Up @@ -142,18 +143,18 @@ public static void check(DesignTheme theme) {

if (complaints.size() > 0) {
player.displayClientMessage(
Component.literal(ChatFormatting.GOLD + "The Following Designs are missing:"), false);
new TextComponent(ChatFormatting.GOLD + "The Following Designs are missing:"), false);
for (Component text : complaints) {
player.displayClientMessage(text, false);
}
player.displayClientMessage(
Component.literal(
new TextComponent(
ChatFormatting.GOLD + "Try and add these missing designs or exclude their type from your theme."),
false);

} else {
player.displayClientMessage(
Component.literal(ChatFormatting.GREEN + "For prior traits no missing designs have been found."),
new TextComponent(ChatFormatting.GREEN + "For prior traits no missing designs have been found."),
false);
}

Expand All @@ -164,7 +165,7 @@ private static boolean exists(DesignQuery query) {
}

private static void alert(String message) {
complaints.add(Component.literal("-> " + ChatFormatting.RED + message));
complaints.add(new TextComponent("-> " + ChatFormatting.RED + message));
}

private static String glue(List<Integer> heights) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.core.Direction;
import net.minecraft.core.Direction.Axis;
import net.minecraft.core.registries.Registries;
import net.minecraft.core.Registry;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.world.level.block.Block;
Expand Down Expand Up @@ -123,15 +123,13 @@ public CompoundTag writeToNBT(CompoundTag compound) {
public static PaletteDefinition fromNBT(CompoundTag compound) {
PaletteDefinition palette = defaultPalette().clone();

var holderGetter = Minecraft.getInstance().level.holderLookup(Registries.BLOCK);

if (compound != null) {
if (compound.contains("Palette")) {
CompoundTag paletteTag = compound.getCompound("Palette");
palette.name = paletteTag.getString("Name");
for (Palette key : Palette.values()) {
if (paletteTag.contains(key.name())) {
palette.put(key, NbtUtils.readBlockState(holderGetter, paletteTag.getCompound(key.name())));
palette.put(key, NbtUtils.readBlockState(paletteTag.getCompound(key.name())));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.timmie.mightyarchitect.control.Schematic;
import net.minecraft.client.Minecraft;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;

public abstract class PhaseBase implements IArchitectPhase {

Expand Down Expand Up @@ -34,7 +35,7 @@ protected void sendStatusMessage(String message) {
if (message == null)
return;

minecraft.player.displayClientMessage(Component.literal(message), true);
minecraft.player.displayClientMessage(new TextComponent(message), true);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.core.BlockPos;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.world.level.block.TrapDoorBlock;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.levelgen.Heightmap;
Expand Down Expand Up @@ -114,7 +115,7 @@ public void whenExited() {

protected void notifyChange() {
getModel().updatePalettePreview();
minecraft.player.displayClientMessage(Component.literal("Updating Preview..."), true);
minecraft.player.displayClientMessage(new TextComponent("Updating Preview..."), true);
MightyClient.renderer.update();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;

import java.util.List;

Expand All @@ -18,9 +19,9 @@ public void whenEntered() {
LocalPlayer player = Minecraft.getInstance().player;
if (player == null)
return;
player.displayClientMessage(Component.literal(
player.displayClientMessage(new TextComponent(
"The Mighty Architect was " + ChatFormatting.BOLD + "Paused" + ChatFormatting.RESET + "."), false);
player.displayClientMessage(Component.literal("You can continue composing with [" + ChatFormatting.AQUA
player.displayClientMessage(new TextComponent("You can continue composing with [" + ChatFormatting.AQUA
+ MightyClient.COMPOSE.getTranslatedKeyMessage()
.getString()
.toUpperCase()
Expand Down
Loading

0 comments on commit a301ce7

Please sign in to comment.