Skip to content

Commit

Permalink
Merge pull request #174 from refinedmods/develop
Browse files Browse the repository at this point in the history
v2.0.0-milestone.1.4
  • Loading branch information
raoulvdberge authored Jun 22, 2022
2 parents 83eddfd + 8bb7520 commit ddc2498
Show file tree
Hide file tree
Showing 493 changed files with 11,762 additions and 6,023 deletions.
30 changes: 15 additions & 15 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ This project uses [Gitflow](https://www.atlassian.com/git/tutorials/comparing-wo

## Way of working when adding functionality

If you are adding functionality or are changing behavior, please update the wiki and Patchouli in-game documentation.
If you are adding functionality or are changing behavior, please update the documentation.

If there are differences with the Refined Storage 1 implementation, document this in the changelog as well.

Expand Down Expand Up @@ -78,17 +78,17 @@ Refined Storage 2 is modularized. That means that API is split up into various m
Important to note is that most modules aren't dependent on Minecraft or a mod loader. Only modules that start
with `refinedstorage2-platform-*` have dependencies on Minecraft.

| Name | Description |
|-----------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| `refinedstorage2-core-api` | Contains some utility classes and enums. |
| `refinedstorage2-grid-api` | Contains Grid related functionality. |
| `refinedstorage2-network-api` | Contains storage networking related functionality. |
| `refinedstorage2-query-parser` | A query parser. Contains a lexer and parser. Only used for Grid query parsing. |
| `refinedstorage2-resource-api` | Contains API for handling resources and resource lists. |
| `refinedstorage2-storage-api` | Contains storage related functionality. |
| `refinedstorage2-test` | This module is used in tests to provide the `@Rs2Test` annotation. |
| `refinedstorage2-platform-fabric` | The platform module for Fabric. This module contains Fabric specific code. Don't depend on this when integrating! |
| `refinedstorage2-platform-forge` | The platform module for Forge. This module contains Forge specific code. Don't depend on this when integrating! |
| `refinedstorage2-platform-api` | The API package. Use this to integrate with Refined Storage. |
| `refinedstorage2-platform-common` | Common mod code. Most gameplay code is in here. Don't depend on this when integrating! |
| `refinedstorage2-platform-abstractions` | Platform abstractions used for Fabric and Forge. Don't depend on this when integrating! |
| Name | Use in addons | Description |
|-----------------------------------|--------------|--------------------------------------------------------------------------------|
| `refinedstorage2-core-api` | ✔️ | Contains some utility classes and enums. |
| `refinedstorage2-grid-api` | ✔️ | Contains Grid related functionality. |
| `refinedstorage2-network-api` | ✔️ | Contains storage network related functionality. |
| `refinedstorage2-query-parser` | ✔️ | A query parser, contains a lexer and parser. Only used for Grid query parsing. |
| `refinedstorage2-resource-api` | ✔️ | Contains API for handling resources. |
| `refinedstorage2-storage-api` | ✔️ | Contains storage related functionality. |
| `refinedstorage2-test` | ✔️ | This module is used in tests to provide the `@Rs2Test` annotation. |
| `refinedstorage2-platform-api` | ✔️ | Implements the various Refined Storage API modules for use in Minecraft. |
| `refinedstorage2-platform-fabric` | | The platform module for Fabric. This module contains Fabric specific code. |
| `refinedstorage2-platform-forge` | | The platform module for Forge. This module contains Forge specific code. |
| `refinedstorage2-platform-common` | | Common mod code. Most gameplay code is in here. |
| `refinedstorage2-platform-test` | | This module is used in platform tests for various Minecraft related helpers. |
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ body:
description: |
If your Minecraft version isn't listed here, it means that it's no longer supported. In that case, don't create an issue.
options:
- Minecraft 1.18.1
- Minecraft 1.18.2
validations:
required: true
- type: input
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ jobs:
run: ./gradlew publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CREEPERHOST_MAVEN_USERNAME: ${{ secrets.CREEPERHOST_MAVEN_USERNAME }}
CREEPERHOST_MAVEN_TOKEN: ${{ secrets.CREEPERHOST_MAVEN_TOKEN }}
RELEASE: ${{ steps.tagName.outputs.tag }}
- name: Retrieve changelog
id: changelog_reader
Expand Down
36 changes: 36 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,42 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

All device inventories (most notably the Disk Drive inventory) will be empty after upgrading. Make sure to move all
disks, etc. to intermediate storage like a chest.

### Added

- The Wrench now dismantles devices when crouching.
- The Disk Drive in item form now supports rendering of disks that were dismantled.
- In order to retain Controller energy, the Controller must now be dismantled.
- You can now use any Wrench from other mods in order to rotate or dismantle.
- Item and fluid storage blocks.
- Initial advancements.

### Fixed

- Fixed inventory contents of devices not retaining their original order when reloading a world.
- Fixed bug where (already opened) Grid doesn't update if a storage is removed.
- Fixed last modified info in the Grid not being persisted.
- Fixed removals in filter inventory not being saved properly.

### Changed

- Ported to Minecraft 1.18.2.
- Grid auto-selection and JEI/REI synchronization are now two different options.
- Grid display settings are now stored in the client configuration, no longer per-block.
- You now need to crouch with a dye in order to change the color of a device.
- Item storage capacities are now multiples of 1024 to make it more stack-size friendly.
- Storage tooltips now have colors.
- Storage tooltips now show percentage full.
- Item storage tooltips now show amount of stacks and max stacks stored.

### Removed

- Removed the Patchouli integration.

## [2.0.0-milestone.1.3] - 2022-02-12

### Added

- Forge support.
Expand Down
13 changes: 10 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ allprojects {

subprojects {
group = 'com.refinedmods.refinedstorage2'
version = '2.0.0-milestone.1.3'
version = '2.0.0-milestone.1.4'

if (System.getenv('GITHUB_SHA') != null) {
version += '+' + System.getenv('GITHUB_SHA').substring(0, 7)
Expand All @@ -29,7 +29,6 @@ subprojects {
]

project.ext.compileApis = [
':refinedstorage2-platform-abstractions',
':refinedstorage2-platform-api',
':refinedstorage2-platform-common',
]
Expand Down Expand Up @@ -63,6 +62,14 @@ subprojects {
password = System.getenv("GITHUB_TOKEN")
}
}
maven {
name = "CreeperHost"
url = uri("https://maven.creeperhost.net/release")
credentials {
username = System.getenv("CREEPERHOST_MAVEN_USERNAME")
password = System.getenv("CREEPERHOST_MAVEN_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
Expand Down Expand Up @@ -106,6 +113,6 @@ sonarqube {
property "sonar.organization", "refinedmods"
property "sonar.host.url", "https://sonarcloud.io"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/codeCoverageReport/codeCoverageReport.xml"
property "sonar.coverage.exclusions", "refinedstorage2-platform-*/**/*"
property "sonar.coverage.exclusions", "refinedstorage2-platform-forge/**/*,refinedstorage2-platform-fabric/**/*,refinedstorage2-platform-common/**/*,refinedstorage2-platform-api/**/*"
}
}
34 changes: 16 additions & 18 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ org.gradle.jvmargs=-Xmx1G
junitVersion=5.8.2
# Use the same Log4j API as MC to not break logging in the development environment.
log4jVersion=2.14.1
equalsverifierVersion=3.8.1
assertJVersion=3.21.0
mockitoVersion=4.2.0
equalsverifierVersion=3.10
assertJVersion=3.22.0
mockitoVersion=4.6.0
# Libraries
guavaVersion=31.0.1-jre
guavaVersion=31.1-jre
apiGuardianVersion=1.1.2
# MC
minecraftVersion=1.18.1
parchmentVersion=2021.12.19
fabricLoaderVersion=0.12.12
fabricApiVersion=0.45.0+1.18
forgeVersion=39.0.9
minecraftVersion=1.18.2
parchmentVersion=2022.05.22
fabricLoaderVersion=0.14.6
fabricApiVersion=0.53.4+1.18.2
forgeVersion=40.1.48
# Mod dependencies
# https://www.curseforge.com/minecraft/mc-mods/auto-config-updated-api/files
autoconfig1uVersion=3.3.1
autoconfig1uVersion=3.4.0
# https://www.curseforge.com/minecraft/mc-mods/cloth-config/files
clothConfigVersion=6.1.48
clothConfigVersion=6.2.62
# https://github.com/TechReborn/Energy
energyVersion=2.1.0
# https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items/files/
reiVersion=7.1.356
# https://www.curseforge.com/minecraft/mc-mods/roughly-enough-items/files
reiVersion=8.2.470
# https://www.curseforge.com/minecraft/mc-mods/modmenu/files
modMenuVersion=3.0.1
# https://www.curseforge.com/minecraft/mc-mods/patchouli-fabric/files
patchouliVersion=1.18.1-61-FABRIC
modMenuVersion=3.2.2
# https://www.curseforge.com/minecraft/mc-mods/wthit/files
wthitVersion=4.4.0
wthitVersion=4.10.3
# https://www.curseforge.com/minecraft/mc-mods/jei/files
jeiVersion=9.2.3.84
jeiVersion=9.7.0.195
1 change: 1 addition & 0 deletions refinedstorage2-core-api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ archivesBaseName = 'refinedstorage2-core-api'
dependencies {
testImplementation project(':refinedstorage2-test')
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${project.junitVersion}"
testImplementation "org.junit.jupiter:junit-jupiter-params:${project.junitVersion}"
testImplementation "org.assertj:assertj-core:${project.assertJVersion}"
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.refinedmods.refinedstorage2.api.core.component;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.4")
public interface ComponentAccessor<C> {
<I extends C> I getComponent(Class<I> componentType);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.refinedmods.refinedstorage2.api.core.component;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.4")
public class ComponentMap<C> implements ComponentAccessor<C> {
private final Map<Class<? extends C>, C> map;

public ComponentMap(LinkedHashMap<Class<? extends C>, C> map) {
this.map = Collections.unmodifiableMap(map);
}

public Collection<C> getComponents() {
return map.values();
}

@Override
public <I extends C> I getComponent(Class<I> componentType) {
return (I) map.get(componentType);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.refinedmods.refinedstorage2.api.core.component;

import java.util.LinkedHashMap;
import java.util.function.Function;

import org.apiguardian.api.API;

@API(status = API.Status.STABLE, since = "2.0.0-milestone.1.4")
public class ComponentMapFactory<C, X> {
private final LinkedHashMap<Class<? extends C>, Function<X, C>> factories;

public ComponentMapFactory() {
this(new LinkedHashMap<>());
}

private ComponentMapFactory(LinkedHashMap<Class<? extends C>, Function<X, C>> factories) {
this.factories = factories;
}

public void addFactory(Class<? extends C> componentType, Function<X, C> factory) {
factories.put(componentType, factory);
}

public ComponentMapFactory<C, X> copy() {
return new ComponentMapFactory<>(new LinkedHashMap<>(factories));
}

public ComponentMap<C> buildComponentMap(X context) {
LinkedHashMap<Class<? extends C>, C> components = new LinkedHashMap<>();
factories.forEach((componentType, factory) -> components.put(componentType, factory.apply(context)));
return new ComponentMap<>(components);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.refinedmods.refinedstorage2.api.core;
package com.refinedmods.refinedstorage2.api.core.util;

// TODO: Add test
public record LastModified(Type type, long amount) {
private static final long SECOND = 1000;
private static final long MINUTE = SECOND * 60;
Expand All @@ -10,7 +9,6 @@ public record LastModified(Type type, long amount) {
private static final long YEAR = DAY * 365;

public enum Type {
JUST_NOW,
SECOND,
MINUTE,
HOUR,
Expand All @@ -22,9 +20,7 @@ public enum Type {
public static LastModified calculate(long time, long now) {
long diff = now - time;

if (diff < SECOND * 10) {
return new LastModified(Type.JUST_NOW, diff / SECOND);
} else if (diff < MINUTE) {
if (diff < MINUTE) {
return new LastModified(Type.SECOND, diff / SECOND);
} else if (diff < HOUR) {
return new LastModified(Type.MINUTE, diff / MINUTE);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.refinedmods.refinedstorage2.api.core.component;

import com.refinedmods.refinedstorage2.test.Rs2Test;

import org.junit.jupiter.api.Test;

import static org.assertj.core.api.Assertions.assertThat;

@Rs2Test
class ComponentMapFactoryTest {
@Test
void Test_should_register_factory_and_build_map_correctly() {
// Arrange
ComponentMapFactory<TestComponent, String> sut = new ComponentMapFactory<>();

sut.addFactory(TestComponent1.class, TestComponent1::new);
sut.addFactory(TestComponent3.class, TestComponent3::new);

// Act
ComponentMap<TestComponent> map = sut.buildComponentMap("TEST");

// Assert
assertThat(map.getComponent(TestComponent1.class).getGivenContext()).isEqualTo("C1 TEST");
assertThat(map.getComponent(TestComponent2.class)).isNull();
assertThat(map.getComponent(TestComponent3.class).getGivenContext()).isEqualTo("C3 TEST");
assertThat(map.getComponents()).usingRecursiveFieldByFieldElementComparator().containsExactly(
new TestComponent1("TEST"),
new TestComponent3("TEST")
);
}

@Test
void Test_should_copy_correctly() {
// Arrange
ComponentMapFactory<TestComponent, String> original = new ComponentMapFactory<>();
original.addFactory(TestComponent1.class, TestComponent1::new);
original.addFactory(TestComponent2.class, TestComponent2::new);

// Act
ComponentMapFactory<TestComponent, String> copied = original.copy();
copied.addFactory(TestComponent3.class, TestComponent3::new);

// Assert
assertThat(original.buildComponentMap("original").getComponents()).hasSize(2);
assertThat(copied.buildComponentMap("copied").getComponents()).hasSize(3);
}

private interface TestComponent {
String getGivenContext();
}

private abstract static class TestComponentImpl implements TestComponent {
private final String componentId;
private final String givenContext;

public TestComponentImpl(String componentId, String givenContext) {
this.componentId = componentId;
this.givenContext = givenContext;
}

@Override
public String getGivenContext() {
return componentId + " " + givenContext;
}
}

private static class TestComponent1 extends TestComponentImpl {
public TestComponent1(String givenContext) {
super("C1", givenContext);
}
}

private static class TestComponent2 extends TestComponentImpl {
public TestComponent2(String givenContext) {
super("C2", givenContext);
}
}

private static class TestComponent3 extends TestComponentImpl {
public TestComponent3(String givenContext) {
super("C3", givenContext);
}
}
}
Loading

0 comments on commit ddc2498

Please sign in to comment.