Skip to content
This repository has been archived by the owner on Feb 9, 2018. It is now read-only.

Commit

Permalink
Added a custom font to MO GUI's.
Browse files Browse the repository at this point in the history
Made the Android Hud choppy fix on this branch as well.
Started integrating TextureMap with MO's particles.
New blood and smoke custom animated particles.
Fixed Weapon recoil value spillage from previously fired weapon.
  • Loading branch information
simeonradivoev committed Feb 22, 2016
1 parent 935bd3e commit 9c24dee
Show file tree
Hide file tree
Showing 57 changed files with 521 additions and 335 deletions.
Binary file added PSD/items/supply_crate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion src/main/java/matteroverdrive/api/android/IBioticStat.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import matteroverdrive.client.render.HoloIcons;
import matteroverdrive.entity.android_player.AndroidAttributes;
import matteroverdrive.entity.android_player.AndroidPlayer;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.item.ItemStack;
import net.minecraftforge.event.entity.living.LivingEvent;
import net.minecraftforge.fml.relauncher.Side;
Expand Down Expand Up @@ -190,7 +191,7 @@ public interface IBioticStat
* Called to register any custom Icons
* @param holoIcons The TextureMap for the Holo Icons
*/
void registerIcons(HoloIcons holoIcons);
void registerIcons(TextureMap textureMap,HoloIcons holoIcons);

/**
* Gets the Bionic Stat Icon.
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/matteroverdrive/client/RenderHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ public void onModelBake(ModelBakeEvent event)
@SubscribeEvent
public void onTextureStich(TextureStitchEvent.Pre event)
{
weaponRenderHandler.onTextureStich(Minecraft.getMinecraft().getTextureMapBlocks(),this);
if (event.map == Minecraft.getMinecraft().getTextureMapBlocks())
{
weaponRenderHandler.onTextureStich(Minecraft.getMinecraft().getTextureMapBlocks(), this);
}
}

public static void registerItemRendererVarients()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package matteroverdrive.client.data;

import net.minecraft.client.renderer.texture.TextureAtlasSprite;

/**
* Created by Simeon on 2/20/2016.
*/
public class TextureAtlasSpriteParticle extends TextureAtlasSprite
{
private int frameSize;
private int speed;
private int animationCounter;
private int tickCount;
private int frameCountPerRow;
private float frameSizeDeltaWidth;
private float frameSizeDeltaHeight;

public TextureAtlasSpriteParticle(String spriteName,int frameSize,int speed)
{
super(spriteName);
this.frameSize = frameSize;
this.speed = speed;
}

public TextureAtlasSpriteParticle copy()
{
TextureAtlasSpriteParticle sprite = new TextureAtlasSpriteParticle(this.getIconName(),frameSize,speed);
sprite.copyFrom(this);
sprite.calculate();
return sprite;
}

private void calculate()
{
frameCountPerRow = getIconWidth() / frameSize;
frameSizeDeltaWidth = (super.getMaxU() - super.getMinU()) / (float) frameCountPerRow;
frameSizeDeltaHeight = (super.getMaxV() - super.getMinV()) / (float) frameCountPerRow;
}

public void updateParticleAnimation()
{
++this.tickCount;
if (tickCount >= speed)
{
tickCount = 0;
if (animationCounter < (frameCountPerRow*frameCountPerRow)-1)
{
animationCounter++;
}
}
}

/**
* Returns the minimum U coordinate to use when rendering with this icon.
*/
public float getMinU()
{
if (frameCountPerRow > 0)
{
return super.getMinU() + ((animationCounter % frameCountPerRow) * frameSizeDeltaWidth);
}
return super.getMinU();
}

/**
* Returns the maximum U coordinate to use when rendering with this icon.
*/
public float getMaxU()
{
if (frameCountPerRow > 0)
{
return super.getMinU() + ((animationCounter % frameCountPerRow) + 1) * frameSizeDeltaWidth;
}
return super.getMaxU();
}

/**
* Returns the minimum V coordinate to use when rendering with this icon.
*/
public float getMinV()
{
if (frameCountPerRow > 0)
{
float vOffset = ((float) Math.floor((animationCounter) / frameCountPerRow) * frameSizeDeltaHeight);
return super.getMinV() + vOffset;
}
return super.getMinV();
}

/**
* Returns the maximum V coordinate to use when rendering with this icon.
*/
public float getMaxV()
{
if (frameCountPerRow > 0)
{
float vOffset = (((float) Math.floor((animationCounter) / frameCountPerRow) + 1) * frameSizeDeltaHeight);
return super.getMinV() + vOffset;
}
return super.getMaxV();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import matteroverdrive.Reference;
import matteroverdrive.api.inventory.IBlockScanner;
import matteroverdrive.client.RenderHandler;
import matteroverdrive.proxy.ClientProxy;
import matteroverdrive.util.RenderUtils;
import matteroverdrive.util.math.MOMathHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
Expand Down Expand Up @@ -54,9 +52,7 @@ public void onRenderWorldLast(RenderHandler handler, RenderWorldLastEvent event)
lastY = MOMathHelper.Lerp(lastY, viewEntityPos.yCoord, 0.05);
Vec3 viewEntityPosRound = new Vec3(Math.floor(viewEntityPos.xCoord), lastY, Math.floor(viewEntityPos.zCoord));


GlStateManager.translate(-viewEntityPos.xCoord, -viewEntityPos.yCoord, -viewEntityPos.zCoord);
RenderUtils.bindTexture(ClientProxy.renderHandler.getRenderParticlesHandler().additiveTextureSheet);
WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();

int vewDistance = 128;
Expand Down
182 changes: 90 additions & 92 deletions src/main/java/matteroverdrive/client/render/HoloIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,126 +21,54 @@
import matteroverdrive.MatterOverdrive;
import matteroverdrive.Reference;
import matteroverdrive.client.data.Color;
import matteroverdrive.fx.MOEntityFX;
import matteroverdrive.util.MOLog;
import matteroverdrive.util.RenderUtils;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.WorldRenderer;
import net.minecraft.client.renderer.texture.IIconCreator;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Vec3;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.apache.logging.log4j.Level;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
* Created by Simeon on 6/15/2015.
*/
@SideOnly(Side.CLIENT)
public class HoloIcons {
public class HoloIcons implements IIconCreator{
private final Map<String, HoloIcon> iconMap;
public final TextureMap textureMap;
public int sheetSize = 256;
public final ResourceLocation sheet = new ResourceLocation(Reference.MOD_ID, "textures/gui/holo_icons.png");

public HoloIcons() {
iconMap = new HashMap<>();
textureMap = new TextureMap("textures");
textureMap = new TextureMap("textures/gui/items",this);
Minecraft.getMinecraft().renderEngine.loadTickableTexture(sheet,textureMap);
try
{
textureMap.loadTexture(Minecraft.getMinecraft().getResourceManager());
} catch (IOException e)
{
MOLog.log(Level.ERROR,e,"There was a problem while creating Holo Icons texture sheet");
}
}

public void registerIcons() {
reg("holo_home", 14);
reg("holo_dotted_circle", 20);
reg("holo_factory", 14);
reg("person", 18);
reg("android_slot_arms", 16);
reg("android_slot_chest", 16);
reg("android_slot_head", 16);
reg("android_slot_legs", 16);
reg("android_slot_other", 16);
reg("barrel", 16);
reg("battery", 16);
reg("color", 16);
reg("factory", 16);
reg("module", 16);
reg("sights", 16);
reg("shielding", 16);
reg("scanner", 16);
reg("upgrade", 16);
reg("decompose", 16);
reg("pattern_storage", 16);
reg("home_icon", 14);
reg("page_icon_home", 14);
reg("page_icon_tasks", 15);
reg("page_icon_upgrades", 12);
reg("page_icon_config", 16);
reg("page_icon_search", 16);
reg("page_icon_info", 16);
reg("page_icon_galaxy", 11);
reg("page_icon_quadrant", 9);
reg("page_icon_star", 12);
reg("page_icon_planet", 16);
reg("energy", 16);
reg("arrow_right", 19);
reg("travel_icon", 18);
reg("icon_search", 16);
reg("icon_size", 16);
reg("icon_shuttle", 16);
reg("icon_size", 16);
reg("icon_stats", 16);
reg("icon_scount_planet", 32);
reg("icon_attack", 16);
reg("up_arrow", 7);
reg("crosshair", 3);
reg("up_arrow_large", 18);
reg("android_feature_icon_bg", 22);
reg("android_feature_icon_bg_active", 22);
reg("health", 18);
reg("black_circle", 18);
reg("connections", 16);
reg("ammo", 18);
reg("temperature", 18);
reg("flash_drive", 16);
reg("trade", 16);
reg("mini_quit", 16);
reg("mini_back", 16);
reg("tick", 16);
reg("list", 16);
reg("grid", 16);
reg("sort_random", 16);
reg("minimap_target",21);
reg("question_mark",20);
reg("android_feature_icon_bg_black",22);
reg("smile",16);

MatterOverdrive.statRegistry.registerIcons(this);
}

@SubscribeEvent
public void onModelBaking(ModelBakeEvent event)
{
textureMap.loadSprites(Minecraft.getMinecraft().getResourceManager(), iconRegistry -> {
for (Map.Entry<String,HoloIcon> entry : iconMap.entrySet())
{
TextureAtlasSprite sprite = iconRegistry.registerSprite(new ResourceLocation("mo:gui/items/"+ entry.getKey()));
entry.getValue().setIcon(sprite);
}
});
}

private void reg(String iconName, int originalSize) {
registerIcon(iconName,originalSize);
private void reg(TextureMap textureMap,String iconName, int originalSize) {
registerIcon(textureMap,iconName,originalSize);
}

public HoloIcon registerIcon(String iconName,int originalSize)
public HoloIcon registerIcon(TextureMap textureMap,String iconName,int originalSize)
{
HoloIcon holoIcon = new HoloIcon(textureMap.registerSprite(new ResourceLocation(Reference.MOD_ID + ":" + iconName)), originalSize, originalSize);
HoloIcon holoIcon = new HoloIcon(textureMap.registerSprite(new ResourceLocation(Reference.MOD_ID,iconName)), originalSize, originalSize);
iconMap.put(iconName, holoIcon);
return holoIcon;
}
Expand Down Expand Up @@ -176,17 +104,17 @@ public void renderIcon(HoloIcon icon, double x, double y, int width, int height)
}
}

public static void tessalateParticleIcon(MOEntityFX.ParticleIcon icon, double x, double y, double z, float size, Color color)
public static void tessalateParticleIcon(TextureAtlasSprite icon, double x, double y, double z, float size, Color color)
{
RenderUtils.tessalateParticle(Minecraft.getMinecraft().getRenderViewEntity(), icon, size, new Vec3(x, y, z), color);
}

public static void tessalateStaticIcon(MOEntityFX.ParticleIcon icon, double x, double y, double z, float size, Color color)
public static void tessalateStaticIcon(TextureAtlasSprite icon, double x, double y, double z, float size, Color color)
{
tessalateStaticIcon(icon, x, y, z, size, color, 1);
}

public static void tessalateStaticIcon(MOEntityFX.ParticleIcon icon, double x, double y, double z, float size, Color color, float multiply)
public static void tessalateStaticIcon(TextureAtlasSprite icon, double x, double y, double z, float size, Color color, float multiply)
{
float halfSize = size / 2;
float uMin = icon.getMinU();
Expand All @@ -200,4 +128,74 @@ public static void tessalateStaticIcon(MOEntityFX.ParticleIcon icon, double x, d
wr.pos(x + halfSize,y + halfSize,z).tex(uMin,vMin).color(color.getFloatR() * multiply, color.getFloatG() * multiply, color.getFloatB() * multiply, color.getFloatA()).endVertex();
wr.pos(x - halfSize,y + halfSize,z).tex(uMax,vMin).color(color.getFloatR() * multiply, color.getFloatG() * multiply, color.getFloatB() * multiply, color.getFloatA()).endVertex();
}

@Override
public void registerSprites(TextureMap ir)
{
reg(ir,"holo_home", 14);
reg(ir,"holo_dotted_circle", 20);
reg(ir,"holo_factory", 14);
reg(ir,"person", 18);
reg(ir,"android_slot_arms", 16);
reg(ir,"android_slot_chest", 16);
reg(ir,"android_slot_head", 16);
reg(ir,"android_slot_legs", 16);
reg(ir,"android_slot_other", 16);
reg(ir,"barrel", 16);
reg(ir,"battery", 16);
reg(ir,"color", 16);
reg(ir,"factory", 16);
reg(ir,"module", 16);
reg(ir,"sights", 16);
reg(ir,"shielding", 16);
reg(ir,"scanner", 16);
reg(ir,"upgrade", 16);
reg(ir,"decompose", 16);
reg(ir,"pattern_storage", 16);
reg(ir,"home_icon", 14);
reg(ir,"page_icon_home", 14);
reg(ir,"page_icon_tasks", 15);
reg(ir,"page_icon_upgrades", 12);
reg(ir,"page_icon_config", 16);
reg(ir,"page_icon_search", 16);
reg(ir,"page_icon_info", 16);
reg(ir,"page_icon_galaxy", 11);
reg(ir,"page_icon_quadrant", 9);
reg(ir,"page_icon_star", 12);
reg(ir,"page_icon_planet", 16);
reg(ir,"energy", 16);
reg(ir,"arrow_right", 19);
reg(ir,"travel_icon", 18);
reg(ir,"icon_search", 16);
reg(ir,"icon_size", 16);
reg(ir,"icon_shuttle", 16);
reg(ir,"icon_size", 16);
reg(ir,"icon_stats", 16);
reg(ir,"icon_scount_planet", 32);
reg(ir,"icon_attack", 16);
reg(ir,"up_arrow", 7);
reg(ir,"crosshair", 3);
reg(ir,"up_arrow_large", 18);
reg(ir,"android_feature_icon_bg", 22);
reg(ir,"android_feature_icon_bg_active", 22);
reg(ir,"health", 18);
reg(ir,"black_circle", 18);
reg(ir,"connections", 16);
reg(ir,"ammo", 18);
reg(ir,"temperature", 18);
reg(ir,"flash_drive", 16);
reg(ir,"trade", 16);
reg(ir,"mini_quit", 16);
reg(ir,"mini_back", 16);
reg(ir,"tick", 16);
reg(ir,"list", 16);
reg(ir,"grid", 16);
reg(ir,"sort_random", 16);
reg(ir,"minimap_target",21);
reg(ir,"question_mark",20);
reg(ir,"android_feature_icon_bg_black",22);
reg(ir,"smile",16);

MatterOverdrive.statRegistry.registerIcons(ir,this);
}
}
Loading

0 comments on commit 9c24dee

Please sign in to comment.