Skip to content

Commit

Permalink
Fixed scripting bugs and cleaned a bit up
Browse files Browse the repository at this point in the history
Also: we're now offically in a release build.
Fly safely Space Cowboy
  • Loading branch information
WorldSEnder committed Sep 10, 2015
1 parent 458b650 commit 3a244c9
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 147 deletions.
2 changes: 1 addition & 1 deletion build.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "0.2.102b_1710"
version = "1.0.001b_1710"
group= "com.github.worldsender.mcanm"
archivesBaseName = "mcanm"
ext {
Expand Down
4 changes: 4 additions & 0 deletions scripts/io_export_mhfc/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ def __init__(self, name, curves, offset):
self.loc_x = Animation(loc_curves[0], offset)
self.loc_y = Animation(loc_curves[1], offset)
self.loc_z = Animation(loc_curves[2], offset)

self.rot_w = Animation(rot_curves[0], offset)
self.rot_x = Animation(rot_curves[1], offset)
self.rot_y = Animation(rot_curves[2], offset)
self.rot_z = Animation(rot_curves[3], offset)

self.scale_x = Animation(scale_curves[0], offset)
self.scale_y = Animation(scale_curves[1], offset)
self.scale_z = Animation(scale_curves[2], offset)
Expand All @@ -230,10 +232,12 @@ def to_file(self, file_h):
self.loc_x.to_file(file_h)
self.loc_y.to_file(file_h)
self.loc_z.to_file(file_h)

self.rot_x.to_file(file_h)
self.rot_y.to_file(file_h)
self.rot_z.to_file(file_h)
self.rot_w.to_file(file_h)

self.scale_x.to_file(file_h)
self.scale_y.to_file(file_h)
self.scale_z.to_file(file_h)
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/com/github/worldsender/mcanm/MCAnm.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,27 @@

import org.apache.logging.log4j.Logger;

import com.github.worldsender.mcanm.test.CubeEntity;

import cpw.mods.fml.client.event.ConfigChangedEvent.OnConfigChangedEvent;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.registry.EntityRegistry;

@Mod(
modid = Reference.core_modid,
name = Reference.core_modname,
version = Reference.core_modversion,
guiFactory = "com.github.worldsender.mcanm.client.config.MCAnmGuiFactory")
public class MCAnm {
/**
* Enables various visual outputs, e.g. the bones of models are rendered.
*/
public static final boolean isDebug = false;

@Mod.Instance(Reference.core_modid)
public static MCAnm instance;
Expand Down Expand Up @@ -46,6 +54,15 @@ public void preInit(FMLPreInitializationEvent pre) {
logger.info("Successfully loaded MC Animations");
}

@Mod.EventHandler
public void init(FMLInitializationEvent event) {
if (!isDebug)
return;
int id = 0;
EntityRegistry.registerModEntity(CubeEntity.class, "Cube", id, this,
80, 1, true);
}

@SubscribeEvent
public void onConfigChange(OnConfigChangedEvent occe) {
if (!occe.modID.equals(Reference.core_modid))
Expand Down
18 changes: 14 additions & 4 deletions src/main/java/com/github/worldsender/mcanm/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,18 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.IReloadableResourceManager;
import net.minecraft.client.resources.IResourceManager;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;

import com.github.worldsender.mcanm.MCAnm;
import com.github.worldsender.mcanm.Proxy;
import com.github.worldsender.mcanm.client.model.mcanmmodel.MCMDModelLoader;
import com.github.worldsender.mcanm.client.model.mcanmmodel.ModelRegistry;
import com.github.worldsender.mcanm.client.model.mcanmmodel.animation.stored.AnimationRegistry;
import com.github.worldsender.mcanm.client.model.util.AnimationLoader;
import com.github.worldsender.mcanm.client.model.util.ModelLoader;
import com.github.worldsender.mcanm.client.renderer.entity.RenderAnimatedModel;
import com.github.worldsender.mcanm.test.CubeEntity;

import cpw.mods.fml.client.registry.RenderingRegistry;

public class ClientProxy implements Proxy {
@Override
Expand All @@ -19,12 +24,17 @@ public void register() {
.getResourceManager();
if (resManager instanceof IReloadableResourceManager) {
IReloadableResourceManager registry = (IReloadableResourceManager) resManager;
registry.registerReloadListener(AnimationRegistry.instance);
registry.registerReloadListener(ModelRegistry.instance);
registry.registerReloadListener(AnimationLoader.instance);
registry.registerReloadListener(ModelLoader.instance);
} else {
MCAnm.logger
.warn("Couldn't register reload managers. Models will not be reloaded on switching texture pack");
}
MCAnm.logger.info("Registered Reload Managers.");
if (MCAnm.isDebug) {
RenderingRegistry.registerEntityRenderingHandler(CubeEntity.class,
RenderAnimatedModel.fromResLocation(new ResourceLocation(
"mcanm:models/Cube/Cube.mcmd"), 1.0f));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@
import static org.lwjgl.opengl.GL11.glPushMatrix;
import static org.lwjgl.opengl.GL11.glScalef;
import static org.lwjgl.opengl.GL11.glTranslatef;

import java.util.Random;

import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.model.TextureOffset;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;

import com.github.worldsender.mcanm.client.model.mcanmmodel.ModelMCMD;
import com.github.worldsender.mcanm.client.model.mcanmmodel.ModelRegistry;
import com.github.worldsender.mcanm.client.model.util.ModelLoader;
import com.github.worldsender.mcanm.client.renderer.IAnimatedObject;

/**
* A general purpose model that should fulfill most of your needs. I uses a
* A general purpose model that should fulfill most of your needs. It uses a
* {@link ModelMHMD} internally to render thus the registered entity class HAS
* TO IMPLEMENT {@link IAnimatedObject}. This will throw an exception during
* rendering otherwise.
Expand All @@ -35,7 +32,7 @@ private static boolean checkValidPartial(float newPartialTick) {
protected float partialTick;
/**
* Loads the model from the given ResourceLocation using the
* {@link ModelRegistry} thus this constructor is exception-free and will
* {@link ModelLoader} thus this constructor is exception-free and will
* load the models from the Registry's chache if possible. You can give/load
* your own model with {@link #ModelAnimated(ModelMHMD)} to receive
* exceptions.
Expand All @@ -44,7 +41,13 @@ private static boolean checkValidPartial(float newPartialTick) {
* the {@link ResourceLocation} to load the model from
*/
public ModelAnimated(ResourceLocation resLoc) {
this(ModelRegistry.loadFrom(resLoc));
this(ModelLoader.loadFrom(resLoc));
// Useless piece of .... sklsdalsafhkjasd
// So we don't get problems with arrows in our entity.
// I want to kill the programmer who thought it would be a good idea
// not to let the entity decide where to put the arrow
ModelRenderer argggghhhh = new ModelRenderer(this, 0, 0);
argggghhhh.addBox(0, 0, 0, 1, 1, 1);
}
/**
* This constructor just puts the model into itself. Nothing is checked
Expand Down Expand Up @@ -79,29 +82,11 @@ public void render(Entity entity, float uLimbSwing,
glPopMatrix();
}

@Override
public final ModelRenderer getRandomModelBox(Random r) {
return this.getArrowModelBox(r);
}

// Will not use this method
@Override
public TextureOffset getTextureOffset(String boxName) {
return new TextureOffset(0, 0);
}
/**
* This should return the box in which a specific arrow is being stuck in.
* Use the given random for RNG so that arrows stay in place (over multiple
* render calls).
*
* @param r
* a {@link Random} to use for RNG
* @return a {@link ModelRenderer} to place arrows on. Not null
*/
protected ModelRenderer getArrowModelBox(Random r) {
// FIXME For some reason we cannot return null here
return null;
}

public float getPartialTick() {
return this.partialTick;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
import com.github.worldsender.mcanm.Reference;
import com.github.worldsender.mcanm.client.model.mcanmmodel.data.RawData;
import com.github.worldsender.mcanm.client.model.mcanmmodel.loader.VersionizedModelLoader;
import com.github.worldsender.mcanm.client.model.util.ModelLoader;

/**
* This class can be used to load a model without registering it automatically
* in the {@link ModelRegistry}. This can be useful if you later want to load
* in the {@link ModelLoader}. This can be useful if you later want to load
* the model with different data.
*
* @author WorldSEnder
Expand Down Expand Up @@ -91,14 +92,14 @@ public ModelMCMD loadInstance(ResourceLocation resource,
// when that is null.
ModelMCMD model = new ModelMCMD(resource, resManager);
if (register) {
ModelRegistry.instance.registerModel(model);
ModelLoader.instance.registerModel(model);
}
return model;
}
/**
* ADVANCED USE<br>
* Use this to load a Model and receive any occuring Exceptions. The
* received model can later be registered in the {@link ModelRegistry} to
* received model can later be registered in the {@link ModelLoader} to
* cache it.
*
* @param resLocation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
import com.github.worldsender.mcanm.client.model.mcanmmodel.data.RawData;
import com.github.worldsender.mcanm.client.model.mcanmmodel.glcontext.GLHelper;
import com.github.worldsender.mcanm.client.model.mcanmmodel.loader.VersionizedModelLoader;
import com.github.worldsender.mcanm.client.model.util.ModelLoader;
import com.github.worldsender.mcanm.client.renderer.IAnimatedObject;
/**
* Represents a model that is more abstract than boxes. The format also offers
* animating the model through bones and a few more things.<br>
* The model can be registered for reloading in the {@link ModelRegistry}. This
* The model can be registered for reloading in the {@link ModelLoader}. This
* will reload the model whenever the user changes the active texture packs.
* This means that mobs or whatever it is can be customized by the texture pack.
* AWESOME.
Expand Down Expand Up @@ -135,15 +136,21 @@ public ResourceLocation getResourceLocation() {
*/
@Override
public boolean equals(Object obj) {
if (obj instanceof ModelMCMD) {
ModelMCMD other = (ModelMCMD) obj;
// Compare loading locations
if (this.reloadLocation == other.reloadLocation
&& this.reloadLocation != null)
return true;
// Compare model ids
if (this.modelUUID == other.modelUUID)
return true;
if (obj == null) {
return false;
}
if (!(obj instanceof ModelMCMD)) {
return false;
}
ModelMCMD other = (ModelMCMD) obj;
// Compare loading locations
if (this.reloadLocation != null
&& this.reloadLocation.equals(other.reloadLocation)) {
return true;
}
// Compare model ids
if (this.modelUUID == other.modelUUID) {
return true;
}
return false;
}
Expand Down Expand Up @@ -181,7 +188,7 @@ public UUID getModelUUID() {
// ---------------------- Never used ---------------------------
private static void throwUsage() {
throw new IllegalAccessError(
"Can't use this method with this model-type. Use one of render(...)");
"Can't use this method with this model-type. Use one of #render(...)");
}
@Override
public void renderAll() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,6 @@ public static class BoneTransformation {
private static Vector3f identityScale() {
return new Vector3f(1.0F, 1.0F, 1.0F);
}
/**
* For every value the 'left' and 'right' {@link BoneTransformation}s
* argument hold, the value in the result will be<br>
* <code>(1-factor)^2*(2*factor+1)*left + factor^2*(3-2*factor)*right</code>
* .<br>
* Note: this holds that no two different factors will generate the same
* output value (if left and right differ and factor is in [0, 1])
*/
@Deprecated
public static final int SPLINE = 3;

public static final BoneTransformation identity = new BoneTransformation();

Expand Down
Loading

0 comments on commit 3a244c9

Please sign in to comment.