Skip to content

Commit

Permalink
Added the spawn egg and re-added animations.
Browse files Browse the repository at this point in the history
  • Loading branch information
KiriCattus committed Feb 26, 2022
1 parent 8ed13ce commit 0de8788
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
24 changes: 11 additions & 13 deletions src/main/java/dev/tophatcat/redpandas/RedPandas.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,19 @@
import dev.tophatcat.redpandas.common.PandaRegistry;
import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.SpawnEggItem;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.common.ForgeSpawnEggItem;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.fml.ModLoadingContext;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.config.ModConfig;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.fml.loading.FMLEnvironment;

import java.awt.Color;
import net.minecraftforge.fmllegacy.RegistryObject;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

@Mod(RedPandas.MOD_ID)
@EventBusSubscriber(bus = EventBusSubscriber.Bus.MOD)
Expand All @@ -49,19 +49,20 @@ public class RedPandas {
*/
public static final String MOD_ID = "redpandas";

private static final DeferredRegister<Item> ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID);

/**
* Setup the mod.
*/
public RedPandas() {
//TODO Fix missing model animations.
//TODO Fix missing spawn egg.
ModLoadingContext modLoadingContext = ModLoadingContext.get();
FMLJavaModLoadingContext fmlContext = FMLJavaModLoadingContext.get();

IEventBus modBus = fmlContext.getModEventBus();
IEventBus forgeBus = MinecraftForge.EVENT_BUS;

PandaRegistry.ENTITIES.register(FMLJavaModLoadingContext.get().getModEventBus());
ITEMS.register(FMLJavaModLoadingContext.get().getModEventBus());
if (FMLEnvironment.dist == Dist.CLIENT) {
PandaRendering.setupRendering(modBus, forgeBus);
}
Expand All @@ -75,11 +76,8 @@ public RedPandas() {
forgeBus.addListener(PandaEvents::biomeLoad);
}

@SuppressWarnings("deprecation")
public static void registerItems(RegistryEvent.Register<Item> event) {
event.getRegistry().registerAll(
new SpawnEggItem(PandaRegistry.RED_PANDA.get(), Color.RED.getRGB(), Color.BLACK.getRGB(),
new Item.Properties().tab(CreativeModeTab.TAB_MISC))
.setRegistryName(MOD_ID + ":red_panda_spawn_egg"));
}
@SuppressWarnings({"unused"})
public static final RegistryObject<Item> RED_PANDA_SPAWN_EGG = ITEMS.register("red_panda_spawn_egg",
() -> new ForgeSpawnEggItem(PandaRegistry.RED_PANDA, 0xff0000, 0x000000,
new Item.Properties().tab(CreativeModeTab.TAB_MISC)));
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import net.minecraft.client.model.geom.builders.MeshDefinition;
import net.minecraft.client.model.geom.builders.PartDefinition;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;

import javax.annotation.Nonnull;

public class RedPandaModel<T extends RedPandaEntity> extends EntityModel<T> {

Expand Down Expand Up @@ -98,8 +101,16 @@ public static LayerDefinition createBodyLayer() {
}

@Override
public void setupAnim(T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {

public void setupAnim(@Nonnull T entity, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch) {
this.head.xRot = headPitch * 0.0070F;
this.head.yRot = netHeadYaw * 0.0070F;
this.leftFrontLeg.xRot = Mth.cos(limbSwing * 0.6662F) * 0.9F * limbSwingAmount;
this.rightFrontLeg.xRot = Mth.cos(limbSwing * 0.6662F
+ (float) Math.PI) * 1.4F * limbSwingAmount;
this.rightBackLeg.xRot = Mth.cos(limbSwing * 0.6662F) * 0.9F * limbSwingAmount;
this.leftBackLeg.xRot = Mth.cos(limbSwing * 0.6662F
+ (float) Math.PI) * 1.4F * limbSwingAmount;
this.tail.yRot = Mth.cos(limbSwing * 0.6662F) * 0.3F * limbSwingAmount;
}

@Override
Expand Down

0 comments on commit 0de8788

Please sign in to comment.