Cleanup repo, delete old code
This commit is contained in:
parent
3b18bfae40
commit
41333e001f
23 changed files with 10 additions and 3100 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
de.fu_berlin.inf.dpp.annotations.contribution.color.1=126,185,207
|
||||||
|
de.fu_berlin.inf.dpp.annotations.contribution.color.2=171,168,117
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
lineNumberRuler=true
|
lineNumberRuler=true
|
||||||
overviewRuler_migration=migrated_3.1
|
overviewRuler_migration=migrated_3.1
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<section name="Workbench">
|
<section name="Workbench">
|
||||||
|
<section name="ChooseWorkspaceDialogSettings">
|
||||||
|
<item value="346" key="DIALOG_Y_ORIGIN"/>
|
||||||
|
<item value="658" key="DIALOG_X_ORIGIN"/>
|
||||||
|
</section>
|
||||||
|
<section name="WORKBENCH_SETTINGS">
|
||||||
|
<list key="ENABLED_TRANSFERS">
|
||||||
|
</list>
|
||||||
|
</section>
|
||||||
<section name="ExternalProjectImportWizard">
|
<section name="ExternalProjectImportWizard">
|
||||||
<item value="false" key="WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"/>
|
<item value="false" key="WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"/>
|
||||||
<item value="false" key="WizardProjectsImportPage.STORE_COPY_PROJECT_ID"/>
|
<item value="false" key="WizardProjectsImportPage.STORE_COPY_PROJECT_ID"/>
|
||||||
|
|
|
@ -1,647 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.src.Block;
|
|
||||||
import net.minecraft.src.Entity;
|
|
||||||
import net.minecraft.src.Item;
|
|
||||||
import net.minecraft.src.ModLoader;
|
|
||||||
import net.minecraft.src.Packet100OpenWindow;
|
|
||||||
import net.minecraft.src.RenderBlocks;
|
|
||||||
import net.minecraft.src.SoundPoolEntry;
|
|
||||||
import net.minecraft.src.Tessellator;
|
|
||||||
import net.minecraft.src.RenderGlobal;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
|
||||||
import net.minecraft.src.MovingObjectPosition;
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
import net.minecraft.src.WorldClient;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL11;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.*;
|
|
||||||
import net.minecraft.src.*;
|
|
||||||
import net.minecraft.src.forge.packets.ForgePacket;
|
|
||||||
|
|
||||||
import org.lwjgl.opengl.GL12;
|
|
||||||
|
|
||||||
import static net.minecraft.src.forge.IItemRenderer.ItemRenderType.*;
|
|
||||||
import static net.minecraft.src.forge.IItemRenderer.ItemRendererHelper.*;
|
|
||||||
|
|
||||||
public class ForgeHooksClient
|
|
||||||
{
|
|
||||||
private static Field textureID = null;
|
|
||||||
private static boolean textureIDChecked = false;
|
|
||||||
public static boolean enable4096 = false; //If the server has told us that 4096 is enabled.
|
|
||||||
|
|
||||||
public static boolean onBlockHighlight(RenderGlobal render, EntityPlayer player, MovingObjectPosition target, int i, ItemStack itemstack, float partialTicks)
|
|
||||||
{
|
|
||||||
for (IHighlightHandler handler : highlightHandlers)
|
|
||||||
{
|
|
||||||
if (handler.onBlockHighlight(render, player, target, i, itemstack, partialTicks))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onRenderWorldLast(RenderGlobal render, float partialTicks)
|
|
||||||
{
|
|
||||||
for (IRenderWorldLastHandler handler : renderWorldLastHandlers)
|
|
||||||
{
|
|
||||||
handler.onRenderWorldLast(render, partialTicks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedList<IHighlightHandler> highlightHandlers = new LinkedList<IHighlightHandler>();
|
|
||||||
public static LinkedList<IRenderWorldLastHandler> renderWorldLastHandlers = new LinkedList<IRenderWorldLastHandler>();
|
|
||||||
|
|
||||||
public static void onTextureLoad(String textureName, int textureID)
|
|
||||||
{
|
|
||||||
for (ITextureLoadHandler handler: textureLoadHandlers)
|
|
||||||
{
|
|
||||||
handler.onTextureLoad(textureName, textureID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public static LinkedList<ITextureLoadHandler> textureLoadHandlers = new LinkedList<ITextureLoadHandler>();
|
|
||||||
|
|
||||||
public static boolean canRenderInPass(Block block, int pass)
|
|
||||||
{
|
|
||||||
if (block instanceof IMultipassRender)
|
|
||||||
{
|
|
||||||
return ((IMultipassRender)block).canRenderInPass(pass);
|
|
||||||
}
|
|
||||||
if (pass == block.getRenderBlockPass())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static class TesKey implements Comparable<TesKey>
|
|
||||||
{
|
|
||||||
public TesKey(int textureID, int subID)
|
|
||||||
{
|
|
||||||
tex = textureID;
|
|
||||||
sub = subID;
|
|
||||||
}
|
|
||||||
public int compareTo(TesKey key)
|
|
||||||
{
|
|
||||||
if (sub == key.sub)
|
|
||||||
{
|
|
||||||
return tex - key.tex;
|
|
||||||
}
|
|
||||||
return sub - key.sub;
|
|
||||||
}
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
return compareTo((TesKey)obj) == 0;
|
|
||||||
}
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int c1 = Integer.valueOf(tex).hashCode();
|
|
||||||
int c2 = Integer.valueOf(sub).hashCode();
|
|
||||||
return c1 + 31 * c2;
|
|
||||||
}
|
|
||||||
public int tex, sub;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HashMap<TesKey, Tessellator> tessellators = new HashMap<TesKey, Tessellator>();
|
|
||||||
public static HashMap<String, Integer> textures = new HashMap<String, Integer>();
|
|
||||||
public static boolean inWorld = false;
|
|
||||||
public static TreeSet<TesKey> renderTextures = new TreeSet<TesKey>();
|
|
||||||
public static Tessellator defaultTessellator = null;
|
|
||||||
public static HashMap<TesKey, IRenderContextHandler> renderHandlers = new HashMap<TesKey, IRenderContextHandler>();
|
|
||||||
|
|
||||||
protected static void registerRenderContextHandler(String texture, int subID, IRenderContextHandler handler)
|
|
||||||
{
|
|
||||||
Integer texID = textures.get(texture);
|
|
||||||
if (texID == null)
|
|
||||||
{
|
|
||||||
texID = ModLoader.getMinecraftInstance().renderEngine.getTexture(texture);
|
|
||||||
textures.put(texture, texID);
|
|
||||||
}
|
|
||||||
renderHandlers.put(new TesKey(texID, subID), handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void bindTessellator(int texture, int subID)
|
|
||||||
{
|
|
||||||
TesKey key = new TesKey(texture, subID);
|
|
||||||
Tessellator tess = tessellators.get(key);
|
|
||||||
if (tess == null)
|
|
||||||
{
|
|
||||||
tess = new Tessellator();
|
|
||||||
//Hack around for waiting for Optifine to implement the feature he requested.
|
|
||||||
//Should make it not cause while we wait for him to update.
|
|
||||||
if (!textureIDChecked && textureID == null)
|
|
||||||
{
|
|
||||||
textureIDChecked = true;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
textureID = Tessellator.class.getField("textureID");
|
|
||||||
}
|
|
||||||
catch (NoSuchFieldException ex){}
|
|
||||||
}
|
|
||||||
if (textureID != null)
|
|
||||||
{
|
|
||||||
tess.textureID = texture;
|
|
||||||
}
|
|
||||||
//End Hack
|
|
||||||
tessellators.put(key, tess);
|
|
||||||
}
|
|
||||||
if (inWorld && !renderTextures.contains(key))
|
|
||||||
{
|
|
||||||
renderTextures.add(key);
|
|
||||||
tess.startDrawingQuads();
|
|
||||||
tess.setTranslation(defaultTessellator.xOffset, defaultTessellator.yOffset, defaultTessellator.zOffset);
|
|
||||||
}
|
|
||||||
Tessellator.instance = tess;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IRenderContextHandler unbindContext = null;
|
|
||||||
protected static void bindTexture(String texture, int subID)
|
|
||||||
{
|
|
||||||
Integer texID = textures.get(texture);
|
|
||||||
if (texID == null)
|
|
||||||
{
|
|
||||||
texID = ModLoader.getMinecraftInstance().renderEngine.getTexture(texture);
|
|
||||||
textures.put(texture, texID);
|
|
||||||
}
|
|
||||||
if (!inWorld)
|
|
||||||
{
|
|
||||||
if (unbindContext != null)
|
|
||||||
{
|
|
||||||
unbindContext.afterRenderContext();
|
|
||||||
unbindContext = null;
|
|
||||||
}
|
|
||||||
if (Tessellator.instance.isDrawing)
|
|
||||||
{
|
|
||||||
int mode = Tessellator.instance.drawMode;
|
|
||||||
Tessellator.instance.draw();
|
|
||||||
Tessellator.instance.startDrawing(mode);
|
|
||||||
}
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
|
|
||||||
unbindContext = renderHandlers.get(new TesKey(texID, subID));
|
|
||||||
if (unbindContext != null)
|
|
||||||
{
|
|
||||||
unbindContext.beforeRenderContext();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
bindTessellator(texID, subID);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static void unbindTexture()
|
|
||||||
{
|
|
||||||
if (inWorld)
|
|
||||||
{
|
|
||||||
Tessellator.instance = defaultTessellator;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (Tessellator.instance.isDrawing)
|
|
||||||
{
|
|
||||||
int mode = Tessellator.instance.drawMode;
|
|
||||||
Tessellator.instance.draw();
|
|
||||||
if (unbindContext != null)
|
|
||||||
{
|
|
||||||
unbindContext.afterRenderContext();
|
|
||||||
unbindContext = null;
|
|
||||||
}
|
|
||||||
Tessellator.instance.startDrawing(mode);
|
|
||||||
}
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static int renderPass = -1;
|
|
||||||
public static void beforeRenderPass(int pass)
|
|
||||||
{
|
|
||||||
renderPass = pass;
|
|
||||||
defaultTessellator = Tessellator.instance;
|
|
||||||
Tessellator.renderingWorldRenderer = true;
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
|
|
||||||
renderTextures.clear();
|
|
||||||
inWorld = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void afterRenderPass(int pass)
|
|
||||||
{
|
|
||||||
renderPass = -1;
|
|
||||||
inWorld = false;
|
|
||||||
for (TesKey info : renderTextures)
|
|
||||||
{
|
|
||||||
IRenderContextHandler handler = renderHandlers.get(info);
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, info.tex);
|
|
||||||
Tessellator tess = tessellators.get(info);
|
|
||||||
if (handler == null)
|
|
||||||
{
|
|
||||||
tess.draw();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Tessellator.instance = tess;
|
|
||||||
handler.beforeRenderContext();
|
|
||||||
tess.draw();
|
|
||||||
handler.afterRenderContext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture("/terrain.png"));
|
|
||||||
Tessellator.renderingWorldRenderer = false;
|
|
||||||
Tessellator.instance = defaultTessellator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void beforeBlockRender(Block block, RenderBlocks render)
|
|
||||||
{
|
|
||||||
if (!block.isDefaultTexture && render.overrideBlockTexture == -1)
|
|
||||||
{
|
|
||||||
bindTexture(block.getTextureFile(), 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void afterBlockRender(Block block, RenderBlocks render)
|
|
||||||
{
|
|
||||||
if (!block.isDefaultTexture && render.overrideBlockTexture == -1)
|
|
||||||
{
|
|
||||||
unbindTexture();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void overrideTexture(Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof ITextureProvider)
|
|
||||||
{
|
|
||||||
GL11.glBindTexture(GL11.GL_TEXTURE_2D, ModLoader.getMinecraftInstance().renderEngine.getTexture(((ITextureProvider)obj).getTextureFile()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getTexture(String def, Object obj)
|
|
||||||
{
|
|
||||||
if (obj instanceof ITextureProvider)
|
|
||||||
{
|
|
||||||
return ((ITextureProvider)obj).getTextureFile();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void renderEquippedItem(IItemRenderer customRenderer, RenderBlocks renderBlocks, EntityLiving entity, ItemStack item)
|
|
||||||
{
|
|
||||||
if (customRenderer.shouldUseRenderHelper(EQUIPPED, item, EQUIPPED_BLOCK))
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(-0.5F, -0.5F, -0.5F);
|
|
||||||
customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glTranslatef(0.0F, -0.3F, 0.0F);
|
|
||||||
GL11.glScalef(1.5F, 1.5F, 1.5F);
|
|
||||||
GL11.glRotatef(50.0F, 0.0F, 1.0F, 0.0F);
|
|
||||||
GL11.glRotatef(335.0F, 0.0F, 0.0F, 1.0F);
|
|
||||||
GL11.glTranslatef(-0.9375F, -0.0625F, 0.0F);
|
|
||||||
customRenderer.renderItem(EQUIPPED, item, renderBlocks, entity);
|
|
||||||
GL11.glDisable(GL12.GL_RESCALE_NORMAL);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean renderEntityItem(EntityItem entity, ItemStack item, float bobing, float rotation, Random random, RenderEngine engine, RenderBlocks renderBlocks)
|
|
||||||
{
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, ENTITY);
|
|
||||||
|
|
||||||
if (customRenderer == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_ROTATION))
|
|
||||||
{
|
|
||||||
GL11.glRotatef(rotation, 0.0F, 1.0F, 0.0F);
|
|
||||||
}
|
|
||||||
if (!customRenderer.shouldUseRenderHelper(ENTITY, item, ENTITY_BOBBING))
|
|
||||||
{
|
|
||||||
GL11.glTranslatef(0.0F, -bobing, 0.0F);
|
|
||||||
}
|
|
||||||
boolean is3D = customRenderer.shouldUseRenderHelper(ENTITY, item, BLOCK_3D);
|
|
||||||
|
|
||||||
if (item.getItem() instanceof ItemBlock && (is3D || RenderBlocks.renderItemIn3d(Block.blocksList[item.itemID].getRenderType())))
|
|
||||||
{
|
|
||||||
engine.bindTexture(engine.getTexture(item.getItem().getTextureFile()));
|
|
||||||
int renderType = Block.blocksList[item.itemID].getRenderType();
|
|
||||||
float scale = (renderType == 1 || renderType == 19 || renderType == 12 || renderType == 2 ? 0.5F : 0.25F);
|
|
||||||
|
|
||||||
GL11.glScalef(scale, scale, scale);
|
|
||||||
int size = entity.item.stackSize;
|
|
||||||
int count = (size > 20 ? 4 : (size > 5 ? 3 : (size > 1 ? 2 : 1)));
|
|
||||||
|
|
||||||
for(int j = 0; j < size; j++)
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
if (j > 0)
|
|
||||||
{
|
|
||||||
GL11.glTranslatef(
|
|
||||||
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / 0.5F,
|
|
||||||
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / 0.5F,
|
|
||||||
((random.nextFloat() * 2.0F - 1.0F) * 0.2F) / 0.5F);
|
|
||||||
}
|
|
||||||
customRenderer.renderItem(ENTITY, item, renderBlocks, entity);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
engine.bindTexture(engine.getTexture(item.getItem().getTextureFile()));
|
|
||||||
GL11.glScalef(0.5F, 0.5F, 0.5F);
|
|
||||||
customRenderer.renderItem(ENTITY, item, renderBlocks, entity);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean renderInventoryItem(RenderBlocks renderBlocks, RenderEngine engine, ItemStack item, boolean inColor, float zLevel, float x, float y)
|
|
||||||
{
|
|
||||||
IItemRenderer customRenderer = MinecraftForgeClient.getItemRenderer(item, INVENTORY);
|
|
||||||
if (customRenderer == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
engine.bindTexture(engine.getTexture(Item.itemsList[item.itemID].getTextureFile()));
|
|
||||||
if (customRenderer.shouldUseRenderHelper(INVENTORY, item, INVENTORY_BLOCK))
|
|
||||||
{
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(x - 2, y + 3, -3.0F + zLevel);
|
|
||||||
GL11.glScalef(10F, 10F, 10F);
|
|
||||||
GL11.glTranslatef(1.0F, 0.5F, 1.0F);
|
|
||||||
GL11.glScalef(1.0F, 1.0F, -1F);
|
|
||||||
GL11.glRotatef(210F, 1.0F, 0.0F, 0.0F);
|
|
||||||
GL11.glRotatef(45F, 0.0F, 1.0F, 0.0F);
|
|
||||||
|
|
||||||
|
|
||||||
if(inColor)
|
|
||||||
{
|
|
||||||
int color = Item.itemsList[item.itemID].getColorFromDamage(item.getItemDamage(), 0);
|
|
||||||
float r = (float)(color >> 16 & 0xff) / 255F;
|
|
||||||
float g = (float)(color >> 8 & 0xff) / 255F;
|
|
||||||
float b = (float)(color & 0xff) / 255F;
|
|
||||||
GL11.glColor4f(r, g, b, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
GL11.glRotatef(-90F, 0.0F, 1.0F, 0.0F);
|
|
||||||
renderBlocks.useInventoryTint = inColor;
|
|
||||||
customRenderer.renderItem(INVENTORY, item, renderBlocks);
|
|
||||||
renderBlocks.useInventoryTint = true;
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GL11.glDisable(GL11.GL_LIGHTING);
|
|
||||||
GL11.glPushMatrix();
|
|
||||||
GL11.glTranslatef(x, y, -3.0F + zLevel);
|
|
||||||
|
|
||||||
if (inColor)
|
|
||||||
{
|
|
||||||
int color = Item.itemsList[item.itemID].getColorFromDamage(item.getItemDamage(), 0);
|
|
||||||
float r = (float)(color >> 16 & 255) / 255.0F;
|
|
||||||
float g = (float)(color >> 8 & 255) / 255.0F;
|
|
||||||
float b = (float)(color & 255) / 255.0F;
|
|
||||||
GL11.glColor4f(r, g, b, 1.0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
customRenderer.renderItem(INVENTORY, item, renderBlocks);
|
|
||||||
GL11.glPopMatrix();
|
|
||||||
GL11.glEnable(GL11.GL_LIGHTING);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Trys to get the class for the specified name, will also try the
|
|
||||||
* net.minecraft.src package in case we are in MCP
|
|
||||||
* Returns null if not found.
|
|
||||||
*
|
|
||||||
* @param name The class name
|
|
||||||
* @return The Class, or null if not found
|
|
||||||
*/
|
|
||||||
private static Class getClass(String name)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Class.forName(name);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return Class.forName("net.minecraft.src." + name);
|
|
||||||
}
|
|
||||||
catch (Exception e2)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LinkedList<ISoundHandler> soundHandlers = new LinkedList<ISoundHandler>();
|
|
||||||
public static LinkedList<ISoundHandler> soundHandlers2 = new LinkedList<ISoundHandler>();
|
|
||||||
public static void onSetupAudio(SoundManager soundManager)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
handler.onSetupAudio(soundManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLoadSoundSettings(SoundManager soundManager)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
handler.onLoadSoundSettings(soundManager);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundPoolEntry onPlayBackgroundMusic(SoundManager soundManager, SoundPoolEntry entry)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
entry = handler.onPlayBackgroundMusic(soundManager, entry);
|
|
||||||
if (entry == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundPoolEntry onPlayStreaming(SoundManager soundManager, SoundPoolEntry entry, String soundName, float x, float y, float z)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
entry = handler.onPlayStreaming(soundManager, entry, soundName, x, y, z);
|
|
||||||
if (entry == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundPoolEntry onPlaySound(SoundManager soundManager, SoundPoolEntry entry, String soundName, float x, float y, float z, float volume, float pitch)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
entry = handler.onPlaySound(soundManager, entry, soundName, x, y, z, volume, pitch);
|
|
||||||
if (entry == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SoundPoolEntry onPlaySoundEffect(SoundManager soundManager, SoundPoolEntry entry, String soundName, float volume, float pitch)
|
|
||||||
{
|
|
||||||
for (ISoundHandler handler : soundHandlers)
|
|
||||||
{
|
|
||||||
entry = handler.onPlaySoundEffect(soundManager, entry, soundName, volume, pitch);
|
|
||||||
if (entry == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String onPlaySoundAtEntity(Entity entity, String soundName, float volume, float pitch)
|
|
||||||
{
|
|
||||||
MinecraftForgeClient.checkMinecraftVersion("Minecraft Minecraft 1.2.5", "Interface check in onPlaySoundAtEntity, remove it Mods should be updated");
|
|
||||||
for (ISoundHandler handler : soundHandlers2)
|
|
||||||
{
|
|
||||||
soundName = handler.onPlaySoundAtEntity(entity, soundName,volume, pitch);
|
|
||||||
if (soundName == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return soundName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onLogin(Packet1Login login, NetClientHandler net, NetworkManager netManager)
|
|
||||||
{
|
|
||||||
ForgeHooks.onLogin(netManager, login);
|
|
||||||
|
|
||||||
String[] channels = MessageManager.getInstance().getRegisteredChannels(netManager);
|
|
||||||
StringBuilder tmp = new StringBuilder();
|
|
||||||
tmp.append("Forge");
|
|
||||||
for(String channel : channels)
|
|
||||||
{
|
|
||||||
tmp.append("\0");
|
|
||||||
tmp.append(channel);
|
|
||||||
}
|
|
||||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
|
||||||
pkt.channel = "REGISTER";
|
|
||||||
try
|
|
||||||
{
|
|
||||||
pkt.data = tmp.toString().getBytes("UTF8");
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
pkt.length = pkt.data.length;
|
|
||||||
net.addToSendQueue(pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We use some of the unused fields in Packet 001 Login to identify the user as having Forge installed.
|
|
||||||
* This allows modded clients to connect to Vanilla server without crashing.
|
|
||||||
* It also allows unmodded clients to connect to Forge server without crashing.
|
|
||||||
* Its a bit of a dirty hack, but it doesn't interrupt the login flow, and its unused data.
|
|
||||||
* The C->S serverMode is set to the hash code of the string "Forge", this should provide a fairly unique
|
|
||||||
* identifier so we are certain it is not random, and it is Forge installed.
|
|
||||||
* The C->S dimension is set to the current Forge build number, in case we need to do any quick version checks.
|
|
||||||
*/
|
|
||||||
public static Packet onSendLogin(Packet1Login pkt)
|
|
||||||
{
|
|
||||||
enable4096 = false; //Disable 4096 packet modification untill the server says yes.
|
|
||||||
pkt.serverMode = ForgePacket.FORGE_ID;
|
|
||||||
pkt.field_48170_e = ForgeHooks.buildVersion;
|
|
||||||
return pkt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void onCustomPayload(Packet250CustomPayload pkt, NetworkManager net)
|
|
||||||
{
|
|
||||||
MessageManager inst = MessageManager.getInstance();
|
|
||||||
if (pkt.channel.equals("REGISTER"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String channels = new String(pkt.data, "UTF8");
|
|
||||||
for (String channel : channels.split("\0"))
|
|
||||||
{
|
|
||||||
inst.addActiveChannel(net, channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException ex)
|
|
||||||
{
|
|
||||||
ModLoader.throwException("ForgeHooksClient.onCustomPayload", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (pkt.channel.equals("UNREGISTER"))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String channels = new String(pkt.data, "UTF8");
|
|
||||||
for (String channel : channels.split("\0"))
|
|
||||||
{
|
|
||||||
inst.removeActiveChannel(net, channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (UnsupportedEncodingException ex)
|
|
||||||
{
|
|
||||||
ModLoader.throwException("ForgeHooksClient.onCustomPayload", ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inst.dispatchIncomingMessage(net, pkt.channel, pkt.data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is added for Optifine's convenience. And to explode if a ModMaker is developing.
|
|
||||||
* @param texture
|
|
||||||
*/
|
|
||||||
public static void onTextureLoadPre(String texture)
|
|
||||||
{
|
|
||||||
if (Tessellator.renderingWorldRenderer)
|
|
||||||
{
|
|
||||||
String msg = String.format("Warning: Texture %s not preloaded, will cause render glitches!", texture);
|
|
||||||
System.out.println(msg);
|
|
||||||
if (Tessellator.class.getPackage() != null)
|
|
||||||
{
|
|
||||||
if (Tessellator.class.getPackage().equals("net.minecraft.src"))
|
|
||||||
{
|
|
||||||
Minecraft mc = ModLoader.getMinecraftInstance();
|
|
||||||
if (mc.ingameGUI != null)
|
|
||||||
{
|
|
||||||
mc.ingameGUI.addChatMessage(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.*;
|
|
||||||
import net.minecraft.src.forge.packets.PacketMissingMods;
|
|
||||||
|
|
||||||
public class GuiMissingMods extends GuiScreen
|
|
||||||
{
|
|
||||||
PacketMissingMods packet;
|
|
||||||
public GuiMissingMods(PacketMissingMods pkt)
|
|
||||||
{
|
|
||||||
packet = pkt;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initGui()
|
|
||||||
{
|
|
||||||
controlList.clear();
|
|
||||||
controlList.add(new GuiButton(0, width / 2 - 100, height - 60, StringTranslate.getInstance().translateKey("gui.toMenu")));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void actionPerformed(GuiButton guibutton)
|
|
||||||
{
|
|
||||||
if (guibutton.id == 0)
|
|
||||||
{
|
|
||||||
mc.displayGuiScreen(new GuiMainMenu());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void drawScreen(int i, int j, float f)
|
|
||||||
{
|
|
||||||
drawDefaultBackground();
|
|
||||||
drawCenteredString(fontRenderer, "The server requires you to have the following mods:", width / 2, 50, 0xffffff);
|
|
||||||
int y = 0;
|
|
||||||
for (String mod : packet.Mods)
|
|
||||||
{
|
|
||||||
drawCenteredString(fontRenderer, mod, width / 2, 80 + y++ * 10, 0xffffff);
|
|
||||||
}
|
|
||||||
super.drawScreen(i, j, f);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,278 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
|
||||||
import net.minecraft.src.*;
|
|
||||||
import net.minecraft.src.forge.packets.*;
|
|
||||||
|
|
||||||
public class PacketHandlerClient extends PacketHandlerBase
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onPacketData(NetworkManager network, String channel, byte[] bytes)
|
|
||||||
{
|
|
||||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ForgePacket pkt = null;
|
|
||||||
NetClientHandler net = (NetClientHandler)network.getNetHandler();
|
|
||||||
|
|
||||||
int packetID = data.read();
|
|
||||||
switch (packetID)
|
|
||||||
{
|
|
||||||
case ForgePacket.SPAWN:
|
|
||||||
pkt = new PacketEntitySpawn();
|
|
||||||
pkt.readData(data);
|
|
||||||
onEntitySpawnPacket((PacketEntitySpawn)pkt, data, ModLoader.getMinecraftInstance().theWorld);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ForgePacket.MODLIST:
|
|
||||||
pkt = new PacketModList(false);
|
|
||||||
pkt.readData(data);
|
|
||||||
onModListCheck(net, (PacketModList)pkt);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ForgePacket.MOD_MISSING:
|
|
||||||
pkt = new PacketMissingMods(false);
|
|
||||||
pkt.readData(data);
|
|
||||||
onMissingMods((PacketMissingMods)pkt, net);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ForgePacket.OPEN_GUI:
|
|
||||||
pkt = new PacketOpenGUI();
|
|
||||||
pkt.readData(data);
|
|
||||||
onOpenGui((PacketOpenGUI)pkt);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ForgePacket.TRACK:
|
|
||||||
pkt = new PacketEntityTrack();
|
|
||||||
pkt.readData(data);
|
|
||||||
onEntityTrackPacket((PacketEntityTrack)pkt, ModLoader.getMinecraftInstance().theWorld);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
ModLoader.getLogger().log(Level.SEVERE, "Exception in PacketHandlerClient.onPacketData", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Process the Entity Track packet. This corrects the serverPos[XYZ] to match
|
|
||||||
* with the server, so any following relative updates are valid.
|
|
||||||
* @param packet The Track Packet
|
|
||||||
* @param world The world the entity is in
|
|
||||||
*/
|
|
||||||
public void onEntityTrackPacket(PacketEntityTrack packet, World world)
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + packet.toString(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
Minecraft mc = ModLoader.getMinecraftInstance();
|
|
||||||
Entity entity = ((WorldClient)world).getEntityByID(packet.entityId);
|
|
||||||
if (entity == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.serverPosX = packet.serverPosX;
|
|
||||||
entity.serverPosY = packet.serverPosY;
|
|
||||||
entity.serverPosZ = packet.serverPosZ;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes the Entity Spawn packet. And spawns an entity in world as needed.
|
|
||||||
* If the client has the required client mod.
|
|
||||||
* @param packet The Spawn Packet
|
|
||||||
* @param data A stream holding extra data for the entity to read
|
|
||||||
* @param world The world to spawn the entity in
|
|
||||||
*/
|
|
||||||
public void onEntitySpawnPacket(PacketEntitySpawn packet, DataInputStream data, World world)
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + packet.toString(true));
|
|
||||||
}
|
|
||||||
Class cls = MinecraftForge.getEntityClass(packet.modID, packet.typeID);
|
|
||||||
if (cls == null)
|
|
||||||
{
|
|
||||||
System.out.println("Could not find entity info for " + Integer.toHexString(packet.modID) + " : " + packet.typeID);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
double posX = (double)packet.posX / 32D;
|
|
||||||
double posY = (double)packet.posY / 32D;
|
|
||||||
double posZ = (double)packet.posZ / 32D;
|
|
||||||
float yaw = (float)(packet.yaw * 360) / 256.0F;
|
|
||||||
float pitch = (float)(packet.pitch * 360) / 256.0F;
|
|
||||||
float yawHead = (float)(packet.yawHead * 360) / 256.0F;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Entity entity = (Entity)(cls.getConstructor(World.class).newInstance(world));
|
|
||||||
if (entity instanceof IThrowableEntity)
|
|
||||||
{
|
|
||||||
Minecraft mc = ModLoader.getMinecraftInstance();
|
|
||||||
Entity thrower = (mc.thePlayer.entityId == packet.throwerID ? mc.thePlayer : ((WorldClient)world).getEntityByID(packet.throwerID));
|
|
||||||
((IThrowableEntity)entity).setThrower(thrower);
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.serverPosX = packet.posX;
|
|
||||||
entity.serverPosY = packet.posY;
|
|
||||||
entity.serverPosZ = packet.posZ;
|
|
||||||
|
|
||||||
Entity parts[] = entity.getParts();
|
|
||||||
if (parts != null)
|
|
||||||
{
|
|
||||||
int i = packet.entityID - entity.entityId;
|
|
||||||
for (int j = 0; j < parts.length; j++)
|
|
||||||
{
|
|
||||||
parts[j].entityId += i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
entity.entityId = packet.entityID;
|
|
||||||
entity.setPositionAndRotation(posX, posY, posZ, yaw, pitch);
|
|
||||||
|
|
||||||
if (entity instanceof EntityLiving)
|
|
||||||
{
|
|
||||||
((EntityLiving)entity).rotationYawHead = yawHead;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet.metadata != null)
|
|
||||||
{
|
|
||||||
entity.getDataWatcher().updateWatchedObjectsFromList((List)packet.metadata);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet.throwerID > 0)
|
|
||||||
{
|
|
||||||
entity.setVelocity(packet.speedX / 8000D, packet.speedY / 8000D, packet.speedZ / 8000D);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entity instanceof ISpawnHandler)
|
|
||||||
{
|
|
||||||
((ISpawnHandler)entity).readSpawnData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
((WorldClient)world).addEntityToWorld(packet.entityID, entity);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
|
||||||
ModLoader.getLogger().throwing("ForgeHooksClient", "onEntitySpawnPacket", e);
|
|
||||||
ModLoader.throwException(String.format("Error spawning entity of type %d for %s.", packet.typeID, MinecraftForge.getModByID(packet.modID)), e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets up the list of ID to mod mappings.
|
|
||||||
* TODO; Make it display an error, and prompt if the user wishes to continue anyways
|
|
||||||
* if it detects that the server does not have a corresponding mod to one it has installed.
|
|
||||||
*
|
|
||||||
* Sends a list of all loaded mods to the server.
|
|
||||||
* For now, it it simple a String[] of mod.toString()
|
|
||||||
*
|
|
||||||
* @param network The network connection to send the packet on.
|
|
||||||
* @param packet The Server to client packet containing a list of NetworkMod ID's
|
|
||||||
*/
|
|
||||||
private void onModListCheck(NetClientHandler net, PacketModList packet)
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + packet.toString(true));
|
|
||||||
}
|
|
||||||
|
|
||||||
ForgeHooksClient.enable4096 = packet.has4096;
|
|
||||||
|
|
||||||
ForgeHooks.networkMods.clear();
|
|
||||||
NetworkMod[] mods = MinecraftForge.getNetworkMods();
|
|
||||||
for (NetworkMod mod : mods)
|
|
||||||
{
|
|
||||||
for (Entry<Integer, String> entry : packet.ModIDs.entrySet())
|
|
||||||
{
|
|
||||||
if (mod.toString().equals(entry.getValue()))
|
|
||||||
{
|
|
||||||
ForgeHooks.networkMods.put(entry.getKey(), mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ArrayList<NetworkMod> missing = new ArrayList<NetworkMod>();
|
|
||||||
for (NetworkMod mod : mods)
|
|
||||||
{
|
|
||||||
if (MinecraftForge.getModID(mod) == -1 && mod.serverSideRequired())
|
|
||||||
{
|
|
||||||
missing.add(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//TODO: Display error/confirmation screen
|
|
||||||
|
|
||||||
PacketModList pkt = new PacketModList(false);
|
|
||||||
pkt.Mods = new String[ModLoader.getLoadedMods().size()];
|
|
||||||
int x = 0;
|
|
||||||
for (BaseMod mod : (List<BaseMod>)ModLoader.getLoadedMods())
|
|
||||||
{
|
|
||||||
pkt.Mods[x++] = mod.toString();
|
|
||||||
}
|
|
||||||
net.addToSendQueue(pkt.getPacket());
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("C->S: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Received when the client does not have a mod installed that the server requires them to.
|
|
||||||
* Displays a informative screen, and disconnects from the server.
|
|
||||||
*
|
|
||||||
* @param pkt The missing mods packet
|
|
||||||
* @param net The network handler
|
|
||||||
*/
|
|
||||||
private void onMissingMods(PacketMissingMods pkt, NetClientHandler net)
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
net.disconnect();
|
|
||||||
Minecraft mc = ModLoader.getMinecraftInstance();
|
|
||||||
mc.changeWorld1(null);
|
|
||||||
mc.displayGuiScreen(new GuiMissingMods(pkt));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles opening the Gui for the player.
|
|
||||||
*
|
|
||||||
* @param pkt The Open Gui Packet
|
|
||||||
*/
|
|
||||||
private void onOpenGui(PacketOpenGUI pkt)
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
NetworkMod mod = MinecraftForge.getModByID(pkt.ModID);
|
|
||||||
if (mod != null)
|
|
||||||
{
|
|
||||||
EntityPlayerSP player = (EntityPlayerSP)ModLoader.getMinecraftInstance().thePlayer;
|
|
||||||
player.openGui(mod, pkt.GuiID, player.worldObj, pkt.X, pkt.Y, pkt.Z);
|
|
||||||
player.craftingInventory.windowId = pkt.WindowID;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendPacket(NetworkManager network, Packet packet)
|
|
||||||
{
|
|
||||||
NetClientHandler net = (NetClientHandler)network.getNetHandler();
|
|
||||||
net.addToSendQueue(packet);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
|
|
||||||
import net.minecraft.src.forge.ForgeHooks;
|
|
||||||
import net.minecraft.src.forge.MinecraftForge;
|
|
||||||
import net.minecraft.src.forge.MinecraftForgeClient;
|
|
||||||
import net.minecraft.src.forge.NetworkMod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is just here to make the Forge version show up nicely in the ModLoader logs/Crash Screen
|
|
||||||
*/
|
|
||||||
public class mod_MinecraftForge extends NetworkMod
|
|
||||||
{
|
|
||||||
@MLProp(info = "Set to true to disable darkrooms, it adds a extra check when planting the grass and plants to check that they won't instantly die.")
|
|
||||||
public static boolean DISABLE_DARK_ROOMS = false;
|
|
||||||
|
|
||||||
@MLProp(info = "Set to false to reproduce a vinella bug that prevents mobs from spawning on inverted half-slabs and inverted stairs.")
|
|
||||||
public static boolean SPAWNER_ALLOW_ON_INVERTED = true;
|
|
||||||
|
|
||||||
@MLProp(info = "Set to true to randomly shuffle the potential chunks for spawning, this is useful in FTB challange maps where you don't want one side hogging the spawns")
|
|
||||||
public static boolean SPAWNER_MAKE_MORE_RANDOM = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion()
|
|
||||||
{
|
|
||||||
return String.format("%d.%d.%d.%d",
|
|
||||||
ForgeHooks.majorVersion, ForgeHooks.minorVersion,
|
|
||||||
ForgeHooks.revisionVersion, ForgeHooks.buildVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load()
|
|
||||||
{
|
|
||||||
MinecraftForge.getDungeonLootTries(); //Random thing to make things Initialize
|
|
||||||
MinecraftForgeClient.init();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,19 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
public class EntityTrackerInfo
|
|
||||||
{
|
|
||||||
public final NetworkMod Mod;
|
|
||||||
public final int ID;
|
|
||||||
public final int Range;
|
|
||||||
public final int UpdateFrequency;
|
|
||||||
public final boolean SendVelocityInfo;
|
|
||||||
|
|
||||||
public EntityTrackerInfo(NetworkMod mod, int ID, int range, int updateFrequency, boolean sendVelocityInfo)
|
|
||||||
{
|
|
||||||
Mod = mod;
|
|
||||||
this.ID = ID;
|
|
||||||
Range = range;
|
|
||||||
UpdateFrequency = updateFrequency;
|
|
||||||
SendVelocityInfo = sendVelocityInfo;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,243 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.BaseMod;
|
|
||||||
import net.minecraft.src.Block;
|
|
||||||
import net.minecraft.src.Chunk;
|
|
||||||
import net.minecraft.src.ChunkCoordIntPair;
|
|
||||||
import net.minecraft.src.DamageSource;
|
|
||||||
import net.minecraft.src.Entity;
|
|
||||||
import net.minecraft.src.EntityItem;
|
|
||||||
import net.minecraft.src.EntityLiving;
|
|
||||||
import net.minecraft.src.EntityMinecart;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
|
||||||
import net.minecraft.src.IInventory;
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
import net.minecraft.src.Item;
|
|
||||||
import net.minecraft.src.EnumStatus;
|
|
||||||
import net.minecraft.src.ModLoader;
|
|
||||||
import net.minecraft.src.NBTTagCompound;
|
|
||||||
import net.minecraft.src.NetworkManager;
|
|
||||||
import net.minecraft.src.Packet;
|
|
||||||
import net.minecraft.src.Packet131MapData;
|
|
||||||
import net.minecraft.src.Packet1Login;
|
|
||||||
import net.minecraft.src.Packet250CustomPayload;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
import net.minecraft.src.mod_MinecraftForge;
|
|
||||||
import net.minecraft.src.forge.packets.PacketEntitySpawn;
|
|
||||||
import net.minecraft.src.forge.packets.PacketHandlerBase;
|
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
public class ForgeHooks
|
|
||||||
{
|
|
||||||
// Tool Path
|
|
||||||
// ------------------------------------------------------------
|
|
||||||
public static boolean canHarvestBlock(Block block, EntityPlayer player, int metadata)
|
|
||||||
{
|
|
||||||
if (block.blockMaterial.isHarvestable())
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
ItemStack stack = player.inventory.getCurrentItem();
|
|
||||||
if (stack == null)
|
|
||||||
{
|
|
||||||
return player.canHarvestBlock(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
List info = (List)toolClasses.get(stack.itemID);
|
|
||||||
if (info == null)
|
|
||||||
{
|
|
||||||
return player.canHarvestBlock(block);
|
|
||||||
}
|
|
||||||
Object[] tmp = info.toArray();
|
|
||||||
String toolClass = (String)tmp[0];
|
|
||||||
int harvestLevel = (Integer)tmp[1];
|
|
||||||
|
|
||||||
Integer blockHarvestLevel = (Integer)toolHarvestLevels.get(Arrays.asList(block.blockID, metadata, toolClass));
|
|
||||||
if (blockHarvestLevel == null)
|
|
||||||
{
|
|
||||||
return player.canHarvestBlock(block);
|
|
||||||
}
|
|
||||||
if (blockHarvestLevel > harvestLevel)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static float blockStrength(Block block, EntityPlayer player, int metadata)
|
|
||||||
{
|
|
||||||
float hardness = block.getHardness(metadata);
|
|
||||||
if (hardness < 0.0F)
|
|
||||||
{
|
|
||||||
return 0.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!canHarvestBlock(block, player, metadata))
|
|
||||||
{
|
|
||||||
return 1.0F / hardness / 100F;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return player.getCurrentPlayerStrVsBlock(block, metadata) / hardness / 30F;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isToolEffective(ItemStack stack, Block block, int metadata)
|
|
||||||
{
|
|
||||||
List toolClass = (List)toolClasses.get(stack.itemID);
|
|
||||||
if (toolClass == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return toolEffectiveness.contains(Arrays.asList(block.blockID, metadata, (String)toolClass.get(0)));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void initTools()
|
|
||||||
{
|
|
||||||
if (toolInit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
toolInit = true;
|
|
||||||
|
|
||||||
MinecraftForge.setToolClass(Item.pickaxeWood, "pickaxe", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.pickaxeStone, "pickaxe", 1);
|
|
||||||
MinecraftForge.setToolClass(Item.pickaxeSteel, "pickaxe", 2);
|
|
||||||
MinecraftForge.setToolClass(Item.pickaxeGold, "pickaxe", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.pickaxeDiamond, "pickaxe", 3);
|
|
||||||
|
|
||||||
MinecraftForge.setToolClass(Item.axeWood, "axe", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.axeStone, "axe", 1);
|
|
||||||
MinecraftForge.setToolClass(Item.axeSteel, "axe", 2);
|
|
||||||
MinecraftForge.setToolClass(Item.axeGold, "axe", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.axeDiamond, "axe", 3);
|
|
||||||
|
|
||||||
MinecraftForge.setToolClass(Item.shovelWood, "shovel", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.shovelStone, "shovel", 1);
|
|
||||||
MinecraftForge.setToolClass(Item.shovelSteel, "shovel", 2);
|
|
||||||
MinecraftForge.setToolClass(Item.shovelGold, "shovel", 0);
|
|
||||||
MinecraftForge.setToolClass(Item.shovelDiamond, "shovel", 3);
|
|
||||||
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.obsidian, "pickaxe", 3);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 2);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 2);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 2);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 2);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 1);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 1);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 1);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 1);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 2);
|
|
||||||
MinecraftForge.setBlockHarvestLevel(Block.oreRedstoneGlowing, "pickaxe", 2);
|
|
||||||
MinecraftForge.removeBlockEffectiveness(Block.oreRedstone, "pickaxe");
|
|
||||||
MinecraftForge.removeBlockEffectiveness(Block.obsidian, "pickaxe");
|
|
||||||
MinecraftForge.removeBlockEffectiveness(Block.oreRedstoneGlowing, "pickaxe");
|
|
||||||
|
|
||||||
Block[] pickeff =
|
|
||||||
{
|
|
||||||
Block.cobblestone, Block.stairDouble,
|
|
||||||
Block.stairSingle, Block.stone,
|
|
||||||
Block.sandStone, Block.cobblestoneMossy,
|
|
||||||
Block.oreCoal, Block.ice,
|
|
||||||
Block.netherrack, Block.oreLapis,
|
|
||||||
Block.blockLapis
|
|
||||||
};
|
|
||||||
for (Block block : pickeff)
|
|
||||||
{
|
|
||||||
MinecraftForge.setBlockHarvestLevel(block, "pickaxe", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Block[] spadeEff =
|
|
||||||
{
|
|
||||||
Block.grass, Block.dirt,
|
|
||||||
Block.sand, Block.gravel,
|
|
||||||
Block.snow, Block.blockSnow,
|
|
||||||
Block.blockClay, Block.tilledField,
|
|
||||||
Block.slowSand, Block.mycelium
|
|
||||||
};
|
|
||||||
for (Block block : spadeEff)
|
|
||||||
{
|
|
||||||
MinecraftForge.setBlockHarvestLevel(block, "shovel", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
Block[] axeEff =
|
|
||||||
{
|
|
||||||
Block.planks, Block.bookShelf,
|
|
||||||
Block.wood, Block.chest,
|
|
||||||
Block.stairDouble, Block.stairSingle,
|
|
||||||
Block.pumpkin, Block.pumpkinLantern
|
|
||||||
};
|
|
||||||
for (Block block : axeEff)
|
|
||||||
{
|
|
||||||
MinecraftForge.setBlockHarvestLevel(block, "axe", 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static HashMap<Class, EntityTrackerInfo> entityTrackerMap = new HashMap<Class, EntityTrackerInfo>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Builds the 'Spawn' packet using the Custom Payload packet on the 'Forge' channel.
|
|
||||||
* Supports entities that have custom spawn data, as well as the generic 'Owner' construct.
|
|
||||||
*
|
|
||||||
* @param entity The entity instance to spawn
|
|
||||||
* @return The spawn packet, or null if we arn't spawning it.
|
|
||||||
*/
|
|
||||||
public static Packet getEntitySpawnPacket(Entity entity)
|
|
||||||
{
|
|
||||||
EntityTrackerInfo info = MinecraftForge.getEntityTrackerInfo(entity, false);
|
|
||||||
if (info == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
PacketEntitySpawn pkt = new PacketEntitySpawn(entity, info.Mod, info.ID);
|
|
||||||
return pkt.getPacket();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Hashtable<Integer, NetworkMod> networkMods = new Hashtable<Integer, NetworkMod>();
|
|
||||||
public static Hashtable<BaseMod, IGuiHandler> guiHandlers = new Hashtable<BaseMod, IGuiHandler>();
|
|
||||||
|
|
||||||
static boolean toolInit = false;
|
|
||||||
static HashMap toolClasses = new HashMap();
|
|
||||||
static HashMap toolHarvestLevels = new HashMap();
|
|
||||||
static HashSet toolEffectiveness = new HashSet();
|
|
||||||
|
|
||||||
private static PacketHandlerBase forgePacketHandler = null;
|
|
||||||
public static void setPacketHandler(PacketHandlerBase handler)
|
|
||||||
{
|
|
||||||
if (forgePacketHandler != null)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Attempted to set Forge's Internal packet handler after it was already set");
|
|
||||||
}
|
|
||||||
forgePacketHandler = handler;
|
|
||||||
}
|
|
||||||
public static PacketHandlerBase getPacketHandler()
|
|
||||||
{
|
|
||||||
return forgePacketHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean onItemDataPacket(NetworkManager net, Packet131MapData pkt)
|
|
||||||
{
|
|
||||||
NetworkMod mod = MinecraftForge.getModByID(pkt.itemID);
|
|
||||||
if (mod == null)
|
|
||||||
{
|
|
||||||
ModLoader.getLogger().log(Level.WARNING, String.format("Received Unknown MapData packet %d:%d", pkt.itemID, pkt.uniqueID));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
mod.onPacketData(net, pkt.uniqueID, pkt.itemData);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,35 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
import net.minecraft.src.Chunk;
|
|
||||||
import net.minecraft.src.ChunkCoordIntPair;
|
|
||||||
import net.minecraft.src.Entity;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register an implementation of this interface to be used for chunk load handling.
|
|
||||||
*/
|
|
||||||
public interface IChunkLoadHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called from World.tickBlocksAndAmbiance
|
|
||||||
* Add loaded chunks to this set for them to receive block tick updates
|
|
||||||
* @param world The world containing the chunks
|
|
||||||
* @param chunkList The set of active chunks
|
|
||||||
*/
|
|
||||||
public void addActiveChunks(World world, Set<ChunkCoordIntPair> chunkList);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called from ChunkProvider.dropChunk
|
|
||||||
* Return false to prevent the unloading of this chunk
|
|
||||||
* @param chunk The chunk to be unloaded
|
|
||||||
*/
|
|
||||||
public boolean canUnloadChunk(Chunk chunk);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called from World.updateEntityWithOptionalForce.
|
|
||||||
* Return true to allow this entity to update.
|
|
||||||
* @param entity The entity to update
|
|
||||||
*/
|
|
||||||
public boolean canUpdateEntity(Entity entity);
|
|
||||||
}
|
|
|
@ -1,36 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.NetworkManager;
|
|
||||||
import net.minecraft.src.Packet1Login;
|
|
||||||
|
|
||||||
public interface IConnectionHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Raised when a Client successfully connects it's socket to the Server.
|
|
||||||
* @param network The new NetworkManager associated with this connection.
|
|
||||||
*/
|
|
||||||
public void onConnect(NetworkManager network);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Raised when you receive a Packet1Login.
|
|
||||||
* On the server, it is raised after the NetHandler is switched, and the
|
|
||||||
* initial user placement/info packets are sent.
|
|
||||||
*
|
|
||||||
* On the client, this is raised after the packet is parsed, and the user
|
|
||||||
* is sitting at the 'Downloading Terrain' screen.
|
|
||||||
*
|
|
||||||
* @param network The NetoworkManager associated with this connection.
|
|
||||||
* @param login The login packet
|
|
||||||
*/
|
|
||||||
public void onLogin(NetworkManager network, Packet1Login login);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Raised whenever the socket is closed, can be caused by various reasons.
|
|
||||||
*
|
|
||||||
* @param network The NetworkManager associated with this connection.
|
|
||||||
* @param message The translated message to be displayed for this disconnection.
|
|
||||||
* @param args Any additional arguments that the code may of provided.
|
|
||||||
* Sometimes this is further explanation, or a Throwable, in the case of errors.
|
|
||||||
*/
|
|
||||||
public void onDisconnect(NetworkManager network, String message, Object[] args);
|
|
||||||
}
|
|
|
@ -1,18 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.IInventory;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
|
|
||||||
public interface ICraftingHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called after an item is taken from crafting.
|
|
||||||
*/
|
|
||||||
public void onTakenFromCrafting(EntityPlayer player, ItemStack stack, IInventory craftMatrix);
|
|
||||||
}
|
|
|
@ -1,17 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
|
||||||
|
|
||||||
public interface IDestroyToolHandler
|
|
||||||
{
|
|
||||||
/** Called when the user's currently equipped item is destroyed.
|
|
||||||
*/
|
|
||||||
public void onDestroyCurrentItem(EntityPlayer player, ItemStack orig);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
|
|
||||||
public interface IFuelHandler
|
|
||||||
{
|
|
||||||
/** Called when a furnace gains fuel to get its burn time.
|
|
||||||
* @return fuel burn time in ticks or 0 to continue processing
|
|
||||||
*/
|
|
||||||
public int getItemBurnTime(ItemStack stack);
|
|
||||||
}
|
|
|
@ -1,20 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
import net.minecraft.src.EntityPlayer;
|
|
||||||
|
|
||||||
public interface IHoeHandler
|
|
||||||
{
|
|
||||||
/** Called when a hoe is used on a block. This is called on both sides
|
|
||||||
* in SMP.
|
|
||||||
* @return true to consume a use of the hoe and return.
|
|
||||||
*/
|
|
||||||
public boolean onUseHoe(ItemStack hoe, EntityPlayer player, World world, int X, int Y, int Z);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.NetworkManager;
|
|
||||||
|
|
||||||
public interface IPacketHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called when we receive a Packet250CustomPayload for a channel that this
|
|
||||||
* handler is registered to.
|
|
||||||
*
|
|
||||||
* @param network The NetworkManager for the current connection.
|
|
||||||
* @param channel The Channel the message came on.
|
|
||||||
* @param data The message payload.
|
|
||||||
*/
|
|
||||||
public void onPacketData(NetworkManager network, String channel, byte[] data);
|
|
||||||
}
|
|
|
@ -1,29 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.EntityLiving;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
|
|
||||||
@Deprecated //See IEntityLivingHandler
|
|
||||||
public interface ISpecialMobSpawnHandler
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Raised when a Entity is spawned into the world from natural means, meaning
|
|
||||||
* not by command, MobSpawner, cheat, etc.. Just naturally throughout the world.
|
|
||||||
*
|
|
||||||
* This allows the mod to create special functionality that runs on a mob natural
|
|
||||||
* spawn. The Vanilla minecraft mechanic of having 'Spider Jockies', the color of
|
|
||||||
* sheep's wool, and Ocelot's spawning with babies can be canceled by returning
|
|
||||||
* true from this function
|
|
||||||
*
|
|
||||||
* Returning true will indicate that you have performed your special spawning,
|
|
||||||
* and no more handling will be done.
|
|
||||||
*
|
|
||||||
* @param entity The newly spawned entity
|
|
||||||
* @param world The world the entity is in
|
|
||||||
* @param x The Entitie's X Position
|
|
||||||
* @param y The Entitie's Y Position
|
|
||||||
* @param z The Entitie's Z Position
|
|
||||||
* @return True to prevent any further special case handling from executing.
|
|
||||||
*/
|
|
||||||
public boolean onSpecialEntitySpawn(EntityLiving entity, World world, float x, float y, float z);
|
|
||||||
}
|
|
|
@ -1,26 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.Block;
|
|
||||||
import net.minecraft.src.Entity;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface is to be implemented by block classes. It will allow a block
|
|
||||||
* to control how it resists to explosion
|
|
||||||
*
|
|
||||||
* @see Block
|
|
||||||
*/
|
|
||||||
public interface ISpecialResistance
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the explosion resistance of the block located at position X, Y,
|
|
||||||
* Z, from an exploder explosing on srcX, srcY, srcZ.
|
|
||||||
*/
|
|
||||||
public float getSpecialExplosionResistance(World world, int X, int Y, int Z, double srcX, double srcY, double srcZ, Entity exploder);
|
|
||||||
}
|
|
|
@ -1,436 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Hashtable;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
import net.minecraft.src.NetworkManager;
|
|
||||||
|
|
||||||
public class MessageManager
|
|
||||||
{
|
|
||||||
private Hashtable<NetworkManager, ConnectionInstance> connections = new Hashtable<NetworkManager, ConnectionInstance>();
|
|
||||||
private static MessageManager instance;
|
|
||||||
|
|
||||||
public static MessageManager getInstance()
|
|
||||||
{
|
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new MessageManager();
|
|
||||||
}
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ConnectionInstance
|
|
||||||
{
|
|
||||||
private NetworkManager network;
|
|
||||||
private Hashtable<String, ArrayList<IPacketHandler>> channelToHandlers = new Hashtable<String, ArrayList<IPacketHandler>>();
|
|
||||||
private Hashtable<IPacketHandler, ArrayList<String>> handlerToChannels = new Hashtable<IPacketHandler, ArrayList<String>>();
|
|
||||||
private HashSet<String> activeChannels = new HashSet<String>();
|
|
||||||
|
|
||||||
public ConnectionInstance(NetworkManager mgr)
|
|
||||||
{
|
|
||||||
network = mgr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the associated NetworkManager
|
|
||||||
* @return The associated NetworkManager;
|
|
||||||
*/
|
|
||||||
public NetworkManager getNetwork()
|
|
||||||
{
|
|
||||||
return network;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes all channels and handlers from the registration.
|
|
||||||
*
|
|
||||||
* @return An array of channels that were in the registration
|
|
||||||
* If the connection is still active, you should send UNREGISTER messages for these.
|
|
||||||
*/
|
|
||||||
public String[] unregisterAll()
|
|
||||||
{
|
|
||||||
String[] ret = getRegisteredChannels();
|
|
||||||
channelToHandlers.clear();
|
|
||||||
handlerToChannels.clear();
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a channel to a specific handler.
|
|
||||||
*
|
|
||||||
* @param handler The handler to register
|
|
||||||
* @param channel The channel to register on
|
|
||||||
* @return True if the channel was not previously registered to any handlers.
|
|
||||||
* If True, the connection is still active, and this is not the OnLogin event,
|
|
||||||
* you should send a REGISTER command for this channel.
|
|
||||||
*/
|
|
||||||
public boolean registerChannel(IPacketHandler handler, String channel)
|
|
||||||
{
|
|
||||||
ArrayList<IPacketHandler> handlers = channelToHandlers.get(channel);
|
|
||||||
ArrayList<String> channels = handlerToChannels.get(handler);
|
|
||||||
boolean ret = false;
|
|
||||||
|
|
||||||
if (handlers == null)
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
handlers = new ArrayList<IPacketHandler>();
|
|
||||||
channelToHandlers.put(channel, handlers);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels == null)
|
|
||||||
{
|
|
||||||
channels = new ArrayList<String>();
|
|
||||||
handlerToChannels.put(handler, channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!channels.contains(channel))
|
|
||||||
{
|
|
||||||
channels.add(channel);
|
|
||||||
}
|
|
||||||
if (!handlers.contains(handler))
|
|
||||||
{
|
|
||||||
handlers.add(handler);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a channel from the specified handler.
|
|
||||||
*
|
|
||||||
* @param handler The handler to remove the channel from.
|
|
||||||
* @param channel The channel to remove from the handler registration.
|
|
||||||
* @return True if this was the last handler registered with the specified channel.
|
|
||||||
* If this is the case, and the network connection is still alive, you should send
|
|
||||||
* a UNREGISTER message for this channel.
|
|
||||||
*/
|
|
||||||
public boolean unregisterChannel(IPacketHandler handler, String channel)
|
|
||||||
{
|
|
||||||
boolean ret = false;
|
|
||||||
ArrayList<IPacketHandler> handlers = channelToHandlers.get(channel);
|
|
||||||
ArrayList<String> channels = handlerToChannels.get(handler);
|
|
||||||
|
|
||||||
if (handlers != null && handlers.contains(handler))
|
|
||||||
{
|
|
||||||
handlers.remove(handler);
|
|
||||||
if (handlers.size() == 0)
|
|
||||||
{
|
|
||||||
ret = true;
|
|
||||||
channelToHandlers.remove(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channels != null && channels.contains(channel))
|
|
||||||
{
|
|
||||||
channels.remove(channel);
|
|
||||||
if (handlers.size() == 0)
|
|
||||||
{
|
|
||||||
handlerToChannels.remove(handler);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a handler from all of it's associated channels.
|
|
||||||
*
|
|
||||||
* @param handler The handler to unregister
|
|
||||||
* @return A list of channels that now have no handlers.
|
|
||||||
* If the connection is still active, you should send a UNREGISTER
|
|
||||||
* message for each channel in this list.
|
|
||||||
*/
|
|
||||||
public String[] unregisterHandler(IPacketHandler handler)
|
|
||||||
{
|
|
||||||
ArrayList<String> tmp = handlerToChannels.get(handler);
|
|
||||||
if (tmp != null)
|
|
||||||
{
|
|
||||||
String[] channels = tmp.toArray(new String[0]);
|
|
||||||
tmp = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (String channel : channels)
|
|
||||||
{
|
|
||||||
if (unregisterChannel(handler, channel))
|
|
||||||
{
|
|
||||||
tmp.add(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return tmp.toArray(new String[0]);
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of all unique channels that currently have valid handlers.
|
|
||||||
*
|
|
||||||
* @return The channel list
|
|
||||||
*/
|
|
||||||
public String[] getRegisteredChannels()
|
|
||||||
{
|
|
||||||
int x = 0;
|
|
||||||
String[] ret = new String[channelToHandlers.size()];
|
|
||||||
|
|
||||||
for (String value : channelToHandlers.keySet())
|
|
||||||
{
|
|
||||||
ret[x++] = value;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of all handlers currently registered to the specified channel.
|
|
||||||
*
|
|
||||||
* @param channel The channel to get the handlers for.
|
|
||||||
* @return A array containing all handlers for this channel.
|
|
||||||
*/
|
|
||||||
public IPacketHandler[] getChannelHandlers(String channel)
|
|
||||||
{
|
|
||||||
ArrayList<IPacketHandler> handlers = channelToHandlers.get(channel);
|
|
||||||
if (handlers != null)
|
|
||||||
{
|
|
||||||
return handlers.toArray(new IPacketHandler[0]);
|
|
||||||
}
|
|
||||||
return new IPacketHandler[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a channel to the active set.
|
|
||||||
* This is a set that the other end of the connection has registered a channel.
|
|
||||||
*
|
|
||||||
* @param channel The channel name
|
|
||||||
*/
|
|
||||||
public void addActiveChannel(String channel)
|
|
||||||
{
|
|
||||||
if (!activeChannels.contains(channel))
|
|
||||||
{
|
|
||||||
activeChannels.add(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a channel from the active set.
|
|
||||||
* This should be done with the other end of the connection unregisters a channel.
|
|
||||||
*
|
|
||||||
* @param channel
|
|
||||||
*/
|
|
||||||
public void removeActiveChannel(String channel)
|
|
||||||
{
|
|
||||||
if (activeChannels.contains(channel))
|
|
||||||
{
|
|
||||||
activeChannels.remove(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the specified channel is registered as active by the other end of the connection.
|
|
||||||
*
|
|
||||||
* @param channel The channel to check
|
|
||||||
* @return True if it's active, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean isActiveChannel(String channel)
|
|
||||||
{
|
|
||||||
return activeChannels.contains(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves, or creates a ConnectionInstance associated with the specific NetworkManager.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @return A ConnectionInstance channel manager for this NetworkManager
|
|
||||||
*/
|
|
||||||
public ConnectionInstance getConnection(NetworkManager manager)
|
|
||||||
{
|
|
||||||
ConnectionInstance ret = connections.get(manager);
|
|
||||||
if (ret == null)
|
|
||||||
{
|
|
||||||
ret = new ConnectionInstance(manager);
|
|
||||||
connections.put(manager, ret);
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the associated channel manager, and unregisters all channels/handlers from it.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @return An array of all channels that were still registered to this NetowrkManager.
|
|
||||||
* If the connection is still active, you should send a UNREGISTER request for
|
|
||||||
* all of these channels.
|
|
||||||
*/
|
|
||||||
public String[] removeConnection(NetworkManager manager)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
String[] ret = con.unregisterAll();
|
|
||||||
connections.remove(manager);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a channel to a specific handler.
|
|
||||||
*
|
|
||||||
* @param manager The manager to register to
|
|
||||||
* @param handler The handler to register
|
|
||||||
* @param channel The channel to register on
|
|
||||||
* @return True if the channel was not previously registered to any handlers.
|
|
||||||
* If True, the connection is still active, and this is not the OnLogin event,
|
|
||||||
* you should send a REGISTER command for this channel.
|
|
||||||
*/
|
|
||||||
public boolean registerChannel(NetworkManager manager, IPacketHandler handler, String channel)
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.registerChannel(handler, channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a channel from the specified handler.
|
|
||||||
*
|
|
||||||
* @param manager The manager to register to
|
|
||||||
* @param handler The handler to remove the channel from.
|
|
||||||
* @param channel The channel to remove from the handler registration.
|
|
||||||
* @return True if this was the last handler registered with the specified channel.
|
|
||||||
* If this is the case, and the network connection is still alive, you should send
|
|
||||||
* a UNREGISTER message for this channel.
|
|
||||||
*/
|
|
||||||
public boolean unregisterChannel(NetworkManager manager, IPacketHandler handler, String channel)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.unregisterChannel(handler, channel);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unregisters a handler from all of it's associated channels.
|
|
||||||
*
|
|
||||||
* @param manager The manager to register to
|
|
||||||
* @param handler The handler to unregister
|
|
||||||
* @return A list of channels that now have no handlers.
|
|
||||||
* If the connection is still active, you should send a UNREGISTER
|
|
||||||
* message for each channel in this list.
|
|
||||||
*/
|
|
||||||
public String[] unregisterHandler(NetworkManager manager, IPacketHandler handler)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.unregisterHandler(handler);
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of all unique channels that currently have valid handlers.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @return The channel list
|
|
||||||
*/
|
|
||||||
public String[] getRegisteredChannels(NetworkManager manager)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.getRegisteredChannels();
|
|
||||||
}
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a list of all handlers currently registered to the specified channel.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @param channel The channel to get the handlers for.
|
|
||||||
* @return A array containing all handlers for this channel.
|
|
||||||
*/
|
|
||||||
public IPacketHandler[] getChannelHandlers(NetworkManager manager, String channel)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.getChannelHandlers(channel);
|
|
||||||
}
|
|
||||||
return new IPacketHandler[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a channel to the active set.
|
|
||||||
* This is a set that the other end of the connection has registered a channel.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @param channel The channel name
|
|
||||||
*/
|
|
||||||
public void addActiveChannel(NetworkManager manager, String channel)
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
con.addActiveChannel(channel);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a channel from the active set.
|
|
||||||
* This should be done with the other end of the connection unregisters a channel.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @param channel
|
|
||||||
*/
|
|
||||||
public void removeActiveChannel(NetworkManager manager, String channel)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
con.removeActiveChannel(channel);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if the specified channel is registered as active by the other end of the connection.
|
|
||||||
*
|
|
||||||
* @param manager The NetworkManager to look for.
|
|
||||||
* @param channel The channel to check
|
|
||||||
* @return True if it's active, false otherwise.
|
|
||||||
*/
|
|
||||||
public boolean isActiveChannel(NetworkManager manager, String channel)
|
|
||||||
{
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
return con.isActiveChannel(channel);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispatchIncomingMessage(NetworkManager manager, String channel, byte[] data)
|
|
||||||
{
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
data = new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (channel.equals("Forge"))
|
|
||||||
{
|
|
||||||
if (ForgeHooks.getPacketHandler() != null)
|
|
||||||
{
|
|
||||||
byte[] tmpData = new byte[data.length];
|
|
||||||
System.arraycopy(data, 0, tmpData, 0, data.length);
|
|
||||||
ForgeHooks.getPacketHandler().onPacketData(manager, channel, tmpData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (connections.containsKey(manager))
|
|
||||||
{
|
|
||||||
ConnectionInstance con = getConnection(manager);
|
|
||||||
IPacketHandler[] handlers = con.getChannelHandlers(channel);
|
|
||||||
byte[] tmpData = new byte[data.length];
|
|
||||||
for (IPacketHandler handler : handlers)
|
|
||||||
{
|
|
||||||
System.arraycopy(data, 0, tmpData, 0, data.length);
|
|
||||||
handler.onPacketData(manager, channel, tmpData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,835 +0,0 @@
|
||||||
/**
|
|
||||||
* This software is provided under the terms of the Minecraft Forge Public
|
|
||||||
* License v1.0.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import net.minecraft.src.Achievement;
|
|
||||||
import net.minecraft.src.BaseMod;
|
|
||||||
import net.minecraft.src.Block;
|
|
||||||
import net.minecraft.src.Entity;
|
|
||||||
import net.minecraft.src.EntityLiving;
|
|
||||||
import net.minecraft.src.EntityMinecart;
|
|
||||||
import net.minecraft.src.Item;
|
|
||||||
import net.minecraft.src.ItemStack;
|
|
||||||
import net.minecraft.src.Material;
|
|
||||||
import net.minecraft.src.ModLoader;
|
|
||||||
import net.minecraft.src.NetworkManager;
|
|
||||||
import net.minecraft.src.Packet;
|
|
||||||
import net.minecraft.src.Packet131MapData;
|
|
||||||
import net.minecraft.src.Packet132TileEntityData;
|
|
||||||
import net.minecraft.src.World;
|
|
||||||
import net.minecraft.src.forge.oredict.OreDictionary;
|
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.Map.Entry;
|
|
||||||
|
|
||||||
public class MinecraftForge
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Kill minecraft with an error message.
|
|
||||||
*/
|
|
||||||
public static void killMinecraft(String mod, String message)
|
|
||||||
{
|
|
||||||
throw new RuntimeException(mod + ": " + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Version checking. Ensures that a sufficiently recent version of Forge
|
|
||||||
* is installed. Will result in a fatal error if the major versions
|
|
||||||
* mismatch or if the version is too old. Will print a warning message if
|
|
||||||
* the minor versions don't match.
|
|
||||||
*/
|
|
||||||
public static void versionDetect(String mod, int major, int minor, int revision)
|
|
||||||
{
|
|
||||||
if (major != ForgeHooks.majorVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Major Version Mismatch, expecting " + major + ".x.x");
|
|
||||||
}
|
|
||||||
else if (minor != ForgeHooks.minorVersion)
|
|
||||||
{
|
|
||||||
if (minor > ForgeHooks.minorVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Too Old, need at least " + major + "." + minor + "." + revision);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
System.out.println(mod + ": MinecraftForge minor version mismatch, expecting " + major + "." + minor + ".x, may lead to unexpected behavior");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (revision > ForgeHooks.revisionVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Too Old, need at least " + major + "." + minor + "." + revision);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Strict version checking. Ensures that a sufficiently recent version of
|
|
||||||
* Forge is installed. Will result in a fatal error if the major or minor
|
|
||||||
* versions mismatch or if the version is too old. Use this function for
|
|
||||||
* mods that use recent, new, or unstable APIs to prevent
|
|
||||||
* incompatibilities.
|
|
||||||
*/
|
|
||||||
public static void versionDetectStrict(String mod, int major, int minor, int revision)
|
|
||||||
{
|
|
||||||
if (major != ForgeHooks.majorVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Major Version Mismatch, expecting " + major + ".x.x");
|
|
||||||
}
|
|
||||||
else if (minor != ForgeHooks.minorVersion)
|
|
||||||
{
|
|
||||||
if (minor > ForgeHooks.minorVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Too Old, need at least " + major + "." + minor + "." + revision);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge minor version mismatch, expecting " + major + "." + minor + ".x");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (revision > ForgeHooks.revisionVersion)
|
|
||||||
{
|
|
||||||
killMinecraft(mod, "MinecraftForge Too Old, need at least " + major + "." + minor + "." + revision);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Forge Branding info used by FML to display on the client's main screen.
|
|
||||||
* @return 'Minecraft Forge vx.x.x.x'
|
|
||||||
*/
|
|
||||||
public static String getVersionString()
|
|
||||||
{
|
|
||||||
return String.format("Minecraft Forge %d.%d.%d.%d", ForgeHooks.majorVersion, ForgeHooks.minorVersion, ForgeHooks.revisionVersion, ForgeHooks.buildVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int dungeonLootAttempts = 8;
|
|
||||||
private static ArrayList<ObjectPair<Float, String>> dungeonMobs = new ArrayList<ObjectPair<Float, String>>();
|
|
||||||
private static ArrayList<ObjectPair<Float, DungeonLoot>> dungeonLoot = new ArrayList<ObjectPair<Float, DungeonLoot>>();
|
|
||||||
/**
|
|
||||||
* Set the number of item stacks that will be attempted to be added to each Dungeon chest.
|
|
||||||
* Note: Due to random number generation, you will not always get this amount per chest.
|
|
||||||
* @param number The maximum number of item stacks to add to a chest.
|
|
||||||
*/
|
|
||||||
public static void setDungeonLootTries(int number)
|
|
||||||
{
|
|
||||||
dungeonLootAttempts = number;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The max number of item stacks found in each dungeon chest.
|
|
||||||
*/
|
|
||||||
public static int getDungeonLootTries()
|
|
||||||
{
|
|
||||||
return dungeonLootAttempts;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a mob to the possible list of creatures the spawner will create.
|
|
||||||
* If the mob is already in the spawn list, the rarity will be added to the existing one,
|
|
||||||
* causing the mob to be more common.
|
|
||||||
*
|
|
||||||
* @param name The name of the monster, use the same name used when registering the entity.
|
|
||||||
* @param rarity The rarity of selecting this mob over others. Must be greater then 0.
|
|
||||||
* Vanilla Minecraft has the following mobs:
|
|
||||||
* Spider 1
|
|
||||||
* Skeleton 1
|
|
||||||
* Zombie 2
|
|
||||||
* Meaning, Zombies are twice as common as spiders or skeletons.
|
|
||||||
* @return The new rarity of the monster,
|
|
||||||
*/
|
|
||||||
public static float addDungeonMob(String name, float rarity)
|
|
||||||
{
|
|
||||||
if (rarity <= 0)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException("Rarity must be greater then zero");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (ObjectPair<Float, String> mob : dungeonMobs)
|
|
||||||
{
|
|
||||||
if (name.equals(mob.getValue2()))
|
|
||||||
{
|
|
||||||
mob.setValue1(mob.getValue1() + rarity);
|
|
||||||
return mob.getValue1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dungeonMobs.add(new ObjectPair<Float, String>(rarity, name));
|
|
||||||
return rarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will completely remove a Mob from the dungeon spawn list.
|
|
||||||
*
|
|
||||||
* @param name The name of the mob to remove
|
|
||||||
* @return The rarity of the removed mob, prior to being removed.
|
|
||||||
*/
|
|
||||||
public static float removeDungeonMob(String name)
|
|
||||||
{
|
|
||||||
for (ObjectPair<Float, String> mob : dungeonMobs)
|
|
||||||
{
|
|
||||||
if (name.equals(name))
|
|
||||||
{
|
|
||||||
dungeonMobs.remove(mob);
|
|
||||||
return mob.getValue1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a random mob name from the list.
|
|
||||||
* @param rand World generation random number generator
|
|
||||||
* @return The mob name
|
|
||||||
*/
|
|
||||||
public static String getRandomDungeonMob(Random rand)
|
|
||||||
{
|
|
||||||
float maxRarity = 0f;
|
|
||||||
for (ObjectPair<Float, String> mob : dungeonMobs)
|
|
||||||
{
|
|
||||||
maxRarity += mob.getValue1();
|
|
||||||
}
|
|
||||||
|
|
||||||
float targetRarity = rand.nextFloat() * maxRarity;
|
|
||||||
for (ObjectPair<Float, String> mob : dungeonMobs)
|
|
||||||
{
|
|
||||||
if (targetRarity < mob.getValue1())
|
|
||||||
{
|
|
||||||
return mob.getValue2();
|
|
||||||
}
|
|
||||||
targetRarity -= mob.getValue1();
|
|
||||||
}
|
|
||||||
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a item stack to the dungeon loot list with a stack size
|
|
||||||
* of 1.
|
|
||||||
*
|
|
||||||
* @param item The ItemStack to be added to the loot list
|
|
||||||
* @param rarity The relative chance that this item will spawn, Vanilla has
|
|
||||||
* most of its items set to 1. Like the saddle, bread, silk, wheat, etc..
|
|
||||||
* Rarer items are set to lower values, EXA: Golden Apple 0.01
|
|
||||||
*/
|
|
||||||
public static void addDungeonLoot(ItemStack item, float rarity)
|
|
||||||
{
|
|
||||||
addDungeonLoot(item, rarity, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a item stack, with a range of sizes, to the dungeon loot list.
|
|
||||||
* If a stack matching the same item, and size range, is already in the list
|
|
||||||
* the rarities will be added together making the item more common.
|
|
||||||
*
|
|
||||||
* @param item The ItemStack to be added to the loot list
|
|
||||||
* @param rarity The relative chance that this item will spawn, Vanilla has
|
|
||||||
* most of its items set to 1. Like the saddle, bread, silk, wheat, etc..
|
|
||||||
* Rarer items are set to lower values, EXA: Golden Apple 0.01
|
|
||||||
* @param minCount When this item does generate, the minimum number that is in the stack
|
|
||||||
* @param maxCount When this item does generate, the maximum number that can bein the stack
|
|
||||||
* @return The new rarity of the loot.
|
|
||||||
*/
|
|
||||||
public static float addDungeonLoot(ItemStack item, float rarity, int minCount, int maxCount)
|
|
||||||
{
|
|
||||||
for (ObjectPair<Float, DungeonLoot> loot : dungeonLoot)
|
|
||||||
{
|
|
||||||
if (loot.getValue2().equals(item, minCount, maxCount))
|
|
||||||
{
|
|
||||||
loot.setValue1(loot.getValue1() + rarity);
|
|
||||||
return loot.getValue1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dungeonLoot.add(new ObjectPair<Float, DungeonLoot>(rarity, new DungeonLoot(item, minCount, maxCount)));
|
|
||||||
return rarity;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Removes a item stack from the dungeon loot list, this will remove all items
|
|
||||||
* as long as the item stack matches, it will not care about matching the stack
|
|
||||||
* size ranges perfectly.
|
|
||||||
*
|
|
||||||
* @param item The item stack to remove
|
|
||||||
* @return The total rarity of all items removed
|
|
||||||
*/
|
|
||||||
public static float removeDungeonLoot(ItemStack item)
|
|
||||||
{
|
|
||||||
return removeDungeonLoot(item, -1, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a item stack from the dungeon loot list. If 'minCount' parameter
|
|
||||||
* is greater then 0, it will only remove loot items that have the same exact
|
|
||||||
* stack size range as passed in by parameters.
|
|
||||||
*
|
|
||||||
* @param item The item stack to remove
|
|
||||||
* @param minCount The minimum count for the match check, if less then 0,
|
|
||||||
* the size check is skipped
|
|
||||||
* @param maxCount The max count used in match check when 'minCount' is >= 0
|
|
||||||
* @return The total rarity of all items removed
|
|
||||||
*/
|
|
||||||
public static float removeDungeonLoot(ItemStack item, int minCount, int maxCount)
|
|
||||||
{
|
|
||||||
float rarity = 0;
|
|
||||||
ArrayList<ObjectPair<Float, DungeonLoot>> lootTmp = (ArrayList<ObjectPair<Float, DungeonLoot>>)dungeonLoot.clone();
|
|
||||||
if (minCount < 0)
|
|
||||||
{
|
|
||||||
for (ObjectPair<Float, DungeonLoot> loot : lootTmp)
|
|
||||||
{
|
|
||||||
if (loot.getValue2().equals(item))
|
|
||||||
{
|
|
||||||
dungeonLoot.remove(loot);
|
|
||||||
rarity += loot.getValue1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (ObjectPair<Float, DungeonLoot> loot : lootTmp)
|
|
||||||
{
|
|
||||||
if (loot.getValue2().equals(item, minCount, maxCount))
|
|
||||||
{
|
|
||||||
dungeonLoot.remove(loot);
|
|
||||||
rarity += loot.getValue1();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rarity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets a random item stack to place in a dungeon chest during world generation
|
|
||||||
* @param rand World generation random number generator
|
|
||||||
* @return The item stack
|
|
||||||
*/
|
|
||||||
public static ItemStack getRandomDungeonLoot(Random rand)
|
|
||||||
{
|
|
||||||
float maxRarity = 0f;
|
|
||||||
for (ObjectPair<Float, DungeonLoot> loot : dungeonLoot)
|
|
||||||
{
|
|
||||||
maxRarity += loot.getValue1();
|
|
||||||
}
|
|
||||||
|
|
||||||
float targetRarity = rand.nextFloat() * maxRarity;
|
|
||||||
for (ObjectPair<Float, DungeonLoot> loot : dungeonLoot)
|
|
||||||
{
|
|
||||||
if (targetRarity < loot.getValue1())
|
|
||||||
{
|
|
||||||
return loot.getValue2().generateStack(rand);
|
|
||||||
}
|
|
||||||
targetRarity -= loot.getValue1();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Achievement Pages ----------------------------------------
|
|
||||||
private static LinkedList<AchievementPage> achievementPages = new LinkedList<AchievementPage>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an achievement page.
|
|
||||||
* @param page The page.
|
|
||||||
*/
|
|
||||||
public static void registerAchievementPage(AchievementPage page)
|
|
||||||
{
|
|
||||||
if (getAchievementPage(page.getName()) != null)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Duplicate achievement page name \"" + page.getName() + "\"!");
|
|
||||||
}
|
|
||||||
achievementPages.add(page);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return an achievement page by its index on the list.
|
|
||||||
* @param index The page's index.
|
|
||||||
* @return the achievement page corresponding to the index or null if invalid index
|
|
||||||
*/
|
|
||||||
public static AchievementPage getAchievementPage(int index)
|
|
||||||
{
|
|
||||||
return achievementPages.get(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return an achievement page by its name.
|
|
||||||
* @param name The page's name.
|
|
||||||
* @return the achievement page with the given name or null if no such page
|
|
||||||
*/
|
|
||||||
public static AchievementPage getAchievementPage(String name)
|
|
||||||
{
|
|
||||||
for (AchievementPage page : achievementPages)
|
|
||||||
{
|
|
||||||
if (page.getName().equals(name))
|
|
||||||
{
|
|
||||||
return page;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return the list of achievement pages.
|
|
||||||
* @return the list's size
|
|
||||||
*/
|
|
||||||
public static Set<AchievementPage> getAchievementPages()
|
|
||||||
{
|
|
||||||
return new HashSet<AchievementPage>(achievementPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return whether an achievement is in any page or not.
|
|
||||||
* @param achievement The achievement.
|
|
||||||
*/
|
|
||||||
public static boolean isAchievementInPages(Achievement achievement)
|
|
||||||
{
|
|
||||||
for (AchievementPage page : achievementPages)
|
|
||||||
{
|
|
||||||
if (page.getAchievements().contains(achievement))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Minecart Dictionary --------------------------------------
|
|
||||||
private static Map<MinecartKey, ItemStack> itemForMinecart = new HashMap<MinecartKey, ItemStack>();
|
|
||||||
private static Map<ItemStack, MinecartKey> minecartForItem = new HashMap<ItemStack, MinecartKey>();
|
|
||||||
/**
|
|
||||||
* Registers a custom minecart and its corresponding item.
|
|
||||||
* This should be the item used to place the minecart by the user,
|
|
||||||
* not the item dropped by the cart.
|
|
||||||
* @param cart The minecart.
|
|
||||||
* @param item The item used to place the cart.
|
|
||||||
*/
|
|
||||||
public static void registerMinecart(Class<? extends EntityMinecart> cart, ItemStack item)
|
|
||||||
{
|
|
||||||
registerMinecart(cart, 0, item);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a minecart and its corresponding item.
|
|
||||||
* This should be the item used to place the minecart by the user,
|
|
||||||
* not the item dropped by the cart.
|
|
||||||
* @param minecart The minecart.
|
|
||||||
* @param type The minecart type, used to differentiate carts that have the same class.
|
|
||||||
* @param item The item used to place the cart.
|
|
||||||
*/
|
|
||||||
public static void registerMinecart(Class<? extends EntityMinecart> minecart, int type, ItemStack item)
|
|
||||||
{
|
|
||||||
MinecartKey key = new MinecartKey(minecart, type);
|
|
||||||
itemForMinecart.put(key, item);
|
|
||||||
minecartForItem.put(item, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes a previously registered Minecart. Useful for replacing the vanilla minecarts.
|
|
||||||
* @param minecart
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
public static void removeMinecart(Class<? extends EntityMinecart> minecart, int type)
|
|
||||||
{
|
|
||||||
MinecartKey key = new MinecartKey(minecart, type);
|
|
||||||
ItemStack item = itemForMinecart.remove(key);
|
|
||||||
if (item != null)
|
|
||||||
{
|
|
||||||
minecartForItem.remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns an ItemStack that represents this cart.
|
|
||||||
* The player should be able to use this item to place the minecart.
|
|
||||||
* This is the item that was registered with the cart via the registerMinecart function,
|
|
||||||
* but is not necessary the item the cart drops when destroyed.
|
|
||||||
* @param minecart The cart class
|
|
||||||
* @return An ItemStack that can be used to place the cart.
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemForCart(Class<? extends EntityMinecart> minecart)
|
|
||||||
{
|
|
||||||
return getItemForCart(minecart, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns an ItemStack that represents this cart.
|
|
||||||
* The player should be able to use this item to place the minecart.
|
|
||||||
* This is the item that was registered with the cart via the registerMinecart function,
|
|
||||||
* but is not necessary the item the cart drops when destroyed.
|
|
||||||
* @param minecart The cart class
|
|
||||||
* @param type The minecartType value
|
|
||||||
* @return An ItemStack that can be used to place the cart.
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemForCart(Class<? extends EntityMinecart> minecart, int type)
|
|
||||||
{
|
|
||||||
ItemStack item = itemForMinecart.get(new MinecartKey(minecart, type));
|
|
||||||
if (item == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return item.copy();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This function returns an ItemStack that represents this cart.
|
|
||||||
* The player should be able to use this item to place the minecart.
|
|
||||||
* This is the item that was registered with the cart via the registerMinecart function,
|
|
||||||
* but is not necessary the item the cart drops when destroyed.
|
|
||||||
* @param cart The cart entity
|
|
||||||
* @return An ItemStack that can be used to place the cart.
|
|
||||||
*/
|
|
||||||
public static ItemStack getItemForCart(EntityMinecart cart)
|
|
||||||
{
|
|
||||||
return getItemForCart(cart.getClass(), cart.getMinecartType());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The function will return the cart class for a given item.
|
|
||||||
* If the item was not registered via the registerMinecart function it will return null.
|
|
||||||
* @param item The item to test.
|
|
||||||
* @return Cart if mapping exists, null if not.
|
|
||||||
*/
|
|
||||||
public static Class<? extends EntityMinecart> getCartClassForItem(ItemStack item)
|
|
||||||
{
|
|
||||||
MinecartKey key = null;
|
|
||||||
for (Map.Entry<ItemStack, MinecartKey> entry : minecartForItem.entrySet())
|
|
||||||
{
|
|
||||||
if (entry.getKey().isItemEqual(item))
|
|
||||||
{
|
|
||||||
key = entry.getValue();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (key != null)
|
|
||||||
{
|
|
||||||
return key.minecart;
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The function will return the cart type for a given item.
|
|
||||||
* Will return -1 if the mapping doesn't exist.
|
|
||||||
* If the item was not registered via the registerMinecart function it will return null.
|
|
||||||
* @param item The item to test.
|
|
||||||
* @return the cart minecartType value.
|
|
||||||
*/
|
|
||||||
public static int getCartTypeForItem(ItemStack item)
|
|
||||||
{
|
|
||||||
MinecartKey key = null;
|
|
||||||
for (Map.Entry<ItemStack, MinecartKey> entry : minecartForItem.entrySet())
|
|
||||||
{
|
|
||||||
if (entry.getKey().isItemEqual(item))
|
|
||||||
{
|
|
||||||
key = entry.getValue();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (key != null)
|
|
||||||
{
|
|
||||||
return key.type;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Will return a set of all registered minecart items.
|
|
||||||
* @return a copy of the set of all minecart items
|
|
||||||
*/
|
|
||||||
public static Set<ItemStack> getAllCartItems()
|
|
||||||
{
|
|
||||||
Set<ItemStack> ret = new HashSet<ItemStack>();
|
|
||||||
for (ItemStack item : minecartForItem.keySet())
|
|
||||||
{
|
|
||||||
ret.add(item.copy());
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a Entity class tracking information. Used for sendingEntity
|
|
||||||
* information over the network.
|
|
||||||
*
|
|
||||||
* @param entityClass The class for the Entity
|
|
||||||
* @param mod The BaseMod that provides this Entity.
|
|
||||||
* @param ID The ID for the Entity. Needs to be unique combination of Mod and ID.
|
|
||||||
* @param range How close a player has to be to be informed this Entity exists.
|
|
||||||
* @param updateFrequency How many ticks between checking and sending information updates for this Entity.
|
|
||||||
* @param sendVelocityInfo If velocity information should be included in the update information.
|
|
||||||
* @return True, if successfully registered. False if the class is already registered.
|
|
||||||
*/
|
|
||||||
public static boolean registerEntity(Class entityClass, NetworkMod mod, int ID, int range, int updateFrequency, boolean sendVelocityInfo)
|
|
||||||
{
|
|
||||||
if (ForgeHooks.entityTrackerMap.containsKey(entityClass))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ForgeHooks.entityTrackerMap.put(entityClass, new EntityTrackerInfo(mod, ID, range, updateFrequency, sendVelocityInfo));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the tracker info for input Entity.
|
|
||||||
*
|
|
||||||
* @param entity The Entity to find tracking info for.
|
|
||||||
* @param checkSupers If we should check the super-classes for a match.
|
|
||||||
* @return The information, or Null if not found.
|
|
||||||
*/
|
|
||||||
public static EntityTrackerInfo getEntityTrackerInfo(Entity entity, boolean checkSupers)
|
|
||||||
{
|
|
||||||
for (Map.Entry<Class, EntityTrackerInfo> entry : ForgeHooks.entityTrackerMap.entrySet())
|
|
||||||
{
|
|
||||||
if (entry.getKey().isInstance(entity))
|
|
||||||
{
|
|
||||||
if (!checkSupers || entry.getKey() == entity.getClass())
|
|
||||||
{
|
|
||||||
return entry.getValue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves the Class for a registered Entity based on ModID and Entity Type.
|
|
||||||
*
|
|
||||||
* @param modID The ID of the mod (mod.toString().hashCode())
|
|
||||||
* @param type The ID for the Entity
|
|
||||||
* @return The entity Class, or null if not found.
|
|
||||||
*/
|
|
||||||
public static Class getEntityClass(int modID, int type)
|
|
||||||
{
|
|
||||||
for (Map.Entry<Class, EntityTrackerInfo> entry : ForgeHooks.entityTrackerMap.entrySet())
|
|
||||||
{
|
|
||||||
EntityTrackerInfo info = entry.getValue();
|
|
||||||
if (type == info.ID && modID == getModID(info.Mod))
|
|
||||||
{
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieves a mod instance based on it's ID. (toString().hashCode())
|
|
||||||
*
|
|
||||||
* @param id The mod ID
|
|
||||||
* @return The mod, or null if not found
|
|
||||||
*/
|
|
||||||
public static NetworkMod getModByID(int id)
|
|
||||||
{
|
|
||||||
return ForgeHooks.networkMods.get(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a unique index number for the specific mod.
|
|
||||||
*
|
|
||||||
* @param mod The mod to find
|
|
||||||
* @return The index number, -1 if no index found
|
|
||||||
*/
|
|
||||||
public static int getModID(NetworkMod mod)
|
|
||||||
{
|
|
||||||
for (Entry<Integer, NetworkMod> entry : ForgeHooks.networkMods.entrySet())
|
|
||||||
{
|
|
||||||
if (entry.getValue() == mod)
|
|
||||||
{
|
|
||||||
return entry.getKey();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a list of mods that are designed to be used over the network.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static NetworkMod[] getNetworkMods()
|
|
||||||
{
|
|
||||||
ArrayList<NetworkMod> ret = new ArrayList<NetworkMod>();
|
|
||||||
for (BaseMod mod : (List<BaseMod>)ModLoader.getLoadedMods())
|
|
||||||
{
|
|
||||||
if (mod instanceof NetworkMod)
|
|
||||||
{
|
|
||||||
ret.add((NetworkMod)mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret.toArray(new NetworkMod[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the GuiHandler associated with a mod.
|
|
||||||
*
|
|
||||||
* @param mod The mod
|
|
||||||
* @param handler The Gui Handler
|
|
||||||
*/
|
|
||||||
public static void setGuiHandler(BaseMod mod, IGuiHandler handler)
|
|
||||||
{
|
|
||||||
ForgeHooks.guiHandlers.put(mod, handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the GuiHandler associated with a mod
|
|
||||||
*
|
|
||||||
* @param mod The mod
|
|
||||||
* @return The handler, or null if none associated.
|
|
||||||
*/
|
|
||||||
public static IGuiHandler getGuiHandler(BaseMod mod)
|
|
||||||
{
|
|
||||||
return ForgeHooks.guiHandlers.get(mod);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a new Arrow Nock event handler
|
|
||||||
* @param handler The Handler to be registered
|
|
||||||
*/
|
|
||||||
public static void registerArrowNockHandler(IArrowNockHandler handler)
|
|
||||||
{
|
|
||||||
ForgeHooks.arrowNockHandlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers a new Arrow Loose event handler
|
|
||||||
* @param handler The Handler to be registered
|
|
||||||
*/
|
|
||||||
public static void registerArrowLooseHandler(IArrowLooseHandler handler)
|
|
||||||
{
|
|
||||||
ForgeHooks.arrowLooseHandlers.add(handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a packet on the specified NetworkManager
|
|
||||||
*
|
|
||||||
* @param net The manager to send the packet on
|
|
||||||
* @param packet The packet to be sent
|
|
||||||
*/
|
|
||||||
public static void sendPacket(NetworkManager net, Packet packet)
|
|
||||||
{
|
|
||||||
ForgeHooks.getPacketHandler().sendPacket(net, packet);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a 'small' payload packet to the specified manager.
|
|
||||||
* It uses the Packet131MapData packet for it's communication
|
|
||||||
* so things are limited.
|
|
||||||
*
|
|
||||||
* @param net The manager to send the packet to
|
|
||||||
* @param mod The mod associated with this packet
|
|
||||||
* @param id The ID number used to identify this packet
|
|
||||||
* @param data The data to be sent, must be no larger then 255 bytes.
|
|
||||||
*/
|
|
||||||
public static void sendPacket(NetworkManager net, NetworkMod mod, short id, byte[] data)
|
|
||||||
{
|
|
||||||
if (data == null)
|
|
||||||
{
|
|
||||||
data = new byte[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data.length > 255)
|
|
||||||
{
|
|
||||||
throw new IllegalArgumentException(String.format("Data argument was to long, must not be longer then 255 bytes was %d", data.length));
|
|
||||||
}
|
|
||||||
|
|
||||||
Packet131MapData pkt = new Packet131MapData();
|
|
||||||
pkt.itemID = (short)getModID(mod);
|
|
||||||
pkt.uniqueID = id;
|
|
||||||
pkt.itemData = data;
|
|
||||||
sendPacket(net, pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Helper function for wrapping and sending a Packet132TileEntityData packet,
|
|
||||||
* useful so we don't have to edit the packet class itself to add the constructor on the client side.
|
|
||||||
*
|
|
||||||
* @param net The manager to send the packet to
|
|
||||||
* @param x Position X
|
|
||||||
* @param y Position Y
|
|
||||||
* @param z Position Z
|
|
||||||
* @param action Action ID
|
|
||||||
* @param par1 Custom Parameter 1
|
|
||||||
* @param par2 Custom Parameter 2
|
|
||||||
* @param par3 Custom Parameter 3
|
|
||||||
*/
|
|
||||||
public static void sendTileEntityPacket(NetworkManager net, int x, short y, int z, byte action, int par1, int par2, int par3)
|
|
||||||
{
|
|
||||||
Packet132TileEntityData pkt = new Packet132TileEntityData();
|
|
||||||
pkt.xPosition = x;
|
|
||||||
pkt.yPosition = y;
|
|
||||||
pkt.zPosition = z;
|
|
||||||
pkt.actionType = action;
|
|
||||||
pkt.customParam1 = par1;
|
|
||||||
pkt.customParam2 = par2;
|
|
||||||
pkt.customParam3 = par3;
|
|
||||||
sendPacket(net, pkt);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int isClient = -1;
|
|
||||||
public static boolean isClient()
|
|
||||||
{
|
|
||||||
if (isClient == -1)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Class.forName("net.minecraft.client.Minecraft", false, MinecraftForge.class.getClassLoader());
|
|
||||||
isClient = 1;
|
|
||||||
}
|
|
||||||
catch (ClassNotFoundException e)
|
|
||||||
{
|
|
||||||
isClient = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return isClient == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Method invoked by FML before any other mods are loaded.
|
|
||||||
*/
|
|
||||||
public static void initialize()
|
|
||||||
{
|
|
||||||
//Cause the classes to initialize if they already haven't
|
|
||||||
Block.stone.getTextureFile();
|
|
||||||
Item.appleGold.getTextureFile();
|
|
||||||
|
|
||||||
Block filler = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
filler = Block.class.getConstructor(int.class, Material.class).newInstance(256, Material.air);
|
|
||||||
}catch (Exception e){}
|
|
||||||
|
|
||||||
if (filler == null)
|
|
||||||
{
|
|
||||||
throw new RuntimeException("Could not create Forge filler block");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int x = 256; x < 4096; x++)
|
|
||||||
{
|
|
||||||
if (Item.itemsList[x - 256] != null)
|
|
||||||
{
|
|
||||||
Block.blocksList[x] = filler;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
addDungeonMob("Skeleton", 1.0f);
|
|
||||||
addDungeonMob("Zombie", 2.0f);
|
|
||||||
addDungeonMob("Spider", 1.0f);
|
|
||||||
|
|
||||||
addDungeonLoot(new ItemStack(Item.saddle), 1.00f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.ingotIron), 1.00f, 1, 4);
|
|
||||||
addDungeonLoot(new ItemStack(Item.bread), 1.00f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.wheat), 1.00f, 1, 4);
|
|
||||||
addDungeonLoot(new ItemStack(Item.gunpowder), 1.00f, 1, 4);
|
|
||||||
addDungeonLoot(new ItemStack(Item.silk), 1.00f, 1, 4);
|
|
||||||
addDungeonLoot(new ItemStack(Item.bucketEmpty), 1.00f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.appleGold), 0.01f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.redstone), 0.50f, 1, 4);
|
|
||||||
addDungeonLoot(new ItemStack(Item.record13), 0.05f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.recordCat), 0.05f );
|
|
||||||
addDungeonLoot(new ItemStack(Item.dyePowder, 1, 3), 1.00f );
|
|
||||||
|
|
||||||
registerMinecart(EntityMinecart.class, 0, new ItemStack(Item.minecartEmpty));
|
|
||||||
registerMinecart(EntityMinecart.class, 1, new ItemStack(Item.minecartCrate));
|
|
||||||
registerMinecart(EntityMinecart.class, 2, new ItemStack(Item.minecartPowered));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,96 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import net.minecraft.src.*;
|
|
||||||
import net.minecraft.src.forge.packets.ForgePacket;
|
|
||||||
import net.minecraft.src.forge.packets.PacketModList;
|
|
||||||
|
|
||||||
public class ForgeHooksServer
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Called when a Entity is being added to a EntityTracker.
|
|
||||||
* If we have valid info, register the entity.
|
|
||||||
*
|
|
||||||
* @param tracker The EntityTracker instance
|
|
||||||
* @param entity The Entity to add
|
|
||||||
* @return True if we registered the Entity
|
|
||||||
*/
|
|
||||||
public static boolean OnTrackEntity(EntityTracker tracker, Entity entity)
|
|
||||||
{
|
|
||||||
EntityTrackerInfo info = MinecraftForge.getEntityTrackerInfo(entity, true);
|
|
||||||
if (info != null)
|
|
||||||
{
|
|
||||||
tracker.trackEntity(entity, info.Range, info.UpdateFrequency, info.SendVelocityInfo);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void sendModListRequest(NetworkManager net)
|
|
||||||
{
|
|
||||||
NetworkMod[] list = MinecraftForge.getNetworkMods();
|
|
||||||
PacketModList pkt = new PacketModList(true);
|
|
||||||
|
|
||||||
for (NetworkMod mod : list)
|
|
||||||
{
|
|
||||||
pkt.ModIDs.put(MinecraftForge.getModID(mod), mod.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
((NetServerHandler)net.getNetHandler()).sendPacket(pkt.getPacket());
|
|
||||||
if (((PacketHandlerServer)ForgeHooks.getPacketHandler()).DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handleLoginPacket(Packet1Login pktLogin, NetServerHandler net, NetworkManager manager)
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
if (pktLogin.serverMode == ForgePacket.FORGE_ID)
|
|
||||||
{
|
|
||||||
ForgeHooks.onLogin(manager, pktLogin);
|
|
||||||
|
|
||||||
String[] channels = MessageManager.getInstance().getRegisteredChannels(manager);
|
|
||||||
StringBuilder tmp = new StringBuilder();
|
|
||||||
tmp.append("Forge");
|
|
||||||
for(String channel : channels)
|
|
||||||
{
|
|
||||||
tmp.append("\0");
|
|
||||||
tmp.append(channel);
|
|
||||||
}
|
|
||||||
Packet250CustomPayload pkt = new Packet250CustomPayload();
|
|
||||||
pkt.channel = "REGISTER";
|
|
||||||
try {
|
|
||||||
pkt.data = tmp.toString().getBytes("UTF8");
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
pkt.length = pkt.data.length;
|
|
||||||
net.sendPacket(pkt);
|
|
||||||
ForgeHooksServer.sendModListRequest(manager);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
net.kickPlayer(mod_MinecraftForge.NO_FORGE_KICK_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private static boolean hasInit = false;
|
|
||||||
public static void init()
|
|
||||||
{
|
|
||||||
if (hasInit)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
hasInit = true;
|
|
||||||
ForgeHooks.setPacketHandler(new PacketHandlerServer());
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,176 +0,0 @@
|
||||||
package net.minecraft.src.forge;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
|
|
||||||
import cpw.mods.fml.server.FMLServerHandler;
|
|
||||||
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
|
||||||
import net.minecraft.src.*;
|
|
||||||
import net.minecraft.src.forge.packets.*;
|
|
||||||
|
|
||||||
public class PacketHandlerServer extends PacketHandlerBase
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void onPacketData(NetworkManager network, String channel, byte[] bytes)
|
|
||||||
{
|
|
||||||
NetServerHandler net = (NetServerHandler)network.getNetHandler();
|
|
||||||
DataInputStream data = new DataInputStream(new ByteArrayInputStream(bytes));
|
|
||||||
ForgePacket pkt = null;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
int packetID = data.read();
|
|
||||||
switch (packetID)
|
|
||||||
{
|
|
||||||
case ForgePacket.MODLIST:
|
|
||||||
pkt = new PacketModList(true);
|
|
||||||
pkt.readData(data);
|
|
||||||
onModListResponse(net, (PacketModList)pkt);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
ModLoader.getLogger().log(Level.SEVERE, "Exception in PacketHandlerServer.onPacketData", e);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void onModListResponse(NetServerHandler net, PacketModList pkt) throws IOException
|
|
||||||
{
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("C->S: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
if (pkt.Length < 0)
|
|
||||||
{
|
|
||||||
net.kickPlayer("Invalid mod list response, Size: " + pkt.Length);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!pkt.has4096)
|
|
||||||
{
|
|
||||||
net.kickPlayer("Must have Forge build #136+ (4096 fix) to connect to this server");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (pkt.Mods.length == 0)
|
|
||||||
{
|
|
||||||
ModLoader.getLogger().log(Level.INFO, net.getUsername() + " joined with no mods");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ModLoader.getLogger().log(Level.INFO, net.getUsername() + " joined with: " + Arrays.toString(pkt.Mods).replaceAll("mod_", ""));
|
|
||||||
}
|
|
||||||
|
|
||||||
//TODO: Write a 'banned mods' system and do the checks here
|
|
||||||
|
|
||||||
NetworkMod[] serverMods = MinecraftForge.getNetworkMods();
|
|
||||||
ArrayList<NetworkMod> missing = new ArrayList<NetworkMod>();
|
|
||||||
for (NetworkMod mod : serverMods)
|
|
||||||
{
|
|
||||||
if (!mod.clientSideRequired())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
boolean found = false;
|
|
||||||
for (String modName : pkt.Mods)
|
|
||||||
{
|
|
||||||
if (modName.equals(mod.toString()))
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
missing.add(mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missing.size() > 0)
|
|
||||||
{
|
|
||||||
doMissingMods(net, missing);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
finishLogin(net);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the user a list of mods they are missing and then disconnects them
|
|
||||||
* @param net The network handler
|
|
||||||
*/
|
|
||||||
private void doMissingMods(NetServerHandler net, ArrayList<NetworkMod> list)
|
|
||||||
{
|
|
||||||
PacketMissingMods pkt = new PacketMissingMods(true);
|
|
||||||
pkt.Mods = new String[list.size()];
|
|
||||||
int x = 0;
|
|
||||||
for (NetworkMod mod : list)
|
|
||||||
{
|
|
||||||
pkt.Mods[x++] = mod.toString();
|
|
||||||
}
|
|
||||||
if (DEBUG)
|
|
||||||
{
|
|
||||||
System.out.println("S->C: " + pkt.toString(true));
|
|
||||||
}
|
|
||||||
net.sendPacket(pkt.getPacket());
|
|
||||||
disconnectUser(net);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disconnects the player just like kicking them, just without the kick message.
|
|
||||||
* @param net The network handler
|
|
||||||
*/
|
|
||||||
private void disconnectUser(NetServerHandler net)
|
|
||||||
{
|
|
||||||
MinecraftServer mc = ModLoader.getMinecraftServerInstance();
|
|
||||||
net.getPlayerEntity().func_30002_A();
|
|
||||||
net.netManager.serverShutdown();
|
|
||||||
mc.configManager.sendPacketToAllPlayers(new Packet3Chat("\247e" + net.getUsername() + " left the game."));
|
|
||||||
mc.configManager.playerLoggedOut(net.getPlayerEntity());
|
|
||||||
net.connectionClosed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void finishLogin(NetServerHandler net)
|
|
||||||
{
|
|
||||||
EntityPlayerMP player = net.getPlayerEntity();
|
|
||||||
WorldServer world = net.mcServer.getWorldManager(player.dimension);
|
|
||||||
ChunkCoordinates spawn = world.getSpawnPoint();
|
|
||||||
|
|
||||||
net.sendPacket(new Packet1Login("", player.entityId, world.getWorldInfo().getTerrainType(),
|
|
||||||
player.itemInWorldManager.getGameType(), world.worldProvider.worldType,
|
|
||||||
(byte)world.difficultySetting, (byte)world.getHeight(),
|
|
||||||
(byte)net.mcServer.configManager.getMaxPlayers()));
|
|
||||||
|
|
||||||
net.sendPacket(new Packet6SpawnPosition(spawn.posX, spawn.posY, spawn.posZ));
|
|
||||||
net.sendPacket(new Packet202PlayerAbilities(player.capabilities));
|
|
||||||
net.mcServer.configManager.updateTimeAndWeather(player, world);
|
|
||||||
net.mcServer.configManager.sendPacketToAllPlayers(new Packet3Chat("\u00a7e" + player.username + " joined the game."));
|
|
||||||
net.mcServer.configManager.playerLoggedIn(player);
|
|
||||||
|
|
||||||
net.teleportTo(player.posX, player.posY, player.posZ, player.rotationYaw, player.rotationPitch);
|
|
||||||
net.sendPacket(new Packet4UpdateTime(world.getWorldTime()));
|
|
||||||
|
|
||||||
for (Object efx : player.getActivePotionEffects())
|
|
||||||
{
|
|
||||||
net.sendPacket(new Packet41EntityEffect(player.entityId, (PotionEffect)efx));
|
|
||||||
}
|
|
||||||
|
|
||||||
player.func_20057_k();
|
|
||||||
FMLServerHandler.instance().announceLogin(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendPacket(NetworkManager network, Packet packet)
|
|
||||||
{
|
|
||||||
NetServerHandler net = (NetServerHandler)network.getNetHandler();
|
|
||||||
net.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,54 +0,0 @@
|
||||||
package net.minecraft.src;
|
|
||||||
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import net.minecraft.src.forge.ForgeHooks;
|
|
||||||
import net.minecraft.src.forge.MinecraftForge;
|
|
||||||
import net.minecraft.src.forge.NetworkMod;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is just here to make the Forge version show up nicely in the ModLoader logs/Crash Screen
|
|
||||||
*/
|
|
||||||
public class mod_MinecraftForge extends NetworkMod
|
|
||||||
{
|
|
||||||
@MLProp(info = "Set to true to disable darkrooms, it adds a extra check when planting the grass and plants to check that they won't instantly die.")
|
|
||||||
public static boolean DISABLE_DARK_ROOMS = false;
|
|
||||||
|
|
||||||
@MLProp(info = "Set to false to reproduce a vinella bug that prevents mobs from spawning on inverted half-slabs and inverted stairs.")
|
|
||||||
public static boolean SPAWNER_ALLOW_ON_INVERTED = true;
|
|
||||||
|
|
||||||
@MLProp(info = "The kick message used when a client tries to connect but does not have Minecraft Forge installed.")
|
|
||||||
public static String NO_FORGE_KICK_MESSAGE = "This server requires you to have Minecraft Forge installed. http://MinecraftForge.net/";
|
|
||||||
|
|
||||||
@MLProp(info = "Set to true to randomly shuffle the potential chunks for spawning, this is useful in FTB challange maps where you don't want one side hogging the spawns")
|
|
||||||
public static boolean SPAWNER_MAKE_MORE_RANDOM = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getVersion()
|
|
||||||
{
|
|
||||||
return String.format("%d.%d.%d.%d",
|
|
||||||
ForgeHooks.majorVersion, ForgeHooks.minorVersion,
|
|
||||||
ForgeHooks.revisionVersion, ForgeHooks.buildVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void load()
|
|
||||||
{
|
|
||||||
MinecraftForge.getDungeonLootTries(); //Random thing to make things Initialize
|
|
||||||
int x = 0;
|
|
||||||
for (BaseMod mod : ModLoader.getLoadedMods())
|
|
||||||
{
|
|
||||||
if (mod instanceof NetworkMod)
|
|
||||||
{
|
|
||||||
if (x == Item.map.shiftedIndex)
|
|
||||||
{
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
ForgeHooks.networkMods.put(x++, (NetworkMod)mod);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//Add 131 & 132 to C->S list
|
|
||||||
((Set)ModLoader.getPrivateValue(Packet.class, null, 3)).add(131);
|
|
||||||
((Set)ModLoader.getPrivateValue(Packet.class, null, 3)).add(132);
|
|
||||||
}
|
|
||||||
}
|
|
28
jenkins.bat
28
jenkins.bat
|
@ -1,28 +0,0 @@
|
||||||
@echo off
|
|
||||||
if "%1"=="" (
|
|
||||||
echo You must enter a build number to promote to the latest
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
echo Jenkins build script started for build #%1
|
|
||||||
rmdir /S /Q ..\conf
|
|
||||||
xcopy /Y /E /I conf\* ..\conf
|
|
||||||
|
|
||||||
..\runtime\bin\python\python_mcp setup.py -skipdecompile
|
|
||||||
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
|
|
||||||
|
|
||||||
..\runtime\bin\python\python_mcp release.py %1
|
|
||||||
if %ERRORLEVEL% NEQ 0 exit /b %ERRORLEVEL%
|
|
||||||
|
|
||||||
cd forge-*%1
|
|
||||||
if %ERRORLEVEL% NEQ 0 (
|
|
||||||
echo Release failed to produce artifacts %1
|
|
||||||
exit /b 1
|
|
||||||
)
|
|
||||||
|
|
||||||
for /f "delims=\" %%a in ("%cd%") do SET VERSION=%%~nxa
|
|
||||||
SET VERSION=%VERSION:~6%
|
|
||||||
echo Forge Version: %VERSION%
|
|
||||||
|
|
||||||
..\..\MediafireUploader.exe Forge-%VERSION% minecraftforge-client-%VERSION%.zip minecraftforge-server-%VERSION%.zip minecraftforge-src-%VERSION%.zip
|
|
||||||
|
|
Loading…
Reference in a new issue