本文整理汇总了Java中net.minecraftforge.fml.common.registry.GameData类的典型用法代码示例。如果您正苦于以下问题:Java GameData类的具体用法?Java GameData怎么用?Java GameData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GameData类属于net.minecraftforge.fml.common.registry包,在下文中一共展示了GameData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SpecifiedItem
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
private static int SpecifiedItem(String color, int added, short[] dmgs, String[] itemId, String identifier) {
for (ResourceLocation key : GameData.getItemRegistry().getKeys()) {
if (key.toString().startsWith(identifier)) {
int id = GameData.getItemRegistry().getId(key);
Item item = Item.getItemById(id);
if (item == null) {
if (itemId[0].equals("minecraft") || Loader.isModLoaded(itemId[0]))
Log.warn("Stumbled upon invalid entry in item registry while parsing whitelist $1, object not found: $0", key, color);
continue;
}
getList(color).put(item, dmgs);
++added;
}
}
return added;
}
示例2: SpecifiedBlock
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
private static int SpecifiedBlock(String color, int added, short[] dmgs, String[] itemId, String identifier) {
for (ResourceLocation key : GameData.getBlockRegistry().getKeys()) {
if (key.toString().startsWith(identifier)) {
int id = GameData.getBlockRegistry().getId(key);
Block block = Block.getBlockById(id);
if (block == null) {
if (itemId[0].equals("minecraft") || Loader.isModLoaded(itemId[0]))
Log.warn("Stumbled upon invalid entry in block registry while parsing whitelist $1, object not found: $0", key, color);
continue;
}
getList(color).put(Item.getItemFromBlock(block), dmgs);
++added;
}
}
return added;
}
示例3: catagorize
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
private static String catagorize(ItemStack i) {
StringBuilder sb = new StringBuilder();
Item item = i.getItem();
sb.append(GameData.getItemRegistry().getNameForObject(item).getResourceDomain());
if(item instanceof ItemBlock){
if(((ItemBlock)item).getBlock() instanceof ITileEntityProvider){
sb.append("A");
} else {
sb.append("B");
}
} else {
sb.append("I");
}
sb.append(item.getUnlocalizedName());
sb.append(i.getMetadata());
return sb.toString();
}
示例4: getValidItems
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
public static @Nonnull NNList<ItemStack> getValidItems() {
final NNList<ItemStack> list = new NNList<ItemStack>();
final NNList<ItemStack> sublist = new NNList<ItemStack>();
for (final Item item : GameData.getItemRegistry()) {
for (CreativeTabs tab : item.getCreativeTabs()) {
EnderIO.proxy.getSubItems(NullHelper.notnullM(item, "Null item in game registry"), tab, sublist);
sublist.apply(new Callback<ItemStack>() {
@Override
public void apply(@Nonnull ItemStack stack) {
if (Prep.isInvalid(stack)) {
Log.error("The item " + item + " (" + item.getUnlocalizedName() + ") produces empty itemstacks in getSubItems()");
} else if (stack.getItem() == Items.AIR) {
Log.error("The item " + item + " (" + item.getUnlocalizedName() + ") produces itemstacks without item in getSubItems()");
} else {
list.add(stack);
}
}
});
sublist.clear();
}
}
return list;
}
示例5: loadChunk
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
private void loadChunk(int id, Shader shader, ExtendedBlockStorage storage) {
ObjectIntIdentityMap<IBlockState> map = GameData.getBlockStateIDMap();
int[] data = new int[chunkSize*2];
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
IBlockState state = storage.get(x, y, z);
boolean fullBlock = state.isFullBlock();
boolean cube = state.isFullCube();
if (fullBlock != cube) {
Log.info(state.getBlock().getUnlocalizedName() + ": " + fullBlock);
}
if (fullBlock) {
stateSet.add(state);
}
int stateId = map.get(state); //TODO
data[(y<<9) + (z<<5) + (x<<1)] = Block.getIdFromBlock(storage.get(x, y, z).getBlock());
}
}
}
for (int y = 0; y < 16; y++) {
for (int z = 0; z < 16; z++) {
for (int x = 0; x < 16; x++) {
data[(y<<9) + (z<<5) + (x<<1) + 1] = storage.getBlocklightArray().get(x, y, z);
}
}
}
IntBuffer buffer = BufferUtils.createIntBuffer(chunkSize*2);
buffer.put(data);
buffer.flip();
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, shader.getChunkSsbo());
GL15.glBufferSubData(GL43.GL_SHADER_STORAGE_BUFFER, (id-1)*chunkSize*2*4, buffer);
GL15.glBindBuffer(GL43.GL_SHADER_STORAGE_BUFFER, 0);
}
示例6: remap
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
/**
* Remap the missing item to the specified Block.
*
* Use this if you have renamed a Block, don't forget to handle the ItemBlock.
* Existing references using the old name will point to the new one.
*
* @param target Block to remap to.
*/
public void remap(Block target)
{
if (type != GameRegistry.Type.BLOCK) throw new IllegalArgumentException("Can't remap an item to a block.");
if (target == null) throw new NullPointerException("remap target is null");
if (GameData.getBlockRegistry().getId(target) < 0) throw new IllegalArgumentException(String.format("The specified block %s hasn't been registered at startup.", target));
action = Action.REMAP;
this.target = target;
}
示例7: getOreIDs
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
/**
* Gets all the integer ID for the ores that the specified item stack is registered to.
* If the item stack is not linked to any ore, this will return an empty array and no new entry will be created.
*
* @param stack The item stack of the ore.
* @return An array of ids that this ore is registered as.
*/
public static int[] getOreIDs(ItemStack stack)
{
if (stack == null || stack.getItem() == null) throw new IllegalArgumentException("Stack can not be null!");
Set<Integer> set = new HashSet<Integer>();
// HACK: use the registry name's ID. It is unique and it knows about substitutions. Fallback to a -1 value (what Item.getIDForItem would have returned) in the case where the registry is not aware of the item yet
// IT should be noted that -1 will fail the gate further down, if an entry already exists with value -1 for this name. This is what is broken and being warned about.
// APPARENTLY it's quite common to do this. OreDictionary should be considered alongside Recipes - you can't make them properly until you've registered with the game.
ResourceLocation registryName = stack.getItem().delegate.name();
int id;
if (registryName == null)
{
FMLLog.log(Level.DEBUG, "Attempted to find the oreIDs for an unregistered object (%s). This won't work very well.", stack);
return new int[0];
}
else
{
id = GameData.getItemRegistry().getId(registryName);
}
List<Integer> ids = stackToId.get(id);
if (ids != null) set.addAll(ids);
ids = stackToId.get(id | ((stack.getItemDamage() + 1) << 16));
if (ids != null) set.addAll(ids);
Integer[] tmp = set.toArray(new Integer[set.size()]);
int[] ret = new int[tmp.length];
for (int x = 0; x < tmp.length; x++)
ret[x] = tmp[x];
return ret;
}
示例8: rebakeMap
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
public static void rebakeMap()
{
//System.out.println("Baking OreDictionary:");
stackToId.clear();
for (int id = 0; id < idToStack.size(); id++)
{
List<ItemStack> ores = idToStack.get(id);
if (ores == null) continue;
for (ItemStack ore : ores)
{
// HACK: use the registry name's ID. It is unique and it knows about substitutions
ResourceLocation name = ore.getItem().delegate.name();
int hash;
if (name == null)
{
FMLLog.log(Level.DEBUG, "Defaulting unregistered ore dictionary entry for ore dictionary %s: type %s to -1", getOreName(id), ore.getItem().getClass());
hash = -1;
}
else
{
hash = GameData.getItemRegistry().getId(name);
}
if (ore.getItemDamage() != WILDCARD_VALUE)
{
hash |= ((ore.getItemDamage() + 1) << 16); // +1 so meta 0 is significant
}
List<Integer> ids = stackToId.get(hash);
if (ids == null)
{
ids = Lists.newArrayList();
stackToId.put(hash, ids);
}
ids.add(id);
//System.out.println(id + " " + getOreName(id) + " " + Integer.toHexString(hash) + " " + ore);
}
}
}
示例9: PotionBase
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
protected PotionBase(String name, boolean isBadEffectIn, int liquidColorIn)
{
super(isBadEffectIn, liquidColorIn);
this.setRegistryName(new ResourceLocation(Reference.MOD_ID,name));
GameData.getPotionRegistry().register(this);
}
示例10: generate
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
public void generate(Random random, int chunkX, int chunkZ, World world, OreConfig config) {
Block block = GameData.getBlockRegistry().getObject(config.getBlock());
Block block2 = GameData.getBlockRegistry().getObject(config.getReplacementBlock());
if (block2 == null) {
block2 = Blocks.STONE;
}
WorldGenMinable worldGenMinable = new WorldGenMinable(block.getDefaultState(), config.veinSize, BlockMatcher.forBlock(block2));
int xPos, yPos, zPos;
for (int i = 0; i < config.veinsPerChunk; i++) {
xPos = chunkX * 16 + random.nextInt(16);
yPos = 10 + random.nextInt(config.maxYHeight - config.minYHeight);
zPos = chunkZ * 16 + random.nextInt(16);
worldGenMinable.generate(world, random, new BlockPos(xPos, yPos, zPos));
}
}
示例11: getModNameFromItem
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private static String getModNameFromItem(ItemStack stack) {
try {
ResourceLocation resource = GameData.getItemRegistry().getNameForObject(stack.getItem());
ModContainer mod = findModContainer(resource.getResourceDomain());
return mod == null ? "Minecraft" : mod.getName();
}
catch (NullPointerException e) {
return "";
}
}
示例12: createState
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static IBlockState createState(String block, HashMap<String, String> properties)
{
Block foundBlock = GameData.getBlockRegistry().getObject(new ResourceLocation(block));
ImmutableList<IBlockState> states = foundBlock.getBlockState().getValidStates();
Iterator<IBlockState> iterator = states.iterator();
while (iterator.hasNext())
{
boolean isCorrectState = true;
IBlockState state = iterator.next();
ImmutableMap<IProperty, Comparable> stateProps = state.getProperties();
Iterator<Entry<IProperty, Comparable>> propIterater = stateProps.entrySet().iterator();
while(propIterater.hasNext())
{
Entry<IProperty, Comparable> entry = propIterater.next();
IProperty property = entry.getKey();
if(properties.containsKey(property.getName()))
{
if(!state.getValue(property).toString().contentEquals(properties.get(property.getName())))
{
isCorrectState = false;
}
}
}
if(isCorrectState)
{
return state;
}
}
GenLoaderAPI.log.log(Level.WARN, "Block: *" + block + "* with properties: *" + properties + "* was not found, resorting to block's default state");
return foundBlock.getDefaultState();
}
示例13: WeightedBlockState
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
public WeightedBlockState(int Weight, IBlockState State)
{
this.weight = Weight;
this.block = GameData.getBlockRegistry().getNameForObject(State.getBlock()).toString();
this.properties = BlockUtils.generateProperties(State);
this.state = State;
}
示例14: getAllEligibleItemStacks
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
/** Gets the list of possible blocks that can be crafted (clientside only) */
@SideOnly(Side.CLIENT)
public static List getAllEligibleItemStacks() {
JointList<ItemStack> list = new JointList<ItemStack>();
if(!EBConfig.enableCreativeTabVariants) return list;
// iterate through all the items
Iterable<Item> allItems;
allItems = GameData.getItemRegistry().typeSafeIterable();
for(Item i : allItems) {
// check to make sure the mod for the item is not BL'd
String modId = i.getRegistryName().getResourceDomain();
if(EBConfig.blacklistedMods.contains(modId)) continue;
// get all of the exposed subitems for this item
JointList<ItemStack> j = new JointList<ItemStack>();
if(i instanceof IOverrideEBSubtypes) {
((IOverrideEBSubtypes)i).getEBSubtypes(i, j);
} else {
i.getSubItems(i, CreativeTabs.SEARCH, j);
}
for(ItemStack s : j) {
// check each one for eligibility
ItemStack dupe = s.copy();
dupe.stackSize = 9; // the amount of blocks to hold
if(isItemStackValid(s)) {
if(isItemStackCraftable(s)) list.join(dupe); // add to the list
}
}
}
return list;
}
示例15: bindHooks
import net.minecraftforge.fml.common.registry.GameData; //导入依赖的package包/类
private static void bindHooks() {
ChestGenHooks hooks = ChestGenHooks.getInfo("Placemod");
for (ResourceLocation itemName : GameData.getItemRegistry().getKeys()) {
Item item = Item.itemRegistry.getObject(itemName);
int maxDmg = item.getMaxDamage();
for (int meta = 0; meta <= maxDmg; ++meta) {
hooks.addItem(new WeightedRandomChestContent(new ItemStack(item, 1, meta), 1, maxChestStackSize, 256 / (1 + maxDmg)));
}
}
hooks.setMin(minChestItems);
hooks.setMax(maxChestItems);
}