Merge remote-tracking branch 'remotes/origin/1.14' into 1.15
# Conflicts: # build.gradle # src/main/java/techreborn/blocks/misc/BlockRubberLog.java
27
build.gradle
|
@ -13,7 +13,7 @@ buildscript {
|
|||
classpath "net.fabricmc:fabric-loom:0.2.6-SNAPSHOT"
|
||||
classpath "gradle.plugin.net.minecrell:licenser:0.2.1"
|
||||
classpath 'de.undercouch:gradle-download-task:3.4.3'
|
||||
//classpath 'net.covers1624:GradleStuff:1.0-SNAPSHOT'
|
||||
classpath "com.wynprice.cursemaven:CurseMaven:1.2.2"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ apply plugin: net.minecrell.gradle.licenser.Licenser
|
|||
apply plugin: 'de.undercouch.download'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
//apply plugin: 'net.covers1624.contained-deps'
|
||||
apply plugin: "com.wynprice.cursemaven"
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
|
@ -41,14 +41,19 @@ repositories {
|
|||
}
|
||||
maven {
|
||||
name = 'curseforge'
|
||||
// REI
|
||||
url = 'https://minecraft.curseforge.com/api/maven'
|
||||
}
|
||||
maven {
|
||||
url 'https://jitpack.io'
|
||||
}
|
||||
maven {
|
||||
// LibCD
|
||||
url 'http://server.bbkr.space:8081/artifactory/libs-release'
|
||||
}
|
||||
}
|
||||
|
||||
version = "3.0.14"
|
||||
version = "3.0.20"
|
||||
|
||||
configurations {
|
||||
shade
|
||||
|
@ -76,16 +81,23 @@ dependencies {
|
|||
modCompile "net.fabricmc.fabric-api:fabric-api:0.4.12+build.261-1.15"
|
||||
|
||||
modCompileOnly "io.github.prospector:modmenu:1.7.9-unstable.19w34a+build.1"
|
||||
modCompileOnly ("me.shedaniel:RoughlyEnoughItems:3.1-pre+build.4") {
|
||||
modCompileOnly ("me.shedaniel:RoughlyEnoughItems:3.2.6+build.49") {
|
||||
//Thanks for moving the project breaking gradle...
|
||||
exclude group: 'io.github.prospector.modmenu', module: 'ModMenu'
|
||||
}
|
||||
modCompile ('io.github.cottonmc:LibCD:1.5.0+1.14.4') {
|
||||
transitive = false
|
||||
}
|
||||
modRuntime ("io.github.cottonmc:Jankson:1.0.0+j1.1.2") {
|
||||
transitive = false
|
||||
}
|
||||
|
||||
def rcVersion = 'RebornCore:RebornCore-1.15:4.0.16+build.10'
|
||||
|
||||
modCompile (rcVersion) {
|
||||
transitive = false
|
||||
}
|
||||
include rcVersion
|
||||
|
||||
compile 'org.checkerframework:checker-qual:2.10.0'
|
||||
compile 'org.spongepowered:configurate-hocon:3.6'
|
||||
|
@ -98,6 +110,13 @@ dependencies {
|
|||
}
|
||||
|
||||
compile 'teamreborn:energy:0.0.7'
|
||||
|
||||
//Test Generators mod
|
||||
if (false){
|
||||
modCompile curse.resolve("energies", "2771235")
|
||||
modCompile curse.resolve("protos", "2771226")
|
||||
modCompile curse.resolve("generators", "2790134")
|
||||
}
|
||||
}
|
||||
|
||||
processResources {
|
||||
|
|
|
@ -26,6 +26,7 @@ package techreborn;
|
|||
|
||||
import net.fabricmc.api.ModInitializer;
|
||||
import net.fabricmc.fabric.api.client.itemgroup.FabricItemGroupBuilder;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
import net.minecraft.block.DispenserBlock;
|
||||
import net.minecraft.item.ItemGroup;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -39,6 +40,7 @@ import reborncore.common.util.Torus;
|
|||
import reborncore.common.world.DataAttachment;
|
||||
import techreborn.blockentity.storage.idsu.IDSUManager;
|
||||
import techreborn.client.GuiHandler;
|
||||
import techreborn.compat.libcd.TRTweaker;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.events.ModRegistry;
|
||||
import techreborn.init.*;
|
||||
|
@ -89,6 +91,10 @@ public class TechReborn implements ModInitializer {
|
|||
|
||||
DataAttachment.REGISTRY.register(IDSUManager.class, IDSUManager::new);
|
||||
|
||||
if (FabricLoader.getInstance().isModLoaded("libcd")) {
|
||||
TRTweaker.init();
|
||||
}
|
||||
|
||||
LOGGER.info("TechReborn setup done!");
|
||||
|
||||
}
|
||||
|
|
|
@ -26,10 +26,13 @@ package techreborn.api.recipe.recipes;
|
|||
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialBlastFurnaceBlockEntity;
|
||||
|
||||
public class BlastFurnaceRecipe extends RebornRecipe {
|
||||
|
@ -39,6 +42,11 @@ public class BlastFurnaceRecipe extends RebornRecipe {
|
|||
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
public BlastFurnaceRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, int heat) {
|
||||
super(type, name, ingredients, outputs, power, time);
|
||||
this.heat = heat;
|
||||
}
|
||||
|
||||
public int getHeat() {
|
||||
return heat;
|
||||
|
|
|
@ -27,10 +27,14 @@ package techreborn.api.recipe.recipes;
|
|||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import reborncore.common.crafting.RebornFluidRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.blockentity.machine.multiblock.FluidReplicatorBlockEntity;
|
||||
import techreborn.utils.FluidUtils;
|
||||
|
@ -41,6 +45,14 @@ public class FluidReplicatorRecipe extends RebornFluidRecipe {
|
|||
super(type, name);
|
||||
}
|
||||
|
||||
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
||||
super(type, name, ingredients, outputs, power, time);
|
||||
}
|
||||
|
||||
public FluidReplicatorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||
super(type, name, ingredients, outputs, power, time, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tank getTank(BlockEntity be) {
|
||||
FluidReplicatorBlockEntity blockEntity = (FluidReplicatorBlockEntity) be;
|
||||
|
|
|
@ -27,10 +27,13 @@ package techreborn.api.recipe.recipes;
|
|||
import com.google.gson.JsonObject;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import techreborn.blockentity.fusionReactor.FusionControlComputerBlockEntity;
|
||||
|
||||
/**
|
||||
|
@ -45,6 +48,12 @@ public class FusionReactorRecipe extends RebornRecipe {
|
|||
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
public FusionReactorRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, int startE, int minSize) {
|
||||
super(type, name, ingredients, outputs, power, time);
|
||||
this.startE = startE;
|
||||
this.minSize = minSize;
|
||||
}
|
||||
|
||||
public int getStartEnergy () {
|
||||
return startE;
|
||||
|
|
|
@ -25,9 +25,13 @@
|
|||
package techreborn.api.recipe.recipes;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.RebornFluidRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialGrinderBlockEntity;
|
||||
|
||||
|
@ -37,6 +41,14 @@ public class IndustrialGrinderRecipe extends RebornFluidRecipe {
|
|||
super(type, name);
|
||||
}
|
||||
|
||||
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
||||
super(type, name, ingredients, outputs, power, time);
|
||||
}
|
||||
|
||||
public IndustrialGrinderRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||
super(type, name, ingredients, outputs, power, time, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tank getTank(BlockEntity be) {
|
||||
IndustrialGrinderBlockEntity blockEntity = (IndustrialGrinderBlockEntity) be;
|
||||
|
|
|
@ -25,9 +25,13 @@
|
|||
package techreborn.api.recipe.recipes;
|
||||
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.RebornFluidRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.util.Tank;
|
||||
import techreborn.blockentity.machine.multiblock.IndustrialSawmillBlockEntity;
|
||||
|
||||
|
@ -37,6 +41,14 @@ public class IndustrialSawmillRecipe extends RebornFluidRecipe {
|
|||
super(type, name);
|
||||
}
|
||||
|
||||
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time) {
|
||||
super(type, name, ingredients, outputs, power, time);
|
||||
}
|
||||
|
||||
public IndustrialSawmillRecipe(RebornRecipeType<?> type, Identifier name, DefaultedList<RebornIngredient> ingredients, DefaultedList<ItemStack> outputs, int power, int time, FluidInstance fluid) {
|
||||
super(type, name, ingredients, outputs, power, time, fluid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tank getTank(BlockEntity be) {
|
||||
IndustrialSawmillBlockEntity blockEntity = (IndustrialSawmillBlockEntity) be;
|
||||
|
|
|
@ -24,21 +24,17 @@
|
|||
|
||||
package techreborn.api.recipe.recipes;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.inventory.CraftingInventory;
|
||||
import net.minecraft.inventory.Inventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.RecipeSerializer;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.JsonHelper;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.PacketByteBuf;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
|
@ -50,43 +46,39 @@ import java.util.List;
|
|||
public class RollingMachineRecipe extends RebornRecipe {
|
||||
|
||||
private ShapedRecipe shapedRecipe;
|
||||
private JsonObject shaped;
|
||||
|
||||
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name) {
|
||||
super(type, name);
|
||||
}
|
||||
|
||||
public RollingMachineRecipe(RebornRecipeType<?> type, Identifier name, ShapedRecipe recipe) {
|
||||
super(type, name);
|
||||
this.shapedRecipe = recipe;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(JsonObject jsonObject) {
|
||||
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
||||
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
||||
shaped = withoutTags(json);
|
||||
if(jsonObject.has("shaped")) {
|
||||
JsonObject json = JsonHelper.getObject(jsonObject, "shaped");
|
||||
shapedRecipe = RecipeSerializer.SHAPED.read(getId(), json);
|
||||
} else {
|
||||
//This will be handled by the PacketByteBuf deserialize
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void serialize(JsonObject jsonObject) {
|
||||
jsonObject.add("shaped", shaped);
|
||||
public void serialize(PacketByteBuf byteBuf) {
|
||||
String s = shapedRecipe.getId().toString();
|
||||
byteBuf.writeInt(s.length());
|
||||
byteBuf.writeString(s);
|
||||
RecipeSerializer.SHAPED.write(byteBuf, shapedRecipe);
|
||||
}
|
||||
|
||||
//This needs to be done to remove the item tags, and replace them with just items for when syncing to the server
|
||||
private JsonObject withoutTags(JsonObject jsonObject) {
|
||||
JsonObject key = jsonObject.get("key").getAsJsonObject();
|
||||
key.entrySet().forEach(entry -> {
|
||||
if(entry.getValue().isJsonObject()){
|
||||
JsonObject value = entry.getValue().getAsJsonObject();
|
||||
if(value.has("tag")){
|
||||
|
||||
Identifier tag = new Identifier(value.get("tag").getAsString());
|
||||
Tag<Item> itemTag = ItemTags.getContainer().get(tag);
|
||||
Item item = Iterables.get(itemTag.values(), 0);
|
||||
|
||||
//Remove the tag, and replace it with a basic s
|
||||
value.remove("tag");
|
||||
value.addProperty("item", Registry.ITEM.getId(item).toString());
|
||||
}
|
||||
}
|
||||
});
|
||||
return jsonObject;
|
||||
@Override
|
||||
public void deserialize(PacketByteBuf byteBuf) {
|
||||
Identifier identifier = new Identifier(byteBuf.readString(byteBuf.readInt()));
|
||||
shapedRecipe = RecipeSerializer.SHAPED.read(identifier, byteBuf);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -32,12 +32,12 @@ import reborncore.api.blockentity.InventoryProvider;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.Energy;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
||||
implements IToolDrop, InventoryProvider, IContainerProvider {
|
||||
|
@ -59,8 +59,13 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
for (int i = 0; i < 6; i++) {
|
||||
ItemStack stack = inventory.getInvStack(i);
|
||||
|
||||
if (!stack.isEmpty()) {
|
||||
ExternalPowerSystems.chargeItem(this, stack);
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
.into(
|
||||
Energy
|
||||
.of(stack)
|
||||
)
|
||||
.move();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +82,7 @@ public class ChargeOMatBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
@Override
|
||||
public boolean canProvideEnergy(final Direction direction) {
|
||||
return false;
|
||||
return direction == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -24,6 +24,10 @@
|
|||
|
||||
package techreborn.blockentity.cable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.network.packet.BlockEntityUpdateS2CPacket;
|
||||
|
@ -35,6 +39,7 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Tickable;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
|
@ -44,14 +49,10 @@ import team.reborn.energy.Energy;
|
|||
import team.reborn.energy.EnergySide;
|
||||
import team.reborn.energy.EnergyStorage;
|
||||
import team.reborn.energy.EnergyTier;
|
||||
import techreborn.blocks.cable.BlockCable;
|
||||
import techreborn.blocks.cable.CableBlock;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 19/05/2017.
|
||||
*/
|
||||
|
@ -60,19 +61,28 @@ public class CableBlockEntity extends BlockEntity
|
|||
implements Tickable, IListInfoProvider, IToolDrop, EnergyStorage {
|
||||
|
||||
private double energy = 0;
|
||||
private int transferRate = 0;
|
||||
private TRContent.Cables cableType = null;
|
||||
private ArrayList<Direction> sendingFace = new ArrayList<Direction>();
|
||||
int ticksSinceLastChange = 0;
|
||||
private ArrayList<EnergySide> sendingFace = new ArrayList<>();
|
||||
|
||||
public CableBlockEntity() {
|
||||
super(TRBlockEntities.CABLE);
|
||||
}
|
||||
|
||||
public CableBlockEntity(TRContent.Cables type) {
|
||||
super(TRBlockEntities.CABLE);
|
||||
this.cableType = type;
|
||||
}
|
||||
|
||||
private TRContent.Cables getCableType() {
|
||||
if (cableType != null) {
|
||||
return cableType;
|
||||
}
|
||||
if (world == null) {
|
||||
return TRContent.Cables.COPPER;
|
||||
}
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if(block instanceof BlockCable){
|
||||
return ((BlockCable) block).type;
|
||||
if(block instanceof CableBlock){
|
||||
return ((CableBlock) block).type;
|
||||
}
|
||||
//Something has gone wrong if this happens
|
||||
return TRContent.Cables.COPPER;
|
||||
|
@ -108,61 +118,57 @@ public class CableBlockEntity extends BlockEntity
|
|||
}
|
||||
return compound;
|
||||
}
|
||||
|
||||
// ITickable
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
if (world.isClient) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cableType == null) {
|
||||
cableType = getCableType();
|
||||
transferRate = cableType.transferRate;
|
||||
sendingFace.clear();
|
||||
|
||||
if(getEnergy() == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
ticksSinceLastChange++;
|
||||
if (ticksSinceLastChange >= 20) {
|
||||
sendingFace.clear();
|
||||
ticksSinceLastChange = 0;
|
||||
}
|
||||
|
||||
ArrayList<BlockEntity> acceptors = new ArrayList<BlockEntity>();
|
||||
ArrayList<Pair<BlockEntity, Direction>> acceptors = new ArrayList<>();
|
||||
for (Direction face : Direction.values()) {
|
||||
EnergySide side = EnergySide.fromMinecraft(face);
|
||||
BlockEntity blockEntity = world.getBlockEntity(pos.offset(face));
|
||||
|
||||
if (blockEntity == null) {
|
||||
continue;
|
||||
} else if (Energy.valid(blockEntity)) {
|
||||
if (blockEntity != null && Energy.valid(blockEntity)) {
|
||||
if (blockEntity instanceof CableBlockEntity && energy <= Energy.of(blockEntity).side(EnergySide.fromMinecraft(face)).getEnergy()) {
|
||||
continue;
|
||||
}
|
||||
acceptors.add(blockEntity);
|
||||
if (!sendingFace.contains(face)) {
|
||||
sendingFace.add(face);
|
||||
if(Energy.of(blockEntity).side(EnergySide.fromMinecraft(face.getOpposite())).getMaxInput() > 0){
|
||||
acceptors.add(Pair.of(blockEntity, face));
|
||||
if (!sendingFace.contains(side)) {
|
||||
sendingFace.add(side);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (acceptors.size() == 0) {
|
||||
if (acceptors.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Collections.shuffle(acceptors);
|
||||
acceptors.forEach(blockEntity -> Energy.of(this)
|
||||
.into(Energy.of(blockEntity))
|
||||
.move());
|
||||
|
||||
acceptors.forEach(pair -> {
|
||||
Energy.of(this)
|
||||
.into(Energy.of(pair.getLeft()).side(EnergySide.fromMinecraft(pair.getRight().getOpposite())))
|
||||
.move();
|
||||
});
|
||||
}
|
||||
|
||||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||
if (isReal) {
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.transferRate") + ": "
|
||||
+ Formatting.GOLD
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(transferRate) + "/t"));
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(getCableType().transferRate) + "/t"));
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.tier") + ": "
|
||||
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(cableType.tier.toString())));
|
||||
}
|
||||
+ Formatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getCableType().tier.toString())));
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
|
@ -190,7 +196,7 @@ public class CableBlockEntity extends BlockEntity
|
|||
return energyOut;
|
||||
}
|
||||
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
public boolean canAcceptEnergy(EnergySide direction) {
|
||||
if (sendingFace.contains(direction)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -199,22 +205,25 @@ public class CableBlockEntity extends BlockEntity
|
|||
|
||||
@Override
|
||||
public double getMaxInput(EnergySide side) {
|
||||
return transferRate;
|
||||
if(!canAcceptEnergy(side)) {
|
||||
return 0;
|
||||
}
|
||||
return getCableType().transferRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxOutput(EnergySide side) {
|
||||
return transferRate;
|
||||
return getCableType().transferRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxStoredPower() {
|
||||
return transferRate * 4;
|
||||
return getCableType().transferRate * 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnergyTier getTier() {
|
||||
return PowerAcceptorBlockEntity.getTier(cableType.transferRate);
|
||||
return PowerAcceptorBlockEntity.getTier(getCableType().transferRate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -54,6 +54,11 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
public SolarPanelBlockEntity() {
|
||||
super(TRBlockEntities.SOLAR_PANEL);
|
||||
}
|
||||
|
||||
public SolarPanelBlockEntity(SolarPanels panel) {
|
||||
super(TRBlockEntities.SOLAR_PANEL);
|
||||
this.panel = panel;
|
||||
}
|
||||
|
||||
public boolean isSunOut() {
|
||||
return canSeeSky && !world.isRaining() && !world.isThundering() && world.isDaylight();
|
||||
|
@ -145,13 +150,16 @@ public class SolarPanelBlockEntity extends PowerAcceptorBlockEntity implements I
|
|||
|
||||
@Override
|
||||
public void addInfo(List<Text> info, boolean isReal, boolean hasData) {
|
||||
if (panel == SolarPanels.CREATIVE) {
|
||||
return;
|
||||
}
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("reborncore.tooltip.energy.maxEnergy") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(getMaxPower())));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.day") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD)));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.day") + ": "
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("techreborn.tooltip.generationRate.night") + ": "
|
||||
+ Formatting.GOLD + PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN)));
|
||||
|
||||
info.add(new LiteralText(Formatting.GRAY + StringUtils.t("reborncore.tooltip.energy.tier") + ": "
|
||||
|
|
|
@ -1,207 +1,233 @@
|
|||
package techreborn.blockentity.machine.iron;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
||||
public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop {
|
||||
|
||||
public RebornInventory<?> inventory;
|
||||
public int burnTime;
|
||||
public int totalBurnTime;
|
||||
public int progress;
|
||||
public int totalCookingTime;
|
||||
int fuelSlot;
|
||||
Block toolDrop;
|
||||
boolean active = false;
|
||||
|
||||
public AbstractIronMachineBlockEntity(BlockEntityType<?> blockEntityTypeIn, int fuelSlot, Block toolDrop) {
|
||||
super(blockEntityTypeIn);
|
||||
this.fuelSlot = fuelSlot;
|
||||
// default value for vanilla smelting recipes is 200
|
||||
this.totalCookingTime = (int) (200 / TechRebornConfig.cookingScale);
|
||||
this.toolDrop = toolDrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that we have all inputs and can put output into slot
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean canSmelt();
|
||||
|
||||
/**
|
||||
* Turn ingredients into the appropriate smelted
|
||||
* item in the output slot
|
||||
*/
|
||||
protected abstract void smelt();
|
||||
|
||||
/**
|
||||
* Returns the number of ticks that the supplied fuel item will keep the
|
||||
* furnace burning, or 0 if the item isn't fuel
|
||||
* @param stack Itemstack of fuel
|
||||
* @return Integer Number of ticks
|
||||
*/
|
||||
private int getItemBurnTime(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0) * TechRebornConfig.fuelScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns remaining fraction of fuel burn time
|
||||
* @param scale Scale to use for burn time
|
||||
* @return int scaled remaining fuel burn time
|
||||
*/
|
||||
public int getBurnTimeRemainingScaled(int scale) {
|
||||
if (totalBurnTime == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return burnTime * scale / totalBurnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns crafting progress
|
||||
* @param scale Scale to use for crafting progress
|
||||
* @return int Scaled crafting progress
|
||||
*/
|
||||
public int getProgressScaled(int scale) {
|
||||
if (totalCookingTime > 0) {
|
||||
return progress * scale / totalCookingTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Iron Machine is burning fuel thus can do work
|
||||
* @return Boolean True if machine is burning
|
||||
*/
|
||||
public boolean isBurning() {
|
||||
return burnTime > 0;
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) state.getBlock();
|
||||
if (state.get(BlockMachineBase.ACTIVE) != burnTime > 0)
|
||||
blockMachineBase.setActive(burnTime > 0, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// MachineBaseBlockEntity
|
||||
@Override
|
||||
public void fromTag(CompoundTag compoundTag) {
|
||||
super.fromTag(compoundTag);
|
||||
burnTime = compoundTag.getInt("BurnTime");
|
||||
totalBurnTime = compoundTag.getInt("TotalBurnTime");
|
||||
progress = compoundTag.getInt("Progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putInt("BurnTime", burnTime);
|
||||
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
||||
compoundTag.putInt("Progress", progress);
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(world.isClient){
|
||||
return;
|
||||
}
|
||||
boolean isBurning = isBurning();
|
||||
if (isBurning) {
|
||||
--burnTime;
|
||||
}
|
||||
|
||||
if (!isBurning && canSmelt()) {
|
||||
burnTime = totalBurnTime = getItemBurnTime(inventory.getInvStack(fuelSlot));
|
||||
if (burnTime > 0) {
|
||||
// Fuel slot
|
||||
ItemStack fuelStack = inventory.getInvStack(fuelSlot);
|
||||
if (fuelStack.getItem().hasRecipeRemainder()) {
|
||||
inventory.setInvStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
|
||||
} else if (fuelStack.getCount() > 1) {
|
||||
inventory.shrinkSlot(fuelSlot, 1);
|
||||
} else if (fuelStack.getCount() == 1) {
|
||||
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isBurning() && canSmelt()) {
|
||||
++progress;
|
||||
if (progress == totalCookingTime) {
|
||||
progress = 0;
|
||||
smelt();
|
||||
}
|
||||
} else {
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
if (isBurning != isBurning()) {
|
||||
inventory.setChanged();
|
||||
updateState();
|
||||
}
|
||||
if (inventory.hasChanged()) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// InventoryProvider
|
||||
@Override
|
||||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
return new ItemStack(toolDrop);
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.burnTime;
|
||||
}
|
||||
|
||||
public void setBurnTime(int burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
public int getTotalBurnTime() {
|
||||
return this.totalBurnTime;
|
||||
}
|
||||
|
||||
public void setTotalBurnTime(int totalBurnTime) {
|
||||
this.totalBurnTime = totalBurnTime;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.blockentity.machine.iron;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.entity.AbstractFurnaceBlockEntity;
|
||||
import net.minecraft.block.entity.BlockEntityType;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.blockentity.MachineBaseBlockEntity;
|
||||
import reborncore.common.blockentity.SlotConfiguration;
|
||||
import reborncore.common.blocks.BlockMachineBase;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
||||
public abstract class AbstractIronMachineBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, SlotConfiguration.SlotFilter {
|
||||
|
||||
public RebornInventory<?> inventory;
|
||||
public int burnTime;
|
||||
public int totalBurnTime;
|
||||
public int progress;
|
||||
public int totalCookingTime;
|
||||
int fuelSlot;
|
||||
Block toolDrop;
|
||||
boolean active = false;
|
||||
|
||||
public AbstractIronMachineBlockEntity(BlockEntityType<?> blockEntityTypeIn, int fuelSlot, Block toolDrop) {
|
||||
super(blockEntityTypeIn);
|
||||
this.fuelSlot = fuelSlot;
|
||||
// default value for vanilla smelting recipes is 200
|
||||
this.totalCookingTime = (int) (200 / TechRebornConfig.cookingScale);
|
||||
this.toolDrop = toolDrop;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that we have all inputs and can put output into slot
|
||||
* @return
|
||||
*/
|
||||
protected abstract boolean canSmelt();
|
||||
|
||||
/**
|
||||
* Turn ingredients into the appropriate smelted
|
||||
* item in the output slot
|
||||
*/
|
||||
protected abstract void smelt();
|
||||
|
||||
/**
|
||||
* Returns the number of ticks that the supplied fuel item will keep the
|
||||
* furnace burning, or 0 if the item isn't fuel
|
||||
* @param stack Itemstack of fuel
|
||||
* @return Integer Number of ticks
|
||||
*/
|
||||
private int getItemBurnTime(ItemStack stack) {
|
||||
if (stack.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
return (int) (AbstractFurnaceBlockEntity.createFuelTimeMap().getOrDefault(stack.getItem(), 0) * TechRebornConfig.fuelScale);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns remaining fraction of fuel burn time
|
||||
* @param scale Scale to use for burn time
|
||||
* @return int scaled remaining fuel burn time
|
||||
*/
|
||||
public int getBurnTimeRemainingScaled(int scale) {
|
||||
if (totalBurnTime == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return burnTime * scale / totalBurnTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns crafting progress
|
||||
* @param scale Scale to use for crafting progress
|
||||
* @return int Scaled crafting progress
|
||||
*/
|
||||
public int getProgressScaled(int scale) {
|
||||
if (totalCookingTime > 0) {
|
||||
return progress * scale / totalCookingTime;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if Iron Machine is burning fuel thus can do work
|
||||
* @return Boolean True if machine is burning
|
||||
*/
|
||||
public boolean isBurning() {
|
||||
return burnTime > 0;
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
BlockState state = world.getBlockState(pos);
|
||||
if (state.getBlock() instanceof BlockMachineBase) {
|
||||
BlockMachineBase blockMachineBase = (BlockMachineBase) state.getBlock();
|
||||
if (state.get(BlockMachineBase.ACTIVE) != burnTime > 0)
|
||||
blockMachineBase.setActive(burnTime > 0, world, pos);
|
||||
}
|
||||
}
|
||||
|
||||
// MachineBaseBlockEntity
|
||||
@Override
|
||||
public void fromTag(CompoundTag compoundTag) {
|
||||
super.fromTag(compoundTag);
|
||||
burnTime = compoundTag.getInt("BurnTime");
|
||||
totalBurnTime = compoundTag.getInt("TotalBurnTime");
|
||||
progress = compoundTag.getInt("Progress");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag toTag(CompoundTag compoundTag) {
|
||||
super.toTag(compoundTag);
|
||||
compoundTag.putInt("BurnTime", burnTime);
|
||||
compoundTag.putInt("TotalBurnTime", totalBurnTime);
|
||||
compoundTag.putInt("Progress", progress);
|
||||
return compoundTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tick() {
|
||||
super.tick();
|
||||
if(world.isClient){
|
||||
return;
|
||||
}
|
||||
boolean isBurning = isBurning();
|
||||
if (isBurning) {
|
||||
--burnTime;
|
||||
}
|
||||
|
||||
if (!isBurning && canSmelt()) {
|
||||
burnTime = totalBurnTime = getItemBurnTime(inventory.getInvStack(fuelSlot));
|
||||
if (burnTime > 0) {
|
||||
// Fuel slot
|
||||
ItemStack fuelStack = inventory.getInvStack(fuelSlot);
|
||||
if (fuelStack.getItem().hasRecipeRemainder()) {
|
||||
inventory.setInvStack(fuelSlot, new ItemStack(fuelStack.getItem().getRecipeRemainder()));
|
||||
} else if (fuelStack.getCount() > 1) {
|
||||
inventory.shrinkSlot(fuelSlot, 1);
|
||||
} else if (fuelStack.getCount() == 1) {
|
||||
inventory.setInvStack(fuelSlot, ItemStack.EMPTY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isBurning() && canSmelt()) {
|
||||
++progress;
|
||||
if (progress == totalCookingTime) {
|
||||
progress = 0;
|
||||
smelt();
|
||||
}
|
||||
} else if(!canSmelt()) {
|
||||
progress = 0;
|
||||
}
|
||||
|
||||
if (isBurning != isBurning()) {
|
||||
inventory.setChanged();
|
||||
updateState();
|
||||
}
|
||||
if (inventory.hasChanged()) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeUpgraded() {
|
||||
return false;
|
||||
}
|
||||
|
||||
// InventoryProvider
|
||||
@Override
|
||||
public RebornInventory<?> getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
|
||||
// IToolDrop
|
||||
@Override
|
||||
public ItemStack getToolDrop(PlayerEntity entityPlayer) {
|
||||
return new ItemStack(toolDrop);
|
||||
}
|
||||
|
||||
public int getBurnTime() {
|
||||
return this.burnTime;
|
||||
}
|
||||
|
||||
public void setBurnTime(int burnTime) {
|
||||
this.burnTime = burnTime;
|
||||
}
|
||||
|
||||
public int getTotalBurnTime() {
|
||||
return this.totalBurnTime;
|
||||
}
|
||||
|
||||
public void setTotalBurnTime(int totalBurnTime) {
|
||||
this.totalBurnTime = totalBurnTime;
|
||||
}
|
||||
|
||||
public int getProgress() {
|
||||
return progress;
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -136,4 +136,17 @@ public class IronAlloyFurnaceBlockEntity extends AbstractIronMachineBlockEntity
|
|||
.syncIntegerValue(this::getTotalBurnTime, this::setTotalBurnTime)
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStackValid(int slotID, ItemStack stack) {
|
||||
return ModRecipes.ALLOY_SMELTER.getRecipes(world).stream()
|
||||
.anyMatch(rebornRecipe -> rebornRecipe.getRebornIngredients().stream()
|
||||
.anyMatch(rebornIngredient -> rebornIngredient.test(stack))
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInputSlots() {
|
||||
return new int[]{input1, input2};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,6 @@
|
|||
|
||||
package techreborn.blockentity.machine.iron;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import net.minecraft.entity.ExperienceOrbEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -41,6 +39,8 @@ import techreborn.init.TRBlockEntities;
|
|||
import techreborn.init.TRContent;
|
||||
import techreborn.utils.RecipeUtils;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
int inputSlot = 0;
|
||||
|
@ -118,7 +118,12 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
int result = inventory.getInvStack(outputSlot).getCount() + outputStack.getCount();
|
||||
return result <= inventory.getStackLimit() && result <= outputStack.getMaxCount();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isStackValid(int slotID, ItemStack stack) {
|
||||
return !getResultFor(stack).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromTag(CompoundTag compoundTag) {
|
||||
super.fromTag(compoundTag);
|
||||
|
@ -141,6 +146,11 @@ public class IronFurnaceBlockEntity extends AbstractIronMachineBlockEntity imple
|
|||
this.experience = experience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getInputSlots() {
|
||||
return new int[]{inputSlot};
|
||||
}
|
||||
|
||||
@Override
|
||||
public BuiltContainer createContainer(int syncID, final PlayerEntity player) {
|
||||
return new ContainerBuilder("ironfurnace").player(player.inventory).inventory().hotbar()
|
||||
|
|
|
@ -30,6 +30,7 @@ import net.minecraft.util.math.BlockPos;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
|
@ -40,8 +41,6 @@ import techreborn.init.TRContent;
|
|||
|
||||
public class DistillationTowerBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
||||
|
||||
public MultiblockChecker multiblockChecker;
|
||||
|
||||
public DistillationTowerBlockEntity() {
|
||||
|
@ -74,10 +73,8 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
|||
final BlockPos downCenter = pos.method_10079(getFacing().getOpposite(), 2);
|
||||
multiblockChecker = new MultiblockChecker(world, downCenter);
|
||||
}
|
||||
|
||||
if (!world.isClient && getMutliBlock()){
|
||||
super.tick();
|
||||
}
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
@ -88,4 +85,9 @@ public class DistillationTowerBlockEntity extends GenericMachineBlockEntity impl
|
|||
.outputSlot(4, 119, 37).outputSlot(5, 139, 37).energySlot(6, 8, 72).syncEnergyValue().syncCrafterValue()
|
||||
.addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(RebornRecipe rebornRecipe) {
|
||||
return getMutliBlock();
|
||||
}
|
||||
}
|
|
@ -29,13 +29,14 @@ import net.minecraft.util.math.BlockPos;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.recipes.RecipeCrafter;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.init.TRBlockEntities;
|
||||
import techreborn.blockentity.GenericMachineBlockEntity;
|
||||
import techreborn.init.TRContent;
|
||||
|
||||
public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity implements IContainerProvider {
|
||||
|
||||
|
@ -65,10 +66,8 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
|||
if (multiblockChecker == null) {
|
||||
multiblockChecker = new MultiblockChecker(world, pos.down(3));
|
||||
}
|
||||
|
||||
if (!world.isClient && getMutliBlock()){
|
||||
super.tick();
|
||||
}
|
||||
|
||||
super.tick();
|
||||
}
|
||||
|
||||
// IContainerProvider
|
||||
|
@ -78,4 +77,9 @@ public class ImplosionCompressorBlockEntity extends GenericMachineBlockEntity im
|
|||
.blockEntity(this).slot(0, 50, 27).slot(1, 50, 47).outputSlot(2, 92, 36).outputSlot(3, 110, 36)
|
||||
.energySlot(4, 8, 72).syncEnergyValue().syncCrafterValue().addInventory().create(this, syncID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canCraft(RebornRecipe rebornRecipe) {
|
||||
return getMutliBlock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,9 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.Direction;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.blockentity.InventoryProvider;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
|
||||
import reborncore.common.util.RebornInventory;
|
||||
import team.reborn.energy.Energy;
|
||||
import team.reborn.energy.EnergyTier;
|
||||
import techreborn.blocks.storage.BlockEnergyStorage;
|
||||
|
||||
|
@ -72,8 +72,13 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
|||
if (!inventory.getInvStack(0).isEmpty()) {
|
||||
ItemStack stack = inventory.getInvStack(0);
|
||||
|
||||
if (ExternalPowerSystems.isPoweredItem(stack)) {
|
||||
ExternalPowerSystems.chargeItem(this, stack);
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(this)
|
||||
.into(
|
||||
Energy
|
||||
.of(stack)
|
||||
)
|
||||
.move();
|
||||
}
|
||||
}
|
||||
if (!inventory.getInvStack(1).isEmpty()) {
|
||||
|
@ -88,12 +93,12 @@ public class EnergyStorageBlockEntity extends PowerAcceptorBlockEntity
|
|||
|
||||
@Override
|
||||
public boolean canAcceptEnergy(Direction direction) {
|
||||
return getFacing() != direction;
|
||||
return direction == null || getFacing() != direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy(Direction direction) {
|
||||
return getFacing() == direction;
|
||||
return direction == null || getFacing() == direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
|
|||
import reborncore.client.containerBuilder.IContainerProvider;
|
||||
import reborncore.client.containerBuilder.builder.BuiltContainer;
|
||||
import reborncore.client.containerBuilder.builder.ContainerBuilder;
|
||||
import team.reborn.energy.EnergySide;
|
||||
import team.reborn.energy.EnergyTier;
|
||||
import techreborn.blockentity.storage.EnergyStorageBlockEntity;
|
||||
import techreborn.config.TechRebornConfig;
|
||||
|
@ -48,7 +49,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public double getEnergy() {
|
||||
public double getStored(EnergySide face) {
|
||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||
return 0.0;
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ public class InterdimensionalSUBlockEntity extends EnergyStorageBlockEntity impl
|
|||
}
|
||||
|
||||
@Override
|
||||
public void setEnergy(double energy) {
|
||||
public void setStored(double energy) {
|
||||
if (ownerUdid == null || ownerUdid.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -122,6 +122,9 @@ public class TransformerBlockEntity extends PowerAcceptorBlockEntity
|
|||
// TileMachineBase
|
||||
@Override
|
||||
public Direction getFacingEnum() {
|
||||
if(world == null){
|
||||
return null;
|
||||
}
|
||||
Block block = world.getBlockState(pos).getBlock();
|
||||
if (block instanceof BlockTransformer) {
|
||||
return ((BlockTransformer) block).getFacing(world.getBlockState(pos));
|
||||
|
|
|
@ -39,10 +39,12 @@ import net.minecraft.state.property.AbstractProperty;
|
|||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.util.ActionResult;
|
||||
import net.minecraft.util.Hand;
|
||||
import net.minecraft.util.SystemUtil;
|
||||
import net.minecraft.util.hit.BlockHitResult;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.shape.VoxelShape;
|
||||
import net.minecraft.util.shape.VoxelShapes;
|
||||
import net.minecraft.world.BlockView;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
|
@ -57,11 +59,15 @@ import techreborn.init.TRContent;
|
|||
import techreborn.utils.damageSources.ElectrialShockSource;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by modmuss50 on 19/05/2017.
|
||||
*/
|
||||
public class BlockCable extends BlockWithEntity {
|
||||
public class CableBlock extends BlockWithEntity {
|
||||
|
||||
public static final BooleanProperty EAST = BooleanProperty.of("east");
|
||||
public static final BooleanProperty WEST = BooleanProperty.of("west");
|
||||
|
@ -70,9 +76,18 @@ public class BlockCable extends BlockWithEntity {
|
|||
public static final BooleanProperty UP = BooleanProperty.of("up");
|
||||
public static final BooleanProperty DOWN = BooleanProperty.of("down");
|
||||
|
||||
public static final Map<Direction, BooleanProperty> PROPERTY_MAP = SystemUtil.consume(new HashMap<>(), map -> {
|
||||
map.put(Direction.EAST, EAST);
|
||||
map.put(Direction.WEST, WEST);
|
||||
map.put(Direction.NORTH, NORTH);
|
||||
map.put(Direction.SOUTH, SOUTH);
|
||||
map.put(Direction.UP, UP);
|
||||
map.put(Direction.DOWN, DOWN);
|
||||
});
|
||||
|
||||
public final TRContent.Cables type;
|
||||
|
||||
public BlockCable(TRContent.Cables type) {
|
||||
public CableBlock(TRContent.Cables type) {
|
||||
super(Block.Settings.of(Material.STONE).strength(1f, 8f));
|
||||
this.type = type;
|
||||
setDefaultState(this.stateFactory.getDefaultState().with(EAST, false).with(WEST, false).with(NORTH, false)
|
||||
|
@ -128,7 +143,7 @@ public class BlockCable extends BlockWithEntity {
|
|||
@Nullable
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||
return new CableBlockEntity();
|
||||
return new CableBlockEntity(type);
|
||||
}
|
||||
|
||||
// Block
|
||||
|
@ -169,13 +184,21 @@ public class BlockCable extends BlockWithEntity {
|
|||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState state, BlockView world, BlockPos pos, EntityContext entityContext) {
|
||||
if (type != null) {
|
||||
// outline is 1px bigger then model to ease selection
|
||||
double culling = type.cableThickness - 1;
|
||||
return Block.createCuboidShape(culling, culling, culling, 16.0D - culling, 16.0D - culling,
|
||||
16.0D - culling);
|
||||
double size = type != null ? type.cableThickness : 6;
|
||||
VoxelShape baseShape = Block.createCuboidShape(size, size, size, 16.0D - size, 16.0D - size, 16.0D - size);
|
||||
|
||||
List<VoxelShape> connections = new ArrayList<>();
|
||||
for(Direction dir : Direction.values()){
|
||||
if(state.get(PROPERTY_MAP.get(dir))) {
|
||||
double x = dir == Direction.WEST ? 0 : dir == Direction.EAST ? 16D : size;
|
||||
double z = dir == Direction.NORTH ? 0 : dir == Direction.SOUTH ? 16D : size;
|
||||
double y = dir == Direction.DOWN ? 0 : dir == Direction.UP ? 16D : size;
|
||||
|
||||
VoxelShape shape = Block.createCuboidShape(x, y, z, 16.0D - size, 16.0D - size, 16.0D - size);
|
||||
connections.add(shape);
|
||||
}
|
||||
}
|
||||
return Block.createCuboidShape(4, 4, 4, 12, 12, 12);
|
||||
return VoxelShapes.union(baseShape, connections.toArray(new VoxelShape[]{}));
|
||||
}
|
||||
|
||||
@Override
|
|
@ -45,7 +45,7 @@ public class BlockSolarPanel extends BlockMachineBase {
|
|||
|
||||
@Override
|
||||
public BlockEntity createBlockEntity(BlockView worldIn) {
|
||||
return new SolarPanelBlockEntity();
|
||||
return new SolarPanelBlockEntity(panelType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ package techreborn.blocks.lighting;
|
|||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.entity.EntityContext;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemPlacementContext;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
@ -61,25 +62,29 @@ public class BlockLamp extends BaseBlockEntityProvider {
|
|||
|
||||
public BlockLamp(int cost, double depth, double width) {
|
||||
super(FabricBlockSettings.of(Material.REDSTONE_LAMP).strength(2f, 2f).lightLevel(brightness).build());
|
||||
this.shape = GenCuboidShapes(depth, width);
|
||||
this.shape = genCuboidShapes(depth, width);
|
||||
this.cost = cost;
|
||||
this.setDefaultState(this.stateFactory.getDefaultState().with(FACING, Direction.NORTH).with(ACTIVE, false));
|
||||
BlockWrenchEventHandler.wrenableBlocks.add(this);
|
||||
}
|
||||
|
||||
private VoxelShape[] GenCuboidShapes(double depth, double width) {
|
||||
private VoxelShape[] genCuboidShapes(double depth, double width) {
|
||||
double culling = (16.0D - width) / 2 ;
|
||||
VoxelShape[] shapes = {
|
||||
Block.createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||
Block.createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||
Block.createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
Block.createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
Block.createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
Block.createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
return new VoxelShape[]{
|
||||
createCuboidShape(culling, 16.0 - depth, culling, 16.0 - culling, 16.0D, 16.0 - culling),
|
||||
createCuboidShape(culling, 0.0D, culling, 16.0D - culling, depth, 16.0 - culling),
|
||||
createCuboidShape(culling, culling, 16.0 - depth, 16.0 - culling, 16.0 - culling, 16.0D),
|
||||
createCuboidShape(culling, culling, 0.0D, 16.0 - culling, 16.0 - culling, depth),
|
||||
createCuboidShape(16.0 - depth, culling, culling, 16.0D, 16.0 - culling, 16.0 - culling),
|
||||
createCuboidShape(0.0D, culling, culling, depth, 16.0 - culling, 16.0 - culling)
|
||||
};
|
||||
return shapes;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public VoxelShape getOutlineShape(BlockState blockState, BlockView blockView, BlockPos blockPos, EntityContext entityContext) {
|
||||
return shape[blockState.get(FACING).ordinal()];
|
||||
}
|
||||
|
||||
public static boolean isActive(BlockState state) {
|
||||
return state.get(ACTIVE);
|
||||
}
|
||||
|
|
|
@ -26,7 +26,9 @@ package techreborn.blocks.misc;
|
|||
|
||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||
import net.minecraft.block.*;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.AxeItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
|
@ -44,7 +46,6 @@ import net.minecraft.util.hit.BlockHitResult;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.util.WorldUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
import techreborn.events.TRRecipeHandler;
|
||||
|
@ -120,24 +121,36 @@ public class BlockRubberLog extends LogBlock {
|
|||
return ActionResult.PASS;
|
||||
}
|
||||
|
||||
if (stack.getItem() instanceof AxeItem) {
|
||||
worldIn.playSound(playerIn, pos, SoundEvents.ITEM_AXE_STRIP, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
if (worldIn.isClient) {
|
||||
return true;
|
||||
}
|
||||
worldIn.setBlockState(pos, TRContent.RUBBER_LOG_STRIPPED.getDefaultState().with(PillarBlock.AXIS, state.get(PillarBlock.AXIS)), 11);
|
||||
if (playerIn instanceof LivingEntity) {
|
||||
LivingEntity playerEntity = (LivingEntity) playerIn;
|
||||
stack.damage(1, playerEntity, player -> { player.sendToolBreakStatus(hand); });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((Energy.valid(stack) && Energy.of(stack).getEnergy() > 20) || stack.getItem() instanceof ItemTreeTap) {
|
||||
if (state.get(HAS_SAP) && state.get(SAP_SIDE) == hitResult.getSide()) {
|
||||
worldIn.setBlockState(pos, state.with(HAS_SAP, false).with(SAP_SIDE, Direction.fromHorizontal(0)));
|
||||
worldIn.playSound(null, pos.getX(), pos.getY(), pos.getZ(), ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS,
|
||||
0.6F, 1F);
|
||||
if (!worldIn.isClient) {
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(stack).use(20);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, playerIn);
|
||||
} else {
|
||||
playerIn.getStackInHand(Hand.MAIN_HAND).damage(1, playerIn, playerEntity -> {});
|
||||
}
|
||||
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
||||
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
||||
}
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
|
||||
}
|
||||
worldIn.playSound(playerIn, pos, ModSounds.SAP_EXTRACT, SoundCategory.BLOCKS, 0.6F, 1F);
|
||||
if (worldIn.isClient) {
|
||||
return true;
|
||||
}
|
||||
if (Energy.valid(stack)) {
|
||||
Energy.of(stack).use(20);
|
||||
} else {
|
||||
stack.damage(1, playerIn, player -> { player.sendToolBreakStatus(hand); });
|
||||
}
|
||||
if (!playerIn.inventory.insertStack(TRContent.Parts.SAP.getStack())) {
|
||||
WorldUtils.dropItem(TRContent.Parts.SAP.getStack(), worldIn, pos.offset(hitResult.getSide()));
|
||||
}
|
||||
if (playerIn instanceof ServerPlayerEntity) {
|
||||
TRRecipeHandler.unlockTRRecipes((ServerPlayerEntity) playerIn);
|
||||
}
|
||||
return ActionResult.SUCCESS;
|
||||
}
|
||||
|
|
|
@ -1,3 +1,27 @@
|
|||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
package techreborn.client.render;
|
||||
|
||||
import net.fabricmc.fabric.api.client.render.fluid.v1.FluidRenderHandler;
|
||||
|
|
102
src/main/java/techreborn/compat/libcd/TRRecipeParser.java
Normal file
|
@ -0,0 +1,102 @@
|
|||
package techreborn.compat.libcd;
|
||||
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import io.github.cottonmc.libcd.tweaker.TweakerSyntaxException;
|
||||
import io.github.cottonmc.libcd.tweaker.TweakerUtils;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.StringNbtReader;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.common.crafting.ingredient.*;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Optional;
|
||||
|
||||
public class TRRecipeParser {
|
||||
|
||||
public static RebornIngredient processIngredient(Object input) throws TweakerSyntaxException {
|
||||
if (input instanceof RebornIngredient) {
|
||||
return (RebornIngredient) input;
|
||||
} else if (input instanceof Ingredient) {
|
||||
return new WrappedIngredient((Ingredient) input);
|
||||
} else if (input instanceof String) {
|
||||
String in = (String) input;
|
||||
Optional<Integer> amount = Optional.empty();
|
||||
int atIndex = in.lastIndexOf('@');
|
||||
if (atIndex != -1 && in.lastIndexOf('}') < atIndex) {
|
||||
String count = in.substring(atIndex + 1);
|
||||
amount = Optional.of(Integer.parseInt(count));
|
||||
in = in.substring(0, atIndex);
|
||||
}
|
||||
if (in.indexOf('~') == 0) {
|
||||
//fluids
|
||||
Identifier id = new Identifier(in.substring(1));
|
||||
Fluid fluid = Registry.FLUID.get(id);
|
||||
if (fluid == Fluids.EMPTY) throw new TweakerSyntaxException("Failed to get fluid for input: " + in);
|
||||
return new FluidIngredient(fluid, Optional.empty(), amount);
|
||||
} else if (in.indexOf('#') == 0) {
|
||||
Identifier id = new Identifier(in.substring(1));
|
||||
Tag<Item> itemTag = ItemTags.getContainer().get(id);
|
||||
if (itemTag == null) throw new TweakerSyntaxException("Failed to get item tag for input: " + in);
|
||||
return new TagIngredient(id, ItemTags.getContainer().get(id), amount);
|
||||
} else {
|
||||
ItemStack stack;
|
||||
Optional<CompoundTag> tag = Optional.empty();
|
||||
boolean requireEmpty = false;
|
||||
if (in.contains("->")) {
|
||||
ItemStack readStack = TweakerUtils.INSTANCE.getSpecialStack(in);
|
||||
if (readStack.isEmpty())
|
||||
throw new TweakerSyntaxException("Failed to get special stack for input: " + in);
|
||||
if (readStack.hasTag()) {
|
||||
tag = Optional.of(readStack.getTag());
|
||||
} else {
|
||||
requireEmpty = true;
|
||||
}
|
||||
stack = readStack;
|
||||
} else {
|
||||
int nbtIndex = in.indexOf('{');
|
||||
if (nbtIndex != -1) {
|
||||
try {
|
||||
String nbt = in.substring(nbtIndex);
|
||||
in = in.substring(0, nbtIndex);
|
||||
StringNbtReader reader = new StringNbtReader(new StringReader(nbt));
|
||||
CompoundTag parsedTag = reader.parseCompoundTag();
|
||||
if (parsedTag.isEmpty()) requireEmpty = true;
|
||||
else tag = Optional.of(reader.parseCompoundTag());
|
||||
} catch (CommandSyntaxException e) {
|
||||
throw new TweakerSyntaxException(e.getMessage());
|
||||
}
|
||||
}
|
||||
Identifier id = new Identifier(in);
|
||||
Item item = Registry.ITEM.get(id);
|
||||
if (item == Items.AIR) throw new TweakerSyntaxException("Failed to get item for input: " + in);
|
||||
stack = new ItemStack(item);
|
||||
}
|
||||
return new StackIngredient(Collections.singletonList(stack), amount, tag, requireEmpty);
|
||||
}
|
||||
}
|
||||
else throw new TweakerSyntaxException("Illegal object passed to TechReborn of type " + input.getClass().getName());
|
||||
}
|
||||
|
||||
public static FluidInstance parseFluid(String fluid) {
|
||||
int amount = 1000;
|
||||
int amtIndex = fluid.indexOf('@');
|
||||
if (amtIndex != -1) {
|
||||
String amtStr = fluid.substring(amtIndex + 1);
|
||||
fluid = fluid.substring(0, amtIndex);
|
||||
amount = Integer.parseInt(amtStr);
|
||||
}
|
||||
Identifier id = new Identifier(fluid);
|
||||
return new FluidInstance(Registry.FLUID.get(id), amount);
|
||||
}
|
||||
}
|
534
src/main/java/techreborn/compat/libcd/TRTweaker.java
Normal file
|
@ -0,0 +1,534 @@
|
|||
package techreborn.compat.libcd;
|
||||
|
||||
import io.github.cottonmc.libcd.tweaker.*;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.recipe.ShapedRecipe;
|
||||
import net.minecraft.resource.ResourceManager;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.crafting.RecipeManager;
|
||||
import reborncore.common.crafting.ingredient.FluidIngredient;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.TechReborn;
|
||||
import techreborn.api.generator.EFluidGenerator;
|
||||
import techreborn.api.generator.FluidGeneratorRecipe;
|
||||
import techreborn.api.generator.GeneratorRecipeHelper;
|
||||
import techreborn.api.recipe.recipes.*;
|
||||
import techreborn.init.ModRecipes;
|
||||
import techreborn.init.TRContent;
|
||||
import techreborn.items.ItemDynamicCell;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class TRTweaker implements Tweaker {
|
||||
public static final TRTweaker INSTANCE = new TRTweaker();
|
||||
private RecipeTweaker tweaker = RecipeTweaker.INSTANCE;
|
||||
|
||||
List<FluidGeneratorRecipe> added = new ArrayList<>();
|
||||
List<FluidGeneratorRecipe> toAdd = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public void prepareReload(ResourceManager resourceManager) {
|
||||
for (FluidGeneratorRecipe recipe : added) {
|
||||
GeneratorRecipeHelper.removeFluidRecipe(recipe.getGeneratorType(), recipe.getFluid());
|
||||
}
|
||||
added.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyReload(ResourceManager resourceManager, Executor executor) {
|
||||
for (FluidGeneratorRecipe recipe : toAdd) {
|
||||
if (GeneratorRecipeHelper.getFluidRecipesForGenerator(recipe.getGeneratorType()).addRecipe(recipe)) {
|
||||
added.add(recipe);
|
||||
} else {
|
||||
TechReborn.LOGGER.error("Could not add recipe to TechReborn generator " + recipe.getGeneratorType().getRecipeID()
|
||||
+ ": a recipe for fluid " + Registry.FLUID.getId(recipe.getFluid()) + " already exists");
|
||||
}
|
||||
}
|
||||
toAdd.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplyMessage() {
|
||||
int recipeCount = added.size();
|
||||
return recipeCount + " TechReborn fluid generator " + (recipeCount == 1? "recipe" : "recipes");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a fluid ingredient
|
||||
* @param fluid The fluid required.
|
||||
* @param holders The fluid-holding items the fluid can be in, or [] for any.
|
||||
* @param amount The amount of fluid needed, or -1 for any.
|
||||
* @return A prepared fluid ingredient.
|
||||
*/
|
||||
public FluidIngredient createFluidIngredient(String fluid, String[] holders, int amount) {
|
||||
Fluid parsedFluid = TweakerUtils.INSTANCE.getFluid(fluid);
|
||||
Optional<List<Item>> parsedHolders;
|
||||
Optional<Integer> count;
|
||||
if (holders.length == 0) parsedHolders = Optional.empty();
|
||||
else {
|
||||
List<Item> items = new ArrayList<>();
|
||||
for (String holder : holders) {
|
||||
items.add(TweakerUtils.INSTANCE.getItem(holder));
|
||||
}
|
||||
parsedHolders = Optional.of(items);
|
||||
}
|
||||
if (amount == -1) count = Optional.empty();
|
||||
else count = Optional.of(amount);
|
||||
return new FluidIngredient(parsedFluid, parsedHolders, count);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a generic TechReborn recipe.
|
||||
* @param type The type of RebornRecipe to add.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void add(RebornRecipeType type, Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
tweaker.addRecipe(new RebornRecipe(type, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn " + type.getName().getPath().replace('_', ' ') + " recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void add(String type, Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
Identifier id;
|
||||
if (type.contains(":")) id = new Identifier(type);
|
||||
else id = new Identifier("techreborn", type);
|
||||
RebornRecipeType<?> recipeType = RecipeManager.getRecipeType(id);
|
||||
add(recipeType, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to smelt in an alloy smelter.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to smelt for.
|
||||
*/
|
||||
public void addAlloySmelter(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.ALLOY_SMELTER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to assemble in an assembling machine.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addAssemblingMachine(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.ASSEMBLING_MACHINE, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to smelt in a TechReborn blast furnace.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to smelt for.
|
||||
* @param heat How hot the blast furnace needs to be.
|
||||
*/
|
||||
public void addBlastFurnace(Object[] inputs, ItemStack[] outputs, int power, int time, int heat) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
tweaker.addRecipe(new BlastFurnaceRecipe(ModRecipes.BLAST_FURNACE, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time, heat));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn blast furnace recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a centrifuge.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addCentrifuge(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.CENTRIFUGE, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a chemical reactor.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addChemicalReactor(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.CHEMICAL_REACTOR, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to compress in a compressor.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addCompressor(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.COMPRESSOR, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to distil in a distillation tower.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addDistillationTower(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.DISTILLATION_TOWER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to extract in an extractor.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addExtractor(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.EXTRACTOR, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a grinder.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addGrinder(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.GRINDER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an implosion compressor.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addImplosionCompressor(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.IMPLOSION_COMPRESSOR, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an industrial electrolyzer.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addIndustrialElectrolyzer(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.INDUSTRIAL_ELECTROLYZER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an industrial grinder.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addIndustrialGrinder(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
tweaker.addRecipe(new IndustrialGrinderRecipe(ModRecipes.INDUSTRIAL_GRINDER, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn industrial grinder recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an industrial grinder.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
* @param fluid The fluid required for the operation, including an amount.
|
||||
*/
|
||||
public void addIndustrialGrinder(Object[] inputs, ItemStack[] outputs, int power, int time, String fluid) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
FluidInstance fluidInst = TRRecipeParser.parseFluid(fluid);
|
||||
tweaker.addRecipe(new IndustrialGrinderRecipe(ModRecipes.INDUSTRIAL_GRINDER, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time, fluidInst));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn industrial grinder recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an industria sawmilll.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addIndustrialSawmill(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
tweaker.addRecipe(new IndustrialSawmillRecipe(ModRecipes.INDUSTRIAL_SAWMILL, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn industrial sawmill recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in an industrial sawmill.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
* @param fluid The fluid required for this operation, including an amount.
|
||||
*/
|
||||
public void addIndustrialSawmill(Object[] inputs, ItemStack[] outputs, int power, int time, String fluid) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
FluidInstance fluidInst = TRRecipeParser.parseFluid(fluid);
|
||||
tweaker.addRecipe(new IndustrialSawmillRecipe(ModRecipes.INDUSTRIAL_SAWMILL, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time, fluidInst));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn industrial sawmill recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a recycler.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addRecycler(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.RECYCLER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to get from a scrapbox. Input is always a scrap box.
|
||||
* @param output The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addScrapbox(ItemStack output, int power, int time) {
|
||||
add(ModRecipes.SCRAPBOX, new String[]{"techreborn:scrap_box"}, new ItemStack[]{output}, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a vacuum freezer.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addVacuumFreezer(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.VACUUM_FREEZER, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a fluid replicator.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
* @param fluid The fluid required for this operation, including an amount.
|
||||
*/
|
||||
public void addFluidReplicator(Object[] inputs, int power, int time, String fluid) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(new ItemStack(TRContent.Parts.UU_MATTER));
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
FluidInstance fluidInst = TRRecipeParser.parseFluid(fluid);
|
||||
tweaker.addRecipe(new FluidReplicatorRecipe(ModRecipes.FLUID_REPLICATOR, id, ingredients, DefaultedList.of(), power, time, fluidInst));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn fluid replicator recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a fusion reactor.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
* @param startE The energy requried to start the reaction.
|
||||
* @param minSize The minimum size of the reactor coil ring for this reaction.
|
||||
*/
|
||||
public void addFusionReactor(Object[] inputs, ItemStack[] outputs, int power, int time, int startE, int minSize) {
|
||||
try {
|
||||
Identifier id = tweaker.getRecipeId(outputs[0]);
|
||||
DefaultedList<RebornIngredient> ingredients = DefaultedList.of();
|
||||
for (Object input : inputs) {
|
||||
ingredients.add(TRRecipeParser.processIngredient(input));
|
||||
}
|
||||
tweaker.addRecipe(new FusionReactorRecipe(ModRecipes.FUSION_REACTOR, id, ingredients, DefaultedList.copyOf(ItemStack.EMPTY, outputs), power, time, startE, minSize));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn fusion reactor recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a rolling machine recipe from a 2D array of inputs, like a standard CraftTweaker recipe.
|
||||
* @param inputs the 2D array (array of arrays) of inputs to use.
|
||||
* @param output The output of the recipe.
|
||||
*/
|
||||
public void addRollingMachine(Object[][] inputs, ItemStack output) {
|
||||
try {
|
||||
Object[] processed = RecipeParser.processGrid(inputs);
|
||||
int width = inputs[0].length;
|
||||
int height = inputs.length;
|
||||
addRollingMachine(processed, output, width, height);
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn rolling machine recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a rolling machine recipe from a 1D array of inputs.
|
||||
* @param inputs The input item or tag ids required in order: left to right, top to bottom.
|
||||
* @param output The output of the recipe.
|
||||
* @param width How many rows the recipe needs.
|
||||
* @param height How many columns the recipe needs.
|
||||
*/
|
||||
public void addRollingMachine(Object[] inputs, ItemStack output, int width, int height) {
|
||||
Identifier recipeId = tweaker.getRecipeId(output);
|
||||
try {
|
||||
DefaultedList<Ingredient> ingredients = DefaultedList.of();
|
||||
for (int i = 0; i < Math.min(inputs.length, width * height); i++) {
|
||||
Object id = inputs[i];
|
||||
if (id.equals("")) continue;
|
||||
ingredients.add(i, RecipeParser.processIngredient(id));
|
||||
}
|
||||
tweaker.addRecipe(new RollingMachineRecipe(ModRecipes.ROLLING_MACHINE, recipeId, new ShapedRecipe(recipeId, "", width, height, ingredients, output)));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn rolling machine recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a rolling machine recipe from a pattern and dictionary.
|
||||
* @param pattern A crafting pattern like one you'd find in a vanilla recipe JSON.
|
||||
* @param dictionary A map of single characters to item or tag ids.
|
||||
* @param output The output of the recipe.
|
||||
*/
|
||||
public void addRollingMachine(String[] pattern, Map<String, Object> dictionary, ItemStack output) {
|
||||
Identifier recipeId = tweaker.getRecipeId(output);
|
||||
try {
|
||||
pattern = RecipeParser.processPattern(pattern);
|
||||
Map<String, Ingredient> map = RecipeParser.processDictionary(dictionary);
|
||||
int x = pattern[0].length();
|
||||
int y = pattern.length;
|
||||
DefaultedList<Ingredient> ingredients = RecipeParser.getIngredients(pattern, map, x, y);
|
||||
tweaker.addRecipe(new RollingMachineRecipe(ModRecipes.ROLLING_MACHINE, recipeId, new ShapedRecipe(recipeId, "", x, y, ingredients, output)));
|
||||
} catch (Exception e) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn rolling machine recipe - " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a solid canning machine.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addSolidCanningMachine(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.SOLID_CANNING_MACHINE, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a recipe to process in a wire mill.
|
||||
* @param inputs The input ingredients for the recipe.
|
||||
* @param outputs The outputs of the recipe.
|
||||
* @param power How much power the recipe consumes per tick.
|
||||
* @param time How many ticks (1/20 of a second) to process for.
|
||||
*/
|
||||
public void addWireMill(Object[] inputs, ItemStack[] outputs, int power, int time) {
|
||||
add(ModRecipes.WIRE_MILL, inputs, outputs, power, time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a fluid to process in a fluid generator.
|
||||
* @param generator The type of generator: thermal, gas, diesel, semifluid, or plasma.
|
||||
* @param fluid The fluid to add a recipe for.
|
||||
* @param euPerMB How much EU should be generated per millibucket of fluid.
|
||||
*/
|
||||
public void addFluidGenerator(String generator, String fluid, int euPerMB) {
|
||||
EFluidGenerator type;
|
||||
switch(generator.toLowerCase()) {
|
||||
case "thermal":
|
||||
case "techreborn.thermalgenerator":
|
||||
type = EFluidGenerator.THERMAL;
|
||||
break;
|
||||
case "gas":
|
||||
case "techreborn.gasgenerator":
|
||||
type = EFluidGenerator.GAS;
|
||||
break;
|
||||
case "diesel":
|
||||
case "techreborn.dieselgenerator":
|
||||
type = EFluidGenerator.DIESEL;
|
||||
break;
|
||||
case "semifluid":
|
||||
case "techreborn.semifluidgenerator":
|
||||
type = EFluidGenerator.SEMIFLUID;
|
||||
break;
|
||||
case "plasma":
|
||||
case "techreborn.plasmagenerator":
|
||||
type = EFluidGenerator.PLASMA;
|
||||
break;
|
||||
default:
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn fluid generator recipe - could not find generator: " + generator);
|
||||
return;
|
||||
}
|
||||
Fluid parsedFluid = TweakerUtils.INSTANCE.getFluid(fluid);
|
||||
if (parsedFluid == Fluids.EMPTY) {
|
||||
TechReborn.LOGGER.error("Error parsing TechReborn fluid generator recipe - could not find fluid: " + fluid);
|
||||
return;
|
||||
}
|
||||
toAdd.add(new FluidGeneratorRecipe(parsedFluid, euPerMB, type));
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
Tweaker.addTweaker("TRTweaker", TRTweaker.INSTANCE);
|
||||
TweakerStackGetter.registerGetter(new Identifier("techreborn:cell"), (id) -> ItemDynamicCell.getCellWithFluid(Registry.FLUID.get(id)));
|
||||
}
|
||||
}
|
|
@ -26,6 +26,7 @@ package techreborn.compat.rei;
|
|||
|
||||
import me.shedaniel.math.api.Point;
|
||||
import me.shedaniel.math.api.Rectangle;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeCategory;
|
||||
import me.shedaniel.rei.api.Renderer;
|
||||
import me.shedaniel.rei.gui.renderers.RecipeRenderer;
|
||||
|
@ -71,12 +72,13 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
|
|||
}
|
||||
|
||||
@Override
|
||||
public Renderer getIcon() {
|
||||
return Renderer.fromItemStack(new ItemStack(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL).asItem()));
|
||||
public EntryStack getLogo() {
|
||||
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecipeRenderer getSimpleRenderer(MachineRecipeDisplay<R> recipe) {
|
||||
// There is currently no replacement for Renderer in the 1.14 version of REI
|
||||
return Renderer.fromRecipe(() -> Collections.singletonList(recipe.getInput().get(0)), recipe::getOutput);
|
||||
}
|
||||
|
||||
|
@ -92,37 +94,28 @@ public class MachineRecipeCategory<R extends RebornRecipe> implements RecipeCate
|
|||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
||||
|
||||
int i = 0;
|
||||
for (List<ItemStack> inputs : machineRecipe.getInput()){
|
||||
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), Renderer.fromItemStacks(inputs), true, true, true));
|
||||
}
|
||||
|
||||
FluidInstance fluidInstance = machineRecipe.getFluidInstance();
|
||||
if (fluidInstance != null) {
|
||||
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), Renderer.fromFluid(fluidInstance.getFluid()), true, true, true));
|
||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()){
|
||||
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs));
|
||||
}
|
||||
|
||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
||||
widgets.add(new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()){
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta) {
|
||||
font.draw(text, x - font.getStringWidth(text) / 2, y, ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
}
|
||||
});
|
||||
LabelWidget costLabel;
|
||||
widgets.add(costLabel = new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()));
|
||||
costLabel.setHasShadows(false);
|
||||
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
|
||||
i = 0;
|
||||
for (ItemStack outputs : machineRecipe.getOutput()){
|
||||
widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 1 + (i++ * 20), Renderer.fromItemStack(outputs), true, true, true));
|
||||
for (EntryStack outputs : machineRecipe.getOutputEntries()){
|
||||
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1 + (i++ * 20)).entry(outputs));
|
||||
}
|
||||
|
||||
int heat = machineRecipe.getHeat();
|
||||
if (heat > 0) {
|
||||
String neededHeat = heat + " " + StringUtils.t("techreborn.jei.recipe.heat");
|
||||
widgets.add(new LabelWidget(startPoint.x + 61, startPoint.y + 1 + (i++ * 20), neededHeat){
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta) {
|
||||
font.draw(text, x - font.getStringWidth(text) / 2, y, ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
}
|
||||
});
|
||||
LabelWidget heatLabel;
|
||||
widgets.add(heatLabel = new LabelWidget(startPoint.x + 61, startPoint.y + 1 + (i++ * 20), neededHeat));
|
||||
heatLabel.setHasShadows(false);
|
||||
heatLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
}
|
||||
|
||||
return widgets;
|
||||
|
|
|
@ -24,38 +24,39 @@
|
|||
|
||||
package techreborn.compat.rei;
|
||||
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import me.shedaniel.rei.utils.CollectionUtils;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.api.recipe.recipes.BlastFurnaceRecipe;
|
||||
import reborncore.common.crafting.RebornFluidRecipe;
|
||||
import reborncore.common.crafting.RebornRecipe;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.api.recipe.recipes.BlastFurnaceRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDisplay {
|
||||
|
||||
|
||||
private final R recipe;
|
||||
private List<List<ItemStack>> inputs;
|
||||
private List<ItemStack> outputs;
|
||||
private List<List<EntryStack>> inputs;
|
||||
private List<EntryStack> outputs;
|
||||
private int energy = 0;
|
||||
private int heat = 0;
|
||||
private FluidInstance fluidInstance = null;
|
||||
|
||||
|
||||
public MachineRecipeDisplay(R recipe) {
|
||||
this.recipe = recipe;
|
||||
this.inputs = recipe.getRebornIngredients().stream().map(RebornIngredient::getPreviewStacks).collect(Collectors.toList());
|
||||
this.outputs = recipe.getOutputs();
|
||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
||||
this.outputs = CollectionUtils.map(recipe.getOutputs(), stack -> EntryStack.create(stack));
|
||||
this.energy = recipe.getPower();
|
||||
if (recipe instanceof BlastFurnaceRecipe) {
|
||||
this.heat = ((BlastFurnaceRecipe) recipe).getHeat();
|
||||
}
|
||||
if (recipe instanceof RebornFluidRecipe) {
|
||||
this.fluidInstance = ((RebornFluidRecipe) recipe).getFluidInstance();
|
||||
inputs.add(Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount())));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,27 +71,27 @@ public class MachineRecipeDisplay<R extends RebornRecipe> implements RecipeDispl
|
|||
public FluidInstance getFluidInstance() {
|
||||
return fluidInstance;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Optional<Identifier> getRecipeLocation() {
|
||||
return Optional.ofNullable(recipe).map(RebornRecipe::getId);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<List<ItemStack>> getInput() {
|
||||
public List<List<EntryStack>> getInputEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<List<ItemStack>> getRequiredItems() {
|
||||
public List<List<EntryStack>> getRequiredEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutput() {
|
||||
public List<EntryStack> getOutputEntries() {
|
||||
return outputs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Identifier getRecipeCategory() {
|
||||
return recipe.getRebornRecipeType().getName();
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
package techreborn.compat.rei;
|
||||
|
||||
import me.shedaniel.rei.RoughlyEnoughItemsCore;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import me.shedaniel.rei.api.RecipeHelper;
|
||||
import me.shedaniel.rei.api.plugins.REIPluginV0;
|
||||
|
@ -48,6 +50,7 @@ import techreborn.init.TRContent;
|
|||
import techreborn.init.TRContent.Machine;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
@ -89,7 +92,7 @@ public class ReiPlugin implements REIPluginV0 {
|
|||
|
||||
@Override
|
||||
public SemanticVersion getMinimumVersion() throws VersionParsingException {
|
||||
return SemanticVersion.parse("3.0-pre");
|
||||
return SemanticVersion.parse("3.2.5");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -143,6 +146,29 @@ public class ReiPlugin implements REIPluginV0 {
|
|||
recipeHelper.registerWorkingStations(ModRecipes.WIRE_MILL.getName(), new ItemStack(Machine.WIRE_MILL.asItem()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postRegister() {
|
||||
// Alright we are going to apply check tags to cells, this should not take long at all.
|
||||
// Check Tags will not check the amount of the ItemStack, but will enable checking their tags.
|
||||
for (EntryStack stack : RoughlyEnoughItemsCore.getEntryRegistry().getStacksList())
|
||||
applyCellEntry(stack);
|
||||
for (List<RecipeDisplay> displays : RecipeHelper.getInstance().getAllRecipes().values()) {
|
||||
for (RecipeDisplay display : displays) {
|
||||
for (List<EntryStack> entries : display.getInputEntries())
|
||||
for (EntryStack stack : entries)
|
||||
applyCellEntry(stack);
|
||||
for (EntryStack stack : display.getOutputEntries())
|
||||
applyCellEntry(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void applyCellEntry(EntryStack stack) {
|
||||
// getItem can be null but this works
|
||||
if (stack.getItem() == TRContent.CELL)
|
||||
stack.addSetting(EntryStack.Settings.CHECK_TAGS, EntryStack.Settings.TRUE);
|
||||
}
|
||||
|
||||
private <R extends RebornRecipe> void registerMachineRecipe(RecipeHelper recipeHelper, RebornRecipeType<R> recipeType){
|
||||
Function<R, RecipeDisplay> recipeDisplay = r -> new MachineRecipeDisplay<>((RebornRecipe) r);
|
||||
|
||||
|
|
|
@ -1,30 +1,48 @@
|
|||
package techreborn.compat.rei.fluidreplicator;
|
||||
/*
|
||||
* This file is part of TechReborn, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2018 TechReborn
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
package techreborn.compat.rei.fluidreplicator;
|
||||
|
||||
import me.shedaniel.math.api.Point;
|
||||
import me.shedaniel.math.api.Rectangle;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeCategory;
|
||||
import me.shedaniel.rei.api.Renderer;
|
||||
import me.shedaniel.rei.gui.widget.LabelWidget;
|
||||
import me.shedaniel.rei.gui.widget.RecipeArrowWidget;
|
||||
import me.shedaniel.rei.gui.widget.RecipeBaseWidget;
|
||||
import me.shedaniel.rei.gui.widget.SlotWidget;
|
||||
import me.shedaniel.rei.gui.widget.Widget;
|
||||
import me.shedaniel.rei.gui.widget.*;
|
||||
import me.shedaniel.rei.impl.ScreenHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.text.TranslatableText;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||
import techreborn.compat.rei.ReiPlugin;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplicatorRecipeDisplay> {
|
||||
|
||||
private final RebornRecipeType<FluidReplicatorRecipe> rebornRecipeType;
|
||||
|
@ -33,52 +51,48 @@ public class FluidReplicatorRecipeCategory implements RecipeCategory<FluidReplic
|
|||
this.rebornRecipeType = recipeType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Identifier getIdentifier() {
|
||||
return rebornRecipeType.getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCategoryName() {
|
||||
return StringUtils.t(rebornRecipeType.getName().toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Renderer getIcon() {
|
||||
return Renderer.fromItemStack(new ItemStack(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL).asItem()));
|
||||
public EntryStack getLogo() {
|
||||
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Widget> setupDisplay(Supplier<FluidReplicatorRecipeDisplay> recipeDisplaySupplier, Rectangle bounds) {
|
||||
|
||||
|
||||
FluidReplicatorRecipeDisplay machineRecipe = recipeDisplaySupplier.get();
|
||||
|
||||
Point startPoint = new Point( bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
||||
|
||||
List<Widget> widgets = new LinkedList<>();
|
||||
widgets.add(new RecipeBaseWidget(bounds));
|
||||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
||||
|
||||
|
||||
Point startPoint = new Point(bounds.getCenterX() - 41, bounds.getCenterY() - 13);
|
||||
|
||||
List<Widget> widgets = new LinkedList<>();
|
||||
widgets.add(new RecipeBaseWidget(bounds));
|
||||
widgets.add(new RecipeArrowWidget(startPoint.x + 24, startPoint.y + 1, true));
|
||||
|
||||
int i = 0;
|
||||
for (List<ItemStack> inputs : machineRecipe.getInput()){
|
||||
widgets.add(new SlotWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), Renderer.fromItemStacks(inputs), true, true, true));
|
||||
for (List<EntryStack> inputs : machineRecipe.getInputEntries()) {
|
||||
widgets.add(EntryWidget.create(startPoint.x + 1, startPoint.y + 1 + (i++ * 20)).entries(inputs));
|
||||
}
|
||||
|
||||
Text energyPerTick = new TranslatableText("techreborn.jei.recipe.running.cost", "E", machineRecipe.getEnergy());
|
||||
widgets.add(new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()){
|
||||
@Override
|
||||
public void render(int mouseX, int mouseY, float delta) {
|
||||
font.draw(text, x - font.getStringWidth(text) / 2, y, ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
}
|
||||
});
|
||||
|
||||
FluidInstance fluidInstance = machineRecipe.getFluidInstance();
|
||||
if (fluidInstance != null) {
|
||||
widgets.add(new SlotWidget(startPoint.x + 61, startPoint.y + 1, Renderer.fromFluid(fluidInstance.getFluid()), true, true, true));
|
||||
}
|
||||
|
||||
LabelWidget costLabel;
|
||||
widgets.add(costLabel = new LabelWidget(startPoint.x + 1, startPoint.y + 1 + (i++ * 20), energyPerTick.asFormattedString()));
|
||||
costLabel.setHasShadows(false);
|
||||
costLabel.setDefaultColor(ScreenHelper.isDarkModeEnabled() ? 0xFFBBBBBB : 0xFF404040);
|
||||
|
||||
if (!machineRecipe.getOutputEntries().isEmpty())
|
||||
widgets.add(EntryWidget.create(startPoint.x + 61, startPoint.y + 1).entries(machineRecipe.getOutputEntries()));
|
||||
|
||||
return widgets;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -24,32 +24,32 @@
|
|||
|
||||
package techreborn.compat.rei.fluidreplicator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.api.RecipeDisplay;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import me.shedaniel.rei.utils.CollectionUtils;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.ingredient.RebornIngredient;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import techreborn.api.recipe.recipes.FluidReplicatorRecipe;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author drcrazy
|
||||
*
|
||||
*/
|
||||
public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
||||
|
||||
private final FluidReplicatorRecipe recipe;
|
||||
private List<List<ItemStack>> inputs;
|
||||
private List<List<EntryStack>> inputs;
|
||||
private List<EntryStack> output;
|
||||
private FluidInstance fluidInstance;
|
||||
private int energy = 0;
|
||||
|
||||
public FluidReplicatorRecipeDisplay(FluidReplicatorRecipe recipe) {
|
||||
this.recipe = recipe;
|
||||
this.inputs = recipe.getRebornIngredients().stream().map(RebornIngredient::getPreviewStacks).collect(Collectors.toList());
|
||||
this.inputs = CollectionUtils.map(recipe.getRebornIngredients(), ing -> CollectionUtils.map(ing.getPreviewStacks(), EntryStack::create));
|
||||
this.fluidInstance = recipe.getFluidInstance();
|
||||
this.output = fluidInstance == null ? Collections.emptyList() : Collections.singletonList(EntryStack.create(fluidInstance.getFluid(), fluidInstance.getAmount()));
|
||||
this.energy = recipe.getPower();
|
||||
}
|
||||
|
||||
|
@ -60,17 +60,22 @@ public class FluidReplicatorRecipeDisplay implements RecipeDisplay {
|
|||
public int getEnergy() {
|
||||
return energy;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<List<ItemStack>> getInput() {
|
||||
public List<List<EntryStack>> getInputEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemStack> getOutput() {
|
||||
return new ArrayList<ItemStack>();
|
||||
public List<EntryStack> getOutputEntries() {
|
||||
return output;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<List<EntryStack>> getRequiredEntries() {
|
||||
return inputs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Identifier getRecipeCategory() {
|
||||
return recipe.getRebornRecipeType().getName();
|
||||
|
|
|
@ -24,9 +24,8 @@
|
|||
|
||||
package techreborn.compat.rei.rollingmachine;
|
||||
|
||||
import me.shedaniel.rei.api.Renderer;
|
||||
import me.shedaniel.rei.api.EntryStack;
|
||||
import me.shedaniel.rei.plugin.crafting.DefaultCraftingCategory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import reborncore.common.crafting.RebornRecipeType;
|
||||
|
@ -35,26 +34,26 @@ import techreborn.api.recipe.recipes.RollingMachineRecipe;
|
|||
import techreborn.compat.rei.ReiPlugin;
|
||||
|
||||
public class RollingMachineCategory extends DefaultCraftingCategory {
|
||||
|
||||
|
||||
private final RebornRecipeType<RollingMachineRecipe> rebornRecipeType;
|
||||
|
||||
|
||||
public RollingMachineCategory(RebornRecipeType<RollingMachineRecipe> rebornRecipeType) {
|
||||
this.rebornRecipeType = rebornRecipeType;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Identifier getIdentifier() {
|
||||
return rebornRecipeType.getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getCategoryName() {
|
||||
return StringUtils.t(rebornRecipeType.getName().toString());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Renderer getIcon() {
|
||||
return Renderer.fromItemStack(new ItemStack(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL).asItem()));
|
||||
public EntryStack getLogo() {
|
||||
return EntryStack.create(ReiPlugin.iconMap.getOrDefault(rebornRecipeType, () -> Items.DIAMOND_SHOVEL));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,8 @@ package techreborn.events;
|
|||
|
||||
import net.minecraft.block.FenceBlock;
|
||||
import net.minecraft.block.FenceGateBlock;
|
||||
import net.minecraft.block.LogBlock;
|
||||
import net.minecraft.block.MaterialColor;
|
||||
import net.minecraft.block.SlabBlock;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -111,6 +113,7 @@ public class ModRegistry {
|
|||
RebornRegistry.registerBlock(TRContent.REINFORCED_GLASS = InitUtils.setup(new BlockReinforcedGlass(), "reinforced_glass"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_LEAVES = InitUtils.setup(new BlockRubberLeaves(), "rubber_leaves"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_LOG = InitUtils.setup(new BlockRubberLog(), "rubber_log"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_LOG_STRIPPED = InitUtils.setup(new LogBlock(MaterialColor.SPRUCE, InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_log_stripped"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_PLANKS = InitUtils.setup(new BlockRubberPlank(), "rubber_planks"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_SAPLING = InitUtils.setup(new BlockRubberSapling(), "rubber_sapling"), itemGroup);
|
||||
RebornRegistry.registerBlock(TRContent.RUBBER_PLANK_SLAB = InitUtils.setup(new SlabBlock(InitUtils.setupRubberBlockSettings(2.0F, 15.0F)), "rubber_plank_slab"), itemGroup);
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
|
||||
package techreborn.init;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.ArmorMaterial;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
|
@ -31,9 +34,6 @@ import net.minecraft.sound.SoundEvent;
|
|||
import net.minecraft.sound.SoundEvents;
|
||||
import net.minecraft.util.Lazy;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
||||
public enum TRArmorMaterial implements ArmorMaterial {
|
||||
|
||||
|
@ -49,9 +49,9 @@ public enum TRArmorMaterial implements ArmorMaterial {
|
|||
PERIDOT(17, new int[] { 3, 8, 3, 2 }, 16, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> {
|
||||
return Ingredient.ofItems(TRContent.Gems.PERIDOT.asItem());
|
||||
}),
|
||||
CLOAKING(5, new int[] { 1, 2, 3, 1 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, null),
|
||||
LITHIUMBATPACK(25, new int[]{2, 5, 6, 2}, 10, SoundEvents.ITEM_ARMOR_EQUIP_TURTLE, 0.0F, null),
|
||||
LAPOTRONPACK(33, new int[]{3, 6, 8, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 2.0F, null);
|
||||
CLOAKING(5, new int[] { 1, 2, 3, 1 }, 0, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, () -> Ingredient.EMPTY),
|
||||
LITHIUMBATPACK(25, new int[]{2, 5, 6, 2}, 10, SoundEvents.ITEM_ARMOR_EQUIP_TURTLE, 0.0F, () -> Ingredient.EMPTY),
|
||||
LAPOTRONPACK(33, new int[]{3, 6, 8, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 2.0F, () -> Ingredient.EMPTY);
|
||||
|
||||
|
||||
private static final int[] MAX_DAMAGE_ARRAY = new int[]{13, 15, 16, 11};
|
||||
|
|
|
@ -50,7 +50,7 @@ import techreborn.blockentity.machine.tier1.*;
|
|||
import techreborn.blockentity.machine.tier3.*;
|
||||
import techreborn.blockentity.storage.AdjustableSUBlockEntity;
|
||||
import techreborn.blocks.*;
|
||||
import techreborn.blocks.cable.BlockCable;
|
||||
import techreborn.blocks.cable.CableBlock;
|
||||
import techreborn.blocks.generator.*;
|
||||
import techreborn.blocks.lighting.BlockLamp;
|
||||
import techreborn.blocks.storage.*;
|
||||
|
@ -93,6 +93,7 @@ public class TRContent {
|
|||
public static Block RUBBER_BUTTON;
|
||||
public static Block RUBBER_PRESSURE_PLATE;
|
||||
public static Block RUBBER_DOOR;
|
||||
public static Block RUBBER_LOG_STRIPPED;
|
||||
|
||||
// Armor
|
||||
public static Item CLOAKING_DEVICE;
|
||||
|
@ -258,7 +259,7 @@ public class TRContent {
|
|||
|
||||
|
||||
public final String name;
|
||||
public final BlockCable block;
|
||||
public final CableBlock block;
|
||||
|
||||
public int transferRate;
|
||||
public int defaultTransferRate;
|
||||
|
@ -276,7 +277,7 @@ public class TRContent {
|
|||
this.canKill = canKill;
|
||||
this.defaultCanKill = canKill;
|
||||
this.tier = tier;
|
||||
this.block = new BlockCable(this);
|
||||
this.block = new CableBlock(this);
|
||||
InitUtils.setup(block, name + "_cable");
|
||||
}
|
||||
|
||||
|
|
|
@ -133,7 +133,7 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
|||
FluidState fluidState = usageContext.getWorld().getFluidState(pos);
|
||||
if(fluidState.getFluid() != Fluids.EMPTY && fluidState.isStill()){
|
||||
stack.decrement(1);
|
||||
usageContext.getPlayer().inventory.insertStack(getCellWithFluid(fluidState.getFluid(), 1));
|
||||
insertOrDropStack(usageContext.getPlayer(), getCellWithFluid(fluidState.getFluid(), 1));
|
||||
usageContext.getWorld().setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
playEmptyingSound(usageContext.getPlayer(), usageContext.getWorld(), pos, fluidState.getFluid());
|
||||
}
|
||||
|
@ -141,13 +141,19 @@ public class ItemDynamicCell extends Item implements ItemFluidInfo {
|
|||
if(blockState.canReplace(new ItemPlacementContext(usageContext))){
|
||||
usageContext.getWorld().setBlockState(pos, containedFluid.getDefaultState().getBlockState());
|
||||
stack.decrement(1);
|
||||
usageContext.getPlayer().inventory.insertStack(getEmpty());
|
||||
insertOrDropStack(usageContext.getPlayer(), getEmpty());
|
||||
playEmptyingSound(usageContext.getPlayer(), usageContext.getWorld(), pos, containedFluid);
|
||||
}
|
||||
}
|
||||
return super.useOnBlock(usageContext);
|
||||
}
|
||||
|
||||
private void insertOrDropStack(PlayerEntity playerEntity, ItemStack stack){
|
||||
if(!playerEntity.inventory.insertStack(stack)){
|
||||
playerEntity.dropStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
//Thanks vanilla :)
|
||||
private void playEmptyingSound(@Nullable PlayerEntity playerEntity, IWorld world, BlockPos blockPos, Fluid fluid) {
|
||||
SoundEvent soundEvent = fluid.matches(FluidTags.LAVA) ? SoundEvents.ITEM_BUCKET_EMPTY_LAVA : SoundEvents.ITEM_BUCKET_EMPTY;
|
||||
|
|
|
@ -35,10 +35,10 @@ import net.minecraft.item.ItemGroup;
|
|||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
import team.reborn.energy.EnergyHolder;
|
||||
import team.reborn.energy.EnergyTier;
|
||||
import techreborn.TechReborn;
|
||||
|
@ -62,9 +62,18 @@ public class ItemLithiumIonBatpack extends ArmorItem implements EnergyHolder, It
|
|||
return;
|
||||
}
|
||||
|
||||
if(!Energy.valid(itemStack)){
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < player.inventory.getInvSize(); i++) {
|
||||
if (!player.inventory.getInvStack(i).isEmpty()) {
|
||||
ExternalPowerSystems.chargeItem(itemStack, player.inventory.getInvStack(i));
|
||||
if (Energy.valid(player.inventory.getInvStack(i))) {
|
||||
Energy.of(itemStack)
|
||||
.into(
|
||||
Energy
|
||||
.of(player.inventory.getInvStack(i))
|
||||
)
|
||||
.move();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import net.minecraft.item.*;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -80,9 +79,8 @@ public class ItemChainsaw extends AxeItem implements EnergyHolder, ItemDurabilit
|
|||
if (Energy.of(stack).getEnergy() >= cost
|
||||
&& (state.getMaterial() == Material.WOOD)) {
|
||||
return this.poweredSpeed;
|
||||
} else {
|
||||
return super.getMiningSpeed(stack, state);
|
||||
}
|
||||
return super.getMiningSpeed(stack, state);
|
||||
}
|
||||
|
||||
// ItemTool
|
||||
|
@ -91,7 +89,6 @@ public class ItemChainsaw extends AxeItem implements EnergyHolder, ItemDurabilit
|
|||
Random rand = new Random();
|
||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||
Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import net.minecraft.entity.LivingEntity;
|
|||
import net.minecraft.item.*;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -76,7 +75,6 @@ public class ItemDrill extends PickaxeItem implements EnergyHolder, ItemDurabili
|
|||
Random rand = new Random();
|
||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||
Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import net.minecraft.item.PickaxeItem;
|
|||
import net.minecraft.item.ToolMaterials;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -75,7 +74,6 @@ public class ItemJackhammer extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
Random rand = new Random();
|
||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||
Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,6 @@ import net.minecraft.item.*;
|
|||
import net.minecraft.util.DefaultedList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -84,7 +83,6 @@ public class ItemRockCutter extends PickaxeItem implements EnergyHolder, ItemDur
|
|||
Random rand = new Random();
|
||||
if (rand.nextInt(EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack) + 1) == 0) {
|
||||
Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,6 @@ import net.minecraft.util.*;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
|
@ -187,8 +186,6 @@ public class ItemIndustrialChainsaw extends ItemChainsaw {
|
|||
return;
|
||||
}
|
||||
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
|
||||
blockState.getBlock().afterBreak(world, (PlayerEntity) entityLiving, pos, blockState, world.getBlockEntity(pos), stack);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
world.removeBlockEntity(pos);
|
||||
|
|
|
@ -47,7 +47,6 @@ import net.minecraft.util.math.BlockPos;
|
|||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.world.RayTraceContext;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
import team.reborn.energy.Energy;
|
||||
|
@ -122,8 +121,6 @@ public class ItemIndustrialDrill extends ItemDrill {
|
|||
BlockState blockState = world.getBlockState(pos);
|
||||
|
||||
if(Energy.of(drill).use(cost)){
|
||||
ExternalPowerSystems.requestEnergyFromArmor(drill, playerIn);
|
||||
|
||||
blockState.getBlock().onBlockRemoved(blockState, world, pos, blockState, true);
|
||||
blockState.getBlock().afterBreak(world, playerIn, pos, blockState, world.getBlockEntity(pos), drill);
|
||||
world.setBlockState(pos, Blocks.AIR.getDefaultState());
|
||||
|
|
|
@ -42,7 +42,6 @@ import net.minecraft.text.TranslatableText;
|
|||
import net.minecraft.util.*;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.api.items.ItemStackModifiers;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ChatUtils;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
|
@ -90,9 +89,7 @@ public class ItemNanosaber extends SwordItem implements EnergyHolder, ItemDurabi
|
|||
// ItemSword
|
||||
@Override
|
||||
public boolean postHit(ItemStack stack, LivingEntity entityHit, LivingEntity entityHitter) {
|
||||
boolean used = Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityHitter);
|
||||
return used;
|
||||
return Energy.of(stack).use(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -39,7 +39,6 @@ import net.minecraft.util.DefaultedList;
|
|||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import reborncore.common.powerSystem.ExternalPowerSystems;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.ItemDurabilityExtensions;
|
||||
import reborncore.common.util.ItemUtils;
|
||||
|
@ -80,7 +79,6 @@ public class ItemOmniTool extends PickaxeItem implements EnergyHolder, ItemDurab
|
|||
@Override
|
||||
public boolean postMine(ItemStack stack, World worldIn, BlockState blockIn, BlockPos pos, LivingEntity entityLiving) {
|
||||
Energy.of(stack).use(cost);
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityLiving);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -110,7 +108,6 @@ public class ItemOmniTool extends PickaxeItem implements EnergyHolder, ItemDurab
|
|||
if(Energy.of(stack).use(hitCost)) {
|
||||
entityliving.damage(DamageSource.player((PlayerEntity) attacker), 8F);
|
||||
}
|
||||
ExternalPowerSystems.requestEnergyFromArmor(stack, entityliving);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
package techreborn.utils;
|
||||
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
|
@ -33,6 +32,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import reborncore.common.fluid.container.FluidInstance;
|
||||
import reborncore.common.fluid.container.GenericFluidContainer;
|
||||
import reborncore.common.fluid.container.ItemFluidInfo;
|
||||
import reborncore.mixin.extensions.FluidBlockExtensions;
|
||||
|
@ -117,14 +117,14 @@ public class FluidUtils {
|
|||
}
|
||||
}
|
||||
|
||||
sourceFluid.subtractAmount(1000);
|
||||
|
||||
if(outputStack.isEmpty()){
|
||||
inventory.setInvStack(outputSlot, itemFluidInfo.getFull(sourceFluid.getFluid()));
|
||||
} else {
|
||||
outputStack.increment(1);
|
||||
}
|
||||
|
||||
sourceFluid.subtractAmount(1000);
|
||||
|
||||
inputStack.decrement(1);
|
||||
|
||||
return false;
|
||||
|
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.1 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 616 B |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 622 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 884 B After Width: | Height: | Size: 614 B |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 878 B After Width: | Height: | Size: 614 B |
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"variants": {
|
||||
"axis=y": { "model": "techreborn:block/rubber/rubber_log_stripped" },
|
||||
"axis=z": { "model": "techreborn:block/rubber/rubber_log_stripped", "x": 90 },
|
||||
"axis=x": { "model": "techreborn:block/rubber/rubber_log_stripped", "x": 90, "y": 90 }
|
||||
}
|
||||
}
|
|
@ -83,9 +83,10 @@
|
|||
|
||||
"_comment1": "Blocks",
|
||||
"block.techreborn.rubber_log": "Rubber Wood",
|
||||
"block.techreborn.rubber_log_stripped": "Stripped Rubber Wood",
|
||||
"block.techreborn.rubber_planks": "Rubber Wood Planks",
|
||||
"block.techreborn.rubber_plank_slab": "Rubber Wood Plank Slab",
|
||||
"block.techreborn.rubber_plank_stair": "Rubber Wood Plank Stair",
|
||||
"block.techreborn.rubber_plank_slab": "Rubber Wood Plank Slab",
|
||||
"block.techreborn.rubber_plank_stair": "Rubber Wood Plank Stairs",
|
||||
"block.techreborn.rubber_leaves": "Rubber Wood Leaves",
|
||||
"block.techreborn.rubber_sapling": "Rubber Wood Sapling",
|
||||
"block.techreborn.rubber_fence": "Rubber Wood Fence",
|
||||
|
@ -414,6 +415,7 @@
|
|||
"item.techreborn.tungsten_nugget": "Tungsten Nugget",
|
||||
"item.techreborn.tungstensteel_nugget": "Tungstensteel Nugget",
|
||||
"item.techreborn.zinc_nugget": "Zinc Nugget",
|
||||
"item.techreborn.emerald_nugget": "Emerald Nugget",
|
||||
|
||||
"_comment12": "Plates",
|
||||
"item.techreborn.advanced_alloy_plate": "Advanced Alloy Plate",
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"parent": "minecraft:block/cube_column",
|
||||
"textures": {
|
||||
"end": "techreborn:block/stripped_rubber_log_top",
|
||||
"side": "techreborn:block/stripped_rubber_log_side"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"parent": "techreborn:block/rubber/rubber_log_stripped"
|
||||
}
|
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1 KiB |
Before Width: | Height: | Size: 765 B After Width: | Height: | Size: 834 B |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 781 B After Width: | Height: | Size: 749 B |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 708 B After Width: | Height: | Size: 705 B |
Before Width: | Height: | Size: 1 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -1,12 +1,18 @@
|
|||
{
|
||||
"animation": {
|
||||
"frametime": 5,
|
||||
"interpolate": true,
|
||||
"frames": [
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
3,
|
||||
4
|
||||
4,
|
||||
5,
|
||||
4,
|
||||
3,
|
||||
2,
|
||||
1
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 601 B After Width: | Height: | Size: 502 B |
Before Width: | Height: | Size: 794 B After Width: | Height: | Size: 723 B |
Before Width: | Height: | Size: 511 B After Width: | Height: | Size: 522 B |
Before Width: | Height: | Size: 541 B After Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 515 B After Width: | Height: | Size: 511 B |
Before Width: | Height: | Size: 525 B After Width: | Height: | Size: 551 B |
Before Width: | Height: | Size: 634 B After Width: | Height: | Size: 579 B |
Before Width: | Height: | Size: 514 B After Width: | Height: | Size: 546 B |
Before Width: | Height: | Size: 743 B After Width: | Height: | Size: 777 B |
Before Width: | Height: | Size: 544 B After Width: | Height: | Size: 562 B |
Before Width: | Height: | Size: 547 B After Width: | Height: | Size: 535 B |
Before Width: | Height: | Size: 613 B After Width: | Height: | Size: 584 B |
Before Width: | Height: | Size: 540 B After Width: | Height: | Size: 532 B |
Before Width: | Height: | Size: 596 B After Width: | Height: | Size: 553 B |
Before Width: | Height: | Size: 688 B After Width: | Height: | Size: 606 B |
Before Width: | Height: | Size: 586 B After Width: | Height: | Size: 515 B |
Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 714 B |
Before Width: | Height: | Size: 531 B After Width: | Height: | Size: 564 B |
Before Width: | Height: | Size: 676 B After Width: | Height: | Size: 593 B |
Before Width: | Height: | Size: 554 B After Width: | Height: | Size: 520 B |
Before Width: | Height: | Size: 825 B After Width: | Height: | Size: 483 B |
Before Width: | Height: | Size: 740 B After Width: | Height: | Size: 447 B |
Before Width: | Height: | Size: 630 B After Width: | Height: | Size: 462 B |
Before Width: | Height: | Size: 418 B After Width: | Height: | Size: 413 B |
After Width: | Height: | Size: 435 B |
After Width: | Height: | Size: 400 B |
Before Width: | Height: | Size: 545 B After Width: | Height: | Size: 291 B |
Before Width: | Height: | Size: 696 B After Width: | Height: | Size: 366 B |
Before Width: | Height: | Size: 501 B After Width: | Height: | Size: 290 B |
Before Width: | Height: | Size: 635 B After Width: | Height: | Size: 289 B |
Before Width: | Height: | Size: 546 B After Width: | Height: | Size: 283 B |
Before Width: | Height: | Size: 717 B After Width: | Height: | Size: 362 B |
Before Width: | Height: | Size: 491 B After Width: | Height: | Size: 307 B |
Before Width: | Height: | Size: 579 B After Width: | Height: | Size: 291 B |