Version-agnostic and package-agnostic interfaces used in Constellar. Zero strict dependencies, works as a submodule.

Overview

bridge

Version-agnostic and package-agnostic interfaces used in Constellar. Zero strict dependencies, works as a submodule.

Used for cross-compatibility in Constellar, works across versions. All different client versions have to do is implement these interfaces accordingly.

The aim of this system is to add a layer of agnosticism between versions, allowing similar (or even exactly the same) code to work on different versions, using only bridges.

Yes, this concept is nearly identical to Lunar's bridge system.

Examples

Here is an example definition of a bridge:

public interface IExampleBridge extends IBridge {
    // Implement the package.
    @Override
    default String getPackageAssociation() { return "net.minecraft"; }
    
    String getFieldExample();
}

This interface defines a bridge that can be implemented.

Here is an example of a mixin-less implementation of a bridge, which is not recommended:

public class MyExampleBridge extends IExampleBridge
{
    // We can use a singleton here if the bridge connects to a static class. Otherwise, use instances.
    public static final MyExampleBridge INSTANCE = new MyExampleBridge();
    
    @Override
    public String getFieldExample() { return Example.INSTANCE.fieldExample; }
}

Here is the recommended approach, which uses mixins:

@Mixin(Example.class) // mixin into the example class
public abstract class MixinExampleBridge implements IExampleBridge // pretend Example implements IExample
{
    // Decorate a field with shadow to reference the field in Example's class.
    @Shadow public String fieldExample;
    
    // Then simply implement the interface.
    @Override
    public string getFieldExample() { return fieldExample; }
}

Thanks to the magic of mixins, we can safely cast an instance of Example to IExampleBridge, and use it with a safe conscience. ((IExampleBridge) Example.INSTANCE).getFieldExample() This is similar in concept to Mixin accessors. The importancs of this system, however, can be seen below:

public interface IMinecraftBridge extends IBridge
{
    // define methods, etc.
}

@Mixin(Minecraft.class)
public class MinecraftBridgeMixin implements IMinecraftBridge
{
    // interface impl, this can vary between versions but the usage outside of the mixin will always be the same!!
}

public final class MyClient
{
    public static IMinecraftBridge Minecraft; // set this value somewhere
    
    void foobar() {
        // This code will always work, no matter the version.
        // This entire class, if designed correctly, can be completely version-independent!
        // Note that this means you do not need to directly reference any packages either.
        System.out.println(Minecraft.getSomeField());
        
        // If you, for example, have a field that returns a class in the `net.minecraft` package,
        // you should make it return a bridge instead, and follow the examples above to implement that bridge as well.
    }
}
You might also like...

This repository contains Java programs to become zero to hero in Java. Programs related to each and every concep are present from easy to intermidiate level.

Learn Java Programming In this repository you will find topic wise programs of java from basics to intermediate. This follows topic wise approach that

Oct 9, 2022

EliteRising Lava Rising Package v1.1 for MC-1.17.1

EliteRising v1.1 for 1.17 v1.1 Changelog This update took significant my time. So v1.1 update's content is so big. Let's start. Commands -Added team c

Jun 19, 2022

NPM Package - A react native component that let you to add a wavy background UI.

NPM Package - A react native component that let you to add a wavy background UI.

react-native-wavy-background A react native component that let you to add a wavy background UI. Installation npm install react-native-wavy-background

Oct 19, 2022

The Minecraft Mod Package Manager!

The Minecraft Mod Package Manager!

Modget-Minecraft The Minecraft Mod Package Manager! Modget is based on TheBrokenRail's ModUpdater mod and is inspired heavily by Microsoft's Winget. C

Dec 28, 2022

Education from zero to advanced

Java And React Boot Camp This repo consists of the codes written in the course and the project assignments given. Lectures Lecture 1 intro Lecture 2 o

Sep 19, 2022

Esse repositório disponibiliza uma versão zero de uma API de cadastro de usuários (Users) a ser melhorada com desafios ☕️ 🇧🇷

java-training-api Esse repositório disponibiliza uma versão zero de uma API de cadastro de usuários (Users) na pasta SRC a ser melhorada. DESAFIOS Os

Dec 22, 2022

Zero-Dependency RFC 8252 OAuth 2.0 Authorization Flow

Tiny OAuth2 Client This is a minimal zero-dependency implementation of the RFC 8252 OAuth 2.0 for Native Apps, relying on Loopback Interface Redirecti

Jun 17, 2022

JHipster Works with Spring Native!

Spring Native with JHipster This repository contains five apps we (@joshlong and @mraible) used to figure out how to make Spring Native work with JHip

Dec 22, 2022

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & native view and interstitial dialog.

GFX-AdPromote An Android library for member secretGFX group, This can be used to growing your apps and get more install via a simple banner view & nat

Dec 25, 2022
Owner
uranometrical
Hi! We develop a Minecraft PvP client, an extensible launcher, and reverse-engineer software.
uranometrical
Facsimile - Copy Your Most Used Text to Clipboard Easily with Facsimile!. It Helps You to Store You Most Used Text as a Key, Value Pair and Copy it to Clipboard with a Shortcut.

Facsimile An exact copy of Your Information ! Report Bug · Request Feature Table of Contents About The Project Built With Getting Started Installation

Sri lakshmi kanthan P 1 Sep 12, 2022
A fault tolerant, protocol-agnostic RPC system

Finagle Status This project is used in production at Twitter (and many other organizations), and is being actively developed and maintained. Releases

Twitter 8.5k Jan 4, 2023
By this package we can get sim info, call logs and sms logs.Also we can find for specific sim info and call logs as well.

sim_sms_call_info A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package

 Hasib Akon 3 Sep 17, 2022
A basic shard that demonstrates optional implementations, and interfaces.

Glass - Example A basic shard that demonstrates optional implementations, and interfaces. Basic Information A lot of stuff will be more complex than o

null 1 Feb 13, 2022
A list of direct references to classes and interfaces in the Java Language Specification (3d Ed.)

A list of direct references to classes and interfaces in the Java Language Specification (3d Ed.) and a program to compute the indirectly required classes and interfaces

Joshua Bloch 12 Jun 3, 2022
This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practical coding example and required JAR dependencies

SpringMVC-Database-Integration This module explains about the example of Spring MVC + Database Integration with MySQL using Hibernate ORM with practic

GowthamRaj K 3 Nov 2, 2021
AndroidHiddenApiBypass - Bypass restrictions on non-SDK interfaces

AndroidHiddenApiBypass Bypass restrictions on non-SDK interfaces. Why AndroidHiddenApiBypass? Pure Java: no native code used. Reliable: does not rely

LSPosed 903 Jan 6, 2023
Docker-compose-integration-tstst - An exploration of how to run integration tests against an application that has inconvenient external dependencies (e.g. a SQL database).

Tstst? it was supposed to be docker-compose-integration-tests but i was too lazy to fix it at the outset, and now im trying to convince myself its fun

null 1 Jan 4, 2022
App to demonstrate the passage of adapter items into activity using interfaces

OnClickListenerExample This application shows how to pass adapter items into an activity using interfaces. The sample data set contains two fields rep

Rohan Bari 1 Feb 2, 2022
Maven plugin to check if dependencies in CycloneDX BOM files use only allowed licenses.

license-checker-cyclonedx-maven-plugin Maven plugin to check if dependencies in CycloneDX BOM files use only allowed licenses. Quick start guide 1. Ad

null 3 Sep 17, 2022