type) {
18 | return Optional.ofNullable(get(type));
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/annotations/AbstractionMarker.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 28-1-2017.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target({ElementType.METHOD, ElementType.TYPE})
13 | public @interface AbstractionMarker {
14 |
15 | public String value();
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/annotations/CopyMarker.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.annotations;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 23-12-2016.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target({ElementType.METHOD, ElementType.FIELD, ElementType.TYPE})
13 | public @interface CopyMarker {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/annotations/StaticLoad.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.annotations;
2 |
3 | import net.minecraftforge.api.distmarker.Dist;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Created by Elec332 on 29-10-2016.
12 | *
13 | * Loads the annotated class (So the static initializer block will get called) after preInit, but before init
14 | */
15 | @Target(ElementType.TYPE)
16 | @Retention(RetentionPolicy.RUNTIME)
17 | public @interface StaticLoad {
18 |
19 | Dist[] onlyIn() default {};
20 |
21 | int weight() default Byte.MAX_VALUE;
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/callback/CallbackProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.callback;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 29-9-2016.
10 | *
11 | * Used to annotate a class that implements {@link ICallbackProcessor}
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.TYPE)
15 | public @interface CallbackProcessor {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/callback/ICallbackProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.callback;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * Created by Elec332 on 29-9-2016.
7 | *
8 | * A callback processor, every class annotated with {@link RegisteredCallback} will be instantiated and available to the
9 | * callback processor, which can filter out his callbacks and process them.
10 | */
11 | public interface ICallbackProcessor {
12 |
13 | /**
14 | * Used to get the callbacks this class needs to process from the list (and optionally process them in the same function)
15 | *
16 | * @param callbacks All (instantiated) classes annotated with {@link RegisteredCallback}
17 | */
18 | void getCallbacks(List> callbacks);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/callback/RegisteredCallback.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.callback;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 29-9-2016.
10 | *
11 | * Used to annotate callback classes
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.TYPE)
15 | public @interface RegisteredCallback {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/IColoredBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.util.math.BlockPos;
5 | import net.minecraft.world.IBlockReader;
6 |
7 | import javax.annotation.Nonnull;
8 | import javax.annotation.Nullable;
9 |
10 | /**
11 | * Created by Elec332 on 16-9-2016.
12 | */
13 | public interface IColoredBlock {
14 |
15 | default int colorMultiplier(@Nonnull BlockState state, @Nullable IBlockReader worldIn, @Nullable BlockPos pos, int tintIndex) {
16 | return -1;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/IColoredItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | /**
6 | * Created by Elec332 on 21-8-2016.
7 | */
8 | public interface IColoredItem {
9 |
10 | default int getColorFromItemStack(ItemStack stack, int tintIndex) {
11 | return -1;
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/IIconRegistrar.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import net.minecraft.client.renderer.texture.AtlasTexture;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraft.util.ResourceLocation;
6 |
7 | /**
8 | * Created by Elec332 on 9-12-2015.
9 | *
10 | * Simple helper to register icons ({@link TextureAtlasSprite}'s)
11 | */
12 | public interface IIconRegistrar {
13 |
14 | /**
15 | * Used for registering sprites
16 | *
17 | * @param location The sprite location
18 | * @return The registered sprite
19 | */
20 | TextureAtlasSprite registerSprite(ResourceLocation location);
21 |
22 | /**
23 | * @return The underlying {@link AtlasTexture}
24 | */
25 | AtlasTexture getTextureMap();
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/IRenderMatrix.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | /**
4 | * Created by Elec332 on 1-7-2020
5 | */
6 | public interface IRenderMatrix {
7 |
8 | void translate(double x, double y, double z);
9 |
10 | default void scale(float scale) {
11 | scale(scale, scale, scale);
12 | }
13 |
14 | void scale(float scaleX, float scaleY, float scaleZ);
15 |
16 | void rotateDegrees(float angle, float x, float y, float z);
17 |
18 | void bindTexture(ITextureLocation location);
19 |
20 | void push();
21 |
22 | void pop();
23 |
24 | default int getLight() {
25 | return 15728880;
26 | }
27 |
28 | default int getOverlay() {
29 | return 0;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/ITESRItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import com.mojang.blaze3d.matrix.MatrixStack;
4 | import net.minecraft.client.renderer.IRenderTypeBuffer;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraftforge.api.distmarker.Dist;
7 | import net.minecraftforge.api.distmarker.OnlyIn;
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * Created by Elec332 on 23-12-2019
13 | */
14 | public interface ITESRItem {
15 |
16 | @OnlyIn(Dist.CLIENT)
17 | void renderItem(ItemStack stack, @Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/ITessellator.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import com.mojang.blaze3d.matrix.MatrixStack;
4 | import com.mojang.blaze3d.vertex.IVertexBuilder;
5 | import net.minecraft.util.math.vector.Matrix4f;
6 | import net.minecraftforge.api.distmarker.Dist;
7 | import net.minecraftforge.api.distmarker.OnlyIn;
8 | import net.minecraftforge.client.model.pipeline.VertexBufferConsumer;
9 |
10 | import javax.annotation.Nonnull;
11 | import java.util.Objects;
12 |
13 | /**
14 | * Created by Elec332 on 25-11-2015.
15 | *
16 | * A tessellator that works like 1.7.10, meaning that
17 | * it remembers the brightness, opaque and color settings, and that
18 | * {@link ITessellator#addVertexWithUV(double, double, double, float, float)}
19 | * can be called for creating vertices
20 | */
21 | @OnlyIn(Dist.CLIENT)
22 | public interface ITessellator {
23 |
24 | void setBrightness(int brightness);
25 |
26 | void setColorOpaque_F(float red, float green, float blue);
27 |
28 | void setColorOpaque(int red, int green, int blue);
29 |
30 | void setColorRGBA_F(float red, float green, float blue, float alpha);
31 |
32 | void setColorRGBA_I(int color, int alpha);
33 |
34 | void setColorRGBA(int red, int green, int blue, int alpha);
35 |
36 | default void setTransformation(@Nonnull MatrixStack matrix) {
37 | setMatrix(Objects.requireNonNull(matrix).getLast().getMatrix());
38 | }
39 |
40 | void setMatrix(Matrix4f matrix);
41 |
42 | void clearMatrix();
43 |
44 | void addVertexWithUV(Matrix4f matrix, double x, double y, double z, float u, float v);
45 |
46 | void addVertexWithUV(double x, double y, double z, float u, float v);
47 |
48 | void startDrawingWorldBlock();
49 |
50 | void startDrawingGui();
51 |
52 | void draw();
53 |
54 | @Nonnull
55 | IVertexBuilder getVertexBuilder();
56 |
57 | @Nonnull
58 | VertexBufferConsumer getVertexBufferConsumer();
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/ITextureLoader.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import elec332.core.api.client.model.IRenderingRegistry;
4 | import net.minecraftforge.api.distmarker.Dist;
5 | import net.minecraftforge.api.distmarker.OnlyIn;
6 |
7 | /**
8 | * Created by Elec332 on 9-12-2015.
9 | *
10 | * Can be used by objects that need to register textures.
11 | * Needs to be registered by calling
12 | * {@link IRenderingRegistry#registerLoader(ITextureLoader)}
13 | */
14 | public interface ITextureLoader {
15 |
16 | /**
17 | * Use this to register your textures.
18 | *
19 | * @param iconRegistrar The IIconRegistrar.
20 | */
21 | @OnlyIn(Dist.CLIENT)
22 | void registerTextures(IIconRegistrar iconRegistrar);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/ITextureLocation.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client;
2 |
3 | import net.minecraft.util.ResourceLocation;
4 |
5 | /**
6 | * Created by Elec332 on 6-7-2020
7 | */
8 | public interface ITextureLocation {
9 |
10 | ResourceLocation getTextureLocation();
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/IModelAndTextureLoader.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model;
2 |
3 | import elec332.core.api.client.ITextureLoader;
4 |
5 | /**
6 | * Created by Elec332 on 21-11-2015.
7 | *
8 | * A combination of {@link IModelLoader} and {@link ITextureLoader}
9 | * Needs to be registered by calling
10 | * {@link IRenderingRegistry#registerLoader(IModelAndTextureLoader)}
11 | */
12 | public interface IModelAndTextureLoader extends IModelLoader, ITextureLoader {
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/IModelBakery.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model;
2 |
3 | import elec332.core.api.client.model.model.IModelWithoutQuads;
4 | import elec332.core.api.client.model.model.IQuadProvider;
5 | import elec332.core.api.client.model.template.IModelTemplate;
6 | import elec332.core.api.client.model.template.IQuadTemplate;
7 | import elec332.core.api.client.model.template.IQuadTemplateSidedMap;
8 | import net.minecraft.client.renderer.model.IBakedModel;
9 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
10 | import net.minecraft.client.renderer.model.ModelRotation;
11 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
12 |
13 | import javax.annotation.Nullable;
14 | import java.util.List;
15 |
16 | /**
17 | * Created by Elec332 on 29-10-2016.
18 | */
19 | public interface IModelBakery {
20 |
21 | IBakedModel forTemplate(IModelTemplate template);
22 |
23 | IBakedModel forTemplate(IModelTemplate template, ModelRotation rotation);
24 |
25 | IBakedModel forTemplateOverrideQuads(IModelTemplate template, @Nullable IQuadTemplateSidedMap sidedQuads, @Nullable List generalQuads);
26 |
27 | IBakedModel forTemplateOverrideQuads(IModelTemplate template, ModelRotation rotation, @Nullable IQuadTemplateSidedMap sidedQuads, @Nullable List generalQuads);
28 |
29 | IBakedModel itemModelForTextures(TextureAtlasSprite... textures);
30 |
31 | IBakedModel forQuadProvider(IModelTemplate template, final IQuadProvider quadProvider);
32 |
33 | IBakedModel forQuadProvider(IModelWithoutQuads modelWithoutQuads, final IQuadProvider quadProvider);
34 |
35 | IBakedModel itemModelForTextures(IModelTemplate template, TextureAtlasSprite... textures);
36 |
37 | ItemCameraTransforms getDefaultItemTransformation();
38 |
39 | ItemCameraTransforms getDefaultBlockTransformation();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/IModelLoader.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model;
2 |
3 | import net.minecraftforge.api.distmarker.Dist;
4 | import net.minecraftforge.api.distmarker.OnlyIn;
5 |
6 | /**
7 | * Created by Elec332 on 9-12-2015.
8 | *
9 | * Can be used by objects that need to make models,
10 | * Needs to be registered by calling
11 | * {@link IRenderingRegistry#registerLoader(IModelLoader)}
12 | */
13 | public interface IModelLoader {
14 |
15 | /**
16 | * A helper method to prevent you from having to hook into the event,
17 | * use this to make your quads. (This always comes AFTER the textures are loaded)
18 | *
19 | * @param quadBakery The QuadBakery.
20 | */
21 | @OnlyIn(Dist.CLIENT)
22 | void registerModels(IQuadBakery quadBakery, IModelBakery modelBakery, ITemplateBakery templateBakery);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/ITemplateBakery.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model;
2 |
3 | import elec332.core.api.client.model.template.*;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraft.util.Direction;
6 |
7 | import javax.annotation.Nonnull;
8 |
9 | /**
10 | * Created by Elec332 on 29-10-2016.
11 | */
12 | public interface ITemplateBakery {
13 |
14 | @Nonnull
15 | IMutableModelTemplate newDefaultItemTemplate();
16 |
17 | @Nonnull
18 | IMutableModelTemplate newDefaultBlockTemplate(TextureAtlasSprite... textures);
19 |
20 | @Nonnull
21 | IMutableModelTemplate newDefaultBlockTemplate(TextureAtlasSprite texture);
22 |
23 | @Nonnull
24 | IMutableModelTemplate newDefaultBlockTemplate();
25 |
26 | @Nonnull
27 | IMutableModelTemplate newModelTemplate();
28 |
29 | @Nonnull
30 | IMutableModelTemplate copyOf(IModelTemplate template);
31 |
32 | @Nonnull
33 | IMutableQuadTemplate templateQuadForTexture(Direction side, TextureAtlasSprite texture);
34 |
35 | @Nonnull
36 | IMutableQuadTemplate newQuadTemplate(Direction side);
37 |
38 | @Nonnull
39 | IMutableQuadTemplate copyOf(@Nonnull IQuadTemplate template);
40 |
41 | @Nonnull
42 | IQuadTemplate makeImmutable(@Nonnull IQuadTemplate template);
43 |
44 | @Nonnull
45 | IQuadTemplate.IMutableUVData forUV(float uMin, float vMin, float uMax, float vMax);
46 |
47 | @Nonnull
48 | IQuadTemplate.IUVData makeImmutable(@Nonnull IQuadTemplate.IUVData data);
49 |
50 | @Nonnull
51 | IQuadTemplateSidedMap newQuadSidedMap();
52 |
53 | @Nonnull
54 | IQuadTemplateSidedMap newQuadSidedMap(TextureAtlasSprite texture);
55 |
56 | @Nonnull
57 | IQuadTemplateSidedMap newQuadSidedMap(TextureAtlasSprite... textures);
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/loading/IBlockModelHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.loading;
2 |
3 | import net.minecraft.block.Block;
4 | import net.minecraft.block.BlockState;
5 | import net.minecraft.client.renderer.model.IBakedModel;
6 | import net.minecraft.client.renderer.model.ModelResourceLocation;
7 |
8 | /**
9 | * Created by Elec332 on 11-3-2016.
10 | *
11 | * Model handler for blocks
12 | */
13 | public interface IBlockModelHandler {
14 |
15 | /**
16 | * Whether this handler can handle this block
17 | *
18 | * @param block The block
19 | * @return Whether this handler can handle this block
20 | */
21 | boolean handleBlock(Block block);
22 |
23 | /**
24 | * Notifies this {@link IBlockModelHandler} of the
25 | * {@link ModelResourceLocation} of the provided {@link BlockState}
26 | *
27 | * @param state The {@link BlockState}
28 | * @param modelLocation The location of the provided {@link BlockState}
29 | */
30 | default void notifyModelLocation(BlockState state, ModelResourceLocation modelLocation) {
31 | }
32 |
33 | /**
34 | * Used to create/fetch the model for this {@param block}
35 | *
36 | * @param state The block state
37 | * @param identifier The identifier of this block state
38 | * @param fullResourceLocation The full ModelResourceLocation for this model
39 | * @return The model for this {@param state}
40 | */
41 | IBakedModel getModelFor(BlockState state, String identifier, ModelResourceLocation fullResourceLocation);
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/loading/IItemModelHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.loading;
2 |
3 | import net.minecraft.client.renderer.model.IBakedModel;
4 | import net.minecraft.client.renderer.model.ModelResourceLocation;
5 | import net.minecraft.item.Item;
6 |
7 | /**
8 | * Created by Elec332 on 11-3-2016.
9 | *
10 | * Model handler for items
11 | */
12 | public interface IItemModelHandler {
13 |
14 | /**
15 | * Whether this handler can handle this item
16 | *
17 | * @param item The item
18 | * @return Whether this handler can handle this item
19 | */
20 | boolean handleItem(Item item);
21 |
22 | /**
23 | * Used to create an identifier for this Item
24 | * (This will also be the variant in the ModelResourceLocation)
25 | *
26 | * @param item The item
27 | * @return The identifier for this Item
28 | */
29 | String getIdentifier(Item item);
30 |
31 | /**
32 | * Used to create/fetch the model for this {@param item}
33 | *
34 | * @param item The item
35 | * @param identifier The identifier of this item
36 | * @param fullResourceLocation The full ModelResourceLocation for this model
37 | * @return The model for this {@param item}
38 | */
39 | IBakedModel getModelFor(Item item, String identifier, ModelResourceLocation fullResourceLocation);
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/loading/IModelManager.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.loading;
2 |
3 | /**
4 | * Created by Elec332 on 19-8-2020
5 | */
6 | public interface IModelManager {
7 |
8 | void registerModelHandler(Object object);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/loading/ModelHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.loading;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 11-3-2016.
10 | *
11 | * Used to annotate any type of model handler
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.TYPE)
15 | public @interface ModelHandler {
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/model/IModelWithoutQuads.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.model;
2 |
3 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraftforge.api.distmarker.Dist;
6 | import net.minecraftforge.api.distmarker.OnlyIn;
7 |
8 | /**
9 | * Created by Elec332 on 15-11-2015.
10 | */
11 | @OnlyIn(Dist.CLIENT)
12 | public interface IModelWithoutQuads {
13 |
14 | boolean isAmbientOcclusion();
15 |
16 | boolean isGui3d();
17 |
18 | boolean isBuiltInRenderer();
19 |
20 | TextureAtlasSprite getParticleTexture();
21 |
22 | ItemCameraTransforms getItemCameraTransforms();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/model/IQuadProvider.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.model;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.client.renderer.model.BakedQuad;
5 | import net.minecraft.util.Direction;
6 | import net.minecraftforge.api.distmarker.Dist;
7 | import net.minecraftforge.api.distmarker.OnlyIn;
8 |
9 | import javax.annotation.Nullable;
10 | import java.util.List;
11 | import java.util.Random;
12 |
13 | /**
14 | * Created by Elec332 on 11-3-2016.
15 | */
16 | public interface IQuadProvider {
17 |
18 | @OnlyIn(Dist.CLIENT)
19 | List getBakedQuads(@Nullable BlockState state, Direction side, Random random);
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IModelTemplate.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraftforge.api.distmarker.Dist;
6 | import net.minecraftforge.api.distmarker.OnlyIn;
7 |
8 | import java.util.List;
9 |
10 | /**
11 | * Created by Elec332 on 5-12-2015.
12 | */
13 | @OnlyIn(Dist.CLIENT)
14 | public interface IModelTemplate extends IQuadProviderTemplate {
15 |
16 | List getGeneralQuads();
17 |
18 | IQuadTemplateSidedMap getSidedQuads();
19 |
20 | boolean isAmbientOcclusion();
21 |
22 | boolean isGui3d();
23 |
24 | boolean isBuiltInRenderer();
25 |
26 | TextureAtlasSprite getTexture();
27 |
28 | ItemCameraTransforms getItemCameraTransforms();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IMutableModelTemplate.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Elec332 on 29-10-2016.
10 | */
11 | public interface IMutableModelTemplate extends IModelTemplate {
12 |
13 | IMutableModelTemplate setGeneralQuads(List generalQuads);
14 |
15 | IMutableModelTemplate setSidedQuads(IQuadTemplateSidedMap sidedQuads);
16 |
17 | IMutableModelTemplate setAmbientOcclusion(boolean ao);
18 |
19 | IMutableModelTemplate setGui3d(boolean gui3d);
20 |
21 | IMutableModelTemplate setBuiltIn(boolean builtIn);
22 |
23 | IMutableModelTemplate setTexture(TextureAtlasSprite texture);
24 |
25 | IMutableModelTemplate setItemCameraTransforms(ItemCameraTransforms transforms);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IMutableQuadTemplate.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraft.client.renderer.model.ModelRotation;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraft.util.Direction;
6 | import net.minecraft.util.math.vector.Vector3f;
7 |
8 | /**
9 | * Created by Elec332 on 29-10-2016.
10 | */
11 | public interface IMutableQuadTemplate extends IQuadTemplate {
12 |
13 | IMutableQuadTemplate setV1(Vector3f v1);
14 |
15 | IMutableQuadTemplate setV2(Vector3f v2);
16 |
17 | IMutableQuadTemplate setTexture(TextureAtlasSprite texture);
18 |
19 | IMutableQuadTemplate setSide(Direction side);
20 |
21 | IMutableQuadTemplate setRotation(ModelRotation rotation);
22 |
23 | IMutableQuadTemplate setUvData(IUVData uvData);
24 |
25 | IMutableQuadTemplate setTintIndex(int tintIndex);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IQuadProviderTemplate.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraftforge.api.distmarker.Dist;
4 | import net.minecraftforge.api.distmarker.OnlyIn;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Elec332 on 11-3-2016.
10 | */
11 | @OnlyIn(Dist.CLIENT)
12 | public interface IQuadProviderTemplate {
13 |
14 | List getGeneralQuads();
15 |
16 | IQuadTemplateSidedMap getSidedQuads();
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IQuadTemplate.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraft.client.renderer.model.ModelRotation;
4 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
5 | import net.minecraft.util.Direction;
6 | import net.minecraft.util.math.vector.Vector3f;
7 | import net.minecraftforge.api.distmarker.Dist;
8 | import net.minecraftforge.api.distmarker.OnlyIn;
9 |
10 | /**
11 | * Created by Elec332 on 6-12-2015.
12 | */
13 | @OnlyIn(Dist.CLIENT)
14 | public interface IQuadTemplate {
15 |
16 | Vector3f getV1();
17 |
18 | Vector3f getV2();
19 |
20 | TextureAtlasSprite getTexture();
21 |
22 | Direction getSide();
23 |
24 | ModelRotation getRotation();
25 |
26 | IUVData getUVData();
27 |
28 | int getTintIndex();
29 |
30 | interface IUVData {
31 |
32 | float getUMin();
33 |
34 | float getVMin();
35 |
36 | float getUMax();
37 |
38 | float getVMax();
39 |
40 | }
41 |
42 | interface IMutableUVData extends IUVData {
43 |
44 | IMutableUVData setUMin(float f);
45 |
46 | IMutableUVData setVMin(float f);
47 |
48 | IMutableUVData setUMax(float f);
49 |
50 | IMutableUVData setVMax(float f);
51 |
52 | @Override
53 | float getUMin();
54 |
55 | @Override
56 | float getVMin();
57 |
58 | @Override
59 | float getUMax();
60 |
61 | @Override
62 | float getVMax();
63 |
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/client/model/template/IQuadTemplateSidedMap.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.client.model.template;
2 |
3 | import net.minecraft.util.Direction;
4 | import net.minecraftforge.api.distmarker.Dist;
5 | import net.minecraftforge.api.distmarker.OnlyIn;
6 |
7 | import javax.annotation.Nonnull;
8 | import java.util.List;
9 |
10 | /**
11 | * Created by Elec332 on 6-12-2015.
12 | */
13 | @OnlyIn(Dist.CLIENT)
14 | public interface IQuadTemplateSidedMap {
15 |
16 | void setQuadsForSide(Direction side, @Nonnull List newQuads);
17 |
18 | void addQuadsForSide(Direction side, List toAdd);
19 |
20 | void addQuadForSide(Direction side, IQuadTemplate toAdd);
21 |
22 | @Nonnull
23 | List getForSide(Direction side);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/config/IConfigurableElement.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.config;
2 |
3 | import net.minecraftforge.common.ForgeConfigSpec;
4 | import net.minecraftforge.fml.config.ModConfig;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Created by Elec332 on 18-10-2016.
10 | *
11 | * Used in reconfigurable objects/elements, can be registered to an {@link IConfigWrapper}
12 | */
13 | public interface IConfigurableElement {
14 |
15 | void registerProperties(@Nonnull ForgeConfigSpec.Builder config, ModConfig.Type type);
16 |
17 | /**
18 | * Gets called when the config file is initially loaded
19 | * and when the config values have changed.
20 | *
21 | * Use this to reload e.g. fields with the values from the defined properties
22 | */
23 | default void load() {
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/IRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe;
2 |
3 | import elec332.core.util.RegistryHelper;
4 | import net.minecraft.data.IFinishedRecipe;
5 | import net.minecraft.item.Item;
6 | import net.minecraft.nbt.CompoundNBT;
7 | import net.minecraft.util.ResourceLocation;
8 |
9 | /**
10 | * Created by Elec332 on 15-7-2020
11 | */
12 | public interface IRecipeBuilder> extends IRecipeBuilderBase {
13 |
14 | /**
15 | * Gets the group of this recipe
16 | */
17 | String getGroup();
18 |
19 | /**
20 | * Gets the result of this recipe
21 | */
22 | Item getResult();
23 |
24 | T withTag(CompoundNBT tag);
25 |
26 | /**
27 | * Builds this recipe into an {@link IFinishedRecipe}.
28 | */
29 | default void build() {
30 | this.build(RegistryHelper.getItemRegistry().getKey(this.getResult()));
31 | }
32 |
33 | /**
34 | * Builds this recipe into an {@link IFinishedRecipe}. Use {@link #build()} if save is the same as the ID for
35 | * the result.
36 | */
37 | default void build(String save) {
38 | ResourceLocation resourcelocation = RegistryHelper.getItemRegistry().getKey(this.getResult());
39 | if ((new ResourceLocation(save)).equals(resourcelocation)) {
40 | throw new IllegalStateException("Shaped Recipe " + save + " should remove its 'save' argument");
41 | } else {
42 | this.build(new ResourceLocation(save));
43 | }
44 | }
45 |
46 | /**
47 | * Builds this recipe into an {@link IFinishedRecipe}.
48 | */
49 | void build(ResourceLocation id);
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/IRecipeBuilderBase.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe;
2 |
3 | import net.minecraft.advancements.ICriterionInstance;
4 | import net.minecraft.item.Item;
5 | import net.minecraft.item.crafting.Ingredient;
6 | import net.minecraft.tags.Tag;
7 | import net.minecraft.util.IItemProvider;
8 |
9 | /**
10 | * Created by Elec332 on 15-7-2020
11 | */
12 | interface IRecipeBuilderBase> {
13 |
14 | T addCriterion(String name, ICriterionInstance criterion);
15 |
16 | default T key(Character symbol, Tag- tag) {
17 | return this.key(symbol, Ingredient.fromTag(tag));
18 | }
19 |
20 | default T key(Character symbol, IItemProvider item) {
21 | return this.key(symbol, Ingredient.fromItems(item));
22 | }
23 |
24 | T key(Character symbol, Ingredient ingredient);
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/IRecipeType.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe;
2 |
3 | import net.minecraft.advancements.ICriterionInstance;
4 | import net.minecraft.data.IFinishedRecipe;
5 | import net.minecraft.item.crafting.Ingredient;
6 | import net.minecraft.util.IItemProvider;
7 |
8 | import java.util.Map;
9 | import java.util.function.Consumer;
10 |
11 | /**
12 | * Created by Elec332 on 15-7-2020
13 | */
14 | public interface IRecipeType
> {
15 |
16 | T createBuilder(Consumer registry, IItemProvider result, int resultCount, String group, Map keys, Map criteria);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/impl/ICookingRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe.impl;
2 |
3 | import elec332.core.api.data.recipe.IRecipeBuilder;
4 | import net.minecraft.item.Item;
5 | import net.minecraft.item.crafting.Ingredient;
6 | import net.minecraft.tags.Tag;
7 | import net.minecraft.util.IItemProvider;
8 |
9 | /**
10 | * Created by Elec332 on 15-7-2020
11 | */
12 | public interface ICookingRecipeBuilder extends IRecipeBuilder {
13 |
14 | ICookingRecipeBuilder withOutput(Character input, float experience, int cookingTime);
15 |
16 | ICookingRecipeBuilder withOutput(Tag- input, float experience, int cookingTime);
17 |
18 | ICookingRecipeBuilder withOutput(IItemProvider input, float experience, int cookingTime);
19 |
20 | ICookingRecipeBuilder withOutput(Ingredient input, float experience, int cookingTime);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/impl/IShapedRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe.impl;
2 |
3 | import elec332.core.api.data.recipe.IRecipeBuilder;
4 |
5 | /**
6 | * Created by Elec332 on 15-7-2020
7 | */
8 | public interface IShapedRecipeBuilder extends IRecipeBuilder
{
9 |
10 | IShapedRecipeBuilder patternLine(String pattern);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/impl/IShapelessRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe.impl;
2 |
3 | import elec332.core.api.data.recipe.IRecipeBuilder;
4 | import elec332.core.data.recipe.ShapelessRecipeBuilder;
5 | import net.minecraft.item.Item;
6 | import net.minecraft.item.crafting.Ingredient;
7 | import net.minecraft.tags.Tag;
8 | import net.minecraft.util.IItemProvider;
9 |
10 | /**
11 | * Created by Elec332 on 15-7-2020
12 | */
13 | public interface IShapelessRecipeBuilder extends IRecipeBuilder {
14 |
15 | ShapelessRecipeBuilder addIngredient(Tag- tag);
16 |
17 | ShapelessRecipeBuilder addIngredient(IItemProvider item);
18 |
19 | ShapelessRecipeBuilder addIngredient(IItemProvider item, int quantity);
20 |
21 | ShapelessRecipeBuilder addIngredient(Ingredient ingredient);
22 |
23 | ShapelessRecipeBuilder addIngredient(Ingredient ingredient, int quantity);
24 |
25 | ShapelessRecipeBuilder addIngredient(Character ingredient);
26 |
27 | ShapelessRecipeBuilder addIngredient(Character ingredient, int quantity);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/data/recipe/impl/IStoneCutterRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.data.recipe.impl;
2 |
3 | import elec332.core.api.data.recipe.IRecipeBuilder;
4 | import net.minecraft.item.Item;
5 | import net.minecraft.item.crafting.Ingredient;
6 | import net.minecraft.tags.Tag;
7 | import net.minecraft.util.IItemProvider;
8 |
9 | /**
10 | * Created by Elec332 on 15-7-2020
11 | */
12 | public interface IStoneCutterRecipeBuilder extends IRecipeBuilder
{
13 |
14 | IStoneCutterRecipeBuilder withOutput(Character input);
15 |
16 | IStoneCutterRecipeBuilder withOutput(Tag- input);
17 |
18 | IStoneCutterRecipeBuilder withOutput(IItemProvider input);
19 |
20 | IStoneCutterRecipeBuilder withOutput(Ingredient input);
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/discovery/AnnotationDataProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.discovery;
2 |
3 | import net.minecraftforge.fml.ModLoadingStage;
4 |
5 | import java.lang.annotation.ElementType;
6 | import java.lang.annotation.Retention;
7 | import java.lang.annotation.RetentionPolicy;
8 | import java.lang.annotation.Target;
9 |
10 | /**
11 | * Created by Elec332 on 7-3-2016.
12 | *
13 | * Used to annotate a class that implements {@link IAnnotationDataProcessor}
14 | */
15 | @Retention(RetentionPolicy.RUNTIME)
16 | @Target(ElementType.TYPE)
17 | public @interface AnnotationDataProcessor {
18 |
19 | /**
20 | * Valid ModLoadingStages:
21 | * ModLoadingStage.CONSTRUCTING
22 | * ModLoadingStage.PREINITIALIZATION
23 | * ModLoadingStage.INITIALIZATION
24 | * ModLoadingStage.POSTINITIALIZATION
25 | * ModLoadingStage.AVAILABLE
26 | *
27 | * @return The (array of) ModLoadingStage(s) in which to load this.
28 | */
29 | ModLoadingStage[] value();
30 |
31 | /**
32 | * The importance of this {@link IAnnotationDataProcessor}, higher = earlier processing
33 | *
34 | * @return Importance of this {@link IAnnotationDataProcessor}
35 | */
36 | int importance() default -1;
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/discovery/IAnnotationData.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.discovery;
2 |
3 | import net.minecraftforge.fml.loading.moddiscovery.ModFile;
4 | import org.objectweb.asm.Type;
5 |
6 | import javax.annotation.Nullable;
7 | import java.lang.reflect.Field;
8 | import java.lang.reflect.Method;
9 | import java.util.Map;
10 |
11 | /**
12 | * Created by Elec332 on 29-10-2016.
13 | *
14 | * Works like the legacy ASMData with more features for easier handling
15 | */
16 | public interface IAnnotationData {
17 |
18 | ModFile getFile();
19 |
20 | default String getAnnotationName() {
21 | return getAnnotationType().toString();
22 | }
23 |
24 | Type getAnnotationType();
25 |
26 | Map getAnnotationInfo();
27 |
28 | default String getClassName() {
29 | return getClassType().getClassName();
30 | }
31 |
32 | @Nullable
33 | default Class> tryLoadClass() {
34 | if (hasWrongSideOnlyAnnotation()) {
35 | return null;
36 | }
37 | return loadClass();
38 | }
39 |
40 | Class> loadClass();
41 |
42 | Type getClassType();
43 |
44 | String getMemberName();
45 |
46 | boolean isField();
47 |
48 | String getFieldName();
49 |
50 | Field getField();
51 |
52 | Class> getFieldType();
53 |
54 | boolean isMethod();
55 |
56 | String getMethodName();
57 |
58 | Method getMethod();
59 |
60 | Type[] getMethodParameterTypes();
61 |
62 | Class>[] getMethodParameters();
63 |
64 | boolean hasWrongSideOnlyAnnotation();
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/discovery/IAnnotationDataHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.discovery;
2 |
3 | import net.minecraftforge.fml.ModContainer;
4 | import net.minecraftforge.forgespi.language.IModFileInfo;
5 | import org.objectweb.asm.Type;
6 |
7 | import javax.annotation.Nonnull;
8 | import java.lang.annotation.Annotation;
9 | import java.util.Collection;
10 | import java.util.Map;
11 | import java.util.Set;
12 | import java.util.function.Function;
13 |
14 | /**
15 | * Created by Elec332 on 7-3-2016.
16 | *
17 | * Handles annotation data
18 | */
19 | public interface IAnnotationDataHandler {
20 |
21 | default Set getAnnotationList(Class extends Annotation> annotationClass) {
22 | return getAnnotationList(Type.getType(annotationClass));
23 | }
24 |
25 | Set getAnnotationList(Type annotationType);
26 |
27 | boolean hasWrongSideOnlyAnnotation(String clazz);
28 |
29 | Function> getAnnotationsFor(IModFileInfo file);
30 |
31 | Function> getAnnotationsFor(ModContainer mc);
32 |
33 | @Nonnull
34 | Map> getClassAnnotations(String clazz);
35 |
36 | ModContainer deepSearchOwner(IAnnotationData annotationData);
37 |
38 | String deepSearchOwnerName(IAnnotationData annotationData);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/discovery/IAnnotationDataProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.discovery;
2 |
3 | import net.minecraftforge.fml.ModLoadingStage;
4 |
5 | /**
6 | * Created by Elec332 on 7-3-2016.
7 | *
8 | * A class that wants to process the ASMDataTable at a given time
9 | * (Defined in {@link AnnotationDataProcessor} and given as a argument in {@link IAnnotationDataProcessor#processASMData(IAnnotationDataHandler, ModLoadingStage)})
10 | * in the mod lifecycle
11 | */
12 | public interface IAnnotationDataProcessor {
13 |
14 | /**
15 | * Process the ASMDataTable, the current {@link ModLoadingStage} is supplied in case
16 | * this processor gets run at multiple times in the mod lifecycle
17 | *
18 | * @param annotationData The ASMDataTable
19 | * @param state The current {@link ModLoadingStage}
20 | */
21 | void processASMData(IAnnotationDataHandler annotationData, ModLoadingStage state);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInfoDataAccessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import net.minecraft.entity.player.PlayerEntity;
4 | import net.minecraft.nbt.CompoundNBT;
5 | import net.minecraft.util.math.vector.Vector3d;
6 | import net.minecraft.world.World;
7 |
8 | import javax.annotation.Nonnull;
9 |
10 | /**
11 | * Created by Elec332 on 16-10-2016.
12 | */
13 | public interface IInfoDataAccessor {
14 |
15 | /**
16 | * The player looking at the object.
17 | *
18 | * @return The player
19 | */
20 | @Nonnull
21 | PlayerEntity getPlayer();
22 |
23 | /**
24 | * The world in which the object is located
25 | *
26 | * @return The world
27 | */
28 | @Nonnull
29 | World getWorld();
30 |
31 | @Nonnull
32 | CompoundNBT getData();
33 |
34 | /**
35 | * The exact position at which the object was hit
36 | *
37 | * @return The hit vec
38 | */
39 | Vector3d getHitVec();
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInfoDataAccessorBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import net.minecraft.block.Block;
4 | import net.minecraft.block.BlockState;
5 | import net.minecraft.entity.player.PlayerEntity;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraft.nbt.CompoundNBT;
8 | import net.minecraft.tileentity.TileEntity;
9 | import net.minecraft.util.Direction;
10 | import net.minecraft.util.math.BlockPos;
11 | import net.minecraft.util.math.BlockRayTraceResult;
12 | import net.minecraft.util.math.vector.Vector3d;
13 | import net.minecraft.world.World;
14 |
15 | import javax.annotation.Nonnull;
16 | import javax.annotation.Nullable;
17 |
18 | /**
19 | * Created by Elec332 on 16-10-2016.
20 | */
21 | public interface IInfoDataAccessorBlock extends IInfoDataAccessor {
22 |
23 | @Nonnull
24 | @Override
25 | PlayerEntity getPlayer();
26 |
27 | @Nonnull
28 | @Override
29 | World getWorld();
30 |
31 | @Nonnull
32 | BlockPos getPos();
33 |
34 | @Nonnull
35 | @Override
36 | CompoundNBT getData();
37 |
38 | @Nonnull
39 | @Override
40 | Vector3d getHitVec();
41 |
42 | @Nonnull
43 | Direction getSide();
44 |
45 | @Nonnull
46 | BlockState getBlockState();
47 |
48 | @Nonnull
49 | Block getBlock();
50 |
51 | @Nullable
52 | TileEntity getTileEntity();
53 |
54 | @Nullable
55 | ItemStack getStack();
56 |
57 | @Nonnull
58 | BlockRayTraceResult getRayTraceResult();
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInfoDataAccessorEntity.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import net.minecraft.entity.Entity;
4 | import net.minecraft.entity.player.PlayerEntity;
5 | import net.minecraft.nbt.CompoundNBT;
6 | import net.minecraft.util.math.vector.Vector3d;
7 | import net.minecraft.world.World;
8 |
9 | import javax.annotation.Nonnull;
10 | import javax.annotation.Nullable;
11 |
12 | /**
13 | * Created by Elec332 on 16-10-2016.
14 | */
15 | public interface IInfoDataAccessorEntity extends IInfoDataAccessor {
16 |
17 | @Nonnull
18 | @Override
19 | PlayerEntity getPlayer();
20 |
21 | @Nonnull
22 | Entity getEntity();
23 |
24 | @Nonnull
25 | @Override
26 | World getWorld();
27 |
28 | @Nonnull
29 | @Override
30 | CompoundNBT getData();
31 |
32 | @Nullable
33 | @Override
34 | Vector3d getHitVec();
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInfoProvider.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import net.minecraft.entity.player.ServerPlayerEntity;
4 | import net.minecraft.nbt.CompoundNBT;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Created by Elec332 on 16-10-2016.
10 | */
11 | public interface IInfoProvider {
12 |
13 | void addInformation(@Nonnull IInformation information, @Nonnull IInfoDataAccessorBlock hitData);
14 |
15 | void gatherInformation(@Nonnull CompoundNBT tag, @Nonnull ServerPlayerEntity player, @Nonnull IInfoDataAccessorBlock hitData);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInfoProviderEntity.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import net.minecraft.entity.player.ServerPlayerEntity;
4 | import net.minecraft.nbt.CompoundNBT;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Created by Elec332 on 16-10-2016.
10 | */
11 | public interface IInfoProviderEntity {
12 |
13 | void addInformation(@Nonnull IInformation information, @Nonnull IInfoDataAccessorEntity hitData);
14 |
15 | void gatherInformation(@Nonnull CompoundNBT tag, @Nonnull ServerPlayerEntity player, @Nonnull IInfoDataAccessorEntity hitData);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/IInformation.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | import com.google.common.base.Preconditions;
4 | import net.minecraft.util.text.ITextComponent;
5 | import net.minecraft.util.text.StringTextComponent;
6 |
7 | import javax.annotation.Nonnull;
8 | import javax.annotation.Nullable;
9 |
10 | /**
11 | * Created by Elec332 on 16-10-2016.
12 | *
13 | * Represents the information that will be given to the player
14 | */
15 | public interface IInformation {
16 |
17 | @Nonnull
18 | InfoMod getProviderType();
19 |
20 | default void addInformation(@Nonnull String line) {
21 | addInformation(new StringTextComponent(Preconditions.checkNotNull(line)));
22 | }
23 |
24 | void addInformation(@Nonnull ITextComponent text);
25 |
26 | @Nonnull
27 | Object getInformationComponent();
28 |
29 | @Nullable
30 | default Boolean isDebugMode() {
31 | return null;
32 | }
33 |
34 | @Nullable
35 | default Boolean isExtendedMode() {
36 | return null;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/info/InfoMod.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.info;
2 |
3 | /**
4 | * Created by Elec332 on 16-10-2016.
5 | */
6 | public enum InfoMod {
7 |
8 | TOP,
9 | WAILA
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/inventory/IHasProgressBar.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.inventory;
2 |
3 | /**
4 | * Created by Elec332 on 20-5-2015.
5 | *
6 | * Used for 'things' that have a progress bar in their GUI
7 | */
8 | public interface IHasProgressBar {
9 |
10 | /**
11 | * @return The progress of this machine, can be any value.
12 | */
13 | int getProgress();
14 |
15 | /**
16 | * Used to get a scaled value of the progress (between 0.0f and 1.0f)
17 | *
18 | * @param progress The progress of this machine
19 | * @return The scaled progress of this machine (between 0.0f and 1.0f)
20 | */
21 | float getProgressScaled(int progress);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/mod/IElecCoreMod.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.mod;
2 |
3 | import com.mojang.brigadier.CommandDispatcher;
4 | import elec332.core.api.registration.IObjectRegister;
5 | import elec332.core.api.registration.IWorldGenRegister;
6 | import elec332.core.api.registry.ISingleRegister;
7 | import elec332.core.api.storage.IExternalSaveHandler;
8 | import net.minecraft.command.CommandSource;
9 | import net.minecraft.command.ISuggestionProvider;
10 |
11 | import java.util.function.Consumer;
12 |
13 | /**
14 | * Created by Elec332 on 20-10-2016.
15 | *
16 | * Can be implemented in main mod or module classes,
17 | * provides some extra features/helpers
18 | */
19 | public interface IElecCoreMod {
20 |
21 | default void registerRegisters(Consumer> objectHandler, Consumer worldHandler) {
22 | }
23 |
24 | default void registerCommands(CommandDispatcher commandRegistry) {
25 | }
26 |
27 | default void registerClientCommands(CommandDispatcher extends ISuggestionProvider> commandRegistry) {
28 | }
29 |
30 | default void registerSaveHandlers(ISingleRegister saveHandlerRegistry) {
31 | }
32 |
33 | default void afterConstruction() {
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/mod/IElecCoreModHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.mod;
2 |
3 | import net.minecraftforge.fml.ModContainer;
4 |
5 | import java.lang.annotation.Annotation;
6 | import java.util.function.BiConsumer;
7 | import java.util.function.Function;
8 |
9 | /**
10 | * Created by Elec332 on 12-8-2018.
11 | */
12 | public interface IElecCoreModHandler {
13 |
14 | void registerSimpleFieldHandler(Class extends Annotation> annotation, Function func);
15 |
16 | void registerModHandler(BiConsumer handler);
17 |
18 | void registerConstructionModHandler(BiConsumer handler);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/mod/SidedProxy.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.mod;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * This class was present in forge versions prior to MC 1.13
10 | *
11 | * @author cpw
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.FIELD)
15 | public @interface SidedProxy {
16 |
17 | /**
18 | * The full name of the client side class to load and populate.
19 | * Defaults to the nested class named "ClientProxy" in the current class.
20 | */
21 | String clientSide() default "";
22 |
23 | /**
24 | * The full name of the server side class to load and populate.
25 | * Defaults to the nested class named "ServerProxy" in the current class.
26 | */
27 | String serverSide() default "";
28 |
29 | /**
30 | * The name of a mod to load this proxy for. This is required if this annotation is not in the class with @Mod annotation.
31 | * Or there is no other way to determine the mod this annotation belongs to. When in doubt, add this value.
32 | */
33 | String modId() default "";
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/module/IModuleContainer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.module;
2 |
3 | import net.minecraftforge.fml.ModContainer;
4 |
5 | import javax.annotation.Nonnull;
6 |
7 | /**
8 | * Created by Elec332 on 25-9-2016.
9 | *
10 | * Container for a module, somewhat like {@link ModContainer}
11 | */
12 | public interface IModuleContainer extends IModuleInfo {
13 |
14 | @Nonnull
15 | Object getModule();
16 |
17 | @Nonnull
18 | ModContainer getOwnerMod();
19 |
20 | /**
21 | * Used for invoking events on the module.
22 | *
23 | * @param event The event
24 | * @throws Exception If the container failed to dispatch the event to the module,
25 | * or if the module itself threw an exception processing this event
26 | */
27 | void invokeEvent(Object event) throws Exception;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/module/IModuleController.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.module;
2 |
3 | import net.minecraftforge.common.ForgeConfigSpec;
4 |
5 | import javax.annotation.Nonnull;
6 | import javax.annotation.Nullable;
7 | import java.util.function.BiFunction;
8 | import java.util.function.Consumer;
9 | import java.util.function.Function;
10 |
11 | /**
12 | * Created by Elec332 on 25-9-2016.
13 | */
14 | public interface IModuleController {
15 |
16 | default boolean shouldModuleConstruct(IModuleInfo moduleInfo, boolean allDependenciesPresent) {
17 | return allDependenciesPresent;
18 | }
19 |
20 | boolean isModuleEnabled(String moduleName);
21 |
22 | @Nullable
23 | default ForgeConfigSpec.BooleanValue getModuleConfig(String moduleName) {
24 | return null;
25 | }
26 |
27 | @Nullable
28 | default IModuleContainer wrap(@Nonnull IModuleInfo module, Function invoker, BiFunction defaultWrapper) throws Exception {
29 | return defaultWrapper.apply(invoker.apply(module), module);
30 | }
31 |
32 | default void registerAdditionalModules(Consumer registry, BiFunction, IModuleInfo.Builder> factory1, BiFunction factory2) {
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/IExtendedMessageContext.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import net.minecraft.entity.player.PlayerEntity;
4 | import net.minecraft.world.World;
5 | import net.minecraftforge.fml.LogicalSide;
6 | import net.minecraftforge.fml.network.PacketDispatcher;
7 |
8 | /**
9 | * Created by Elec332 on 3-12-2016.
10 | */
11 | public interface IExtendedMessageContext {
12 |
13 | LogicalSide getReceptionSide();
14 |
15 | PlayerEntity getSender();
16 |
17 | World getWorld();
18 |
19 | PacketDispatcher getNetworkManager();
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/ILocatedPacket.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import net.minecraft.world.World;
4 |
5 | /**
6 | * Created by Elec332 on 24-11-2017.
7 | */
8 | public interface ILocatedPacket {
9 |
10 | IPacketDispatcher.TargetPoint getTargetPoint(World world, double range);
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/IMessage.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import net.minecraft.network.PacketBuffer;
4 |
5 | /**
6 | * Created by Elec332 on 2-1-2019
7 | */
8 | public interface IMessage {
9 |
10 | /**
11 | * Convert from the supplied buffer into your specific message type
12 | *
13 | * @param buf
14 | */
15 | void fromBytes(PacketBuffer buf);
16 |
17 | /**
18 | * Deconstruct your message into the supplied byte buffer
19 | *
20 | * @param buf
21 | */
22 | void toBytes(PacketBuffer buf);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/INetworkHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import elec332.core.api.network.object.INetworkObjectManager;
4 | import elec332.core.api.network.simple.ISimpleNetworkPacketManager;
5 |
6 | /**
7 | * Created by Elec332 on 23-10-2016.
8 | */
9 | public interface INetworkHandler extends IPacketDispatcher, IPacketRegistry, INetworkObjectManager, ISimpleNetworkPacketManager {
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/INetworkManager.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import elec332.core.api.network.simple.ISimpleNetworkPacketManager;
4 | import net.minecraft.util.ResourceLocation;
5 | import net.minecraftforge.fml.network.NetworkEvent;
6 | import net.minecraftforge.fml.network.simple.SimpleChannel;
7 |
8 | import java.util.function.Predicate;
9 | import java.util.function.Supplier;
10 |
11 | /**
12 | * Created by Elec332 on 16-10-2016.
13 | */
14 | public interface INetworkManager {
15 |
16 | T getNetworkHandler(Object mod);
17 |
18 | T createNetworkHandler(Object mod, SimpleChannel simpleNetworkWrapper);
19 |
20 | T createNetworkHandler(Object mod, ResourceLocation channelName, Supplier networkProtocolVersion, Predicate clientAcceptedVersions, Predicate serverAcceptedVersions);
21 |
22 | ISimpleNetworkPacketManager getSimpleNetworkManager(Object mod);
23 |
24 | ISimpleNetworkPacketManager getAdditionalSimpleNetworkManager(Object mod, ResourceLocation name);
25 |
26 | IPacketRegistry newPacketRegistry();
27 |
28 | IExtendedMessageContext wrapMessageContext(NetworkEvent.Context messageContext);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/IPacketRegistryContainer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | /**
4 | * Created by Elec332 on 23-10-2016.
5 | *
6 | * A container that can register packets to an {@link IPacketRegistry}
7 | */
8 | public interface IPacketRegistryContainer {
9 |
10 | /**
11 | * Gets called when this container is supposed to register
12 | * its packets to the provided {@link IPacketRegistry}
13 | *
14 | * @param packetRegistry The packet registry to register the packets to
15 | */
16 | void registerPacketsTo(IPacketRegistry packetRegistry);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/ModNetworkHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 24-10-2016.
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target(ElementType.FIELD)
13 | public @interface ModNetworkHandler {
14 |
15 | String value() default "";
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/object/INetworkObject.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.object;
2 |
3 | /**
4 | * Created by Elec332 on 23-10-2016.
5 | */
6 | public interface INetworkObject> extends INetworkObjectSender, INetworkObjectReceiver {
7 |
8 | @Override
9 | default void setNetworkObjectHandler(INetworkObjectHandler handler) {
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/object/INetworkObjectManager.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.object;
2 |
3 | import javax.annotation.Nullable;
4 |
5 | /**
6 | * Created by Elec332 on 23-10-2016.
7 | */
8 | public interface INetworkObjectManager {
9 |
10 | , S extends INetworkObjectSender> INetworkObjectHandler> registerNetworkObject(N networkObject);
11 |
12 | , S extends INetworkObjectSender> INetworkObjectHandler registerNetworkObject(@Nullable R networkObjectR, @Nullable S networkObjectS);
13 |
14 | > INetworkObjectHandler registerSpecialNetworkObject(N networkObject);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/object/INetworkObjectReceiver.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.object;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 |
5 | /**
6 | * Created by Elec332 on 24-10-2016.
7 | */
8 | public interface INetworkObjectReceiver> {
9 |
10 | void onPacket(int id, ElecByteBuf data);
11 |
12 | default void setNetworkObjectHandler(INetworkObjectHandler handler) {
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/object/INetworkObjectSender.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.object;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 |
5 | /**
6 | * Created by Elec332 on 24-10-2016.
7 | */
8 | public interface INetworkObjectSender> {
9 |
10 | default void writePacket(int id, ElecByteBuf data) {
11 | }
12 |
13 | void setNetworkObjectHandler(INetworkObjectHandler handler);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/simple/ISimplePacket.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.simple;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 |
5 | import javax.annotation.Nullable;
6 |
7 | /**
8 | * Created by Elec332 on 23-10-2016.
9 | *
10 | * A simple packet
11 | */
12 | public interface ISimplePacket {
13 |
14 | void toBytes(ElecByteBuf byteBuf);
15 |
16 | @Nullable
17 | default ISimplePacketHandler getPacketHandler() {
18 | return null;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/network/simple/ISimplePacketHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.network.simple;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 |
6 | /**
7 | * Created by Elec332 on 23-10-2016.
8 | *
9 | * Packet-handler for simple packets, can be used for multiple packets.
10 | * A packet can also have a custom packet-handler chosen by the sender.
11 | */
12 | public interface ISimplePacketHandler {
13 |
14 | void onPacket(ElecByteBuf data, IExtendedMessageContext messageContext, ISimpleNetworkPacketManager networkHandler);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/package-info.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by Elec332 on 25-11-2015.
3 | */
4 | //@API(owner = "eleccore", provides = "ElecCoreAPI", apiVersion = "1.0.0") //TODO: check if this returns
5 | package elec332.core.api;
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/APIInjectedEvent.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraftforge.eventbus.api.GenericEvent;
4 |
5 | /**
6 | * Created by Elec332 on 10-7-2020
7 | */
8 | public abstract class APIInjectedEvent extends GenericEvent {
9 |
10 | public APIInjectedEvent(Class type) {
11 | super(type);
12 | }
13 |
14 | public abstract T getInjectedAPI();
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/DataGenerator.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 6-8-2020
10 | */
11 | @Retention(RetentionPolicy.RUNTIME)
12 | @Target(ElementType.TYPE)
13 | public @interface DataGenerator {
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/HasSpecialRenderer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
4 | import net.minecraft.tileentity.TileEntity;
5 |
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | /**
12 | * Created by Elec332 on 13-8-2018.
13 | *
14 | * Used on a {@link TileEntity} to bind the specified {@link TileEntityRenderer} to it.
15 | */
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target(ElementType.TYPE)
18 | public @interface HasSpecialRenderer {
19 |
20 | Class extends TileEntityRenderer>> value();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/IBlockRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraft.block.Block;
4 |
5 | /**
6 | * Created by Elec332 on 12-10-2017.
7 | *
8 | * Block version of {@link IObjectRegister}
9 | */
10 | public interface IBlockRegister extends IObjectRegister {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/IItemRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraft.item.Item;
4 |
5 | /**
6 | * Created by Elec332 on 12-10-2017.
7 | *
8 | * Item version of {@link IObjectRegister}
9 | */
10 | public interface IItemRegister extends IObjectRegister- {
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/IObjectRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraftforge.registries.IForgeRegistry;
4 | import net.minecraftforge.registries.IForgeRegistryEntry;
5 |
6 | /**
7 | * Created by Elec332 on 12-10-2017.
8 | *
9 | * Can be used to register objects to an {@link IForgeRegistry},
10 | * this uses the normal forge events
11 | */
12 | public interface IObjectRegister> {
13 |
14 | default void preRegister() {
15 | }
16 |
17 | void register(IForgeRegistry registry);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/ITileRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraft.tileentity.TileEntityType;
4 |
5 | /**
6 | * Created by Elec332 on 26-12-2019
7 | */
8 | public interface ITileRegister extends IObjectRegister> {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/IWorldGenRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import elec332.core.api.world.IBiomeGenWrapper;
4 | import net.minecraft.world.biome.Biome;
5 | import net.minecraft.world.gen.feature.Feature;
6 | import net.minecraft.world.gen.feature.IFeatureConfig;
7 | import net.minecraft.world.gen.feature.NoFeatureConfig;
8 | import net.minecraft.world.gen.placement.IPlacementConfig;
9 | import net.minecraft.world.gen.placement.NoPlacementConfig;
10 | import net.minecraftforge.registries.IForgeRegistry;
11 |
12 | /**
13 | * Created by Elec332 on 1-1-2019
14 | */
15 | public interface IWorldGenRegister {
16 |
17 | NoFeatureConfig EMPTY_FEATURE_CONFIG = IFeatureConfig.NO_FEATURE_CONFIG;
18 | NoPlacementConfig EMPTY_PLACEMENT_CONFIG = IPlacementConfig.NO_PLACEMENT_CONFIG;
19 |
20 | default void init() {
21 | }
22 |
23 | default void registerFeatures(IForgeRegistry> featureRegistry) {
24 | }
25 |
26 | void configureBiome(Biome biome, IBiomeGenWrapper registry);
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/RegisteredMultiPart.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 8-3-2016.
10 | *
11 | * Used to register multiparts, annotate your multipart class to register it
12 | */
13 | @Retention(RetentionPolicy.RUNTIME)
14 | @Target(ElementType.TYPE)
15 | public @interface RegisteredMultiPart {
16 |
17 | String value();
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registration/RegisteredTileEntity.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registration;
2 |
3 | import net.minecraft.tileentity.TileEntity;
4 | import net.minecraft.tileentity.TileEntityType;
5 |
6 | import java.lang.annotation.ElementType;
7 | import java.lang.annotation.Retention;
8 | import java.lang.annotation.RetentionPolicy;
9 | import java.lang.annotation.Target;
10 |
11 | /**
12 | * Created by Elec332 on 14-1-2016.
13 | *
14 | * Used to register {@link TileEntity}'s, annotate your TileEntity class to register it
15 | */
16 | @Retention(RetentionPolicy.RUNTIME)
17 | @Target({ElementType.TYPE, ElementType.FIELD})
18 | public @interface RegisteredTileEntity {
19 |
20 | String value();
21 |
22 | /**
23 | * Use this to set the mod owner of this tile when auto-detection fails
24 | *
25 | * @return The mod owner
26 | */
27 | String mod() default "";
28 |
29 | /**
30 | * Use this interface if you want the {@link TileEntityType} to be set automatically
31 | */
32 | interface TypeSetter {
33 |
34 | void setTileEntityType(TileEntityType> type);
35 |
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registry/IDualObjectRegistry.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registry;
2 |
3 | import java.util.Map;
4 |
5 | /**
6 | * Created by Elec332 on 16-10-2016.
7 | */
8 | public interface IDualObjectRegistry extends IDualRegister {
9 |
10 | @Override
11 | boolean register(T t, V v);
12 |
13 | Map getAllRegisteredObjects();
14 |
15 | }
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registry/IDualRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registry;
2 |
3 | /**
4 | * Created by Elec332 on 20-10-2016.
5 | */
6 | public interface IDualRegister {
7 |
8 | boolean register(T t, V v);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registry/ISingleObjectRegistry.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registry;
2 |
3 | import java.util.Set;
4 |
5 | /**
6 | * Created by Elec332 on 16-10-2016.
7 | */
8 | public interface ISingleObjectRegistry extends ISingleRegister {
9 |
10 | @Override
11 | boolean register(T t);
12 |
13 | Set getAllRegisteredObjects();
14 |
15 | }
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/registry/ISingleRegister.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.registry;
2 |
3 | /**
4 | * Created by Elec332 on 20-10-2016.
5 | */
6 | public interface ISingleRegister {
7 |
8 | boolean register(T t);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/storage/IExternalSaveHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.storage;
2 |
3 | import net.minecraft.nbt.CompoundNBT;
4 | import net.minecraft.world.storage.IServerConfiguration;
5 | import net.minecraft.world.storage.SaveFormat;
6 |
7 | import javax.annotation.Nullable;
8 |
9 | /**
10 | * Created by Elec332 on 16-7-2016.
11 | */
12 | public interface IExternalSaveHandler {
13 |
14 | String getName();
15 |
16 | /**
17 | * Invoked when the save-data should be loaded from the disk.
18 | */
19 | void load(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag);
20 |
21 | /**
22 | * Invoked when the save-data should be written to the disk.
23 | *
24 | * @return The version at which the data was saved
25 | */
26 | @Nullable
27 | CompoundNBT save(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo);
28 |
29 | default void nullifyData() {
30 | }
31 |
32 | default boolean makeBackups() {
33 | return true;
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/storage/ISimpleExternalSaveHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.storage;
2 |
3 | import net.minecraft.nbt.CompoundNBT;
4 | import net.minecraft.world.storage.IServerConfiguration;
5 | import net.minecraft.world.storage.SaveFormat;
6 |
7 | import java.io.File;
8 |
9 | /**
10 | * Created by Elec332 on 5-7-2016.
11 | */
12 | public interface ISimpleExternalSaveHandler extends IExternalSaveHandler {
13 |
14 | @Override
15 | default void load(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag) {
16 | load(levelSave.getWorldDir().toFile());
17 | }
18 |
19 | @Override
20 | default CompoundNBT save(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo) {
21 | save(levelSave.getWorldDir().toFile());
22 | return null;
23 | }
24 |
25 | /**
26 | * Invoked when the save-data should be loaded from the disk.
27 | *
28 | * @param worldDirectory The world directory
29 | */
30 | void load(File worldDirectory);
31 |
32 | /**
33 | * Invoked when the save-data should be written to the disk.
34 | *
35 | * @param worldDirectory The world directory
36 | */
37 | void save(File worldDirectory);
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/storage/NBTSerializableSaveHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.storage;
2 |
3 | import com.google.common.base.Preconditions;
4 | import elec332.core.api.util.IClearable;
5 | import net.minecraft.nbt.CompoundNBT;
6 | import net.minecraft.world.storage.IServerConfiguration;
7 | import net.minecraft.world.storage.SaveFormat;
8 | import net.minecraftforge.common.util.INBTSerializable;
9 |
10 | import javax.annotation.Nullable;
11 |
12 | /**
13 | * Created by Elec332 on 22-10-2016.
14 | */
15 | public class NBTSerializableSaveHandler implements IExternalSaveHandler {
16 |
17 | public NBTSerializableSaveHandler(String name, INBTSerializable nbtSerializable) {
18 | this.name = Preconditions.checkNotNull(name);
19 | this.nbtSerializable = Preconditions.checkNotNull(nbtSerializable);
20 | this.clearable = nbtSerializable instanceof IClearable ? (IClearable) nbtSerializable : null;
21 | }
22 |
23 | private final INBTSerializable nbtSerializable;
24 | private final IClearable clearable;
25 | private final String name;
26 |
27 | @Override
28 | public String getName() {
29 | return this.name;
30 | }
31 |
32 | @Override
33 | public void load(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag) {
34 | nbtSerializable.deserializeNBT(tag);
35 | }
36 |
37 | @Nullable
38 | @Override
39 | public CompoundNBT save(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo) {
40 | return nbtSerializable.serializeNBT();
41 | }
42 |
43 | @Override
44 | public void nullifyData() {
45 | if (clearable != null) {
46 | clearable.clear();
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/storage/SaveHandlerWrapper.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.storage;
2 |
3 | import net.minecraft.nbt.CompoundNBT;
4 | import net.minecraft.world.storage.IServerConfiguration;
5 | import net.minecraft.world.storage.SaveFormat;
6 |
7 | import javax.annotation.Nullable;
8 |
9 | /**
10 | * Created by Elec332 on 22-10-2016.
11 | */
12 | public class SaveHandlerWrapper implements IExternalSaveHandler {
13 |
14 | public static SaveHandlerWrapper wrap(String name, IExternalSaveHandler... handlers) {
15 | return new SaveHandlerWrapper(name, handlers);
16 | }
17 |
18 | private SaveHandlerWrapper(String name, IExternalSaveHandler[] saveHandlers) {
19 | this.saveHandlers = saveHandlers;
20 | this.name = name;
21 | }
22 |
23 | private final IExternalSaveHandler[] saveHandlers;
24 | private final String name;
25 |
26 | @Override
27 | public String getName() {
28 | return this.name;
29 | }
30 |
31 | @Override
32 | public void load(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo, CompoundNBT tag) {
33 | for (IExternalSaveHandler saveHandler1 : saveHandlers) {
34 | saveHandler1.load(levelSave, serverInfo, tag.getCompound(saveHandler1.getName()));
35 | }
36 | }
37 |
38 | @Nullable
39 | @Override
40 | public CompoundNBT save(SaveFormat.LevelSave levelSave, IServerConfiguration serverInfo) {
41 | CompoundNBT ret = new CompoundNBT();
42 | for (IExternalSaveHandler saveHandler1 : saveHandlers) {
43 | CompoundNBT tag = saveHandler1.save(levelSave, serverInfo);
44 | if (tag != null) {
45 | ret.put(saveHandler1.getName(), tag);
46 | }
47 | }
48 | return ret;
49 | }
50 |
51 | @Override
52 | public void nullifyData() {
53 | for (IExternalSaveHandler saveHandler : saveHandlers) {
54 | saveHandler.nullifyData();
55 | }
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/structure/GenerationType.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.structure;
2 |
3 | /**
4 | * Used to determine where a structure can be generated
5 | */
6 | public enum GenerationType {
7 |
8 | SURFACE,
9 | SEA_LEVEL,
10 | UNDERGROUND,
11 | NONE
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/util/IClearable.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.util;
2 |
3 | /**
4 | * Created by Elec332 on 23-10-2016.
5 | */
6 | public interface IClearable {
7 |
8 | void clear();
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/util/IEntityFilter.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.util;
2 |
3 | import net.minecraft.entity.Entity;
4 |
5 | import java.util.List;
6 | import java.util.function.Predicate;
7 | import java.util.stream.Collectors;
8 |
9 | /**
10 | * Created by Elec332 on 25-10-2016.
11 | *
12 | * Entity filter
13 | */
14 | public interface IEntityFilter
{
15 |
16 | List
filterEntities(List
toFilter);
17 |
18 | static IEntityFilter of(Predicate predicate) {
19 | return toFilter -> toFilter.stream().filter(predicate).collect(Collectors.toList());
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/util/IMemberPointer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.util;
2 |
3 | import java.lang.annotation.Annotation;
4 | import java.lang.reflect.AccessibleObject;
5 | import java.lang.reflect.Member;
6 |
7 | /**
8 | * Created by Elec332 on 2-1-2019
9 | */
10 | public interface IMemberPointer {
11 |
12 | @SuppressWarnings("unchecked")
13 | default Class getParentType() {
14 | return (Class
) getReflectedMember().getDeclaringClass();
15 | }
16 |
17 | Class getType();
18 |
19 | default String getName() {
20 | return getReflectedMember().getName();
21 | }
22 |
23 | boolean isStatic();
24 |
25 | default A getAnnotation(Class annotation) {
26 | return getReflectedMember().getAnnotation(annotation);
27 | }
28 |
29 | M getReflectedMember();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/util/IRightClickCancel.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.util;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | /**
6 | * Created by Elec332 on 30-4-2015.
7 | */
8 | public interface IRightClickCancel {
9 |
10 | default boolean cancelInteraction(ItemStack stack) {
11 | return true;
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/util/ISimpleResourcePack.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.util;
2 |
3 | import net.minecraft.resources.ResourcePackType;
4 | import net.minecraft.util.ResourceLocation;
5 |
6 | import javax.annotation.Nonnull;
7 | import java.io.InputStream;
8 |
9 | /**
10 | * Created by Elec332 on 20-8-2020
11 | */
12 | public interface ISimpleResourcePack {
13 |
14 | InputStream getResourceStream(@Nonnull ResourcePackType type, @Nonnull ResourceLocation location);
15 |
16 | boolean resourceExists(@Nonnull ResourcePackType type, @Nonnull ResourceLocation location);
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/world/IChunkIOHook.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.world;
2 |
3 | import net.minecraft.nbt.CompoundNBT;
4 | import net.minecraft.world.chunk.IChunk;
5 |
6 | /**
7 | * Created by Elec332 on 1-1-2019
8 | */
9 | public interface IChunkIOHook {
10 |
11 | void chunkLoadedFromDisk(IChunk chunk, CompoundNBT data, IWorldGenManager worldGenManager);
12 |
13 | void chunkSavedToDisk(IChunk chunk, CompoundNBT data, IWorldGenManager worldGenManager);
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/world/IRetroGenFeature.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.world;
2 |
3 | import net.minecraft.world.gen.feature.IFeatureConfig;
4 |
5 | /**
6 | * Created by Elec332 on 10-7-2020
7 | */
8 | public interface IRetroGenFeature {
9 |
10 | String DEFAULT_GENERATED_KEY = "generated";
11 |
12 | String getName(C config);
13 |
14 | default String getGenKey(C config) {
15 | return DEFAULT_GENERATED_KEY;
16 | }
17 |
18 | default boolean shouldRetroGen(boolean hasInitialGen, C config) {
19 | return !hasInitialGen;
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/world/IRetroGenFeatureConfig.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.world;
2 |
3 | import net.minecraft.world.gen.feature.IFeatureConfig;
4 |
5 | /**
6 | * Created by Elec332 on 1-1-2019
7 | */
8 | public interface IRetroGenFeatureConfig extends IFeatureConfig {
9 |
10 | String getName();
11 |
12 | default String getGenKey() {
13 | return "generated";
14 | }
15 |
16 | default boolean shouldRetroGen(boolean hasInitialGen) {
17 | return !hasInitialGen;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/world/IWorldEventHook.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.world;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.util.math.BlockPos;
5 | import net.minecraft.world.IWorld;
6 |
7 | /**
8 | * Created by Elec332 on 30-6-2020
9 | */
10 | public interface IWorldEventHook {
11 |
12 | void markBlockChanged(IWorld world, BlockPos pos, BlockState oldState, BlockState newState);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/world/RetroGenFeatureWrapper.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.world;
2 |
3 | import com.mojang.serialization.Codec;
4 | import net.minecraft.util.ResourceLocation;
5 | import net.minecraft.util.math.BlockPos;
6 | import net.minecraft.world.ISeedReader;
7 | import net.minecraft.world.gen.ChunkGenerator;
8 | import net.minecraft.world.gen.feature.Feature;
9 | import net.minecraft.world.gen.feature.IFeatureConfig;
10 |
11 | import javax.annotation.Nonnull;
12 | import java.util.Random;
13 | import java.util.function.Function;
14 |
15 | /**
16 | * Created by Elec332 on 10-7-2020
17 | */
18 | public class RetroGenFeatureWrapper extends Feature implements IRetroGenFeature {
19 |
20 | public RetroGenFeatureWrapper(Feature parent, Codec codec, ResourceLocation name) {
21 | this(parent, codec, c -> name.toString());
22 | setRegistryName(name);
23 | }
24 |
25 | public RetroGenFeatureWrapper(Feature parent, Codec codec, Function namer) {
26 | super(codec);
27 | this.parent = parent;
28 | this.namer = namer;
29 | }
30 |
31 | private final Feature parent;
32 | private final Function namer;
33 |
34 | @Override
35 | public boolean func_241855_a(@Nonnull ISeedReader worldIn, @Nonnull ChunkGenerator generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull C config) {
36 | return parent.func_241855_a(worldIn, generator, rand, pos, config);
37 | }
38 |
39 | @Override
40 | public String getName(C config) {
41 | return namer.apply(config);
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/wrench/IRotatable.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.wrench;
2 |
3 | import net.minecraft.util.Direction;
4 | import net.minecraft.util.math.BlockPos;
5 | import net.minecraft.world.World;
6 |
7 | /**
8 | * Created by Elec332 on 7-2-2015.
9 | */
10 | public interface IRotatable {
11 |
12 | Direction getFacing();
13 |
14 | boolean rotateBlock(World world, BlockPos pos, Direction sideHit);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/api/wrench/IWrenchable.java:
--------------------------------------------------------------------------------
1 | package elec332.core.api.wrench;
2 |
3 | import net.minecraft.item.ItemStack;
4 | import net.minecraft.util.Direction;
5 | import net.minecraft.util.math.BlockPos;
6 | import net.minecraft.world.World;
7 |
8 | /**
9 | * Created by Elec332 on 5-2-2015.
10 | */
11 | public interface IWrenchable {
12 |
13 | ItemStack itemDropped(World world, BlockPos pos);
14 |
15 | boolean onWrenched(World world, BlockPos pos, Direction direction);
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/block/AbstractLegacyBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.block;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.entity.player.PlayerEntity;
5 | import net.minecraft.util.ActionResultType;
6 | import net.minecraft.util.Hand;
7 | import net.minecraft.util.math.BlockPos;
8 | import net.minecraft.util.math.BlockRayTraceResult;
9 | import net.minecraft.world.World;
10 |
11 | /**
12 | * Created by Elec332 on 6-7-2020
13 | */
14 | public class AbstractLegacyBlock extends AbstractBlock {
15 |
16 | public AbstractLegacyBlock(Properties builder) {
17 | super(builder);
18 | }
19 |
20 | @Override
21 | public final ActionResultType onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
22 | return onBlockActivatedLegacy(world, pos, state, player, hand, hit) ? ActionResultType.SUCCESS : ActionResultType.PASS;
23 | }
24 |
25 | public boolean onBlockActivatedLegacy(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
26 | return super.onBlockActivated(world, pos, state, player, hand, hit) == ActionResultType.SUCCESS;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/block/BlockMethods.java:
--------------------------------------------------------------------------------
1 | package elec332.core.block;
2 |
3 | import elec332.core.util.PlayerHelper;
4 | import net.minecraft.block.Block;
5 | import net.minecraft.block.BlockState;
6 | import net.minecraft.entity.player.PlayerEntity;
7 | import net.minecraft.fluid.FluidState;
8 | import net.minecraft.util.ActionResultType;
9 | import net.minecraft.util.Hand;
10 | import net.minecraft.util.math.BlockPos;
11 | import net.minecraft.util.math.BlockRayTraceResult;
12 | import net.minecraft.world.World;
13 |
14 | import javax.annotation.Nonnull;
15 |
16 | /**
17 | * Created by Elec332 on 29-12-2018
18 | */
19 | public final class BlockMethods {
20 |
21 | @SuppressWarnings("all")
22 | public static String createUnlocalizedName(B block) {
23 | return "tile." + block.getRegistryName().toString().replace(":", ".").toLowerCase();
24 | }
25 |
26 | public static ActionResultType onBlockActivated(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockRayTraceResult hit, B block) {
27 | return hit != null ? block.onBlockActivated(world, pos, state, player, hand, hit) : ActionResultType.PASS;
28 | }
29 |
30 | public static boolean removedByPlayer(@Nonnull BlockState state, World world, @Nonnull BlockPos pos, @Nonnull PlayerEntity player, boolean willHarvest, FluidState fluid, B block) {
31 | if (!block.canBreak(world, pos, player)) {
32 | if (PlayerHelper.isPlayerInCreative(player)) {
33 | block.onBlockClicked(state, world, pos, player);
34 | }
35 | return false;
36 | }
37 | block.onBlockHarvested(world, pos, state, player);
38 | return world.setBlockState(pos, fluid.getBlockState(), world.isRemote ? 11 : 3);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/block/IAbstractBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.block;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.entity.Entity;
5 | import net.minecraft.entity.player.PlayerEntity;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraft.loot.LootContext;
8 | import net.minecraft.tileentity.TileEntity;
9 | import net.minecraft.util.ActionResultType;
10 | import net.minecraft.util.Hand;
11 | import net.minecraft.util.math.AxisAlignedBB;
12 | import net.minecraft.util.math.BlockPos;
13 | import net.minecraft.util.math.BlockRayTraceResult;
14 | import net.minecraft.world.IBlockReader;
15 | import net.minecraft.world.World;
16 |
17 | import javax.annotation.Nonnull;
18 | import java.util.List;
19 |
20 | /**
21 | * Created by Elec332 on 29-12-2018
22 | */
23 | public interface IAbstractBlock {
24 |
25 | default void addSelectionBoxes(BlockState state, World world, BlockPos pos, List boxes) {
26 | boxes.add(state.getShape(world, pos).getBoundingBox());
27 | }
28 |
29 | default ActionResultType onBlockActivated(World world, BlockPos pos, BlockState state, PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
30 | return ActionResultType.PASS;
31 | }
32 |
33 | default boolean canBreak(World world, BlockPos pos, PlayerEntity player) {
34 | return true;
35 | }
36 |
37 | @SuppressWarnings("unchecked")
38 | default T getTileEntity(IBlockReader world, BlockPos pos) {
39 | return (T) world.getTileEntity(pos);
40 | }
41 |
42 | default T getTileEntity(IBlockReader world, BlockPos pos, Class type) {
43 | return getTileEntity(world, pos);
44 | }
45 |
46 | default List getDrops(List drops, @Nonnull LootContext.Builder builder, Entity entity, World world, BlockPos pos, @Nonnull BlockState state, ItemStack stack) {
47 | return drops;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/block/ISelectionBoxOverride.java:
--------------------------------------------------------------------------------
1 | package elec332.core.block;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.entity.player.PlayerEntity;
5 | import net.minecraft.util.math.BlockPos;
6 | import net.minecraft.util.math.RayTraceResult;
7 | import net.minecraft.util.math.shapes.VoxelShape;
8 | import net.minecraft.world.IWorld;
9 |
10 | /**
11 | * Created by Elec332 on 1-2-2019
12 | */
13 | public interface ISelectionBoxOverride {
14 |
15 | default public VoxelShape getSelectionBox(BlockState state, IWorld world, BlockPos pos, PlayerEntity player, RayTraceResult hit) {
16 | return state.getShape(world, pos);
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/ModelProperties.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model;
2 |
3 | import net.minecraft.util.math.BlockPos;
4 | import net.minecraft.world.IBlockDisplayReader;
5 | import net.minecraftforge.client.model.data.ModelProperty;
6 |
7 | /**
8 | * Created by Elec332 on 3-1-2020
9 | */
10 | public class ModelProperties {
11 |
12 | public static final ModelProperty WORLD = new ModelProperty<>();
13 | public static final ModelProperty POS = new ModelProperty<>();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/SimpleModelCache.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model;
2 |
3 | import net.minecraft.block.BlockState;
4 | import net.minecraft.client.renderer.model.BakedQuad;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraft.util.Direction;
7 | import net.minecraft.util.ResourceLocation;
8 | import net.minecraft.util.math.BlockPos;
9 | import net.minecraft.world.IBlockDisplayReader;
10 | import net.minecraftforge.client.model.data.IModelData;
11 | import net.minecraftforge.client.model.data.ModelProperty;
12 |
13 | import javax.annotation.Nonnull;
14 | import java.util.List;
15 |
16 | /**
17 | * Created by Elec332 on 28-7-2020
18 | */
19 | public abstract class SimpleModelCache extends ModelCache {
20 |
21 | public SimpleModelCache(ResourceLocation particle) {
22 | this.particle = particle;
23 | property = new ModelProperty<>();
24 | }
25 |
26 | private final ModelProperty property;
27 | private final ResourceLocation particle;
28 |
29 | @Override
30 | protected final K get(BlockState state, IModelData modelState) {
31 | return modelState.getData(property);
32 | }
33 |
34 | @Override
35 | protected abstract K get(ItemStack stack);
36 |
37 | @Override
38 | public final void addModelData(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData modelData) {
39 | modelData.setData(property, get(world, pos, state));
40 | }
41 |
42 | protected abstract K get(@Nonnull IBlockDisplayReader world, @Nonnull BlockPos pos, @Nonnull BlockState state);
43 |
44 | @Override
45 | protected abstract void bakeQuads(List quads, Direction side, K key);
46 |
47 | @Nonnull
48 | @Override
49 | protected ResourceLocation getTextureLocation() {
50 | return particle;
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/legacy/AbstractLegacyTileEntityRenderer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.legacy;
2 |
3 | import com.mojang.blaze3d.matrix.MatrixStack;
4 | import elec332.core.api.client.IRenderMatrix;
5 | import elec332.core.client.util.AbstractTileEntityRenderer;
6 | import net.minecraft.client.renderer.IRenderTypeBuffer;
7 | import net.minecraft.tileentity.TileEntity;
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * Created by Elec332 on 6-7-2020
13 | */
14 | public abstract class AbstractLegacyTileEntityRenderer extends AbstractTileEntityRenderer {
15 |
16 | @Override
17 | public void render(@Nonnull T tileEntityIn, float partialTicks, @Nonnull MatrixStack matrixStackIn, @Nonnull IRenderTypeBuffer bufferIn, int combinedLightIn, int combinedOverlayIn) {
18 | render(tileEntityIn, partialTicks, CompatRenderMatrix.wrap(matrixStackIn, bufferIn, combinedLightIn, combinedOverlayIn));
19 | }
20 |
21 | public abstract void render(T tile, float partialTicks, IRenderMatrix renderMatrix);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/legacy/LegacyTextureLocation.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.legacy;
2 |
3 | import com.google.common.base.Preconditions;
4 | import elec332.core.api.client.ITextureLocation;
5 | import elec332.core.client.RenderHelper;
6 | import net.minecraft.client.renderer.RenderType;
7 | import net.minecraft.util.ResourceLocation;
8 |
9 | /**
10 | * Created by Elec332 on 6-7-2020
11 | */
12 | public class LegacyTextureLocation implements ITextureLocation {
13 |
14 | public LegacyTextureLocation(ResourceLocation location) {
15 | this.tex = Preconditions.checkNotNull(location);
16 | this.renderType = RenderHelper.createRenderType("ctiv_render_type", RenderType.getCutout(), location);
17 | }
18 |
19 | private final ResourceLocation tex;
20 | private final RenderType renderType;
21 |
22 | @Override
23 | public ResourceLocation getTextureLocation() {
24 | return tex;
25 | }
26 |
27 | public RenderType getRenderType() {
28 | return renderType;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/loading/IBlockModelItemLink.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.loading;
2 |
3 | import net.minecraft.block.Block;
4 | import net.minecraft.block.BlockState;
5 | import net.minecraft.item.ItemStack;
6 |
7 | /**
8 | * Created by Elec332 on 22-3-2017.
9 | */
10 | public interface IBlockModelItemLink {
11 |
12 | default BlockState getRenderState(ItemStack s) {
13 | return ((Block) this).getDefaultState();
14 | }
15 |
16 | default boolean itemInheritsModel() {
17 | return true;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/loading/INoJsonBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.loading;
2 |
3 | import elec332.core.api.client.model.IModelAndTextureLoader;
4 | import net.minecraft.block.BlockState;
5 | import net.minecraft.client.renderer.model.IBakedModel;
6 | import net.minecraftforge.api.distmarker.Dist;
7 | import net.minecraftforge.api.distmarker.OnlyIn;
8 |
9 | /**
10 | * Created by Elec332 on 15-11-2015.
11 | */
12 | public interface INoJsonBlock extends IModelAndTextureLoader {
13 |
14 | /**
15 | * This method is used when a model is requested for every valid BlockState,
16 | * during the initialisation of the ModelRegistry.
17 | *
18 | * @param state The current BlockState, can NOT be an ExtendedBlockState.
19 | * @return The model to render for this block for the given arguments.
20 | */
21 | @OnlyIn(Dist.CLIENT)
22 | public IBakedModel getBlockModel(BlockState state);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/loading/INoJsonItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.loading;
2 |
3 | import elec332.core.api.client.model.IModelAndTextureLoader;
4 | import net.minecraft.client.renderer.model.IBakedModel;
5 | import net.minecraft.entity.LivingEntity;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraft.world.World;
8 | import net.minecraftforge.api.distmarker.Dist;
9 | import net.minecraftforge.api.distmarker.OnlyIn;
10 |
11 | /**
12 | * Created by Elec332 on 19-11-2015.
13 | */
14 | public interface INoJsonItem extends IModelAndTextureLoader {
15 |
16 | @OnlyIn(Dist.CLIENT)
17 | public IBakedModel getItemModel(ItemStack stack, World world, LivingEntity entity);
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/loading/handler/INoJsonBlockHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.loading.handler;
2 |
3 | import elec332.core.api.client.model.loading.IBlockModelHandler;
4 | import elec332.core.api.client.model.loading.ModelHandler;
5 | import elec332.core.client.model.loading.INoJsonBlock;
6 | import net.minecraft.block.Block;
7 | import net.minecraft.block.BlockState;
8 | import net.minecraft.client.renderer.model.IBakedModel;
9 | import net.minecraft.client.renderer.model.ModelResourceLocation;
10 | import net.minecraftforge.api.distmarker.Dist;
11 | import net.minecraftforge.api.distmarker.OnlyIn;
12 |
13 | /**
14 | * Created by Elec332 on 12-3-2016.
15 | */
16 | @ModelHandler
17 | @OnlyIn(Dist.CLIENT)
18 | public class INoJsonBlockHandler implements IBlockModelHandler {
19 |
20 | @Override
21 | public boolean handleBlock(Block block) {
22 | return block instanceof INoJsonBlock;
23 | }
24 |
25 | @Override
26 | public IBakedModel getModelFor(BlockState state, String identifier, ModelResourceLocation fullResourceLocation) {
27 | return ((INoJsonBlock) state.getBlock()).getBlockModel(state);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/model/AbstractBlockModel.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.model;
2 |
3 | import com.google.common.collect.ImmutableList;
4 | import elec332.core.api.client.model.model.IModelWithoutQuads;
5 | import elec332.core.client.RenderHelper;
6 | import elec332.core.client.model.ElecModelBakery;
7 | import net.minecraft.client.renderer.model.BakedQuad;
8 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
9 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
10 | import net.minecraft.util.ResourceLocation;
11 | import net.minecraftforge.api.distmarker.Dist;
12 | import net.minecraftforge.api.distmarker.OnlyIn;
13 |
14 | /**
15 | * Created by Elec332 on 15-11-2015.
16 | */
17 | @OnlyIn(Dist.CLIENT)
18 | @SuppressWarnings({"deprecation", "unused"})
19 | public abstract class AbstractBlockModel implements IModelWithoutQuads {
20 |
21 | private static final ImmutableList EMPTY_LIST;
22 |
23 | @Override
24 | public boolean isAmbientOcclusion() {
25 | return true;
26 | }
27 |
28 | @Override
29 | public boolean isGui3d() {
30 | return true;
31 | }
32 |
33 | @Override
34 | public boolean isBuiltInRenderer() {
35 | return false;
36 | }
37 |
38 | @Override
39 | public TextureAtlasSprite getParticleTexture() {
40 | return RenderHelper.getBlockTextures().getSprite(getTextureLocation());
41 | }
42 |
43 | public abstract ResourceLocation getTextureLocation();
44 |
45 | @Override
46 | public ItemCameraTransforms getItemCameraTransforms() {
47 | return ElecModelBakery.DEFAULT_BLOCK;
48 | }
49 |
50 | static {
51 | EMPTY_LIST = ImmutableList.of();
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/model/renderer/AbstractModel.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.model.renderer;
2 |
3 | import com.google.common.collect.Lists;
4 | import com.mojang.blaze3d.matrix.MatrixStack;
5 | import com.mojang.blaze3d.vertex.IVertexBuilder;
6 | import elec332.core.api.client.IRenderMatrix;
7 | import elec332.core.client.model.legacy.CompatRenderMatrix;
8 | import net.minecraft.client.renderer.model.Model;
9 | import net.minecraft.client.renderer.model.ModelRenderer;
10 |
11 | import javax.annotation.Nonnull;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by Elec332 on 6-7-2020
16 | */
17 | public class AbstractModel extends Model {
18 |
19 | public AbstractModel() {
20 | super(null);
21 | this.models = Lists.newArrayList();
22 | }
23 |
24 | private final List models;
25 |
26 | @Override
27 | public void accept(@Nonnull ModelRenderer modelPart) {
28 | models.add(modelPart);
29 | }
30 |
31 | public void render(@Nonnull IRenderMatrix matrixStack, int light, int overlayTexture, float r, float g, float b, float a) {
32 | CompatRenderMatrix compat = CompatRenderMatrix.unWrap(matrixStack);
33 | render(compat.getStack(), compat.getVertexBuilder(), light, overlayTexture, r, g, b, a);
34 | }
35 |
36 | @Override
37 | public void render(@Nonnull MatrixStack matrixStackIn, @Nonnull IVertexBuilder bufferIn, int packedLightIn, int packedOverlayIn, float red, float green, float blue, float alpha) {
38 | for (ModelRenderer model : models) {
39 | model.render(matrixStackIn, bufferIn, packedLightIn, packedOverlayIn, red, green, blue, alpha);
40 | }
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/util/AbstractItemOverrideList.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.util;
2 |
3 | import net.minecraft.client.renderer.model.IBakedModel;
4 | import net.minecraft.client.renderer.model.ItemOverrideList;
5 | import net.minecraft.client.world.ClientWorld;
6 | import net.minecraft.entity.LivingEntity;
7 | import net.minecraft.item.ItemStack;
8 | import net.minecraft.world.World;
9 |
10 | import javax.annotation.Nonnull;
11 | import javax.annotation.Nullable;
12 |
13 | /**
14 | * Created by Elec332 on 19-1-2020
15 | */
16 | public abstract class AbstractItemOverrideList extends ItemOverrideList {
17 |
18 | @Nullable
19 | @Override
20 | public IBakedModel func_239290_a_(@Nonnull IBakedModel model, @Nonnull ItemStack stack, @Nullable ClientWorld worldIn, @Nullable LivingEntity entityIn) {
21 | return getModel(model, stack, worldIn, entityIn);
22 | }
23 |
24 | @Nullable
25 | protected abstract IBakedModel getModel(@Nonnull IBakedModel model, @Nonnull ItemStack stack, @Nullable World world, @Nullable LivingEntity entity);
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/util/AbstractTileEntityItemStackRenderer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.util;
2 |
3 | import com.mojang.blaze3d.matrix.MatrixStack;
4 | import net.minecraft.client.renderer.IRenderTypeBuffer;
5 | import net.minecraft.client.renderer.model.ItemCameraTransforms;
6 | import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
7 | import net.minecraft.item.ItemStack;
8 |
9 | import javax.annotation.Nonnull;
10 |
11 | /**
12 | * Created by Elec332 on 23-12-2019
13 | */
14 | public abstract class AbstractTileEntityItemStackRenderer extends ItemStackTileEntityRenderer {
15 |
16 | @Override
17 | public void func_239207_a_(@Nonnull ItemStack stack, @Nonnull ItemCameraTransforms.TransformType transformType, @Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn) {
18 | renderItem(stack, matrixStack, renderTypeBuffer, combinedLightIn, combinedOverlayIn);
19 | }
20 |
21 | protected abstract void renderItem(@Nonnull ItemStack stack, @Nonnull MatrixStack matrixStack, @Nonnull IRenderTypeBuffer renderTypeBuffer, int combinedLightIn, int combinedOverlayIn);
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/util/AbstractTileEntityRenderer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.util;
2 |
3 | import net.minecraft.client.renderer.tileentity.TileEntityRenderer;
4 | import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
5 | import net.minecraft.tileentity.TileEntity;
6 |
7 | /**
8 | * Created by Elec332 on 29-6-2020
9 | */
10 | public abstract class AbstractTileEntityRenderer extends TileEntityRenderer {
11 |
12 | public AbstractTileEntityRenderer() {
13 | super(TileEntityRendererDispatcher.instance);
14 | }
15 |
16 | public AbstractTileEntityRenderer(TileEntityRendererDispatcher rendererDispatcherIn) {
17 | super(rendererDispatcherIn);
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/util/SimpleModelTransform.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.util;
2 |
3 | import net.minecraft.client.renderer.model.IModelTransform;
4 | import net.minecraft.util.math.vector.TransformationMatrix;
5 |
6 | /**
7 | * Created by Elec332 on 28-6-2020
8 | */
9 | public class SimpleModelTransform implements IModelTransform {
10 |
11 | public SimpleModelTransform(TransformationMatrix matrix, boolean uvLock) {
12 | this.matrix = matrix;
13 | this.uvLock = uvLock;
14 | }
15 |
16 | private final TransformationMatrix matrix;
17 | private final boolean uvLock;
18 |
19 | @Override
20 | public TransformationMatrix getRotation() {
21 | return this.matrix;
22 | }
23 |
24 | @Override
25 | public TransformationMatrix getPartTransformation(Object part) {
26 | return getRotation();
27 | }
28 |
29 | @Override
30 | public boolean isUvLock() {
31 | return this.uvLock;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/client/util/WrappedUnbakedModel.java:
--------------------------------------------------------------------------------
1 | package elec332.core.client.util;
2 |
3 | import com.mojang.datafixers.util.Pair;
4 | import net.minecraft.client.renderer.model.*;
5 | import net.minecraft.client.renderer.texture.TextureAtlasSprite;
6 | import net.minecraft.util.ResourceLocation;
7 |
8 | import javax.annotation.Nonnull;
9 | import javax.annotation.Nullable;
10 | import java.util.Collection;
11 | import java.util.Set;
12 | import java.util.function.Function;
13 |
14 | /**
15 | * Created by Elec332 on 3-1-2020
16 | */
17 | public class WrappedUnbakedModel implements IUnbakedModel {
18 |
19 | public WrappedUnbakedModel(IUnbakedModel base) {
20 | this.base = base;
21 | }
22 |
23 | protected final IUnbakedModel base;
24 |
25 | @Nonnull
26 | @Override
27 | public Collection getDependencies() {
28 | return base.getDependencies();
29 | }
30 |
31 | @Nonnull
32 | @Override
33 | public Collection getTextures(@Nonnull Function modelGetter, @Nonnull Set> missingTextureErrors) {
34 | return base.getTextures(modelGetter, missingTextureErrors);
35 | }
36 |
37 | @Nullable
38 | @Override
39 | public IBakedModel bakeModel(@Nonnull ModelBakery modelBakeryIn, @Nonnull Function spriteGetterIn, @Nonnull IModelTransform transformIn, @Nonnull ResourceLocation locationIn) {
40 | return base.bakeModel(modelBakeryIn, spriteGetterIn, transformIn, locationIn);
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/ModNames.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat;
2 |
3 | import elec332.core.ElecCore;
4 | import net.minecraftforge.common.ForgeMod;
5 |
6 | /**
7 | * Created by Elec332 on 17-11-2016.
8 | */
9 | public class ModNames {
10 |
11 | public static final String FORGE = ForgeMod.getInstance().getModId();
12 | public static final String ELECCORE = ElecCore.MODID;
13 | public static final String WAILA = "waila";
14 | public static final String FORESTRY = "forestry";
15 | public static final String THE_ONE_PROBE = "theoneprobe";
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/jei/IHasSpecialSubtypes.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat.jei;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | import javax.annotation.Nonnull;
6 |
7 | /**
8 | * Created by Elec332 on 5-1-2020
9 | */
10 | public interface IHasSpecialSubtypes {
11 |
12 | public String getIdentifier(@Nonnull ItemStack stack);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/top/TOPCompatHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat.top;
2 |
3 | import com.google.common.base.Function;
4 | import elec332.core.ElecCore;
5 | import elec332.core.api.module.ElecModule;
6 | import elec332.core.compat.ModNames;
7 | import mcjty.theoneprobe.api.ITheOneProbe;
8 | import net.minecraftforge.fml.InterModComms;
9 | import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
10 |
11 | import javax.annotation.Nullable;
12 |
13 | /**
14 | * Created by Elec332 on 19-1-2020
15 | */
16 | @ElecModule(owner = ElecCore.MODID, name = "TOPCompat", modDependencies = ModNames.THE_ONE_PROBE)
17 | public class TOPCompatHandler implements Function { //Function and not a Consumer... :/
18 |
19 | @ElecModule.EventHandler
20 | public void afterModLoad(FMLCommonSetupEvent event) {
21 | InterModComms.sendTo(ModNames.THE_ONE_PROBE, "getTheOneProbe", () -> this);
22 | }
23 |
24 | @Nullable
25 | @Override
26 | public Void apply(@Nullable ITheOneProbe input) {
27 | if (input == null) {
28 | throw new IllegalArgumentException();
29 | }
30 | input.registerProvider(new TOPHandlerBlock());
31 | input.registerEntityProvider(new TOPHandlerEntity());
32 | return null;
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/top/TOPInformationType.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat.top;
2 |
3 | import elec332.core.api.info.IInformation;
4 | import elec332.core.api.info.InfoMod;
5 | import mcjty.theoneprobe.api.IProbeInfo;
6 | import mcjty.theoneprobe.api.ProbeMode;
7 | import net.minecraft.util.text.ITextComponent;
8 |
9 | import javax.annotation.Nonnull;
10 | import javax.annotation.Nullable;
11 |
12 | /**
13 | * Created by Elec332 on 19-1-2020
14 | */
15 | public class TOPInformationType implements IInformation {
16 |
17 | public TOPInformationType(ProbeMode probeMode, IProbeInfo info) {
18 | this.probeMode = probeMode;
19 | this.info = info;
20 | }
21 |
22 | private final ProbeMode probeMode;
23 | private final IProbeInfo info;
24 |
25 | @Nonnull
26 | @Override
27 | public InfoMod getProviderType() {
28 | return InfoMod.TOP;
29 | }
30 |
31 | @Override
32 | public void addInformation(@Nonnull ITextComponent text) {
33 | info.text(text);
34 | }
35 |
36 | @Nonnull
37 | @Override
38 | public Object getInformationComponent() {
39 | return info;
40 | }
41 |
42 | @Nullable
43 | @Override
44 | public Boolean isDebugMode() {
45 | return probeMode == ProbeMode.DEBUG;
46 | }
47 |
48 | @Nullable
49 | @Override
50 | public Boolean isExtendedMode() {
51 | return probeMode == ProbeMode.EXTENDED;
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/waila/WailaCompatHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat.waila;
2 |
3 | import elec332.core.ElecCore;
4 | import elec332.core.api.module.ElecModule;
5 | import elec332.core.compat.ModNames;
6 | import mcp.mobius.waila.api.IRegistrar;
7 | import mcp.mobius.waila.api.IWailaPlugin;
8 | import mcp.mobius.waila.api.TooltipPosition;
9 | import mcp.mobius.waila.api.WailaPlugin;
10 | import net.minecraft.block.Block;
11 | import net.minecraft.entity.Entity;
12 | import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
13 |
14 | /**
15 | * Created by Elec332 on 15-8-2015.
16 | */
17 | @WailaPlugin
18 | @ElecModule(owner = ElecCore.MODID, name = "WailaCompat", modDependencies = ModNames.WAILA)
19 | public class WailaCompatHandler implements IWailaPlugin {
20 |
21 | private static IRegistrar registrar = null;
22 | private static boolean enabled;
23 |
24 | @ElecModule.EventHandler
25 | public void afterModLoad(FMLCommonSetupEvent event) {
26 | WailaCompatHandler.enabled = true;
27 | }
28 |
29 | @Override
30 | public void register(IRegistrar registrar) {
31 | if (enabled && WailaCompatHandler.registrar == null) {
32 | WailaHandlerBlock teh = new WailaHandlerBlock();
33 | WailaHandlerEntity eh = new WailaHandlerEntity();
34 | registrar.registerBlockDataProvider(teh, Block.class);
35 | registrar.registerComponentProvider(teh, TooltipPosition.BODY, Block.class);
36 | registrar.registerEntityDataProvider(eh, Entity.class);
37 | registrar.registerComponentProvider(eh, TooltipPosition.BODY, Entity.class);
38 | }
39 | WailaCompatHandler.registrar = registrar;
40 | }
41 |
42 | }
--------------------------------------------------------------------------------
/src/main/java/elec332/core/compat/waila/WailaInformationType.java:
--------------------------------------------------------------------------------
1 | package elec332.core.compat.waila;
2 |
3 | import com.google.common.base.Preconditions;
4 | import elec332.core.api.info.IInformation;
5 | import elec332.core.api.info.InfoMod;
6 | import net.minecraft.util.text.ITextComponent;
7 |
8 | import javax.annotation.Nonnull;
9 | import java.util.List;
10 |
11 | /**
12 | * Created by Elec332 on 19-2-2019
13 | */
14 | public class WailaInformationType implements IInformation {
15 |
16 | public WailaInformationType(List tooltip) {
17 | this.tooltip = Preconditions.checkNotNull(tooltip);
18 | }
19 |
20 | private final List tooltip;
21 |
22 | @Nonnull
23 | @Override
24 | public InfoMod getProviderType() {
25 | return InfoMod.WAILA;
26 | }
27 |
28 | @Override
29 | public void addInformation(@Nonnull ITextComponent text) {
30 | tooltip.add(Preconditions.checkNotNull(text));
31 | }
32 |
33 | @Nonnull
34 | @Override
35 | public Object getInformationComponent() {
36 | return tooltip;
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/AbstractBlockTagsProvider.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data;
2 |
3 | import net.minecraft.data.BlockTagsProvider;
4 | import net.minecraft.data.DataGenerator;
5 |
6 | /**
7 | * Created by Elec332 on 14-7-2020
8 | */
9 | public abstract class AbstractBlockTagsProvider extends BlockTagsProvider {
10 |
11 | public AbstractBlockTagsProvider(DataGenerator generatorIn) {
12 | super(generatorIn);
13 | }
14 |
15 | @Override
16 | protected final void registerTags() {
17 | registerBlockTags();
18 | }
19 |
20 | protected abstract void registerBlockTags();
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/AbstractItemTagsProvider.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data;
2 |
3 | import net.minecraft.data.BlockTagsProvider;
4 | import net.minecraft.data.DataGenerator;
5 | import net.minecraft.data.ItemTagsProvider;
6 |
7 | /**
8 | * Created by Elec332 on 14-7-2020
9 | */
10 | public abstract class AbstractItemTagsProvider extends ItemTagsProvider {
11 |
12 | public AbstractItemTagsProvider(DataGenerator generatorIn, BlockTagsProvider blockTagsProvider) {
13 | super(generatorIn, blockTagsProvider);
14 | }
15 |
16 | @Override
17 | protected final void registerTags() {
18 | registerItemTags();
19 | }
20 |
21 | protected abstract void registerItemTags();
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/AbstractTranslationProvider.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data;
2 |
3 | import net.minecraft.data.DataGenerator;
4 | import net.minecraft.fluid.Fluid;
5 | import net.minecraftforge.common.data.LanguageProvider;
6 |
7 | import java.util.function.Supplier;
8 |
9 | /**
10 | * Created by Elec332 on 15-7-2020
11 | */
12 | public abstract class AbstractTranslationProvider extends LanguageProvider {
13 |
14 | public AbstractTranslationProvider(DataGenerator gen, String modid) {
15 | this(gen, modid, "en_us");
16 | }
17 |
18 | public AbstractTranslationProvider(DataGenerator gen, String modid, String locale) {
19 | super(gen, modid, locale);
20 | }
21 |
22 | @Override
23 | protected final void addTranslations() {
24 | registerTranslations();
25 | }
26 |
27 | protected abstract void registerTranslations();
28 |
29 | public void addFluid(Supplier fluid, String name) {
30 | add(fluid.get(), name);
31 | }
32 |
33 | public void add(Fluid fluid, String name) {
34 | add(fluid.getAttributes().getTranslationKey(), name);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/recipe/AbstractCraftingRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data.recipe;
2 |
3 | import com.google.common.base.Preconditions;
4 | import com.google.gson.JsonObject;
5 | import elec332.core.api.data.recipe.IRecipeBuilder;
6 | import net.minecraft.advancements.ICriterionInstance;
7 | import net.minecraft.data.IFinishedRecipe;
8 | import net.minecraft.item.crafting.Ingredient;
9 | import net.minecraft.nbt.CompoundNBT;
10 | import net.minecraft.util.IItemProvider;
11 |
12 | import javax.annotation.Nonnull;
13 | import java.util.Map;
14 | import java.util.function.Consumer;
15 |
16 | /**
17 | * Created by Elec332 on 15-7-2020
18 | */
19 | public abstract class AbstractCraftingRecipeBuilder> extends AbstractRecipeBuilder {
20 |
21 | public AbstractCraftingRecipeBuilder(Consumer registry, IItemProvider result, int resultCount, String group, Map keys, Map criteria) {
22 | super(registry, result, resultCount, group, keys, criteria);
23 | }
24 |
25 | @Override
26 | protected void register(IFinishedRecipe recipe) {
27 | if (tag != null) {
28 | final CompoundNBT finalTag = tag.copy();
29 | recipe = new WrappedFinishedRecipe(recipe) {
30 |
31 | @Override
32 | public void serialize(@Nonnull JsonObject json) {
33 | super.serialize(json);
34 | Preconditions.checkNotNull(json.getAsJsonObject("result")).addProperty("nbt", finalTag.toString());
35 | }
36 |
37 | };
38 | }
39 | super.register(recipe);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/recipe/RecipeTypes.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data.recipe;
2 |
3 | import elec332.core.api.data.recipe.IRecipeType;
4 | import elec332.core.api.data.recipe.impl.ICookingRecipeBuilder;
5 | import elec332.core.api.data.recipe.impl.IShapedRecipeBuilder;
6 | import elec332.core.api.data.recipe.impl.IShapelessRecipeBuilder;
7 | import elec332.core.api.data.recipe.impl.IStoneCutterRecipeBuilder;
8 | import net.minecraft.item.crafting.CookingRecipeSerializer;
9 | import net.minecraft.item.crafting.IRecipeSerializer;
10 |
11 | import java.util.function.Function;
12 |
13 | /**
14 | * Created by Elec332 on 15-7-2020
15 | */
16 | public class RecipeTypes {
17 |
18 | public static final Function, IRecipeType> COOKING_RECIPE_TYPE_GETTER = serializer ->
19 | (IRecipeType) (registry, result, resultCount, group, keys, criteria) -> new CookingRecipeBuilder(registry, result, resultCount, group, keys, criteria, serializer);
20 |
21 | public static final IRecipeType SHAPED_RECIPE = ShapedRecipeBuilder::new;
22 | public static final IRecipeType SHAPELESS_RECIPE = ShapelessRecipeBuilder::new;
23 | public static final IRecipeType FURNACE_RECIPE = COOKING_RECIPE_TYPE_GETTER.apply(IRecipeSerializer.SMELTING);
24 | public static final IRecipeType BLASTFURNACE_RECIPE = COOKING_RECIPE_TYPE_GETTER.apply(IRecipeSerializer.BLASTING);
25 | public static final IRecipeType SMOKING_RECIPE = COOKING_RECIPE_TYPE_GETTER.apply(IRecipeSerializer.SMOKING);
26 | public static final IRecipeType CAMPFIRE_RECIPE = COOKING_RECIPE_TYPE_GETTER.apply(IRecipeSerializer.CAMPFIRE_COOKING);
27 | public static final IRecipeType STONECUTTING_RECIPE = StoneCutterRecipeBuilder::new;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/recipe/ShapedRecipeBuilder.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data.recipe;
2 |
3 | import elec332.core.api.data.recipe.impl.IShapedRecipeBuilder;
4 | import net.minecraft.advancements.ICriterionInstance;
5 | import net.minecraft.data.IFinishedRecipe;
6 | import net.minecraft.item.crafting.Ingredient;
7 | import net.minecraft.util.IItemProvider;
8 | import net.minecraft.util.ResourceLocation;
9 |
10 | import java.util.Map;
11 | import java.util.function.Consumer;
12 |
13 | /**
14 | * Created by Elec332 on 15-7-2020
15 | */
16 | public class ShapedRecipeBuilder extends AbstractCraftingRecipeBuilder implements IShapedRecipeBuilder {
17 |
18 | public ShapedRecipeBuilder(Consumer registry, IItemProvider result, int resultCount, String group, Map keys, Map criteria) {
19 | super(registry, result, resultCount, group, keys, criteria);
20 | this.builder = net.minecraft.data.ShapedRecipeBuilder.shapedRecipe(result, resultCount);
21 | }
22 |
23 | private final net.minecraft.data.ShapedRecipeBuilder builder;
24 |
25 | @Override
26 | public ShapedRecipeBuilder patternLine(String pattern) {
27 | pattern.chars().forEach(c -> maybeAdd((char) c, builder::key));
28 | builder.patternLine(pattern);
29 | return this;
30 | }
31 |
32 | @Override
33 | public void build(ResourceLocation id) {
34 | builder.setGroup(getGroup());
35 | getCriteria().forEach(builder::addCriterion);
36 | builder.build(this::register, id);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/data/recipe/WrappedFinishedRecipe.java:
--------------------------------------------------------------------------------
1 | package elec332.core.data.recipe;
2 |
3 | import com.google.common.base.Preconditions;
4 | import com.google.gson.JsonObject;
5 | import net.minecraft.data.IFinishedRecipe;
6 | import net.minecraft.item.crafting.IRecipeSerializer;
7 | import net.minecraft.util.ResourceLocation;
8 |
9 | import javax.annotation.Nonnull;
10 | import javax.annotation.Nullable;
11 |
12 | /**
13 | * Created by Elec332 on 15-7-2020
14 | */
15 | public class WrappedFinishedRecipe implements IFinishedRecipe {
16 |
17 | public WrappedFinishedRecipe(IFinishedRecipe recipe) {
18 | this.recipe = Preconditions.checkNotNull(recipe);
19 | }
20 |
21 | private final IFinishedRecipe recipe;
22 |
23 | @Override
24 | public void serialize(@Nonnull JsonObject json) {
25 | recipe.serialize(json);
26 | }
27 |
28 | @Nonnull
29 | @Override
30 | public ResourceLocation getID() {
31 | return recipe.getID();
32 | }
33 |
34 | @Nonnull
35 | @Override
36 | public IRecipeSerializer> getSerializer() {
37 | return recipe.getSerializer();
38 | }
39 |
40 | @Nullable
41 | @Override
42 | public JsonObject getAdvancementJson() {
43 | return recipe.getAdvancementJson();
44 | }
45 |
46 | @Nullable
47 | @Override
48 | public ResourceLocation getAdvancementID() {
49 | return recipe.getAdvancementID();
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/GridInformation.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid;
2 |
3 | import java.lang.annotation.ElementType;
4 | import java.lang.annotation.Retention;
5 | import java.lang.annotation.RetentionPolicy;
6 | import java.lang.annotation.Target;
7 |
8 | /**
9 | * Created by Elec332 on 9-10-2016.
10 | *
11 | * Can be used on field in {@link net.minecraft.tileentity.TileEntity}'s
12 | * to give a tile information about the grid it is in.
13 | */
14 | @Retention(RetentionPolicy.RUNTIME)
15 | @Target(ElementType.FIELD)
16 | public @interface GridInformation {
17 |
18 | public Class value();
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/IPositionable.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid;
2 |
3 | import elec332.core.world.DimensionCoordinate;
4 |
5 | import javax.annotation.Nonnull;
6 |
7 | /**
8 | * Created by Elec332 on 8-11-2017.
9 | */
10 | public interface IPositionable {
11 |
12 | @Nonnull
13 | public DimensionCoordinate getPosition();
14 |
15 | default public boolean hasChanged() {
16 | return false;
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/ITileEntityLink.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid;
2 |
3 | import net.minecraft.tileentity.TileEntity;
4 | import net.minecraft.util.Direction;
5 | import net.minecraftforge.common.capabilities.Capability;
6 | import net.minecraftforge.common.capabilities.ICapabilityProvider;
7 | import net.minecraftforge.common.util.LazyOptional;
8 |
9 | import javax.annotation.Nonnull;
10 | import javax.annotation.Nullable;
11 |
12 | /**
13 | * Created by Elec332 on 24-7-2016.
14 | */
15 | public interface ITileEntityLink extends IPositionable, ICapabilityProvider {
16 |
17 | @Nullable
18 | TileEntity getTileEntity();
19 |
20 | @Nonnull
21 | @Override
22 | LazyOptional getCapability(@Nonnull Capability cap, @Nullable Direction side);
23 |
24 | @Nullable
25 | default Class> getInformationType() {
26 | return null;
27 | }
28 |
29 | @Nullable
30 | default Object getInformation() {
31 | return null;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/multiblock/AbstractDynamicMultiblock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid.multiblock;
2 |
3 | import com.google.common.collect.Sets;
4 | import net.minecraft.tileentity.TileEntity;
5 |
6 | import java.util.Collections;
7 | import java.util.Set;
8 |
9 | /**
10 | * Created by Elec332 on 1-8-2020
11 | */
12 | public abstract class AbstractDynamicMultiblock, L extends AbstractDynamicMultiblockTileLink> {
13 |
14 | public AbstractDynamicMultiblock() {
15 | this.objects = Sets.newHashSet();
16 | this.objects_ = Collections.unmodifiableSet(this.objects);
17 | }
18 |
19 | private final Set objects, objects_;
20 |
21 | protected Set getComponents() {
22 | return this.objects_;
23 | }
24 |
25 | protected void tick() {
26 | }
27 |
28 | protected void onComponentRemoved(L link) {
29 | onGridChanged();
30 | }
31 |
32 | protected final void addComponent(L link) {
33 | this.objects.add(link);
34 | onComponentAdded(link, false);
35 | onGridChanged();
36 | }
37 |
38 | protected void onComponentAdded(L link, boolean mergeAdd) {
39 | }
40 |
41 | protected abstract boolean canMerge(M other);
42 |
43 | @SuppressWarnings("unchecked")
44 | protected final void mergeWith(M other) {
45 | for (L link : other.getComponents()) {
46 | link.setGrid((M) this);
47 | objects.add(link);
48 | onComponentAdded(link, true);
49 | }
50 | onMergedWith(other);
51 | onGridChanged();
52 | }
53 |
54 | protected void onMergedWith(M other) {
55 | }
56 |
57 | protected void invalidate() {
58 | onGridChanged();
59 | }
60 |
61 | protected abstract void onGridChanged();
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/multiblock/AbstractDynamicMultiblockTileLink.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid.multiblock;
2 |
3 | import elec332.core.grid.DefaultTileEntityLink;
4 | import net.minecraft.tileentity.TileEntity;
5 |
6 | import javax.annotation.Nullable;
7 |
8 | /**
9 | * Created by Elec332 on 1-8-2020
10 | */
11 | public abstract class AbstractDynamicMultiblockTileLink, L extends AbstractDynamicMultiblockTileLink> extends DefaultTileEntityLink {
12 |
13 | protected AbstractDynamicMultiblockTileLink(T tile) {
14 | super(tile);
15 | }
16 |
17 | private M grid;
18 |
19 | @Nullable
20 | public M getGrid() {
21 | return grid;
22 | }
23 |
24 | void setGrid(M grid) {
25 | this.grid = grid;
26 | setGridToTile(grid);
27 | }
28 |
29 | protected abstract void setGridToTile(@Nullable M grid);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/grid/multiblock/SimpleDynamicMultiblockTileLink.java:
--------------------------------------------------------------------------------
1 | package elec332.core.grid.multiblock;
2 |
3 | import com.google.common.base.Preconditions;
4 | import net.minecraft.tileentity.TileEntity;
5 |
6 | import javax.annotation.Nullable;
7 | import java.util.function.BiConsumer;
8 |
9 | /**
10 | * Created by Elec332 on 1-8-2020
11 | */
12 | public class SimpleDynamicMultiblockTileLink>> extends AbstractDynamicMultiblockTileLink> {
13 |
14 | public static >> SimpleDynamicMultiblockTileLink wrap(T tile) {
15 | return new SimpleDynamicMultiblockTileLink<>(tile);
16 | }
17 |
18 | public SimpleDynamicMultiblockTileLink(T tile) {
19 | this(tile, (t, g) -> {
20 | });
21 | }
22 |
23 | public SimpleDynamicMultiblockTileLink(T tile, BiConsumer gridSetter) {
24 | super(tile);
25 | this.gridSetter = Preconditions.checkNotNull(gridSetter);
26 | }
27 |
28 | private final BiConsumer gridSetter;
29 |
30 | @Override
31 | protected void setGridToTile(@Nullable M grid) {
32 | gridSetter.accept(Preconditions.checkNotNull(getTileEntity()), grid);
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/handler/ElecCoreRegistrar.java:
--------------------------------------------------------------------------------
1 | package elec332.core.handler;
2 |
3 | import elec332.core.api.annotations.StaticLoad;
4 | import elec332.core.api.info.IInfoProvider;
5 | import elec332.core.api.info.IInfoProviderEntity;
6 | import elec332.core.api.registry.ISingleObjectRegistry;
7 | import elec332.core.api.registry.SimpleRegistries;
8 | import elec332.core.grid.IStructureWorldEventHandler;
9 | import elec332.core.util.FMLHelper;
10 |
11 | import java.util.function.Predicate;
12 |
13 | /**
14 | * Created by Elec332 on 1-8-2016.
15 | */
16 | @StaticLoad
17 | @SuppressWarnings("all")
18 | public final class ElecCoreRegistrar {
19 |
20 | private ElecCoreRegistrar() {
21 | throw new IllegalAccessError();
22 | }
23 |
24 | public static final ISingleObjectRegistry GRIDHANDLERS;
25 | public static final ISingleObjectRegistry INFORMATION_PROVIDERS;
26 | public static final ISingleObjectRegistry INFORMATION_PROVIDERS_ENTITY;
27 |
28 | static {
29 | IN_MOD_LOADING = input -> FMLHelper.isInModInitialisation();
30 | GRIDHANDLERS = SimpleRegistries.newSingleObjectRegistry(ElecCoreRegistrar.IN_MOD_LOADING);
31 | INFORMATION_PROVIDERS = SimpleRegistries.newSingleObjectRegistry(ElecCoreRegistrar.IN_MOD_LOADING);
32 | INFORMATION_PROVIDERS_ENTITY = SimpleRegistries.newSingleObjectRegistry(ElecCoreRegistrar.IN_MOD_LOADING);
33 | }
34 |
35 | private static final Predicate IN_MOD_LOADING;
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/handler/annotations/PostInitAnnotationProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.handler.annotations;
2 |
3 | import elec332.core.api.discovery.AnnotationDataProcessor;
4 | import net.minecraftforge.fml.ModLoadingStage;
5 |
6 | /**
7 | * Created by Elec332 on 7-10-2016.
8 | */
9 | @SuppressWarnings("unused")
10 | @AnnotationDataProcessor(ModLoadingStage.PROCESS_IMC)
11 | public class PostInitAnnotationProcessor extends AbstractAnnotationProcessor {
12 |
13 | @Override
14 | @SuppressWarnings("unchecked")
15 | protected void registerProcesses() {
16 | /*registerDataProcessor(RegisteredForestryIndividual.class, new Consumer() {
17 | @Override
18 | public void accept(ASMDataTable.ASMData asmData) {
19 | Class> clazz = loadClass(asmData);
20 | if (clazz.isEnum() && IIndividualTemplate.class.isAssignableFrom(clazz)){
21 | for (Object o : clazz.getEnumConstants()){
22 | IndividualDefinitionRegistry.registerBee((IIndividualTemplate)o);
23 | }
24 | }
25 | }
26 | });*/
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/handler/annotations/PreInitAnnotationProcessor.java:
--------------------------------------------------------------------------------
1 | package elec332.core.handler.annotations;
2 |
3 | import elec332.core.api.discovery.AnnotationDataProcessor;
4 | import net.minecraftforge.fml.ModLoadingStage;
5 |
6 | /**
7 | * Created by Elec332 on 24-9-2016.
8 | */
9 | @SuppressWarnings("unused")
10 | @AnnotationDataProcessor(ModLoadingStage.COMMON_SETUP)
11 | public class PreInitAnnotationProcessor extends AbstractAnnotationProcessor {
12 |
13 | @Override
14 | protected void registerProcesses() {
15 |
16 | }
17 |
18 | }
19 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/handler/event/PlayerEventHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.handler.event;
2 |
3 | import elec332.core.api.util.IRightClickCancel;
4 | import elec332.core.util.math.RayTraceHelper;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraft.item.ItemUseContext;
7 | import net.minecraft.util.Hand;
8 | import net.minecraftforge.event.entity.player.PlayerInteractEvent;
9 | import net.minecraftforge.eventbus.api.EventPriority;
10 | import net.minecraftforge.eventbus.api.SubscribeEvent;
11 |
12 | /**
13 | * Created by Elec332 on 13-8-2018.
14 | */
15 | public class PlayerEventHandler {
16 |
17 | @SubscribeEvent(priority = EventPriority.LOWEST)
18 | @SuppressWarnings("all")
19 | public void onItemRightClick(PlayerInteractEvent.RightClickBlock event) {
20 | ItemStack stack;
21 | if (event.getHand() == Hand.OFF_HAND) {
22 | stack = event.getPlayer().getHeldItem(Hand.MAIN_HAND);
23 | if (stack != null && stack.getItem() instanceof IRightClickCancel && ((IRightClickCancel) stack.getItem()).cancelInteraction(stack)) {
24 | event.setCanceled(true);
25 | return;
26 | }
27 | }
28 | stack = event.getItemStack();
29 | if (stack != null && stack.getItem() instanceof IRightClickCancel && ((IRightClickCancel) stack.getItem()).cancelInteraction(stack)) {
30 | event.setCanceled(true);
31 | ItemUseContext iuc = new ItemUseContext(event.getPlayer(), event.getHand(), RayTraceHelper.retraceBlock(event.getWorld(), event.getPos(), event.getPlayer()));
32 | stack.getItem().onItemUse(iuc);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/hud/drawing/IDrawer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.hud.drawing;
2 |
3 | import elec332.core.hud.position.Alignment;
4 | import net.minecraft.client.Minecraft;
5 | import net.minecraftforge.api.distmarker.Dist;
6 | import net.minecraftforge.api.distmarker.OnlyIn;
7 |
8 | /**
9 | * Created by Elec332 on 8-1-2017.
10 | */
11 | public interface IDrawer {
12 |
13 | @OnlyIn(Dist.CLIENT)
14 | public int draw(D drawable, Minecraft mc, Alignment alignment, int x, int y, Object... data);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/hud/drawing/ItemStackDrawer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.hud.drawing;
2 |
3 | import elec332.core.hud.position.Alignment;
4 | import net.minecraft.client.Minecraft;
5 | import net.minecraft.client.renderer.RenderHelper;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraftforge.api.distmarker.Dist;
8 | import net.minecraftforge.api.distmarker.OnlyIn;
9 |
10 | /**
11 | * Created by Elec332 on 8-1-2017.
12 | */
13 | public class ItemStackDrawer implements IDrawer {
14 |
15 | private ItemStackDrawer() {
16 | }
17 |
18 | public static final IDrawer INSTANCE;
19 |
20 | @Override
21 | @OnlyIn(Dist.CLIENT)
22 | public int draw(ItemStack drawable, Minecraft mc, Alignment alignment, int x, int y, Object... data) {
23 | RenderHelper.enableStandardItemLighting();
24 | mc.getItemRenderer().renderItemIntoGUI(drawable, x, y);
25 | RenderHelper.disableStandardItemLighting();
26 | return 18;
27 | }
28 |
29 | static {
30 | INSTANCE = new ItemStackDrawer();
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/hud/position/HorizontalStartingPoint.java:
--------------------------------------------------------------------------------
1 | package elec332.core.hud.position;
2 |
3 | import net.minecraft.client.MainWindow;
4 | import net.minecraft.client.Minecraft;
5 |
6 | /**
7 | * Created by Elec332 on 8-1-2017.
8 | */
9 | public enum HorizontalStartingPoint implements IStartingPoint {
10 |
11 | LEFT {
12 | @Override
13 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight) {
14 | return 5;
15 | }
16 |
17 | },
18 | RIGHT {
19 | @Override
20 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight) {
21 | return sr.getScaledWidth() - 5;
22 | }
23 |
24 | };
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/hud/position/IStartingPoint.java:
--------------------------------------------------------------------------------
1 | package elec332.core.hud.position;
2 |
3 | import net.minecraft.client.MainWindow;
4 | import net.minecraft.client.Minecraft;
5 |
6 | /**
7 | * Created by Elec332 on 8-1-2017.
8 | */
9 | public interface IStartingPoint {
10 |
11 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/hud/position/VerticalStartingPoint.java:
--------------------------------------------------------------------------------
1 | package elec332.core.hud.position;
2 |
3 | import net.minecraft.client.MainWindow;
4 | import net.minecraft.client.Minecraft;
5 |
6 | /**
7 | * Created by Elec332 on 8-1-2017.
8 | */
9 | public enum VerticalStartingPoint implements IStartingPoint {
10 |
11 | TOP {
12 | @Override
13 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight) {
14 | return 9;
15 | }
16 |
17 | },
18 | MIDDLE {
19 | @Override
20 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight) {
21 | return sr.getScaledHeight() / 2 - hudHeight / 2;
22 | }
23 |
24 | },
25 | BOTTOM {
26 | @Override
27 | public int getStartingPoint(Minecraft mc, MainWindow sr, int hudHeight) {
28 | return sr.getScaledHeight() - hudHeight - 9;
29 | }
30 |
31 | };
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/ContainerNull.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory;
2 |
3 | import net.minecraft.entity.player.PlayerEntity;
4 | import net.minecraft.inventory.container.Container;
5 |
6 | import javax.annotation.Nonnull;
7 |
8 | /**
9 | * Created by Elec332 on 11-10-2015.
10 | *
11 | * Null/fake container
12 | */
13 | public final class ContainerNull extends Container {
14 |
15 | public ContainerNull() {
16 | super(null, -1);
17 | }
18 |
19 | @Override
20 | public boolean canInteractWith(@Nonnull PlayerEntity player) {
21 | return false;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/slot/SlotOutput.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.slot;
2 |
3 | import net.minecraft.inventory.IInventory;
4 | import net.minecraft.inventory.container.Slot;
5 | import net.minecraft.item.ItemStack;
6 |
7 | import javax.annotation.Nonnull;
8 |
9 | /**
10 | * Created by Elec332 on 5-5-2015.
11 | */
12 | public class SlotOutput extends Slot {
13 |
14 | public SlotOutput(IInventory inventory, int index, int x, int z) {
15 | super(inventory, index, x, z);
16 | }
17 |
18 | @Override
19 | public boolean isItemValid(@Nonnull ItemStack stack) {
20 | return false;
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/widget/IWidgetListener.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.widget;
2 |
3 | import elec332.core.inventory.window.IWindowListener;
4 | import net.minecraft.item.ItemStack;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Created by Elec332 on 29-11-2016.
10 | */
11 | public interface IWidgetListener {
12 |
13 | /**
14 | * update the crafting window inventory with the items in the list
15 | */
16 | void updateCraftingInventory(List itemsList);
17 |
18 | /**
19 | * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
20 | * contents of that slot.
21 | */
22 | void sendSlotContents(int slotInd, ItemStack stack);
23 |
24 | /**
25 | * Sends two ints to the client-side Container. Used for furnace burning time, smelting progress, brewing progress,
26 | * and enchanting level. Normally the first int identifies which variable to update, and the second contains the new
27 | * value. Both are truncated to shorts in non-local SMP.
28 | */
29 | void sendProgressBarUpdate(int newValue);
30 |
31 | IWindowListener getWindowListener();
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/widget/slot/WidgetScrollableSlot.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.widget.slot;
2 |
3 | import net.minecraftforge.items.IItemHandler;
4 |
5 | /**
6 | * Created by Elec332 on 3-12-2016.
7 | */
8 | public class WidgetScrollableSlot extends WidgetSlot {
9 |
10 | public WidgetScrollableSlot(IItemHandler inventory, int index, int x, int y) {
11 | super(inventory, index, x, y);
12 | this.index = index;
13 | }
14 |
15 | private int index;
16 |
17 | public void setSlotIndex(int index) {
18 | this.index = index;
19 | }
20 |
21 | @Override
22 | public int getSlotIndex() {
23 | return this.index;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/widget/slot/WidgetSlotOutput.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.widget.slot;
2 |
3 | import net.minecraft.item.ItemStack;
4 | import net.minecraftforge.items.IItemHandler;
5 |
6 | /**
7 | * Created by Elec332 on 17-12-2016.
8 | */
9 | public class WidgetSlotOutput extends WidgetSlot {
10 |
11 | public WidgetSlotOutput(IItemHandler inventory, int index, int x, int y) {
12 | super(inventory, index, x, y);
13 | }
14 |
15 | @Override
16 | public boolean isItemValid(ItemStack stack) {
17 | return false;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IGuiEventListener.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | import net.minecraftforge.api.distmarker.Dist;
4 | import net.minecraftforge.api.distmarker.OnlyIn;
5 |
6 | /**
7 | * Created by Elec332 on 28-12-2019
8 | */
9 | public interface IGuiEventListener {
10 |
11 | @OnlyIn(Dist.CLIENT)
12 | public void mouseMoved(double mouseX, double mouseY);
13 |
14 | @OnlyIn(Dist.CLIENT)
15 | public boolean mouseClicked(double mouseX, double mouseY, int button);
16 |
17 | @OnlyIn(Dist.CLIENT)
18 | public boolean mouseReleased(double mouseX, double mouseY, int mouseButton);
19 |
20 | @OnlyIn(Dist.CLIENT)
21 | public boolean mouseDragged(double mouseX, double mouseY, int mouseButton, double dragX, double dragY);
22 |
23 | @OnlyIn(Dist.CLIENT)
24 | public boolean mouseScrolled(double wheel, double translatedMouseX, double translatedMouseY);
25 |
26 | @OnlyIn(Dist.CLIENT)
27 | public boolean keyPressed(int key, int scanCode, int modifiers);
28 |
29 | @OnlyIn(Dist.CLIENT)
30 | public boolean keyReleased(int keyCode, int scanCode, int modifiers);
31 |
32 | @OnlyIn(Dist.CLIENT)
33 | public boolean charTyped(char typedChar, int keyCode);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/ISimpleWindowFactory.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | /**
4 | * Created by Elec332 on 2-12-2016.
5 | */
6 | public interface ISimpleWindowFactory extends IWindowFactory, IWindowModifier {
7 |
8 | @Override
9 | default Window createWindow(Object... args) {
10 | return new Window(getXSize(), getYSize(), this);
11 | }
12 |
13 | default int getXSize() {
14 | return -1;
15 | }
16 |
17 | default int getYSize() {
18 | return -1;
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWidgetContainer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | import elec332.core.inventory.widget.IWidget;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Elec332 on 31-7-2015.
9 | */
10 | public interface IWidgetContainer {
11 |
12 | public List getWidgets();
13 |
14 | public W addWidget(W widget);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWindowContainer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | import elec332.core.inventory.widget.slot.WidgetSlot;
4 | import net.minecraft.entity.player.PlayerEntity;
5 | import net.minecraft.inventory.container.ClickType;
6 | import net.minecraft.item.ItemStack;
7 | import net.minecraft.nbt.CompoundNBT;
8 | import net.minecraftforge.api.distmarker.Dist;
9 | import net.minecraftforge.api.distmarker.OnlyIn;
10 |
11 | import javax.annotation.Nonnull;
12 | import java.util.List;
13 |
14 | /**
15 | * Created by Elec332 on 17-12-2016.
16 | */
17 | public interface IWindowContainer {
18 |
19 | public WidgetSlot getSlot(int id);
20 |
21 | public int getSlotListSize();
22 |
23 | @Nonnull
24 | public T addSlotToWindow(@Nonnull T widget);
25 |
26 | public void detectAndSendChanges();
27 |
28 | public PlayerEntity getPlayer();
29 |
30 | public List getListeners();
31 |
32 | @OnlyIn(Dist.CLIENT)
33 | public void handleSlotClickDefault(WidgetSlot slotIn, int slotId, int mouseButton, @Nonnull ClickType type);
34 |
35 | @OnlyIn(Dist.CLIENT)
36 | public boolean mouseDraggedDefault(double mouseX, double mouseY, int mouseButton, double dragX, double dragY);
37 |
38 | @OnlyIn(Dist.CLIENT)
39 | public boolean mouseReleasedDefault(double mouseX, double mouseY, int mouseButton);
40 |
41 | public boolean mergeItemStackDefault(ItemStack stack, int startIndex, int endIndex, boolean reverseDirection);
42 |
43 | public ItemStack slotClickDefault(int slotId, int dragType, ClickType clickTypeIn, PlayerEntity player);
44 |
45 | public void sendPacket(CompoundNBT tag);
46 |
47 | public int getWindowID();
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWindowFactory.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | /**
4 | * Created by Elec332 on 2-12-2016.
5 | */
6 | public interface IWindowFactory {
7 |
8 | Window createWindow(Object... args);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWindowHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 | import net.minecraft.entity.player.PlayerEntity;
5 | import net.minecraft.world.World;
6 |
7 | /**
8 | * Created by Elec332 on 29-11-2016.
9 | */
10 | public interface IWindowHandler {
11 |
12 | Window createWindow(PlayerEntity player, World world, ElecByteBuf data);
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWindowListener.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Elec332 on 17-12-2016.
9 | */
10 | public interface IWindowListener {
11 |
12 | /**
13 | * update the crafting window inventory with the items in the list
14 | */
15 | public void updateCraftingInventory(List itemsList);
16 |
17 | /**
18 | * Sends the contents of an inventory slot to the client-side Container. This doesn't have to match the actual
19 | * contents of that slot.
20 | */
21 | public void sendSlotContents(int slotInd, ItemStack stack);
22 |
23 | /**
24 | * Sends two ints to the client-side Container. Used for furnace burning time, smelting progress, brewing progress,
25 | * and enchanting level. Normally the first int identifies which variable to update, and the second contains the new
26 | * value. Both are truncated to shorts in non-local SMP.
27 | */
28 | public void sendProgressBarUpdate(int id, int newValue);
29 |
30 | public Object getActualListener();
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/inventory/window/IWindowModifier.java:
--------------------------------------------------------------------------------
1 | package elec332.core.inventory.window;
2 |
3 | /**
4 | * Created by Elec332 on 2-12-2016.
5 | */
6 | public interface IWindowModifier {
7 |
8 | public void modifyWindow(Window window, Object... args);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/item/AbstractItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.item;
2 |
3 | import net.minecraft.item.Item;
4 | import net.minecraft.item.ItemGroup;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraft.util.NonNullList;
7 |
8 | import javax.annotation.Nonnull;
9 |
10 | /**
11 | * Created by Elec332 on 21-8-2016.
12 | */
13 | public abstract class AbstractItem extends Item implements IAbstractItem {
14 |
15 | public AbstractItem(Properties itemBuilder) {
16 | super(itemBuilder);
17 | }
18 |
19 | private String unlocalizedName;
20 |
21 | @Nonnull
22 | @Override
23 | public String getDefaultTranslationKey() {
24 | if (this.unlocalizedName == null) {
25 | unlocalizedName = ItemMethods.createUnlocalizedName(this);
26 | }
27 | return unlocalizedName;
28 | }
29 |
30 | @Nonnull
31 | @Override
32 | public String getTranslationKey(ItemStack stack) {
33 | return ItemMethods.getUnlocalizedName(stack, this);
34 | }
35 |
36 | @Override
37 | public void fillItemGroup(@Nonnull ItemGroup group, @Nonnull NonNullList items) {
38 | super.fillItemGroup(group, items);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/item/AbstractItemBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.item;
2 |
3 | import net.minecraft.block.Block;
4 | import net.minecraft.item.BlockItem;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraft.nbt.CompoundNBT;
7 |
8 | import javax.annotation.Nonnull;
9 |
10 | /**
11 | * Created by Elec332 on 26-11-2016.
12 | */
13 | public abstract class AbstractItemBlock extends BlockItem implements IAbstractItem {
14 |
15 | public AbstractItemBlock(Block block, Properties itemBuilder) {
16 | super(block, itemBuilder);
17 | }
18 |
19 | public static final String TILE_DATA_TAG = "BlockEntityTag";
20 |
21 | private String unlocalizedName;
22 |
23 | @Nonnull
24 | @Override
25 | public String getDefaultTranslationKey() {
26 | if (this.unlocalizedName == null) {
27 | unlocalizedName = ItemMethods.createUnlocalizedName(this);
28 | }
29 | return unlocalizedName;
30 | }
31 |
32 | @Nonnull
33 | @Override
34 | public String getTranslationKey(ItemStack stack) {
35 | return ItemMethods.getUnlocalizedName(stack, this);
36 | }
37 |
38 | public static CompoundNBT getTileData(ItemStack stack) {
39 | return stack.getOrCreateChildTag(AbstractItemBlock.TILE_DATA_TAG);
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/item/IAbstractItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.item;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | /**
6 | * Created by Elec332 on 29-12-2018
7 | */
8 | public interface IAbstractItem {
9 |
10 | default public String getVariantName(ItemStack stack) {
11 | return "";
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/item/IEnumItem.java:
--------------------------------------------------------------------------------
1 | package elec332.core.item;
2 |
3 | import elec332.core.api.client.IColoredItem;
4 | import net.minecraft.item.Item;
5 | import net.minecraft.item.ItemStack;
6 | import net.minecraft.util.ResourceLocation;
7 |
8 | /**
9 | * Created by Elec332 on 21-8-2016.
10 | */
11 | public interface IEnumItem extends IColoredItem {
12 |
13 | /**
14 | * Here you can initialize your item.
15 | * This only gets called for the first Enum value (ordinal 0), because all values
16 | * use the same item.
17 | *
18 | * @param item The item
19 | */
20 | public void initializeItem(ItemEnumBased extends IEnumItem> item);
21 |
22 | /**
23 | * Here you can define the {@link Item.Properties} parameters for your item.
24 | * Used for things like setting max uses, creative tab, ect...
25 | * This only gets called for the first Enum value (ordinal 0), because all values
26 | * use the same item.
27 | */
28 | public Item.Properties getItemData();
29 |
30 | @Override
31 | default int getColorFromItemStack(ItemStack stack, int tintIndex) {
32 | return -1;
33 | }
34 |
35 | default public boolean shouldShow() {
36 | return true;
37 | }
38 |
39 | default public ResourceLocation[] getTextures() {
40 | return new ResourceLocation[]{
41 | getTextureLocation()
42 | };
43 | }
44 |
45 | public ResourceLocation getTextureLocation();
46 |
47 | default public String getUnlocalizedName(ItemStack stack) {
48 | return stack.getItem().getTranslationKey() + "." + ((Enum) this).name().toLowerCase();
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/item/ItemMethods.java:
--------------------------------------------------------------------------------
1 | package elec332.core.item;
2 |
3 | import net.minecraft.item.BlockItem;
4 | import net.minecraft.item.Item;
5 | import net.minecraft.item.ItemStack;
6 |
7 | import javax.annotation.Nonnull;
8 |
9 | /**
10 | * Created by Elec332 on 27-12-2018
11 | */
12 | public class ItemMethods {
13 |
14 | @SuppressWarnings("all")
15 | public static String createUnlocalizedName(I item) {
16 | if (item instanceof BlockItem) {
17 | return ((BlockItem) item).getBlock().getTranslationKey();
18 | }
19 | return "item." + item.getRegistryName().toString().replace(":", ".").toLowerCase();
20 | }
21 |
22 | @Nonnull
23 | public static String getUnlocalizedName(ItemStack stack, I item) {
24 | if (stack.hasTag()) {
25 | return item.getTranslationKey() + "." + item.getVariantName(stack);
26 | }
27 | return item.getTranslationKey();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/IElecCoreNetworkTile.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network;
2 |
3 | import net.minecraft.entity.player.ServerPlayerEntity;
4 | import net.minecraft.nbt.CompoundNBT;
5 |
6 | /**
7 | * Created by Elec332 on 25-8-2015.
8 | *
9 | * Used for sending packets between/to {@link net.minecraft.tileentity.TileEntity}'s
10 | */
11 | public interface IElecCoreNetworkTile {
12 |
13 | /**
14 | * Called on the server side when a packet was received from the client
15 | *
16 | * @param sender The player that sent the message
17 | * @param ID The message ID
18 | * @param data The message data
19 | */
20 | public void onPacketReceivedFromClient(ServerPlayerEntity sender, int ID, CompoundNBT data);
21 |
22 | /**
23 | * Gets called when a message has been received from the server
24 | *
25 | * @param id The message ID
26 | * @param tag The message data
27 | */
28 | public void onDataPacket(int id, CompoundNBT tag);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/IElecNetworkHandler.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network;
2 |
3 | import elec332.core.api.network.INetworkHandler;
4 |
5 | /**
6 | * Created by Elec332 on 24-10-2016.
7 | */
8 | public interface IElecNetworkHandler extends INetworkHandler, IElecPacketRegistry {
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/IElecPacketRegistry.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network;
2 |
3 | import elec332.core.api.network.IExtendedMessageContext;
4 | import elec332.core.api.network.IMessage;
5 | import elec332.core.api.network.IPacketRegistry;
6 | import elec332.core.network.packets.AbstractPacket;
7 |
8 | import java.util.function.BiConsumer;
9 | import java.util.function.Supplier;
10 |
11 | /**
12 | * Created by Elec332 on 15-10-2016.
13 | */
14 | public interface IElecPacketRegistry extends IPacketRegistry {
15 |
16 | /**
17 | * Registers a packet to this packet registry
18 | *
19 | * @param packetClass The packet class
20 | */
21 | @SuppressWarnings("unchecked")
22 | default public void registerAbstractPacket(Class packetClass) {
23 | registerPacket((Class extends BiConsumer>>) packetClass, packetClass);
24 | }
25 |
26 | /**
27 | * Registers a packet to this packet registry
28 | * The packet handler should be on the server side
29 | *
30 | * @param packet The packet type
31 | */
32 | default public void registerAbstractPacket(AbstractPacket packet) {
33 | registerPacket(packet);
34 | }
35 |
36 | /**
37 | * Registers a packet to this packet registry
38 | *
39 | * @param messageHandler The message handler
40 | * @param messageType The message class
41 | */
42 | @Override
43 | public void registerPacket(BiConsumer> messageHandler, Class messageType);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/impl/DefaultByteBufFactory.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.impl;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 | import io.netty.buffer.ByteBuf;
5 | import io.netty.buffer.Unpooled;
6 |
7 | /**
8 | * Created by Elec332 on 4-11-2016.
9 | */
10 | interface DefaultByteBufFactory extends ElecByteBuf.Factory {
11 |
12 | @Override
13 | default public ElecByteBuf createByteBuf() {
14 | return createByteBuf(Unpooled.buffer());
15 | }
16 |
17 | @Override
18 | default public ElecByteBuf createByteBuf(ByteBuf parent) {
19 | return new ElecByteBufImpl(parent);
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/impl/DefaultExtendedMessageContext.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.impl;
2 |
3 | import com.google.common.base.Preconditions;
4 | import elec332.core.ElecCore;
5 | import elec332.core.api.network.IExtendedMessageContext;
6 | import net.minecraft.entity.player.PlayerEntity;
7 | import net.minecraft.world.World;
8 | import net.minecraftforge.fml.LogicalSide;
9 | import net.minecraftforge.fml.network.NetworkEvent;
10 | import net.minecraftforge.fml.network.PacketDispatcher;
11 |
12 | /**
13 | * Created by Elec332 on 3-12-2016.
14 | */
15 | class DefaultExtendedMessageContext implements IExtendedMessageContext {
16 |
17 | DefaultExtendedMessageContext(NetworkEvent.Context messageContext) {
18 | this.messageContext = messageContext;
19 | }
20 |
21 | private final NetworkEvent.Context messageContext;
22 |
23 | @Override
24 | public LogicalSide getReceptionSide() {
25 | return messageContext.getDirection().getReceptionSide();
26 | }
27 |
28 | @Override
29 | public PlayerEntity getSender() {
30 | return getReceptionSide() == LogicalSide.CLIENT ? ElecCore.proxy.getClientPlayer() : messageContext.getSender();
31 | }
32 |
33 | @Override
34 | public World getWorld() {
35 | return getReceptionSide() == LogicalSide.CLIENT ? ElecCore.proxy.getClientWorld() : Preconditions.checkNotNull(messageContext.getSender()).getEntityWorld();
36 | }
37 |
38 | @Override
39 | public PacketDispatcher getNetworkManager() {
40 | return messageContext.getPacketDispatcher();
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/impl/DefaultPacketRegistry.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.impl;
2 |
3 | import com.google.common.collect.Lists;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 | import elec332.core.api.network.IMessage;
6 | import elec332.core.api.network.IPacketRegistry;
7 |
8 | import java.util.List;
9 | import java.util.function.BiConsumer;
10 | import java.util.function.Supplier;
11 |
12 | /**
13 | * Created by Elec332 on 23-10-2016.
14 | */
15 | class DefaultPacketRegistry implements IPacketRegistry {
16 |
17 | DefaultPacketRegistry() {
18 | this.registeredPackets = Lists.newArrayList();
19 | }
20 |
21 | private final List> registeredPackets;
22 |
23 | @Override
24 | @SuppressWarnings("unchecked")
25 | public void registerPacket(BiConsumer> messageHandler, Class messageType) {
26 | registeredPackets.add(new Wrapper(messageHandler, messageType));
27 | }
28 |
29 | @Override
30 | @SuppressWarnings("unchecked")
31 | public void registerPacketsTo(IPacketRegistry packetRegistry) {
32 | for (Wrapper wrapper : registeredPackets) {
33 | packetRegistry.registerPacket(wrapper.messageHandler, wrapper.messageType);
34 | }
35 | }
36 |
37 | private class Wrapper {
38 |
39 | private Wrapper(BiConsumer> messageHandler, Class messageType) {
40 | this.messageHandler = messageHandler;
41 | this.messageType = messageType;
42 | }
43 |
44 | private final BiConsumer> messageHandler;
45 | private final Class messageType;
46 |
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/AbstractMessage.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.api.network.IMessage;
4 | import net.minecraft.nbt.CompoundNBT;
5 | import net.minecraft.network.PacketBuffer;
6 |
7 | import java.util.function.Supplier;
8 |
9 | /**
10 | * Created by Elec332 on 1-8-2015.
11 | */
12 | public abstract class AbstractMessage implements IMessage {
13 |
14 | public AbstractMessage(Supplier dataSupplier) {
15 | this(dataSupplier.get());
16 | }
17 |
18 | public AbstractMessage(CompoundNBT b) {
19 | this.networkPackageObject = b;
20 | }
21 |
22 | protected CompoundNBT networkPackageObject;
23 |
24 | @Override
25 | public void fromBytes(PacketBuffer buf) {
26 | this.networkPackageObject = buf.readCompoundTag();
27 | }
28 |
29 | @Override
30 | public void toBytes(PacketBuffer buf) {
31 | buf.writeCompoundTag(this.networkPackageObject);
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/AbstractPacket.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.ElecCore;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 | import net.minecraft.nbt.CompoundNBT;
6 |
7 | import java.util.function.BiConsumer;
8 | import java.util.function.Supplier;
9 |
10 | /**
11 | * Created by Elec332 on 23-2-2015.
12 | */
13 | public abstract class AbstractPacket extends AbstractMessage implements BiConsumer> {
14 |
15 | public AbstractPacket() {
16 | super((CompoundNBT) null);
17 | }
18 |
19 | public AbstractPacket(Supplier dataSupplier) {
20 | super(dataSupplier);
21 | }
22 |
23 | public AbstractPacket(CompoundNBT b) {
24 | super(b);
25 | }
26 |
27 | @Override
28 | public void accept(AbstractPacket abstractPacket, Supplier extendedMessageContext) {
29 | IExtendedMessageContext messageContext = extendedMessageContext.get();
30 | ElecCore.tickHandler.registerCall(() -> onMessageThreadSafe(abstractPacket.networkPackageObject, messageContext), messageContext.getReceptionSide());
31 | }
32 |
33 | public abstract void onMessageThreadSafe(CompoundNBT message, IExtendedMessageContext ctx);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/AbstractPacketTileAction.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.ElecCore;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 | import elec332.core.util.NBTBuilder;
6 | import elec332.core.world.WorldHelper;
7 | import net.minecraft.nbt.CompoundNBT;
8 | import net.minecraft.tileentity.TileEntity;
9 | import net.minecraft.util.math.BlockPos;
10 | import net.minecraft.world.World;
11 | import net.minecraftforge.fml.LogicalSide;
12 |
13 | /**
14 | * Created by Elec332 on 4-9-2015.
15 | */
16 | public abstract class AbstractPacketTileAction extends AbstractPacket {
17 |
18 | public AbstractPacketTileAction() {
19 | }
20 |
21 | public AbstractPacketTileAction(TileEntity tile, CompoundNBT message) {
22 | this(tile, message, 0);
23 | }
24 |
25 | public AbstractPacketTileAction(TileEntity tile, CompoundNBT message, int id) {
26 | super(new NBTBuilder().setTag("data", message).setInteger("id", id).setBlockPos(tile.getPos()).serializeNBT());
27 | }
28 |
29 | @Override
30 | public void onMessageThreadSafe(CompoundNBT message, IExtendedMessageContext ctx) {
31 | NBTBuilder tag = new NBTBuilder(message);
32 | BlockPos loc = tag.getBlockPos();
33 | int i = tag.getInteger("id");
34 | CompoundNBT data = tag.getCompound("data");
35 | World world;
36 | if (ctx.getReceptionSide() == LogicalSide.SERVER) {
37 | world = ctx.getWorld();
38 | } else {
39 | world = ElecCore.proxy.getClientWorld();
40 | }
41 | processPacket(world, WorldHelper.getTileAt(world, loc), i, data, ctx);
42 | }
43 |
44 | public abstract void processPacket(World world, TileEntity tile, int id, CompoundNBT message, IExtendedMessageContext ctx);
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/PacketReRenderBlock.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.api.network.IExtendedMessageContext;
4 | import elec332.core.world.WorldHelper;
5 | import net.minecraft.nbt.CompoundNBT;
6 | import net.minecraft.tileentity.TileEntity;
7 | import net.minecraft.world.World;
8 |
9 | /**
10 | * Created by Elec332 on 4-9-2015.
11 | */
12 | public class PacketReRenderBlock extends AbstractPacketTileAction {
13 |
14 | public PacketReRenderBlock() {
15 | }
16 |
17 | public PacketReRenderBlock(TileEntity tile) {
18 | super(tile, writeTileToNBT(tile));
19 | }
20 |
21 | private static CompoundNBT writeTileToNBT(TileEntity tile) {
22 | CompoundNBT tag = new CompoundNBT();
23 | tile.write(tag);
24 | return tag;
25 | }
26 |
27 | @Override
28 | public void processPacket(World world, TileEntity tile, int id, CompoundNBT message, IExtendedMessageContext ctx) {
29 | if (tile != null) {
30 | tile.read(WorldHelper.getBlockState(world, tile.getPos()), message);
31 | WorldHelper.markBlockForRenderUpdate(world, tile.getPos());
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/PacketSyncWidget.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.ElecCore;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 | import elec332.core.inventory.widget.Widget;
6 | import elec332.core.inventory.window.IWidgetContainer;
7 | import elec332.core.inventory.window.Window;
8 | import elec332.core.util.NBTBuilder;
9 | import net.minecraft.inventory.container.Container;
10 | import net.minecraft.nbt.CompoundNBT;
11 | import net.minecraftforge.fml.LogicalSide;
12 |
13 | /**
14 | * Created by Elec332 on 31-7-2015.
15 | */
16 | @SuppressWarnings("unused")
17 | public class PacketSyncWidget extends AbstractPacket {
18 |
19 | public PacketSyncWidget() {
20 | }
21 |
22 | public PacketSyncWidget(CompoundNBT tag, IWidgetContainer widgetContainer, Widget widget) {
23 | super(new NBTBuilder().setTag("containerData", new NBTBuilder().setInteger("widget", widgetContainer.getWidgets().indexOf(widget)).setInteger("window", ((Window) widgetContainer).getWindowID()).serializeNBT()).setTag("data", tag).serializeNBT());
24 | }
25 |
26 | @Override
27 | public void onMessageThreadSafe(CompoundNBT message, IExtendedMessageContext ctx) {
28 | CompoundNBT data = message.getCompound("data");
29 | CompoundNBT containerData = message.getCompound("containerData");
30 | Container openContainer = ElecCore.proxy.getClientPlayer().openContainer;
31 | if (openContainer.windowId == containerData.getInt("window")) {
32 | ((IWidgetContainer) openContainer).getWidgets().get(containerData.getInt("widget")).readNBTChangesFromPacket(data, LogicalSide.CLIENT);
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/PacketTileDataToServer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.api.network.IExtendedMessageContext;
4 | import elec332.core.network.IElecCoreNetworkTile;
5 | import elec332.core.util.NBTBuilder;
6 | import elec332.core.world.WorldHelper;
7 | import net.minecraft.entity.player.ServerPlayerEntity;
8 | import net.minecraft.nbt.CompoundNBT;
9 | import net.minecraft.tileentity.TileEntity;
10 |
11 | /**
12 | * Created by Elec332 on 15-8-2015.
13 | */
14 | @SuppressWarnings("unused")
15 | public class PacketTileDataToServer extends AbstractPacket {
16 |
17 | public PacketTileDataToServer() {
18 | }
19 |
20 | public PacketTileDataToServer(IElecCoreNetworkTile tile, int ID, CompoundNBT data) {
21 | super(new NBTBuilder().setInteger("PacketId", ID).setTag("data", data).setBlockPos(((TileEntity) tile).getPos()).serializeNBT());
22 | }
23 |
24 | @Override
25 | public void onMessageThreadSafe(CompoundNBT message, IExtendedMessageContext ctx) {
26 | NBTBuilder data = new NBTBuilder(message);
27 | int ID = data.getInteger("PacketId");
28 | ServerPlayerEntity sender = (ServerPlayerEntity) ctx.getSender();
29 | IElecCoreNetworkTile tile = (IElecCoreNetworkTile) WorldHelper.getTileAt(sender.getEntityWorld(), data.getBlockPos());
30 | if (tile != null) {
31 | tile.onPacketReceivedFromClient(sender, ID, message.getCompound("data"));
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/PacketWidgetDataToServer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.api.network.IExtendedMessageContext;
4 | import elec332.core.inventory.widget.Widget;
5 | import elec332.core.inventory.window.IWidgetContainer;
6 | import elec332.core.inventory.window.Window;
7 | import elec332.core.inventory.window.WindowManager;
8 | import elec332.core.util.NBTBuilder;
9 | import net.minecraft.nbt.CompoundNBT;
10 | import net.minecraftforge.fml.LogicalSide;
11 |
12 | /**
13 | * Created by Elec332 on 23-8-2015.
14 | */
15 | @SuppressWarnings("unused")
16 | public class PacketWidgetDataToServer extends AbstractPacket {
17 |
18 | public PacketWidgetDataToServer() {
19 | }
20 |
21 | public PacketWidgetDataToServer(CompoundNBT tag, IWidgetContainer widgetContainer, Widget widget) {
22 | super(new NBTBuilder().setTag("containerData", new NBTBuilder().setInteger("widget", widgetContainer.getWidgets().indexOf(widget)).setInteger("window", ((Window) widgetContainer).getWindowID()).serializeNBT()).setTag("data", tag).serializeNBT());
23 | }
24 |
25 | @Override
26 | public void onMessageThreadSafe(CompoundNBT message, IExtendedMessageContext ctx) {
27 | CompoundNBT data = message.getCompound("data");
28 | CompoundNBT containerData = message.getCompound("containerData");
29 | Window window = WindowManager.getOpenWindow(ctx.getSender(), containerData.getInt("window"));
30 | if (window != null) {
31 | window.getWidgets().get(containerData.getInt("widget")).readNBTChangesFromPacket(data, LogicalSide.SERVER);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/network/packets/PacketWindowData.java:
--------------------------------------------------------------------------------
1 | package elec332.core.network.packets;
2 |
3 | import elec332.core.api.network.ElecByteBuf;
4 | import elec332.core.api.network.IExtendedMessageContext;
5 | import elec332.core.api.network.simple.ISimpleNetworkPacketManager;
6 | import elec332.core.api.network.simple.ISimplePacket;
7 | import elec332.core.api.network.simple.ISimplePacketHandler;
8 | import elec332.core.inventory.window.WindowContainer;
9 | import net.minecraft.inventory.container.Container;
10 | import net.minecraft.nbt.CompoundNBT;
11 |
12 | import javax.annotation.Nullable;
13 |
14 | /**
15 | * Created by Elec332 on 3-12-2016.
16 | */
17 | public class PacketWindowData implements ISimplePacket, ISimplePacketHandler {
18 |
19 | public PacketWindowData(WindowContainer container, CompoundNBT tag) {
20 | this.tag = tag;
21 | this.window = container.windowId;
22 | }
23 |
24 | private final CompoundNBT tag;
25 | private final int window;
26 |
27 | @Override
28 | public void toBytes(ElecByteBuf byteBuf) {
29 | byteBuf.writeInt(window);
30 | byteBuf.writeCompoundNBTToBuffer(tag);
31 | }
32 |
33 | @Nullable
34 | @Override
35 | public ISimplePacketHandler getPacketHandler() {
36 | return this;
37 | }
38 |
39 | @Override
40 | public void onPacket(ElecByteBuf data, IExtendedMessageContext messageContext, ISimpleNetworkPacketManager networkHandler) {
41 | Container container = messageContext.getSender().openContainer;
42 | if (container.windowId == data.readInt() && container instanceof WindowContainer) {
43 | ((WindowContainer) container).getWindow().onPacket(data.readCompoundNBTFromBuffer(), messageContext.getReceptionSide());
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/tile/IActivatableTile.java:
--------------------------------------------------------------------------------
1 | package elec332.core.tile;
2 |
3 | import net.minecraft.entity.player.PlayerEntity;
4 | import net.minecraft.util.ActionResultType;
5 | import net.minecraft.util.Hand;
6 | import net.minecraft.util.math.BlockRayTraceResult;
7 |
8 | /**
9 | * Created by Elec332 on 9-2-2019
10 | */
11 | public interface IActivatableTile {
12 |
13 | default ActionResultType onBlockActivated(PlayerEntity player, Hand hand, BlockRayTraceResult hit) {
14 | return ActionResultType.PASS;
15 | }
16 |
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/tile/ITileWithDrops.java:
--------------------------------------------------------------------------------
1 | package elec332.core.tile;
2 |
3 | import net.minecraft.item.ItemStack;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * Created by Elec332 on 7-2-2019
9 | *
10 | * Created because something alike is due to be added to forge, and I need it :)
11 | */
12 | public interface ITileWithDrops {
13 |
14 | public void getDrops(List items, int fortune);
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/tile/sub/SubTileLogicBase.java:
--------------------------------------------------------------------------------
1 | package elec332.core.tile.sub;
2 |
3 | import net.minecraft.nbt.CompoundNBT;
4 | import net.minecraft.util.math.BlockPos;
5 | import net.minecraft.world.World;
6 |
7 | /**
8 | * Created by Elec332 on 20-2-2018
9 | */
10 | public abstract class SubTileLogicBase implements ISubTileLogic {
11 |
12 | public SubTileLogicBase(Data data) {
13 | this.tile = data.tile;
14 | this.id = data.id;
15 | }
16 |
17 | private final TileMultiObject tile;
18 | protected final int id;
19 |
20 | @Override
21 | public final World getWorld() {
22 | return tile.getWorld();
23 | }
24 |
25 | @Override
26 | public final boolean hasWorld() {
27 | return tile.hasWorld();
28 | }
29 |
30 | @Override
31 | public final BlockPos getPos() {
32 | return tile.getPos();
33 | }
34 |
35 | @Override
36 | public final void markDirty() {
37 | tile.markDirty();
38 | }
39 |
40 | @Override
41 | public final void sendPacket(int ID, CompoundNBT data) {
42 | CompoundNBT tag = new CompoundNBT();
43 | tag.putInt("kid", ID);
44 | tag.put("data", data);
45 | tile.sendPacket(id, tag);
46 | }
47 |
48 | public static class Data {
49 |
50 | Data(TileMultiObject tile, int id) {
51 | this.tile = tile;
52 | this.id = id;
53 | }
54 |
55 | private final TileMultiObject tile;
56 | private final int id;
57 |
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/BlockProperties.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraft.state.BooleanProperty;
4 | import net.minecraft.state.EnumProperty;
5 | import net.minecraft.state.properties.BlockStateProperties;
6 | import net.minecraft.util.Direction;
7 |
8 | /**
9 | * Created by Elec332 on 7-12-2015.
10 | */
11 | public final class BlockProperties {
12 |
13 | public static final EnumProperty FACING_NORMAL = BlockStateProperties.FACING;
14 | public static final EnumProperty FACING_ALL = FACING_NORMAL;
15 | public static final EnumProperty FACING_HORIZONTAL = BlockStateProperties.HORIZONTAL_FACING;
16 | public static final BooleanProperty WATERLOGGED = BlockStateProperties.WATERLOGGED;
17 |
18 | public static final BooleanProperty ENABLED = BooleanProperty.create("enabled");
19 | public static final BooleanProperty ACTIVE = BooleanProperty.create("active");
20 | public static final BooleanProperty ON = BooleanProperty.create("on");
21 |
22 | public static final BooleanProperty UP = BlockStateProperties.UP;
23 | public static final BooleanProperty DOWN = BlockStateProperties.DOWN;
24 | public static final BooleanProperty NORTH = BlockStateProperties.NORTH;
25 | public static final BooleanProperty EAST = BlockStateProperties.EAST;
26 | public static final BooleanProperty SOUTH = BlockStateProperties.SOUTH;
27 | public static final BooleanProperty WEST = BlockStateProperties.WEST;
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/EntityHelper.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraft.entity.Entity;
4 | import net.minecraft.entity.EntityType;
5 | import net.minecraft.entity.LivingEntity;
6 | import net.minecraft.util.DamageSource;
7 | import net.minecraft.util.ResourceLocation;
8 | import net.minecraft.util.math.vector.Vector3d;
9 | import net.minecraft.world.World;
10 |
11 | import javax.annotation.Nullable;
12 |
13 | /**
14 | * Created by Elec332 on 13-8-2018.
15 | */
16 | public class EntityHelper {
17 |
18 | /**
19 | * Modifies the entity motion
20 | *
21 | * @param entity The entity to be modified
22 | * @param motionMod The motion that will be added to the entity
23 | */
24 | public static void addMotion(Entity entity, Vector3d motionMod) {
25 | entity.setMotion(entity.getMotion().add(motionMod));
26 | }
27 |
28 | /**
29 | * Creates an entity by a {@link ResourceLocation}
30 | *
31 | * @param name The entity name in the registry
32 | * @param world The world in which the entity has to be created
33 | * @return The new entity, created from the provided name
34 | */
35 | @Nullable
36 | public static Entity createEntity(ResourceLocation name, World world) {
37 | EntityType> entityType = RegistryHelper.getEntities().getValue(name);
38 | return entityType == null ? null : entityType.create(world);
39 | }
40 |
41 | /**
42 | * Insta-kills an entity without glitches, with the specified {@link DamageSource} as cause of death.
43 | *
44 | * @param source The cause of death
45 | * @param target The entity that will be dead very soon
46 | */
47 | public static void smiteEntity(DamageSource source, LivingEntity target) { //non-buggy version by InfinityRaider
48 | target.setHealth(0);
49 | target.onDeath(source);
50 | //target.setDead();
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/LoadTimer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraftforge.fml.ModLoadingStage;
4 | import net.minecraftforge.fml.event.lifecycle.ModLifecycleEvent;
5 | import org.apache.logging.log4j.Logger;
6 |
7 | /**
8 | * Created by Elec332 on 7-5-2016.
9 | *
10 | * A load-timer, for keeping track of mod (event) loading times
11 | */
12 | public class LoadTimer {
13 |
14 | public LoadTimer(Logger logger, String mod) {
15 | this.logger = logger;
16 | this.mod = mod;
17 | }
18 |
19 | private final String mod;
20 | private final Logger logger;
21 | private long start;
22 | private ModLoadingStage lastState;
23 |
24 | /**
25 | * Starts the timer for the specified event, should be called at the beginning of the event
26 | *
27 | * @param event The FML loading event
28 | */
29 | public void startPhase(ModLifecycleEvent event) {
30 | if (lastState != null) {
31 | throw new IllegalStateException("Cannot start phase without ending phase " + lastState + "first.");
32 | }
33 | start = System.currentTimeMillis();
34 | lastState = FMLHelper.getStageFrom(event);
35 | }
36 |
37 | /**
38 | * Stops the timer for the specified event and prints the time it took to the specified logger,
39 | * should be called at the end of the event
40 | *
41 | * @param event The FML loading event
42 | */
43 | public void endPhase(ModLifecycleEvent event) {
44 | ModLoadingStage modState = FMLHelper.getStageFrom(event);
45 | if (this.lastState != modState) {
46 | throw new IllegalArgumentException();
47 | }
48 | lastState = null;
49 | logger.info(mod + " has " + FMLHelper.getLoadingStageName(modState) + " in " + (System.currentTimeMillis() - start) + " ms");
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/MoonPhase.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraft.world.World;
4 |
5 | /**
6 | * Created by Elec332 on 23-8-2016.
7 | *
8 | * The moon phases in Minecraft
9 | *
10 | * Taken from MagicBees, original code can be found here:
11 | * https://github.com/MagicBees/MagicBees/blob/master/src/main/java/magicbees/main/utils/MoonPhase.java
12 | */
13 | public enum MoonPhase {
14 |
15 | FULL("full"),
16 | WANING_GIBBOUS("gibbousWaning"),
17 | WANING_HALF("halfWaning"),
18 | WANING_CRESCENT("crescentWaning"),
19 | NEW("new"),
20 | WAXING_CRESCENT("crescentWaxing"),
21 | WAXING_HALF("halfWaxing"),
22 | WAXING_GIBBOUS("gibbousWaxing");
23 |
24 | private String phaseName;
25 |
26 | MoonPhase(String name) {
27 | this.phaseName = name;
28 | }
29 |
30 | public boolean isBetween(MoonPhase first, MoonPhase second) {
31 | if (first.ordinal() <= second.ordinal()) {
32 | return first.ordinal() <= this.ordinal() && this.ordinal() <= second.ordinal();
33 | } else {
34 | return first.ordinal() <= this.ordinal() && this.ordinal() <= WAXING_GIBBOUS.ordinal() || FULL.ordinal() <= this.ordinal() && this.ordinal() <= second.ordinal();
35 | }
36 | }
37 |
38 | public String getLocalizedName() {
39 | return StatCollector.translateToLocal("moon." + this.phaseName);
40 | }
41 |
42 | public static MoonPhase getMoonPhase(World w) {
43 | return getMoonPhaseFromTime(w.getWorldInfo().getGameTime());
44 | }
45 |
46 | public static MoonPhase getMoonPhaseFromTime(long time) {
47 | return values()[(int) ((time - 6000L) / 24000L) % 8];
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/NBTTypes.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraft.nbt.*;
4 |
5 | /**
6 | * Created by Elec332 on 12-7-2015.
7 | */
8 | public enum NBTTypes {
9 |
10 | END(EndNBT.INSTANCE), //0
11 | BYTE(ByteNBT.ZERO), //1
12 | SHORT(ShortNBT.valueOf((short) 0)), //2
13 | INT(IntNBT.valueOf(0)), //3
14 | LONG(LongNBT.valueOf(0)), //4
15 | FLOAT(FloatNBT.valueOf(0)), //5
16 | DOUBLE(DoubleNBT.ZERO), //6
17 | BYTE_ARRAY(new ByteArrayNBT(new byte[0])), //7
18 | STRING(StringNBT.valueOf("")), //8
19 | LIST(new ListNBT()), //9
20 | COMPOUND(new CompoundNBT()), //10
21 | INT_ARRAY(new IntArrayNBT(new int[0])); //11
22 |
23 | ///##########################///
24 |
25 | NBTTypes(INBT nbtBase) {
26 | this(nbtBase.getId(), nbtBase.getClass());
27 | }
28 |
29 | NBTTypes(byte i, Class extends INBT> clazz) {
30 | this.ID = i;
31 | this.clazz = clazz;
32 | if (i != ordinal()) {
33 | throw new IllegalArgumentException();
34 | }
35 | }
36 |
37 | private final byte ID;
38 | private final Class extends INBT> clazz;
39 |
40 | public byte getID() {
41 | return ID;
42 | }
43 |
44 | public Class extends INBT> getClazz() {
45 | return clazz;
46 | }
47 |
48 | public boolean equals(int i) {
49 | return i == ID;
50 | }
51 |
52 | public static Class extends INBT> getClass(int i) {
53 | for (NBTTypes data : NBTTypes.values()) {
54 | if (data.ID == i) {
55 | return data.clazz;
56 | }
57 | }
58 | throw new IllegalArgumentException("No NBT-Type for ID: " + i);
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/ObjectReference.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import javax.annotation.Nullable;
4 | import java.util.function.Consumer;
5 | import java.util.function.Supplier;
6 |
7 | /**
8 | * Created by Elec332 on 4-1-2019
9 | */
10 | public class ObjectReference implements Supplier, Consumer {
11 |
12 | public static ObjectReference of(@Nullable T ref) {
13 | ObjectReference ret = new ObjectReference<>();
14 | ret.set(ref);
15 | return ret;
16 | }
17 |
18 | public ObjectReference() {
19 | this.ref = null;
20 | }
21 |
22 | private T ref;
23 |
24 | public void set(T obj) {
25 | this.ref = obj;
26 | }
27 |
28 | @Override
29 | public T get() {
30 | return this.ref;
31 | }
32 |
33 | @Override
34 | public void accept(T t) {
35 | set(t);
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/ResourceHelper.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import elec332.core.ElecCore;
4 | import net.minecraft.util.ResourceLocation;
5 |
6 | import javax.annotation.Nonnull;
7 | import java.io.FileNotFoundException;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | /**
12 | * Created by Elec332 on 19-1-2020
13 | */
14 | public class ResourceHelper {
15 |
16 | /**
17 | * Gets the {@link InputStream} from the provided {@link ResourceLocation},
18 | * also works on the {@link net.minecraftforge.api.distmarker.Dist#DEDICATED_SERVER}
19 | * (MC's method doesn't)
20 | *
21 | * @param resourceLocation The location of the resource
22 | * @return The {@link InputStream} from the provided {@link ResourceLocation}
23 | */
24 | @Nonnull
25 | public static InputStream getInputStreamFromResource(@Nonnull ResourceLocation resourceLocation) throws IOException {
26 | String location = "/assets/" + resourceLocation.getNamespace() + "/" + resourceLocation.getPath();
27 | InputStream ret = ElecCore.class.getResourceAsStream(location);
28 | if (ret != null) {
29 | return ret;
30 | }
31 | throw new FileNotFoundException(location);
32 | }
33 |
34 | public static ResourceLocation getItemModelLocation(@Nonnull ResourceLocation name) {
35 | return getPrefixedLocation(name, "item/");
36 | }
37 |
38 | public static ResourceLocation getBlockModelLocation(@Nonnull ResourceLocation name) {
39 | return getPrefixedLocation(name, "block/");
40 | }
41 |
42 | public static ResourceLocation getPrefixedLocation(@Nonnull ResourceLocation name, @Nonnull String prefix) {
43 | return new ResourceLocation(name.getNamespace(), prefix + name.getPath());
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/StatCollector.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util;
2 |
3 | import net.minecraft.util.text.LanguageMap;
4 |
5 | /**
6 | * Created by Elec332 on 10-3-2016.
7 | *
8 | * Translation helper
9 | */
10 | public class StatCollector {
11 |
12 | private static final LanguageMap fallback = LanguageMap.getInstance();
13 |
14 | public static String translateToLocal(String key) {
15 | return LanguageMap.getInstance().func_230503_a_(key);
16 | }
17 |
18 | public static String translateToLocalFormatted(String key, Object... format) {
19 | return String.format(LanguageMap.getInstance().func_230503_a_(key), format);
20 | }
21 |
22 | public static String translateToFallback(String key) {
23 | return fallback.func_230503_a_(key);
24 | }
25 |
26 | public static boolean canTranslate(String key) {
27 | return LanguageMap.getInstance().func_230506_b_(key);
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/function/FuncHelper.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.function;
2 |
3 | import java.util.function.Supplier;
4 |
5 | /**
6 | * Created by Elec332 on 20-1-2019
7 | */
8 | public class FuncHelper {
9 |
10 | public static Runnable safeRunnable(UnsafeRunnable runnable) {
11 | return () -> {
12 | try {
13 | runnable.run();
14 | } catch (Exception e) {
15 | throw new RuntimeException(e);
16 | }
17 | };
18 | }
19 |
20 | public static Supplier safeSupplier(UnsafeSupplier supplier) {
21 | return () -> {
22 | try {
23 | return supplier.get();
24 | } catch (Exception e) {
25 | throw new RuntimeException(e);
26 | }
27 | };
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/function/TriConsumer.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.function;
2 |
3 | import java.util.Objects;
4 |
5 | /**
6 | * Created by Elec332 on 28-7-2020
7 | */
8 | public interface TriConsumer {
9 |
10 | void accept(A k, B v, C s);
11 |
12 | default TriConsumer andThen(TriConsumer super A, ? super B, ? super C> after) {
13 | Objects.requireNonNull(after);
14 | return (a, b, c) -> {
15 | accept(a, b, c);
16 | after.accept(a, b, c);
17 | };
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/function/UnsafeRunnable.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.function;
2 |
3 | /**
4 | * Created by Elec332 on 20-1-2019
5 | */
6 | public interface UnsafeRunnable {
7 |
8 | public void run() throws Exception;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/function/UnsafeSupplier.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.function;
2 |
3 | /**
4 | * Created by Elec332 on 26-1-2019
5 | */
6 | public interface UnsafeSupplier {
7 |
8 | public T get() throws Exception;
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/math/CombinedIndexedVoxelShape.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.math;
2 |
3 | import net.minecraft.util.math.BlockPos;
4 | import net.minecraft.util.math.BlockRayTraceResult;
5 | import net.minecraft.util.math.shapes.VoxelShape;
6 | import net.minecraft.util.math.vector.Vector3d;
7 |
8 | import javax.annotation.Nonnull;
9 | import javax.annotation.Nullable;
10 | import java.util.List;
11 |
12 | /**
13 | * Created by Elec332 on 28-12-2019
14 | *
15 | * Originally created by Amadornes
16 | */
17 | public class CombinedIndexedVoxelShape extends CustomRayTraceVoxelShape {
18 |
19 | public CombinedIndexedVoxelShape(VoxelShape parent, List shapes) {
20 | super(parent);
21 | this.shapes = shapes;
22 | }
23 |
24 | private final List shapes;
25 |
26 | @Override
27 | @Nullable
28 | public BlockRayTraceResult rayTrace(@Nonnull Vector3d start, @Nonnull Vector3d end, @Nonnull BlockPos pos) {
29 | BlockRayTraceResult closest = null;
30 | double closestDist = Double.POSITIVE_INFINITY;
31 | for (VoxelShape shape : shapes) {
32 | BlockRayTraceResult hit = shape.rayTrace(start, end, pos);
33 | if (hit == null) {
34 | continue;
35 | }
36 | double dist = hit.getHitVec().squareDistanceTo(start);
37 | if (closestDist < dist) {
38 | continue;
39 | }
40 | closest = hit;
41 | closestDist = dist;
42 | }
43 | return closest;
44 | }
45 |
46 | }
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/math/IndexedBlockPos.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.math;
2 |
3 | import net.minecraft.dispenser.IPosition;
4 | import net.minecraft.entity.Entity;
5 | import net.minecraft.util.math.BlockPos;
6 | import net.minecraft.util.math.vector.Vector3d;
7 | import net.minecraft.util.math.vector.Vector3i;
8 |
9 | /**
10 | * Created by Elec332 on 5-2-2019
11 | */
12 | public class IndexedBlockPos extends BlockPos {
13 |
14 | public IndexedBlockPos(int x, int y, int z, int index) {
15 | super(x, y, z);
16 | this.index = index;
17 | }
18 |
19 | public IndexedBlockPos(double x, double y, double z, int index) {
20 | super(x, y, z);
21 | this.index = index;
22 | }
23 |
24 | public IndexedBlockPos(Entity source, int index) {
25 | this(source.getPositionVec(), index);
26 | }
27 |
28 | public IndexedBlockPos(Vector3d vec, int index) {
29 | super(vec);
30 | this.index = index;
31 | }
32 |
33 | public IndexedBlockPos(IPosition pos, int index) {
34 | super(pos);
35 | this.index = index;
36 | }
37 |
38 | public IndexedBlockPos(Vector3i source, int index) {
39 | super(source);
40 | this.index = index;
41 | }
42 |
43 | public final int index;
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/elec332/core/util/math/IndexedVoxelShape.java:
--------------------------------------------------------------------------------
1 | package elec332.core.util.math;
2 |
3 | import net.minecraft.util.math.BlockPos;
4 | import net.minecraft.util.math.BlockRayTraceResult;
5 | import net.minecraft.util.math.shapes.VoxelShape;
6 | import net.minecraft.util.math.vector.Vector3d;
7 |
8 | import javax.annotation.Nonnull;
9 | import javax.annotation.Nullable;
10 |
11 | /**
12 | * Created by Elec332 on 28-12-2019
13 | *
14 | * Originally created by Amadornes
15 | */
16 | public class IndexedVoxelShape extends CustomRayTraceVoxelShape {
17 |
18 | public IndexedVoxelShape(VoxelShape shape, int subHit, Object hitInfo) {
19 | super(shape);
20 | this.subHit = subHit;
21 | this.hitInfo = hitInfo;
22 | }
23 |
24 | private final int subHit;
25 | private final Object hitInfo;
26 |
27 | @Override
28 | @Nullable
29 | public BlockRayTraceResult rayTrace(@Nonnull Vector3d start, @Nonnull Vector3d end, @Nonnull BlockPos pos) {
30 | BlockRayTraceResult hit = shape.rayTrace(start, end, pos);
31 | if (hit == null) {
32 | return null;
33 | }
34 | hit.subHit = subHit;
35 | hit.hitInfo = hitInfo;
36 | return hit;
37 | }
38 |
39 | }
--------------------------------------------------------------------------------
/src/main/resources/META-INF/accesstransformer.cfg:
--------------------------------------------------------------------------------
1 | public net.minecraft.world.Explosion field_77280_f #size
2 |
3 | public net.minecraft.tileentity.MobSpawnerBaseLogic func_98279_f()Z #isActivated
4 |
5 | public net.minecraft.util.math.shapes.VoxelShape func_211542_b(DDD)Z #contains
6 |
7 | ##Worldgen
8 |
9 | public net.minecraft.world.gen.feature.Feature field_214535_a #configFactory
10 | public net.minecraft.world.gen.carver.ConfiguredCarver field_222732_a # carver
11 |
12 | public net.minecraft.world.biome.Biome func_201866_a(Lnet/minecraft/entity/EnumCreatureType;Lnet/minecraft/world/biome/Biome$SpawnListEntry;)V #addSpawn
13 | public net.minecraft.world.chunk.Chunk field_76634_f #heightMap
14 | public net.minecraft.world.gen.NoiseChunkGenerator field_236080_h_ #DimensionSettings
15 | public-f net.minecraft.world.biome.BiomeGenerationSettings * #All fields, otherwise you cannot add features at runtime
16 |
17 | ##Client
18 | public-f net.minecraft.client.renderer.model.ModelBakery field_209607_C #STATE_CONTAINER_OVERRIDES
19 |
20 | public net.minecraft.client.renderer.RenderType field_228629_af_ #needsSorting
21 | public net.minecraft.client.renderer.RenderType$State *
22 | public net.minecraft.client.renderer.RenderState$TextureState field_228604_S_ #mipmap
23 | public net.minecraft.client.renderer.RenderState$TextureState field_228603_R_ #blur
24 |
25 | ##Data
26 | protected-f net.minecraft.data.loot.BlockLootTables field_218578_f #IMMUNE_TO_EXPLOSIONS
27 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/cpw.mods.modlauncher.serviceapi.ILaunchPluginService:
--------------------------------------------------------------------------------
1 | elec332.core.loader.WorldEventListenerHook
--------------------------------------------------------------------------------
/src/main/resources/assets/eleccore/buttons.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elecs-Mods/ElecCore/7c12616a96094682e4f36ab9fd76ecaf6fa3bcbd/src/main/resources/assets/eleccore/buttons.png
--------------------------------------------------------------------------------
/src/main/resources/assets/eleccore/default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elecs-Mods/ElecCore/7c12616a96094682e4f36ab9fd76ecaf6fa3bcbd/src/main/resources/assets/eleccore/default.png
--------------------------------------------------------------------------------
/src/main/resources/assets/eleccore/lang/en_US.lang:
--------------------------------------------------------------------------------
1 | ##TAB
2 | itemGroup.Elecs_Mods=Elec's Mods
3 |
4 | moon.full=Full Moon
5 | moon.gibbousWaning=Waning Gibbous
6 | moon.gibbousWaxing=Waxing Gibbous
7 | moon.halfWaning=Waning Half
8 | moon.halfWaxing=Waxing Half
9 | moon.crescentWaning=Waning Crescent
10 | moon.crescentWaxing=Waxing Crescent
11 | moon.new=New Moon
12 |
--------------------------------------------------------------------------------
/src/main/resources/assets/eleccore/models/item/entity.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/chest",
3 | "textures": {
4 | "particle": "missingno"
5 | }
6 | }
--------------------------------------------------------------------------------
/src/main/resources/assets/eleccore/progressbars.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Elecs-Mods/ElecCore/7c12616a96094682e4f36ab9fd76ecaf6fa3bcbd/src/main/resources/assets/eleccore/progressbars.png
--------------------------------------------------------------------------------