Turned Lib into a mod
This commit is contained in:
parent
d9a74730ab
commit
e3300615a6
10 changed files with 121 additions and 527 deletions
6
src/minecraft/dark/core/ClientProxy.java
Normal file
6
src/minecraft/dark/core/ClientProxy.java
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
package dark.core;
|
||||||
|
|
||||||
|
public class ClientProxy extends MainProxy
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -1,35 +1,97 @@
|
||||||
package dark.core;
|
package dark.core;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import net.minecraftforge.common.Configuration;
|
import net.minecraftforge.common.Configuration;
|
||||||
|
import universalelectricity.prefab.network.PacketManager;
|
||||||
import cpw.mods.fml.common.Loader;
|
import cpw.mods.fml.common.Loader;
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.Mod.EventHandler;
|
||||||
|
import cpw.mods.fml.common.Mod.Metadata;
|
||||||
|
import cpw.mods.fml.common.ModMetadata;
|
||||||
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.network.NetworkMod;
|
||||||
|
|
||||||
|
/** @author HangCow, DarkGuardsman */
|
||||||
|
@Mod(modid = DarkMain.MOD_ID, name = DarkMain.MOD_NAME, version = DarkMain.VERSION, useMetadata = true)
|
||||||
|
@NetworkMod(channels = { DarkMain.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
|
||||||
public class DarkMain
|
public class DarkMain
|
||||||
{
|
{
|
||||||
private static boolean loadedItems = false;
|
// @Mod Prerequisites
|
||||||
|
public static final String MAJOR_VERSION = "@MAJOR@";
|
||||||
|
public static final String MINOR_VERSION = "@MINOR@";
|
||||||
|
public static final String REVIS_VERSION = "@REVIS@";
|
||||||
|
public static final String BUILD_VERSION = "@BUILD@";
|
||||||
|
|
||||||
|
// @Mod
|
||||||
|
public static final String MOD_ID = "DarkCore";
|
||||||
|
public static final String MOD_NAME = "Dark Heart";
|
||||||
|
public static final String VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + REVIS_VERSION + "." + BUILD_VERSION;
|
||||||
|
|
||||||
|
@SidedProxy(clientSide = "dark.core.ClientProxy", serverSide = "dark.core.MainProxy")
|
||||||
|
public static MainProxy proxy;
|
||||||
|
|
||||||
|
public static final String CHANNEL = "DarkPackets";
|
||||||
|
|
||||||
|
@Metadata(DarkMain.MOD_ID)
|
||||||
|
public static ModMetadata meta;
|
||||||
|
|
||||||
/* RESOURCE FILE PATHS */
|
/* RESOURCE FILE PATHS */
|
||||||
public static final String RESOURCE_PATH = "/mods/dark/";
|
public static final String DOMAIN = "dark";
|
||||||
public static final String TEXTURE_DIRECTORY = RESOURCE_PATH + "textures/";
|
public static final String PREFIX = DOMAIN + ":";
|
||||||
|
|
||||||
|
public static final String DIRECTORY_NO_SLASH = "assets/" + DOMAIN + "/";
|
||||||
|
public static final String DIRECTORY = "/" + DIRECTORY_NO_SLASH;
|
||||||
|
public static final String LANGUAGE_PATH = DIRECTORY + "languages/";
|
||||||
|
public static final String SOUND_PATH = DIRECTORY + "audio/";
|
||||||
|
|
||||||
|
public static final String TEXTURE_DIRECTORY = "textures/";
|
||||||
|
public static final String BLOCK_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
|
||||||
|
public static final String ITEM_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
||||||
|
public static final String MODEL_DIRECTORY = TEXTURE_DIRECTORY + "models/";
|
||||||
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
|
public static final String GUI_DIRECTORY = TEXTURE_DIRECTORY + "gui/";
|
||||||
public static final String BLOCK_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "blocks/";
|
|
||||||
public static final String ITEM_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "items/";
|
|
||||||
public static final String MODEL_TEXTURE_DIRECTORY = TEXTURE_DIRECTORY + "models/";
|
|
||||||
public static final String TEXTURE_NAME_PREFIX = "dark:";
|
|
||||||
|
|
||||||
|
/** Main config file */
|
||||||
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/General.cfg"));
|
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir(), "Dark/General.cfg"));
|
||||||
|
/** Main mod output to console */
|
||||||
public static final Logger LOGGER = Logger.getLogger("DarkLib");
|
public static final Logger LOGGER = Logger.getLogger("DarkLib");
|
||||||
|
|
||||||
public void init()
|
@EventHandler
|
||||||
|
public void preInit(FMLPreInitializationEvent event)
|
||||||
{
|
{
|
||||||
|
proxy.preInit();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void registerMod(Object mod)
|
@EventHandler
|
||||||
|
public void generalLoad(FMLInitializationEvent event)
|
||||||
{
|
{
|
||||||
|
proxy.init();
|
||||||
|
|
||||||
|
/* MCMOD.INFO FILE BUILDER? */
|
||||||
|
meta.modId = DarkMain.MOD_ID;
|
||||||
|
meta.name = DarkMain.MOD_NAME;
|
||||||
|
meta.description = "Main mod for several of the mods created by DarkGuardsman and his team. Doesn't add much of anything by itself but is needed for several mods to function correctly";
|
||||||
|
meta.url = "www.BuiltBroken.com";
|
||||||
|
|
||||||
|
meta.logoFile = DarkMain.TEXTURE_DIRECTORY + "GP_Banner.png";
|
||||||
|
meta.version = DarkMain.VERSION;
|
||||||
|
meta.authorList = Arrays.asList(new String[] { "DarkGuardsman", "HangCow" });
|
||||||
|
meta.credits = "Please see the website.";
|
||||||
|
meta.autogenerated = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void postLoad(FMLPostInitializationEvent event)
|
||||||
|
{
|
||||||
|
proxy.postInit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
23
src/minecraft/dark/core/MainProxy.java
Normal file
23
src/minecraft/dark/core/MainProxy.java
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
package dark.core;
|
||||||
|
|
||||||
|
public class MainProxy
|
||||||
|
{
|
||||||
|
public void preInit()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void postInit()
|
||||||
|
{
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,14 +1,10 @@
|
||||||
package dark.core.api;
|
package dark.core.api;
|
||||||
|
|
||||||
|
|
||||||
public interface IColorCoded
|
public interface IColorCoded
|
||||||
{
|
{
|
||||||
/**
|
/** Returns the ColorCode of the object */
|
||||||
* Returns the ColorCode of the object
|
|
||||||
*/
|
|
||||||
public ColorCode getColor();
|
public ColorCode getColor();
|
||||||
/**
|
|
||||||
* Sets the ColorCode of the Object
|
/** Sets the ColorCode of the Object */
|
||||||
*/
|
|
||||||
public void setColor(Object obj);
|
public void setColor(Object obj);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,50 +1,42 @@
|
||||||
package dark.core.api;
|
package dark.core.api;
|
||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dark.library.access.AccessLevel;
|
import dark.library.access.AccessLevel;
|
||||||
import dark.library.access.UserAccess;
|
import dark.library.access.UserAccess;
|
||||||
|
|
||||||
|
/** Used by any object that needs to restrict access to it by a set of usernames
|
||||||
|
*
|
||||||
|
* @author DarkGuardsman */
|
||||||
public interface ISpecialAccess
|
public interface ISpecialAccess
|
||||||
{
|
{
|
||||||
/**
|
/** Gets the player's access level on the machine he is using
|
||||||
* Gets the player's access level on the machine he is using
|
|
||||||
*
|
*
|
||||||
* @return access level of the player, make sure to return no access if the player doesn't have
|
* @return access level of the player, make sure to return no access if the player doesn't have
|
||||||
* any
|
* any */
|
||||||
*/
|
|
||||||
public AccessLevel getUserAccess(String username);
|
public AccessLevel getUserAccess(String username);
|
||||||
|
|
||||||
/**
|
/** gets the access list for the machine
|
||||||
* gets the access list for the machine
|
|
||||||
*
|
*
|
||||||
* @return hasMap of players and there access levels
|
* @return hasMap of players and there access levels */
|
||||||
*/
|
|
||||||
public List<UserAccess> getUsers();
|
public List<UserAccess> getUsers();
|
||||||
|
|
||||||
/**
|
/** sets the players access level in the access map
|
||||||
* sets the players access level in the access map
|
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return true if the level was set false if something went wrong
|
* @return true if the level was set false if something went wrong */
|
||||||
*/
|
|
||||||
public boolean addUserAccess(String username, AccessLevel level, boolean save);
|
public boolean addUserAccess(String username, AccessLevel level, boolean save);
|
||||||
|
|
||||||
/**
|
/** Removes the user from the access list
|
||||||
* Removes the user from the access list
|
|
||||||
*
|
*
|
||||||
* @param username
|
* @param username
|
||||||
* @return
|
* @return */
|
||||||
*/
|
|
||||||
public boolean removeUserAccess(String username);
|
public boolean removeUserAccess(String username);
|
||||||
|
|
||||||
/**
|
/** Gets a list of users with this specified access level.
|
||||||
* Gets a list of users with this specified access level.
|
|
||||||
*
|
*
|
||||||
* @param level
|
* @param level
|
||||||
* @return
|
* @return */
|
||||||
*/
|
|
||||||
List<UserAccess> getUsersWithAcess(AccessLevel level);
|
List<UserAccess> getUsersWithAcess(AccessLevel level);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,106 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
|
||||||
* 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
package dark.core.render;
|
|
||||||
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
|
||||||
|
|
||||||
public class EntityBlock extends Entity
|
|
||||||
{
|
|
||||||
|
|
||||||
@SideOnly(Side.CLIENT)
|
|
||||||
public Icon texture;
|
|
||||||
public float shadowSize = 0;
|
|
||||||
public float rotationX = 0;
|
|
||||||
public float rotationY = 0;
|
|
||||||
public float rotationZ = 0;
|
|
||||||
public double iSize, jSize, kSize;
|
|
||||||
private int brightness = -1;
|
|
||||||
|
|
||||||
public EntityBlock(World world)
|
|
||||||
{
|
|
||||||
super(world);
|
|
||||||
preventEntitySpawning = false;
|
|
||||||
noClip = true;
|
|
||||||
isImmuneToFire = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBlock(World world, double xPos, double yPos, double zPos)
|
|
||||||
{
|
|
||||||
super(world);
|
|
||||||
setPositionAndRotation(xPos, yPos, zPos, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public EntityBlock(World world, double i, double j, double k, double iSize, double jSize, double kSize)
|
|
||||||
{
|
|
||||||
this(world);
|
|
||||||
this.iSize = iSize;
|
|
||||||
this.jSize = jSize;
|
|
||||||
this.kSize = kSize;
|
|
||||||
setPositionAndRotation(i, j, k, 0, 0);
|
|
||||||
this.motionX = 0.0;
|
|
||||||
this.motionY = 0.0;
|
|
||||||
this.motionZ = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setPosition(double d, double d1, double d2)
|
|
||||||
{
|
|
||||||
super.setPosition(d, d1, d2);
|
|
||||||
boundingBox.minX = posX;
|
|
||||||
boundingBox.minY = posY;
|
|
||||||
boundingBox.minZ = posZ;
|
|
||||||
|
|
||||||
boundingBox.maxX = posX + iSize;
|
|
||||||
boundingBox.maxY = posY + jSize;
|
|
||||||
boundingBox.maxZ = posZ + kSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void moveEntity(double d, double d1, double d2)
|
|
||||||
{
|
|
||||||
setPosition(posX + d, posY + d1, posZ + d2);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBrightness(int brightness)
|
|
||||||
{
|
|
||||||
this.brightness = brightness;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void entityInit()
|
|
||||||
{
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void readEntityFromNBT(NBTTagCompound data)
|
|
||||||
{
|
|
||||||
iSize = data.getDouble("iSize");
|
|
||||||
jSize = data.getDouble("jSize");
|
|
||||||
kSize = data.getDouble("kSize");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void writeEntityToNBT(NBTTagCompound data)
|
|
||||||
{
|
|
||||||
data.setDouble("iSize", iSize);
|
|
||||||
data.setDouble("jSize", jSize);
|
|
||||||
data.setDouble("kSize", kSize);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getBrightnessForRender(float par1)
|
|
||||||
{
|
|
||||||
return brightness > 0 ? brightness : super.getBrightnessForRender(par1);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,148 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011 http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public License
|
|
||||||
* 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
package dark.core.render;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.GLAllocation;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import dark.core.render.RenderEntityBlock.BlockInterface;
|
|
||||||
|
|
||||||
/** @author CovertJaguar <railcraft.wikispaces.com> */
|
|
||||||
public class LiquidRenderer
|
|
||||||
{
|
|
||||||
|
|
||||||
private static Map<FluidStack, int[]> flowingRenderCache = new HashMap<FluidStack, int[]>();
|
|
||||||
private static Map<FluidStack, int[]> stillRenderCache = new HashMap<FluidStack, int[]>();
|
|
||||||
public static final int DISPLAY_STAGES = 100;
|
|
||||||
private static final BlockInterface liquidBlock = new BlockInterface();
|
|
||||||
|
|
||||||
public static class LiquidTextureException extends RuntimeException
|
|
||||||
{
|
|
||||||
|
|
||||||
private final FluidStack liquid;
|
|
||||||
|
|
||||||
public LiquidTextureException(FluidStack liquid)
|
|
||||||
{
|
|
||||||
super();
|
|
||||||
this.liquid = liquid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
String liquidName = liquid.getFluid().getName();
|
|
||||||
if (liquidName == null)
|
|
||||||
{
|
|
||||||
liquidName = String.format("ID: %d", liquid.getFluid().getBlockID());
|
|
||||||
}
|
|
||||||
return String.format("Liquid %s has no icon. Please contact the author of the mod the liquid came from.", liquidName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Icon getLiquidTexture(FluidStack liquid)
|
|
||||||
{
|
|
||||||
if (liquid == null || liquid.getFluid() == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Icon icon = liquid.getFluid().getIcon();
|
|
||||||
if (icon == null)
|
|
||||||
{
|
|
||||||
throw new LiquidTextureException(liquid);
|
|
||||||
}
|
|
||||||
return icon;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getLiquidSheet(Fluid liquid)
|
|
||||||
{
|
|
||||||
return "/terrain.png";
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int[] getLiquidDisplayLists(FluidStack liquid, World world, boolean flowing)
|
|
||||||
{
|
|
||||||
if (liquid == null || liquid.getFluid() == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
Fluid fluid = liquid.getFluid();
|
|
||||||
|
|
||||||
Map<FluidStack, int[]> cache = flowing ? flowingRenderCache : stillRenderCache;
|
|
||||||
|
|
||||||
int[] diplayLists = cache.get(liquid);
|
|
||||||
if (diplayLists != null)
|
|
||||||
{
|
|
||||||
return diplayLists;
|
|
||||||
}
|
|
||||||
|
|
||||||
diplayLists = new int[DISPLAY_STAGES];
|
|
||||||
|
|
||||||
if (fluid.getBlockID() < Block.blocksList.length && Block.blocksList[fluid.getBlockID()] != null)
|
|
||||||
{
|
|
||||||
liquidBlock.baseBlock = Block.blocksList[fluid.getBlockID()];
|
|
||||||
if (!flowing)
|
|
||||||
{
|
|
||||||
liquidBlock.texture = getLiquidTexture(liquid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (Item.itemsList[fluid.getBlockID()] != null)
|
|
||||||
{
|
|
||||||
liquidBlock.baseBlock = Block.waterStill;
|
|
||||||
liquidBlock.texture = getLiquidTexture(liquid);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
cache.put(liquid, diplayLists);
|
|
||||||
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glDisable(GL11.GL_BLEND);
|
|
||||||
GL11.glDisable(GL11.GL_CULL_FACE);
|
|
||||||
|
|
||||||
int color = fluid.getColor();
|
|
||||||
float c1 = (float) (color >> 16 & 255) / 255.0F;
|
|
||||||
float c2 = (float) (color >> 8 & 255) / 255.0F;
|
|
||||||
float c3 = (float) (color & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(c1, c2, c3, 1);
|
|
||||||
for (int s = 0; s < DISPLAY_STAGES; ++s)
|
|
||||||
{
|
|
||||||
diplayLists[s] = GLAllocation.generateDisplayLists(1);
|
|
||||||
GL11.glNewList(diplayLists[s], 4864 /*GL_COMPILE*/);
|
|
||||||
|
|
||||||
liquidBlock.minX = 0.01f;
|
|
||||||
liquidBlock.minY = 0;
|
|
||||||
liquidBlock.minZ = 0.01f;
|
|
||||||
|
|
||||||
liquidBlock.maxX = 0.99f;
|
|
||||||
liquidBlock.maxY = (float) s / (float) DISPLAY_STAGES;
|
|
||||||
liquidBlock.maxZ = 0.99f;
|
|
||||||
|
|
||||||
RenderEntityBlock.renderBlock(liquidBlock, world, 0, 0, 0, false, true);
|
|
||||||
|
|
||||||
GL11.glEndList();
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glColor4f(1, 1, 1, 1);
|
|
||||||
GL11.glEnable(GL11.GL_CULL_FACE);
|
|
||||||
GL11.glEnable(GL11.GL_BLEND);
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
|
|
||||||
return diplayLists;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,231 +0,0 @@
|
||||||
/**
|
|
||||||
* Copyright (c) SpaceToad, 2011
|
|
||||||
* http://www.mod-buildcraft.com
|
|
||||||
*
|
|
||||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
|
||||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
|
||||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
|
||||||
*/
|
|
||||||
|
|
||||||
package dark.core.render;
|
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.client.renderer.RenderBlocks;
|
|
||||||
import net.minecraft.client.renderer.Tessellator;
|
|
||||||
import net.minecraft.client.renderer.entity.Render;
|
|
||||||
import net.minecraft.entity.Entity;
|
|
||||||
import net.minecraft.util.Icon;
|
|
||||||
import net.minecraft.util.ResourceLocation;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
|
||||||
import net.minecraft.world.World;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
public class RenderEntityBlock extends Render
|
|
||||||
{
|
|
||||||
|
|
||||||
private static RenderBlocks renderBlocks = new RenderBlocks();
|
|
||||||
private static final ResourceLocation field_110782_f = new ResourceLocation("textures/entity/boat.png");
|
|
||||||
|
|
||||||
public static class BlockInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public double minX;
|
|
||||||
public double minY;
|
|
||||||
public double minZ;
|
|
||||||
public double maxX;
|
|
||||||
public double maxY;
|
|
||||||
public double maxZ;
|
|
||||||
|
|
||||||
public Block baseBlock = Block.sand;
|
|
||||||
|
|
||||||
public Icon texture = null;
|
|
||||||
|
|
||||||
public Icon getBlockTextureFromSide(int i)
|
|
||||||
{
|
|
||||||
if (texture == null)
|
|
||||||
return baseBlock.getBlockTextureFromSide(i);
|
|
||||||
else
|
|
||||||
return texture;
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getBlockBrightness(IBlockAccess iblockaccess, int i, int j, int k)
|
|
||||||
{
|
|
||||||
return baseBlock.getBlockBrightness(iblockaccess, i, j, k);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public RenderEntityBlock()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void doRender(Entity entity, double i, double j, double k, float f, float f1)
|
|
||||||
{
|
|
||||||
doRenderBlock((EntityBlock) entity, i, j, k);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void doRenderBlock(EntityBlock entity, double i, double j, double k)
|
|
||||||
{
|
|
||||||
if (entity.isDead)
|
|
||||||
return;
|
|
||||||
|
|
||||||
shadowSize = entity.shadowSize;
|
|
||||||
World world = entity.worldObj;
|
|
||||||
BlockInterface util = new BlockInterface();
|
|
||||||
util.texture = entity.texture;
|
|
||||||
|
|
||||||
ResourceLocation name = new ResourceLocation("/terrain.png");
|
|
||||||
func_110776_a(name);
|
|
||||||
|
|
||||||
for (int iBase = 0; iBase < entity.iSize; ++iBase)
|
|
||||||
{
|
|
||||||
for (int jBase = 0; jBase < entity.jSize; ++jBase)
|
|
||||||
{
|
|
||||||
for (int kBase = 0; kBase < entity.kSize; ++kBase)
|
|
||||||
{
|
|
||||||
|
|
||||||
util.minX = 0;
|
|
||||||
util.minY = 0;
|
|
||||||
util.minZ = 0;
|
|
||||||
|
|
||||||
double remainX = entity.iSize - iBase;
|
|
||||||
double remainY = entity.jSize - jBase;
|
|
||||||
double remainZ = entity.kSize - kBase;
|
|
||||||
|
|
||||||
util.maxX = (remainX > 1.0 ? 1.0 : remainX);
|
|
||||||
util.maxY = (remainY > 1.0 ? 1.0 : remainY);
|
|
||||||
util.maxZ = (remainZ > 1.0 ? 1.0 : remainZ);
|
|
||||||
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef((float) i, (float) j, (float) k);
|
|
||||||
GL11.glRotatef(entity.rotationX, 1, 0, 0);
|
|
||||||
GL11.glRotatef(entity.rotationY, 0, 1, 0);
|
|
||||||
GL11.glRotatef(entity.rotationZ, 0, 0, 1);
|
|
||||||
GL11.glTranslatef(iBase, jBase, kBase);
|
|
||||||
|
|
||||||
int lightX, lightY, lightZ;
|
|
||||||
|
|
||||||
lightX = (int) (Math.floor(entity.posX) + iBase);
|
|
||||||
lightY = (int) (Math.floor(entity.posY) + jBase);
|
|
||||||
lightZ = (int) (Math.floor(entity.posZ) + kBase);
|
|
||||||
|
|
||||||
GL11.glDisable(2896 /* GL_LIGHTING */);
|
|
||||||
renderBlock(util, world, lightX, lightY, lightZ, false, true);
|
|
||||||
GL11.glEnable(2896 /* GL_LIGHTING */);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderBlock(BlockInterface block, IBlockAccess blockAccess, int i, int j, int k, boolean doLight, boolean doTessellating)
|
|
||||||
{
|
|
||||||
float f = 0.5F;
|
|
||||||
float f1 = 1.0F;
|
|
||||||
float f2 = 0.8F;
|
|
||||||
float f3 = 0.6F;
|
|
||||||
|
|
||||||
renderBlocks.renderMaxX = block.maxX;
|
|
||||||
renderBlocks.renderMinX = block.minX;
|
|
||||||
renderBlocks.renderMaxY = block.maxY;
|
|
||||||
renderBlocks.renderMinY = block.minY;
|
|
||||||
renderBlocks.renderMaxZ = block.maxZ;
|
|
||||||
renderBlocks.renderMinZ = block.minZ;
|
|
||||||
renderBlocks.enableAO = false;
|
|
||||||
|
|
||||||
Tessellator tessellator = Tessellator.instance;
|
|
||||||
|
|
||||||
if (doTessellating)
|
|
||||||
{
|
|
||||||
tessellator.startDrawingQuads();
|
|
||||||
}
|
|
||||||
|
|
||||||
float f4 = 0, f5 = 0;
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f4 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f * f5, f * f5, f * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceYNeg(null, 0, 0, 0, block.getBlockTextureFromSide(0));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f1 * f5, f1 * f5, f1 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceYPos(null, 0, 0, 0, block.getBlockTextureFromSide(1));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceZNeg(null, 0, 0, 0, block.getBlockTextureFromSide(2));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f2 * f5, f2 * f5, f2 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceZPos(null, 0, 0, 0, block.getBlockTextureFromSide(3));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceXNeg(null, 0, 0, 0, block.getBlockTextureFromSide(4));
|
|
||||||
|
|
||||||
if (doLight)
|
|
||||||
{
|
|
||||||
f5 = block.getBlockBrightness(blockAccess, i, j, k);
|
|
||||||
if (f5 < f4)
|
|
||||||
{
|
|
||||||
f5 = f4;
|
|
||||||
}
|
|
||||||
tessellator.setColorOpaque_F(f3 * f5, f3 * f5, f3 * f5);
|
|
||||||
}
|
|
||||||
|
|
||||||
renderBlocks.renderFaceXPos(null, 0, 0, 0, block.getBlockTextureFromSide(5));
|
|
||||||
|
|
||||||
if (doTessellating)
|
|
||||||
{
|
|
||||||
tessellator.draw();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected ResourceLocation func_110775_a(Entity par1Entity)
|
|
||||||
{
|
|
||||||
return field_110782_f;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +1,4 @@
|
||||||
package dark.core;
|
package dark.helpers;
|
||||||
|
|
||||||
import universalelectricity.core.vector.Vector3;
|
import universalelectricity.core.vector.Vector3;
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class PlayerMsgHelper
|
||||||
while (it.hasNext() && canSee)
|
while (it.hasNext() && canSee)
|
||||||
{
|
{
|
||||||
EntityPlayer player = it.next();
|
EntityPlayer player = it.next();
|
||||||
if (world.rayTraceBlocks_do_do(loc.toVec3(), new Vector3(player).add(new Vector3(0, player.getEyeHeight(), 0)).toVec3(), canSee, canSee) != null)
|
if (world.clip(loc.toVec3(), new Vector3(player).add(new Vector3(0, player.getEyeHeight(), 0)).toVec3()) != null)
|
||||||
{
|
{
|
||||||
it.remove();
|
it.remove();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue