Update to 1.16.1
This commit is contained in:
@@ -19,10 +19,10 @@ import net.minecraft.block.AbstractSignBlock;
|
||||
import net.minecraft.block.NoteBlock;
|
||||
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.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraft.util.text.TranslationTextComponent;
|
||||
import net.minecraft.world.Difficulty;
|
||||
@@ -163,13 +163,11 @@ public class ActionHelper
|
||||
Minecraft.getInstance().displayGuiScreen(null);
|
||||
Minecraft.getInstance().mouseHelper.grabMouse();
|
||||
|
||||
Style redColor = new Style().setColor(TextFormatting.RED);
|
||||
ITextComponent message = new TranslationTextComponent("<" + Main.NAME + "> %s", new TranslationTextComponent("worldhandler.error.gui")).func_240699_a_(TextFormatting.RED);
|
||||
ITextComponent cause = new StringTextComponent(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).func_240699_a_(TextFormatting.RED);
|
||||
|
||||
ITextComponent message = new TranslationTextComponent("<" + Main.NAME + "> %s", new TranslationTextComponent("worldhandler.error.gui")).setStyle(redColor);
|
||||
ITextComponent cause = new StringTextComponent(" " + e.getClass().getCanonicalName() + ": " + e.getMessage()).setStyle(redColor);
|
||||
|
||||
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, message);
|
||||
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, cause);
|
||||
Minecraft.getInstance().ingameGUI.func_238450_a_(ChatType.SYSTEM, message, Util.field_240973_b_);
|
||||
Minecraft.getInstance().ingameGUI.func_238450_a_(ChatType.SYSTEM, cause, Util.field_240973_b_);
|
||||
|
||||
WorldHandler.LOGGER.throwing(e);
|
||||
}
|
||||
@@ -179,8 +177,8 @@ public class ActionHelper
|
||||
{
|
||||
if(!CommandHelper.canPlayerIssueCommand() && Config.getSettings().permissionQuery())
|
||||
{
|
||||
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused")));
|
||||
Minecraft.getInstance().ingameGUI.addChatMessage(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.settings.permission_query"))));
|
||||
Minecraft.getInstance().ingameGUI.func_238450_a_(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused")), Util.field_240973_b_);
|
||||
Minecraft.getInstance().ingameGUI.func_238450_a_(ChatType.SYSTEM, new StringTextComponent(TextFormatting.RED + I18n.format("worldhandler.permission.refused.change", I18n.format("gui.worldhandler.config.settings.permission_query"))), Util.field_240973_b_);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -9,6 +9,7 @@ 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;
|
||||
@@ -25,14 +26,14 @@ import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
public class AdvancementHelper implements IFutureReloadListener
|
||||
{
|
||||
private static final AdvancementHelper INSTANCE = new AdvancementHelper();
|
||||
private final AdvancementManager manager = new AdvancementManager();
|
||||
private final AdvancementManager manager = new AdvancementManager(new LootPredicateManager());
|
||||
|
||||
@Override
|
||||
public CompletableFuture<Void> reload(IStage stage, IResourceManager resourceManager, IProfiler preparationsProfiler, IProfiler reloadProfiler, Executor backgroundExecutor, Executor gameExecutor)
|
||||
{
|
||||
return CompletableFuture.supplyAsync(() ->
|
||||
{
|
||||
SimpleReloadableResourceManager serverResourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA, Thread.currentThread());
|
||||
SimpleReloadableResourceManager serverResourceManager = new SimpleReloadableResourceManager(ResourcePackType.SERVER_DATA);
|
||||
serverResourceManager.addReloadListener(new NetworkTagManager());
|
||||
serverResourceManager.addReloadListener(this.manager);
|
||||
return serverResourceManager;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BlockHelper
|
||||
}
|
||||
}
|
||||
|
||||
return Minecraft.getInstance().player.getPosition();
|
||||
return Minecraft.getInstance().player.func_233580_cy_();
|
||||
}
|
||||
|
||||
public static Block getFocusedBlock()
|
||||
@@ -148,7 +148,7 @@ public class BlockHelper
|
||||
{
|
||||
if(CommandHelper.canPlayerIssueCommand() && Minecraft.getInstance().getConnection() != null)
|
||||
{
|
||||
BlockPos pos = Minecraft.getInstance().player.getPosition().add(0, 3, 0);
|
||||
BlockPos pos = Minecraft.getInstance().player.func_233580_cy_().add(0, 3, 0);
|
||||
|
||||
BuilderFill placeFill = new BuilderFill();
|
||||
placeFill.setPosition1(pos);
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public abstract class Connection
|
||||
{
|
||||
private final Type type;
|
||||
|
||||
public Connection(Type type)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return this.type;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static enum Type
|
||||
{
|
||||
INTEGRATED,
|
||||
DEDICATED;
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class IntegratedConnection extends Connection
|
||||
{
|
||||
private final String worldName;
|
||||
private final String folderName;
|
||||
|
||||
public IntegratedConnection(Type type, String worldName, String folderName)
|
||||
{
|
||||
super(type);
|
||||
this.worldName = worldName;
|
||||
this.folderName = folderName;
|
||||
}
|
||||
|
||||
public String getWorldName()
|
||||
{
|
||||
return this.worldName;
|
||||
}
|
||||
|
||||
public String getFolderName()
|
||||
{
|
||||
return this.folderName;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class DedicatedConnection extends Connection
|
||||
{
|
||||
private final ServerData data;
|
||||
|
||||
public DedicatedConnection(Type type, ServerData data)
|
||||
{
|
||||
super(type);
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ServerData getData()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
56
src/main/java/exopandora/worldhandler/util/IConnection.java
Normal file
56
src/main/java/exopandora/worldhandler/util/IConnection.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import net.minecraft.client.multiplayer.ServerData;
|
||||
import net.minecraft.world.WorldSettings;
|
||||
import net.minecraft.world.gen.settings.DimensionGeneratorSettings;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
public interface IConnection
|
||||
{
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class IntegratedConnection implements IConnection
|
||||
{
|
||||
private final String folder;
|
||||
private final WorldSettings worldSettings;
|
||||
private final DimensionGeneratorSettings dimensionGeneratorSettings;
|
||||
|
||||
public IntegratedConnection(String folderName, WorldSettings worldSettings, DimensionGeneratorSettings dimensionGeneratorSettings)
|
||||
{
|
||||
this.folder = folderName;
|
||||
this.worldSettings = worldSettings;
|
||||
this.dimensionGeneratorSettings = dimensionGeneratorSettings;
|
||||
}
|
||||
|
||||
public String getFolder()
|
||||
{
|
||||
return this.folder;
|
||||
}
|
||||
|
||||
public WorldSettings getWorldSettings()
|
||||
{
|
||||
return this.worldSettings;
|
||||
}
|
||||
|
||||
public DimensionGeneratorSettings getDimensionGeneratorSettings()
|
||||
{
|
||||
return this.dimensionGeneratorSettings;
|
||||
}
|
||||
}
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public static class DedicatedConnection implements IConnection
|
||||
{
|
||||
private final ServerData data;
|
||||
|
||||
public DedicatedConnection(ServerData data)
|
||||
{
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public ServerData getData()
|
||||
{
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
|
||||
import exopandora.worldhandler.builder.INBTWritable;
|
||||
import net.minecraft.nbt.INBT;
|
||||
import net.minecraft.nbt.StringNBT;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.util.text.Style;
|
||||
import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
@@ -31,8 +33,14 @@ public class MutableStringTextComponent extends StringTextComponent implements I
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
if(this.isSpecial())
|
||||
{
|
||||
return MutableStringTextComponent.getSpecialFormattedText(this.text);
|
||||
}
|
||||
|
||||
return this.text;
|
||||
}
|
||||
|
||||
@@ -43,16 +51,9 @@ public class MutableStringTextComponent extends StringTextComponent implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getFormattedText()
|
||||
public String getString()
|
||||
{
|
||||
String formatted = super.getFormattedText();
|
||||
|
||||
if(this.isSpecial())
|
||||
{
|
||||
return MutableStringTextComponent.getSpecialFormattedText(formatted);
|
||||
}
|
||||
|
||||
return formatted;
|
||||
return this.text;
|
||||
}
|
||||
|
||||
public boolean isSpecial()
|
||||
@@ -74,7 +75,49 @@ public class MutableStringTextComponent extends StringTextComponent implements I
|
||||
|
||||
public String formatter(String string, Integer index)
|
||||
{
|
||||
return this.getStyle().getFormattingCode() + string;
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
if(this.getStyle() != null)
|
||||
{
|
||||
Style style = this.getStyle();
|
||||
|
||||
if(style.func_240711_a_() != null)
|
||||
{
|
||||
TextFormatting color = TextFormatting.getValueByName(style.func_240711_a_().func_240747_b_());
|
||||
|
||||
if(color != null)
|
||||
{
|
||||
builder.append(color);
|
||||
}
|
||||
}
|
||||
|
||||
if(style.getBold())
|
||||
{
|
||||
builder.append(TextFormatting.BOLD);
|
||||
}
|
||||
|
||||
if(style.getItalic())
|
||||
{
|
||||
builder.append(TextFormatting.ITALIC);
|
||||
}
|
||||
|
||||
if(style.getUnderlined())
|
||||
{
|
||||
builder.append(TextFormatting.UNDERLINE);
|
||||
}
|
||||
|
||||
if(style.getObfuscated())
|
||||
{
|
||||
builder.append(TextFormatting.OBFUSCATED);
|
||||
}
|
||||
|
||||
if(style.getStrikethrough())
|
||||
{
|
||||
builder.append(TextFormatting.STRIKETHROUGH);
|
||||
}
|
||||
}
|
||||
|
||||
return builder.toString() + string;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,13 +134,13 @@ public class MutableStringTextComponent extends StringTextComponent implements I
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
MutableStringTextComponent serial = (MutableStringTextComponent) this.deepCopy();
|
||||
MutableStringTextComponent serial = (MutableStringTextComponent) this.func_230532_e_(); //deepCopy
|
||||
serial.setText(MutableStringTextComponent.getSpecialFormattedText(this.getUnformattedComponentText()));
|
||||
return ITextComponent.Serializer.toJson(serial);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MutableStringTextComponent shallowCopy()
|
||||
public MutableStringTextComponent func_230531_f_() //shallowCopy
|
||||
{
|
||||
return new MutableStringTextComponent(this.text);
|
||||
}
|
||||
@@ -116,7 +159,7 @@ public class MutableStringTextComponent extends StringTextComponent implements I
|
||||
else
|
||||
{
|
||||
MutableStringTextComponent stringtextcomponent = (MutableStringTextComponent) object;
|
||||
return this.text.equals(stringtextcomponent.getText()) && super.equals(object);
|
||||
return this.text.equals(stringtextcomponent.getUnformattedComponentText()) && super.equals(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ 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.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.nbt.DoubleNBT;
|
||||
import net.minecraft.nbt.INBT;
|
||||
@@ -54,7 +54,7 @@ public class NBTHelper
|
||||
|
||||
public static INBT serialize(ResourceLocation[] itemArray)
|
||||
{
|
||||
if(Arrays.stream(itemArray).allMatch(resource -> Blocks.AIR.getRegistryName().equals(resource)))
|
||||
if(Arrays.stream(itemArray).allMatch(resource -> Items.AIR.getRegistryName().equals(resource)))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import net.minecraftforge.registries.IForgeRegistryEntry;
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class RegistryHelper
|
||||
{
|
||||
private static final Map<IForgeRegistry<?>, Function<?, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<?, String>>();
|
||||
private static final Map<IForgeRegistry<?>, Function<? extends ForgeRegistryEntry<?>, String>> FORGE = new HashMap<IForgeRegistry<?>, Function<? extends ForgeRegistryEntry<?>, String>>();
|
||||
|
||||
static
|
||||
{
|
||||
@@ -44,7 +44,7 @@ public class RegistryHelper
|
||||
|
||||
@Nullable
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> String translate(ResourceLocation resource)
|
||||
public static <T extends ForgeRegistryEntry<T>> String translate(ResourceLocation resource)
|
||||
{
|
||||
for(IForgeRegistry<?> registry : FORGE.keySet())
|
||||
{
|
||||
|
||||
156
src/main/java/exopandora/worldhandler/util/RenderUtils.java
Normal file
156
src/main/java/exopandora/worldhandler/util/RenderUtils.java
Normal file
@@ -0,0 +1,156 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import com.mojang.blaze3d.matrix.MatrixStack;
|
||||
import com.mojang.blaze3d.platform.GlStateManager;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
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.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)
|
||||
{
|
||||
float hour = TextUtils.toHour(worldTicks);
|
||||
float minute = TextUtils.toMinute(worldTicks);
|
||||
|
||||
if(smooth)
|
||||
{
|
||||
hour = (worldTicks + 6000) / 1000F;
|
||||
minute = (float) ((worldTicks + 6000F - Math.floor(hour) * 1000) * 6 / 100);
|
||||
}
|
||||
|
||||
float rotationHour = (360 / 12) * (hour >= 12 ? (hour - 12) : hour) - 180F;
|
||||
float rotationMinute = (360 / 60) * minute - 180F;
|
||||
|
||||
matrix.push();
|
||||
matrix.translate(width + 5, height + 5, 0F);
|
||||
matrix.scale(0.25F, 0.25F, 0.25F);
|
||||
|
||||
matrix.rotate(Vector3f.ZP.rotationDegrees(rotationHour));
|
||||
AbstractGui.func_238467_a_(matrix, -1, -1, 1, 11, 0xFF383838);
|
||||
matrix.rotate(Vector3f.ZN.rotationDegrees(rotationHour));
|
||||
|
||||
matrix.rotate(Vector3f.ZP.rotationDegrees(rotationMinute));
|
||||
AbstractGui.func_238467_a_(matrix, -1, -1, 1, 15, 0xFF6F6F6F);
|
||||
matrix.rotate(Vector3f.ZN.rotationDegrees(rotationMinute));
|
||||
|
||||
matrix.pop();
|
||||
|
||||
RenderUtils.color(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF(), Config.getSkin().getButtonAlphaF());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
|
||||
|
||||
gui.func_238474_b_(matrix, width + 0, height, 48, 0, 10, 10);
|
||||
|
||||
matrix.push();
|
||||
matrix.scale(0.5F, 0.5F, 0.5F);
|
||||
Screen.func_238467_a_(matrix, (width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
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().getItemModelWithOverrides(stack, (World) null, (LivingEntity) null);
|
||||
|
||||
matrix.push();
|
||||
|
||||
textureManager.bindTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE);
|
||||
textureManager.getTexture(PlayerContainer.LOCATION_BLOCKS_TEXTURE).setBlurMipmapDirect(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.zLevel);
|
||||
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().getRenderTypeBuffers().getBufferSource();
|
||||
boolean flag = !bakedmodel.func_230044_c_();
|
||||
|
||||
if(flag)
|
||||
{
|
||||
RenderHelper.setupGuiFlatDiffuseLighting();
|
||||
}
|
||||
|
||||
itemRenderer.renderItem(stack, ItemCameraTransforms.TransformType.GUI, false, matrix, buffer, 15728880, OverlayTexture.NO_OVERLAY, bakedmodel);
|
||||
buffer.finish();
|
||||
|
||||
RenderSystem.enableDepthTest();
|
||||
|
||||
if(flag)
|
||||
{
|
||||
RenderHelper.setupGui3DDiffuseLighting();
|
||||
}
|
||||
|
||||
RenderUtils.disableAlphaTest();
|
||||
RenderUtils.disableRescaleNormal();
|
||||
|
||||
matrix.pop();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
}
|
||||
@@ -40,11 +40,11 @@ public class SignText implements INBTWritable
|
||||
{
|
||||
if(command != null && !command.isEmpty())
|
||||
{
|
||||
this.text.getStyle().setClickEvent(new ClickEvent(Action.RUN_COMMAND, command));
|
||||
this.text.getStyle().func_240715_a_(new ClickEvent(Action.RUN_COMMAND, command));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.text.getStyle().setClickEvent(null);
|
||||
this.text.getStyle().func_240715_a_(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,7 +80,7 @@ public class SignText implements INBTWritable
|
||||
|
||||
if(this.text.getStyle().isEmpty() && !this.hasCommand())
|
||||
{
|
||||
return this.text.getFormattedText();
|
||||
return this.text.getString();
|
||||
}
|
||||
|
||||
return this.text.toString();
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class TextFormatting
|
||||
{
|
||||
public static String shortenString(String str, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
return TextFormatting.shortenString(str, "", maxWidth, fontRenderer);
|
||||
}
|
||||
|
||||
public static String shortenString(String str, String prefix, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
if(fontRenderer.getStringWidth(prefix + str) > (maxWidth - fontRenderer.getStringWidth(prefix)))
|
||||
{
|
||||
String result = prefix;
|
||||
|
||||
for(char c : str.toCharArray())
|
||||
{
|
||||
if(fontRenderer.getStringWidth(result + c + "...") < maxWidth)
|
||||
{
|
||||
result += c;
|
||||
}
|
||||
else
|
||||
{
|
||||
return result + "...";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prefix + str;
|
||||
}
|
||||
|
||||
public static String getTotalTimePlayed(long tick)
|
||||
{
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
|
||||
seconds = (int) (tick / 20);
|
||||
|
||||
if(seconds > 60)
|
||||
{
|
||||
int min = MathHelper.floor(seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
minutes = min;
|
||||
}
|
||||
|
||||
if(minutes > 60)
|
||||
{
|
||||
int hrs = MathHelper.floor(minutes / 60);
|
||||
minutes = minutes % 60;
|
||||
hours = hrs;
|
||||
}
|
||||
|
||||
if(hours > 24)
|
||||
{
|
||||
int day = MathHelper.floor(hours / 24);
|
||||
hours = hours % 24;
|
||||
days = day;
|
||||
}
|
||||
|
||||
return String.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public static int getHour(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000) / 1000F) % 24;
|
||||
|
||||
return hour;
|
||||
}
|
||||
|
||||
public static int getMinute(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000F) / 1000F);
|
||||
int minute = MathHelper.floor((tick + 6000F - hour * 1000) * 6 / 100);
|
||||
|
||||
return minute;
|
||||
}
|
||||
|
||||
public static String formatWorldTime(long tick)
|
||||
{
|
||||
int hour = TextFormatting.getHour(tick);
|
||||
int minute = TextFormatting.getMinute(tick);
|
||||
|
||||
return String.format("%02d:%02d", hour, minute);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String formatNullable(String text, Object... parameters)
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return I18n.format(text, parameters);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static String formatNonnull(String text, Object... parameters)
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
return I18n.format(text, parameters);
|
||||
}
|
||||
}
|
||||
116
src/main/java/exopandora/worldhandler/util/TextUtils.java
Normal file
116
src/main/java/exopandora/worldhandler/util/TextUtils.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
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.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("<").func_240699_a_(net.minecraft.util.text.TextFormatting.BOLD);
|
||||
public static final IFormattableTextComponent ARROW_RIGHT_BOLD = new StringTextComponent(">").func_240699_a_(net.minecraft.util.text.TextFormatting.BOLD);
|
||||
|
||||
public static IFormattableTextComponent stripText(IFormattableTextComponent string, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
return TextUtils.stripText(string, (IFormattableTextComponent) StringTextComponent.field_240750_d_, maxWidth, fontRenderer);
|
||||
}
|
||||
|
||||
public static IFormattableTextComponent stripText(IFormattableTextComponent string, IFormattableTextComponent prefix, int maxWidth, FontRenderer fontRenderer)
|
||||
{
|
||||
if(fontRenderer.func_238414_a_(prefix) + fontRenderer.func_238414_a_(string) > (maxWidth - fontRenderer.func_238414_a_(prefix)))
|
||||
{
|
||||
IFormattableTextComponent result = new StringTextComponent("").func_240703_c_(string.getStyle());
|
||||
|
||||
for(char c : string.getString().toCharArray())
|
||||
{
|
||||
IFormattableTextComponent extension = new StringTextComponent(result.getString() + c + "...").func_240703_c_(string.getStyle());
|
||||
|
||||
if(fontRenderer.func_238414_a_(extension) < maxWidth)
|
||||
{
|
||||
result = new StringTextComponent(result.getString() + c).func_240703_c_(string.getStyle());
|
||||
}
|
||||
else
|
||||
{
|
||||
return new StringTextComponent(result.getString() + "...").func_240703_c_(string.getStyle());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return prefix.func_230531_f_().func_230529_a_(string);
|
||||
}
|
||||
|
||||
public static String formatTotalTime(long tick)
|
||||
{
|
||||
int days = 0;
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
int seconds = 0;
|
||||
|
||||
seconds = (int) (tick / 20);
|
||||
|
||||
if(seconds > 60)
|
||||
{
|
||||
int min = MathHelper.floor(seconds / 60);
|
||||
seconds = seconds % 60;
|
||||
minutes = min;
|
||||
}
|
||||
|
||||
if(minutes > 60)
|
||||
{
|
||||
int hrs = MathHelper.floor(minutes / 60);
|
||||
minutes = minutes % 60;
|
||||
hours = hrs;
|
||||
}
|
||||
|
||||
if(hours > 24)
|
||||
{
|
||||
int day = MathHelper.floor(hours / 24);
|
||||
hours = hours % 24;
|
||||
days = day;
|
||||
}
|
||||
|
||||
return String.format("%d:%02d:%02d:%02d", days, hours, minutes, seconds);
|
||||
}
|
||||
|
||||
public static int toHour(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000) / 1000F) % 24;
|
||||
|
||||
return hour;
|
||||
}
|
||||
|
||||
public static int toMinute(long tick)
|
||||
{
|
||||
int hour = MathHelper.floor((tick + 6000F) / 1000F);
|
||||
int minute = MathHelper.floor((tick + 6000F - hour * 1000) * 6 / 100);
|
||||
|
||||
return minute;
|
||||
}
|
||||
|
||||
public static String formatWorldTime(long tick)
|
||||
{
|
||||
int hour = TextUtils.toHour(tick);
|
||||
int minute = TextUtils.toMinute(tick);
|
||||
|
||||
return String.format("%02d:%02d", hour, minute);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public static IFormattableTextComponent formatNonnull(String text, Object... parameters)
|
||||
{
|
||||
if(text == null)
|
||||
{
|
||||
return (IFormattableTextComponent) StringTextComponent.field_240750_d_;
|
||||
}
|
||||
|
||||
return new TranslationTextComponent(text, parameters);
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package exopandora.worldhandler.util;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import exopandora.worldhandler.config.Config;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.AbstractGui;
|
||||
import net.minecraft.client.gui.screen.Screen;
|
||||
import net.minecraftforge.api.distmarker.Dist;
|
||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||
|
||||
@OnlyIn(Dist.CLIENT)
|
||||
public class UtilRender
|
||||
{
|
||||
public static void drawWatchIntoGui(AbstractGui gui, int width, int height, long worldTicks, boolean smooth)
|
||||
{
|
||||
float hour = TextFormatting.getHour(worldTicks);
|
||||
float minute = TextFormatting.getMinute(worldTicks);
|
||||
|
||||
if(smooth)
|
||||
{
|
||||
hour = (worldTicks + 6000) / 1000F;
|
||||
minute = (float) ((worldTicks + 6000F - Math.floor(hour) * 1000) * 6 / 100);
|
||||
}
|
||||
|
||||
float rotationHour = (360 / 12) * (hour >= 12 ? (hour - 12) : hour) - 180F;
|
||||
float rotationMinute = (360 / 60) * minute - 180F;
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.translatef(width + 5, height + 5, 0F);
|
||||
RenderSystem.scalef(0.25F, 0.25F, 0.25F);
|
||||
|
||||
RenderSystem.rotatef(rotationHour, 0F, 0F, 1F);
|
||||
Screen.fill(-1, -1, 1, 11, 0xFF383838);
|
||||
RenderSystem.rotatef(-rotationHour, 0F, 0F, 1F);
|
||||
|
||||
RenderSystem.rotatef(rotationMinute, 0F, 0F, 1F);
|
||||
Screen.fill(-1, -1, 1, 15, 0xFF6F6F6F);
|
||||
RenderSystem.rotatef(-rotationMinute, 0F, 0F, 1F);
|
||||
|
||||
RenderSystem.color3f(1.0F, 1.0F, 1.0F);
|
||||
RenderSystem.popMatrix();
|
||||
|
||||
RenderSystem.color3f(Config.getSkin().getButtonRedF(), Config.getSkin().getButtonGreenF(), Config.getSkin().getButtonBlueF());
|
||||
Minecraft.getInstance().getTextureManager().bindTexture(ResourceHelper.getIconTexture());
|
||||
|
||||
gui.blit(width + 0, height, 48, 0, 10, 10);
|
||||
|
||||
RenderSystem.pushMatrix();
|
||||
RenderSystem.scalef(0.5F, 0.5F, 0.5F);
|
||||
Screen.fill((width + 5) * 2 - 1, (height + 4) * 2 + 1, (width + 6) * 2 - 1, (height + 5) * 2 + 1, 0xFF000000);
|
||||
RenderSystem.popMatrix();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user