This commit is contained in:
parent
c542083c95
commit
3a8fa37f12
@ -9,7 +9,16 @@ import net.minecraft.world.World;
|
|||||||
* Action That Can Be Performed With Energy
|
* Action That Can Be Performed With Energy
|
||||||
*/
|
*/
|
||||||
public class Action {
|
public class Action {
|
||||||
|
/**
|
||||||
|
* Action Function
|
||||||
|
*/
|
||||||
public interface ActionFunction {
|
public interface ActionFunction {
|
||||||
|
/**
|
||||||
|
* Run Function
|
||||||
|
* @param world World
|
||||||
|
* @param pos Block Position
|
||||||
|
* @param state Block State
|
||||||
|
*/
|
||||||
void run(World world, BlockPos pos, BlockState state);
|
void run(World world, BlockPos pos, BlockState state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ public interface InfuserAction {
|
|||||||
*/
|
*/
|
||||||
void run(World world, BlockPos pos);
|
void run(World world, BlockPos pos);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Output Item For Display In REI
|
||||||
|
* @return Output Item
|
||||||
|
*/
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
InfuserOutputItem display();
|
InfuserOutputItem display();
|
||||||
|
|
||||||
@ -71,7 +75,7 @@ public interface InfuserAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Infuser Action That Creates Some Particles
|
* Infuser Action That Creates Particles
|
||||||
*/
|
*/
|
||||||
class ParticleAction implements InfuserAction {
|
class ParticleAction implements InfuserAction {
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ public class InfuserEntry {
|
|||||||
* Success Chance
|
* Success Chance
|
||||||
*/
|
*/
|
||||||
public final double successChance;
|
public final double successChance;
|
||||||
|
|
||||||
private final InfuserAction[] success;
|
private final InfuserAction[] success;
|
||||||
private final InfuserAction[] fail;
|
private final InfuserAction[] fail;
|
||||||
|
|
||||||
@ -61,6 +62,11 @@ public class InfuserEntry {
|
|||||||
weightedList.pick(world.random).run(world, pos);
|
weightedList.pick(world.random).run(world, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get All REI Display Output Items
|
||||||
|
* @param isFail Get Failure Items Instead Of Success Items
|
||||||
|
* @return All REI Display Output Items
|
||||||
|
*/
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public List<InfuserOutputItem> getOutputItems(boolean isFail) {
|
public List<InfuserOutputItem> getOutputItems(boolean isFail) {
|
||||||
InfuserAction[] actionList = isFail ? fail : success;
|
InfuserAction[] actionList = isFail ? fail : success;
|
||||||
@ -71,6 +77,11 @@ public class InfuserEntry {
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Chance For One Action
|
||||||
|
* @param isFail Is A Failure Action
|
||||||
|
* @return Chance
|
||||||
|
*/
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public double getSingleChance(boolean isFail) {
|
public double getSingleChance(boolean isFail) {
|
||||||
return (1d / (double) (isFail ? fail.length : success.length)) * (isFail ? 1d - successChance : successChance);
|
return (1d / (double) (isFail ? fail.length : success.length)) * (isFail ? 1d - successChance : successChance);
|
||||||
|
@ -4,11 +4,25 @@ import net.fabricmc.api.EnvType;
|
|||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Output Item For Display In REI
|
||||||
|
*/
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class InfuserOutputItem {
|
public class InfuserOutputItem {
|
||||||
|
/**
|
||||||
|
* Is This A Real Item
|
||||||
|
*/
|
||||||
public final boolean outputsItem;
|
public final boolean outputsItem;
|
||||||
|
/**
|
||||||
|
* Display Item
|
||||||
|
*/
|
||||||
public final ItemStack stack;
|
public final ItemStack stack;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Display Item
|
||||||
|
* @param outputsItem Is This A Real Item
|
||||||
|
* @param item Display Item
|
||||||
|
*/
|
||||||
public InfuserOutputItem(boolean outputsItem, ItemStack item) {
|
public InfuserOutputItem(boolean outputsItem, ItemStack item) {
|
||||||
this.outputsItem = outputsItem;
|
this.outputsItem = outputsItem;
|
||||||
this.stack = item;
|
this.stack = item;
|
||||||
|
Reference in New Issue
Block a user