Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Duzos committed Oct 6, 2024
1 parent 3156e14 commit e088e28
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 393 deletions.
24 changes: 0 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,3 @@ allprojects {
withSourcesJar()
}
}

spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}

java {
//eclipse()

removeUnusedImports()
importOrder('java', 'javax', '', 'net.minecraft', group)

indentWithSpaces()
trimTrailingWhitespace()

formatAnnotations()
}
}
28 changes: 28 additions & 0 deletions common/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id "com.diffplug.spotless" version "6.20.0"
}

architectury {
common(rootProject.enabled_platforms.split(","))
}
Expand Down Expand Up @@ -28,3 +32,27 @@ publishing {
// Add repositories to publish to here.
}
}

spotless {
format 'misc', {
// define the files to apply `misc` to
target '*.gradle', '.gitattributes', '.gitignore'

// define the steps to apply to those files
trimTrailingWhitespace()
indentWithSpaces()
endWithNewline()
}

java {
//eclipse()

removeUnusedImports()
importOrder('java', 'javax', '', 'net.minecraft', group)

indentWithSpaces()
trimTrailingWhitespace()

formatAnnotations()
}
}
1 change: 1 addition & 0 deletions common/src/main/java/mc/duzo/fakeplayer/FakePlayerMod.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dev.architectury.platform.Platform;
import dev.architectury.utils.Env;

import mc.duzo.fakeplayer.client.FakePlayerModClient;
import mc.duzo.fakeplayer.network.FPNetwork;

Expand Down
57 changes: 28 additions & 29 deletions common/src/main/java/mc/duzo/fakeplayer/Register.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,48 @@
package mc.duzo.fakeplayer;

import static mc.duzo.fakeplayer.FakePlayerMod.MOD_ID;

import java.util.function.Supplier;

import com.google.common.base.Suppliers;
import dev.architectury.registry.CreativeTabRegistry;
import dev.architectury.registry.level.entity.EntityAttributeRegistry;
import dev.architectury.registry.registries.DeferredRegister;
import dev.architectury.registry.registries.RegistrarManager;
import dev.architectury.registry.registries.RegistrySupplier;
import mc.duzo.fakeplayer.entity.FakePlayerEntity;

import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.item.Item;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;
import net.minecraft.registry.RegistryKeys;
import net.minecraft.text.Text;
import net.minecraft.world.GameRules;


import java.util.function.Supplier;

import static mc.duzo.fakeplayer.FakePlayerMod.MOD_ID;
import mc.duzo.fakeplayer.entity.FakePlayerEntity;

public class Register {
public static final Supplier<RegistrarManager> REGISTRIES = Suppliers.memoize(() -> RegistrarManager.get(MOD_ID));

// Registering a new creative tab
public static final DeferredRegister<ItemGroup> TABS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM_GROUP);
public static final RegistrySupplier<ItemGroup> FP_TAB = TABS.register("tab", () ->
CreativeTabRegistry.create(Text.translatable("itemGroup." + MOD_ID + ".tab"),
() -> new ItemStack(Items.IRON_INGOT)));

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM);
public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(MOD_ID, RegistryKeys.ENTITY_TYPE);
public static final RegistrySupplier<EntityType<FakePlayerEntity>> FAKE_PLAYER = ENTITIES.register("fake_player", () -> EntityType.Builder
.create(FakePlayerEntity::new, SpawnGroup.MISC)
.setDimensions(0.6f, 1.8f)
.build("fake_player"));

public static void init() {
ENTITIES.register();
TABS.register();
ITEMS.register();

EntityAttributeRegistry.register(FAKE_PLAYER, FakePlayerEntity::getHumanoidAttributes);
}
public static final Supplier<RegistrarManager> REGISTRIES = Suppliers.memoize(() -> RegistrarManager.get(MOD_ID));

// Registering a new creative tab
public static final DeferredRegister<ItemGroup> TABS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM_GROUP);
public static final RegistrySupplier<ItemGroup> FP_TAB = TABS.register("tab", () ->
CreativeTabRegistry.create(Text.translatable("itemGroup." + MOD_ID + ".tab"),
() -> new ItemStack(Items.IRON_INGOT)));

public static final DeferredRegister<Item> ITEMS = DeferredRegister.create(MOD_ID, RegistryKeys.ITEM);
public static final DeferredRegister<EntityType<?>> ENTITIES = DeferredRegister.create(MOD_ID, RegistryKeys.ENTITY_TYPE);
public static final RegistrySupplier<EntityType<FakePlayerEntity>> FAKE_PLAYER = ENTITIES.register("fake_player", () -> EntityType.Builder
.create(FakePlayerEntity::new, SpawnGroup.MISC)
.setDimensions(0.6f, 1.8f)
.build("fake_player"));

public static void init() {
ENTITIES.register();
TABS.register();
ITEMS.register();

EntityAttributeRegistry.register(FAKE_PLAYER, FakePlayerEntity::getHumanoidAttributes);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package mc.duzo.fakeplayer.client;

import dev.architectury.registry.client.level.entity.EntityRendererRegistry;

import mc.duzo.fakeplayer.Register;
import mc.duzo.fakeplayer.client.renderer.FakePlayerEntityRenderer;

public class FakePlayerModClient {
public static void init() {
EntityRendererRegistry.register(Register.FAKE_PLAYER, FakePlayerEntityRenderer::new);
}
public static void init() {
EntityRendererRegistry.register(Register.FAKE_PLAYER, FakePlayerEntityRenderer::new);
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package mc.duzo.fakeplayer.client.model;

import mc.duzo.fakeplayer.entity.HumanoidEntity;
import net.minecraft.client.model.ModelPart;
import net.minecraft.client.render.entity.model.PlayerEntityModel;

import mc.duzo.fakeplayer.entity.HumanoidEntity;

public class HumanoidEntityModel extends PlayerEntityModel<HumanoidEntity> {
public HumanoidEntityModel(ModelPart root, boolean thinArms) {
super(root, thinArms);
}
public HumanoidEntityModel(ModelPart root, boolean thinArms) {
super(root, thinArms);
}
}
Original file line number Diff line number Diff line change
@@ -1,32 +1,33 @@
package mc.duzo.fakeplayer.client.renderer;

import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.util.Identifier;

import mc.duzo.fakeplayer.client.model.HumanoidEntityModel;
import mc.duzo.fakeplayer.entity.FakePlayerEntity;
import mc.duzo.fakeplayer.entity.HumanoidEntity;
import mc.duzo.fakeplayer.util.SkinGrabber;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.util.Identifier;

public class FakePlayerEntityRenderer extends HumanoidEntityRenderer<FakePlayerEntity, HumanoidEntityModel> {
public FakePlayerEntityRenderer(EntityRendererFactory.Context context) {
super(context, false);
}
public FakePlayerEntityRenderer(EntityRendererFactory.Context context) {
super(context, false);
}



@Override
public Identifier getTexture(HumanoidEntity entity) {
if (entity.getCustomName() == null || entity.getCustomName().getString().isBlank()) {
// If the name is the default blank one, send back the error
return SkinGrabber.ERROR_TEXTURE;
}
@Override
public Identifier getTexture(HumanoidEntity entity) {
if (entity.getCustomName() == null || entity.getCustomName().getString().isBlank()) {
// If the name is the default blank one, send back the error
return SkinGrabber.ERROR_TEXTURE;
}

Identifier texture = SkinGrabber.getEntitySkinFromList(entity);
Identifier texture = SkinGrabber.getEntitySkinFromList(entity);

if (texture != null) {
return texture;
}
if (texture != null) {
return texture;
}

return SkinGrabber.ERROR_TEXTURE;
}
return SkinGrabber.ERROR_TEXTURE;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package mc.duzo.fakeplayer.client.renderer;

import mc.duzo.fakeplayer.FakePlayerMod;
import mc.duzo.fakeplayer.client.model.HumanoidEntityModel;
import mc.duzo.fakeplayer.entity.HumanoidEntity;
import net.minecraft.client.render.VertexConsumerProvider;
import net.minecraft.client.render.entity.EntityRendererFactory;
import net.minecraft.client.render.entity.LivingEntityRenderer;
Expand All @@ -14,25 +11,29 @@
import net.minecraft.client.util.math.MatrixStack;
import net.minecraft.util.Identifier;

import mc.duzo.fakeplayer.FakePlayerMod;
import mc.duzo.fakeplayer.client.model.HumanoidEntityModel;
import mc.duzo.fakeplayer.entity.HumanoidEntity;

public abstract class HumanoidEntityRenderer<F extends HumanoidEntity, H extends PlayerEntityModel<HumanoidEntity>> extends LivingEntityRenderer<HumanoidEntity, HumanoidEntityModel> {
protected HumanoidEntityRenderer(EntityRendererFactory.Context context, boolean isSlim) {
super(context, new HumanoidEntityModel(context.getPart(EntityModelLayers.PLAYER), isSlim), 0.5f);
this.addFeature(new ArmorFeatureRenderer(this, new ArmorEntityModel(context.getPart(EntityModelLayers.PLAYER_INNER_ARMOR)), new ArmorEntityModel(context.getPart(EntityModelLayers.PLAYER_OUTER_ARMOR)), context.getModelManager()));
this.addFeature(new HeldItemFeatureRenderer<>(this, context.getHeldItemRenderer()));
}
protected HumanoidEntityRenderer(EntityRendererFactory.Context context, boolean isSlim) {
super(context, new HumanoidEntityModel(context.getPart(EntityModelLayers.PLAYER), isSlim), 0.5f);
this.addFeature(new ArmorFeatureRenderer(this, new ArmorEntityModel(context.getPart(EntityModelLayers.PLAYER_INNER_ARMOR)), new ArmorEntityModel(context.getPart(EntityModelLayers.PLAYER_OUTER_ARMOR)), context.getModelManager()));
this.addFeature(new HeldItemFeatureRenderer<>(this, context.getHeldItemRenderer()));
}

@Override
public void render(HumanoidEntity livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
matrixStack.push();
@Override
public void render(HumanoidEntity livingEntity, float f, float g, MatrixStack matrixStack, VertexConsumerProvider vertexConsumerProvider, int i) {
matrixStack.push();

matrixStack.scale(0.9375F, 0.9375F, 0.9375F);
matrixStack.scale(0.9375F, 0.9375F, 0.9375F);

super.render(livingEntity, f, g, matrixStack, vertexConsumerProvider, i);
matrixStack.pop();
}
super.render(livingEntity, f, g, matrixStack, vertexConsumerProvider, i);
matrixStack.pop();
}

@Override
public Identifier getTexture(HumanoidEntity entity) {
return new Identifier(FakePlayerMod .MOD_ID,"textures/entity/humanoid/humanoid.png");
}
@Override
public Identifier getTexture(HumanoidEntity entity) {
return new Identifier(FakePlayerMod .MOD_ID,"textures/entity/humanoid/humanoid.png");
}
}
Loading

0 comments on commit e088e28

Please sign in to comment.