本文整理匯總了Java中cpw.mods.fml.common.registry.GameData類的典型用法代碼示例。如果您正苦於以下問題:Java GameData類的具體用法?Java GameData怎麽用?Java GameData使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
GameData類屬於cpw.mods.fml.common.registry包,在下文中一共展示了GameData類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: preInit
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
public static void preInit() {
if(ModConfig.enableAdditionalNodeTypes) {
try {
ItemBlock item = (ItemBlock) Item.getItemFromBlock(ConfigBlocks.blockAiry);
item.field_150939_a = RegisteredBlocks.blockNode;
//Hacky way
FMLControlledNamespacedRegistry<Block> registry = GameData.getBlockRegistry();
registry.underlyingIntegerMap.field_148749_a.put(RegisteredBlocks.blockNode, Block.getIdFromBlock(ConfigBlocks.blockAiry));
registry.underlyingIntegerMap.field_148748_b.set(Block.getIdFromBlock(ConfigBlocks.blockAiry), RegisteredBlocks.blockNode);
((BiMap)registry.field_148758_b).forcePut(RegisteredBlocks.blockNode, registry.field_148758_b.get(ConfigBlocks.blockAiry));
registry.underlyingIntegerMap.field_148749_a.remove(ConfigBlocks.blockAiry);
ConfigBlocks.blockAiry = RegisteredBlocks.blockNode;
} catch (Exception e) {
e.printStackTrace();
}
}
}
示例2: initializeMods
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
public void initializeMods()
{
progressBar.step("Initializing mods Phase 2");
// Mod controller should be in the initialization state here
modController.distributeStateMessage(LoaderState.INITIALIZATION);
progressBar.step("Initializing mods Phase 3");
modController.transition(LoaderState.POSTINITIALIZATION, false);
modController.distributeStateMessage(FMLInterModComms.IMCEvent.class);
ItemStackHolderInjector.INSTANCE.inject();
modController.distributeStateMessage(LoaderState.POSTINITIALIZATION);
progressBar.step("Finishing up");
modController.transition(LoaderState.AVAILABLE, false);
modController.distributeStateMessage(LoaderState.AVAILABLE);
GameData.freezeData();
// Dump the custom registry data map, if necessary
GameData.dumpRegistry(minecraftDir);
FMLLog.info("Forge Mod Loader has successfully loaded %d mod%s", mods.size(), mods.size() == 1 ? "" : "s");
progressBar.step("Completing Minecraft initialization");
}
示例3: nerfStandardRecipes
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override
protected void nerfStandardRecipes ()
{
for (Item item : (Iterable<Item>) GameData.getItemRegistry())
{
if ((item instanceof ItemTool || item instanceof ItemSword) && !isBBTool(item))
{
String repairMaterial = BetterBeginningsHandler.getToolRepairMaterial(item);
if (!Strings.isNullOrEmpty(repairMaterial) && !OreDictionary.getOres(repairMaterial).isEmpty())
{
nerfToolRecipe(new ItemStack(item), repairMaterial);
}
}
}
}
示例4: readItemStackFromData
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
protected ItemStack readItemStackFromData(DataInputStream data) throws IOException {
ItemStack itemstack = null;
String itemName = data.readUTF();
if (!itemName.isEmpty()) {
Item item = GameData.getItemRegistry().getRaw(itemName);
byte stackSize = data.readByte();
short meta = data.readShort();
itemstack = new ItemStack(item, stackSize, meta);
if (item.isDamageable() || item.getShareTag()) {
itemstack.stackTagCompound = this.readNBTTagCompound(data);
}
}
return itemstack;
}
示例5: writeNBT
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@TileEvent(TileEventType.WORLD_NBT_WRITE)
public void writeNBT(NBTTagCompound cmp){
cmp.setInteger(NBTKeys.storedMana.toString(), currMana);
NBTTagCompound inv = new NBTTagCompound();
for (int i = 0; i < inventory.length; i++){
if (inventory[i] == null) continue;
NBTTagCompound slot = new NBTTagCompound();
slot.setInteger(NBTKeys.amount.toString(), inventory[i].stackSize);
slot.setString(NBTKeys.item.toString(), GameData.getItemRegistry().getNameForObject(inventory[i].getItem()));
slot.setInteger(NBTKeys.metadata.toString(), inventory[i].getItemDamage());
if (inventory[i].hasTagCompound())
slot.setString(NBTKeys.nbt.toString(), inventory[i].getTagCompound().toString());
else
slot.setString(NBTKeys.nbt.toString(), "");
inv.setTag("#" + i, slot);
}
cmp.setTag(NBTKeys.inventory.toString(), inv);
}
示例6: blockListToBlockNames
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
protected String[] blockListToBlockNames(final List<Block> blockList) {
if ((blockList == null) || blockList.isEmpty()) {
return new String[0];
} else {
final String[] result = new String[blockList.size()];
int index = 0;
for (final Block block : blockList) {
final String blockname = GameData.getBlockRegistry().getNameForObject(block);
if (blockname != null) {
result[index] = blockname;
++index;
} else {
DaVincing.log.warn("Ignoring invalid block configuration entry: %s", Utils.blockToString(block));
}
}
Arrays.sort(result);
return result;
}
}
示例7: getItemName
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
public static String getItemName(String s)
{
// If this name is a number we parse the number then check the item registry for an item with that ID.
// If the ID is valid we'll get the name, if not we'll get a null.
// If the name isn't a number just return the name again.
try
{
RegistryNamespaced rn = GameData.getItemRegistry();
int id = Integer.parseInt(s);
if(rn.containsId(id))
return rn.getNameForObject(rn.getObjectById(id));
else
return null;
}
catch (NumberFormatException e) {}
return s;
}
示例8: readCustomNBT
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override
public void readCustomNBT(NBTTagCompound compound) {
String parentType = compound.getString("parentType");
if(parentType.length() > 0) {
Block block = GameData.getBlockRegistry().getObject(parentType);
if(block != null && compound.hasKey("parent") && compound.hasKey("parentMetadata")) {
NBTTagCompound data = compound.getCompoundTag("parent");
int metadata = compound.getInteger("parentMetadata");
TileEntity tile = block.createTileEntity(getWorldObj(), metadata);
if(tile instanceof TileJarFillable) {
placedOn = ForgeDirection.getOrientation(compound.getInteger("placedOn"));
tile.readFromNBT(data);
init((TileJarFillable) tile, block, metadata, placedOn);
}
}
}
if(!isValid() && !getWorldObj().isRemote) {
getWorldObj().setBlockToAir(xCoord, yCoord, zCoord);
}
}
示例9: readMovementInfo
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override
public void readMovementInfo(IMovingBlock block, NBTTagCompound tag) {
block.setBlock(GameData.getBlockRegistry().getObject(tag.getString("block")));
block.setMetadata(tag.getInteger("metadata"));
TileEntity te = block.getTileEntity();
if (tag.hasKey("data") && (te != null || block.getBlock() instanceof ITileEntityProvider)) {
if (te == null) {
te = ((ITileEntityProvider) block.getBlock()).createNewTileEntity(FakeWorld.getFakeWorld((MovingBlock) block),
block.getMetadata());
System.out.println("creating!");
}
if (te != null) {
te.readFromNBT(tag.getCompoundTag("data"));
block.setTileEntity(te);
}
}
((MovingBlock) block).setRenderList(-1);
}
示例10: getItem
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
/**
* Returns the ItemStack with the name specified, or air if nothing is found.
* @param name The name of the item to get.
* @return The item with the name, or an item that is bound to that name.
*/
public static ItemStack getItem(String name) {
if (GameData.getBlockRegistry().containsKey(name)) {
return new ItemStack(GameData.getBlockRegistry().getObject(name));
} else if (GameData.getItemRegistry().containsKey(name)) {
return new ItemStack(GameData.getItemRegistry().getObject(name));
} else {
if (name.matches("(?i)(class|kit|character).*(icon)*"))
return AllKits.getIcon(Vars.get("kit"));
else if (name.matches("(?i)sab.*winner"))
return InfoSab.getWinnerIcon();
else {
for (String s : icons.keySet()) {
if (name.matches(s))
return icons.get(s);
}
return new ItemStack(Blocks.air);
}
}
}
示例11: postInit
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override public void postInit() {
for (Object o : GameData.getItemRegistry()) {
if (o instanceof Item) { // should always be true, but just to be sure
Item i = (Item) o;
try {
Masses.calculateMass(i, 0, 32767);
} catch (StackOverflowError error) {
continue;
} catch (Exception e) {
e.printStackTrace();
System.err.println("Dazed and confused, but trying to continue");
continue;
}
}
}
Masses.bake();
}
示例12: init
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
public static void init(){
ConfigHandler.init(DimensionGuard.config);
Table<String,String,ItemStack> customStacks = ReflectionHelper.getPrivateValue(GameData.class, null, "customItemStacks");
Map<String,ItemStack> customItemStacks = new LinkedHashMap<String, ItemStack>();
for (Table.Cell<String, String,ItemStack> cell: customStacks.cellSet())
{
customItemStacks.put(cell.getRowKey()+":"+cell.getColumnKey(),cell.getValue());
}
addDisabledItems(true, customItemStacks);
addDisabledItems(false, customItemStacks);
addDisabledEntity(true);
addDisabledEntity(false);
}
示例13: deserialize
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override
public ItemStack deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
if (!json.isJsonObject()) {
return null;
}
JsonObject jsonObject = json.getAsJsonObject();
int stackSize = jsonObject.has(STACK_SIZE) ? jsonObject.get(STACK_SIZE).getAsInt() : DEFAULT_STACK_SIZE;
int itemDamage = jsonObject.has(ITEM_DAMAGE) ? jsonObject.get(ITEM_DAMAGE).getAsInt() : DEFAULT_ITEM_DAMAGE;
if (jsonObject.has(BLOCK)) {
Block block = GameData.getBlockRegistry().getObject(jsonObject.get(BLOCK).getAsString());
return new ItemStack(block, stackSize, itemDamage);
} else if (jsonObject.has(ITEM)) {
Item item = GameData.getItemRegistry().getObject(jsonObject.get(ITEM).getAsString());
return new ItemStack(item, stackSize, itemDamage);
}
return null;
}
示例14: callbackIdDifferenceResponse
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
public void callbackIdDifferenceResponse(boolean response)
{
if (response)
{
serverShouldBeKilledQuietly = false;
GameData.releaseGate(true);
client.continueWorldLoading();
}
else
{
serverShouldBeKilledQuietly = true;
GameData.releaseGate(false);
// Reset and clear the client state
client.func_71403_a((WorldClient)null);
client.func_71373_a(null);
}
}
示例15: execute
import cpw.mods.fml.common.registry.GameData; //導入依賴的package包/類
@Override
public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
{
byte[] allData = Bytes.concat(partials);
GameData.initializeServerGate(1);
try
{
NBTTagCompound serverList = CompressedStreamTools.func_74792_a(allData);
NBTTagList list = serverList.func_74761_m("List");
Set<ItemData> itemData = GameData.buildWorldItemData(list);
GameData.validateWorldSave(itemData);
MapDifference<Integer, ItemData> serverDifference = GameData.gateWorldLoadingForValidation();
if (serverDifference!=null)
{
FMLCommonHandler.instance().disconnectIDMismatch(serverDifference, netHandler, network);
}
}
catch (IOException e)
{
}
}