Skip to content

Commit

Permalink
Migrate from javax annotations to jetbrains annotations and remove ou…
Browse files Browse the repository at this point in the history
…r own custom NonNull annotation as now that forge ships with jetbrains annotations available we are able to safely use those in the API
  • Loading branch information
pupnewfster committed Jun 24, 2022
1 parent f16065c commit 6a61646
Show file tree
Hide file tree
Showing 1,472 changed files with 6,232 additions and 7,083 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Please make any localization contributions via [crowdin](https://crowdin.com/pro

## Code contributions

While we have not gotten around to setting up a code style for eclipse yet as we are mostly IntelliJ IDEA users, for the most part we use Google's java formatting style, modified to four spaces, wider column widths, and less force wrapping. For IntelliJ users you can find the style [here](https://github.com/mekanism/Mekanism/blob/1.18.x/docs/GoogleStyle4Indents.xml), and information on how to import a code style into IntelliJ can be found [here](https://www.jetbrains.com/help/idea/settings-code-style.html).
While we have not gotten around to setting up a code style for eclipse yet as we are mostly IntelliJ IDEA users, for the most part we use Google's java formatting style, modified to four spaces, wider column widths, and less force wrapping. For IntelliJ users you can find the style [here](https://github.com/mekanism/Mekanism/blob/1.19.x/docs/Mekanism.xml), and information on how to import a code style into IntelliJ can be found [here](https://www.jetbrains.com/help/idea/settings-code-style.html).
2 changes: 0 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,6 @@ dependencies {
//We use https://github.com/quicktheories/QuickTheories to allow for implementing property based testing
testImplementation "org.quicktheories:quicktheories:${quicktheories_version}"

compileOnly "org.jetbrains:annotations:${jb_annotations}"

compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common-api:${jei_version}")
compileOnly fg.deobf("mezz.jei:jei-${minecraft_version}-forge-api:${jei_version}")
runtimeOnly fg.deobf("mezz.jei:jei-${minecraft_version}-common:${jei_version}")
Expand Down
8 changes: 5 additions & 3 deletions docs/GoogleStyle4Indents.xml → docs/Mekanism.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@
<REPEAT_ANNOTATIONS>
<ANNO name="javax.annotation.Nonnull" />
<ANNO name="javax.annotation.Nullable" />
<ANNO name="javax.annotation.ParametersAreNonnullByDefault" />
<ANNO name="mekanism.api.annotations.FieldsAreNonnullByDefault" />
<ANNO name="mekanism.api.annotations.NonNull" />
<ANNO name="mekanism.api.annotations.FieldsAreNotNullByDefault" />
<ANNO name="mekanism.api.annotations.NothingNullByDefault" />
<ANNO name="mekanism.api.annotations.ParametersAreNotNullByDefault" />
<ANNO name="net.minecraft.MethodsReturnNonnullByDefault" />
<ANNO name="org.jetbrains.annotations.NotNull" />
<ANNO name="org.jetbrains.annotations.Nullable" />
</REPEAT_ANNOTATIONS>
</JavaCodeStyleSettings>
<Objective-C>
Expand Down
5 changes: 0 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ minecraft_version_range=[1.19]
#This specifies what type of release it will be uploaded to CurseForge and Modrinth as
# options are: alpha, beta, release
release_type=alpha
#This determines the minimum version of optional dependencies
# Only bump them whenever we need access to a feature that is not available in earlier versions
# Currently No min versions for optional dependencies

jb_annotations=23.0.0

#JUnit/Testing dependencies
junit_version=5.8.2
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package mekanism.additions.client.model;

import java.util.List;
import javax.annotation.Nonnull;
import mekanism.additions.common.MekanismAdditions;
import mekanism.additions.common.entity.baby.EntityBabyCreeper;
import net.minecraft.client.model.AgeableListModel;
Expand All @@ -14,6 +13,7 @@
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class ModelBabyCreeper extends AgeableListModel<EntityBabyCreeper> {

Expand Down Expand Up @@ -59,20 +59,20 @@ public ModelBabyCreeper(ModelPart root) {
this.rightFrontLeg = root.getChild("left_front_leg");
}

@Nonnull
@NotNull
@Override
protected Iterable<ModelPart> headParts() {
return List.of(this.head);
}

@Nonnull
@NotNull
@Override
protected Iterable<ModelPart> bodyParts() {
return List.of(this.body, this.leftHindLeg, this.rightHindLeg, this.leftFrontLeg, this.rightFrontLeg);
}

@Override
public void setupAnim(@Nonnull EntityBabyCreeper creeper, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
public void setupAnim(@NotNull EntityBabyCreeper creeper, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.head.yRot = netHeadYaw * ((float) Math.PI / 180F);
this.head.xRot = headPitch * ((float) Math.PI / 180F);
this.leftHindLeg.xRot = Mth.cos(limbSwing * 0.6662F) * 1.4F * limbSwingAmount;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
package mekanism.additions.client.model;

import java.util.List;
import javax.annotation.Nonnull;
import mekanism.additions.common.entity.baby.EntityBabyEnderman;
import net.minecraft.client.model.EndermanModel;
import net.minecraft.client.model.geom.ModelPart;
import org.jetbrains.annotations.NotNull;

public class ModelBabyEnderman extends EndermanModel<EntityBabyEnderman> {

public ModelBabyEnderman(ModelPart part) {
super(part);
}

@Nonnull
@NotNull
@Override
protected Iterable<ModelPart> headParts() {
//Make the "hat" (the jaw) be part of the head for scaling purposes
return List.of(this.head, this.hat);
}

@Nonnull
@NotNull
@Override
protected Iterable<ModelPart> bodyParts() {
return List.of(this.body, this.rightArm, this.leftArm, this.rightLeg, this.leftLeg);
}

@Override
public void setupAnim(@Nonnull EntityBabyEnderman enderman, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
public void setupAnim(@NotNull EntityBabyEnderman enderman, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
super.setupAnim(enderman, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch);
//Shift the head and the "hat" (jaw) be in the proper place for baby endermen
head.y += 5.0F;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package mekanism.additions.client.render.entity;

import com.mojang.blaze3d.vertex.PoseStack;
import javax.annotation.Nonnull;
import mekanism.additions.client.model.ModelBabyCreeper;
import mekanism.additions.client.render.entity.layer.BabyCreeperChargeLayer;
import mekanism.additions.common.entity.baby.EntityBabyCreeper;
import net.minecraft.client.renderer.entity.EntityRendererProvider;
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

/**
* Copy of vanilla's creeper render, modified to use our own model/layer that is properly scaled
Expand Down Expand Up @@ -40,9 +40,9 @@ protected float getWhiteOverlayProgress(EntityBabyCreeper creeper, float partial
return (int) (f * 10.0F) % 2 == 0 ? 0.0F : Mth.clamp(f, 0.5F, 1.0F);
}

@Nonnull
@NotNull
@Override
public ResourceLocation getTextureLocation(@Nonnull EntityBabyCreeper entity) {
public ResourceLocation getTextureLocation(@NotNull EntityBabyCreeper entity) {
return CREEPER_TEXTURES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.vertex.PoseStack;
import java.util.Random;
import javax.annotation.Nonnull;
import mekanism.additions.client.model.ModelBabyEnderman;
import mekanism.additions.client.render.entity.layer.BabyEndermanEyesLayer;
import mekanism.additions.client.render.entity.layer.BabyEndermanHeldBlockLayer;
Expand All @@ -13,6 +12,7 @@
import net.minecraft.client.renderer.entity.MobRenderer;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.phys.Vec3;
import org.jetbrains.annotations.NotNull;

/**
* Copy of vanilla's enderman render, modified to use our own model/layer that is properly scaled, so that the block is held in the correct spot and the head is in the
Expand All @@ -30,14 +30,14 @@ public RenderBabyEnderman(EntityRendererProvider.Context context) {
}

@Override
public void render(EntityBabyEnderman enderman, float entityYaw, float partialTicks, @Nonnull PoseStack matrix, @Nonnull MultiBufferSource renderer, int packedLightIn) {
public void render(EntityBabyEnderman enderman, float entityYaw, float partialTicks, @NotNull PoseStack matrix, @NotNull MultiBufferSource renderer, int packedLightIn) {
ModelBabyEnderman model = getModel();
model.carrying = enderman.getCarriedBlock() != null;
model.creepy = enderman.isCreepy();
super.render(enderman, entityYaw, partialTicks, matrix, renderer, packedLightIn);
}

@Nonnull
@NotNull
@Override
public Vec3 getRenderOffset(EntityBabyEnderman enderman, float partialTicks) {
if (enderman.isCreepy()) {
Expand All @@ -46,9 +46,9 @@ public Vec3 getRenderOffset(EntityBabyEnderman enderman, float partialTicks) {
return super.getRenderOffset(enderman, partialTicks);
}

@Nonnull
@NotNull
@Override
public ResourceLocation getTextureLocation(@Nonnull EntityBabyEnderman enderman) {
public ResourceLocation getTextureLocation(@NotNull EntityBabyEnderman enderman) {
return ENDERMAN_TEXTURES;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.VertexConsumer;
import java.util.List;
import javax.annotation.Nonnull;
import mekanism.additions.client.model.AdditionsModelCache;
import mekanism.additions.common.MekanismAdditions;
import mekanism.additions.common.entity.EntityBalloon;
Expand All @@ -17,6 +16,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;

public class RenderBalloon extends EntityRenderer<EntityBalloon> {

Expand All @@ -26,14 +26,14 @@ public RenderBalloon(EntityRendererProvider.Context context) {
super(context);
}

@Nonnull
@NotNull
@Override
public ResourceLocation getTextureLocation(@Nonnull EntityBalloon entity) {
public ResourceLocation getTextureLocation(@NotNull EntityBalloon entity) {
return BALLOON_TEXTURE;
}

@Override
public void render(@Nonnull EntityBalloon balloon, float entityYaw, float partialTick, @Nonnull PoseStack matrix, @Nonnull MultiBufferSource renderer, int light) {
public void render(@NotNull EntityBalloon balloon, float entityYaw, float partialTick, @NotNull PoseStack matrix, @NotNull MultiBufferSource renderer, int light) {
matrix.pushPose();
matrix.translate(-0.5, -1, -0.5);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import javax.annotation.Nonnull;
import mekanism.additions.common.entity.EntityObsidianTNT;
import mekanism.additions.common.registries.AdditionsBlocks;
import net.minecraft.client.renderer.MultiBufferSource;
Expand All @@ -13,6 +12,7 @@
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;

public class RenderObsidianTNTPrimed extends EntityRenderer<EntityObsidianTNT> {

Expand All @@ -25,7 +25,7 @@ public RenderObsidianTNTPrimed(EntityRendererProvider.Context context) {
}

@Override
public void render(@Nonnull EntityObsidianTNT tnt, float entityYaw, float partialTick, @Nonnull PoseStack matrix, @Nonnull MultiBufferSource renderer, int light) {
public void render(@NotNull EntityObsidianTNT tnt, float entityYaw, float partialTick, @NotNull PoseStack matrix, @NotNull MultiBufferSource renderer, int light) {
matrix.pushPose();
matrix.translate(0, 0.5, 0);
if (tnt.getFuse() - partialTick + 1.0F < 10.0F) {
Expand All @@ -46,9 +46,9 @@ public void render(@Nonnull EntityObsidianTNT tnt, float entityYaw, float partia
super.render(tnt, entityYaw, partialTick, matrix, renderer, light);
}

@Nonnull
@NotNull
@Override
public ResourceLocation getTextureLocation(@Nonnull EntityObsidianTNT entity) {
public ResourceLocation getTextureLocation(@NotNull EntityObsidianTNT entity) {
return TextureAtlas.LOCATION_BLOCKS;
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package mekanism.additions.client.render.entity.layer;

import javax.annotation.Nonnull;
import mekanism.additions.client.model.ModelBabyCreeper;
import mekanism.additions.common.entity.baby.EntityBabyCreeper;
import net.minecraft.client.model.EntityModel;
import net.minecraft.client.model.geom.EntityModelSet;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.EnergySwirlLayer;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;

public class BabyCreeperChargeLayer extends EnergySwirlLayer<EntityBabyCreeper, ModelBabyCreeper> {

Expand All @@ -24,13 +24,13 @@ protected float xOffset(float modifier) {
return modifier * 0.01F;
}

@Nonnull
@NotNull
@Override
protected ResourceLocation getTextureLocation() {
return POWER_LOCATION;
}

@Nonnull
@NotNull
@Override
protected EntityModel<EntityBabyCreeper> model() {
return this.creeperModel;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package mekanism.additions.client.render.entity.layer;

import javax.annotation.Nonnull;
import mekanism.additions.client.model.ModelBabyEnderman;
import mekanism.additions.common.entity.baby.EntityBabyEnderman;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.renderer.entity.RenderLayerParent;
import net.minecraft.client.renderer.entity.layers.EyesLayer;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;

public class BabyEndermanEyesLayer extends EyesLayer<EntityBabyEnderman, ModelBabyEnderman> {

Expand All @@ -16,7 +16,7 @@ public BabyEndermanEyesLayer(RenderLayerParent<EntityBabyEnderman, ModelBabyEnde
super(renderer);
}

@Nonnull
@NotNull
@Override
public RenderType renderType() {
return RENDER_TYPE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Vector3f;
import javax.annotation.Nonnull;
import mekanism.additions.client.model.ModelBabyEnderman;
import mekanism.additions.common.entity.baby.EntityBabyEnderman;
import net.minecraft.client.Minecraft;
Expand All @@ -12,6 +11,7 @@
import net.minecraft.client.renderer.texture.OverlayTexture;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraftforge.client.model.data.EmptyModelData;
import org.jetbrains.annotations.NotNull;

public class BabyEndermanHeldBlockLayer extends RenderLayer<EntityBabyEnderman, ModelBabyEnderman> {

Expand All @@ -20,7 +20,7 @@ public BabyEndermanHeldBlockLayer(RenderLayerParent<EntityBabyEnderman, ModelBab
}

@Override
public void render(@Nonnull PoseStack matrix, @Nonnull MultiBufferSource renderer, int light, EntityBabyEnderman enderman, float limbSwing, float limbSwingAmount,
public void render(@NotNull PoseStack matrix, @NotNull MultiBufferSource renderer, int light, EntityBabyEnderman enderman, float limbSwing, float limbSwingAmount,
float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) {
BlockState blockstate = enderman.getCarriedBlock();
if (blockstate != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package mekanism.additions.common;

import mekanism.api.annotations.NothingNullByDefault;
import mekanism.api.text.ILangEntry;
import net.minecraft.Util;

@NothingNullByDefault
public enum AdditionsLang implements ILangEntry {
CHANNEL("walkie", "channel"),
CHANNEL_CHANGE("walkie", "channel.change"),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package mekanism.additions.common;

import javax.annotation.Nonnull;
import mekanism.additions.client.AdditionsClient;
import mekanism.additions.common.block.BlockObsidianTNT;
import mekanism.additions.common.config.MekanismAdditionsConfig;
Expand Down Expand Up @@ -39,6 +38,7 @@
import net.minecraftforge.fml.event.config.ModConfigEvent;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.jetbrains.annotations.NotNull;

@Mod(MekanismAdditions.MODID)
public class MekanismAdditions implements IModModule {
Expand Down Expand Up @@ -120,9 +120,9 @@ private void commonSetup(FMLCommonSetupEvent event) {
Parrot.MOB_SOUND_MAP.put(AdditionsEntityTypes.BABY_WITHER_SKELETON.get(), SoundEvents.PARROT_IMITATE_WITHER_SKELETON);
//Dispenser behavior
DispenserBlock.registerBehavior(AdditionsBlocks.OBSIDIAN_TNT, new DefaultDispenseItemBehavior() {
@Nonnull
@NotNull
@Override
protected ItemStack execute(@Nonnull BlockSource source, @Nonnull ItemStack stack) {
protected ItemStack execute(@NotNull BlockSource source, @NotNull ItemStack stack) {
BlockPos blockpos = source.getPos().relative(source.getBlockState().getValue(DispenserBlock.FACING));
if (BlockObsidianTNT.createAndAddEntity(source.getLevel(), blockpos, null)) {
source.getLevel().gameEvent(null, GameEvent.ENTITY_PLACE, blockpos);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package mekanism.additions.common.advancements;

import javax.annotation.Nullable;
import mekanism.additions.common.MekanismAdditions;
import mekanism.common.advancements.MekanismAdvancement;
import mekanism.common.advancements.MekanismAdvancements;
import org.jetbrains.annotations.Nullable;

public class AdditionsAdvancements {

Expand Down
Loading

0 comments on commit 6a61646

Please sign in to comment.