Skip to content

Commit

Permalink
Merge branch 'dev/1.20.1' into pr/420
Browse files Browse the repository at this point in the history
  • Loading branch information
Rover656 committed Aug 20, 2023
2 parents 2e5265a + 5ec6805 commit c2b3981
Show file tree
Hide file tree
Showing 464 changed files with 9,129 additions and 2,246 deletions.
22 changes: 18 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ void exclusiveRepo(RepositoryHandler handler, String url, Consumer<InclusiveRepo
}

repositories { RepositoryHandler handler ->
exclusiveRepo(handler, 'https://maven.tterrag.com/', 'com.tterrag.registrate')
exclusiveRepo(handler, 'https://maven.tterrag.com/', 'com.tterrag.registrate', 'com.jozufozu.flywheel')
exclusiveRepo(handler, 'https://modmaven.dev/', 'mezz.jei', 'mcjty.theoneprobe', 'appeng')
exclusiveRepo(handler, 'https://cursemaven.com', 'curse.maven')
exclusiveRepo(handler, 'https://maven.blamejared.com', 'vazkii.patchouli')
exclusiveRepo(handler, 'https://maven.blamejared.com', 'vazkii.patchouli', 'net.darkhax.bookshelf', 'net.darkhax.enchdesc')
exclusiveRepo(handler, 'https://dogforce-games.com/maven', 'dev.gigaherz.graph')
exclusiveRepo(handler, 'https://api.modrinth.com/maven', 'maven.modrinth')

Expand Down Expand Up @@ -245,6 +245,10 @@ dependencies {
compileOnly "appeng:appliedenergistics2-forge:${ae2_version}:api"
runtimeOnly fg.deobf("appeng:appliedenergistics2-forge:${ae2_version}")

// Enchantment descriptions
runtimeOnly fg.deobf("net.darkhax.bookshelf:Bookshelf-Forge-${minecraft_version}:${bookshelf_version}")
runtimeOnly fg.deobf("net.darkhax.enchdesc:EnchantmentDescriptions-Forge-${minecraft_version}:${ench_desc_version}")

// The One Probe https://github.com/McJtyMods/TheOneProbe/issues/548
// compileOnly fg.deobf("mcjty.theoneprobe:theoneprobe:${top_version}:api") {
// transitive = false
Expand All @@ -256,6 +260,9 @@ dependencies {
// Jade
runtimeOnly fg.deobf("curse.maven:jade-324717:${jade_cf_id}")

//Flywheel
compileOnly fg.deobf("com.jozufozu.flywheel:flywheel-forge-1.20.1:0.6.9-5") // REMOVE When crash is fixed

// Patchouli
// compileOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}:api")
// runtimeOnly fg.deobf("vazkii.patchouli:Patchouli:${patchouli_version}")
Expand Down Expand Up @@ -436,14 +443,21 @@ String getVersionString() {
}

def version_hash = ''
def branch_name = ''
if (!build_server) {
try {
version_hash = "git rev-parse --short HEAD".execute().text.trim()
version_hash = "-" + "git rev-parse --short HEAD".execute().text.trim()
} catch (ignored) {
}

try {
branch_name = "git rev-parse --abbrev-ref HEAD".execute().text.trim()
branch_name = "-" + branch_name.substring(branch_name.lastIndexOf('/') + 1)
} catch (ignored) {
}
}

return "${mod_version_series}-dev-${version_hash}"
return "${mod_version_series}-dev${branch_name}${version_hash}"
}

String getReleaseType() {
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ mod_version_series=6.0
# Version ranges for mods.toml
minecraft_version_range=[1.20.1]
loader_version_range=[47,)
forge_version_range=[47.1.0,47.1.3]
forge_version_range=[47.1.0,)

# Mappings
# ==== Possible options ====
Expand All @@ -36,6 +36,8 @@ top_version=1.20.0-10.0.0
patchouli_version=1.19.3-78
mekanism_cf_id=3922056
jade_cf_id=4614153
ench_desc_version=17.0.3
bookshelf_version=20.0.2

# ===========================
# Combined Project Properties
Expand Down
14 changes: 10 additions & 4 deletions src/api/java/com/enderio/api/conduit/IConduitType.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.enderio.api.UseOnly;
import com.enderio.api.conduit.ticker.IConduitTicker;
import com.enderio.api.misc.ColorControl;
import com.enderio.api.misc.RedstoneControl;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -49,9 +49,15 @@ default <K> Optional<LazyOptional<K>> proxyCapability(Capability<K> cap, T exten
return Optional.empty();
}

default ConduitConnectionData getDefaultConnection() {
return new ConduitConnectionData(false, true);
/**
* @param level the level
* @param pos conduit position
* @param direction direction the conduit connects to
* @return the connectiondata that should be set on connection based on context
*/
default ConduitConnectionData getDefaultConnection(Level level, BlockPos pos, Direction direction) {
return new ConduitConnectionData(false, true, RedstoneControl.NEVER_ACTIVE);
}

record ConduitConnectionData(boolean isInsert, boolean isExtract) {}
record ConduitConnectionData(boolean isInsert, boolean isExtract, RedstoneControl control) {}
}
8 changes: 8 additions & 0 deletions src/api/java/com/enderio/api/integration/Integration.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,12 @@ default void onModConstruct() {
default Optional<BlockState> getFacadeOf(ItemStack stack) {
return Optional.empty();
}

/**
* @param player The Player that wants to teleport
* @return whether the player can teleport to a nearby block
*/
default boolean canBlockTeleport(Player player) {
return false;
}
}
14 changes: 9 additions & 5 deletions src/api/java/com/enderio/api/integration/IntegrationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
import java.util.function.*;

public class IntegrationManager {

Expand Down Expand Up @@ -50,7 +47,7 @@ public static void executeIf(Predicate<Integration> condition, Consumer<Integrat
consumer.accept(integration);
}
}

public static <T> List<T> getIf(Predicate<Integration> condition, Function<Integration, T> mapper) {
List<T> list = new ArrayList<>();
for (Integration integration : ALL_INTEGRATIONS) {
Expand All @@ -59,4 +56,11 @@ public static <T> List<T> getIf(Predicate<Integration> condition, Function<Integ
}
return list;
}

public static <T> T collectAll(T empty, Function<Integration, T> function, BiConsumer<T, T> merge) {
for (Integration integration : ALL_INTEGRATIONS) {
merge.accept(empty, function.apply(integration));
}
return empty;
}
}
21 changes: 21 additions & 0 deletions src/api/java/com/enderio/api/travel/ITravelTarget.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.enderio.api.travel;

import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;

public interface ITravelTarget {
ResourceLocation getSerializationName();

BlockPos getPos();

CompoundTag save();

int getItem2BlockRange();

int getBlock2BlockRange();

default boolean canTravelTo() {
return true;
}
}
11 changes: 11 additions & 0 deletions src/api/java/com/enderio/api/travel/TravelEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.enderio.api.travel;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.util.Lazy;

import java.util.function.Function;
import java.util.function.Supplier;

public record TravelEntry<T extends ITravelTarget>(ResourceLocation serializationName, Function<CompoundTag, T> constructor,
Supplier<Lazy<TravelRenderer<T>>> renderer) {}
46 changes: 46 additions & 0 deletions src/api/java/com/enderio/api/travel/TravelRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package com.enderio.api.travel;

import net.minecraft.nbt.CompoundTag;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.common.util.Lazy;
import org.jetbrains.annotations.ApiStatus;

import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;

@ApiStatus.Internal
public class TravelRegistry {

private static final Map<ResourceLocation, TravelEntry<?>> registry = new HashMap<>();

public static <T extends ITravelTarget> void addTravelEntry(ResourceLocation serializationName, Function<CompoundTag, T> constructor,
Supplier<Lazy<TravelRenderer<T>>> renderer) {
registry.put(serializationName, new TravelEntry<>(serializationName, constructor, renderer));
}

public static <T extends ITravelTarget> void addTravelEntry(TravelEntry<?> travelEntry) {
registry.put(travelEntry.serializationName(), travelEntry);
}

public static <T extends ITravelTarget> TravelRenderer<T> getRenderer(T entry) {
return (TravelRenderer<T>) registry.get(entry.getSerializationName()).renderer().get().get();
}

public static Optional<ITravelTarget> deserialize(CompoundTag nbt) {
return Optional.ofNullable(registry.get(new ResourceLocation(nbt.getString("name")))).map(entry -> entry.constructor().apply(nbt.getCompound("data")));
}

public static boolean isRegistered(ITravelTarget target) {
return registry.containsKey(target.getSerializationName());
}

public static CompoundTag serialize(ITravelTarget travelData) {
CompoundTag nbt = new CompoundTag();
nbt.putString("name", travelData.getSerializationName().toString());
nbt.put("data", travelData.save());
return nbt;
}
}
8 changes: 8 additions & 0 deletions src/api/java/com/enderio/api/travel/TravelRenderer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.enderio.api.travel;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.LevelRenderer;

public interface TravelRenderer<T extends ITravelTarget> {
void render(T travelData, LevelRenderer levelRenderer, PoseStack poseStack, double distanceSquared, boolean active);
}
5 changes: 5 additions & 0 deletions src/api/java/com/enderio/api/travel/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@javax.annotation.ParametersAreNonnullByDefault
@net.minecraft.MethodsReturnNonnullByDefault
@com.tterrag.registrate.util.nullness.FieldsAreNonnullByDefault

package com.enderio.api.travel;
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ private void updateConnectionWidgets(boolean forceUpdate) {
new EnumIconWidget<>(this, pos.x(), pos.y() + 20,
() -> getOnDynamic(dyn -> dyn.insert(), ColorControl.GREEN),
color -> actOnDynamic(dyn -> dyn.withColor(false, color)),
EIOLang.CHANNEL));
EIOLang.CONDUIT_CHANNEL));
}
if (data.showColorExtract()) {
addTypedButton(
new EnumIconWidget<>(this, pos.x() + 90, pos.y() + 20,
() -> getOnDynamic(dyn -> dyn.extract(), ColorControl.GREEN),
color -> actOnDynamic(dyn -> dyn.withColor(true, color)),
EIOLang.CHANNEL));
EIOLang.CONDUIT_CHANNEL));
}
if (data.showRedstoneExtract()) {
addTypedButton(
Expand All @@ -122,7 +122,7 @@ private void updateConnectionWidgets(boolean forceUpdate) {
new EnumIconWidget<>(this, pos.x() + 90 + 20, pos.y() + 40,
() -> getOnDynamic(dyn -> dyn.redstoneChannel(), ColorControl.GREEN),
color -> actOnDynamic(dyn -> dyn.withRedstoneChannel(color)),
EIOLang.CHANNEL));
EIOLang.REDSTONE_CHANNEL));
}
menu.getConduitType()
.getClientData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.MenuProvider;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.player.Inventory;
Expand Down Expand Up @@ -116,10 +115,9 @@ public void onLoad() {
updateShape();
if (level instanceof ServerLevel serverLevel) {
sync();
bundle.onLoad(level, getBlockPos());
for (var entry: lazyNodes.entrySet()) {
NodeIdentifier<?> node = entry.getValue();
IExtendedConduitData<?> data = node.getExtendedConduitData();
data.onCreated(entry.getKey(), level, worldPosition, null);
for (Direction dir : Direction.values()) {
tryConnectTo(dir, entry.getKey(), false, false).ifPresent(otherNode -> Graph.connect(node, otherNode));
}
Expand All @@ -130,7 +128,6 @@ public void onLoad() {
}
ConduitSavedData.addPotentialGraph(entry.getKey(), Objects.requireNonNull(node.getGraph()), serverLevel);
}
bundle.onLoad(level, getBlockPos());
}
}

Expand Down Expand Up @@ -427,12 +424,12 @@ private boolean doTypesMatch(IConduitType<?> type) {
}

private void connect(Direction direction, IConduitType<?> type) {
bundle.connectTo(direction, type, false);
bundle.connectTo(level, worldPosition, direction, type, false);
updateClient();
}

private void connectEnd(Direction direction, IConduitType<?> type) {
bundle.connectTo(direction, type, true);
bundle.connectTo(level, worldPosition, direction, type, true);
updateClient();
}

Expand Down
Loading

0 comments on commit c2b3981

Please sign in to comment.