All GUI compile errors fixed, switched to excludes over includes in gradle build and lots, LOTS of more fixes.

This commit is contained in:
Sebastian Hartte
2020-06-06 21:16:05 +02:00
parent bb453b0d35
commit ff042a394b
209 changed files with 4527 additions and 4479 deletions
@@ -21,22 +21,46 @@ package appeng.client.render;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.util.Direction;
import org.apache.commons.lang3.tuple.Pair;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
public abstract class DelegateBakedModel implements IBakedModel
{
private IBakedModel baseModel;
private final IBakedModel baseModel;
protected DelegateBakedModel( IBakedModel base )
{
this.baseModel = base;
}
@Override
@Deprecated
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand) {
return baseModel.getQuads(state, side, rand);
}
@Override
public boolean func_230044_c_() {
return baseModel.func_230044_c_();
}
@Override
public ItemOverrideList getOverrides() {
return baseModel.getOverrides();
}
@Override
public IBakedModel handlePerspective( ItemCameraTransforms.TransformType cameraTransformType, MatrixStack mat )
{
@@ -62,6 +86,19 @@ public abstract class DelegateBakedModel implements IBakedModel
return this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
return this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
return this.baseModel.isBuiltInRenderer();
}
public IBakedModel getBaseModel()
{
return this.baseModel;
@@ -32,6 +32,8 @@ import net.minecraft.client.renderer.TransformationMatrix;
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.Material;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.LivingEntity;
import net.minecraft.fluid.Fluids;
@@ -53,9 +55,9 @@ import appeng.fluids.items.FluidDummyItem;
*/
public class DummyFluidDispatcherBakedModel extends DelegateBakedModel
{
private final Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter;
private final Function<Material, TextureAtlasSprite> bakedTextureGetter;
public DummyFluidDispatcherBakedModel( IBakedModel baseModel, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
public DummyFluidDispatcherBakedModel( IBakedModel baseModel, Function<Material, TextureAtlasSprite> bakedTextureGetter )
{
super( baseModel );
this.bakedTextureGetter = bakedTextureGetter;
@@ -108,7 +110,9 @@ public class DummyFluidDispatcherBakedModel extends DelegateBakedModel
}
FluidAttributes attributes = fluidStack.getFluid().getAttributes();
TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply( attributes.getStillTexture( fluidStack ) );
ResourceLocation stillTexture = attributes.getStillTexture(fluidStack);
Material stillMaterial = new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, stillTexture);
TextureAtlasSprite sprite = DummyFluidDispatcherBakedModel.this.bakedTextureGetter.apply(stillMaterial);
if( sprite == null )
{
return new DummyFluidBakedModel( ImmutableList.of() );
@@ -19,71 +19,39 @@
package appeng.client.render;
import appeng.core.AppEng;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
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.Collections;
import java.util.Set;
import java.util.function.Function;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState;
import appeng.core.AppEng;
/**
* The model class for facades. Since facades wrap existing models, they don't declare any dependencies here other
* than the cable anchor.
*/
public class DummyFluidItemModel implements IModel
public class DummyFluidItemModel implements IModelGeometry<DummyFluidItemModel>
{
// We use this to get the default item transforms and make our lives easier
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/dummy_fluid_item_base" );
private IModel baseModel = null;
@Override
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
IBakedModel bakedBaseModel = bakery.getBakedModel(MODEL_BASE, modelTransform, spriteGetter);
private IModel getBaseModel()
{
if( this.baseModel == null )
{
try
{
this.baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
}
return this.baseModel;
return new DummyFluidDispatcherBakedModel( bakedBaseModel, spriteGetter );
}
@Override
public Collection<ResourceLocation> getDependencies()
{
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.emptyList();
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.emptyList();
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
IBakedModel bakedBaseModel = this.getBaseModel().bake( state, format, bakedTextureGetter );
return new DummyFluidDispatcherBakedModel( bakedBaseModel, bakedTextureGetter );
}
@Override
public IModelState getDefaultState()
{
return this.getBaseModel().getDefaultState();
}
}
@@ -0,0 +1,32 @@
package appeng.client.render;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.client.model.IModelLoader;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.function.Supplier;
/**
* A quaint model loader that does not accept any additional parameters in JSON.
*/
public class SimpleModelLoader<T extends IModelGeometry<T>> implements IModelLoader<T> {
private final Supplier<T> factory;
public SimpleModelLoader(Supplier<T> factory) {
this.factory = factory;
}
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public T read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
return factory.get();
}
}
@@ -19,25 +19,20 @@
package appeng.client.render.crafting;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import javax.annotation.Nullable;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.TileCraftingTile;
import appeng.util.Platform;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.client.render.cablebus.CubeBuilder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
/**
@@ -45,38 +40,34 @@ import appeng.client.render.cablebus.CubeBuilder;
* Primarily this base class handles adding the "ring" that frames the multi-block structure and delegates
* rendering of the "inner" part of each block to the subclasses of this class.
*/
abstract class CraftingCubeBakedModel implements IBakedModel
abstract class CraftingCubeBakedModel implements IDynamicBakedModel
{
private final VertexFormat format;
private final TextureAtlasSprite ringCorner;
private final TextureAtlasSprite ringHor;
private final TextureAtlasSprite ringVer;
CraftingCubeBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
CraftingCubeBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer )
{
this.format = format;
this.ringCorner = ringCorner;
this.ringHor = ringHor;
this.ringVer = ringVer;
}
@Nonnull
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
if( side == null )
{
return Collections.emptyList(); // No generic quads for this model
}
EnumSet<Direction> connections = getConnections( state );
EnumSet<Direction> connections = getConnections( extraData );
List<BakedQuad> quads = new ArrayList<>();
CubeBuilder builder = new CubeBuilder( this.format, quads );
CubeBuilder builder = new CubeBuilder( quads );
builder.setDrawFaces( EnumSet.of( side ) );
@@ -114,7 +105,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
break;
}
this.addInnerCube( side, state, builder, x1, y1, z1, x2, y2, z2 );
this.addInnerCube( side, state, extraData, builder, x1, y1, z1, x2, y2, z2 );
return quads;
}
@@ -194,7 +185,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
// drawn in those directions. Since a corner is drawn if the three touching faces dont have adjacent
// crafting cube blocks, we'd have to check for a, side, and the perpendicular direction. But in this
// block, we've already checked for side (due to face culling) and a (see above).
Direction perpendicular = a.rotateAround( side.getAxis() );
Direction perpendicular = Platform.rotateAround( a, side );
for( Direction cornerCandidate : EnumSet.of( perpendicular, perpendicular.getOpposite() ) )
{
if( !connections.contains( cornerCandidate ) )
@@ -256,15 +247,9 @@ abstract class CraftingCubeBakedModel implements IBakedModel
// Retrieve the cube connection state from the block state
// If none is present, just assume there are no adjacent crafting cube blocks
private static EnumSet<Direction> getConnections( @Nullable BlockState state )
private static EnumSet<Direction> getConnections( IModelData modelData )
{
if( !( state instanceof IExtendedBlockState ) )
{
return EnumSet.noneOf( Direction.class );
}
IExtendedBlockState extState = (IExtendedBlockState) state;
CraftingCubeState cubeState = extState.getValue( AbstractCraftingUnitBlock.STATE );
CraftingCubeState cubeState = modelData.getData( TileCraftingTile.STATE );
if( cubeState == null )
{
return EnumSet.noneOf( Direction.class );
@@ -273,7 +258,7 @@ abstract class CraftingCubeBakedModel implements IBakedModel
return cubeState.getConnections();
}
protected abstract void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 );
protected abstract void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2);
@Override
public boolean isAmbientOcclusion()
@@ -300,14 +285,13 @@ abstract class CraftingCubeBakedModel implements IBakedModel
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return ItemCameraTransforms.DEFAULT;
public boolean func_230044_c_() {
return false;
}
@Override
public ItemOverrideList getOverrides()
{
public ItemOverrideList getOverrides() {
return ItemOverrideList.EMPTY;
}
}
@@ -19,44 +19,42 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import com.google.common.collect.ImmutableList;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
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;
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;
/**
* The built-in model for the connected texture crafting cube.
*/
class CraftingCubeModel implements IModel
class CraftingCubeModel implements IModelGeometry<CraftingCubeModel>
{
private final static ResourceLocation RING_CORNER = texture( "ring_corner" );
private final static ResourceLocation RING_SIDE_HOR = texture( "ring_side_hor" );
private final static ResourceLocation RING_SIDE_VER = texture( "ring_side_ver" );
private final static ResourceLocation UNIT_BASE = texture( "unit_base" );
private final static ResourceLocation LIGHT_BASE = texture( "light_base" );
private final static ResourceLocation ACCELERATOR_LIGHT = texture( "accelerator_light" );
private final static ResourceLocation STORAGE_1K_LIGHT = texture( "storage_1k_light" );
private final static ResourceLocation STORAGE_4K_LIGHT = texture( "storage_4k_light" );
private final static ResourceLocation STORAGE_16K_LIGHT = texture( "storage_16k_light" );
private final static ResourceLocation STORAGE_64K_LIGHT = texture( "storage_64k_light" );
private final static ResourceLocation MONITOR_BASE = texture( "monitor_base" );
private final static ResourceLocation MONITOR_LIGHT_DARK = texture( "monitor_light_dark" );
private final static ResourceLocation MONITOR_LIGHT_MEDIUM = texture( "monitor_light_medium" );
private final static ResourceLocation 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( "storage_1k_light" );
private final static Material STORAGE_4K_LIGHT = texture( "storage_4k_light" );
private final static Material STORAGE_16K_LIGHT = texture( "storage_16k_light" );
private final static Material STORAGE_64K_LIGHT = texture( "storage_64k_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;
@@ -66,47 +64,39 @@ class CraftingCubeModel implements IModel
}
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.emptyList();
}
@Override
public Collection<ResourceLocation> getTextures()
{
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( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
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 = bakedTextureGetter.apply( RING_CORNER );
TextureAtlasSprite ringSideHor = bakedTextureGetter.apply( RING_SIDE_HOR );
TextureAtlasSprite ringSideVer = bakedTextureGetter.apply( RING_SIDE_VER );
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( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ) );
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( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter
.apply( LIGHT_BASE ), getLightTexture( bakedTextureGetter, this.type ) );
return new LightBakedModel( ringCorner, ringSideHor, ringSideVer, spriteGetter
.apply( LIGHT_BASE ), getLightTexture( spriteGetter, this.type ) );
case MONITOR:
return new MonitorBakedModel( format, ringCorner, ringSideHor, ringSideVer, bakedTextureGetter.apply( UNIT_BASE ), bakedTextureGetter
.apply( MONITOR_BASE ), bakedTextureGetter.apply(
MONITOR_LIGHT_DARK ), bakedTextureGetter.apply( MONITOR_LIGHT_MEDIUM ), bakedTextureGetter.apply( MONITOR_LIGHT_BRIGHT ) );
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<ResourceLocation, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
private static TextureAtlasSprite getLightTexture( Function<Material, TextureAtlasSprite> textureGetter, AbstractCraftingUnitBlock.CraftingUnitType type )
{
switch( type )
{
@@ -125,14 +115,8 @@ class CraftingCubeModel implements IModel
}
}
@Override
public IModelState getDefaultState()
private static Material texture( String name )
{
return TRSRTransformation.identity();
}
private static ResourceLocation texture( String name )
{
return new ResourceLocation( AppEng.MOD_ID, "blocks/crafting/" + name );
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation(AppEng.MOD_ID, "blocks/crafting/" + name));
}
}
@@ -0,0 +1,61 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.crafting;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.client.model.IModelLoader;
/**
* Loader that allows access to the built-in crafting cube model from block-model JSONs.
*/
public class CraftingCubeModelLoader implements IModelLoader<CraftingCubeModel>
{
public static final CraftingCubeModelLoader INSTANCE = new CraftingCubeModelLoader();
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public CraftingCubeModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
AbstractCraftingUnitBlock.CraftingUnitType unitType = null;
JsonElement typeEl = modelContents.get("type");
if (typeEl != null) {
String typeName = deserializationContext.deserialize(typeEl, String.class);
if (typeName != null) {
unitType = AbstractCraftingUnitBlock.CraftingUnitType.valueOf(typeName.toUpperCase());
}
}
if (unitType == null) {
throw new JsonParseException("type property is missing");
}
return new CraftingCubeModel(unitType);
}
}
@@ -0,0 +1,25 @@
package appeng.client.render.crafting;
import com.mojang.blaze3d.matrix.MatrixStack;
import net.minecraft.client.renderer.IRenderTypeBuffer;
import net.minecraft.client.renderer.tileentity.ItemStackTileEntityRenderer;
import net.minecraft.item.ItemStack;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
/**
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
* held), and showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
* the pattern is being rendered in the GUI, and not anywhere else.
*/
@OnlyIn(Dist.CLIENT)
public class EncodedPatternRenderer extends ItemStackTileEntityRenderer {
@Override
public void render(ItemStack is, MatrixStack ms, IRenderTypeBuffer buffers, int combinedLight, int combinedOverlay) {
}
}
@@ -1,242 +0,0 @@
package appeng.client.render.crafting;
import java.util.List;
import javax.annotation.Nullable;
import javax.vecmath.Matrix4f;
import com.google.common.collect.ImmutableMap;
import org.apache.commons.lang3.tuple.Pair;
import org.lwjgl.input.Keyboard;
import net.minecraft.block.BlockState;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Direction;
import net.minecraft.world.World;
import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.items.misc.ItemEncodedPattern;
/**
* This special model handles switching between rendering the crafting output of an encoded pattern (when shift is being
* held), and
* showing the encoded pattern itself. Matters are further complicated by only wanting to show the crafting output when
* the pattern is being
* rendered in the GUI, and not anywhere else.
*/
class ItemEncodedPatternBakedModel implements IBakedModel
{
private final IBakedModel baseModel;
private final ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms;
private final CustomOverrideList overrides;
ItemEncodedPatternBakedModel( IBakedModel baseModel, ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms )
{
this.baseModel = baseModel;
this.transforms = transforms;
this.overrides = new CustomOverrideList();
}
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
return this.baseModel.getQuads( state, side, rand );
}
@Override
public boolean isAmbientOcclusion()
{
return this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
return this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
return this.baseModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.baseModel.getParticleTexture();
}
@Override
@Deprecated
public ItemCameraTransforms getItemCameraTransforms()
{
return this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
return this.overrides;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
{
if( this.baseModel instanceof IBakedModel )
{
return this.baseModel.handlePerspective( cameraTransformType );
}
return PerspectiveMapWrapper.handlePerspective( this, this.transforms, cameraTransformType );
}
/**
* Since the ItemOverrideList handling comes before handling the perspective awareness (which is the first place
* where we
* know how we are being rendered) we need to remember the model of the crafting output, and make the decision on
* which to render later on.
* Sadly, Forge is pretty inconsistent when it will call the handlePerspective method, so some methods are called
* even on this interim-model.
* Usually those methods only matter for rendering on the ground and other cases, where we wouldn't render the
* crafting output model anyway,
* so in those cases we delegate to the model of the encoded pattern.
*/
private class ShiftHoldingModelWrapper implements IBakedModel
{
private final IBakedModel outputModel;
private ShiftHoldingModelWrapper( IBakedModel outputModel )
{
this.outputModel = outputModel;
}
@Override
public Pair<? extends IBakedModel, Matrix4f> handlePerspective( ItemCameraTransforms.TransformType cameraTransformType )
{
final IBakedModel selectedModel;
// No need to re-check for shift being held since this model is only handed out in that case
if( cameraTransformType == ItemCameraTransforms.TransformType.GUI )
{
selectedModel = this.outputModel;
}
else
{
selectedModel = ItemEncodedPatternBakedModel.this.baseModel;
}
// Now retroactively handle the isGui3d call, for which we always return false below
if( selectedModel.isGui3d() != ItemEncodedPatternBakedModel.this.baseModel.isGui3d() )
{
RenderSystem.enableLighting();
}
if( selectedModel instanceof IBakedModel )
{
return selectedModel.handlePerspective( cameraTransformType );
}
return PerspectiveMapWrapper.handlePerspective( this, ItemEncodedPatternBakedModel.this.transforms, cameraTransformType );
}
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getQuads( state, side, rand );
}
@Override
public boolean isAmbientOcclusion()
{
return ItemEncodedPatternBakedModel.this.baseModel.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
// NOTE: Sadly, Forge will let Minecraft call this method before handling the perspective awareness
return ItemEncodedPatternBakedModel.this.baseModel.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.isBuiltInRenderer();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
// This may be called for items on the ground, in which case we will always fall back to the pattern
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides();
}
}
/**
* Item Override Lists are the only point during item rendering where we can access the item stack that is being
* rendered.
* So this is the point where we actually check if shift is being held, and if so, determine the crafting output
* model.
*/
private class CustomOverrideList extends ItemOverrideList
{
CustomOverrideList()
{
super( ItemEncodedPatternBakedModel.this.baseModel.getOverrides().getOverrides() );
}
@Override
public IBakedModel handleItemState( IBakedModel originalModel, ItemStack stack, World world, LivingEntity entity )
{
boolean shiftHeld = Keyboard.isKeyDown( GLFW.GLFW_KEY_LSHIFT ) || Keyboard.isKeyDown( GLFW.GLFW_KEY_RSHIFT );
if( shiftHeld )
{
ItemEncodedPattern iep = (ItemEncodedPattern) stack.getItem();
ItemStack output = iep.getOutput( stack );
if( !output.isEmpty() )
{
IBakedModel realModel = Minecraft.getInstance().getRenderItem().getItemModelMesher().getItemModel( output );
// Give the item model a chance to handle the overrides as well
realModel = realModel.getOverrides().handleItemState( realModel, output, world, entity );
return new ShiftHoldingModelWrapper( realModel );
}
}
return ItemEncodedPatternBakedModel.this.baseModel.getOverrides().handleItemState( originalModel, stack, world, entity );
}
}
}
@@ -1,68 +0,0 @@
package appeng.client.render.crafting;
import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.client.model.PerspectiveMapWrapper;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.core.AppEng;
/**
* Simple model for the encoded pattern built-in baked model.
*/
class ItemEncodedPatternModel implements IModel
{
private static final ResourceLocation BASE_MODEL = new ResourceLocation( AppEng.MOD_ID, "item/encoded_pattern" );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( BASE_MODEL );
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.emptyList();
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
IBakedModel baseModel;
try
{
baseModel = ModelLoaderRegistry.getModel( BASE_MODEL ).bake( state, format, bakedTextureGetter );
}
catch( Exception e )
{
throw new RuntimeException( e );
}
ImmutableMap<ItemCameraTransforms.TransformType, TRSRTransformation> transforms = PerspectiveMapWrapper.getTransforms( state );
return new ItemEncodedPatternBakedModel( baseModel, transforms );
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
}
}
@@ -26,6 +26,7 @@ import net.minecraft.util.Direction;
import appeng.block.crafting.AbstractCraftingUnitBlock;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -39,15 +40,15 @@ class LightBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite lightTexture;
LightBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
LightBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite baseTexture, TextureAtlasSprite lightTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.baseTexture = baseTexture;
this.lightTexture = lightTexture;
}
@Override
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
builder.setTexture( this.baseTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
@@ -19,15 +19,14 @@
package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.api.util.AEColor;
import appeng.block.crafting.BlockCraftingMonitor;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.crafting.TileCraftingMonitorTile;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -50,9 +49,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite lightBrightTexture;
MonitorBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
MonitorBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite chassisTexture, TextureAtlasSprite baseTexture, TextureAtlasSprite lightDarkTexture, TextureAtlasSprite lightMediumTexture, TextureAtlasSprite lightBrightTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.chassisTexture = chassisTexture;
this.baseTexture = baseTexture;
this.lightDarkTexture = lightDarkTexture;
@@ -61,9 +60,9 @@ class MonitorBakedModel extends CraftingCubeBakedModel
}
@Override
protected void addInnerCube( Direction side, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction side, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
Direction forward = getForward( state );
Direction forward = getForward( modelData );
// For sides other than the front, use the chassis texture
if( side != forward )
@@ -77,7 +76,7 @@ class MonitorBakedModel extends CraftingCubeBakedModel
builder.addCube( x1, y1, z1, x2, y2, z2 );
// Now add the three layered light textures
AEColor color = getColor( state );
AEColor color = getColor( modelData );
boolean powered = state.get( BlockCraftingMonitor.POWERED );
builder.setRenderFullBright( powered );
@@ -96,31 +95,20 @@ class MonitorBakedModel extends CraftingCubeBakedModel
}
private static AEColor getColor( BlockState state )
{
if( state instanceof IExtendedBlockState )
{
IExtendedBlockState extState = (IExtendedBlockState) state;
AEColor color = extState.getValue( BlockCraftingMonitor.COLOR );
if( color != null )
{
return color;
}
private static AEColor getColor(IModelData modelData) {
AEColor color = modelData.getData(TileCraftingMonitorTile.COLOR);
if (color != null) {
return color;
}
return AEColor.TRANSPARENT;
}
private static Direction getForward( BlockState state )
{
if( state instanceof IExtendedBlockState )
{
IExtendedBlockState extState = (IExtendedBlockState) state;
Direction forward = extState.getValue( BlockCraftingMonitor.FORWARD );
if( forward != null )
{
return forward;
}
private static Direction getForward(IModelData modelData) {
Direction forward = modelData.getData(BlockCraftingMonitor.FORWARD);
if (forward != null) {
return forward;
}
return Direction.NORTH;
@@ -21,10 +21,10 @@ package appeng.client.render.crafting;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import appeng.client.render.cablebus.CubeBuilder;
import net.minecraftforge.client.model.data.IModelData;
/**
@@ -35,14 +35,14 @@ class UnitBakedModel extends CraftingCubeBakedModel
private final TextureAtlasSprite unitTexture;
UnitBakedModel( VertexFormat format, TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
UnitBakedModel( TextureAtlasSprite ringCorner, TextureAtlasSprite ringHor, TextureAtlasSprite ringVer, TextureAtlasSprite unitTexture )
{
super( format, ringCorner, ringHor, ringVer );
super( ringCorner, ringHor, ringVer );
this.unitTexture = unitTexture;
}
@Override
protected void addInnerCube( Direction facing, BlockState state, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2 )
protected void addInnerCube(Direction facing, BlockState state, IModelData modelData, CubeBuilder builder, float x1, float y1, float z1, float x2, float y2, float z2)
{
builder.setTexture( this.unitTexture );
builder.addCube( x1, y1, z1, x2, y2, z2 );
@@ -20,12 +20,24 @@ package appeng.client.render.effects;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.IParticleRenderType;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.command.arguments.ItemInput;
import net.minecraft.command.arguments.ItemParser;
import net.minecraft.entity.Entity;
import net.minecraft.item.ItemStack;
import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleType;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.World;
import appeng.api.storage.data.IAEItemStack;
@@ -33,23 +45,32 @@ import appeng.client.EffectType;
import appeng.core.AppEng;
import appeng.entity.EntityFloatingItem;
import appeng.entity.ICanDie;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import java.util.Locale;
public class AssemblerFX extends Particle implements ICanDie
{
public static final ParticleType<AssemblerParticleData> TYPE = new ParticleType<>(false, new AssemblerParticleData.Deserializer());
static {
TYPE.setRegistryName(AppEng.MOD_ID, "assembler_fx");
}
private final EntityFloatingItem fi;
private final float speed;
private float time = 0;
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final IAEItemStack is )
public AssemblerFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final float speed, final ItemStack displayItem )
{
super( w, x, y, z, r, g, b );
this.motionX = 0;
this.motionY = 0;
this.motionZ = 0;
this.speed = speed;
final ItemStack displayItem = is.asItemStackRepresentation();
this.fi = new EntityFloatingItem( this, w, x, y, z, displayItem );
w.addEntity( this.fi );
this.maxAge = (int) Math.ceil( Math.max( 1, 100.0f / speed ) ) + 2;
@@ -99,7 +120,6 @@ public class AssemblerFX extends Particle implements ICanDie
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.NO_RENDER;
}
@@ -117,4 +137,102 @@ public class AssemblerFX extends Particle implements ICanDie
}
}
}
public static class AssemblerParticleData implements IParticleData {
private final float r;
private final float g;
private final float b;
private final float speed;
private final ItemStack itemStack;
public AssemblerParticleData(float r, float g, float b, float speed, ItemStack itemStack) {
this.r = r;
this.g = g;
this.b = b;
this.speed = speed;
this.itemStack = itemStack;
}
@Override
public ParticleType<?> getType() {
return TYPE;
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeFloat(r);
buffer.writeFloat(g);
buffer.writeFloat(b);
buffer.writeFloat(speed);
buffer.writeItemStack(itemStack);
}
public static class Deserializer implements IDeserializer<AssemblerParticleData> {
@Override
public AssemblerParticleData deserialize(ParticleType<AssemblerParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float r = reader.readFloat();
reader.expect(' ');
float g = reader.readFloat();
reader.expect(' ');
float b = reader.readFloat();
reader.expect(' ');
float speed = reader.readFloat();
reader.expect(' ');
ItemParser itemparser = (new ItemParser(reader, false)).parse();
ItemStack itemstack = (new ItemInput(itemparser.getItem(), itemparser.getNbt())).createStack(1, false);
return new AssemblerParticleData(r, g, b, speed, itemstack);
}
@Override
public AssemblerParticleData read(ParticleType<AssemblerParticleData> particleTypeIn, PacketBuffer buffer) {
float r = buffer.readFloat();
float g = buffer.readFloat();
float b = buffer.readFloat();
float speed = buffer.readFloat();
ItemStack itemStack = buffer.readItemStack();
return new AssemblerParticleData(r, g, b, speed, itemStack);
}
}
@Override
public String getParameters() {
return String.format(Locale.ROOT, "%s %.2f %.2f %.2f %.2f ", Registry.PARTICLE_TYPE.getKey(this.getType()), this.r, this.g, this.b, this.speed)
+ (new ItemInput(this.itemStack.getItem(), this.itemStack.getTag())).serialize();
}
public float getR() {
return r;
}
public float getG() {
return g;
}
public float getB() {
return b;
}
public float getSpeed() {
return speed;
}
public ItemStack getItemStack() {
return itemStack;
}
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<AssemblerParticleData> {
public Factory(IAnimatedSprite spriteSet) {
}
public Particle makeParticle(AssemblerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new AssemblerFX(world, x, y, z, data.r, data.g, data.b, data.speed, data.itemStack);
}
}
}
@@ -19,130 +19,120 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.BreakingParticle;
import net.minecraft.client.particle.IParticleRenderType;
import appeng.core.AppEng;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.particles.ItemParticleData;
import net.minecraft.particles.ParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import appeng.api.util.AEPartLocation;
import appeng.client.render.textures.ParticleTextures;
@OnlyIn( Dist.CLIENT )
public class CraftingFx extends BreakingParticle
{
private final TextureAtlasSprite particleTextureIndex;
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "crafting_fx");
}
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public CraftingFx( final World par1World, final double par2, final double par4, final double par6, final Item par8Item )
public CraftingFx( final World par1World, final double x, final double y, final double z, final IAnimatedSprite sprite )
{
super( par1World, par2, par4, par6, par8Item );
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 0.9f;
this.particleRed = 1;
this.particleAlpha = 1.3f;
this.particleScale = 1.5f;
this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
this.selectSpriteRandomly(sprite);
this.maxAge /= 1.2;
this.startBlkX = MathHelper.floor( this.getPosX() );
this.startBlkY = MathHelper.floor( this.getPosY() );
this.startBlkZ = MathHelper.floor( this.getPosZ() );
this.startBlkX = MathHelper.floor( this.posX );
this.startBlkY = MathHelper.floor( this.posY );
this.startBlkZ = MathHelper.floor( this.posZ );
}
@Override
public int getFXLayer()
{
return 1;
}
public void renderParticle(IVertexBuilder buffer, ActiveRenderInfo renderInfo, float partialTicks) {
@Override
public IParticleRenderType getRenderType() {
// TODO: FIXME
return IParticleRenderType.NO_RENDER;
}
@Override
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float partialTick, final float x, final float y, final float z, final float rx, final float rz )
{
if( partialTick < 0 || partialTick > 1 )
if( partialTicks < 0 || partialTicks > 1 )
{
return;
}
final float f6 = this.particleTextureIndex.getMinU();
final float f7 = this.particleTextureIndex.getMaxU();
final float f8 = this.particleTextureIndex.getMinV();
final float f9 = this.particleTextureIndex.getMaxV();
final float scale = 0.1F * this.particleScale;
float offX = (float) ( this.prevPosX + ( this.getPosX() - this.prevPosX ) * partialTick );
float offY = (float) ( this.prevPosY + ( this.getPosY() - this.prevPosY ) * partialTick );
float offZ = (float) ( this.prevPosZ + ( this.getPosZ() - this.prevPosZ ) * partialTick );
float offX = (float)(MathHelper.lerp(partialTicks, this.prevPosX, this.posX));
float offY = (float)(MathHelper.lerp(partialTicks, this.prevPosY, this.posY));
float offZ = (float)(MathHelper.lerp(partialTicks, this.prevPosZ, this.posZ));
final int blkX = MathHelper.floor( offX );
final int blkY = MathHelper.floor( offY );
final int blkZ = MathHelper.floor( offZ );
// I believe this particle is same as breaking particle, but should not exit the original block it was
// spawned in (which is encased in glass)
if( blkX == this.startBlkX && blkY == this.startBlkY && blkZ == this.startBlkZ )
{
offX -= interpPosX;
offY -= interpPosY;
offZ -= interpPosZ;
Vec3d vec3d = renderInfo.getProjectedView();
offX -= vec3d.x;
offY -= vec3d.y;
offZ -= vec3d.z;
int i = this.getBrightnessForRender( partialTick );
int j = i >> 16 & 65535;
int k = i & 65535;
Vector3f[] avector3f = new Vector3f[]{new Vector3f(-1.0F, -1.0F, 0.0F), new Vector3f(-1.0F, 1.0F, 0.0F), new Vector3f(1.0F, 1.0F, 0.0F), new Vector3f(1.0F, -1.0F, 0.0F)};
float scale = this.getScale(partialTicks);
// AELog.info( "" + partialTick );
final float f14 = 1.0F;
par1Tessellator.pos( offX - x * scale - rx * scale, offY - y * scale, offZ - z * scale - rz * scale )
.tex( f7, f9 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( offX - x * scale + rx * scale, offY + y * scale, offZ - z * scale + rz * scale )
.tex( f7, f8 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( offX + x * scale + rx * scale, offY + y * scale, offZ + z * scale + rz * scale )
.tex( f6, f8 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( offX + x * scale - rx * scale, offY - y * scale, offZ + z * scale - rz * scale )
.tex( f6, f9 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
for(int i = 0; i < 4; ++i) {
Vector3f vector3f = avector3f[i];
vector3f.transform(renderInfo.getRotation());
vector3f.mul(scale);
vector3f.add(offX, offY, offZ);
}
float minU = this.getMinU();
float maxU = this.getMaxU();
float minV = this.getMinV();
float maxV = this.getMaxV();
int j = this.getBrightnessForRender(partialTicks);
buffer.pos(avector3f[0].getX(), avector3f[0].getY(), avector3f[0].getZ()).tex(maxU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[1].getX(), avector3f[1].getY(), avector3f[1].getZ()).tex(maxU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[2].getX(), avector3f[2].getY(), avector3f[2].getZ()).tex(minU, minV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
buffer.pos(avector3f[3].getX(), avector3f[3].getY(), avector3f[3].getZ()).tex(minU, maxV).color(this.particleRed, this.particleGreen, this.particleBlue, this.particleAlpha).lightmap(j).endVertex();
}
}
public void fromItem( final AEPartLocation d )
{
this.getPosX() += 0.2 * d.xOffset;
this.getPosY() += 0.2 * d.yOffset;
this.getPosZ() += 0.2 * d.zOffset;
this.posX += 0.2 * d.xOffset;
this.posY += 0.2 * d.yOffset;
this.posZ += 0.2 * d.zOffset;
this.particleScale *= 0.8f;
}
@Override
public void tick()
{
this.prevPosX = this.getPosX();
this.prevPosY = this.getPosY();
this.prevPosZ = this.getPosZ();
this.prevPosX = this.posX;
this.prevPosY = this.posY;
this.prevPosZ = this.posZ;
if( this.age++ >= this.maxAge )
{
@@ -172,4 +162,18 @@ public class CraftingFx extends BreakingParticle
{
this.motionZ = motionZ;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite p_i50477_1_) {
this.spriteSet = p_i50477_1_;
}
public Particle makeParticle(BasicParticleType data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new CraftingFx(worldIn, x, y, z, spriteSet);
}
}
}
@@ -19,13 +19,15 @@
package appeng.client.render.effects;
import net.minecraft.client.particle.BreakingParticle;
import net.minecraft.client.particle.IParticleRenderType;
import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
@@ -38,22 +40,26 @@ import appeng.api.util.AEPartLocation;
public class EnergyFx extends BreakingParticle
{
// FIXME private final TextureAtlasSprite particleTextureIndex;
public static final BasicParticleType TYPE = new BasicParticleType(false);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "energy_fx");
}
private final int startBlkX;
private final int startBlkY;
private final int startBlkZ;
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final ItemStack par8Item )
public EnergyFx( final World par1World, final double par2, final double par4, final double par6, final IAnimatedSprite sprite )
{
super( par1World, par2, par4, par6, par8Item );
super( par1World, par2, par4, par6, new ItemStack(Items.DIAMOND) );
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
this.particleRed = 1;
this.particleAlpha = 1.4f;
this.particleScale = 3.5f;
// FIXME this.particleTextureIndex = ParticleTextures.BlockEnergyParticle;
this.selectSpriteRandomly(sprite);
this.startBlkX = MathHelper.floor( this.posX );
this.startBlkY = MathHelper.floor( this.posY );
@@ -163,4 +169,22 @@ public class EnergyFx extends BreakingParticle
{
this.motionZ = motionZ;
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
EnergyFx result = new EnergyFx(worldIn, x, y, z, spriteSet);
result.setMotionX((float) xSpeed);
result.setMotionY((float) ySpeed);
result.setMotionZ((float) zSpeed);
return result;
}
}
}
@@ -21,11 +21,23 @@ package appeng.client.render.effects;
import java.util.Random;
import appeng.core.AppEng;
import net.minecraft.client.particle.*;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.particles.ParticleType;
import net.minecraft.world.World;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class LightningArcFX extends LightningFX
{
public static final ParticleType<LightningArcParticleData> TYPE = new ParticleType<>(false, LightningArcParticleData.DESERIALIZER);
static {
TYPE.setRegistryName(AppEng.MOD_ID, "lightning_arc_fx");
}
private static final Random RANDOM_GENERATOR = new Random();
private final double rx;
@@ -61,4 +73,20 @@ public class LightningArcFX extends LightningFX
localSteps[s][2] = ( lastDirectionZ + ( RANDOM_GENERATOR.nextDouble() - 0.5 ) * len * 1.2 ) / 2.0;
}
}
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<LightningArcParticleData> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(LightningArcParticleData data, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
SpriteTexturedParticle lightningFX = new LightningArcFX(worldIn, x, y, z, data.target.x, data.target.y, data.target.z, 0, 0, 0);
lightningFX.selectSpriteRandomly(this.spriteSet);
return lightningFX;
}
}
}
@@ -0,0 +1,61 @@
package appeng.client.render.effects;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.sun.javafx.geom.Vec3f;
import net.minecraft.network.PacketBuffer;
import net.minecraft.particles.IParticleData;
import net.minecraft.particles.ParticleType;
import java.util.Locale;
/**
* Contains the target point of the lightning arc (the source point is infered from the particle starting position).
*/
public class LightningArcParticleData implements IParticleData {
public final Vec3f target;
public LightningArcParticleData(Vec3f target) {
this.target = target;
}
public static final IDeserializer<LightningArcParticleData> DESERIALIZER = new IDeserializer<LightningArcParticleData>() {
@Override
public LightningArcParticleData deserialize(ParticleType<LightningArcParticleData> particleTypeIn, StringReader reader) throws CommandSyntaxException {
reader.expect(' ');
float x = reader.readFloat();
reader.expect(' ');
float y = reader.readFloat();
reader.expect(' ');
float z = reader.readFloat();
return new LightningArcParticleData(new Vec3f(x, y, z));
}
@Override
public LightningArcParticleData read(ParticleType<LightningArcParticleData> particleTypeIn, PacketBuffer buffer) {
float x = buffer.readFloat();
float y = buffer.readFloat();
float z = buffer.readFloat();
return new LightningArcParticleData(new Vec3f(x, y, z));
}
};
@Override
public ParticleType<?> getType() {
return LightningArcFX.TYPE;
}
@Override
public void write(PacketBuffer buffer) {
buffer.writeFloat(target.x);
buffer.writeFloat(target.y);
buffer.writeFloat(target.z);
}
@Override
public String getParameters() {
return String.format(Locale.ROOT, "%.2f %.2f %.2f", target.x, target.y, target.z);
}
}
@@ -62,7 +62,7 @@ public class LightningFX extends SpriteTexturedParticle
this.regen();
}
private LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
protected LightningFX( final World w, final double x, final double y, final double z, final double r, final double g, final double b, final int maxAge )
{
super( w, x, y, z, r, g, b );
this.precomputedSteps = new double[LightningFX.STEPS][3];
@@ -19,26 +19,37 @@
package appeng.client.render.effects;
import appeng.core.AppEng;
import com.mojang.blaze3d.vertex.IVertexBuilder;
import net.minecraft.client.particle.BreakingParticle;
import net.minecraft.client.particle.IAnimatedSprite;
import net.minecraft.client.particle.IParticleFactory;
import net.minecraft.client.particle.Particle;
import net.minecraft.client.renderer.ActiveRenderInfo;
import net.minecraft.client.renderer.BufferBuilder;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.entity.Entity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.particles.BasicParticleType;
import net.minecraft.world.World;
import appeng.api.util.AEPartLocation;
import appeng.client.render.textures.ParticleTextures;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
public class MatterCannonFX extends BreakingParticle
{
private final TextureAtlasSprite particleTextureIndex;
public static final BasicParticleType TYPE = new BasicParticleType(false);
public MatterCannonFX( final World par1World, final double par2, final double par4, final double par6, final ItemStack par8Item )
static {
TYPE.setRegistryName(AppEng.MOD_ID, "matter_cannon_fx");
}
public MatterCannonFX( final World par1World, final double x, final double y, final double z, IAnimatedSprite sprite )
{
super( par1World, par2, par4, par6, par8Item );
super( par1World, x, y, z, new ItemStack(Items.DIAMOND) );
this.particleGravity = 0;
this.particleBlue = 1;
this.particleGreen = 1;
@@ -48,7 +59,7 @@ public class MatterCannonFX extends BreakingParticle
this.motionX = 0.0f;
this.motionY = 0.0f;
this.motionZ = 0.0f;
this.particleTextureIndex = ParticleTextures.BlockMatterCannonParticle;
this.selectSpriteRandomly(sprite);
}
public void fromItem( final AEPartLocation d )
@@ -78,49 +89,17 @@ public class MatterCannonFX extends BreakingParticle
this.particleAlpha *= 0.59f;
}
@Override
public int getFXLayer()
{
return 1;
@OnlyIn(Dist.CLIENT)
public static class Factory implements IParticleFactory<BasicParticleType> {
private final IAnimatedSprite spriteSet;
public Factory(IAnimatedSprite spriteSet) {
this.spriteSet = spriteSet;
}
public Particle makeParticle(BasicParticleType data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
return new MatterCannonFX(world, x, y, z, spriteSet);
}
}
@Override
public void renderParticle( final BufferBuilder par1Tessellator, final Entity p_180434_2_, final float par2, final float par3, final float par4, final float par5, final float par6, final float par7 )
{
final float f6 = this.particleTextureIndex.getMinU();
final float f7 = this.particleTextureIndex.getMaxU();
final float f8 = this.particleTextureIndex.getMinV();
final float f9 = this.particleTextureIndex.getMaxV();
final float f10 = 0.05F * this.particleScale;
final float f11 = (float) ( this.prevPosX + ( this.posX - this.prevPosX ) * par2 - interpPosX );
final float f12 = (float) ( this.prevPosY + ( this.posY - this.prevPosY ) * par2 - interpPosY );
final float f13 = (float) ( this.prevPosZ + ( this.posZ - this.prevPosZ ) * par2 - interpPosZ );
final float f14 = 1.0F;
int i = this.getBrightnessForRender( par2 );
int j = i >> 16 & 65535;
int k = i & 65535;
par1Tessellator.pos( f11 - par3 * f10 - par6 * f10, f12 - par4 * f10, f13 - par5 * f10 - par7 * f10 )
.tex( f7, f9 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( f11 - par3 * f10 + par6 * f10, f12 + par4 * f10, f13 - par5 * f10 + par7 * f10 )
.tex( f7, f8 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( f11 + par3 * f10 + par6 * f10, f12 + par4 * f10, f13 + par5 * f10 + par7 * f10 )
.tex( f6, f8 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
par1Tessellator.pos( f11 + par3 * f10 - par6 * f10, f12 - par4 * f10, f13 + par5 * f10 - par7 * f10 )
.tex( f6, f9 )
.color( this.particleRed * f14, this.particleGreen * f14, this.particleBlue * f14, this.particleAlpha )
.lightmap( j, k )
.endVertex();
}
}
@@ -9,48 +9,41 @@ import javax.annotation.Nullable;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
/**
* Model wrapper for the biometric card item model, which combines a base card layer with a "visual hash" of the player
* name
*/
public class BiometricCardModel implements IUnbakedModel
public class BiometricCardModel implements IModelGeometry<BiometricCardModel>
{
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/biometric_card" );
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/biometric_card_hash" ) );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( MODEL_BASE );
}
@Override
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{
return Collections.singleton( TEXTURE );
}
@Nullable
@Override
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform transformIn, ItemOverrideList overrides, ResourceLocation locationIn )
{
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
TextureAtlasSprite texture = spriteGetter.apply( TEXTURE );
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, transformIn, spriteGetter );
return new BiometricCardBakedModel( baseModel, texture );
}
}
@@ -1,76 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.model;
import java.util.Map;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.resources.IResourceManager;
import net.minecraft.resources.IResourceManagerReloadListener;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import net.minecraftforge.client.model.IModelLoader;
/**
* Manages built-in models.
*/
public class BuiltInModelLoader implements IModelLoader
{
private final Map<String, IUnbakedModel> builtInModels;
public BuiltInModelLoader( Map<String, IUnbakedModel> builtInModels )
{
this.builtInModels = ImmutableMap.copyOf( builtInModels );
}
@Override
public boolean accepts( ResourceLocation modelLocation )
{
if( !modelLocation.getNamespace().equals( AppEng.MOD_ID ) )
{
return false;
}
return this.builtInModels.containsKey( modelLocation.getResourcePath() );
}
@Override
public IModel loadModel( ResourceLocation modelLocation ) throws Exception
{
return this.builtInModels.get( modelLocation.getResourcePath() );
}
@Override
public void onResourceManagerReload( IResourceManager resourceManager )
{
for( IModel model : this.builtInModels.values() )
{
if( model instanceof IResourceManagerReloadListener )
{
( (IResourceManagerReloadListener) model ).onResourceManagerReload( resourceManager );
}
}
}
}
@@ -10,24 +10,22 @@ import javax.annotation.Nullable;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import appeng.core.AppEng;
import net.minecraftforge.client.model.geometry.IModelGeometry;
/**
* A color applicator uses the base model, and extends it with additional layers that are colored according to the
* selected color of the applicator.
*/
public class ColorApplicatorModel implements IUnbakedModel
public class ColorApplicatorModel implements IModelGeometry<ColorApplicatorModel>
{
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/color_applicator_colored" );
@@ -37,27 +35,18 @@ public class ColorApplicatorModel implements IUnbakedModel
private static final Material TEXTURE_BRIGHT = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/color_applicator_tip_bright" ) );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( MODEL_BASE );
}
@Override
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Arrays.asList( TEXTURE_DARK, TEXTURE_MEDIUM, TEXTURE_DARK );
}
@Nullable
@Override
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
{
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
TextureAtlasSprite texDark = spriteGetterIn.apply( TEXTURE_DARK );
TextureAtlasSprite texMedium = spriteGetterIn.apply( TEXTURE_MEDIUM );
TextureAtlasSprite texBright = spriteGetterIn.apply( TEXTURE_BRIGHT );
TextureAtlasSprite texDark = spriteGetter.apply( TEXTURE_DARK );
TextureAtlasSprite texMedium = spriteGetter.apply( TEXTURE_MEDIUM );
TextureAtlasSprite texBright = spriteGetter.apply( TEXTURE_BRIGHT );
return new ColorApplicatorBakedModel( baseModel, transformIn, texDark, texMedium, texBright );
return new ColorApplicatorBakedModel( baseModel, modelTransform, texDark, texMedium, texBright );
}
}
@@ -19,53 +19,48 @@
package appeng.client.render.model;
import appeng.block.storage.DriveSlotState;
import appeng.block.storage.DriveSlotsState;
import appeng.client.render.DelegateBakedModel;
import appeng.tile.storage.TileDrive;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IModelData;
import net.minecraftforge.client.model.pipeline.BakedQuadBuilder;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.Matrix4f;
import net.minecraft.client.renderer.Vector3f;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.ItemCameraTransforms;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.pipeline.UnpackedBakedQuad;
import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.block.storage.BlockDrive;
import appeng.block.storage.DriveSlotState;
import appeng.block.storage.DriveSlotsState;
import java.util.Random;
public class DriveBakedModel implements IBakedModel
public class DriveBakedModel extends DelegateBakedModel
{
private final IBakedModel bakedBase;
private final Map<DriveSlotState, IBakedModel> bakedCells;
public DriveBakedModel( IBakedModel bakedBase, Map<DriveSlotState, IBakedModel> bakedCells )
{
super(bakedBase);
this.bakedBase = bakedBase;
this.bakedCells = bakedCells;
}
@Nonnull
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
List<BakedQuad> result = new ArrayList<>();
List<BakedQuad> result = new ArrayList<>(this.bakedBase.getQuads(state, side, rand, extraData));
result.addAll( this.bakedBase.getQuads( state, side, rand ) );
DriveSlotsState slotsState = extraData.getData( TileDrive.SLOTS_STATE );
if( side == null && state instanceof IExtendedBlockState )
if( side == null && slotsState != null )
{
IExtendedBlockState extState = (IExtendedBlockState) state;
DriveSlotsState slotsState = extState.getValue( BlockDrive.SLOTS_STATE );
for( int row = 0; row < 5; row++ )
{
for( int col = 0; col < 2; col++ )
@@ -82,12 +77,12 @@ public class DriveBakedModel implements IBakedModel
float xOffset = -col * 7 / 16.0f;
float yOffset = -row * 3 / 16.0f;
transform.setTranslation( new Vector3f( xOffset, yOffset, 0 ) );
transform.setTranslation( xOffset, yOffset, 0 );
MatrixVertexTransformer transformer = new MatrixVertexTransformer( transform );
for( BakedQuad bakedQuad : bakedCell.getQuads( state, null, rand ) )
for( BakedQuad bakedQuad : bakedCell.getQuads( state, null, rand, extraData ) )
{
UnpackedBakedQuad.Builder builder = new UnpackedBakedQuad.Builder( bakedQuad.getFormat() );
BakedQuadBuilder builder = new BakedQuadBuilder();
transformer.setParent( builder );
transformer.setVertexFormat( builder.getVertexFormat() );
bakedQuad.pipe( transformer );
@@ -100,39 +95,4 @@ public class DriveBakedModel implements IBakedModel
return result;
}
@Override
public boolean isAmbientOcclusion()
{
return this.bakedBase.isAmbientOcclusion();
}
@Override
public boolean isGui3d()
{
return this.bakedBase.isGui3d();
}
@Override
public boolean isBuiltInRenderer()
{
return this.bakedBase.isGui3d();
}
@Override
public TextureAtlasSprite getParticleTexture()
{
return this.bakedBase.getParticleTexture();
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return this.bakedBase.getItemCameraTransforms();
}
@Override
public ItemOverrideList getOverrides()
{
return this.bakedBase.getOverrides();
}
}
@@ -19,28 +19,19 @@
package appeng.client.render.model;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import appeng.block.storage.DriveSlotState;
import com.google.common.collect.ImmutableMap;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.*;
import java.util.function.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.client.model.ModelLoaderRegistry;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.block.storage.DriveSlotState;
public class DriveModel implements IModel
public class DriveModel implements IModelGeometry<DriveModel>
{
private static final ResourceLocation MODEL_BASE = new ResourceLocation( "appliedenergistics2:block/drive_base" );
@@ -53,45 +44,23 @@ public class DriveModel implements IModel
DriveSlotState.FULL, new ResourceLocation( "appliedenergistics2:block/drive_cell_full" ) );
@Override
public Collection<ResourceLocation> getDependencies()
{
return ImmutableList.<ResourceLocation>builder().add( MODEL_BASE ).addAll( MODELS_CELLS.values() ).build();
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Collections.emptyList();
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
EnumMap<DriveSlotState, IBakedModel> cellModels = new EnumMap<>( DriveSlotState.class );
// Load the base model and the model for each cell state.
IModel baseModel;
try
for( DriveSlotState slotState : MODELS_CELLS.keySet() )
{
baseModel = ModelLoaderRegistry.getModel( MODEL_BASE );
for( DriveSlotState slotState : MODELS_CELLS.keySet() )
{
IModel model = ModelLoaderRegistry.getModel( MODELS_CELLS.get( slotState ) );
cellModels.put( slotState, model.bake( state, format, bakedTextureGetter ) );
}
}
catch( Exception e )
{
throw new RuntimeException( e );
IBakedModel cellModel = bakery.getBakedModel( MODELS_CELLS.get( slotState ), modelTransform, spriteGetter );
cellModels.put( slotState, cellModel );
}
IBakedModel bakedBase = baseModel.bake( state, format, bakedTextureGetter );
return new DriveBakedModel( bakedBase, cellModels );
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
return new DriveBakedModel( baseModel, cellModels );
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Collections.emptyList();
}
}
@@ -1,21 +0,0 @@
package appeng.client.render.model;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.client.model.IModelLoader;
public class GlassModelLoader implements IModelLoader<GlassModel> {
public static final GlassModelLoader INSTANCE = new GlassModelLoader();
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public GlassModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
return new GlassModel();
}
}
@@ -9,47 +9,40 @@ import javax.annotation.Nullable;
import com.mojang.datafixers.util.Pair;
import net.minecraft.client.renderer.model.IBakedModel;
import net.minecraft.client.renderer.model.IModelTransform;
import net.minecraft.client.renderer.model.IUnbakedModel;
import net.minecraft.client.renderer.model.Material;
import net.minecraft.client.renderer.model.ModelBakery;
import net.minecraft.client.renderer.model.*;
import net.minecraft.client.renderer.texture.AtlasTexture;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import appeng.core.AppEng;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
/**
* Model wrapper for the memory card item model, which combines a base card layer with a "visual hash" of the part/tile.
*/
public class MemoryCardModel implements IUnbakedModel
public class MemoryCardModel implements IModelGeometry<MemoryCardModel>
{
private static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "item/memory_card" );
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "items/memory_card_hash" ) );
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.singletonList( MODEL_BASE );
}
@Override
public Collection<Material> getTextures( Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
public Collection<Material> getTextures( IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors )
{
return Collections.singleton( TEXTURE );
}
@Nullable
@Override
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation)
{
TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
TextureAtlasSprite texture = spriteGetter.apply( TEXTURE );
IBakedModel baseModel = modelBakeryIn.getBakedModel( MODEL_BASE, transformIn, spriteGetterIn );
IBakedModel baseModel = bakery.getBakedModel( MODEL_BASE, modelTransform, spriteGetter );
return new MemoryCardBakedModel( baseModel, texture );
}
}
@@ -1,44 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.model;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import net.minecraft.resources.IResourceManager;
import net.minecraftforge.client.model.IModelLoader;
/**
* Allows the built-in sky compass model the be loaded from JSON.
*/
public class SkyCompassModelLoader implements IModelLoader<SkyCompassModel> {
public static final SkyCompassModelLoader INSTANCE = new SkyCompassModelLoader();
@Override
public void onResourceManagerReload(IResourceManager resourceManager) {
}
@Override
public SkyCompassModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
return new SkyCompassModel();
}
}
@@ -19,50 +19,43 @@
package appeng.client.render.spatial;
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.block.model.ItemCameraTransforms;
import net.minecraft.client.renderer.block.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.Direction;
import net.minecraftforge.common.property.IExtendedBlockState;
import appeng.block.spatial.BlockSpatialPylon;
import appeng.client.render.cablebus.CubeBuilder;
import appeng.tile.spatial.TileSpatialPylon;
import com.google.common.collect.ImmutableMap;
import net.minecraft.block.BlockState;
import net.minecraft.client.renderer.model.BakedQuad;
import net.minecraft.client.renderer.model.ItemOverrideList;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.Direction;
import net.minecraftforge.client.model.data.IDynamicBakedModel;
import net.minecraftforge.client.model.data.IModelData;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Map;
import java.util.Random;
/**
* The baked model that will be used for rendering the spatial pylon.
*/
class SpatialPylonBakedModel implements IBakedModel
class SpatialPylonBakedModel implements IDynamicBakedModel
{
private final Map<SpatialPylonTextureType, TextureAtlasSprite> textures;
private final VertexFormat format;
SpatialPylonBakedModel( VertexFormat format, Map<SpatialPylonTextureType, TextureAtlasSprite> textures )
SpatialPylonBakedModel( Map<SpatialPylonTextureType, TextureAtlasSprite> textures )
{
this.textures = ImmutableMap.copyOf( textures );
this.format = format;
}
@Nonnull
@Override
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, long rand )
{
int flags = this.getFlags( state );
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, @Nonnull Random rand, @Nonnull IModelData extraData) {
int flags = this.getFlags( extraData );
CubeBuilder builder = new CubeBuilder( this.format );
CubeBuilder builder = new CubeBuilder();
if( flags != 0 )
{
@@ -162,16 +155,10 @@ class SpatialPylonBakedModel implements IBakedModel
return builder.getOutput();
}
private int getFlags( BlockState state )
private int getFlags( IModelData modelData )
{
if( !( state instanceof IExtendedBlockState ) )
{
return 0;
}
IExtendedBlockState extState = (IExtendedBlockState) state;
return extState.getValue( BlockSpatialPylon.STATE );
Integer flags = modelData.getData(TileSpatialPylon.STATE);
return flags != null ? flags : 0;
}
private static SpatialPylonTextureType getTextureTypeFromSideOutside( int flags, Direction ori, Direction dir )
@@ -222,6 +209,11 @@ class SpatialPylonBakedModel implements IBakedModel
return SpatialPylonTextureType.BASE;
}
@Override
public boolean func_230044_c_() {
return false;
}
@Override
public boolean isAmbientOcclusion()
{
@@ -246,12 +238,6 @@ class SpatialPylonBakedModel implements IBakedModel
return this.textures.get( SpatialPylonTextureType.DIM );
}
@Override
public ItemCameraTransforms getItemCameraTransforms()
{
return ItemCameraTransforms.DEFAULT;
}
@Override
public ItemOverrideList getOverrides()
{
@@ -19,62 +19,45 @@
package appeng.client.render.spatial;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.Map;
import appeng.core.AppEng;
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;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModelConfiguration;
import net.minecraftforge.client.model.geometry.IModelGeometry;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import net.minecraft.client.renderer.block.model.IBakedModel;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.client.renderer.vertex.VertexFormat;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.IModel;
import net.minecraftforge.common.model.IModelState;
import net.minecraftforge.common.model.TRSRTransformation;
import appeng.core.AppEng;
class SpatialPylonModel implements IModel
public class SpatialPylonModel implements IModelGeometry<SpatialPylonModel>
{
@Override
public Collection<ResourceLocation> getDependencies()
{
return Collections.emptyList();
}
@Override
public Collection<ResourceLocation> getTextures()
{
return Arrays.stream( SpatialPylonTextureType.values() ).map( SpatialPylonModel::getTexturePath ).collect( Collectors.toList() );
}
@Override
public IBakedModel bake( IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter )
{
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
Map<SpatialPylonTextureType, TextureAtlasSprite> textures = new EnumMap<>( SpatialPylonTextureType.class );
for( SpatialPylonTextureType type : SpatialPylonTextureType.values() )
{
ResourceLocation loc = getTexturePath( type );
textures.put( type, bakedTextureGetter.apply( loc ) );
textures.put( type, spriteGetter.apply(getTexturePath( type )) );
}
return new SpatialPylonBakedModel( format, textures );
return new SpatialPylonBakedModel( textures );
}
@Override
public IModelState getDefaultState()
{
return TRSRTransformation.identity();
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
return Arrays.stream( SpatialPylonTextureType.values() )
.map( SpatialPylonModel::getTexturePath )
.collect( Collectors.toList() );
}
private static ResourceLocation getTexturePath( SpatialPylonTextureType type )
private static Material getTexturePath( SpatialPylonTextureType type )
{
return new ResourceLocation( AppEng.MOD_ID, "blocks/spatial_pylon/" + type.name().toLowerCase() );
return new Material(AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "blocks/spatial_pylon/" + type.name().toLowerCase() ) );
}
}
@@ -1,37 +0,0 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
*
* Applied Energistics 2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Applied Energistics 2 is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
*/
package appeng.client.render.textures;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.event.TextureStitchEvent;
public class ParticleTextures
{
public static TextureAtlasSprite BlockEnergyParticle;
public static TextureAtlasSprite BlockMatterCannonParticle;
public static void registerSprite( TextureStitchEvent.Pre event )
{
BlockEnergyParticle = event.getMap().registerSprite( new ResourceLocation( "appliedenergistics2:particles/energy" ) );
BlockMatterCannonParticle = event.getMap().registerSprite( new ResourceLocation( "appliedenergistics2:particles/matter_cannon" ) );
}
}