Skip to content

Commit

Permalink
Sc/cherrypick to 1.19 (#542)
Browse files Browse the repository at this point in the history
* Fixes (#520)

* fix: return correct capability for lasers

* feat: insert covers directly into inventory on crowbar use, if possible

* fix: capability IO directions

* feat: render locked contents for quantum storage when empty (#524)

* Fix item pipe transfer rate (#530)

* refactor: extract transfer rate counting from fluid pipe nets

* fix: item pipes now limit their transfer correctly

* Fix steam boilers (#532)

* fix: small steam boilers output steam again

* refactor: rename method in SteamBoilerMachine

* fix: display correct temperature in large boilers

* feat: add temperature tooltip in small boilers

* Manual IO modes on covers (#536)

* style: reformat some code in MetaMachine

* refactor: allow covers to override item and fluid transfer capabilities

* feat: UI controls for distribution & manual IO mode

* feat: handle manual IO mode when transferring through covers

* refactor: make previously added @ExpectPlatform method static

* refactor: improve tooltip for insert_first distribution mode

* Inject models into resource manager (#529)

* fix: define outgoing API elements.

* fuck this is annoying, @KilaBash fix the rendering system pls

* feat: the thing. currently throws a shitton of errors. fun.

* ok why does 1/15 items have a model wtf

* would you rather have no errors and 5x memory usage or errors, infinite errors and 5x memory usage

* remove unused stuff.

* fix: remove texture generation, used too much ram; where'd my block textures go?

* fix: add mixinextras version to deps.

* IT FUCKING WORKS :LLEETTSS:

* make ore blocks be able to accept 2 textures, signified by:
1. no suffix in the filename
2. `_layer2` in the filename

* fix ore blocks' tint layers

* feat: megacommit A la textures

* feat: all the secondary colors. until @TTFTCUTS makes/gives me the block textures, I can't do the block models.

* fix laser pipes

* add possibility for secondary textures in cables/pipes/wires

* fix: lang issues

* feat: recipes for active transformer, high power casing, laser cable

* fix: add blank texture to not have errors because of missing secondary sprites.

* chore: reviews

* fixes (#539)

* feat: allow singleblock generators to face up

* fix: allow tools to use their last durability point

* fix: disable worldstripper in dev

* fix: wrong operator on large boiler tooltip

* chore: run data

* fix: special check for diode in Cleanroom energy hatch collection

* chore: update changelog

---------

Co-authored-by: Mikerooni <[email protected]>
  • Loading branch information
screret and mikerooni authored Nov 12, 2023
1 parent b3784c9 commit e38db32
Show file tree
Hide file tree
Showing 498 changed files with 3,438 additions and 1,681 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,19 @@
Version: 1.0.15

* Bump ldlib version for better compass
* add initial compass content
* inject models for items and blocks
* add manual IO mode on covers
* add temperature tooltip for small steam boilers
* return covers to inventory on crowbar use, instead of dropping them
* allow singleblock generators to face up
* allow tools to use their last durability point
* fix lag with pattern checking
* fix the Machine mode selector
* fix several missing recipes
* fix small steam boilers not producing steam
* fix wrong temperatures in the UI
* fix item pipes stopping transfer after their transfer rate per second has been reached once
* fix capability IO directions
* fix laser pipes not connecting to hatches
* fix diodes being counted as energy input in cleanrooms
12 changes: 12 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ configurations {
// snapshotModImplementation {
// resolutionStrategy.cacheChangingModulesFor(0, "seconds")
// }
apiElements {
outgoing {
capability("net.fabricmc.fabric-api:fabric-api-${this.libs.versions.minecraft.get()}:${this.fabric.versions.fabricApi.get()}")
capability("com.lowdragmc.ldlib:ldlib-common-${this.libs.versions.minecraft.get()}:${this.fabric.versions.ldlib.get()}")
capability("com.tterrag.registrate_fabric:Registrate:${this.fabric.versions.registrate.get()}")
capability("dev.toma.configuration:configuration-fabric-${this.libs.versions.minecraft.get()}:${this.fabric.versions.configuration.get()}")
capability("io.github.llamalad7:mixinextras-common:${this.fabric.versions.mixinextras.get()}")
}
}
}

//configurations.all {
Expand Down Expand Up @@ -81,6 +90,9 @@ dependencies {
// KJS
modCompileOnly fabric.kubejs

// Mixin Extras
implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:${fabric.versions.mixinextras.get()}"))

// Configuration
modCompileOnly fabric.configuration
}
Expand Down
10 changes: 10 additions & 0 deletions common/src/main/java/com/gregtechceu/gtceu/api/GTValues.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ public class GTValues {
*/
public static final long[] V = new long[]{8, 32, 128, 512, 2048, 8192, 32768, 131072, 524288, 2097152, 8388608, 33554432, 134217728, 536870912, Integer.MAX_VALUE};

/**
* The Voltage Tiers divided by 2.
*/
public static final int[] VH = {4, 16, 64, 256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 16777216, 67108864, 268435456, 1073741824};


/**
* The Voltage Tiers adjusted for cable loss. Use this for recipe EU/t to avoid full-amp recipes
*/
public static final int[] VA = new int[]{7, 30, 120, 480, 1920, 7680, 30720, 122880, 491520, 1966080, 7864320, 31457280, 125829120, 503316480, 2013265920};

/**
* The Voltage Tiers adjusted for cable loss, divided by 2.
*/
public static final int[] VHA = {7, 16, 60, 240, 960, 3840, 15360, 61440, 245760, 983040, 3932160, 15728640, 62914560, 251658240, 1006632960};

public static final int ULV = 0;
public static final int LV = 1;
public static final int MV = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,38 +34,33 @@
*/
@MethodsReturnNonnullByDefault
@ParametersAreNonnullByDefault
public class MaterialBlock extends AppearanceBlock implements IBlockRendererProvider {
public class MaterialBlock extends AppearanceBlock {

public final TagPrefix tagPrefix;
public final Material material;
public final IRenderer renderer;

public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material) {
super(properties);
this.material = material;
this.tagPrefix = tagPrefix;
this.renderer = Platform.isClient() ? MaterialBlockRenderer.getOrCreate(tagPrefix.materialIconType(), material.getMaterialIconSet()) : null;
}

public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material, IRenderer renderer) {
public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material, boolean registerModel) {
super(properties);
this.material = material;
this.tagPrefix = tagPrefix;
this.renderer = renderer;
if (registerModel && Platform.isClient()) {
MaterialBlockRenderer.create(this, tagPrefix.materialIconType(), material.getMaterialIconSet());
}
}

@Nullable
@Override
@Environment(EnvType.CLIENT)
public IRenderer getRenderer(BlockState state) {
return renderer;
public MaterialBlock(Properties properties, TagPrefix tagPrefix, Material material) {
this(properties, tagPrefix, material, true);
}

@Environment(EnvType.CLIENT)
public static BlockColor tintedColor() {
return (state, reader, pos, tintIndex) -> {
if (state.getBlock() instanceof MaterialBlock block) {
return block.material.getMaterialRGB();
if (tintIndex == 1 && block.material.getMaterialSecondaryRGB() != -1) {
return block.material.getMaterialSecondaryRGB();
} else {
return block.material.getMaterialRGB();
}
}
return -1;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ public List<ItemStack> getDrops(BlockState pState, LootContext.Builder pBuilder)
if (tileEntity instanceof IMachineBlockEntity holder) {
var machine = holder.getMetaMachine();
for (Direction direction : Direction.values()) {
machine.getCoverContainer().removeCover(direction);
machine.getCoverContainer().removeCover(direction, null);
}
if (machine instanceof IMachineModifyDrops machineModifyDrops && entity instanceof Player) {
machineModifyDrops.onDrops(drops, (Player) entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
import net.minecraft.world.level.storage.loot.LootContext;
import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
import net.minecraft.world.phys.shapes.*;
import org.apache.commons.lang3.ArrayUtils;
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.EntityCollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import org.jetbrains.annotations.Nullable;

import javax.annotation.ParametersAreNonnullByDefault;
Expand Down Expand Up @@ -238,7 +240,7 @@ public List<ItemStack> getDrops(BlockState state, LootContext.Builder builder) {
BlockEntity tileEntity = context.getParamOrNull(LootContextParams.BLOCK_ENTITY);
if (tileEntity instanceof IPipeNode<?,?> pipeTile) {
for (Direction direction : Direction.values()) {
pipeTile.getCoverContainer().removeCover(direction);
pipeTile.getCoverContainer().removeCover(direction, null);
}
}
return super.getDrops(state, builder);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.gregtechceu.gtceu.api.block;

import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.data.tag.TagPrefix;
import com.lowdragmc.lowdraglib.client.renderer.IBlockRendererProvider;
import com.lowdragmc.lowdraglib.client.renderer.IRenderer;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.world.level.block.state.BlockState;
import org.jetbrains.annotations.Nullable;

public class RendererMaterialBlock extends MaterialBlock implements IBlockRendererProvider {
public final IRenderer renderer;

public RendererMaterialBlock(Properties properties, TagPrefix tagPrefix, Material material, @Nullable IRenderer renderer) {
super(properties, tagPrefix, material, false);
this.renderer = renderer;
}

@Nullable
@Override
@Environment(EnvType.CLIENT)
public IRenderer getRenderer(BlockState state) {
return renderer;
}
}
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package com.gregtechceu.gtceu.api.blockentity;

import com.gregtechceu.gtceu.api.GTValues;
import com.gregtechceu.gtceu.api.block.BlockProperties;
import com.gregtechceu.gtceu.api.block.MaterialPipeBlock;
import com.gregtechceu.gtceu.api.capability.ICoverable;
import com.gregtechceu.gtceu.api.capability.IToolable;
import com.gregtechceu.gtceu.api.cover.CoverBehavior;
import com.gregtechceu.gtceu.api.data.chemical.material.Material;
import com.gregtechceu.gtceu.api.gui.GuiTextures;
import com.gregtechceu.gtceu.api.pipenet.IPipeNode;
import com.gregtechceu.gtceu.api.pipenet.PipeCoverContainer;
import com.gregtechceu.gtceu.api.block.BlockProperties;
import com.gregtechceu.gtceu.api.capability.ICoverable;
import com.gregtechceu.gtceu.api.capability.IToolable;
import com.gregtechceu.gtceu.api.item.tool.GTToolType;
import com.gregtechceu.gtceu.api.item.tool.IToolGridHighLight;
import com.gregtechceu.gtceu.api.machine.TickableSubscription;
import com.gregtechceu.gtceu.api.pipenet.IAttachData;
import com.gregtechceu.gtceu.api.pipenet.IPipeNode;
import com.gregtechceu.gtceu.api.pipenet.IPipeType;
import com.gregtechceu.gtceu.api.pipenet.PipeCoverContainer;
import com.gregtechceu.gtceu.api.registry.GTRegistries;
import com.gregtechceu.gtceu.api.syncdata.EnhancedFieldManagedStorage;
import com.gregtechceu.gtceu.api.syncdata.IEnhancedManaged;
Expand Down Expand Up @@ -286,7 +286,7 @@ public InteractionResult onToolClick(@NotNull GTToolType toolType, ItemStack ite
} else if (toolType == GTToolType.CROWBAR) {
if (coverBehavior != null) {
if (!isRemote()) {
getCoverContainer().removeCover(gridSide);
getCoverContainer().removeCover(gridSide, playerIn);
}
return InteractionResult.CONSUME;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import com.lowdragmc.lowdraglib.LDLib;
import com.lowdragmc.lowdraglib.gui.texture.IGuiTexture;
import com.lowdragmc.lowdraglib.gui.widget.Widget;
import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer;
import com.lowdragmc.lowdraglib.side.item.IItemTransfer;
import com.lowdragmc.lowdraglib.utils.RayTraceHelper;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
Expand Down Expand Up @@ -61,10 +63,14 @@ public interface ICoverable extends ITickSubscription, IAppearance, IFancyConfig

boolean shouldRenderBackSide();

// TODO replace getItemTransferCap and getFluidTransferCap with a cross-platform capability implementation
IItemTransfer getItemTransferCap(@Nullable Direction side, boolean useCoverCapability);
IFluidTransfer getFluidTransferCap(@Nullable Direction side, boolean useCoverCapability);

/**
* Its an internal method, you should never call it yourself.
* <br>
* Use {@link ICoverable#removeCover(boolean, Direction)} and {@link ICoverable#placeCoverOnSide(Direction, ItemStack, CoverDefinition, ServerPlayer)} instead
* Use {@link ICoverable#removeCover(boolean, Direction, Player)} and {@link ICoverable#placeCoverOnSide(Direction, ItemStack, CoverDefinition, ServerPlayer)} instead
* @param coverBehavior
* @param side
*/
Expand All @@ -79,7 +85,7 @@ default boolean placeCoverOnSide(Direction side, ItemStack itemStack, CoverDefin
return false;
}
if (getCoverAtSide(side) != null) {
removeCover(side);
removeCover(side, player);
}
coverBehavior.onAttached(itemStack, player);
coverBehavior.onLoad();
Expand All @@ -92,7 +98,7 @@ default boolean placeCoverOnSide(Direction side, ItemStack itemStack, CoverDefin
return true;
}

default boolean removeCover(boolean dropItself, Direction side) {
default boolean removeCover(boolean dropItself, Direction side, @Nullable Player player) {
CoverBehavior coverBehavior = getCoverAtSide(side);
if (coverBehavior == null) {
return false;
Expand All @@ -104,16 +110,20 @@ default boolean removeCover(boolean dropItself, Direction side) {
coverBehavior.onRemoved();
setCoverAtSide(null, side);
for (ItemStack dropStack : drops) {
if (player != null && player.getInventory().add(dropStack))
continue;

Block.popResource(getLevel(), getPos(), dropStack);

}
notifyBlockUpdate();
markDirty();
scheduleNeighborShapeUpdate();
return true;
}

default boolean removeCover(Direction side) {
return removeCover(true, side);
default boolean removeCover(Direction side, @Nullable Player player) {
return removeCover(true, side, player);
}

default List<CoverBehavior> getCovers() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import com.gregtechceu.gtceu.api.syncdata.IEnhancedManaged;
import com.gregtechceu.gtceu.client.renderer.cover.ICoverRenderer;
import com.lowdragmc.lowdraglib.gui.texture.ResourceTexture;
import com.lowdragmc.lowdraglib.side.fluid.IFluidTransfer;
import com.lowdragmc.lowdraglib.side.item.IItemTransfer;
import com.lowdragmc.lowdraglib.syncdata.annotation.DescSynced;
import com.lowdragmc.lowdraglib.syncdata.annotation.Persisted;
import com.lowdragmc.lowdraglib.syncdata.field.ManagedFieldHolder;
Expand Down Expand Up @@ -199,4 +201,17 @@ public BlockState getAppearance(BlockState sourceState, BlockPos sourcePos) {
return null;
}

//////////////////////////////////////
//******* Capabilities *******//
//////////////////////////////////////

// TODO possibly refactor this in the future, using some sort of cross-platform capability-like system

public IItemTransfer getItemTransferCap(Direction side, IItemTransfer defaultValue) {
return defaultValue;
}

public IFluidTransfer getFluidTransferCap(Direction side, IFluidTransfer defaultValue) {
return defaultValue;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public F getFilter() {
return this.filter;
}

public boolean test(T resource) {
return getFilter().test(resource);
}

public FilterHandler<T, F> onFilterLoaded(Consumer<F> onFilterLoaded) {
this.onFilterLoaded = onFilterLoaded;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,18 @@ public int getMaterialARGB() {
return materialInfo.color | 0xff000000;
}

public int getMaterialSecondaryARGB() {
return materialInfo.secondaryColor | 0xff000000;
}

public int getMaterialRGB() {
return materialInfo.color;
}

public int getMaterialSecondaryRGB() {
return materialInfo.secondaryColor;
}

public boolean hasFluidColor() {
return materialInfo.hasFluidColor;
}
Expand Down Expand Up @@ -755,6 +763,18 @@ public Builder color(int color, boolean hasFluidColor) {
return this;
}

/**
* Set the secondary color of this Material.<br>
* Defaults to 0xFFFFFF unless {@link Builder#colorAverage()} was called, where
* it will be a weighted average of the components of the Material.
*
* @param color The RGB-formatted Color.
*/
public Builder secondaryColor(int color) {
this.materialInfo.secondaryColor = color;
return this;
}

public Builder colorAverage() {
this.averageRGB = true;
return this;
Expand Down Expand Up @@ -1036,6 +1056,14 @@ private static class MaterialInfo {
*/
private int color = -1;

/**
* The secondary color of this Material.
* If this is default, then it's not used.
* <p>
* Default: 0xFFFFFF if no Components, otherwise it will be the average of Components.
*/
private int secondaryColor = -1;

/**
* The color of this Material.
* <p>
Expand Down
Loading

0 comments on commit e38db32

Please sign in to comment.