Make sure test mods load, fix BlockstateRetextureTest

This commit is contained in:
tterrag 2019-06-21 19:35:32 -04:00
parent 5fb948fb35
commit 8c3e511538
5 changed files with 24 additions and 20 deletions

View file

@ -40,8 +40,8 @@ import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import net.minecraftforge.registries.ObjectHolder;
import net.minecraftforge.eventbus.api.SubscribeEvent;
@Mod(MaterialFogColorTest.MODID)
@Mod.EventBusSubscriber
//@Mod(MaterialFogColorTest.MODID)
//@Mod.EventBusSubscriber
public class MaterialFogColorTest
{
static final String MODID = "fog_color_in_material_test";

View file

@ -42,7 +42,7 @@ public class PathNodeTypeTest
@ObjectHolder(BLOCK_ID)
private static final Block TEST_BLOCK = null;
private static Block TEST_BLOCK = null;
@SubscribeEvent
public static void register(RegistryEvent.Register<Block> event)

View file

@ -32,7 +32,7 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@Mod("client_command_test")
//@Mod("client_command_test")
public class ClientCommandTest
{
/*

View file

@ -25,35 +25,37 @@ import com.google.common.collect.ImmutableMap;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.ModelResourceLocation;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.ModelBakeEvent;
import net.minecraftforge.client.model.BasicState;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.TRSRTransformation;
import net.minecraftforge.fml.common.Mod;
//@Mod(modid = BlockstateRetextureTest.MODID, name = "BlockstateRetextureTest", version = BlockstateRetextureTest.VERSION, acceptableRemoteVersions = "*", clientSideOnly = true)
@Mod(BlockstateRetextureTest.MODID)
public class BlockstateRetextureTest
{
public static final String MODID = "forge_blockstate_retexture_test";
public static final String VERSION = "1.0";
static final boolean ENABLED = false;
static final boolean ENABLED = true;
private static ResourceLocation fenceName = new ResourceLocation("minecraft", "fence");
private static ModelResourceLocation fenceLocation = new ModelResourceLocation(fenceName, "east=true,north=false,south=false,west=true");
private static ResourceLocation fenceName = new ResourceLocation("minecraft", "oak_fence");
private static ModelResourceLocation fenceLocation = new ModelResourceLocation(fenceName, "east=true,north=false,south=false,waterlogged=false,west=true");
private static ResourceLocation stoneName = new ResourceLocation("minecraft", "stone");
private static ModelResourceLocation stoneLocation = new ModelResourceLocation(stoneName, "normal");
private static ModelResourceLocation stoneLocation = new ModelResourceLocation(stoneName, "");
private static Function<ResourceLocation, TextureAtlasSprite> textureGetter = location ->
{
assert location != null;
return Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(location.toString());
return Minecraft.getInstance().getTextureMap().getAtlasSprite(location.toString());
};
//@Mod.EventBusSubscriber(modid = MODID, value = Side.CLIENT)
@Mod.EventBusSubscriber(modid = MODID, value = Dist.CLIENT)
public static class ClientEvents
{
@net.minecraftforge.eventbus.api.SubscribeEvent
@ -64,16 +66,16 @@ public class BlockstateRetextureTest
return;
}
IModel fence = ModelLoaderRegistry.getModelOrLogError(fenceLocation, "Error loading fence model");
IModel stone = ModelLoaderRegistry.getModelOrLogError(stoneLocation, "Error loading planks model");
IModel retexturedFence = fence.retexture(ImmutableMap.of("texture", "blocks/log_oak"));
IModel retexturedStone = stone.retexture(ImmutableMap.of("all", "blocks/diamond_block"));
IModel<?> fence = ModelLoaderRegistry.getModelOrLogError(fenceLocation, "Error loading fence model");
IModel<?> stone = ModelLoaderRegistry.getModelOrLogError(stoneLocation, "Error loading stone model");
IModel<?> retexturedFence = fence.retexture(ImmutableMap.of("texture", "blocks/log_oak"));
IModel<?> retexturedStone = stone.retexture(ImmutableMap.of("all", "blocks/diamond_block"));
IBakedModel fenceResult = retexturedFence.bake(fence.getDefaultState(), DefaultVertexFormats.BLOCK, textureGetter);
IBakedModel stoneResult = retexturedStone.bake(stone.getDefaultState(), DefaultVertexFormats.BLOCK, textureGetter);
IBakedModel fenceResult = retexturedFence.bake(event.getModelLoader(), textureGetter, new BasicState(fence.getDefaultState(), true), DefaultVertexFormats.ITEM);
IBakedModel stoneResult = retexturedStone.bake(event.getModelLoader(), textureGetter, new BasicState(stone.getDefaultState(), true), DefaultVertexFormats.ITEM);
event.getModelRegistry().putObject(fenceLocation, fenceResult);
event.getModelRegistry().putObject(stoneLocation, stoneResult);
event.getModelRegistry().put(fenceLocation, fenceResult);
event.getModelRegistry().put(stoneLocation, ModelLoaderRegistry.getMissingModel().bake(event.getModelLoader(), textureGetter, new BasicState(TRSRTransformation.identity(), false), DefaultVertexFormats.ITEM));
}
}
}

View file

@ -5,6 +5,8 @@ loaderVersion="[2.0,)"
modId="forgedebugmodeldata"
#[[mods]]
# modId="forgedebugmodelloaderregistry"
[[mods]]
modId="forge_blockstate_retexture_test"
[[mods]]
modId="containertypetest"
[[mods]]