Skip to content

Commit

Permalink
Merge pull request #11 from aidan99davis/develop
Browse files Browse the repository at this point in the history
Release Version 1.2
  • Loading branch information
aidan99davis authored Aug 20, 2020
2 parents a2584b9 + 599205a commit eae4ac0
Show file tree
Hide file tree
Showing 179 changed files with 9,088 additions and 383 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ apply plugin: 'net.minecraftforge.gradle'
apply plugin: 'eclipse'
apply plugin: 'maven-publish'

version = '1.0'
version = '1.1'
group = 'com.aidan99davis.spectrobesmod' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'spectrobesmod'

Expand Down Expand Up @@ -90,7 +90,7 @@ repositories {
}

dependencies {
implementation fg.deobf('com.github.bernie-g:geckolib:1.15-1.0.2')
implementation fg.deobf('com.github.bernie-g:geckolib:forge-1.15.2-geckolib-2.0.0-beta.7')
}

dependencies {
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/spectrobes/spectrobesmod/SpectrobesInfo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.spectrobes.spectrobesmod;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

public class SpectrobesInfo {

public static final String MOD_ID = "spectrobesmod";
// Directly reference a log4j logger.
public static final Logger LOGGER = LogManager.getLogger();
}
40 changes: 29 additions & 11 deletions src/main/java/com/spectrobes/spectrobesmod/SpectrobesMod.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
package com.spectrobes.spectrobesmod;

import com.spectrobes.spectrobesmod.client.entity.SpectrobesEntities;
import com.spectrobes.spectrobesmod.common.capability.PlayerEvents;
import com.spectrobes.spectrobesmod.common.capability.PlayerSpectrobeMaster;
import com.spectrobes.spectrobesmod.common.registry.IconRegistry;
import com.spectrobes.spectrobesmod.common.registry.MineralRegistry;
import com.spectrobes.spectrobesmod.util.SpectrobesWorldData;
import net.minecraft.nbt.CompoundNBT;
import net.minecraft.nbt.INBT;
import net.minecraft.util.Direction;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.InterModComms;
Expand All @@ -16,18 +23,14 @@
import net.minecraftforge.fml.event.lifecycle.InterModProcessEvent;
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.annotation.Nullable;
import java.util.stream.Collectors;

// The value here should match an entry in the META-INF/mods.toml file
@Mod("spectrobesmod")
public class SpectrobesMod
{
public static final String MOD_ID = "spectrobesmod";
// Directly reference a log4j logger.
public static final Logger LOGGER = LogManager.getLogger();
public static SpectrobesMod Instance;

public SpectrobesMod() {
Expand All @@ -39,17 +42,32 @@ public SpectrobesMod() {
modEventBus.addListener(this::enqueueIMC);
modEventBus.addListener(this::processIMC);
modEventBus.addListener(this::doClientStuff);
MinecraftForge.EVENT_BUS.addListener(SpectrobesWorldData::onWorldLoaded);
MinecraftForge.EVENT_BUS.addListener(SpectrobesWorldData::onWorldSaved);

SpectrobesEntities.ENTITY_TYPES.register(modEventBus);
// Register ourselves for server and other game events we are interested in
MinecraftForge.EVENT_BUS.register(this);
}

// private <T extends Event> void initialiseCapabilities(final AttachCapabilitiesEvent event) {
// event.addCapability(SpectrobesInfo.MOD_ID, PlayerSpectrobeMaster.Provider);
// }

private void setup(final FMLCommonSetupEvent event)
{
MinecraftForge.EVENT_BUS.register(PlayerEvents.instance);
IconRegistry.init();
CapabilityManager.INSTANCE.register(PlayerSpectrobeMaster.class, new Capability.IStorage<PlayerSpectrobeMaster>() {
@Nullable
@Override
public INBT writeNBT(Capability<PlayerSpectrobeMaster> capability, PlayerSpectrobeMaster instance, Direction side) {
return instance.serializeNBT();
}

@Override
public void readNBT(Capability<PlayerSpectrobeMaster> capability, PlayerSpectrobeMaster instance, Direction side, INBT nbt) {
instance.deserializeNBT((CompoundNBT) nbt);
}
}, () -> null);
}

@OnlyIn(Dist.CLIENT)
Expand All @@ -62,12 +80,12 @@ public void doClientStuff(final FMLClientSetupEvent event)

private void enqueueIMC(final InterModEnqueueEvent event)
{
InterModComms.sendTo("examplemod", "helloworld", () -> { LOGGER.info("Hello world from the MDK"); return "Hello world";});
InterModComms.sendTo("examplemod", "helloworld", () -> { SpectrobesInfo.LOGGER.info("Hello world from the MDK"); return "Hello world";});
}

private void processIMC(final InterModProcessEvent event)
{
LOGGER.info("Got IMC {}", event.getIMCStream().
SpectrobesInfo.LOGGER.info("Got IMC {}", event.getIMCStream().
map(m->m.getMessageSupplier().get()).
collect(Collectors.toList()));
}
Expand All @@ -76,7 +94,7 @@ private void processIMC(final InterModProcessEvent event)
@SubscribeEvent
public void onServerStarting(FMLServerStartingEvent event) {
// do something when the server starts
LOGGER.info("HELLO from server starting");
SpectrobesInfo.LOGGER.info("HELLO from server starting");
}

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
package com.spectrobes.spectrobesmod.client.entity;

import com.spectrobes.spectrobesmod.SpectrobesMod;
import com.spectrobes.spectrobesmod.client.entity.renderer.KomainuRenderer;
import com.spectrobes.spectrobesmod.SpectrobesInfo;
import com.spectrobes.spectrobesmod.client.entity.renderer.*;
import com.spectrobes.spectrobesmod.common.entities.EntitySpectrobe;
import com.spectrobes.spectrobesmod.common.entities.komainu.EntityKomainu;
import com.spectrobes.spectrobesmod.common.entities.komainu.EntityKomanoto;
import com.spectrobes.spectrobesmod.common.entities.samubaku.EntitySamukabu;
import com.spectrobes.spectrobesmod.common.entities.samubaku.EntitySamurite;
import com.spectrobes.spectrobesmod.common.entities.spiko.EntitySpikan;
import com.spectrobes.spectrobesmod.common.entities.spiko.EntitySpiko;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityClassification;
import net.minecraft.entity.EntityType;
Expand All @@ -12,18 +18,56 @@
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;

import java.util.HashMap;
import java.util.Map;

public class SpectrobesEntities {

private static final Map<String, EntityType<? extends EntitySpectrobe>> SPECTROBES = new HashMap<>();

public static final DeferredRegister<EntityType<?>> ENTITY_TYPES
= new DeferredRegister<>(ForgeRegistries.ENTITIES, SpectrobesMod.MOD_ID);
= new DeferredRegister<>(ForgeRegistries.ENTITIES, SpectrobesInfo.MOD_ID);

public static final RegistryObject<EntityType<EntityKomanoto>> ENTITY_KOMANOTO = ENTITY_TYPES.register("entity_komanoto",
() -> EntityType.Builder.create(EntityKomanoto::new,
EntityClassification.CREATURE)
.size(1.5f, 1.5f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "komanoto").toString()));

public static final RegistryObject<EntityType<EntityKomainu>> ENTITY_KOMANOTO = null;
public static final RegistryObject<EntityType<EntityKomainu>> ENTITY_KOMAINU
= ENTITY_TYPES.register("entity_komainu",
() -> EntityType.Builder.create(EntityKomainu::new,
EntityClassification.CREATURE)
.size(0.6f, 1f)
.build(new ResourceLocation(SpectrobesMod.MOD_ID, "komainu").toString()));
.size(0.5f, 0.75f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "komainu").toString()));

public static final RegistryObject<EntityType<EntitySpiko>> ENTITY_SPIKO
= ENTITY_TYPES.register("entity_spiko",
() -> EntityType.Builder.create(EntitySpiko::new,
EntityClassification.CREATURE)
.size(0.75f, 0.5f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "spiko").toString()));

public static final RegistryObject<EntityType<EntitySpikan>> ENTITY_SPIKAN
= ENTITY_TYPES.register("entity_spikan",
() -> EntityType.Builder.create(EntitySpikan::new,
EntityClassification.CREATURE)
.size(1f, 2f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "spikan").toString()));

public static final RegistryObject<EntityType<EntitySamukabu>> ENTITY_SAMUKABU
= ENTITY_TYPES.register("entity_samubaku",
() -> EntityType.Builder.create(EntitySamukabu::new,
EntityClassification.CREATURE)
.size(1f, 1f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "samubaku").toString()));

public static final RegistryObject<EntityType<EntitySamurite>> ENTITY_SAMURITE
= ENTITY_TYPES.register("entity_samurite",
() -> EntityType.Builder.create(EntitySamurite::new,
EntityClassification.CREATURE)
.size(1f, 2f)
.build(new ResourceLocation(SpectrobesInfo.MOD_ID, "samurite").toString()));

public static <T extends Entity> RegistryObject<EntityType<T>> BuildEntity(EntityType.IFactory<T> entity, Class<T> entityClass, float width, float height)
{
Expand All @@ -34,6 +78,32 @@ public static <T extends Entity> RegistryObject<EntityType<T>> BuildEntity(Entit
}

public static void init() {
populateMap();

RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_KOMAINU.get(), manager -> new KomainuRenderer(manager));
RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_SPIKO.get(), manager -> new SpikoRenderer(manager));
RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_KOMANOTO.get(), manager -> new KomanotoRenderer(manager));
RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_SPIKAN.get(), manager -> new SpikanRenderer(manager));
RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_SAMUKABU.get(), manager -> new SamukabuRenderer(manager));
RenderingRegistry.registerEntityRenderingHandler(SpectrobesEntities.ENTITY_SAMURITE.get(), manager -> new SamuriteRenderer(manager));
}

private static void populateMap() {
SPECTROBES.put("komainu", ENTITY_KOMAINU.get());
SPECTROBES.put("komanoto", ENTITY_KOMANOTO.get());
SPECTROBES.put("samukabu", ENTITY_SAMUKABU.get());
SPECTROBES.put("samurite", ENTITY_SAMURITE.get());
SPECTROBES.put("spiko", ENTITY_SPIKO.get());
SPECTROBES.put("spikan", ENTITY_SPIKAN.get());
}

public static EntityType<? extends EntitySpectrobe> getByName(String name) throws ClassNotFoundException {
EntityType<? extends EntitySpectrobe> spectrobe = SPECTROBES.get(name.toLowerCase());
if(spectrobe != null) {
return spectrobe;
}
throw new ClassNotFoundException("could not find the spectrobe's " +
"entity registry. " +
"is its name spelled correctly?");
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package com.spectrobes.spectrobesmod.client.entity.model;

import com.google.common.collect.ImmutableList;
import com.spectrobes.spectrobesmod.SpectrobesMod;
import com.spectrobes.spectrobesmod.SpectrobesInfo;
import com.spectrobes.spectrobesmod.common.entities.komainu.EntityKomainu;
import net.minecraft.client.renderer.model.ModelRenderer;
import net.minecraft.util.ResourceLocation;
import software.bernie.geckolib.animation.model.AnimatedEntityModel;
import software.bernie.geckolib.animation.model.AnimatedModelRenderer;
import software.bernie.geckolib.animation.render.AnimatedModelRenderer;

// Made with Blockbench 3.5.4
// Exported for Minecraft version 1.12.2 or 1.15.2 (same format for both) for entity model animated with GeckoLib
Expand Down Expand Up @@ -92,6 +90,6 @@ public KomainuModel()
@Override
public ResourceLocation getAnimationFileLocation()
{
return new ResourceLocation(SpectrobesMod.MOD_ID, "animations/spectrobe/komainu.json");
return new ResourceLocation(SpectrobesInfo.MOD_ID, "animations/spectrobe/komainu.json");
}
}
Loading

0 comments on commit eae4ac0

Please sign in to comment.