Fix NamespacedWrapper not delegating a new getter. Fixing data loading spam at world start.
Update red/yellow/green tags with new vanilla item names. Reenabled test source directory in project and made ModelDataTest compile.
This commit is contained in:
parent
850c73b73f
commit
b74b72e44c
8 changed files with 41 additions and 103 deletions
|
@ -138,8 +138,8 @@ project(':forge') {
|
|||
runtimeClasspath += sourceSets.fmllauncher.runtimeClasspath
|
||||
java {
|
||||
srcDirs = [
|
||||
//"$rootDir/src/test/java",
|
||||
//"$rootDir/src/fmllaunchertest/java"
|
||||
"$rootDir/src/test/java",
|
||||
"$rootDir/src/fmllaunchertest/java"
|
||||
]
|
||||
}
|
||||
resources {
|
||||
|
|
|
@ -21,6 +21,7 @@ package net.minecraftforge.registries;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Optional;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -72,6 +73,12 @@ class NamespacedWrapper<T extends IForgeRegistryEntry<T>> extends SimpleRegistry
|
|||
return this.delegate.getRaw(name); //get without default
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T> func_218349_b(@Nullable ResourceLocation name)
|
||||
{
|
||||
return Optional.ofNullable( this.delegate.getRaw(name)); //get without default
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ResourceLocation getKey(T value)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:cactus_green"
|
||||
"minecraft:green_dye"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:rose_red"
|
||||
"minecraft:red_dye"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"minecraft:dandelion_yellow"
|
||||
"minecraft:yellow_dye"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -26,24 +26,24 @@ import javax.annotation.Nonnull;
|
|||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockContainer;
|
||||
import net.minecraft.block.BlockRenderType;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.block.ContainerBlock;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.renderer.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.model.IBakedModel;
|
||||
import net.minecraft.client.renderer.model.ItemOverrideList;
|
||||
import net.minecraft.client.renderer.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.tileentity.ITickableTileEntity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityType;
|
||||
import net.minecraft.util.EnumBlockRenderType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorldReader;
|
||||
import net.minecraft.world.IEnviromentBlockReader;
|
||||
import net.minecraftforge.client.event.ModelBakeEvent;
|
||||
import net.minecraftforge.client.model.ModelDataManager;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
|
@ -55,6 +55,7 @@ import net.minecraftforge.event.RegistryEvent;
|
|||
import net.minecraftforge.eventbus.api.IEventBus;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
|
||||
import net.minecraftforge.registries.ObjectHolder;
|
||||
|
||||
@Mod(ModelDataTest.MODID)
|
||||
public class ModelDataTest
|
||||
|
@ -63,6 +64,12 @@ public class ModelDataTest
|
|||
public static final String VERSION = "1.0";
|
||||
|
||||
private static final ModelProperty<Boolean> MAGIC_PROP = new ModelProperty<Boolean>();
|
||||
private static final String BLOCK_NAME = "block";
|
||||
|
||||
@ObjectHolder(MODID + ":" + BLOCK_NAME)
|
||||
private static final Block MY_BLOCK = null;
|
||||
@ObjectHolder(MODID + ":" + BLOCK_NAME)
|
||||
private static final TileEntityType<Tile> TILE_TYPE = null;
|
||||
|
||||
public ModelDataTest()
|
||||
{
|
||||
|
@ -76,8 +83,7 @@ public class ModelDataTest
|
|||
{
|
||||
final IBakedModel stone = event.getModelRegistry().get(new ModelResourceLocation("minecraft:stone"));
|
||||
final IBakedModel dirt = event.getModelRegistry().get(new ModelResourceLocation("minecraft:dirt"));
|
||||
final IBakedModel old = event.getModelRegistry().get(new ModelResourceLocation("forge:modeltest"));
|
||||
event.getModelRegistry().put(new ModelResourceLocation("forge:modeltest"), new IDynamicBakedModel()
|
||||
event.getModelRegistry().put(new ModelResourceLocation(MODID, BLOCK_NAME), new IDynamicBakedModel()
|
||||
{
|
||||
@Override
|
||||
public boolean isGui3d()
|
||||
|
@ -98,7 +104,7 @@ public class ModelDataTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, Random rand, IModelData modelData)
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
return modelData.getData(MAGIC_PROP) ? stone.getQuads(state, side, rand, modelData) : dirt.getQuads(state, side, rand, modelData);
|
||||
}
|
||||
|
@ -106,7 +112,7 @@ public class ModelDataTest
|
|||
@Override
|
||||
public TextureAtlasSprite getParticleTexture()
|
||||
{
|
||||
return MissingTextureSprite.getSprite();
|
||||
return MissingTextureSprite.func_217790_a();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,7 +123,7 @@ public class ModelDataTest
|
|||
|
||||
@Override
|
||||
@Nonnull
|
||||
public IModelData getModelData(@Nonnull IWorldReader world, @Nonnull BlockPos pos, @Nonnull IBlockState state, @Nonnull IModelData tileData)
|
||||
public IModelData getModelData(@Nonnull IEnviromentBlockReader world, @Nonnull BlockPos pos, @Nonnull BlockState state, @Nonnull IModelData tileData)
|
||||
{
|
||||
if (world.getBlockState(pos.down()).getBlock() == Blocks.AIR)
|
||||
{
|
||||
|
@ -128,9 +134,8 @@ public class ModelDataTest
|
|||
});
|
||||
}
|
||||
|
||||
private static final TileEntityType<Tile> TILE_TYPE = TileEntityType.Builder.create(Tile::new).build(null);
|
||||
|
||||
private static class Tile extends TileEntity implements ITickable
|
||||
private static class Tile extends TileEntity implements ITickableTileEntity
|
||||
{
|
||||
|
||||
public Tile()
|
||||
|
@ -146,7 +151,7 @@ public class ModelDataTest
|
|||
if (world.isRemote && counter++ == 100)
|
||||
{
|
||||
ModelDataManager.requestModelDataRefresh(this);
|
||||
world.markBlockRangeForRenderUpdate(getPos(), getPos());
|
||||
world.func_217396_m(getPos());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,9 +164,8 @@ public class ModelDataTest
|
|||
|
||||
public void registerBlocks(RegistryEvent.Register<Block> event)
|
||||
{
|
||||
event.getRegistry().register(new BlockContainer(Block.Properties.create(Material.ROCK))
|
||||
event.getRegistry().register(new ContainerBlock(Block.Properties.create(Material.ROCK))
|
||||
{
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public TileEntity createNewTileEntity(IBlockReader worldIn)
|
||||
|
@ -170,15 +174,15 @@ public class ModelDataTest
|
|||
}
|
||||
|
||||
@Override
|
||||
public EnumBlockRenderType getRenderType(IBlockState state)
|
||||
public BlockRenderType getRenderType(BlockState state)
|
||||
{
|
||||
return EnumBlockRenderType.MODEL;
|
||||
return BlockRenderType.MODEL;
|
||||
}
|
||||
}.setRegistryName("forge:modeltest"));
|
||||
}.setRegistryName(MODID, BLOCK_NAME));
|
||||
}
|
||||
|
||||
public void registerTileEntities(RegistryEvent.Register<TileEntityType<?>> event)
|
||||
{
|
||||
event.getRegistry().register(TILE_TYPE.setRegistryName("forge:modeltest"));
|
||||
event.getRegistry().register(TileEntityType.Builder.func_223042_a(Tile::new, MY_BLOCK).build(null).setRegistryName(MODID, BLOCK_NAME));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
# The name of the mod loader type to load
|
||||
modLoader="javafml"
|
||||
# A version range to match for said mod loader
|
||||
loaderVersion="[2.0,)"
|
||||
|
||||
# debug/client/model
|
||||
|
@ -8,7 +6,7 @@ loaderVersion="[2.0,)"
|
|||
modId="forgedebugmodeldata"
|
||||
version="1.0"
|
||||
displayName="ModelDataTest"
|
||||
[[mods]]
|
||||
modId="forgedebugmodelloaderregistry"
|
||||
version="1.0"
|
||||
displayName="ModelLoaderRegistryTest"
|
||||
#[[mods]]
|
||||
# modId="forgedebugmodelloaderregistry"
|
||||
# version="1.0"
|
||||
# displayName="ModelLoaderRegistryTest"
|
|
@ -1,71 +0,0 @@
|
|||
# The name of the mod loader type to load
|
||||
modLoader="javafml"
|
||||
# A version range to match for said mod loader
|
||||
loaderVersion="[2.0,)"
|
||||
# A URL to query for updates
|
||||
updateJSONURL="http://myurl.me/"
|
||||
# A URL to refer people to when problems occur with this mod
|
||||
issueTrackerURL="http://my.issue.tracker/"
|
||||
# Extra mod loader property
|
||||
randomScalaProperty="fishy"
|
||||
# Arbitrary key-value property pairs available to mods
|
||||
[properties]
|
||||
key="value"
|
||||
|
||||
# A list of mods - how many allowed here is determined by the individual mod loader
|
||||
[[mods]]
|
||||
# The modid of the mod
|
||||
modId="inventorysorter"
|
||||
# The version number of the mod
|
||||
version="1.1"
|
||||
# A display name for the mod
|
||||
displayName="Inventory Sorter"
|
||||
# The description text for the mod (multi line!)
|
||||
description='''
|
||||
This is my mod, there may be
|
||||
others, but this one is mine
|
||||
'''
|
||||
# A random extra property for a mod loader
|
||||
randomExtraProperty="somevalue"
|
||||
# Arbitrary key-value pairs
|
||||
[modproperties.inventorysorter]
|
||||
key="value"
|
||||
# A list of dependencies
|
||||
[[dependencies.inventorysorter]]
|
||||
# the modid of the dependency
|
||||
modId="forge"
|
||||
# Does this dependency have to exist - if not, ordering below must be specified
|
||||
mandatory=true
|
||||
# The version range of the dependency
|
||||
versionRange="[14.23.2.0,)"
|
||||
# An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
|
||||
ordering="NONE"
|
||||
# Side this dependency is applied on - BOTH, CLIENT or SERVER
|
||||
side="BOTH"
|
||||
# Here's another dependency
|
||||
[[dependencies.inventorysorter]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.12.2]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
# Here's another mod in this jar
|
||||
[[mods]]
|
||||
# Note that other mod types may want to add additional key-value pairs in here
|
||||
modId="inventorysortertoo"
|
||||
# ${jarVersion} will read the Implementation-Version of the jar file
|
||||
version="${jarVersion}"
|
||||
displayName="Inventory Sorter as well"
|
||||
description='''
|
||||
This is also my mod, there may be
|
||||
others, but this one is mine
|
||||
'''
|
||||
[[dependencies.inventorysortertoo]]
|
||||
modId="minecraft"
|
||||
mandatory=true
|
||||
versionRange="[1.12.2]"
|
||||
ordering="NONE"
|
||||
side="BOTH"
|
||||
[[mods]]
|
||||
# A minimal mod
|
||||
modId="minimalmod"
|
Loading…
Reference in a new issue