diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index d883c5a0a..c0dfdd3a9 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -1004,7 +1004,7 @@ public class AllBlocks { .register(); public static final BlockEntry COPPER_BLOCK = - REGISTRATE.block("copper_block", p -> new OxidizingBlock(p, 1 / 32f, true)) + REGISTRATE.block("copper_block", p -> new OxidizingBlock(p, 1 / 32f)) .initialProperties(() -> Blocks.IRON_BLOCK) .transform(tagBlockAndItem("storage_blocks/copper")) .transform(oxidizedItemModel()) @@ -1027,14 +1027,14 @@ public class AllBlocks { .transform(oxidizedBlockstate()) .register(); - public static final BlockEntry ZINC_BLOCK = REGISTRATE.block("zinc_block", p -> new MetalBlock(p, true)) + public static final BlockEntry ZINC_BLOCK = REGISTRATE.block("zinc_block", p -> new Block(p)) .initialProperties(() -> Blocks.IRON_BLOCK) .transform(tagBlockAndItem("storage_blocks/zinc")) .build() .register(); - public static final BlockEntry BRASS_BLOCK = - REGISTRATE.block("brass_block", p -> new MetalBlock(p, true)) + public static final BlockEntry BRASS_BLOCK = + REGISTRATE.block("brass_block", p -> new Block(p)) .initialProperties(() -> Blocks.IRON_BLOCK) .transform(tagBlockAndItem("storage_blocks/brass")) .build() diff --git a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java index 420cad086..5b4509cc1 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java +++ b/src/main/java/com/simibubi/create/content/schematics/ClientSchematicLoader.java @@ -22,6 +22,7 @@ import com.simibubi.create.foundation.utility.FilesHelper; import com.simibubi.create.foundation.utility.Lang; import net.minecraft.client.Minecraft; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.StringTextComponent; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; @@ -31,7 +32,7 @@ public class ClientSchematicLoader { public static final int PACKET_DELAY = 10; - private List availableSchematics; + private List availableSchematics; private Map activeUploads; private int packetCycle; @@ -68,10 +69,8 @@ public class ClientSchematicLoader { // Too big Integer maxSize = AllConfigs.SERVER.schematics.maxTotalSchematicSize.get(); if (size > maxSize * 1000) { - Minecraft.getInstance().player.sendMessage(new StringTextComponent( - Lang.translate("schematics.uploadTooLarge") + " (" + size / 1000 + " KB).")); - Minecraft.getInstance().player.sendMessage( - new StringTextComponent(Lang.translate("schematics.maxAllowedSize") + " " + maxSize + " KB")); + Minecraft.getInstance().player.sendMessage(Lang.translate("schematics.uploadTooLarge").append(" (" + size / 1000 + " KB)."), Minecraft.getInstance().player.getUniqueID()); + Minecraft.getInstance().player.sendMessage(Lang.translate("schematics.maxAllowedSize").append(" " + maxSize + " KB"), Minecraft.getInstance().player.getUniqueID()); return; } @@ -126,7 +125,7 @@ public class ClientSchematicLoader { if (Files.isDirectory(path)) return; - availableSchematics.add(path.getFileName().toString()); + availableSchematics.add(ITextComponent.of(path.getFileName().toString())); }); } catch (NoSuchFileException e) { // No Schematics created yet @@ -136,7 +135,7 @@ public class ClientSchematicLoader { } - public List getAvailableSchematics() { + public List getAvailableSchematics() { return availableSchematics; } diff --git a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java index 1d8602b6c..7d75df83a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java +++ b/src/main/java/com/simibubi/create/content/schematics/ItemRequirement.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.block.*; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityType; @@ -49,7 +50,7 @@ public class ItemRequirement { Item item = BlockItem.BLOCK_TO_ITEM.getOrDefault(state.getBlock(), Items.AIR); // double slab needs two items - if (state.has(BlockStateProperties.SLAB_TYPE) && state.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) + if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.SLAB_TYPE) && state.get(BlockStateProperties.SLAB_TYPE) == SlabType.DOUBLE) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, 2))); if (block instanceof TurtleEggBlock) return new ItemRequirement(ItemUseType.CONSUME, Arrays.asList(new ItemStack(item, state.get(TurtleEggBlock.EGGS).intValue()))); diff --git a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java index 045511d4d..d4e05a2a3 100644 --- a/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java +++ b/src/main/java/com/simibubi/create/content/schematics/MaterialChecklist.java @@ -91,9 +91,9 @@ public class MaterialChecklist { Collections.sort(keys, (item1, item2) -> { Locale locale = Locale.ENGLISH; String name1 = - new TranslationTextComponent(((Item) item1).getTranslationKey()).getFormattedText().toLowerCase(locale); + new TranslationTextComponent(item1.getTranslationKey()).getFormattedText().toLowerCase(locale); String name2 = - new TranslationTextComponent(((Item) item2).getTranslationKey()).getFormattedText().toLowerCase(locale); + new TranslationTextComponent(item2.getTranslationKey()).getFormattedText().toLowerCase(locale); return name1.compareTo(name2); }); diff --git a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java index 67d55ce44..81478be86 100644 --- a/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java +++ b/src/main/java/com/simibubi/create/content/schematics/SchematicWorld.java @@ -8,6 +8,7 @@ import java.util.Map; import java.util.Set; import java.util.function.Predicate; +import com.simibubi.create.foundation.utility.BlockHelper; import com.simibubi.create.foundation.utility.worldWrappers.WrappedWorld; import net.minecraft.block.Block; @@ -24,14 +25,11 @@ import net.minecraft.tileentity.TileEntity; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MutableBoundingBox; -import net.minecraft.world.EmptyTickList; -import net.minecraft.world.ITickList; -import net.minecraft.world.LightType; -import net.minecraft.world.World; +import net.minecraft.world.*; import net.minecraft.world.biome.Biome; import net.minecraft.world.biome.Biomes; -public class SchematicWorld extends WrappedWorld { +public class SchematicWorld extends WrappedWorld implements IServerWorld { private Map blocks; private Map tileEntities; @@ -102,7 +100,7 @@ public class SchematicWorld extends WrappedWorld { return Blocks.GRASS_BLOCK.getDefaultState(); if (getBounds().isVecInside(pos) && blocks.containsKey(pos)) { BlockState blockState = blocks.get(pos); - if (blockState.has(BlockStateProperties.LIT)) + if (BlockHelper.hasBlockStateProperty(blockState, BlockStateProperties.LIT)) blockState = blockState.with(BlockStateProperties.LIT, false); return blockState; } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java index 9212c0aa5..452a05ac7 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableScreen.java @@ -1,5 +1,6 @@ package com.simibubi.create.content.schematics.block; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllBlocks; import com.simibubi.create.CreateClient; @@ -18,7 +19,9 @@ import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; +import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import java.nio.file.Paths; import java.util.List; @@ -35,11 +38,11 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = CreateClient.schematicSender.getAvailableSchematics(); + List availableSchematics = CreateClient.schematicSender.getAvailableSchematics(); schematicsLabel = new Label(mainLeft + 36, mainTop + 26, "").withShadow(); - schematicsLabel.text = ""; + schematicsLabel.text = StringTextComponent.EMPTY; if (!availableSchematics.isEmpty()) { schematicsArea = new SelectionScrollInput(mainLeft + 33, mainTop + 23, 134, 14).forOptions(availableSchematics) - .titled(availableSchematicsTitle) + .titled(availableSchematicsTitle.copy()) .writingTo(schematicsLabel); widgets.add(schematicsArea); widgets.add(schematicsLabel); @@ -83,13 +86,7 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); - String schematic = availableSchematics.get(schematicsArea.getState()); - schematicSender.startNewUpload(schematic); + List availableSchematics = schematicSender.getAvailableSchematics(); + ITextComponent schematic = availableSchematics.get(schematicsArea.getState()); + schematicSender.startNewUpload(schematic.getUnformattedComponentText()); } if (folderButton.isHovered()) { @@ -186,18 +182,18 @@ public class SchematicTableScreen extends AbstractSimiContainerScreen availableSchematics = schematicSender.getAvailableSchematics(); + List availableSchematics = schematicSender.getAvailableSchematics(); widgets.remove(schematicsArea); if (!availableSchematics.isEmpty()) { schematicsArea = new SelectionScrollInput(guiLeft - 56 + 33, guiTop - 16 + 23, 134, 14) .forOptions(availableSchematics) - .titled(availableSchematicsTitle) + .titled(availableSchematicsTitle.copy()) .writingTo(schematicsLabel); widgets.add(schematicsArea); } else { schematicsArea = null; - schematicsLabel.text = ""; + schematicsLabel.text = StringTextComponent.EMPTY; } } diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java index 0bbcc83a1..4479525fc 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicTableTileEntity.java @@ -2,6 +2,7 @@ package com.simibubi.create.content.schematics.block; import com.simibubi.create.foundation.tileEntity.SyncedTileEntity; +import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.inventory.container.Container; @@ -48,14 +49,14 @@ public class SchematicTableTileEntity extends SyncedTileEntity implements ITicka } @Override - public void read(CompoundNBT compound) { + public void fromTag(BlockState state, CompoundNBT compound) { inventory.deserializeNBT(compound.getCompound("Inventory")); - readClientUpdate(compound); - super.read(compound); + readClientUpdate(state, compound); + super.fromTag(state, compound); } @Override - public void readClientUpdate(CompoundNBT compound) { + public void readClientUpdate(BlockState state, CompoundNBT compound) { if (compound.contains("Uploading")) { isUploading = true; uploadingSchematic = compound.getString("Schematic"); diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java index e9e435b78..3918e3c65 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonScreen.java @@ -1,6 +1,7 @@ package com.simibubi.create.content.schematics.block; import com.google.common.collect.ImmutableList; +import com.mojang.blaze3d.matrix.MatrixStack; import com.simibubi.create.AllBlocks; import com.simibubi.create.content.schematics.packet.ConfigureSchematicannonPacket; import com.simibubi.create.content.schematics.packet.ConfigureSchematicannonPacket.Option; @@ -19,6 +20,7 @@ import net.minecraft.client.gui.widget.Widget; import net.minecraft.client.renderer.Rectangle2d; import net.minecraft.entity.player.PlayerInventory; import net.minecraft.item.ItemStack; +import net.minecraft.util.text.IFormattableTextComponent; import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TextFormatting; @@ -48,15 +50,15 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen extraAreas; - private final String title = Lang.translate("gui.schematicannon.title"); - private final String settingsTitle = Lang.translate("gui.schematicannon.settingsTitle"); - private final String listPrinter = Lang.translate("gui.schematicannon.listPrinter"); + private final ITextComponent title = Lang.translate("gui.schematicannon.title"); + private final ITextComponent settingsTitle = Lang.translate("gui.schematicannon.settingsTitle"); + private final ITextComponent listPrinter = Lang.translate("gui.schematicannon.listPrinter"); private final String _gunpowderLevel = "gui.schematicannon.gunpowderLevel"; private final String _shotsRemaining = "gui.schematicannon.shotsRemaining"; private final String _shotsRemainingWithBackup = "gui.schematicannon.shotsRemainingWithBackup"; - private final String optionEnabled = Lang.translate("gui.schematicannon.optionEnabled"); - private final String optionDisabled = Lang.translate("gui.schematicannon.optionDisabled"); + private final ITextComponent optionEnabled = Lang.translate("gui.schematicannon.optionEnabled"); + private final ITextComponent optionDisabled = Lang.translate("gui.schematicannon.optionDisabled"); private final ItemStack renderedItem = AllBlocks.SCHEMATICANNON.asStack(); @@ -92,7 +94,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen icons = ImmutableList .of(AllIcons.I_DONT_REPLACE, AllIcons.I_REPLACE_SOLID, AllIcons.I_REPLACE_ANY, AllIcons.I_REPLACE_EMPTY); - List toolTips = ImmutableList + List toolTips = ImmutableList .of(Lang.translate("gui.schematicannon.option.dontReplaceSolid"), Lang.translate("gui.schematicannon.option.replaceWithSolid"), Lang.translate("gui.schematicannon.option.replaceWithAny"), @@ -190,8 +192,8 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen tip = button.getToolTip(); - tip.add(TextFormatting.BLUE + (enabled ? optionEnabled : optionDisabled)); + List tip = button.getToolTip(); + tip.add((enabled ? optionEnabled : optionDisabled).copy().formatted(TextFormatting.BLUE)); tip .addAll(TooltipHelper .cutString(Lang.translate("gui.schematicannon.option." + tooltipKey + ".description"), GRAY, @@ -199,14 +201,14 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen= fuelX && mouseY >= fuelY && mouseX <= fuelX + AllGuiTextures.SCHEMATICANNON_FUEL.width @@ -300,16 +302,16 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen= missingBlockX && mouseY >= missingBlockY && mouseX <= missingBlockX + 16 && mouseY <= missingBlockY + 16) { - renderTooltip(te.missingItem, mouseX, mouseY); + renderTooltip(matrixStack, te.missingItem, mouseX, mouseY); } } int paperX = guiLeft + 20 + 202, paperY = guiTop + 20; if (mouseX >= paperX && mouseY >= paperY && mouseX <= paperX + 16 && mouseY <= paperY + 16) { - renderTooltip(listPrinter, mouseX, mouseY); + renderTooltip(matrixStack, listPrinter, mouseX, mouseY); } - super.renderWindowForeground(mouseX, mouseY, partialTicks); + super.renderWindowForeground(matrixStack, mouseX, mouseY, partialTicks); } @Override diff --git a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java index c17657e8e..d342f2b78 100644 --- a/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java +++ b/src/main/java/com/simibubi/create/content/schematics/block/SchematicannonTileEntity.java @@ -694,9 +694,9 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC boolean placingAir = state.getBlock() == Blocks.AIR; BlockState toReplaceOther = null; - if (state.has(BlockStateProperties.BED_PART) && state.has(BlockStateProperties.HORIZONTAL_FACING) && state.get(BlockStateProperties.BED_PART) == BedPart.FOOT) + if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.BED_PART) && BlockHelper.hasBlockStateProperty(state, BlockStateProperties.HORIZONTAL_FACING) && state.get(BlockStateProperties.BED_PART) == BedPart.FOOT) toReplaceOther = world.getBlockState(pos.offset(state.get(BlockStateProperties.HORIZONTAL_FACING))); - if (state.has(BlockStateProperties.DOUBLE_BLOCK_HALF) + if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.DOUBLE_BLOCK_HALF) && state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.LOWER) toReplaceOther = world.getBlockState(pos.up()); @@ -739,10 +739,10 @@ public class SchematicannonTileEntity extends SmartTileEntity implements INamedC return true; // Block doesnt need to be placed twice (Doors, beds, double plants) - if (state.has(BlockStateProperties.DOUBLE_BLOCK_HALF) + if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.DOUBLE_BLOCK_HALF) && state.get(BlockStateProperties.DOUBLE_BLOCK_HALF) == DoubleBlockHalf.UPPER) return true; - if (state.has(BlockStateProperties.BED_PART) && state.get(BlockStateProperties.BED_PART) == BedPart.HEAD) + if (BlockHelper.hasBlockStateProperty(state, BlockStateProperties.BED_PART) && state.get(BlockStateProperties.BED_PART) == BedPart.HEAD) return true; if (state.getBlock() instanceof PistonHeadBlock) return true; diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java index 7b581e7f5..6f717296d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicAndQuillHandler.java @@ -207,7 +207,7 @@ public class SchematicAndQuillHandler { new BlockPos(bb.getXSize(), bb.getYSize(), bb.getZSize()), true, Blocks.AIR); if (string.isEmpty()) - string = Lang.translate("schematicAndQuill.fallbackName"); + string = Lang.translate("schematicAndQuill.fallbackName").getUnformattedComponentText(); String folderPath = "schematics"; FilesHelper.createFolderIfMissing(folderPath); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java index 1f1c91ea4..6f0b73d73 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicEditScreen.java @@ -3,6 +3,7 @@ package com.simibubi.create.content.schematics.client; import java.util.Collections; import java.util.List; +import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import com.simibubi.create.AllItems; import com.simibubi.create.CreateClient; @@ -19,6 +20,9 @@ import net.minecraft.nbt.NBTUtil; import net.minecraft.util.Mirror; import net.minecraft.util.Rotation; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TranslationTextComponent; import net.minecraft.world.gen.feature.template.PlacementSettings; public class SchematicEditScreen extends AbstractSimiScreen { @@ -27,13 +31,13 @@ public class SchematicEditScreen extends AbstractSimiScreen { private TextFieldWidget yInput; private TextFieldWidget zInput; - private final List rotationOptions = + private final List rotationOptions = Lang.translatedOptions("schematic.rotation", "none", "cw90", "cw180", "cw270"); - private final List mirrorOptions = + private final List mirrorOptions = Lang.translatedOptions("schematic.mirror", "none", "leftRight", "frontBack"); - private final String positionLabel = Lang.translate("schematic.position"); - private final String rotationLabel = Lang.translate("schematic.rotation"); - private final String mirrorLabel = Lang.translate("schematic.mirror"); + private final ITextComponent positionLabel = Lang.translate("schematic.position"); + private final ITextComponent rotationLabel = Lang.translate("schematic.rotation"); + private final ITextComponent mirrorLabel = Lang.translate("schematic.mirror"); private ScrollInput rotationArea; private ScrollInput mirrorArea; @@ -46,9 +50,9 @@ public class SchematicEditScreen extends AbstractSimiScreen { int y = guiTop; handler = CreateClient.schematicHandler; - xInput = new TextFieldWidget(font, x + 75, y + 32, 32, 10, ""); - yInput = new TextFieldWidget(font, x + 115, y + 32, 32, 10, ""); - zInput = new TextFieldWidget(font, x + 155, y + 32, 32, 10, ""); + xInput = new TextFieldWidget(textRenderer, x + 75, y + 32, 32, 10, StringTextComponent.EMPTY); + yInput = new TextFieldWidget(textRenderer, x + 115, y + 32, 32, 10, StringTextComponent.EMPTY); + zInput = new TextFieldWidget(textRenderer, x + 155, y + 32, 32, 10, StringTextComponent.EMPTY); BlockPos anchor = handler.getTransformation().getAnchor(); if (handler.isDeployed()) { @@ -56,7 +60,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { yInput.setText("" + anchor.getY()); zInput.setText("" + anchor.getZ()); } else { - BlockPos alt = minecraft.player.getPosition(); + BlockPos alt = client.player.getBlockPos(); xInput.setText("" + alt.getX()); yInput.setText("" + alt.getY()); zInput.setText("" + alt.getZ()); @@ -82,11 +86,11 @@ public class SchematicEditScreen extends AbstractSimiScreen { PlacementSettings settings = handler.getTransformation().toSettings(); Label labelR = new Label(x + 99, y + 52, "").withShadow(); - rotationArea = new SelectionScrollInput(x + 96, y + 49, 94, 14).forOptions(rotationOptions).titled("Rotation") + rotationArea = new SelectionScrollInput(x + 96, y + 49, 94, 14).forOptions(rotationOptions).titled(new StringTextComponent("Rotation")) .setState(settings.getRotation().ordinal()).writingTo(labelR); Label labelM = new Label(x + 99, y + 72, "").withShadow(); - mirrorArea = new SelectionScrollInput(x + 96, y + 69, 94, 14).forOptions(mirrorOptions).titled("Mirror") + mirrorArea = new SelectionScrollInput(x + 96, y + 69, 94, 14).forOptions(mirrorOptions).titled(new StringTextComponent("Mirror")) .setState(settings.getMirror().ordinal()).writingTo(labelM); Collections.addAll(widgets, xInput, yInput, zInput); @@ -99,7 +103,7 @@ public class SchematicEditScreen extends AbstractSimiScreen { public boolean keyPressed(int code, int p_keyPressed_2_, int p_keyPressed_3_) { if (isPaste(code)) { - String coords = minecraft.keyboardListener.getClipboardString(); + String coords = client.keyboardListener.getClipboardString(); if (coords != null && !coords.isEmpty()) { coords.replaceAll(" ", ""); String[] split = coords.split(","); @@ -126,17 +130,17 @@ public class SchematicEditScreen extends AbstractSimiScreen { } @Override - protected void renderWindow(int mouseX, int mouseY, float partialTicks) { + protected void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { int x = guiLeft; int y = guiTop; AllGuiTextures.SCHEMATIC.draw(this, x, y); - font.drawStringWithShadow(handler.getCurrentSchematicName(), - x + 103 - font.getStringWidth(handler.getCurrentSchematicName()) / 2, y + 10, 0xDDEEFF); + textRenderer.drawWithShadow(matrixStack, handler.getCurrentSchematicName(), + x + 103 - textRenderer.getStringWidth(handler.getCurrentSchematicName()) / 2, y + 10, 0xDDEEFF); - font.drawString(positionLabel, x + 10, y + 32, AllGuiTextures.FONT_COLOR); - font.drawString(rotationLabel, x + 10, y + 52, AllGuiTextures.FONT_COLOR); - font.drawString(mirrorLabel, x + 10, y + 72, AllGuiTextures.FONT_COLOR); + textRenderer.draw(matrixStack, positionLabel, x + 10, y + 32, AllGuiTextures.FONT_COLOR); + textRenderer.draw(matrixStack, rotationLabel, x + 10, y + 52, AllGuiTextures.FONT_COLOR); + textRenderer.draw(matrixStack, mirrorLabel, x + 10, y + 72, AllGuiTextures.FONT_COLOR); RenderSystem.pushMatrix(); RenderSystem.translated(guiLeft + 220, guiTop + 20, 0); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java index 632108933..bb71bfc70 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/SchematicHandler.java @@ -127,11 +127,11 @@ public class SchematicHandler { SchematicWorld wMirroredLR = new SchematicWorld(clientWorld); PlacementSettings placementSettings = new PlacementSettings(); - schematic.addBlocksToWorld(w, BlockPos.ZERO, placementSettings); + schematic.place(w, BlockPos.ZERO, placementSettings); placementSettings.setMirror(Mirror.FRONT_BACK); - schematic.addBlocksToWorld(wMirroredFB, BlockPos.ZERO.east(size.getX() - 1), placementSettings); + schematic.place(wMirroredFB, BlockPos.ZERO.east(size.getX() - 1), placementSettings); placementSettings.setMirror(Mirror.LEFT_RIGHT); - schematic.addBlocksToWorld(wMirroredLR, BlockPos.ZERO.south(size.getZ() - 1), placementSettings); + schematic.place(wMirroredLR, BlockPos.ZERO.south(size.getZ() - 1), placementSettings); renderers.get(0) .display(w); diff --git a/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java b/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java index 45da5bc11..ebeb232eb 100644 --- a/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java +++ b/src/main/java/com/simibubi/create/content/schematics/client/tools/Tools.java @@ -6,6 +6,7 @@ import java.util.List; import com.simibubi.create.foundation.gui.AllIcons; import com.simibubi.create.foundation.utility.Lang; +import net.minecraft.util.text.TranslationTextComponent; public enum Tools { @@ -28,7 +29,7 @@ public enum Tools { return tool; } - public String getDisplayName() { + public TranslationTextComponent getDisplayName() { return Lang.translate("schematic.tool." + Lang.asId(name())); } @@ -44,7 +45,7 @@ public enum Tools { return tools; } - public List getDescription() { + public List getDescription() { return Lang.translatedOptions("schematic.tool." + Lang.asId(name()) + ".description", "0", "1", "2", "3"); } diff --git a/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java b/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java index 521d74a2e..0f7571a0a 100644 --- a/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java +++ b/src/main/java/com/simibubi/create/content/schematics/item/SchematicItem.java @@ -77,7 +77,7 @@ public class SchematicItem extends Item { tooltip.add(new StringTextComponent(TextFormatting.GOLD + stack.getTag() .getString("File"))); } else { - tooltip.add(new StringTextComponent(TextFormatting.RED + Lang.translate("schematic.invalid"))); + tooltip.add(Lang.translate("schematic.invalid").formatted(TextFormatting.RED)); } super.addInformation(stack, worldIn, tooltip, flagIn); } diff --git a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java index 869f966f1..2a5153d4d 100644 --- a/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java +++ b/src/main/java/com/simibubi/create/content/schematics/packet/SchematicPlacePacket.java @@ -37,7 +37,7 @@ public class SchematicPlacePacket extends SimplePacketBase { Template t = SchematicItem.loadSchematic(stack); PlacementSettings settings = SchematicItem.getSettings(stack); settings.setIgnoreEntities(false); - t.addBlocksToWorld(player.getServerWorld(), NBTUtil.readBlockPos(stack.getTag().getCompound("Anchor")), + t.place(player.getServerWorld(), NBTUtil.readBlockPos(stack.getTag().getCompound("Anchor")), settings); }); context.get().setPacketHandled(true); diff --git a/src/main/java/com/simibubi/create/events/CommonEvents.java b/src/main/java/com/simibubi/create/events/CommonEvents.java index 7f3d5bf74..c5fedd175 100644 --- a/src/main/java/com/simibubi/create/events/CommonEvents.java +++ b/src/main/java/com/simibubi/create/events/CommonEvents.java @@ -68,7 +68,7 @@ public class CommonEvents { @SubscribeEvent public static void serverStarted(FMLServerStartingEvent event) { - AllCommands.register(event.getCommandDispatcher()); + AllCommands.register(event.getServer().getCommandManager().getDispatcher()); } @SubscribeEvent diff --git a/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java b/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java index 27a52be14..1828b927d 100644 --- a/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java +++ b/src/main/java/com/simibubi/create/foundation/gui/TextInputPromptScreen.java @@ -2,6 +2,9 @@ package com.simibubi.create.foundation.gui; import java.util.function.Consumer; +import com.mojang.blaze3d.matrix.MatrixStack; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; import org.lwjgl.glfw.GLFW; import com.simibubi.create.foundation.utility.Lang; @@ -11,8 +14,8 @@ import net.minecraft.client.gui.widget.button.Button; public class TextInputPromptScreen extends AbstractSimiScreen { - private final String defaultConfirm = Lang.translate("action.confirm"); - private final String defaultAbort = Lang.translate("action.abort"); + private final ITextComponent defaultConfirm = Lang.translate("action.confirm"); + private final ITextComponent defaultAbort = Lang.translate("action.abort"); private Consumer callback; private Consumer abortCallback; @@ -21,9 +24,9 @@ public class TextInputPromptScreen extends AbstractSimiScreen { private Button confirm; private Button abort; - private String buttonTextConfirm; - private String buttonTextAbort; - private String title; + private ITextComponent buttonTextConfirm; + private ITextComponent buttonTextAbort; + private ITextComponent title; private boolean confirmed; @@ -42,7 +45,7 @@ public class TextInputPromptScreen extends AbstractSimiScreen { super.init(); setWindowSize(AllGuiTextures.TEXT_INPUT.width, AllGuiTextures.TEXT_INPUT.height + 30); - this.nameField = new TextFieldWidget(font, guiLeft + 33, guiTop + 26, 128, 8, ""); + this.nameField = new TextFieldWidget(textRenderer, guiLeft + 33, guiTop + 26, 128, 8, StringTextComponent.EMPTY); this.nameField.setTextColor(-1); this.nameField.setDisabledTextColour(-1); this.nameField.setEnableBackgroundDrawing(false); @@ -52,11 +55,11 @@ public class TextInputPromptScreen extends AbstractSimiScreen { confirm = new Button(guiLeft - 5, guiTop + 50, 100, 20, buttonTextConfirm, button -> { callback.accept(nameField.getText()); confirmed = true; - minecraft.displayGuiScreen(null); + client.displayGuiScreen(null); }); abort = new Button(guiLeft + 100, guiTop + 50, 100, 20, buttonTextAbort, button -> { - minecraft.displayGuiScreen(null); + client.displayGuiScreen(null); }); widgets.add(confirm); @@ -65,9 +68,9 @@ public class TextInputPromptScreen extends AbstractSimiScreen { } @Override - public void renderWindow(int mouseX, int mouseY, float partialTicks) { + public void renderWindow(MatrixStack matrixStack, int mouseX, int mouseY, float partialTicks) { AllGuiTextures.TEXT_INPUT.draw(this, guiLeft, guiTop); - font.drawString(title, guiLeft + (sWidth / 2) - (font.getStringWidth(title) / 2), guiTop + 11, + textRenderer.draw(matrixStack, title, guiLeft + (sWidth / 2) - (textRenderer.getWidth(title) / 2), guiTop + 11, AllGuiTextures.FONT_COLOR); } @@ -78,15 +81,15 @@ public class TextInputPromptScreen extends AbstractSimiScreen { super.removed(); } - public void setButtonTextConfirm(String buttonTextConfirm) { + public void setButtonTextConfirm(ITextComponent buttonTextConfirm) { this.buttonTextConfirm = buttonTextConfirm; } - public void setButtonTextAbort(String buttonTextAbort) { + public void setButtonTextAbort(ITextComponent buttonTextAbort) { this.buttonTextAbort = buttonTextAbort; } - public void setTitle(String title) { + public void setTitle(ITextComponent title) { this.title = title; } diff --git a/src/main/java/com/simibubi/create/foundation/utility/Lang.java b/src/main/java/com/simibubi/create/foundation/utility/Lang.java index 85db137ba..11e5aeb6a 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/Lang.java +++ b/src/main/java/com/simibubi/create/foundation/utility/Lang.java @@ -7,6 +7,7 @@ import java.util.Locale; import com.simibubi.create.Create; import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.TranslationTextComponent; public class Lang { @@ -23,8 +24,8 @@ public class Lang { player.sendStatusMessage(createTranslationTextComponent(key, args), true); } - public static List translatedOptions(String prefix, String... keys) { - List result = new ArrayList<>(keys.length); + public static List translatedOptions(String prefix, String... keys) { + List result = new ArrayList<>(keys.length); for (String key : keys) { result.add(translate(prefix + "." + key)); } diff --git a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java index cf049fc81..028e9b3d3 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java +++ b/src/main/java/com/simibubi/create/foundation/utility/worldWrappers/WrappedWorld.java @@ -4,6 +4,7 @@ import java.util.Collections; import java.util.List; import java.util.function.Predicate; +import mcp.MethodsReturnNonnullByDefault; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -11,16 +12,23 @@ import net.minecraft.entity.player.PlayerEntity; import net.minecraft.fluid.Fluid; import net.minecraft.item.crafting.RecipeManager; import net.minecraft.scoreboard.Scoreboard; -import net.minecraft.tags.NetworkTagManager; +import net.minecraft.tags.ITagCollectionSupplier; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.Direction; import net.minecraft.util.SoundCategory; import net.minecraft.util.SoundEvent; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.registry.DynamicRegistries; import net.minecraft.world.ITickList; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraft.world.chunk.AbstractChunkProvider; import net.minecraft.world.storage.MapData; +import javax.annotation.ParametersAreNonnullByDefault; + +@MethodsReturnNonnullByDefault +@ParametersAreNonnullByDefault public class WrappedWorld extends World { protected World world; @@ -76,6 +84,11 @@ public class WrappedWorld extends World { return world.getPendingFluidTicks(); } + @Override + public AbstractChunkProvider getChunkProvider() { + return null; + } + @Override public void playEvent(PlayerEntity player, int type, BlockPos pos, int data) {} @@ -113,7 +126,7 @@ public class WrappedWorld extends World { @Override public int getNextMapId() { - return 0; + return world.getNextMapId(); } @Override @@ -130,18 +143,22 @@ public class WrappedWorld extends World { } @Override - public NetworkTagManager getTags() { + public ITagCollectionSupplier getTags() { return world.getTags(); } - @Override - public int getMaxHeight() { - return 256; - } - @Override public Biome getGeneratorStoredBiome(int p_225604_1_, int p_225604_2_, int p_225604_3_) { return world.getGeneratorStoredBiome(p_225604_1_, p_225604_2_, p_225604_3_); } + @Override + public DynamicRegistries getRegistryManager() { + return world.getRegistryManager(); + } + + @Override + public float getBrightness(Direction p_230487_1_, boolean p_230487_2_) { + return world.getBrightness(p_230487_1_, p_230487_2_); + } } diff --git a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java index bd799f370..bf3594f7e 100644 --- a/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java +++ b/src/main/java/com/simibubi/create/foundation/worldgen/OxidizingBlock.java @@ -1,6 +1,7 @@ package com.simibubi.create.foundation.worldgen; import com.simibubi.create.content.curiosities.tools.SandPaperItem; +import com.simibubi.create.foundation.utility.BlockHelper; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.player.PlayerEntity; @@ -19,7 +20,7 @@ import java.util.LinkedList; import java.util.OptionalDouble; import java.util.Random; -public class OxidizingBlock extends MetalBlock { +public class OxidizingBlock extends Block { public static final IntegerProperty OXIDIZATION = IntegerProperty.create("oxidization", 0, 7); private float chance; @@ -29,12 +30,6 @@ public class OxidizingBlock extends MetalBlock { this.chance = chance; setDefaultState(getDefaultState().with(OXIDIZATION, 0)); } - - public OxidizingBlock(Properties properties, float chance, boolean isBeaconBaseBlock) { - super(properties, isBeaconBaseBlock); - this.chance = chance; - setDefaultState(getDefaultState().with(OXIDIZATION, 0)); - } @Override protected void fillStateContainer(Builder builder) { @@ -62,7 +57,7 @@ public class OxidizingBlock extends MetalBlock { if (neighborState.func_235903_d_(OXIDIZATION).map(ox -> ox != 0).orElse(false)) { neighbors.add(neighborState.get(OXIDIZATION)); } - if (Block.hasSolidSide(neighborState, worldIn, neighbourPos, facing.getOpposite())) { + if (BlockHelper.hasBlockSolidSide(neighborState, worldIn, neighbourPos, facing.getOpposite())) { continue; } canIncrease = true;