generated from KessokuTeaTime/Example-Mod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
209 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 36 additions & 2 deletions
38
src/main/java/net/krlite/knowledges/api/entrypoint/base/Provider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,43 @@ | ||
package net.krlite.knowledges.api.entrypoint.base; | ||
|
||
import net.krlite.knowledges.KnowledgesCommon; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public interface Provider<E> { | ||
@NotNull List<Class<? extends E>> provide(); | ||
public interface Provider<T> { | ||
@NotNull List<Class<? extends T>> provide(); | ||
|
||
default @NotNull List<Class<? extends Provider<? extends T>>> provideNested() { | ||
return new ArrayList<>(); | ||
} | ||
|
||
default @NotNull List<? extends Class<? extends T>> provideAll() { | ||
List<? extends Provider<? extends T>> nested = provideNested().stream() | ||
.map(c -> { | ||
try { | ||
return c.getDeclaredConstructor().newInstance(); | ||
} catch (Exception e) { | ||
KnowledgesCommon.LOGGER.error("Failed creating child provider {} for {}: constructor not found!", c, getClass(), e); | ||
} | ||
|
||
return null; | ||
}) | ||
.filter(Objects::nonNull) | ||
.toList(); | ||
|
||
List<? extends Class<? extends T>> nestedProvided = nested.stream() | ||
.map(Provider::provideAll) | ||
.flatMap(List::stream) | ||
.toList(); | ||
|
||
var provided = new ArrayList<>(List.copyOf(provide())); | ||
if (provided.isEmpty()) return nestedProvided; | ||
|
||
provided.addAll(nestedProvided); | ||
return provided; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
.../representable/PacketByteBufWritable.java → ...esentable/base/PacketByteBufWritable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
src/main/java/net/krlite/knowledges/api/representable/base/Representable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/main/java/net/krlite/knowledges/impl/entrypoint/component/InfoComponentProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.krlite.knowledges.impl.entrypoint.component; | ||
|
||
import net.krlite.knowledges.api.entrypoint.ComponentProvider; | ||
import net.krlite.knowledges.impl.component.base.InfoComponent; | ||
import net.krlite.knowledges.impl.component.info.BlockInfoComponent; | ||
import net.krlite.knowledges.impl.component.info.EntityInfoComponent; | ||
import net.krlite.knowledges.impl.component.info.FluidInfoComponent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class InfoComponentProvider implements ComponentProvider<InfoComponent> { | ||
@Override | ||
public @NotNull List<Class<? extends InfoComponent>> provide() { | ||
return List.of( | ||
net.krlite.knowledges.impl.component.info.InfoComponent.class, | ||
|
||
BlockInfoComponent.class, | ||
EntityInfoComponent.class, | ||
FluidInfoComponent.class | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../java/net/krlite/knowledges/impl/entrypoint/data/info/BlockInfoComponentDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.api.entrypoint.base.Provider; | ||
import net.krlite.knowledges.impl.data.info.base.BlockInfoComponentData; | ||
import net.krlite.knowledges.impl.entrypoint.data.info.block.BlockInformationDataProvider; | ||
import net.krlite.knowledges.impl.entrypoint.data.info.block.MineableToolDataProvider; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class BlockInfoComponentDataProvider implements DataProvider<BlockInfoComponentData> { | ||
@Override | ||
public @NotNull List<Class<? extends BlockInfoComponentData>> provide() { | ||
return new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public @NotNull List<Class<? extends Provider<? extends BlockInfoComponentData>>> provideNested() { | ||
return List.of( | ||
BlockInformationDataProvider.class, | ||
MineableToolDataProvider.class | ||
); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...java/net/krlite/knowledges/impl/entrypoint/data/info/EntityInfoComponentDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.api.entrypoint.base.Provider; | ||
import net.krlite.knowledges.impl.data.info.base.EntityInfoComponentData; | ||
import net.krlite.knowledges.impl.entrypoint.data.info.entity.EntityDescriptionDataProvider; | ||
import net.krlite.knowledges.impl.entrypoint.data.info.entity.EntityInformationDataProvider; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class EntityInfoComponentDataProvider implements DataProvider<EntityInfoComponentData> { | ||
@Override | ||
public @NotNull List<Class<? extends EntityInfoComponentData>> provide() { | ||
return new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public @NotNull List<Class<? extends Provider<? extends EntityInfoComponentData>>> provideNested() { | ||
return List.of( | ||
EntityDescriptionDataProvider.class, | ||
EntityInformationDataProvider.class | ||
); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...a/net/krlite/knowledges/impl/entrypoint/data/info/block/BlockInformationDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info.block; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.impl.data.info.base.block.BlockInformationData; | ||
import net.krlite.knowledges.impl.data.info.block.blockinformation.*; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class BlockInformationDataProvider implements DataProvider<BlockInformationData> { | ||
@Override | ||
public @NotNull List<Class<? extends BlockInformationData>> provide() { | ||
return List.of( | ||
NoteBlockInformationData.class, | ||
BannerBlockInformationData.class, | ||
ComposterBlockInformationData.class, | ||
RedstoneWireBlockInformationData.class, | ||
CropBlockInformationData.class, | ||
SaplingBlockInformationData.class, | ||
BeehiveBlockInformationData.class | ||
); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
.../java/net/krlite/knowledges/impl/entrypoint/data/info/block/MineableToolDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info.block; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.impl.data.info.block.MineableToolData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class MineableToolDataProvider implements DataProvider<MineableToolData> { | ||
@Override | ||
public @NotNull List<Class<? extends MineableToolData>> provide() { | ||
return List.of( | ||
MineableToolData.class | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...net/krlite/knowledges/impl/entrypoint/data/info/entity/EntityDescriptionDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info.entity; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.impl.data.info.base.entity.EntityDescriptionData; | ||
import net.krlite.knowledges.impl.data.info.entity.entitydescription.AnimalOwnerEntityDescriptionData; | ||
import net.krlite.knowledges.impl.data.info.entity.entitydescription.ItemFrameEntityDescriptionData; | ||
import net.krlite.knowledges.impl.data.info.entity.entitydescription.VillagerEntityDescriptionData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class EntityDescriptionDataProvider implements DataProvider<EntityDescriptionData> { | ||
@Override | ||
public @NotNull List<Class<? extends EntityDescriptionData>> provide() { | ||
return List.of( | ||
AnimalOwnerEntityDescriptionData.class, | ||
ItemFrameEntityDescriptionData.class, | ||
VillagerEntityDescriptionData.class | ||
); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...net/krlite/knowledges/impl/entrypoint/data/info/entity/EntityInformationDataProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package net.krlite.knowledges.impl.entrypoint.data.info.entity; | ||
|
||
import net.krlite.knowledges.api.entrypoint.DataProvider; | ||
import net.krlite.knowledges.impl.data.info.base.entity.EntityInformationData; | ||
import net.krlite.knowledges.impl.data.info.entity.entityinformation.ItemFrameEntityInformationData; | ||
import net.krlite.knowledges.impl.data.info.entity.entityinformation.PaintingEntityInformationData; | ||
import net.krlite.knowledges.impl.data.info.entity.entityinformation.VillagerEntityInformationData; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class EntityInformationDataProvider implements DataProvider<EntityInformationData> { | ||
@Override | ||
public @NotNull List<Class<? extends EntityInformationData>> provide() { | ||
return List.of( | ||
PaintingEntityInformationData.class, | ||
ItemFrameEntityInformationData.class, | ||
VillagerEntityInformationData.class | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters