-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
406 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,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); | ||
} | ||
} |
7 changes: 4 additions & 3 deletions
7
common/src/main/java/mc/duzo/fakeplayer/client/FakePlayerModClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,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); | ||
} | ||
} |
9 changes: 5 additions & 4 deletions
9
common/src/main/java/mc/duzo/fakeplayer/client/model/HumanoidEntityModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,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); | ||
} | ||
} |
35 changes: 18 additions & 17 deletions
35
common/src/main/java/mc/duzo/fakeplayer/client/renderer/FakePlayerEntityRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.