Skip to content

Commit

Permalink
cherrypick to 1.19 (#510)
Browse files Browse the repository at this point in the history
* laser cables (#501)

* feat: laser cables

* fix: remove laser recipe capability, recipes

* fix: add 16A dynamo hatch recipes.

* remove todo

* fix: steam machines only allow GT steam to be inserted.

* reviews

* High-tier content config option (#499)

* feat: highTier.

* fix: loot table errors when highTier is disabled

* test for dev env in enabling HighTier, void miners

* fix tooltips

* Revert "fix tooltips"

This reverts commit a53a9fc.

* fix: add a cap on transfer rate.

* chore: add missing, fix existing textures for pump/fluid regulator covers

* fix: UHV+ fluid regulators.

---------

Co-authored-by: Mikerooni <[email protected]>

* chore: run data, changelog

* ME i/o hatches for multiblocks (#500)

* feat: ME HATCHES
still lots of crashes tho.

* fix up buses. next up: hatches.

* works. current issues:
- input buses output infinite of the inputs without clearing
- you can't empty cleared configs (cause of the above?)

* remove the sychronized blocks i used for testing

* works better. AEItemDisplayWidget doesn't display items, somehow. no clue how.

* feat: pass ME, energy through hulls
FINISH

* feat: recipes

* reviews

* fix: where the shit did this method go?

---------

Co-authored-by: Mikerooni <[email protected]>
  • Loading branch information
screret and mikerooni authored Nov 3, 2023
1 parent 8585280 commit ad45897
Show file tree
Hide file tree
Showing 399 changed files with 8,809 additions and 451 deletions.
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# ChangeLog

* fix transfer + fix ldlib
* fix fluid slot overflow
* fix assembly line recipe handling
* update zh_cn lang
* fix stone ores having broken translations
* Add ME stocking input bus/hatch, ME output bus/hatch
* add laser cables
* add high-tier content config option
* add ore processing chart recipeviewer page
* make manual compression recipes be shaped
* switch certus quartz material amount to 4
26 changes: 26 additions & 0 deletions common/src/main/java/com/gregtechceu/gtceu/GTCEu.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.addon.AddonFinder;
import com.gregtechceu.gtceu.api.addon.IGTAddon;
import com.gregtechceu.gtceu.config.ConfigHolder;
import com.gregtechceu.gtceu.utils.FormattingUtil;
import com.lowdragmc.lowdraglib.LDLib;
import com.lowdragmc.lowdraglib.Platform;
import lombok.Getter;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -15,6 +18,11 @@ public class GTCEu {
public static final String NAME = "GregTechCEu";
public static final Logger LOGGER = LoggerFactory.getLogger(NAME);

/** Will be available at the Pre-Initialization stage */
@Getter
private static boolean highTier;
private static boolean highTierInitialized;

public static void init() {
LOGGER.info("{} is initializing on platform: {}", NAME, Platform.platformName());
}
Expand Down Expand Up @@ -55,7 +63,25 @@ public static boolean isRebornEnergyLoaded() {
return Platform.isForge() || LDLib.isModLoaded(GTValues.MODID_REBORN_ENERGY);
}

public static boolean isAE2Loaded() {
return LDLib.isModLoaded(GTValues.MODID_APPENG);
}

public static boolean isAlmostUnifiedLoaded() {
return LDLib.isModLoaded(GTValues.MODID_ALMOSTUNIFIED);
}


/**
* Initializes High-Tier. Internal use only, do not attempt to call this.
*/
@ApiStatus.Internal
public static void initializeHighTier() {
if (highTierInitialized) throw new IllegalStateException("High-Tier is already initialized.");
highTier = ConfigHolder.INSTANCE.machines.highTierContent || AddonFinder.getAddons().stream().anyMatch(IGTAddon::requiresHighTier) || Platform.isDevEnv();
highTierInitialized = true;

if (isHighTier()) GTCEu.LOGGER.info("High-Tier is Enabled.");
else GTCEu.LOGGER.info("High-Tier is Disabled.");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,12 @@ default void collectMaterialCasings(MaterialCasingCollectionEvent event) {
default void registerRecipeKeys(KJSRecipeKeyEvent event) {

}

/**
* Does this addon require high-tier content to be enabled?
* @return if this addon requires highTier.
*/
default boolean requiresHighTier() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public abstract class PipeBlockEntity<PipeType extends Enum<PipeType> & IPipeTyp
@Persisted(key = "cover")
protected final PipeCoverContainer coverContainer;

@Setter
@Getter @Setter
@DescSynced
@Persisted
@RequireRerender
Expand Down Expand Up @@ -133,6 +133,17 @@ public void clearRemoved() {
coverContainer.onLoad();
}

@Override
public int getNumConnections() {
int count = 0;
int connections = getConnections();
while (connections > 0) {
count++;
connections = connections & (connections - 1);
}
return count;
}

@Nullable
public TickableSubscription subscribeServerTick(Runnable runnable) {
if (!isRemote()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,10 @@ public static ICleanroomReceiver getCleanroomReceiver(Level level, BlockPos pos,
public static IMaintenanceMachine getMaintenanceMachine(Level level, BlockPos pos, @Nullable Direction side) {
throw new AssertionError();
}

@ExpectPlatform
@Nullable
public static ILaserContainer getLaser(Level level, BlockPos pos, @Nullable Direction side) {
throw new AssertionError();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.gregtechceu.gtceu.api.capability;

/**
* It is its own separate interface to make piping work easier
*/
public interface ILaserContainer extends IEnergyContainer {
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@ public class BlockStateRecipeCapability extends RecipeCapability<BlockState> {
protected BlockStateRecipeCapability() {
super("block_state", 0xFFABABAB, SerializerBlockState.INSTANCE);
}

@Override
public BlockState copyInner(BlockState content) {
return content;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -295,4 +295,10 @@ public class GuiTextures {
TIER[i] = new ResourceTexture("gtceu:textures/gui/overlay/tier.png").getSubTexture(0, i * offset, 1, offset);
}
}

// ME hatch/bus
public static final ResourceTexture NUMBER_BACKGROUND = new ResourceTexture("gtceu:textures/gui/widget/number_background.png");
public static final ResourceTexture CONFIG_ARROW = new ResourceTexture("gtceu:textures/gui/widget/config_arrow.png");
public static final ResourceTexture CONFIG_ARROW_DARK = new ResourceTexture("gtceu:textures/gui/widget/config_arrow_dark.png");
public static final ResourceTexture SELECT_BOX = new ResourceTexture("gtceu:textures/gui/widget/select_box.png");
}
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public NumberInputWidget<T> setValue(T value) {
return this;
}

private void updateTextFieldRange() {
protected void updateTextFieldRange() {
setTextFieldRange(textField, min, max);

this.setValue(clamp(valueSupplier.get(), min, max));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.gregtechceu.gtceu.api.item;

import com.gregtechceu.gtceu.api.block.PipeBlock;
import com.gregtechceu.gtceu.common.block.LaserPipeBlock;
import com.lowdragmc.lowdraglib.client.renderer.IItemRendererProvider;
import com.lowdragmc.lowdraglib.client.renderer.IRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.color.item.ItemColor;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.Nullable;

public class LaserPipeBlockItem extends PipeBlockItem implements IItemRendererProvider {

public LaserPipeBlockItem(PipeBlock block, Properties properties) {
super(block, properties);
}

@Override
public LaserPipeBlock getBlock() {
return (LaserPipeBlock) super.getBlock();
}

@Environment(EnvType.CLIENT)
public static ItemColor tintColor() {
return (itemStack, index) -> {
if (itemStack.getItem() instanceof LaserPipeBlockItem materialBlockItem) {
return materialBlockItem.getBlock().tinted(materialBlockItem.getBlock().defaultBlockState(), null, null, index);
}
return -1;
};
}

@Nullable
@Override
@Environment(EnvType.CLIENT)
public IRenderer getRenderer(ItemStack stack) {
return getBlock().getRenderer(getBlock().defaultBlockState());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.lowdragmc.lowdraglib.syncdata.blockentity.IRPCBlockEntity;
import com.lowdragmc.lowdraglib.syncdata.managed.MultiManagedStorage;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;

Expand Down Expand Up @@ -66,4 +67,15 @@ default MachineDefinition getDefinition() {

MultiManagedStorage getRootStorage();

@Override
default void saveCustomPersistedData(CompoundTag tag, boolean forDrop) {
IAutoPersistBlockEntity.super.saveCustomPersistedData(tag, forDrop);
getMetaMachine().saveCustomPersistedData(tag, forDrop);
}

@Override
default void loadCustomPersistedData(CompoundTag tag) {
IAutoPersistBlockEntity.super.loadCustomPersistedData(tag);
getMetaMachine().loadCustomPersistedData(tag);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import net.minecraft.MethodsReturnNonnullByDefault;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.TickTask;
import net.minecraft.server.level.ServerLevel;
Expand Down Expand Up @@ -188,6 +189,19 @@ public void onLoad() {
coverContainer.onLoad();
}

/**
* Use for data not able to be saved with the SyncData system, like optional mod compatiblity in internal machines.
* @param tag the CompoundTag to load data from
* @param forDrop if the save is done for dropping the machine as an item.
*/
public void saveCustomPersistedData(CompoundTag tag, boolean forDrop) {

}

public void loadCustomPersistedData(CompoundTag tag) {

}

//////////////////////////////////////
//***** Tickable Manager ****//
//////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class PartAbility {
public static final PartAbility TANK_VALVE = new PartAbility("tank_valve");
public static final PartAbility PASSTHROUGH_HATCH = new PartAbility("passthrough_hatch");
public static final PartAbility PARALLEL_HATCH = new PartAbility("parallel_hatch");
public static final PartAbility INPUT_LASER = new PartAbility("input_laser");
public static final PartAbility OUTPUT_LASER = new PartAbility("output_laser");

/**
* tier -> available blocks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank;
import com.gregtechceu.gtceu.api.recipe.GTRecipe;
import com.gregtechceu.gtceu.api.recipe.ingredient.FluidIngredient;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.lowdragmc.lowdraglib.side.fluid.FluidStack;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -35,7 +36,7 @@ public List<Long> handleRecipeInner(IO io, GTRecipe recipe, List<Long> left, @Nu
long sum = left.stream().reduce(0L, Long::sum);
long realSum = (long) Math.ceil(sum * conversionRate);
if (realSum > 0) {
var steam = FluidIngredient.of(CustomTags.STEAM, realSum);
var steam = io == IO.IN ? FluidIngredient.of(CustomTags.STEAM, realSum) : FluidIngredient.of(GTMaterials.Steam.getFluid(realSum));
var list = new ArrayList<FluidIngredient>();
list.add(steam);
var leftSteam = steamTank.handleRecipeInner(io, recipe, list, slotName, simulate);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.gregtechceu.gtceu.api.machine.trait.NotifiableFluidTank;
import com.gregtechceu.gtceu.api.machine.feature.ITieredMachine;
import com.gregtechceu.gtceu.common.data.GTMaterials;
import com.gregtechceu.gtceu.data.recipe.CustomTags;
import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted;
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
import lombok.Getter;
Expand All @@ -31,7 +32,7 @@ public SteamMachine(IMachineBlockEntity holder, boolean isHighPressure, Object..
super(holder);
this.isHighPressure = isHighPressure;
this.steamTank = createSteamTank(args);
this.steamTank.setFilter(fluid -> GTMaterials.Steam.getFluid() == fluid.getFluid());
this.steamTank.setFilter(fluidStack -> fluidStack.getFluid().is(CustomTags.STEAM));
}

//////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;

public class NotifiableEnergyContainer extends NotifiableRecipeHandlerTrait<Long> implements IEnergyContainer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ public ManagedFieldHolder getFieldHolder() {

@Override
public List<FluidIngredient> handleRecipeInner(IO io, GTRecipe recipe, List<FluidIngredient> left, @Nullable String slotName, boolean simulate) {
if (io != this.handlerIO) return left;
return handleIngredient(io, left, simulate, this.handlerIO, storages);
}

@Nullable
public static List<FluidIngredient> handleIngredient(IO io, List<FluidIngredient> left, boolean simulate, IO handlerIO, FluidStorage[] storages) {
if (io != handlerIO) return left;
var capabilities = simulate ? Arrays.stream(storages).map(FluidStorage::copy).toArray(FluidStorage[]::new) : storages;
for (FluidStorage capability : capabilities) {
Iterator<FluidIngredient> iterator = left.iterator();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.gregtechceu.gtceu.api.machine.trait;

import com.gregtechceu.gtceu.api.capability.GTCapabilityHelper;
import com.gregtechceu.gtceu.api.capability.ILaserContainer;
import com.gregtechceu.gtceu.api.machine.MetaMachine;
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
import net.minecraft.core.Direction;
import net.minecraft.world.level.block.entity.BlockEntity;

public class NotifiableLaserContainer extends NotifiableEnergyContainer implements ILaserContainer {

public static final ManagedFieldHolder MANAGED_FIELD_HOLDER = new ManagedFieldHolder(NotifiableEnergyContainer.class, NotifiableRecipeHandlerTrait.MANAGED_FIELD_HOLDER);

public NotifiableLaserContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage, long maxOutputVoltage, long maxOutputAmperage) {
super(machine, maxCapacity, maxInputVoltage, maxInputAmperage, maxOutputVoltage, maxOutputAmperage);
}

public static NotifiableLaserContainer emitterContainer(MetaMachine machine, long maxCapacity, long maxOutputVoltage, long maxOutputAmperage) {
return new NotifiableLaserContainer(machine, maxCapacity, 0L, 0L, maxOutputVoltage, maxOutputAmperage);
}

public static NotifiableLaserContainer receiverContainer(MetaMachine machine, long maxCapacity, long maxInputVoltage, long maxInputAmperage) {
return new NotifiableLaserContainer(machine, maxCapacity, maxInputVoltage, maxInputAmperage, 0L, 0L);
}

@Override
public void serverTick() {
amps = 0;
if (getMachine().getLevel().isClientSide)
return;
if (getEnergyStored() < getOutputVoltage() || getOutputVoltage() <= 0 || getOutputAmperage() <= 0)
return;
long outputVoltage = getOutputVoltage();
long outputAmperes = Math.min(getEnergyStored() / outputVoltage, getOutputAmperage());
if (outputAmperes == 0) return;
long amperesUsed = 0;
for (Direction side : Direction.values()) {
if (!outputsEnergy(side)) continue;
BlockEntity tileEntity = getMachine().getLevel().getBlockEntity(getMachine().getPos().relative(side));
Direction oppositeSide = side.getOpposite();
ILaserContainer laserContainer = GTCapabilityHelper.getLaser(getMachine().getLevel(), getMachine().getPos().relative(side), oppositeSide);
if (tileEntity != null && laserContainer != null) {
if (laserContainer == null || !laserContainer.inputsEnergy(oppositeSide)) continue;
amperesUsed += laserContainer.acceptEnergyFromNetwork(oppositeSide, outputVoltage, outputAmperes - amperesUsed);
if (amperesUsed == outputAmperes) break;
}
}
if (amperesUsed > 0) {
setEnergyStored(getEnergyStored() - amperesUsed * outputVoltage);
}
}
}
Loading

0 comments on commit ad45897

Please sign in to comment.