Update to 1.17.1

This commit is contained in:
Marcel Konrad
2021-07-26 00:49:42 +02:00
parent cd058e9582
commit ea35dcb6f3
134 changed files with 1711 additions and 1809 deletions

View File

@@ -14,17 +14,17 @@ import exopandora.worldhandler.gui.container.impl.GuiWorldHandler;
import exopandora.worldhandler.gui.content.Content;
import exopandora.worldhandler.gui.content.Contents;
import exopandora.worldhandler.gui.content.impl.ContentChild;
import net.minecraft.block.AbstractSignBlock;
import net.minecraft.block.NoteBlock;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.util.Util;
import net.minecraft.util.text.ChatType;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.ChatType;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.world.Difficulty;
import net.minecraft.world.level.block.NoteBlock;
import net.minecraft.world.level.block.SignBlock;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -157,8 +157,8 @@ public class ActionHelper
Minecraft.getInstance().setScreen(null);
Minecraft.getInstance().mouseHandler.grabMouse();
ITextComponent message = new TranslationTextComponent("<" + Main.NAME + "> %s", new TranslationTextComponent("worldhandler.error.gui")).withStyle(TextFormatting.RED);
ITextComponent cause = new StringTextComponent(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).withStyle(TextFormatting.RED);
Component message = new TranslatableComponent("<" + Main.NAME + "> %s", new TranslatableComponent("worldhandler.error.gui")).withStyle(ChatFormatting.RED);
Component cause = new TextComponent(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).withStyle(ChatFormatting.RED);
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, message, Util.NIL_UUID);
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, cause, Util.NIL_UUID);
@@ -171,14 +171,14 @@ public class ActionHelper
{
if(!CommandHelper.canPlayerIssueCommand() && Config.getSettings().permissionQuery())
{
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.get("worldhandler.permission.refused")), Util.NIL_UUID);
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.get("worldhandler.permission.refused.change", I18n.get("gui.worldhandler.config.settings.permission_query"))), Util.NIL_UUID);
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new TextComponent(ChatFormatting.RED + I18n.get("worldhandler.permission.refused")), Util.NIL_UUID);
Minecraft.getInstance().gui.handleChat(ChatType.SYSTEM, new TextComponent(ChatFormatting.RED + I18n.get("worldhandler.permission.refused.change", I18n.get("gui.worldhandler.config.settings.permission_query"))), Util.NIL_UUID);
}
else
{
ActionHelper.tryRun(() ->
{
if(BlockHelper.getFocusedBlock() instanceof AbstractSignBlock)
if(BlockHelper.getFocusedBlock() instanceof SignBlock)
{
ActionHelper.open(Contents.SIGN_EDITOR);
}

View File

@@ -7,40 +7,41 @@ import java.util.concurrent.Executor;
import java.util.stream.Collectors;
import net.minecraft.advancements.Advancement;
import net.minecraft.advancements.AdvancementManager;
import net.minecraft.client.Minecraft;
import net.minecraft.loot.LootPredicateManager;
import net.minecraft.profiler.IProfiler;
import net.minecraft.resources.IFutureReloadListener;
import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.IResourcePack;
import net.minecraft.resources.ResourcePackInfo;
import net.minecraft.resources.ResourcePackType;
import net.minecraft.resources.SimpleReloadableResourceManager;
import net.minecraft.tags.NetworkTagManager;
import net.minecraft.core.RegistryAccess;
import net.minecraft.server.ServerAdvancementManager;
import net.minecraft.server.packs.PackResources;
import net.minecraft.server.packs.PackType;
import net.minecraft.server.packs.repository.Pack;
import net.minecraft.server.packs.resources.PreparableReloadListener;
import net.minecraft.server.packs.resources.ResourceManager;
import net.minecraft.server.packs.resources.SimpleReloadableResourceManager;
import net.minecraft.tags.TagManager;
import net.minecraft.util.Unit;
import net.minecraft.util.profiling.ProfilerFiller;
import net.minecraft.world.level.storage.loot.PredicateManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class AdvancementHelper implements IFutureReloadListener
public class AdvancementHelper implements PreparableReloadListener
{
private static final AdvancementHelper INSTANCE = new AdvancementHelper();
private final AdvancementManager manager = new AdvancementManager(new LootPredicateManager());
private final ServerAdvancementManager manager = new ServerAdvancementManager(new PredicateManager());
@Override
public CompletableFuture<Void> reload(IStage stage, IResourceManager resourceManager, IProfiler preparationsProfiler, IProfiler reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)
public CompletableFuture<Void> reload(PreparationBarrier stage, ResourceManager resourceManager, ProfilerFiller preparationsProfiler, ProfilerFiller reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)
{
return CompletableFuture.supplyAsync(() ->
{
SimpleReloadableResourceManager serverResourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
serverResourceManager.registerReloadListener(new NetworkTagManager());
SimpleReloadableResourceManager serverResourceManager = new SimpleReloadableResourceManager(PackType.SERVER_DATA);
serverResourceManager.registerReloadListener(new TagManager(RegistryAccess.builtin()));
serverResourceManager.registerReloadListener(this.manager);
return serverResourceManager;
}).thenCompose(stage::wait).thenAcceptAsync(serverResourceManager ->
{
List<IResourcePack> list = Minecraft.getInstance().getResourcePackRepository().getSelectedPacks().stream().map(ResourcePackInfo::open).collect(Collectors.toList());
serverResourceManager.createFullReload(backgroundExecutor, gameExecutor, CompletableFuture.completedFuture(Unit.INSTANCE), list);
List<PackResources> list = Minecraft.getInstance().getResourcePackRepository().getSelectedPacks().stream().map(Pack::open).collect(Collectors.toList());
serverResourceManager.createReload(backgroundExecutor, gameExecutor, CompletableFuture.completedFuture(Unit.INSTANCE), list);
});
}

View File

@@ -17,18 +17,18 @@ import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.Coordinate.EnumType;
import exopandora.worldhandler.builder.types.CoordinateInt;
import exopandora.worldhandler.config.Config;
import net.minecraft.block.Block;
import net.minecraft.block.Blocks;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.network.play.client.CUpdateCommandBlockPacket;
import net.minecraft.state.properties.BlockStateProperties;
import net.minecraft.tileentity.CommandBlockTileEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.util.math.RayTraceResult.Type;
import net.minecraft.world.World;
import net.minecraft.client.player.LocalPlayer;
import net.minecraft.core.BlockPos;
import net.minecraft.network.protocol.game.ServerboundSetCommandBlockPacket;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.entity.CommandBlockEntity;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.phys.HitResult;
import net.minecraft.world.phys.HitResult.Type;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -44,20 +44,20 @@ public class BlockHelper
@Nonnull
public static BlockPos getFocusedBlockPos()
{
World world = Minecraft.getInstance().level;
RayTraceResult result = Minecraft.getInstance().hitResult;
Level level = Minecraft.getInstance().level;
HitResult result = Minecraft.getInstance().hitResult;
if(result != null && Type.BLOCK.equals(result.getType()) && world != null)
if(result != null && Type.BLOCK.equals(result.getType()) && level != null)
{
BlockRayTraceResult blockResult = (BlockRayTraceResult) result;
BlockHitResult blockResult = (BlockHitResult) result;
if(!ArrayUtils.contains(BLACKLIST, world.getBlockState(blockResult.getBlockPos()).getBlock()))
if(!ArrayUtils.contains(BLACKLIST, level.getBlockState(blockResult.getBlockPos()).getBlock()))
{
return blockResult.getBlockPos();
}
}
PlayerEntity player = Minecraft.getInstance().player;
LocalPlayer player = Minecraft.getInstance().player;
if(player != null)
{
@@ -76,11 +76,11 @@ public class BlockHelper
@Nonnull
public static Block getBlock(BlockPos pos)
{
World world = Minecraft.getInstance().level;
Level level = Minecraft.getInstance().level;
if(world != null)
if(level != null)
{
return world.getBlockState(pos).getBlock();
return level.getBlockState(pos).getBlock();
}
return Blocks.AIR;
@@ -194,8 +194,8 @@ public class BlockHelper
wrapped.setMode2(EnumMode.RUN);
wrapped.setCommand(command);
Minecraft.getInstance().getConnection().send(new CUpdateCommandBlockPacket(pos, wrapped.toActualCommand(), CommandBlockTileEntity.Mode.REDSTONE, true, false, true));
Minecraft.getInstance().getConnection().send(new CUpdateCommandBlockPacket(pos.above(), removeFill.toActualCommand(), CommandBlockTileEntity.Mode.REDSTONE, true, false, true));
Minecraft.getInstance().getConnection().send(new ServerboundSetCommandBlockPacket(pos, wrapped.toActualCommand(), CommandBlockEntity.Mode.REDSTONE, true, false, true));
Minecraft.getInstance().getConnection().send(new ServerboundSetCommandBlockPacket(pos.above(), removeFill.toActualCommand(), CommandBlockEntity.Mode.REDSTONE, true, false, true));
return true;
}

View File

@@ -8,16 +8,16 @@ import exopandora.worldhandler.builder.ICommandBuilderSyntax;
import exopandora.worldhandler.command.CommandWH;
import exopandora.worldhandler.command.CommandWorldHandler;
import net.minecraft.client.Minecraft;
import net.minecraft.command.CommandSource;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.TextComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class CommandHelper
{
public static void sendFeedback(CommandSource source, String message)
public static void sendFeedback(CommandSourceStack source, String message)
{
source.sendSuccess(new StringTextComponent(message), false);
source.sendSuccess(new TextComponent(message), false);
}
public static boolean canPlayerIssueCommand()
@@ -30,7 +30,7 @@ public class CommandHelper
return false;
}
public static void registerCommands(CommandDispatcher<CommandSource> dispatcher)
public static void registerCommands(CommandDispatcher<CommandSourceStack> dispatcher)
{
CommandWorldHandler.register(dispatcher);
CommandWH.register(dispatcher);

View File

@@ -1,8 +1,8 @@
package exopandora.worldhandler.util;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.world.WorldSettings;
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
import net.minecraft.world.level.LevelSettings;
import net.minecraft.world.level.levelgen.WorldGenSettings;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@@ -12,14 +12,14 @@ public interface IConnection
public static class IntegratedConnection implements IConnection
{
private final String folder;
private final WorldSettings worldSettings;
private final DimensionGeneratorSettings dimensionGeneratorSettings;
private final LevelSettings levelSettings;
private final WorldGenSettings worldGenSettings;
public IntegratedConnection(String folderName, WorldSettings worldSettings, DimensionGeneratorSettings dimensionGeneratorSettings)
public IntegratedConnection(String folderName, LevelSettings levelSettings, WorldGenSettings worldGenSettings)
{
this.folder = folderName;
this.worldSettings = worldSettings;
this.dimensionGeneratorSettings = dimensionGeneratorSettings;
this.levelSettings = levelSettings;
this.worldGenSettings = worldGenSettings;
}
public String getFolder()
@@ -27,14 +27,14 @@ public interface IConnection
return this.folder;
}
public WorldSettings getWorldSettings()
public LevelSettings getWorldSettings()
{
return this.worldSettings;
return this.levelSettings;
}
public DimensionGeneratorSettings getDimensionGeneratorSettings()
public WorldGenSettings getWorldGenSettings()
{
return this.dimensionGeneratorSettings;
return this.worldGenSettings;
}
}

View File

@@ -1,122 +0,0 @@
package exopandora.worldhandler.util;
import exopandora.worldhandler.builder.INBTWritable;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.IReorderingProcessor;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class MutableStringTextComponent extends StringTextComponent implements INBTWritable
{
private String text;
public MutableStringTextComponent()
{
super(null);
this.text = "";
}
public MutableStringTextComponent(String text)
{
super(null);
this.text = text;
}
public void setText(String text)
{
this.text = text;
}
@Override
public String getText()
{
if(this.isSpecial())
{
return MutableStringTextComponent.getSpecialFormattedText(this.text);
}
return this.text;
}
@Override
public String getContents()
{
return this.text;
}
@Override
public String getString()
{
return this.text;
}
public boolean isSpecial()
{
return this.text != null && !this.text.isEmpty() && MutableStringTextComponent.getSpecialFormattedText(this.text).contains("\u00A7");
}
public static String getSpecialFormattedText(String text)
{
String result = text.replaceAll("\u0026", "\u00A7").replaceAll("\u00A7\u00A7", "\u0026");
if(result.contains("\u00A7"))
{
result += TextFormatting.RESET;
}
return result;
}
public IReorderingProcessor formatter(String string, Integer index)
{
return IReorderingProcessor.forward(string, this.getStyle());
}
@Override
public INBT serialize()
{
if(this.getContents() != null && !this.getContents().isEmpty())
{
return StringNBT.valueOf(this.toString());
}
return null;
}
@Override
public String toString()
{
MutableStringTextComponent serial = (MutableStringTextComponent) this.copy();
serial.setText(MutableStringTextComponent.getSpecialFormattedText(this.getContents()));
return ITextComponent.Serializer.toJson(serial);
}
@Override
public MutableStringTextComponent plainCopy()
{
return new MutableStringTextComponent(this.text);
}
@Override
public boolean equals(Object object)
{
if(this == object)
{
return true;
}
else if(!(object instanceof MutableStringTextComponent))
{
return false;
}
else
{
MutableStringTextComponent stringtextcomponent = (MutableStringTextComponent) object;
return this.text.equals(stringtextcomponent.getContents()) && super.equals(object);
}
}
}

View File

@@ -0,0 +1,118 @@
package exopandora.worldhandler.util;
import exopandora.worldhandler.builder.INBTWritable;
import net.minecraft.ChatFormatting;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.util.FormattedCharSequence;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class MutableTextComponent extends TextComponent implements INBTWritable
{
public MutableTextComponent()
{
super("");
}
public MutableTextComponent(String text)
{
super(text);
}
public void setText(String text)
{
this.text = text;
}
@Override
public String getText()
{
if(this.isSpecial())
{
return MutableTextComponent.getSpecialFormattedText(this.text);
}
return this.text;
}
@Override
public String getContents()
{
return this.text;
}
@Override
public String getString()
{
return this.text;
}
public boolean isSpecial()
{
return this.text != null && !this.text.isEmpty() && MutableTextComponent.getSpecialFormattedText(this.text).contains("\u00A7");
}
public static String getSpecialFormattedText(String text)
{
String result = text.replaceAll("\u0026", "\u00A7").replaceAll("\u00A7\u00A7", "\u0026");
if(result.contains("\u00A7"))
{
result += ChatFormatting.RESET;
}
return result;
}
public FormattedCharSequence formatter(String string, Integer index)
{
return FormattedCharSequence.forward(string, this.getStyle());
}
@Override
public Tag serialize()
{
if(this.getContents() != null && !this.getContents().isEmpty())
{
return StringTag.valueOf(this.toString());
}
return null;
}
@Override
public String toString()
{
MutableTextComponent serial = (MutableTextComponent) this.copy();
serial.setText(MutableTextComponent.getSpecialFormattedText(this.getContents()));
return Component.Serializer.toJson(serial);
}
@Override
public MutableTextComponent plainCopy()
{
return new MutableTextComponent(this.text);
}
@Override
public boolean equals(Object object)
{
if(this == object)
{
return true;
}
else if(!(object instanceof MutableTextComponent))
{
return false;
}
else
{
MutableTextComponent stringtextcomponent = (MutableTextComponent) object;
return this.text.equals(stringtextcomponent.getContents()) && super.equals(object);
}
}
}

View File

@@ -6,35 +6,35 @@ import java.util.List;
import exopandora.worldhandler.builder.INBTWritable;
import exopandora.worldhandler.builder.component.IBuilderComponent;
import exopandora.worldhandler.builder.component.impl.EntityNBT;
import net.minecraft.block.BlockState;
import net.minecraft.item.Items;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.DoubleNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.ListNBT;
import net.minecraft.nbt.NBTUtil;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.ResourceLocation;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.DoubleTag;
import net.minecraft.nbt.ListTag;
import net.minecraft.nbt.NbtUtils;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class NBTHelper
{
public static INBT serialize(BlockState blockState)
public static Tag serialize(BlockState blockState)
{
return blockState != null ? NBTUtil.writeBlockState(blockState) : null;
return blockState != null ? NbtUtils.writeBlockState(blockState) : null;
}
public static INBT serialize(double[] vector)
public static Tag serialize(double[] vector)
{
if(vector.length == 3 && (vector[0] != 0D || vector[1] != 0D || vector[2] != 0D))
{
ListNBT list = new ListNBT();
ListTag list = new ListTag();
list.add(DoubleNBT.valueOf(vector[0]));
list.add(DoubleNBT.valueOf(vector[1]));
list.add(DoubleNBT.valueOf(vector[2]));
list.add(DoubleTag.valueOf(vector[0]));
list.add(DoubleTag.valueOf(vector[1]));
list.add(DoubleTag.valueOf(vector[2]));
return list;
}
@@ -42,28 +42,28 @@ public class NBTHelper
return null;
}
public static INBT serialize(ResourceLocation resource)
public static Tag serialize(ResourceLocation resource)
{
if(resource != null)
{
return StringNBT.valueOf(resource.toString());
return StringTag.valueOf(resource.toString());
}
return null;
}
public static INBT serialize(ResourceLocation[] itemArray)
public static Tag serialize(ResourceLocation[] itemArray)
{
if(Arrays.stream(itemArray).allMatch(resource -> resource != null && resource.equals(Items.AIR.getRegistryName())))
{
return null;
}
ListNBT list = new ListNBT();
ListTag list = new ListTag();
for(ResourceLocation item : itemArray)
{
CompoundNBT compound = new CompoundNBT();
CompoundTag compound = new CompoundTag();
compound.putString("id", item.toString());
compound.putInt("Count", 1);
list.add(compound);
@@ -72,13 +72,13 @@ public class NBTHelper
return list;
}
public static INBT serialize(List<EntityNBT> entities)
public static Tag serialize(List<EntityNBT> entities)
{
ListNBT list = new ListNBT();
ListTag list = new ListTag();
for(EntityNBT entity : entities)
{
INBT nbt = entity.serialize();
Tag nbt = entity.serialize();
if(nbt != null)
{
@@ -94,17 +94,17 @@ public class NBTHelper
return list;
}
public static void append(CompoundNBT compound, String tag, INBTWritable writable)
public static void append(CompoundTag compound, String tag, INBTWritable writable)
{
NBTHelper.append(compound, tag, writable.serialize());
}
public static void append(CompoundNBT compound, IBuilderComponent component)
public static void append(CompoundTag compound, IBuilderComponent component)
{
NBTHelper.append(compound, component.getTag(), component.serialize());
}
public static void append(CompoundNBT compound, String tag, INBT nbt)
public static void append(CompoundTag compound, String tag, Tag nbt)
{
if(nbt != null)
{

View File

@@ -7,17 +7,16 @@ import java.util.function.Function;
import javax.annotation.Nullable;
import exopandora.worldhandler.Main;
import net.minecraft.block.Block;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.entity.EntityType;
import net.minecraft.item.Item;
import net.minecraft.potion.Effect;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.registry.DynamicRegistries;
import net.minecraft.util.registry.MutableRegistry;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.text.LanguageMap;
import net.minecraft.world.biome.Biome;
import net.minecraft.core.Registry;
import net.minecraft.core.RegistryAccess;
import net.minecraft.locale.Language;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.effect.MobEffect;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.level.biome.Biome;
import net.minecraft.world.level.block.Block;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -34,14 +33,14 @@ public class RegistryHelper
{
registerRegistry(ForgeRegistries.BLOCKS, Block::getDescriptionId);
registerRegistry(ForgeRegistries.ITEMS, Item::getDescriptionId);
registerRegistry(ForgeRegistries.POTIONS, Effect::getDescriptionId);
registerRegistry(ForgeRegistries.POTIONS, MobEffect::getDescriptionId);
registerRegistry(ForgeRegistries.BIOMES, biome ->
{
MutableRegistry<Biome> registry = DynamicRegistries.builtin().registryOrThrow(Registry.BIOME_REGISTRY);
Registry<Biome> registry = RegistryAccess.builtin().registryOrThrow(Registry.BIOME_REGISTRY);
ResourceLocation resource = registry.getKey(biome);
String key = "biome." + biome.getRegistryName().getNamespace() + "." + resource.getPath();
return LanguageMap.getInstance().has(key) ? key : resource.toString();
return Language.getInstance().has(key) ? key : resource.toString();
});
registerRegistry(ForgeRegistries.ENCHANTMENTS, Enchantment::getDescriptionId);
registerRegistry(ForgeRegistries.ENTITIES, EntityType::getDescriptionId);

View File

@@ -1,31 +1,18 @@
package exopandora.worldhandler.util;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import exopandora.worldhandler.config.Config;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.AbstractGui;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.ItemRenderer;
import net.minecraft.client.renderer.RenderHelper;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraft.entity.LivingEntity;
import net.minecraft.inventory.container.PlayerContainer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.vector.Vector3f;
import net.minecraft.world.World;
import net.minecraft.client.gui.GuiComponent;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class RenderUtils
{
public static void drawWatchIntoGui(MatrixStack matrix, AbstractGui gui, int width, int height, long worldTicks, boolean smooth)
public static void drawWatchIntoGui(PoseStack matrix, GuiComponent gui, int width, int height, long worldTicks, boolean smooth)
{
float hour = TextUtils.toHour(worldTicks);
float minute = TextUtils.toMinute(worldTicks);
@@ -44,115 +31,26 @@ public class RenderUtils
matrix.scale(0.25F, 0.25F, 0.25F);
matrix.mulPose(Vector3f.ZP.rotationDegrees(rotationHour));
AbstractGui.fill(matrix, -1, -1, 1, 11, 0xFF383838);
GuiComponent.fill(matrix, -1, -1, 1, 11, 0xFF383838);
matrix.mulPose(Vector3f.ZN.rotationDegrees(rotationHour));
matrix.mulPose(Vector3f.ZP.rotationDegrees(rotationMinute));
AbstractGui.fill(matrix, -1, -1, 1, 15, 0xFF6F6F6F);
GuiComponent.fill(matrix, -1, -1, 1, 15, 0xFF6F6F6F);
matrix.mulPose(Vector3f.ZN.rotationDegrees(rotationMinute));
matrix.popPose();
RenderUtils.colorDefaultButton();
Minecraft.getInstance().getTextureManager().bind(ResourceHelper.iconTexture());
RenderSystem.setShaderTexture(0, ResourceHelper.iconTexture());
gui.blit(matrix, width + 0, height, 48, 0, 10, 10);
matrix.pushPose();
matrix.scale(0.5F, 0.5F, 0.5F);
AbstractGui.fill(matrix, (width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
GuiComponent.fill(matrix, (width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
matrix.popPose();
}
public static void renderItemIntoGUI(MatrixStack matrix, ItemStack stack, int x, int y)
{
ItemRenderer itemRenderer = Minecraft.getInstance().getItemRenderer();
TextureManager textureManager = Minecraft.getInstance().getTextureManager();
IBakedModel bakedmodel = Minecraft.getInstance().getItemRenderer().getModel(stack, (World) null, (LivingEntity) null);
matrix.pushPose();
textureManager.bind(PlayerContainer.BLOCK_ATLAS);
textureManager.getTexture(PlayerContainer.BLOCK_ATLAS).setFilter(false, false);
RenderUtils.enableRescaleNormal();
RenderUtils.enableAlphaTest();
RenderSystem.defaultAlphaFunc();
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
RenderUtils.color(1.0F, 1.0F, 1.0F, 1.0F);
matrix.translate((float) x, (float) y, 100.0F + itemRenderer.blitOffset);
matrix.translate(8.0F, 8.0F, 0.0F);
matrix.scale(1.0F, -1.0F, 1.0F);
matrix.scale(16.0F, 16.0F, 16.0F);
IRenderTypeBuffer.Impl buffer = Minecraft.getInstance().renderBuffers().bufferSource();
boolean flag = !bakedmodel.usesBlockLight();
if(flag)
{
RenderHelper.setupForFlatItems();
}
itemRenderer.render(stack, ItemCameraTransforms.TransformType.GUI, false, matrix, buffer, 15728880, OverlayTexture.NO_OVERLAY, bakedmodel);
buffer.endBatch();
RenderSystem.enableDepthTest();
if(flag)
{
RenderHelper.setupFor3DItems();
}
RenderUtils.disableAlphaTest();
RenderUtils.disableRescaleNormal();
matrix.popPose();
}
@SuppressWarnings("deprecation")
public static void color(float r, float g, float b, float a)
{
RenderSystem.color4f(r, g, b, a);
}
@SuppressWarnings("deprecation")
public static void color(float r, float g, float b)
{
RenderSystem.color3f(r, g, b);
}
@SuppressWarnings("deprecation")
public static void enableAlphaTest()
{
RenderSystem.enableAlphaTest();
}
@SuppressWarnings("deprecation")
public static void disableAlphaTest()
{
RenderSystem.disableAlphaTest();
}
@SuppressWarnings("deprecation")
public static void enableRescaleNormal()
{
RenderSystem.enableRescaleNormal();
}
@SuppressWarnings("deprecation")
public static void disableRescaleNormal()
{
RenderSystem.disableRescaleNormal();
}
@SuppressWarnings("deprecation")
public static void disableLighting()
{
RenderSystem.disableLighting();
}
public static void colorDefaultButton()
{
float r = Config.getSkin().getButtonRed();
@@ -160,7 +58,7 @@ public class RenderUtils
float b = Config.getSkin().getButtonBlue();
float a = Config.getSkin().getButtonAlpha();
RenderUtils.color(r, g, b, a);
RenderSystem.setShaderColor(r, g, b, a);
}
public static void colorDefaultBackground()
@@ -175,7 +73,7 @@ public class RenderUtils
float b = Config.getSkin().getBackgroundBlue();
float a = (float) alpha * Config.getSkin().getBackgroundAlpha();
RenderUtils.color(r, g, b, a);
RenderSystem.setShaderColor(r, g, b, a);
}
public static void colorDarkBackground()
@@ -185,10 +83,10 @@ public class RenderUtils
float b = Config.getSkin().getBackgroundBlue();
float a = Config.getSkin().getBackgroundAlpha();
RenderUtils.color(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
RenderSystem.setShaderColor(Math.max(0, r - 0.3F), Math.max(0, g - 0.3F), Math.max(0, b - 0.3F), a);
}
public static void drawTexturedTriangleBL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleBL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
@@ -196,7 +94,7 @@ public class RenderUtils
}
}
public static void drawTexturedTriangleBR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleBR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
@@ -204,7 +102,7 @@ public class RenderUtils
}
}
public static void drawTexturedTriangleTL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleTL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
@@ -212,7 +110,7 @@ public class RenderUtils
}
}
public static void drawTexturedTriangleTR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int size)
public static void drawTexturedTriangleTR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int size)
{
for(int i = 0; i < size; i++)
{
@@ -220,7 +118,7 @@ public class RenderUtils
}
}
public static void drawTexturedWedgeGradientTR(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int width, int height)
public static void drawTexturedWedgeGradientTR(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int width, int height)
{
RenderSystem.enableBlend();
@@ -236,7 +134,7 @@ public class RenderUtils
RenderSystem.disableBlend();
}
public static void drawTexturedWedgeGradientTL(MatrixStack matrix, AbstractGui gui, int x, int y, int textureX, int textureY, int width, int height)
public static void drawTexturedWedgeGradientTL(PoseStack matrix, GuiComponent gui, int x, int y, int textureX, int textureY, int width, int height)
{
RenderSystem.enableBlend();

View File

@@ -6,7 +6,7 @@ import exopandora.worldhandler.Main;
import exopandora.worldhandler.builder.types.BlockResourceLocation;
import exopandora.worldhandler.builder.types.ItemResourceLocation;
import exopandora.worldhandler.config.Config;
import net.minecraft.util.ResourceLocation;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.IForgeRegistry;

View File

@@ -7,13 +7,13 @@ import java.util.function.Predicate;
import com.google.common.base.Predicates;
import net.minecraft.scoreboard.ScoreCriteria;
import net.minecraft.scoreboard.Team.CollisionRule;
import net.minecraft.scoreboard.Team.Visible;
import net.minecraft.ChatFormatting;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.stats.StatType;
import net.minecraft.stats.Stats;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.TextFormatting;
import net.minecraft.world.scores.Team.CollisionRule;
import net.minecraft.world.scores.Team.Visibility;
import net.minecraft.world.scores.criteria.ObjectiveCriteria;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.registries.ForgeRegistries;
@@ -33,14 +33,14 @@ public class ScoreboardHelper
private void init()
{
//Lists
final List<Node> colors = this.createList(TextFormatting.values(), TextFormatting::getName, TextFormatting::isColor);
final List<Node> visibility = this.createList(Visible.values(), value -> value.name);
final List<Node> colors = this.createList(ChatFormatting.values(), ChatFormatting::getName, ChatFormatting::isColor);
final List<Node> visibility = this.createList(Visibility.values(), value -> value.name);
final List<Node> collision = this.createList(CollisionRule.values(), value -> value.name);
final List<Node> bool = this.createList(new Boolean[] {true, false}, String::valueOf);
//Objectives
for(String scoreCriteria : ScoreCriteria.CRITERIA_BY_NAME.keySet())
for(String scoreCriteria : ObjectiveCriteria.getCustomCriteriaNames())
{
this.objectives.insertNode(scoreCriteria.split("[.:]"));
}

View File

@@ -3,17 +3,17 @@ package exopandora.worldhandler.util;
import javax.annotation.Nullable;
import exopandora.worldhandler.builder.INBTWritable;
import net.minecraft.nbt.INBT;
import net.minecraft.nbt.StringNBT;
import net.minecraft.util.text.event.ClickEvent;
import net.minecraft.util.text.event.ClickEvent.Action;
import net.minecraft.nbt.StringTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.ClickEvent;
import net.minecraft.network.chat.ClickEvent.Action;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class SignText implements INBTWritable
{
private MutableStringTextComponent text = new MutableStringTextComponent();
private MutableTextComponent text = new MutableTextComponent();
private final int line;
public SignText(int line)
@@ -26,12 +26,12 @@ public class SignText implements INBTWritable
return this.line;
}
public MutableStringTextComponent getString()
public MutableTextComponent getString()
{
return this.text;
}
public void setString(MutableStringTextComponent string)
public void setString(MutableTextComponent string)
{
this.text = string;
}
@@ -65,9 +65,9 @@ public class SignText implements INBTWritable
}
@Override
public INBT serialize()
public Tag serialize()
{
return StringNBT.valueOf(this.toString());
return StringTag.valueOf(this.toString());
}
@Override

View File

@@ -1,43 +1,44 @@
package exopandora.worldhandler.util;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.IFormattableTextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.Font;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.util.Mth;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
@OnlyIn(Dist.CLIENT)
public class TextUtils
{
public static final StringTextComponent ARROW_LEFT = new StringTextComponent("<");
public static final StringTextComponent ARROW_RIGHT = new StringTextComponent(">");
public static final IFormattableTextComponent ARROW_LEFT_BOLD = new StringTextComponent("<").withStyle(net.minecraft.util.text.TextFormatting.BOLD);
public static final IFormattableTextComponent ARROW_RIGHT_BOLD = new StringTextComponent(">").withStyle(net.minecraft.util.text.TextFormatting.BOLD);
public static final TextComponent ARROW_LEFT = new TextComponent("<");
public static final TextComponent ARROW_RIGHT = new TextComponent(">");
public static final MutableComponent ARROW_LEFT_BOLD = new TextComponent("<").withStyle(ChatFormatting.BOLD);
public static final MutableComponent ARROW_RIGHT_BOLD = new TextComponent(">").withStyle(ChatFormatting.BOLD);
public static IFormattableTextComponent stripText(IFormattableTextComponent string, int maxWidth, FontRenderer fontRenderer)
public static MutableComponent stripText(MutableComponent string, int maxWidth, Font font)
{
return TextUtils.stripText(string, (IFormattableTextComponent) StringTextComponent.EMPTY, maxWidth, fontRenderer);
return TextUtils.stripText(string, (MutableComponent) TextComponent.EMPTY, maxWidth, font);
}
public static IFormattableTextComponent stripText(IFormattableTextComponent string, IFormattableTextComponent prefix, int maxWidth, FontRenderer fontRenderer)
public static MutableComponent stripText(MutableComponent string, MutableComponent prefix, int maxWidth, Font font)
{
if(fontRenderer.width(prefix) + fontRenderer.width(string) > (maxWidth - fontRenderer.width(prefix)))
if(font.width(prefix) + font.width(string) > (maxWidth - font.width(prefix)))
{
IFormattableTextComponent result = new StringTextComponent("").setStyle(string.getStyle());
MutableComponent result = new TextComponent("").setStyle(string.getStyle());
for(char c : string.getString().toCharArray())
{
IFormattableTextComponent extension = new StringTextComponent(result.getString() + c + "...").setStyle(string.getStyle());
MutableComponent extension = new TextComponent(result.getString() + c + "...").setStyle(string.getStyle());
if(fontRenderer.width(extension) < maxWidth)
if(font.width(extension) < maxWidth)
{
result = new StringTextComponent(result.getString() + c).setStyle(string.getStyle());
result = new TextComponent(result.getString() + c).setStyle(string.getStyle());
}
else
{
return new StringTextComponent(result.getString() + "...").setStyle(string.getStyle());
return new TextComponent(result.getString() + "...").setStyle(string.getStyle());
}
}
}
@@ -80,13 +81,13 @@ public class TextUtils
public static int toHour(long tick)
{
return MathHelper.floor((tick + 6000) / 1000F) % 24;
return Mth.floor((tick + 6000) / 1000F) % 24;
}
public static int toMinute(long tick)
{
int hour = MathHelper.floor((tick + 6000F) / 1000F);
int minute = MathHelper.floor((tick + 6000F - hour * 1000) * 6 / 100);
int hour = Mth.floor((tick + 6000F) / 1000F);
int minute = Mth.floor((tick + 6000F - hour * 1000) * 6 / 100);
return minute;
}
@@ -99,13 +100,13 @@ public class TextUtils
return String.format("%02d:%02d", hour, minute);
}
public static IFormattableTextComponent formatNonnull(String text, Object... parameters)
public static MutableComponent formatNonnull(String text, Object... parameters)
{
if(text == null)
{
return (IFormattableTextComponent) StringTextComponent.EMPTY;
return (MutableComponent) TextComponent.EMPTY;
}
return new TranslationTextComponent(text, parameters);
return new TranslatableComponent(text, parameters);
}
}