GithubHelp home page GithubHelp logo

boogiemonster1o1 / energy Goto Github PK

View Code? Open in Web Editor NEW

This project forked from techreborn/energy

0.0 0.0 0.0 120 KB

An Energy API

License: Do What The F*ck You Want To Public License

Java 100.00%

energy's Introduction

Energy

An Energy API used by TechReborn

  • Fully unit tested
  • Depends on Minecraft and fabric-loader

Currently WIP, the API may change at any time! I am very open to feedback and suggestions on the issue tracker.

This may seem quite different from any energy API that you have seen before (code wise), as this is because I wanted to try something different.

Reference Values

  • 1 coal = 4000
  • 1 plank = 750

Including the API in your project

Latest version

Add the following into your dependencies block in build.gradle

modApi 'teamreborn:energy:<latest_version>'
include 'teamreborn:energy:<latest_version>'

Basic Example

This basic example shows how to move energy from place to another, the source or target can be anything that has a registered holder.

Energy.of(source)
	.side(side)
	.into(
	   Energy.of(target).side(side.getOpposite())
	)
	.move();

Full documentation

WIP will be done at some point

Energy

Energy.of

Energy.of(object) will return an EnergyHandler that can be used to read or interact with the energy of a supplied object (More on this later).

The Object may be an instance of EnergyStorage or any other object that has a supported holder registered (More on this later).

RebornCore (Included in TechReborn) registers a holder for Minecraft's ItemStack, allow you easily get the energy off an ItemStack. BlockEntities are expected to implement EnergyStorage

Energy.valid

Energy.valid will return true if the given object is supported

EnergyHandler

An instance of EnergyHandler can be got from Energy.of()

getEnergy

Returns the current amount of stored energy

double energy = Energy.of(object).getEnergy()

getMaxStored

Returns the maximum amount of energy that the holder can store

double energy = Energy.of(object).getEnergy()

set

Set the amount of energy stored in the holder

Energy.of(object).set(250)

extract

Extract upto the amount of energy provided, returns the amount of energy that was extracted. This is limited by the max output of the holder, as well as the amount of energy that is held in the holder. Returns the the amount of energy actually extracted from the holder.

double extracted = Energy.of(object).extract(20)

insert

Insert upto the amount of energy provided, returns the amount of energy that was inserted. This is limited by the max input of the holder, as well as the amount of free space in the hold. Returns the the amount of energy actually inserted from the holder.

double inserted = Energy.of(object).insert(20)

getMaxInput

getMaxOutput

simulate

side

into

use(amount)

EnergyMovement

move

move(amount)

onlyIf

energy's People

Contributors

modmuss50 avatar prospector avatar boogiemonster1o1 avatar gabrielolvh avatar drcrazy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.