pick 97420a31d The big reformat of 2020

This commit is contained in:
yueh
2020-06-16 21:41:28 +02:00
parent 5304b3febe
commit 5225ea426b
2252 changed files with 95466 additions and 118582 deletions
@@ -18,11 +18,13 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.core.AppEng;
import com.google.common.collect.ImmutableList;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -30,93 +32,91 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.Collection;
import java.util.Set;
import java.util.function.Function;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.core.AppEng;
/**
* The built-in model for the connected texture crafting cube.
*/
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel>
{
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel> {
private final static Material RING_CORNER = texture( "ring_corner" );
private final static Material RING_SIDE_HOR = texture( "ring_side_hor" );
private final static Material RING_SIDE_VER = texture( "ring_side_ver" );
private final static Material UNIT_BASE = texture( "unit_base" );
private final static Material LIGHT_BASE = texture( "light_base" );
private final static Material ACCELERATOR_LIGHT = texture( "accelerator_light" );
private final static Material STORAGE_1K_LIGHT = texture( "1k_storage_light" );
private final static Material STORAGE_4K_LIGHT = texture( "4k_storage_light" );
private final static Material STORAGE_16K_LIGHT = texture( "16k_storage_light" );
private final static Material STORAGE_64K_LIGHT = texture( "64k_storage_light" );
private final static Material MONITOR_BASE = texture( "monitor_base" );
private final static Material MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
private final static Material MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
private final static Material MONITOR_LIGHT_BRIGHT = texture( "monitor_light_bright" );
private final static Material RING_CORNER = texture("ring_corner");
private final static Material RING_SIDE_HOR = texture("ring_side_hor");
private final static Material RING_SIDE_VER = texture("ring_side_ver");
private final static Material UNIT_BASE = texture("unit_base");
private final static Material LIGHT_BASE = texture("light_base");
private final static Material ACCELERATOR_LIGHT = texture("accelerator_light");
private final static Material STORAGE_1K_LIGHT = texture("1k_storage_light");
private final static Material STORAGE_4K_LIGHT = texture("4k_storage_light");
private final static Material STORAGE_16K_LIGHT = texture("16k_storage_light");
private final static Material STORAGE_64K_LIGHT = texture("64k_storage_light");
private final static Material MONITOR_BASE = texture("monitor_base");
private final static Material MONITOR_LIGHT_DARK = texture("monitor_light_dark");
private final static Material MONITOR_LIGHT_MEDIUM = texture("monitor_light_medium");
private final static Material MONITOR_LIGHT_BRIGHT = texture("monitor_light_bright");
private final AbstractCraftingUnitBlock.CraftingUnitType type;
private final AbstractCraftingUnitBlock.CraftingUnitType type;
CraftingCubeModel( AbstractCraftingUnitBlock.CraftingUnitType type )
{
this.type = type;
}
CraftingCubeModel(AbstractCraftingUnitBlock.CraftingUnitType type) {
this.type = type;
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return ImmutableList.of( RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT, STORAGE_1K_LIGHT, STORAGE_4K_LIGHT,
STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE, MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT );
}
@Override
public Collection<Material> getTextures(IModelConfiguration owner,
Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return ImmutableList.of(RING_CORNER, RING_SIDE_HOR, RING_SIDE_VER, UNIT_BASE, LIGHT_BASE, ACCELERATOR_LIGHT,
STORAGE_1K_LIGHT, STORAGE_4K_LIGHT, STORAGE_16K_LIGHT, STORAGE_64K_LIGHT, MONITOR_BASE,
MONITOR_LIGHT_DARK, MONITOR_LIGHT_MEDIUM, MONITOR_LIGHT_BRIGHT);
}
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
// Retrieve our textures and pass them on to the baked model
TextureAtlasSprite ringCorner = spriteGetter.apply( RING_CORNER );
TextureAtlasSprite ringSideHor = spriteGetter.apply( RING_SIDE_HOR );
TextureAtlasSprite ringSideVer = spriteGetter.apply( RING_SIDE_VER );
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery,
Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform,
ItemOverrideList overrides, ResourceLocation modelLocation) {
// Retrieve our textures and pass them on to the baked model
TextureAtlasSprite ringCorner = spriteGetter.apply(RING_CORNER);
TextureAtlasSprite ringSideHor = spriteGetter.apply(RING_SIDE_HOR);
TextureAtlasSprite ringSideVer = spriteGetter.apply(RING_SIDE_VER);
switch( this.type )
{
case UNIT:
return new UnitBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ) );
case ACCELERATOR:
case STORAGE_1K:
case STORAGE_4K:
case STORAGE_16K:
case STORAGE_64K:
return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter
.apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) );
case MONITOR:
return new MonitorBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter.apply( UNIT_BASE ), spriteGetter
.apply( MONITOR_BASE ), spriteGetter.apply(
MONITOR_LIGHT_DARK ), spriteGetter.apply( MONITOR_LIGHT_MEDIUM ), spriteGetter.apply( MONITOR_LIGHT_BRIGHT ) );
default:
throw new IllegalArgumentException( "Unsupported crafting unit type: " + this.type );
}
}
switch (this.type) {
case UNIT:
return new UnitBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(UNIT_BASE));
case ACCELERATOR:
case STORAGE_1K:
case STORAGE_4K:
case STORAGE_16K:
case STORAGE_64K:
return new LightBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(LIGHT_BASE),
getLightTexture(spriteGetter, this.type));
case MONITOR:
return new MonitorBakedModel(ringCorner, ringSideHor, ringSideVer, spriteGetter.apply(UNIT_BASE),
spriteGetter.apply(MONITOR_BASE), spriteGetter.apply(MONITOR_LIGHT_DARK),
spriteGetter.apply(MONITOR_LIGHT_MEDIUM), spriteGetter.apply(MONITOR_LIGHT_BRIGHT));
default:
throw new IllegalArgumentException("Unsupported crafting unit type: " + this.type);
}
}
private static TextureAtlasSprite getLightTexture( Function<Material, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
{
switch( type )
{
case ACCELERATOR:
return textureGetter.apply( ACCELERATOR_LIGHT );
case STORAGE_1K:
return textureGetter.apply( STORAGE_1K_LIGHT );
case STORAGE_4K:
return textureGetter.apply( STORAGE_4K_LIGHT );
case STORAGE_16K:
return textureGetter.apply( STORAGE_16K_LIGHT );
case STORAGE_64K:
return textureGetter.apply( STORAGE_64K_LIGHT );
default:
throw new IllegalArgumentException( "Crafting unit type " + type + " does not use a light texture." );
}
}
private static TextureAtlasSprite getLightTexture(Function<Material, TextureAtlasSprite> textureGetter,
AbstractCraftingUnitBlock.CraftingUnitType type) {
switch (type) {
case ACCELERATOR:
return textureGetter.apply(ACCELERATOR_LIGHT);
case STORAGE_1K:
return textureGetter.apply(STORAGE_1K_LIGHT);
case STORAGE_4K:
return textureGetter.apply(STORAGE_4K_LIGHT);
case STORAGE_16K:
return textureGetter.apply(STORAGE_16K_LIGHT);
case STORAGE_64K:
return textureGetter.apply(STORAGE_64K_LIGHT);
default:
throw new IllegalArgumentException("Crafting unit type " + type + " does not use a light texture.");
}
}
private static Material texture( String name )
{
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name));
}
private static Material texture(String name) {
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE,
new ResourceLocation(AppEng.MOD_ID, "block/crafting/" + name));
}
}