Some work on 1.7, waiting for Abrar to fix a few things.

This commit is contained in:
Lex Manos committed 2013-12-09 21:59:12 -08:00
1 parent d4e7a5c68e
commit 521b8a16c4
18 files changed
+245 -487

No files matched your search

@@ -2,6 +2,7 @@ package net.minecraftforge.common;
import java.util.*;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
@@ -9,6 +10,12 @@ import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.world.WorldServer;
import net.minecraft.world.gen.feature.WorldGenDungeons;
import net.minecraft.world.gen.structure.*;
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.DesertPyramid;
import net.minecraft.world.gen.structure.ComponentScatteredFeaturePieces.JunglePyramid;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.ChestCorridor;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.Library;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.RoomCrossing;
import net.minecraft.world.gen.structure.StructureVillagePieces.House2;
import net.minecraftforge.oredict.OreDictionary;
public class ChestGenHooks
@@ -41,18 +48,18 @@ public class ChestGenHooks
hasInit = true;
addInfo(MINESHAFT_CORRIDOR, StructureMineshaftPieces.mineshaftChestContents, 3, 7);
addInfo(PYRAMID_DESERT_CHEST, ComponentScatteredFeatureDesertPyramid.itemsToGenerateInTemple, 2, 7);
addInfo(PYRAMID_JUNGLE_CHEST, ComponentScatteredFeatureJunglePyramid.junglePyramidsChestContents, 2, 7);
addInfo(PYRAMID_JUNGLE_DISPENSER, ComponentScatteredFeatureJunglePyramid.junglePyramidsDispenserContents, 2, 2);
addInfo(STRONGHOLD_CORRIDOR, ComponentStrongholdChestCorridor.strongholdChestContents, 2, 4);
addInfo(STRONGHOLD_LIBRARY, ComponentStrongholdLibrary.strongholdLibraryChestContents, 1, 5);
addInfo(STRONGHOLD_CROSSING, ComponentStrongholdRoomCrossing.strongholdRoomCrossingChestContents, 1, 5);
addInfo(VILLAGE_BLACKSMITH, ComponentVillageHouse2.villageBlacksmithChestContents, 3, 9);
addInfo(BONUS_CHEST, WorldServer.bonusChestContent, 10, 10);
addInfo(DUNGEON_CHEST, WorldGenDungeons.field_111189_a, 8, 8);
addInfo(MINESHAFT_CORRIDOR, StructureMineshaftPieces.mineshaftChestContents, 3, 7);
addInfo(PYRAMID_DESERT_CHEST, DesertPyramid.itemsToGenerateInTemple, 2, 7);
addInfo(PYRAMID_JUNGLE_CHEST, JunglePyramid.junglePyramidsChestContents, 2, 7);
addInfo(PYRAMID_JUNGLE_DISPENSER, JunglePyramid.junglePyramidsDispenserContents, 2, 2);
addInfo(STRONGHOLD_CORRIDOR, ChestCorridor.strongholdChestContents, 2, 4);
addInfo(STRONGHOLD_LIBRARY, Library.strongholdLibraryChestContents, 1, 5);
addInfo(STRONGHOLD_CROSSING, RoomCrossing.strongholdRoomCrossingChestContents, 1, 5);
addInfo(VILLAGE_BLACKSMITH, House2.villageBlacksmithChestContents, 3, 9);
addInfo(BONUS_CHEST, WorldServer.bonusChestContent, 10, 10);
addInfo(DUNGEON_CHEST, WorldGenDungeons.field_111189_a, 8, 8);
ItemStack book = new ItemStack(Item.enchantedBook, 1, 0);
ItemStack book = new ItemStack(Items.enchanted_book, 1, 0);
WeightedRandomChestContent tmp = new WeightedRandomChestContent(book, 1, 1, 1);
getInfo(MINESHAFT_CORRIDOR ).addItem(tmp);
getInfo(PYRAMID_DESERT_CHEST).addItem(tmp);
@@ -177,7 +184,7 @@ public class ChestGenHooks
while(itr.hasNext())
{
WeightedRandomChestContent cont = itr.next();
if (item.isItemEqual(cont.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.itemID == cont.theItemId.itemID))
if (item.isItemEqual(cont.theItemId) || (item.getItemDamage() == OreDictionary.WILDCARD_VALUE && item.getItem() == cont.theItemId.getItem()))
{
itr.remove();
}
@@ -46,13 +46,7 @@ import cpw.mods.fml.relauncher.FMLInjectionData;
*/
public class Configuration
{
private static boolean[] configMarkers = new boolean[Item.itemsList.length];
private static final int ITEM_SHIFT = 256;
private static final int MAX_BLOCKS = 4096;
public static final String CATEGORY_GENERAL = "general";
public static final String CATEGORY_BLOCK = "block";
public static final String CATEGORY_ITEM = "item";
public static final String ALLOWED_CHARS = "._-";
public static final String DEFAULT_ENCODING = "UTF-8";
public static final String CATEGORY_SPLITTER = ".";
@@ -75,7 +69,6 @@ public class Configuration
static
{
Arrays.fill(configMarkers, false);
NEW_LINE = System.getProperty("line.separator");
}
@@ -107,127 +100,6 @@ public class Configuration
this.caseSensitiveCustomCategories = caseSensitiveCustomCategories;
}
/**
* Gets or create a block id property. If the block id property key is
* already in the configuration, then it will be used. Otherwise,
* defaultId will be used, except if already taken, in which case this
* will try to determine a free default id.
*/
public Property getBlock(String key, int defaultID) { return getBlock(CATEGORY_BLOCK, key, defaultID, null); }
public Property getBlock(String key, int defaultID, String comment) { return getBlock(CATEGORY_BLOCK, key, defaultID, comment); }
public Property getBlock(String category, String key, int defaultID) { return getBlockInternal(category, key, defaultID, null, 256, Block.blocksList.length); }
public Property getBlock(String category, String key, int defaultID, String comment) { return getBlockInternal(category, key, defaultID, comment, 256, Block.blocksList.length); }
/**
* Special version of getBlock to be used when you want to garentee the ID you get is below 256
* This should ONLY be used by mods who do low level terrain generation, or ones that add new
* biomes.
* EXA: ExtraBiomesXL
*
* Specifically, if your block is used BEFORE the Chunk is created, and placed in the terrain byte array directly.
* If you add a new biome and you set the top/filler block, they need to be <256, nothing else.
*
* If you're adding a new ore, DON'T call this function.
*
* Normal mods such as '50 new ores' do not need to be below 256 so should use the normal getBlock
*/
public Property getTerrainBlock(String category, String key, int defaultID, String comment)
{
return getBlockInternal(category, key, defaultID, comment, 0, 256);
}
private Property getBlockInternal(String category, String key, int defaultID, String comment, int lower, int upper)
{
Property prop = get(category, key, -1, comment);
if (prop.getInt() != -1)
{
configMarkers[prop.getInt()] = true;
return prop;
}
else
{
if (defaultID < lower)
{
FMLLog.warning(
"Mod attempted to get a block ID with a default in the Terrain Generation section, " +
"mod authors should make sure there defaults are above 256 unless explicitly needed " +
"for terrain generation. Most ores do not need to be below 256.");
FMLLog.warning("Config \"%s\" Category: \"%s\" Key: \"%s\" Default: %d", fileName, category, key, defaultID);
defaultID = upper - 1;
}
if (Block.blocksList[defaultID] == null && !configMarkers[defaultID])
{
prop.set(defaultID);
configMarkers[defaultID] = true;
return prop;
}
else
{
for (int j = upper - 1; j > 0; j--)
{
if (Block.blocksList[j] == null && !configMarkers[j])
{
prop.set(j);
configMarkers[j] = true;
return prop;
}
}
throw new RuntimeException("No more block ids available for " + key);
}
}
}
public Property getItem(String key, int defaultID) { return getItem(CATEGORY_ITEM, key, defaultID, null); }
public Property getItem(String key, int defaultID, String comment) { return getItem(CATEGORY_ITEM, key, defaultID, comment); }
public Property getItem(String category, String key, int defaultID) { return getItem(category, key, defaultID, null); }
public Property getItem(String category, String key, int defaultID, String comment)
{
Property prop = get(category, key, -1, comment);
int defaultShift = defaultID + ITEM_SHIFT;
if (prop.getInt() != -1)
{
configMarkers[prop.getInt() + ITEM_SHIFT] = true;
return prop;
}
else
{
if (defaultID < MAX_BLOCKS - ITEM_SHIFT)
{
FMLLog.warning(
"Mod attempted to get a item ID with a default value in the block ID section, " +
"mod authors should make sure there defaults are above %d unless explicitly needed " +
"so that all block ids are free to store blocks.", MAX_BLOCKS - ITEM_SHIFT);
FMLLog.warning("Config \"%s\" Category: \"%s\" Key: \"%s\" Default: %d", fileName, category, key, defaultID);
}
if (Item.itemsList[defaultShift] == null && !configMarkers[defaultShift] && defaultShift >= Block.blocksList.length)
{
prop.set(defaultID);
configMarkers[defaultShift] = true;
return prop;
}
else
{
for (int x = Item.itemsList.length - 1; x >= ITEM_SHIFT; x--)
{
if (Item.itemsList[x] == null && !configMarkers[x])
{
prop.set(x - ITEM_SHIFT);
configMarkers[x] = true;
return prop;
}
}
throw new RuntimeException("No more item ids available for " + key);
}
}
}
public Property get(String category, String key, int defaultValue)
{
return get(category, key, defaultValue, null);
@@ -10,7 +10,6 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandom;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraft.util.WeightedRandomItem;
import static net.minecraftforge.common.ChestGenHooks.DUNGEON_CHEST;
@@ -86,7 +85,7 @@ public class DungeonHooks
}
public static class DungeonMob extends WeightedRandomItem
public static class DungeonMob extends WeightedRandom.Item
{
public String type;
public DungeonMob(int weight, String type)
@@ -5,21 +5,20 @@ import java.util.*;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.FMLLog;
import net.minecraft.block.EnumMobType;
import net.minecraft.block.BlockPressurePlate.Sensitivity;
import net.minecraft.block.material.Material;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.entity.Entity.EnumEntitySize;
import net.minecraft.entity.EnumCreatureAttribute;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.EnumEntitySize;
import net.minecraft.entity.player.EnumStatus;
import net.minecraft.entity.item.EntityPainting.EnumArt;
import net.minecraft.entity.player.EntityPlayer.EnumStatus;
import net.minecraft.item.EnumAction;
import net.minecraft.item.EnumArmorMaterial;
import net.minecraft.item.EnumToolMaterial;
import net.minecraft.util.EnumArt;
import net.minecraft.util.EnumMovingObjectType;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.util.MovingObjectPosition.MovingObjectType;
import net.minecraft.world.EnumSkyBlock;
import net.minecraft.world.gen.structure.EnumDoor;
import net.minecraft.world.gen.structure.StructureStrongholdPieces.Stronghold.Door;
import net.minecraftforge.classloading.FMLForgePlugin;
public class EnumHelper
@@ -35,27 +34,27 @@ public class EnumHelper
private static Class[][] commonTypes =
{
{EnumAction.class},
{EnumArmorMaterial.class, int.class, int[].class, int.class},
{ArmorMaterial.class, int.class, int[].class, int.class},
{EnumArt.class, String.class, int.class, int.class, int.class, int.class},
{EnumCreatureAttribute.class},
{EnumCreatureType.class, Class.class, int.class, Material.class, boolean.class},
{EnumDoor.class},
{Door.class},
{EnumEnchantmentType.class},
{EnumEntitySize.class},
{EnumMobType.class},
{EnumMovingObjectType.class},
{Sensitivity.class},
{MovingObjectType.class},
{EnumSkyBlock.class, int.class},
{EnumStatus.class},
{EnumToolMaterial.class, int.class, int.class, float.class, float.class, int.class}
{ToolMaterial.class, int.class, int.class, float.class, float.class, int.class}
};
public static EnumAction addAction(String name)
{
return addEnum(EnumAction.class, name);
}
public static EnumArmorMaterial addArmorMaterial(String name, int durability, int[] reductionAmounts, int enchantability)
public static ArmorMaterial addArmorMaterial(String name, int durability, int[] reductionAmounts, int enchantability)
{
return addEnum(EnumArmorMaterial.class, name, durability, reductionAmounts, enchantability);
return addEnum(ArmorMaterial.class, name, durability, reductionAmounts, enchantability);
}
public static EnumArt addArt(String name, String tile, int sizeX, int sizeY, int offsetX, int offsetY)
{
@@ -69,9 +68,9 @@ public class EnumHelper
{
return addEnum(EnumCreatureType.class, name, typeClass, maxNumber, material, peaceful);
}
public static EnumDoor addDoor(String name)
public static Door addDoor(String name)
{
return addEnum(EnumDoor.class, name);
return addEnum(Door.class, name);
}
public static EnumEnchantmentType addEnchantmentType(String name)
{
@@ -81,18 +80,13 @@ public class EnumHelper
{
return addEnum(EnumEntitySize.class, name);
}
public static EnumMobType addMobType(String name)
public static Sensitivity addSensitivity(String name)
{
return addEnum(EnumMobType.class, name);
return addEnum(Sensitivity.class, name);
}
public static EnumMovingObjectType addMovingObjectType(String name)
public static MovingObjectType addMovingObjectType(String name)
{
if (!isSetup)
{
setup();
}
return addEnum(EnumMovingObjectType.class, name);
return addEnum(MovingObjectType.class, name);
}
public static EnumSkyBlock addSkyBlock(String name, int lightValue)
{
@@ -102,9 +96,9 @@ public class EnumHelper
{
return addEnum(EnumStatus.class, name);
}
public static EnumToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability)
public static ToolMaterial addToolMaterial(String name, int harvestLevel, int maxUses, float efficiency, float damage, int enchantability)
{
return addEnum(EnumToolMaterial.class, name, harvestLevel, maxUses, efficiency, damage, enchantability);
return addEnum(ToolMaterial.class, name, harvestLevel, maxUses, efficiency, damage, enchantability);
}
private static void setup()
@@ -185,6 +179,7 @@ public class EnumHelper
public static <T extends Enum<? >> T addEnum(Class<T> enumType, String enumName, Object... paramValues)
{
setup();
return addEnum(commonTypes, enumType, enumName, paramValues);
}
@@ -1,48 +1,41 @@
package net.minecraftforge.common;
import com.mojang.authlib.GameProfile;
import cpw.mods.fml.common.FMLCommonHandler;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemInWorldManager;
import net.minecraft.network.packet.Packet204ClientInfo;
import net.minecraft.network.play.client.C15PacketClientSettings;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.stats.StatBase;
import net.minecraft.util.ChatMessageComponent;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
//Preliminary, simple Fake Player class
public class FakePlayer extends EntityPlayerMP
{
public FakePlayer(World world, String name)
public FakePlayer(WorldServer world, GameProfile name)
{
super(FMLCommonHandler.instance().getMinecraftServerInstance(), world, name, new ItemInWorldManager(world));
}
public void sendChatToPlayer(String s){}
public boolean canCommandSenderUseCommand(int i, String s){ return false; }
public ChunkCoordinates getPlayerCoordinates()
@Override public boolean canCommandSenderUseCommand(int i, String s){ return false; }
@Override public ChunkCoordinates getPlayerCoordinates()
{
return new ChunkCoordinates(0,0,0);
}
@Override
public void sendChatToPlayer(ChatMessageComponent chatmessagecomponent){}
@Override
public void addStat(StatBase par1StatBase, int par2){}
@Override
public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
@Override
public boolean isEntityInvulnerable(){ return true; }
@Override
public boolean canAttackPlayer(EntityPlayer player){ return false; }
@Override
public void onDeath(DamageSource source){ return; }
@Override
public void onUpdate(){ return; }
@Override
public void travelToDimension(int dim){ return; }
@Override
public void updateClientInfo(Packet204ClientInfo pkt){ return; }
@Override public void func_146105_b(IChatComponent chatmessagecomponent){}
@Override public void addStat(StatBase par1StatBase, int par2){}
@Override public void openGui(Object mod, int modGuiId, World world, int x, int y, int z){}
@Override public boolean isEntityInvulnerable(){ return true; }
@Override public boolean canAttackPlayer(EntityPlayer player){ return false; }
@Override public void onDeath(DamageSource source){ return; }
@Override public void onUpdate(){ return; }
@Override public void travelToDimension(int dim){ return; }
@Override public void func_147100_a(C15PacketClientSettings pkt){ return; }
}
@@ -1,19 +1,27 @@
package net.minecraftforge.common;
import java.util.Map;
import java.util.UUID;
import com.google.common.collect.Maps;
import com.mojang.authlib.GameProfile;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
//To be expanded for generic Mod fake players?
public class FakePlayerFactory
{
private static GameProfile MINECRAFT = new GameProfile("41C82C87-7AfB-4024-BA57-13D2C99CAE77", "[Minecraft]");
// Map of all active fake player usernames to their entities
private static java.util.Map<String, FakePlayer> fakePlayers = new java.util.HashMap<String, FakePlayer>();
private static Map<GameProfile, FakePlayer> fakePlayers = Maps.newHashMap();
private static FakePlayer MINECRAFT_PLAYER = null;
public static FakePlayer getMinecraft(World world)
public static FakePlayer getMinecraft(WorldServer world)
{
if (MINECRAFT_PLAYER == null)
{
MINECRAFT_PLAYER = FakePlayerFactory.get(world, "[Minecraft]");
MINECRAFT_PLAYER = FakePlayerFactory.get(world, MINECRAFT);
}
return MINECRAFT_PLAYER;
}
@@ -21,7 +29,7 @@ public class FakePlayerFactory
/**
* Get a fake player with a given username
*/
public static FakePlayer get(World world, String username)
public static FakePlayer get(WorldServer world, GameProfile username)
{
if (!fakePlayers.containsKey(username))
{