Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Convert Tabs to (4) Spaces #34

Closed
wants to merge 12 commits into from
88 changes: 88 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,88 @@
# Contributing Guidelines

## General Pull Request Rules

In order for your PR to be accepted:
* Your code/addition must be SFW (safe for work)
* Your code must not break the mod
* Your code must not change the concept of someone else's idea
* Your code must follow the style guidelines below

## Style Guidelines

1. The order of members in a class **must** be as follows:
- Static Fields
- Static Initializers
- Non-Static Fields
- Non-Static Initializers
- Constructors
- Static Methods
- Non-Static Methods
- Types (Inner Classes)

2. The the order within each of these groups of members **must** be as follows:
- Public
- Protected
- Package
- Private

3. You **must** use spaces in place of tabs and the tab width will be 4 spaces.

4. You **must** follow these braces rules:
- Braces should be on the end of the current line instead of a new line
- Braces do not need to be used if a jump keyword is used and it is the only line after the statement.
- `else`, `catch`, `finally`, `while` and `do...while` loops must go on the same line as the closing brace.

5. The default file encoding **must** be UTF-8.
6. All textures **must** be 16x16(for items and blocks) and a PNG.
7. All sounds **must** be `.ogg`.
8. You **must** add any additions or any vanilla modifications to the README.md.
9. You **must** not use data generators, as this has already caused tonnes of issues for the project.
10. You **must** use Java. **Not** Kotlin, Groovy, Scala or any other Java Bytecode based language.

11. You **must** follow the Oracle Java Naming Conventions which are as follows:
- Packages: lower_snake_case
- Classes: UpperCamelCase (Avoid abbreviations unless the acronym or abbreviation is more widely used than the long form. For example HTML or URI/URL/URN)
- Interfaces: UpperCamelCase (Should describe what the interfaces does, do not prefix with I)
- Methods: camelCase (Should be verbs and well describe what the method does)
- Constants: UPPER_SNAKE_CASE - Sometimes known as SCREAMING_SNAKE_CASE (ANSI Constants should be avoided)
- Variables: camelCase (Should not start with `\_` or `$` and should not be a singular letter unless the letter makes sense. For example `int x = getPosX()`. An example of a violation would be `int j = getFooBar() * WIBBLE_WOBBLE`)

12. Java Identifiers **must** follow the following order:
- public/private/protected
- abstract
- static
- final
- transient
- volatile
- default
- synchronized
- native
- strictfp

13. Imports **must** be formatted as follows:
- Sorted:
- Non-Static Imports
- Static Imports
- Package Origin according to the following order:
- `java` packages
- `javax` packages
- external packages (e.g. `org.xml`)
- internal packages (e.g. `com.sun`)
- Imports should not be line-wrapped, no matter the length.
- No unused imports should be present.
- Wildcard imports should be avoided unless a very large number of classes(dozens) are imported from that package.
- No more than 1 wildcard import per file should exist.

14. Case lines **must** be indented with a (4 space) tab.
15. Square brackets for arrays **must** be at the type and not at the variable.
16. Annotations **must** be on a separate line from the declaration unless it is annotating a parameter.
17. Lambda Expressions **must** not contain a body if the body is only 1 line.
18. Method References **must** be used in replacement for a lambda expression when possible.
19. Parameter Types in lambda expressions **must** be ommited unless they increase readability.
20. Redudent Parenthesis **must** be removed unless they are clearly increasing readabgility.
21. Long literals **must** use uppercase `L`.
22. Hexadecimal literals **must** use uppercase `A-F`.
23. All other literals **must** use lowercase letters.

For any other niche cases, refer to https://cr.openjdk.java.net/~alundblad/styleguide/index-v6.html
3 changes: 1 addition & 2 deletions README.md
Expand Up @@ -11,8 +11,7 @@ Community Mod. Just for fun.
Alternatively, you can do a lot of these steps in your IDE or GitHub Desktop Application.

### How will my PR be accepted?
Your code will be reviewed by one of the Triage Team. If your code is SFW (Safe For Work), does not break the mod, and
does not change the concept or someone else's idea, then the code will be merged. If it breaks any of these it will be
Your code will be reviewed by one of the Triage Team. If your code is SFW (Safe For Work), does not break the mod, does not change the concept of someone else's idea, and follows the [style guidelines](https://github.com/DaRealTurtyWurty/CommunityMod/blob/main/CONTRIBUTING.md), then the code will be merged. If it breaks any of these it will be
closed. You must also add to this file in the [section below](#whats-included-in-this-mod) for what you have added/modified in your PR. If you do not
supply an edit to this README.md, then you will be asked to add to it. If you continue failing to do so, your PR will be
closed.
Expand Down
55 changes: 25 additions & 30 deletions src/main/java/io/github/communitymod/CommunityMod.java
@@ -1,12 +1,7 @@
package io.github.communitymod;

import io.github.communitymod.core.config.Config;
import io.github.communitymod.core.init.BlockEntityInit;
import io.github.communitymod.core.init.BlockInit;
import io.github.communitymod.core.init.EntityInit;
import io.github.communitymod.core.init.ItemInit;
import io.github.communitymod.core.init.SoundsInit;
import io.github.communitymod.core.init.StructureInit;
import io.github.communitymod.core.init.*;
import io.github.communitymod.network.PacketHandler;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.CreativeModeTab;
Expand All @@ -20,34 +15,34 @@
@Mod(CommunityMod.MODID)
public class CommunityMod {

public static final String MODID = "communitymod";
public static final String MODID = "communitymod";

public static final CreativeModeTab TAB = new CreativeModeTab(MODID) {
public static final CreativeModeTab TAB = new CreativeModeTab(MODID) {

@Override
public ItemStack makeIcon() {
final var resourceLocation = new ResourceLocation(Config.CLIENT.tabIcon.get());
return (ForgeRegistries.ITEMS.containsKey(resourceLocation)
? ForgeRegistries.ITEMS.getValue(resourceLocation)
: ItemInit.BEANS.get()).getDefaultInstance();
}
};
@Override
public ItemStack makeIcon() {
final var resourceLocation = new ResourceLocation(Config.CLIENT.tabIcon.get());
return (ForgeRegistries.ITEMS.containsKey(resourceLocation)
? ForgeRegistries.ITEMS.getValue(resourceLocation)
: ItemInit.BEANS.get()).getDefaultInstance();
}
};

public CommunityMod() {
final var bus = FMLJavaModLoadingContext.get().getModEventBus();
public CommunityMod() {
final var bus = FMLJavaModLoadingContext.get().getModEventBus();

ItemInit.ITEMS.register(bus);
BlockInit.BLOCKS.register(bus);
StructureInit.STRUCTURES.register(bus);
BlockInit.toBlacklist();
BlockEntityInit.BLOCK_ENTITIES.register(bus);
EntityInit.ENTITIES.register(bus);
EntityInit.registerSpawnEggs();
SoundsInit.SOUNDS.register(bus);
ItemInit.ITEMS.register(bus);
BlockInit.BLOCKS.register(bus);
StructureInit.STRUCTURES.register(bus);
BlockInit.toBlacklist();
BlockEntityInit.BLOCK_ENTITIES.register(bus);
EntityInit.ENTITIES.register(bus);
EntityInit.registerSpawnEggs();
SoundsInit.SOUNDS.register(bus);

ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.COMMON, Config.COMMON_SPEC);
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, Config.CLIENT_SPEC);

PacketHandler.init();
}
PacketHandler.init();
}
}
34 changes: 17 additions & 17 deletions src/main/java/io/github/communitymod/client/ClientEvents.java
Expand Up @@ -13,26 +13,26 @@

public final class ClientEvents {

@EventBusSubscriber(modid = CommunityMod.MODID, bus = Bus.FORGE, value = Dist.CLIENT)
public static final class ForgeEvents {
@EventBusSubscriber(modid = CommunityMod.MODID, bus = Bus.FORGE, value = Dist.CLIENT)
public static final class ForgeEvents {

}
}

@EventBusSubscriber(modid = CommunityMod.MODID, bus = Bus.MOD, value = Dist.CLIENT)
public static final class ModEvents {
@SubscribeEvent
public static void clientSetup(final FMLClientSetupEvent event) {
@EventBusSubscriber(modid = CommunityMod.MODID, bus = Bus.MOD, value = Dist.CLIENT)
public static final class ModEvents {
@SubscribeEvent
public static void clientSetup(final FMLClientSetupEvent event) {

}
}

@SubscribeEvent
public static void registerLayers(final EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(BeanRenderer.BEAN_LAYER, BeanModel::createBodyMesh);
}
@SubscribeEvent
public static void registerLayers(final EntityRenderersEvent.RegisterLayerDefinitions event) {
event.registerLayerDefinition(BeanRenderer.BEAN_LAYER, BeanModel::createBodyMesh);
}

@SubscribeEvent
public static void registerRenderers(final EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(EntityInit.BEAN_ENTITY.get(), BeanRenderer::new);
}
}
@SubscribeEvent
public static void registerRenderers(final EntityRenderersEvent.RegisterRenderers event) {
event.registerEntityRenderer(EntityInit.BEAN_ENTITY.get(), BeanRenderer::new);
}
}
}
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;

import io.github.communitymod.common.entities.BeanEntity;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.ModelPart;
Expand All @@ -13,50 +12,50 @@

public class BeanModel<T extends BeanEntity> extends EntityModel<T> {

private final ModelPart main;

public BeanModel(ModelPart model) {
this.main = model;
}

public static LayerDefinition createBodyMesh() {
final var meshDefinition = new MeshDefinition();
final var partDefinition = meshDefinition.getRoot();

partDefinition.addOrReplaceChild("main",
CubeListBuilder.create().texOffs(24, 19).addBox(-2.0f, -6.0f, 0.0f, 5.0f, 1.0f, 1.0f).texOffs(24, 17)
.addBox(-3.0f, -7.0f, 0.0f, 8.0f, 1.0f, 1.0f).texOffs(0, 14)
.addBox(-4.0f, -9.0f, 0.0f, 10.0f, 2.0f, 1.0f).texOffs(21, 13)
.addBox(-2.0f, -12.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(22, 2)
.addBox(-1.0f, -13.0f, 0.0f, 9.0f, 1.0f, 1.0f).texOffs(0, 0)
.addBox(-1.0f, -19.0f, 0.0f, 10.0f, 6.0f, 1.0f).texOffs(0, 21)
.addBox(-3.0f, -11.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 9)
.addBox(-4.0f, -10.0f, 0.0f, 11.0f, 1.0f, 1.0f).texOffs(0, 19)
.addBox(-2.0f, -21.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 17)
.addBox(-3.0f, -22.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 7)
.addBox(-4.0f, -23.0f, 0.0f, 11.0f, 1.0f, 1.0f).texOffs(0, 11)
.addBox(-4.0f, -25.0f, 0.0f, 10.0f, 2.0f, 1.0f).texOffs(22, 15)
.addBox(-3.0f, -26.0f, 0.0f, 8.0f, 1.0f, 1.0f).texOffs(0, 23)
.addBox(-2.0f, -27.0f, 0.0f, 5.0f, 1.0f, 1.0f).texOffs(22, 0)
.addBox(-1.0f, -20.0f, 0.0f, 9.0f, 1.0f, 1.0f).texOffs(24, 4)
.addBox(-2.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f).texOffs(12, 23)
.addBox(2.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f).texOffs(0, 25)
.addBox(-2.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f).texOffs(24, 21).addBox(2.0f, -1.0f, -1.0f, 1.0f,
1.0f, 1.0f),
PartPose.offsetAndRotation(0.0f, 24.0f, 0.0f, 0.0f, 0.0f, 0.0f));

return LayerDefinition.create(meshDefinition, 64, 64);
}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
float red, float green, float blue, float alpha) {
this.main.render(poseStack, buffer, packedLight, packedOverlay);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw,
float headPitch) {
// Use this method to setup the animation and rotation angles
}
private final ModelPart main;

public BeanModel(ModelPart model) {
this.main = model;
}

public static LayerDefinition createBodyMesh() {
final var meshDefinition = new MeshDefinition();
final var partDefinition = meshDefinition.getRoot();

partDefinition.addOrReplaceChild("main",
CubeListBuilder.create().texOffs(24, 19).addBox(-2.0f, -6.0f, 0.0f, 5.0f, 1.0f, 1.0f).texOffs(24, 17)
.addBox(-3.0f, -7.0f, 0.0f, 8.0f, 1.0f, 1.0f).texOffs(0, 14)
.addBox(-4.0f, -9.0f, 0.0f, 10.0f, 2.0f, 1.0f).texOffs(21, 13)
.addBox(-2.0f, -12.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(22, 2)
.addBox(-1.0f, -13.0f, 0.0f, 9.0f, 1.0f, 1.0f).texOffs(0, 0)
.addBox(-1.0f, -19.0f, 0.0f, 10.0f, 6.0f, 1.0f).texOffs(0, 21)
.addBox(-3.0f, -11.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 9)
.addBox(-4.0f, -10.0f, 0.0f, 11.0f, 1.0f, 1.0f).texOffs(0, 19)
.addBox(-2.0f, -21.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 17)
.addBox(-3.0f, -22.0f, 0.0f, 10.0f, 1.0f, 1.0f).texOffs(0, 7)
.addBox(-4.0f, -23.0f, 0.0f, 11.0f, 1.0f, 1.0f).texOffs(0, 11)
.addBox(-4.0f, -25.0f, 0.0f, 10.0f, 2.0f, 1.0f).texOffs(22, 15)
.addBox(-3.0f, -26.0f, 0.0f, 8.0f, 1.0f, 1.0f).texOffs(0, 23)
.addBox(-2.0f, -27.0f, 0.0f, 5.0f, 1.0f, 1.0f).texOffs(22, 0)
.addBox(-1.0f, -20.0f, 0.0f, 9.0f, 1.0f, 1.0f).texOffs(24, 4)
.addBox(-2.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f).texOffs(12, 23)
.addBox(2.0f, -5.0f, 0.0f, 1.0f, 5.0f, 1.0f).texOffs(0, 25)
.addBox(-2.0f, -1.0f, -1.0f, 1.0f, 1.0f, 1.0f).texOffs(24, 21).addBox(2.0f, -1.0f, -1.0f, 1.0f,
1.0f, 1.0f),
PartPose.offsetAndRotation(0.0f, 24.0f, 0.0f, 0.0f, 0.0f, 0.0f));

return LayerDefinition.create(meshDefinition, 64, 64);
}

@Override
public void renderToBuffer(PoseStack poseStack, VertexConsumer buffer, int packedLight, int packedOverlay,
float red, float green, float blue, float alpha) {
this.main.render(poseStack, buffer, packedLight, packedOverlay);
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw,
float headPitch) {
// Use this method to setup the animation and rotation angles
}
}
Expand Up @@ -9,18 +9,18 @@

public class BeanRenderer<T extends BeanEntity> extends MobRenderer<T, BeanModel<T>> {

public static final ModelLayerLocation BEAN_LAYER = new ModelLayerLocation(
new ResourceLocation(CommunityMod.MODID, "bean"), "main");
public static final ModelLayerLocation BEAN_LAYER = new ModelLayerLocation(
new ResourceLocation(CommunityMod.MODID, "bean"), "main");

private static final ResourceLocation ENTITY_TEXTURE = new ResourceLocation(CommunityMod.MODID,
"textures/entities/bean.png");
private static final ResourceLocation ENTITY_TEXTURE = new ResourceLocation(CommunityMod.MODID,
"textures/entities/bean.png");

public BeanRenderer(Context context) {
super(context, new BeanModel<>(context.bakeLayer(BEAN_LAYER)), 0.5f);
}
public BeanRenderer(Context context) {
super(context, new BeanModel<>(context.bakeLayer(BEAN_LAYER)), 0.5f);
}

@Override
public ResourceLocation getTextureLocation(T entity) {
return ENTITY_TEXTURE;
}
@Override
public ResourceLocation getTextureLocation(T entity) {
return ENTITY_TEXTURE;
}
}