Merge branch '1.18' into recipe_serde

# Conflicts:
#	RebornCore/src/main/java/reborncore/common/crafting/RebornRecipeType.java
#	src/datagen/groovy/techreborn/datagen/recipes/smelting/SmeltingRecipesProvider.groovy
This commit is contained in:
modmuss50 2022-01-20 18:51:48 +00:00
commit 8863ea30b3
454 changed files with 3884 additions and 1302 deletions

View file

@ -53,6 +53,7 @@ class SmeltingRecipesProvider extends TechRebornRecipesProvider {
(CommonTags.Items.sheldoniteOres) : TRContent.Ingots.PLATINUM,
(CommonTags.Items.platinumDusts) : TRContent.Ingots.PLATINUM,
(Items.IRON_INGOT) : TRContent.Ingots.REFINED_IRON,
(cItem("iron_plates")): TRContent.Plates.REFINED_IRON,
(CommonTags.Items.silverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.rawSilverOres) : TRContent.Ingots.SILVER,
(CommonTags.Items.tinOres) : TRContent.Ingots.TIN,

View file

@ -33,8 +33,8 @@ import net.minecraft.fluid.Fluids;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Identifier;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import reborncore.common.blockentity.RedstoneConfiguration;
import reborncore.common.config.Configuration;
import reborncore.common.recipes.RecipeCrafter;
@ -58,7 +58,7 @@ import java.util.function.Predicate;
public class TechReborn implements ModInitializer {
public static final String MOD_ID = "techreborn";
public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
public static TechReborn INSTANCE;
public static ItemGroup ITEMGROUP = FabricItemGroupBuilder.build(

View file

@ -26,7 +26,7 @@ package techreborn.api.generator;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
public record FluidGeneratorRecipe(Fluid fluid, int energyPerMb,
EFluidGenerator generatorType) {

View file

@ -26,7 +26,7 @@ package techreborn.api.generator;
import com.google.common.collect.Sets;
import net.minecraft.fluid.Fluid;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
import java.util.HashSet;
import java.util.Optional;

View file

@ -37,7 +37,7 @@ 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;
import reborncore.common.fluid.FluidUtils;
public class FluidReplicatorRecipe extends RebornFluidRecipe {
@ -66,7 +66,7 @@ public class FluidReplicatorRecipe extends RebornFluidRecipe {
return false;
}
final BlockPos hole = blockEntity.getPos().offset(blockEntity.getFacing().getOpposite(), 2);
final Fluid fluid = techreborn.utils.FluidUtils.fluidFromBlock(blockEntity.getWorld().getBlockState(hole).getBlock());
final Fluid fluid = FluidUtils.fluidFromBlock(blockEntity.getWorld().getBlockState(hole).getBlock());
if (fluid == Fluids.EMPTY) {
return true;
}

View file

@ -38,7 +38,6 @@ import reborncore.api.blockentity.InventoryProvider;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.blocks.BlockMachineBase;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.powerSystem.PowerAcceptorBlockEntity;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
@ -46,7 +45,7 @@ import techreborn.api.generator.EFluidGenerator;
import techreborn.api.generator.FluidGeneratorRecipe;
import techreborn.api.generator.FluidGeneratorRecipeList;
import techreborn.api.generator.GeneratorRecipeHelper;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEntity implements IToolDrop, InventoryProvider {
@ -89,10 +88,10 @@ public abstract class BaseFluidGeneratorBlockEntity extends PowerAcceptorBlockEn
if (ticksSinceLastChange >= 10) {
ItemStack inputStack = inventory.getStack(0);
if (!inputStack.isEmpty()) {
if (FluidUtils.isContainerEmpty(inputStack) && !tank.getFluidAmount().isEmpty()) {
FluidUtils.fillContainers(tank, inventory, 0, 1);
} else if (inputStack.getItem() instanceof ItemFluidInfo && getRecipes().getRecipeForFluid(((ItemFluidInfo) inputStack.getItem()).getFluid(inputStack)).isPresent()) {
if (FluidUtils.containsMatchingFluid(inputStack, f -> getRecipes().getRecipeForFluid(f).isPresent())) {
FluidUtils.drainContainers(tank, inventory, 0, 1);
} else {
FluidUtils.fillContainers(tank, inventory, 0, 1);
}
}

View file

@ -47,7 +47,7 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.ModRecipes;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
/**
* @author drcrazy

View file

@ -47,7 +47,7 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.ModRecipes;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
public class IndustrialGrinderBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {

View file

@ -47,7 +47,7 @@ import techreborn.config.TechRebornConfig;
import techreborn.init.ModRecipes;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
public class IndustrialSawmillBlockEntity extends GenericMachineBlockEntity implements BuiltScreenHandlerProvider {

View file

@ -409,6 +409,7 @@ public class AutoCraftingTableBlockEntity extends PowerAcceptorBlockEntity
@Override
public void writeNbt(NbtCompound tag) {
tag.putBoolean("locked", locked);
super.writeNbt(tag);
}
@Override

View file

@ -41,10 +41,10 @@ import techreborn.init.TRContent;
public class HighVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
/**
* MFSU should store 4M Energy with 512 E/t I/O
* MFSU should store 40M Energy with 512 E/t I/O
*/
public HighVoltageSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.HIGH_VOLTAGE_SU, pos, state, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, RcEnergyTier.HIGH, 4_000_000);
super(TRBlockEntities.HIGH_VOLTAGE_SU, pos, state, "HIGH_VOLTAGE_SU", 2, TRContent.Machine.HIGH_VOLTAGE_SU.block, RcEnergyTier.HIGH, 40_000_000);
}
@Override

View file

@ -40,10 +40,10 @@ import techreborn.init.TRContent;
public class MediumVoltageSUBlockEntity extends EnergyStorageBlockEntity implements BuiltScreenHandlerProvider {
/**
* MFE should store 300k energy with 128 E/t I/O
* MFE should store 4M energy with 128 E/t I/O
*/
public MediumVoltageSUBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, pos, state, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, RcEnergyTier.MEDIUM, 300_000);
super(TRBlockEntities.MEDIUM_VOLTAGE_SU, pos, state, "MEDIUM_VOLTAGE_SU", 2, TRContent.Machine.MEDIUM_VOLTAGE_SU.block, RcEnergyTier.MEDIUM, 4_000_000);
}
@Override

View file

@ -43,15 +43,13 @@ import reborncore.client.screen.BuiltScreenHandlerProvider;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.client.screen.builder.ScreenHandlerBuilder;
import reborncore.common.blockentity.MachineBaseBlockEntity;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.util.FluidTextHelper;
import reborncore.common.util.RebornInventory;
import reborncore.common.util.Tank;
import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
import java.util.List;
@ -160,7 +158,7 @@ public class TankUnitBaseBlockEntity extends MachineBaseBlockEntity implements I
info.add(
new LiteralText(String.valueOf(this.tank.getFluidAmount()))
.append(new TranslatableText("techreborn.tooltip.unit.divider"))
.append(WordUtils.capitalize(FluidUtil.getFluidName(this.tank.getFluid())))
.append(WordUtils.capitalize(FluidUtils.getFluidName(this.tank.getFluid())))
);
} else {
info.add(new TranslatableText("techreborn.tooltip.unit.empty"));

View file

@ -24,6 +24,11 @@
package techreborn.blockentity.storage.item;
import net.fabricmc.fabric.api.transfer.v1.item.InventoryStorage;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.item.base.SingleStackStorage;
import net.fabricmc.fabric.api.transfer.v1.storage.Storage;
import net.fabricmc.fabric.api.transfer.v1.storage.base.CombinedStorage;
import net.minecraft.block.BlockState;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.entity.player.PlayerEntity;
@ -51,6 +56,7 @@ import techreborn.init.TRBlockEntities;
import techreborn.init.TRContent;
import java.util.List;
import java.util.Objects;
public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implements InventoryProvider, IToolDrop, IListInfoProvider, BuiltScreenHandlerProvider {
@ -66,6 +72,8 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
private int serverCapacity = -1;
private ItemStack storeItemStack;
// Fabric transfer API support for the internal stack (one per direction);
private final SingleStackStorage[] internalStoreStorage = new SingleStackStorage[6];
private TRContent.StorageUnit type;
@ -75,23 +83,21 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state) {
super(TRBlockEntities.STORAGE_UNIT, pos, state);
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
}
public StorageUnitBaseBlockEntity(BlockPos pos, BlockState state, TRContent.StorageUnit type) {
super(TRBlockEntities.STORAGE_UNIT, pos, state);
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
configureEntity(type);
}
private void configureEntity(TRContent.StorageUnit type) {
// Set capacity to local config unless overridden by server
if(serverCapacity == -1){
this.maxCapacity = type.capacity;
}
storeItemStack = ItemStack.EMPTY;
inventory = new RebornInventory<>(2, "ItemInventory", 64, this);
this.type = type;
}
@ -313,8 +319,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
if (tagCompound.contains("lockedItem")) {
lockedItemStack = ItemStack.fromNbt(tagCompound.getCompound("lockedItem"));
}
inventory.read(tagCompound);
}
@Override
@ -340,8 +344,6 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
if (isLocked()) {
tagCompound.put("lockedItem", lockedItemStack.writeNbt(new NbtCompound()));
}
inventory.write(tagCompound);
}
@Override
@ -500,4 +502,57 @@ public class StorageUnitBaseBlockEntity extends MachineBaseBlockEntity implement
public void setStoredStackFromNBT(NbtCompound tag) {
storeItemStack = ItemStack.fromNbt(tag);
}
private Storage<ItemVariant> getInternalStoreStorage(Direction side) {
Objects.requireNonNull(side);
if (internalStoreStorage[side.getId()] == null) {
internalStoreStorage[side.getId()] = new SingleStackStorage() {
@Override
protected ItemStack getStack() {
return storeItemStack;
}
@Override
protected void setStack(ItemStack stack) {
if (stack.isEmpty()) {
// Ensure we maintain reference equality to EMPTY
storeItemStack = ItemStack.EMPTY;
} else {
storeItemStack = stack;
}
}
@Override
protected int getCapacity(ItemVariant itemVariant) {
// subtract capacity of output slot (super capacity is the default capacity)
return maxCapacity - super.getCapacity(itemVariant);
}
@Override
protected boolean canInsert(ItemVariant itemVariant) {
// Check insertion with the same rules as the input slot
return StorageUnitBaseBlockEntity.this.canInsert(INPUT_SLOT, itemVariant.toStack(), side);
}
@Override
protected boolean canExtract(ItemVariant itemVariant) {
// Check extraction with the same rules as the output slot
return StorageUnitBaseBlockEntity.this.canExtract(OUTPUT_SLOT, itemVariant.toStack(), side);
}
@Override
protected void onFinalCommit() {
inventory.setHashChanged();
}
};
}
return internalStoreStorage[side.getId()];
}
public Storage<ItemVariant> getExposedStorage(Direction side) {
return new CombinedStorage<>(List.of(
getInternalStoreStorage(side),
InventoryStorage.of(this, side)
));
}
}

View file

@ -24,13 +24,13 @@
package techreborn.client.gui;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import reborncore.client.ClientChunkManager;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonSimple;
import reborncore.client.gui.builder.widget.GuiButtonUpDown;
import reborncore.client.gui.builder.widget.GuiButtonUpDown.UpDownButtonType;
import reborncore.client.screen.builder.BuiltScreenHandler;
@ -54,7 +54,7 @@ public class GuiChunkLoader extends GuiBase<BuiltScreenHandler> {
addDrawableChild(new GuiButtonUpDown(x + 64 + 24, y + 40, this, b -> onClick(-1), UpDownButtonType.REWIND));
addDrawableChild(new GuiButtonUpDown(x + 64 + 36, y + 40, this, b -> onClick(-5), UpDownButtonType.FASTREWIND));
addDrawableChild(new GuiButtonSimple(x + 10, y + 70, 155, 20, new LiteralText("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos())));
addDrawableChild(new ButtonWidget(x + 10, y + 70, 155, 20, new LiteralText("Toggle Loaded Chunks"), b -> ClientChunkManager.toggleLoadedChunks(blockEntity.getPos())));
}
@Override

View file

@ -24,6 +24,7 @@
package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.resource.language.I18n;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
@ -64,7 +65,7 @@ public class GuiGreenhouseController extends GuiBase<BuiltScreenHandler> {
drawSlot(matrixStack, 48, gridYPos + 36, layer);
if (!blockEntity.isMultiblockValid()) {
getMinecraft().getTextureManager().bindTexture(new Identifier("techreborn", "textures/item/part/digital_display.png"));
RenderSystem.setShaderTexture(0, new Identifier("techreborn", "textures/item/part/digital_display.png"));
drawTexture(matrixStack, x + 68, y + 22, 0, 0, 16, 16, 16, 16);
if (isPointInRect(68, 22, 16, 16, mouseX, mouseY)) {
List<Text> list = Arrays.stream(I18n.translate("techreborn.tooltip.greenhouse.upgrade_available")

View file

@ -24,16 +24,14 @@
package techreborn.client.gui;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.Identifier;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.gui.builder.widget.GuiButtonSimple;
import reborncore.client.gui.guibuilder.GuiBuilder;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.common.network.NetworkManager;
@ -41,12 +39,10 @@ import techreborn.blockentity.machine.iron.IronFurnaceBlockEntity;
import techreborn.packets.ServerboundPackets;
import techreborn.utils.PlayerUtils;
import java.util.ArrayList;
import java.util.List;
public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
IronFurnaceBlockEntity blockEntity;
private static final Identifier EXP_BUTTON_TEXTURE = new Identifier("minecraft", "textures/item/experience_bottle.png");
public GuiIronFurnace(int syncID, PlayerEntity player, IronFurnaceBlockEntity furnace) {
@ -61,46 +57,49 @@ public class GuiIronFurnace extends GuiBase<BuiltScreenHandler> {
@Override
public void init() {
super.init();
addSelectableChild(new GuiButtonSimple(getGuiLeft() + 116, getGuiTop() + 57, 18, 18, LiteralText.EMPTY, b -> onClick()) {
ButtonWidget.TooltipSupplier tooltipSupplier = (button, matrices, mouseX, mouseY) -> {
PlayerEntity player = MinecraftClient.getInstance().player;
if (player == null) { return; }
String message = "Experience: ";
@Override
public void renderTooltip(MatrixStack matrixStack, int mouseX, int mouseY) {
PlayerEntity player = MinecraftClient.getInstance().player;
String message = "Experience: ";
float furnaceExp = blockEntity.experience;
if (furnaceExp <= 0) {
message = message + "0";
float furnaceExp = blockEntity.experience;
if (furnaceExp <= 0) {
message = message + "0";
} else {
float expTillLevel = (1.0F - player.experienceProgress) * player.getNextLevelExperience();
if (furnaceExp <= expTillLevel) {
int percentage = (int) (blockEntity.experience * 100 / player.getNextLevelExperience());
message = message + "+"
+ (percentage > 0 ? String.valueOf(percentage) : "<1")
+ "%";
} else {
float expTillLevel = (1.0F - player.experienceProgress) * player.getNextLevelExperience();
if (furnaceExp <= expTillLevel) {
int percentage = (int) (blockEntity.experience * 100 / player.getNextLevelExperience());
message = message + "+"
+ (percentage > 0 ? String.valueOf(percentage) : "<1")
+ "%";
} else {
int levels = 0;
furnaceExp -= expTillLevel;
while (furnaceExp > 0) {
furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel);
++levels;
}
message = message + "+" + levels + "L";
int levels = 0;
furnaceExp -= expTillLevel;
while (furnaceExp > 0) {
furnaceExp -= PlayerUtils.getLevelExperience(player.experienceLevel);
++levels;
}
message = message + "+" + levels + "L";
}
List<Text> list = new ArrayList<>();
list.add(new LiteralText(message));
GuiIronFurnace.this.renderTooltip(matrixStack, list, mouseX, mouseY);
RenderSystem.setShaderColor(1, 1, 1, 1);
}
@Override
protected void renderBackground(MatrixStack matrices, MinecraftClient client, int mouseX, int mouseY) {
client.getItemRenderer().renderInGuiWithOverrides(new ItemStack(Items.EXPERIENCE_BOTTLE), x, y);
}
});
renderTooltip(matrices, new LiteralText(message), mouseX, mouseY);
};
addDrawableChild(new TexturedButtonWidget(
getGuiLeft() + 116,
getGuiTop() + 58,
16,
16,
0,
0,
1,
EXP_BUTTON_TEXTURE,
16,
16,
b -> onClick(),
tooltipSupplier,
LiteralText.EMPTY));
}
@Override

View file

@ -29,7 +29,7 @@ import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.text.TranslatableText;
import reborncore.client.gui.builder.GuiBase;
import reborncore.client.screen.builder.BuiltScreenHandler;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.FluidUtils;
import reborncore.common.fluid.container.FluidInstance;
import techreborn.blockentity.storage.fluid.TankUnitBaseBlockEntity;
@ -67,7 +67,7 @@ public class GuiTankUnit extends GuiBase<BuiltScreenHandler> {
textRenderer.draw(matrixStack, new TranslatableText("techreborn.tooltip.unit.empty"), 10, 20, 4210752);
} else {
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.tank.type"), 10, 20, 4210752);
textRenderer.draw(matrixStack, FluidUtil.getFluidName(fluid).replace("_", " "), 10, 30, 4210752);
textRenderer.draw(matrixStack, FluidUtils.getFluidName(fluid).replace("_", " "), 10, 30, 4210752);
textRenderer.draw(matrixStack, new TranslatableText("gui.techreborn.tank.amount"), 10, 50, 4210752);

View file

@ -301,10 +301,10 @@ public class TechRebornConfig {
@Config(config = "items", category = "power", key = "quantumSuitDamageAbsorbCost", comment = "Quantum Suit Cost for Damage Absorbed")
public static double damageAbsorbCost = 10;
@Config(config = "items", category = "upgrades", key = "overclcoker_speed", comment = "Overclocker behavior speed multipiler")
@Config(config = "items", category = "upgrades", key = "overclocker_speed", comment = "Overclocker behavior speed multiplier")
public static double overclockerSpeed = 0.25;
@Config(config = "items", category = "upgrades", key = "overclcoker_power", comment = "Overclocker behavior power multipiler")
@Config(config = "items", category = "upgrades", key = "overclocker_power", comment = "Overclocker behavior power multiplier")
public static double overclockerPower = 0.75;
@Config(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage behavior extra power")

View file

@ -25,18 +25,19 @@
package techreborn.events;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.transfer.v1.item.ItemStorage;
import net.minecraft.block.*;
import net.minecraft.entity.EquipmentSlot;
import net.minecraft.item.Item;
import net.minecraft.item.Item.Settings;
import net.minecraft.item.Items;
import net.minecraft.item.ToolMaterials;
import net.minecraft.sound.BlockSoundGroup;
import reborncore.RebornRegistry;
import reborncore.common.powerSystem.RcEnergyTier;
import team.reborn.energy.api.EnergyStorage;
import techreborn.TechReborn;
import techreborn.blockentity.cable.CableBlockEntity;
import techreborn.blockentity.storage.item.StorageUnitBaseBlockEntity;
import techreborn.blocks.misc.*;
import techreborn.config.TechRebornConfig;
import techreborn.init.*;
@ -172,6 +173,16 @@ public class ModRegistry {
RebornRegistry.registerItem(TRContent.PERIDOT_LEGGINGS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.PERIDOT, EquipmentSlot.LEGS), "peridot_leggings"));
RebornRegistry.registerItem(TRContent.PERIDOT_BOOTS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.PERIDOT, EquipmentSlot.FEET), "peridot_boots"));
RebornRegistry.registerItem(TRContent.SILVER_HELMET = InitUtils.setup(new TRArmourItem(TRArmorMaterials.SILVER, EquipmentSlot.HEAD), "silver_helmet"));
RebornRegistry.registerItem(TRContent.SILVER_CHESTPLATE = InitUtils.setup(new TRArmourItem(TRArmorMaterials.SILVER, EquipmentSlot.CHEST), "silver_chestplate"));
RebornRegistry.registerItem(TRContent.SILVER_LEGGINGS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.SILVER, EquipmentSlot.LEGS), "silver_leggings"));
RebornRegistry.registerItem(TRContent.SILVER_BOOTS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.SILVER, EquipmentSlot.FEET), "silver_boots"));
RebornRegistry.registerItem(TRContent.STEEL_HELMET = InitUtils.setup(new TRArmourItem(TRArmorMaterials.STEEL, EquipmentSlot.HEAD), "steel_helmet"));
RebornRegistry.registerItem(TRContent.STEEL_CHESTPLATE = InitUtils.setup(new TRArmourItem(TRArmorMaterials.STEEL, EquipmentSlot.CHEST), "steel_chestplate"));
RebornRegistry.registerItem(TRContent.STEEL_LEGGINGS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.STEEL, EquipmentSlot.LEGS), "steel_leggings"));
RebornRegistry.registerItem(TRContent.STEEL_BOOTS = InitUtils.setup(new TRArmourItem(TRArmorMaterials.STEEL, EquipmentSlot.FEET), "steel_boots"));
// Battery
RebornRegistry.registerItem(TRContent.RED_CELL_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.redCellBatteryMaxCharge, RcEnergyTier.LOW), "red_cell_battery"));
RebornRegistry.registerItem(TRContent.LITHIUM_ION_BATTERY = InitUtils.setup(new BatteryItem(TechRebornConfig.lithiumIonBatteryMaxCharge, RcEnergyTier.MEDIUM), "lithium_ion_battery"));
@ -211,6 +222,7 @@ public class ModRegistry {
RebornRegistry.registerItem(TRContent.MANUAL = InitUtils.setup(new ManualItem(), "manual"));
RebornRegistry.registerItem(TRContent.DEBUG_TOOL = InitUtils.setup(new DebugToolItem(), "debug_tool"));
RebornRegistry.registerItem(TRContent.CELL = InitUtils.setup(new DynamicCellItem(), "cell"));
TRContent.CELL.registerFluidApi();
TechReborn.LOGGER.debug("TechReborns Items Loaded");
}
@ -232,6 +244,7 @@ public class ModRegistry {
}
private static void registerApis() {
EnergyStorage.SIDED.registerForBlockEntities((be, direction) -> ((CableBlockEntity) be).getSideEnergyStorage(direction), TRBlockEntities.CABLE);
EnergyStorage.SIDED.registerForBlockEntity(CableBlockEntity::getSideEnergyStorage, TRBlockEntities.CABLE);
ItemStorage.SIDED.registerForBlockEntity(StorageUnitBaseBlockEntity::getExposedStorage, TRBlockEntities.STORAGE_UNIT);
}
}

View file

@ -24,12 +24,16 @@
package techreborn.events;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
import net.minecraft.block.Block;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.item.TooltipContext;
import net.minecraft.fluid.FlowableFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.server.integrated.IntegratedServer;
@ -44,6 +48,7 @@ import net.minecraft.world.gen.HeightContext;
import org.jetbrains.annotations.Nullable;
import reborncore.common.BaseBlockEntityProvider;
import techreborn.init.TRContent;
import techreborn.items.DynamicCellItem;
import techreborn.items.UpgradeItem;
import techreborn.utils.ToolTipAssistUtils;
import techreborn.world.OreDistribution;
@ -56,12 +61,18 @@ public class StackToolTipHandler implements ItemTooltipCallback {
public static final Map<Item, Boolean> ITEM_ID = Maps.newHashMap();
private static final Map<Block, OreDistribution> ORE_DISTRIBUTION_MAP = Maps.newHashMap();
private static final List<Block> UNOBTAINABLE_ORES = Lists.newLinkedList();
public static void setup() {
ItemTooltipCallback.EVENT.register(new StackToolTipHandler());
for (TRContent.Ores ore : TRContent.Ores.values()) {
if (ore.isDeepslate()) continue;
if (ore.isDeepslate()) {
TRContent.Ores normal = ore.getUnDeepslate();
if (normal.distribution != null && normal.distribution.dimension != TargetDimension.OVERWORLD)
UNOBTAINABLE_ORES.add(ore.block);
continue;
}
if (ore.distribution != null) {
ORE_DISTRIBUTION_MAP.put(ore.block, ore.distribution);
@ -103,18 +114,25 @@ public class StackToolTipHandler implements ItemTooltipCallback {
tooltipLines.addAll(ToolTipAssistUtils.getUpgradeStats(TRContent.Upgrades.valueOf(upgrade.name.toUpperCase()), stack.getCount(), Screen.hasShiftDown()));
}
OreDistribution oreDistribution = ORE_DISTRIBUTION_MAP.get(block);
if (item instanceof DynamicCellItem cell) {
Fluid fluid = cell.getFluid(stack);
if (!(fluid instanceof FlowableFluid) && fluid != Fluids.EMPTY)
ToolTipAssistUtils.addInfo("unplaceable_fluid", tooltipLines, false);
}
if (oreDistribution != null) {
Text text = switch (oreDistribution.dimension) {
Text text = null;
if (UNOBTAINABLE_ORES.contains(block))
text = new TranslatableText("techreborn.tooltip.unobtainable");
OreDistribution oreDistribution = ORE_DISTRIBUTION_MAP.get(block);
if (oreDistribution != null && text == null) {
text = switch (oreDistribution.dimension) {
case OVERWORLD -> getOverworldOreText(oreDistribution);
case END -> new TranslatableText("techreborn.tooltip.ores.end");
case NETHER -> new TranslatableText("techreborn.tooltip.ores.nether");
};
if (text != null)
tooltipLines.add(text.copy().formatted(Formatting.AQUA));
}
if (text != null)
tooltipLines.add(text.copy().formatted(Formatting.AQUA));
}
private static boolean isTRItem(Item item) {

View file

@ -84,11 +84,12 @@ public enum ModFluids {
this.identifier = new Identifier(TechReborn.MOD_ID, this.toString().toLowerCase(Locale.ROOT));
FluidSettings fluidSettings = FluidSettings.create();
Identifier texture_still = new Identifier(TechReborn.MOD_ID, "block/fluids/" + this.toString().toLowerCase(Locale.ROOT) + "_still");
Identifier texture_flowing = new Identifier(TechReborn.MOD_ID, "block/fluids/" + this.toString().toLowerCase(Locale.ROOT) + "_flowing");
Identifier texture = new Identifier(TechReborn.MOD_ID, "block/fluids/" + this.toString().toLowerCase(Locale.ROOT) + "_flowing");
fluidSettings.setStillTexture(texture);
fluidSettings.setFlowingTexture(texture);
fluidSettings.setStillTexture(texture_still);
fluidSettings.setFlowingTexture(texture_flowing);
stillFluid = new RebornFluid(true, fluidSettings, () -> block, () -> bucket, () -> flowingFluid, () -> stillFluid) {
};

View file

@ -49,6 +49,12 @@ public enum TRArmorMaterials 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());
}),
SILVER(14, new int[]{1, 3, 5, 2}, 20, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, () -> {
return Ingredient.ofItems(TRContent.Ingots.SILVER.asItem());
}),
STEEL(24, new int[]{3, 5, 6, 2}, 5, SoundEvents.ITEM_ARMOR_EQUIP_IRON, 1.75F, 0.1F, () -> {
return Ingredient.ofItems(TRContent.Ingots.STEEL.asItem());
}),
QUANTUM(75, new int[]{3, 6, 8, 3}, 10, SoundEvents.ITEM_ARMOR_EQUIP_DIAMOND, 0.0F, () -> Ingredient.EMPTY),
CLOAKING_DEVICE(5, new int[]{0, 2, 0, 0}, 0, SoundEvents.ITEM_ARMOR_EQUIP_GOLD, 0.0F, () -> Ingredient.EMPTY),
LITHIUM_BATPACK(25, new int[]{0, 5, 0, 0}, 10, SoundEvents.ITEM_ARMOR_EQUIP_TURTLE, 0.0F, () -> Ingredient.EMPTY),
@ -60,18 +66,25 @@ public enum TRArmorMaterials implements ArmorMaterial {
private final int enchantability;
private final SoundEvent soundEvent;
private final float toughness;
private final float knockbackResistance;
private final Lazy<Ingredient> repairMaterial;
TRArmorMaterials(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterialIn) {
SoundEvent soundEvent, float toughness, float knockbackResistance, Supplier<Ingredient> repairMaterialIn) {
this.maxDamageFactor = maxDamageFactor;
this.damageReductionAmountArray = damageReductionAmountArray;
this.enchantability = enchantability;
this.soundEvent = soundEvent;
this.toughness = toughness;
this.knockbackResistance = knockbackResistance;
this.repairMaterial = new Lazy<>(repairMaterialIn);
}
TRArmorMaterials(int maxDamageFactor, int[] damageReductionAmountArray, int enchantability,
SoundEvent soundEvent, float toughness, Supplier<Ingredient> repairMaterialIn) {
this(maxDamageFactor, damageReductionAmountArray, enchantability, soundEvent, toughness, 0.0F, repairMaterialIn);
}
@Override
public int getDurability(EquipmentSlot slotIn) {
return MAX_DAMAGE_ARRAY[slotIn.getEntitySlotId()] * maxDamageFactor;
@ -109,6 +122,6 @@ public enum TRArmorMaterials implements ArmorMaterial {
@Override
public float getKnockbackResistance() {
return 0; //Knockback resitance
return knockbackResistance;
}
}

View file

@ -43,7 +43,7 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.event.GameEvent;
import techreborn.items.DynamicCellItem;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
public class TRCauldronBehavior {
public static void init() {

View file

@ -231,6 +231,22 @@ public class TRContent {
public static Item PERIDOT_LEGGINGS;
@Nullable
public static Item PERIDOT_BOOTS;
@Nullable
public static Item SILVER_HELMET;
@Nullable
public static Item SILVER_CHESTPLATE;
@Nullable
public static Item SILVER_LEGGINGS;
@Nullable
public static Item SILVER_BOOTS;
@Nullable
public static Item STEEL_HELMET;
@Nullable
public static Item STEEL_CHESTPLATE;
@Nullable
public static Item STEEL_LEGGINGS;
@Nullable
public static Item STEEL_BOOTS;
public enum SolarPanels implements ItemConvertible {
BASIC(RcEnergyTier.MICRO, TechRebornConfig.basicGenerationRateD, TechRebornConfig.basicGenerationRateN),
@ -373,6 +389,8 @@ public class TRContent {
private final static Map<Ores, Ores> deepslateMap = new HashMap<>();
private final static Map<Ores, Ores> unDeepslateMap = new HashMap<>();
public enum Ores implements ItemConvertible {
// when changing ores also change data/techreborn/tags/items/ores.json for correct root advancement display
// as well as data/minecraft/tags/blocks for correct mining level
@ -424,6 +442,7 @@ public class TRContent {
Ores(TRContent.Ores stoneOre) {
this((OreDistribution) null);
deepslateMap.put(stoneOre, this);
unDeepslateMap.put(this, stoneOre);
}
@Override
@ -436,6 +455,11 @@ public class TRContent {
return deepslateMap.get(this);
}
public TRContent.Ores getUnDeepslate() {
Preconditions.checkArgument(isDeepslate());
return unDeepslateMap.get(this);
}
public boolean isDeepslate() {
return name.startsWith("deepslate_");
}
@ -600,7 +624,7 @@ public class TRContent {
}
public enum Dusts implements ItemConvertible {
ALMANDINE, ALUMINUM, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME,
ALMANDINE, ALUMINUM, AMETHYST, ANDESITE, ANDRADITE, ASHES, BASALT, BAUXITE, BRASS, BRONZE, CALCITE, CHARCOAL, CHROME,
CINNABAR, CLAY, COAL, DARK_ASHES, DIAMOND, DIORITE, ELECTRUM, EMERALD, ENDER_EYE, ENDER_PEARL, ENDSTONE,
FLINT, GALENA, GRANITE, GROSSULAR, INVAR, LAZURITE, MAGNESIUM, MANGANESE, MARBLE, NETHERRACK,
NICKEL, OBSIDIAN, OLIVINE, PERIDOT, PHOSPHOROUS, PLATINUM, PYRITE, PYROPE, QUARTZ, RED_GARNET, RUBY, SALTPETER,
@ -809,6 +833,7 @@ public class TRContent {
UU_MATTER,
PLANTBALL,
COMPRESSED_PLANTBALL,
SPONGE_PIECE,
SYNTHETIC_REDSTONE_CRYSTAL;

View file

@ -1,3 +1,27 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 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.init;
import net.minecraft.item.ToolMaterial;

View file

@ -24,6 +24,13 @@
package techreborn.items;
import net.fabricmc.fabric.api.transfer.v1.context.ContainerItemContext;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidConstants;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidStorage;
import net.fabricmc.fabric.api.transfer.v1.fluid.FluidVariant;
import net.fabricmc.fabric.api.transfer.v1.item.ItemVariant;
import net.fabricmc.fabric.api.transfer.v1.storage.base.SingleVariantItemStorage;
import net.fabricmc.fabric.api.transfer.v1.transaction.TransactionContext;
import net.minecraft.block.BlockState;
import net.minecraft.block.FluidDrainable;
import net.minecraft.block.FluidFillable;
@ -60,12 +67,11 @@ import net.minecraft.world.event.GameEvent;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.text.WordUtils;
import org.jetbrains.annotations.Nullable;
import reborncore.common.fluid.FluidUtil;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.ItemNBTHelper;
import techreborn.TechReborn;
import techreborn.init.TRContent;
import techreborn.utils.FluidUtils;
import reborncore.common.fluid.FluidUtils;
/**
* Created by modmuss50 on 17/05/2016.
@ -160,7 +166,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
Fluid fluid = getFluid(itemStack);
if (fluid != Fluids.EMPTY) {
//TODO use translation keys for fluid and the cell https://fabric.asie.pl/wiki/tutorial:lang?s[]=translation might be useful
return new LiteralText(WordUtils.capitalizeFully(FluidUtil.getFluidName(fluid).replaceAll("_", " ")) + " Cell");
return new LiteralText(WordUtils.capitalizeFully(FluidUtils.getFluidName(fluid).replaceAll("_", " ")) + " Cell");
}
return super.getName(itemStack);
}
@ -171,7 +177,7 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
Fluid containedFluid = getFluid(stack);
BlockHitResult hitResult = raycast(world, player, containedFluid == Fluids.EMPTY ? RaycastContext.FluidHandling.SOURCE_ONLY : RaycastContext.FluidHandling.NONE);
if (hitResult.getType() == HitResult.Type.MISS) {
if (hitResult.getType() == HitResult.Type.MISS || !(containedFluid instanceof FlowableFluid || Fluids.EMPTY == containedFluid)) {
return TypedActionResult.pass(stack);
}
if (hitResult.getType() != HitResult.Type.BLOCK) {
@ -238,10 +244,75 @@ public class DynamicCellItem extends Item implements ItemFluidInfo {
@Override
public Fluid getFluid(ItemStack itemStack) {
NbtCompound tag = itemStack.getNbt();
return getFluid(itemStack.getNbt());
}
private Fluid getFluid(@Nullable NbtCompound tag) {
if (tag != null && tag.contains("fluid")) {
return Registry.FLUID.get(new Identifier(tag.getString("fluid")));
}
return Fluids.EMPTY;
}
public void registerFluidApi() {
FluidStorage.ITEM.registerForItems((stack, ctx) -> new CellStorage(ctx), this);
}
public class CellStorage extends SingleVariantItemStorage<FluidVariant> {
public CellStorage(ContainerItemContext context) {
super(context);
}
@Override
protected FluidVariant getBlankResource() {
return FluidVariant.blank();
}
@Override
protected FluidVariant getResource(ItemVariant currentVariant) {
return FluidVariant.of(getFluid(currentVariant.getNbt()));
}
@Override
protected long getAmount(ItemVariant currentVariant) {
return getResource(currentVariant).isBlank() ? 0 : FluidConstants.BUCKET;
}
@Override
protected long getCapacity(FluidVariant variant) {
return FluidConstants.BUCKET;
}
@Override
protected ItemVariant getUpdatedVariant(ItemVariant currentVariant, FluidVariant newResource, long newAmount) {
if (newAmount != 0 && newAmount != FluidConstants.BUCKET) {
throw new IllegalArgumentException("Only amounts of 0 and 1 bucket are supported! This is a bug!");
}
// TODO: this is not ideal since we delete any extra NBT, but it probably doesn't matter in practice?
if (newResource.isBlank() || newAmount == 0) {
return ItemVariant.of(DynamicCellItem.this);
} else {
return ItemVariant.of(getCellWithFluid(newResource.getFluid()));
}
}
// A few "hacks" to ensure that transfer is always exactly 0 or 1 bucket.
@Override
public long insert(FluidVariant insertedResource, long maxAmount, TransactionContext transaction) {
if (isResourceBlank() && maxAmount >= FluidConstants.BUCKET) {
return super.insert(insertedResource, FluidConstants.BUCKET, transaction);
} else {
return 0;
}
}
@Override
public long extract(FluidVariant extractedResource, long maxAmount, TransactionContext transaction) {
if (!isResourceBlank() && maxAmount >= FluidConstants.BUCKET) {
return super.extract(extractedResource, FluidConstants.BUCKET, transaction);
} else {
return 0;
}
}
}
}

View file

@ -35,7 +35,6 @@ import net.minecraft.tag.Tag;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.powerSystem.RcEnergyTier;
import reborncore.common.util.ItemUtils;
@ -95,7 +94,7 @@ public class DrillItem extends PickaxeItem implements RcEnergyItem, DynamicAttri
if (Items.DIAMOND_SHOVEL.getMiningSpeedMultiplier(new ItemStack(Items.DIAMOND_SHOVEL), blockIn) > 1.0f) {
return true;
}
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(new ItemStack(Items.DIAMOND_SHOVEL), blockIn) > 1.0f;
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(new ItemStack(Items.DIAMOND_PICKAXE), blockIn) > 1.0f;
}
// MiningToolItem

View file

@ -35,7 +35,6 @@ import net.minecraft.item.*;
import net.minecraft.util.collection.DefaultedList;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import reborncore.common.powerSystem.PowerSystem;
import reborncore.common.powerSystem.RcEnergyItem;
import reborncore.common.util.ItemUtils;
import reborncore.common.powerSystem.RcEnergyTier;
@ -54,7 +53,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
// 10k Energy with 128 E\t charge rate
public RockCutterItem() {
// combat stats same as for diamond pickaxe. Fix for #2468
super(TRToolMaterials.ROCK_CUTTER, 1, -2.8F, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
super(TRToolMaterials.ROCK_CUTTER, 1, -2.8f, new Item.Settings().group(TechReborn.ITEMGROUP).maxCount(1).maxDamage(-1));
}
// PickaxeItem
@ -66,7 +65,7 @@ public class RockCutterItem extends PickaxeItem implements RcEnergyItem {
@Override
public float getMiningSpeedMultiplier(ItemStack stack, BlockState state) {
if (getStoredEnergy(stack) < cost) {
return 2F;
return 1.0f;
} else {
return Items.DIAMOND_PICKAXE.getMiningSpeedMultiplier(stack, state);
}

View file

@ -1,142 +0,0 @@
/*
* This file is part of TechReborn, licensed under the MIT License (MIT).
*
* Copyright (c) 2020 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.utils;
import net.minecraft.block.Block;
import net.minecraft.fluid.Fluid;
import net.minecraft.fluid.Fluids;
import net.minecraft.inventory.Inventory;
import net.minecraft.item.ItemStack;
import net.minecraft.util.registry.Registry;
import org.jetbrains.annotations.NotNull;
import reborncore.common.fluid.FluidValue;
import reborncore.common.fluid.container.FluidInstance;
import reborncore.common.fluid.container.ItemFluidInfo;
import reborncore.common.util.Tank;
import reborncore.mixin.common.AccessorFluidBlock;
import java.util.List;
import java.util.stream.Collectors;
public class FluidUtils {
@NotNull
public static Fluid fluidFromBlock(Block block) {
if (block instanceof AccessorFluidBlock) {
return ((AccessorFluidBlock) block).getFluid();
}
return Fluids.EMPTY;
}
public static List<Fluid> getAllFluids() {
return Registry.FLUID.stream().collect(Collectors.toList());
}
public static boolean drainContainers(Tank tank, Inventory inventory, int inputSlot, int outputSlot) {
return drainContainers(tank, inventory, inputSlot, outputSlot, false);
}
public static boolean drainContainers(Tank tank, Inventory inventory, int inputSlot, int outputSlot, boolean voidFluid) {
ItemStack inputStack = inventory.getStack(inputSlot);
ItemStack outputStack = inventory.getStack(outputSlot);
if (inputStack.isEmpty()) return false;
if (!(inputStack.getItem() instanceof ItemFluidInfo itemFluidInfo)) return false;
if (FluidUtils.isContainerEmpty(inputStack)) return false;
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
if (!outputStack.isEmpty() && !FluidUtils.isContainerEmpty(outputStack)) return false;
if (!outputStack.isEmpty() && !outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
FluidInstance tankFluidInstance = tank.getFluidInstance();
Fluid tankFluid = tankFluidInstance.getFluid();
if (tankFluidInstance.isEmpty() || tankFluid == itemFluidInfo.getFluid(inputStack)) {
FluidValue freeSpace = tank.getFluidValueCapacity().subtract(tankFluidInstance.getAmount());
if (freeSpace.equalOrMoreThan(FluidValue.BUCKET) || voidFluid) {
inputStack.decrement(1);
if (!voidFluid) {
tankFluidInstance.setFluid(itemFluidInfo.getFluid(inputStack));
tankFluidInstance.addAmount(FluidValue.BUCKET);
}
if (outputStack.isEmpty()) {
inventory.setStack(outputSlot, itemFluidInfo.getEmpty());
} else {
outputStack.increment(1);
}
}
}
return true;
}
public static boolean fillContainers(Tank source, Inventory inventory, int inputSlot, int outputSlot) {
ItemStack inputStack = inventory.getStack(inputSlot);
ItemStack outputStack = inventory.getStack(outputSlot);
if (!FluidUtils.isContainerEmpty(inputStack)) return false;
ItemFluidInfo itemFluidInfo = (ItemFluidInfo) inputStack.getItem();
FluidInstance sourceFluid = source.getFluidInstance();
if (sourceFluid.getFluid() == Fluids.EMPTY || sourceFluid.getAmount().lessThan(FluidValue.BUCKET)) {
return false;
}
if (!outputStack.isEmpty()) {
if (outputStack.getCount() >= outputStack.getMaxCount()) return false;
if (!(outputStack.getItem() instanceof ItemFluidInfo outputFluidInfo)) return false;
if (!outputStack.isItemEqual(itemFluidInfo.getEmpty())) return false;
if (outputFluidInfo.getFluid(outputStack) != sourceFluid.getFluid()) {
return false;
}
}
if (outputStack.isEmpty()) {
inventory.setStack(outputSlot, itemFluidInfo.getFull(sourceFluid.getFluid()));
} else {
outputStack.increment(1);
}
sourceFluid.subtractAmount(FluidValue.BUCKET);
inputStack.decrement(1);
return true;
}
public static boolean fluidEquals(@NotNull Fluid fluid, @NotNull Fluid fluid1) {
return fluid == fluid1;
}
public static boolean isContainerEmpty(ItemStack stack) {
if (stack.isEmpty())
return false;
if (stack.getItem() instanceof ItemFluidInfo itemFluidInfo)
return itemFluidInfo.getFluid(stack) == Fluids.EMPTY;
return false;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 352 B

View file

@ -377,6 +377,7 @@
"_comment7": "Dusts",
"item.techreborn.almandine_dust": "Almandine Dust",
"item.techreborn.aluminum_dust": "Aluminium Dust",
"item.techreborn.amethyst_dust": "Amethyst Dust",
"item.techreborn.andesite_dust": "Andesite Dust",
"item.techreborn.andradite_dust": "Andradite Dust",
"item.techreborn.ashes_dust": "Ashes",
@ -638,6 +639,7 @@
"item.techreborn.uu_matter": "UU-Matter",
"item.techreborn.plantball": "Plantball",
"item.techreborn.compressed_plantball": "Compressed Plantball",
"item.techreborn.sponge_piece": "Piece of Sponge",
"item.techreborn.synthetic_redstone_crystal": "Synthetic Redstone Crystal",
"_comment14": "Items-Armor",
@ -728,6 +730,16 @@
"item.techreborn.peridot_leggings": "Peridot Leggings",
"item.techreborn.peridot_boots": "Peridot Boots",
"item.techreborn.silver_helmet": "Silver Helmet",
"item.techreborn.silver_chestplate": "Silver Chestplate",
"item.techreborn.silver_leggings": "Silver Leggings",
"item.techreborn.silver_boots": "Silver Boots",
"item.techreborn.steel_helmet": "Steel Helmet",
"item.techreborn.steel_chestplate": "Steel Chestplate",
"item.techreborn.steel_leggings": "Steel Leggings",
"item.techreborn.steel_boots": "Steel Boots",
"_comment18": "Message",
"techreborn.message.missingmultiblock": "Incomplete Multiblock",
"techreborn.message.setTo": "Set to",
@ -747,6 +759,8 @@
"techreborn.message.info.item.techreborn.energy_storage_upgrade": "Increase energy store",
"techreborn.message.info.item.techreborn.superconductor_upgrade": "Increases energy flow rate",
"techreborn.message.info.unplaceable_fluid": "Cannot be placed",
"techreborn.message.info.block.techreborn.basic_solar_panel": "Produce energy from sunlight",
"techreborn.message.info.block.techreborn.advanced_solar_panel": "Produce energy from sunlight",
"techreborn.message.info.block.techreborn.industrial_solar_panel": "Produce energy from sunlight",
@ -870,6 +884,7 @@
"techreborn.tooltip.ores.overworld" : "Can be found at y levels %s < %s",
"techreborn.tooltip.ores.nether" : "Can be found in the nether",
"techreborn.tooltip.ores.end" : "Can be found in the end",
"techreborn.tooltip.unobtainable": "Unobtainable in Survival Mode",
"_comment23": "ManualUI",
"techreborn.manual.wiki": "Online wiki",

View file

@ -1,5 +1,6 @@
{
{
"textures": {
"particle": "techreborn:block/fluids/beryllium_flowing"
"particle": "techreborn:block/fluids/beryllium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/biofuel_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/biofuel_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/calcium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/calcium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/calcium_carbonate_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/calcium_carbonate_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/carbon_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/carbon_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/carbon_fiber_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/carbon_fiber_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/chlorite_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/chlorite_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/compressed_air_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/compressed_air_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/deuterium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/deuterium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/diesel_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/diesel_still"
}
}

View file

@ -1,5 +1,6 @@
{
{
"textures": {
"particle": "techreborn:block/fluids/electrolyzed_water_flowing"
"particle": "techreborn:block/fluids/electrolyzed_water_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/glyceryl_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/glyceryl_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/helium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/helium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/helium3_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/helium3_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/heliumplasma_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/heliumplasma_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/hydrogen_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/hydrogen_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/lithium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/lithium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/mercury_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/mercury_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/methane_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/methane_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitro_carbon_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitro_carbon_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitro_diesel_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitro_diesel_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitrocoal_fuel_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitrocoal_fuel_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitrofuel_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitrofuel_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitrogen_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitrogen_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/nitrogen_dioxide_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/nitrogen_dioxide_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/oil_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/oil_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/potassium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/potassium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/silicon_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/silicon_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/sodium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/sodium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/sodium_persulfate_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/sodium_persulfate_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/sodium_sulfide_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/sodium_sulfide_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/sulfur_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/sulfur_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/sulfuric_acid_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/sulfuric_acid_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/tritium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/tritium_still"
}
}

View file

@ -1,5 +1,6 @@
{
"textures": {
"particle": "techreborn:block/fluids/wolframium_flowing"
}
}
{
"textures": {
"particle": "techreborn:block/fluids/wolframium_still"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/dust/amethyst_dust"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/silver_boots"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/silver_chestplate"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/silver_helmet"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/silver_leggings"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/part/sponge_piece"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/steel_boots"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/steel_chestplate"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/steel_helmet"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:item/generated",
"textures": {
"layer0": "techreborn:item/armor/steel_leggings"
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.3 KiB

After

Width:  |  Height:  |  Size: 8.1 KiB

Before After
Before After

View file

@ -1,5 +1,3 @@
{
"animation":{
"frametime":2
}
}
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 8.2 KiB

Before After
Before After

View file

@ -1,5 +1,3 @@
{
"animation":{
"frametime":4
}
}
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.6 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

Before After
Before After

View file

@ -1,5 +1,3 @@
{
"animation":{
"frametime":2
}
}
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.4 KiB

After

Width:  |  Height:  |  Size: 8.9 KiB

Before After
Before After

View file

@ -1,5 +1,3 @@
{
"animation":{
"frametime":2
}
}
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 7.5 KiB

Before After
Before After

View file

@ -1,5 +1,3 @@
{
"animation":{
"frametime":2
}
}
{
"animation": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

View file

@ -0,0 +1,5 @@
{
"animation": {
"frametime": 2
}
}

Some files were not shown because too many files have changed in this diff Show more