Fixed formation planes.
This commit is contained in:
@@ -31,13 +31,11 @@ import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.RenderType;
|
||||
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.AtlasTexture;
|
||||
import net.minecraft.client.renderer.texture.MissingTextureSprite;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
@@ -46,7 +44,6 @@ import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.client.model.data.EmptyModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import appeng.api.parts.IPartBakedModel;
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
@@ -116,6 +113,11 @@ public class CableBusBakedModel implements IBakedModel
|
||||
continue;
|
||||
}
|
||||
|
||||
IModelData partModelData = renderState.getPartModelData().get(facing);
|
||||
if (partModelData == null) {
|
||||
partModelData = EmptyModelData.INSTANCE;
|
||||
}
|
||||
|
||||
for( ResourceLocation model : partModel.getModels() )
|
||||
{
|
||||
IBakedModel bakedModel = this.partModels.get( model );
|
||||
@@ -125,15 +127,7 @@ public class CableBusBakedModel implements IBakedModel
|
||||
throw new IllegalStateException( "Trying to use an unregistered part model: " + model );
|
||||
}
|
||||
|
||||
List<BakedQuad> partQuads;
|
||||
if( bakedModel instanceof IPartBakedModel )
|
||||
{
|
||||
partQuads = ( (IPartBakedModel) bakedModel ).getPartQuads( renderState.getPartFlags().get( facing ), rand );
|
||||
}
|
||||
else
|
||||
{
|
||||
partQuads = bakedModel.getQuads( state, null, rand );
|
||||
}
|
||||
List<BakedQuad> partQuads = bakedModel.getQuads(state, null, rand, partModelData);
|
||||
|
||||
// Rotate quads accordingly
|
||||
QuadRotator rotator = new QuadRotator();
|
||||
|
||||
@@ -30,6 +30,7 @@ import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.ILightReader;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
@@ -84,7 +85,8 @@ public class CableBusRenderState
|
||||
// facades on this cable bus
|
||||
private List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
|
||||
|
||||
private EnumMap<Direction, Long> partFlags = new EnumMap<>( Direction.class );
|
||||
// Additional model data passed to the part models
|
||||
private EnumMap<Direction, IModelData> partModelData = new EnumMap<>( Direction.class );
|
||||
|
||||
public CableCoreType getCoreType()
|
||||
{
|
||||
@@ -186,9 +188,9 @@ public class CableBusRenderState
|
||||
return this.boundingBoxes;
|
||||
}
|
||||
|
||||
public EnumMap<Direction, Long> getPartFlags()
|
||||
public EnumMap<Direction, IModelData> getPartModelData()
|
||||
{
|
||||
return this.partFlags;
|
||||
return this.partModelData;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -203,7 +205,7 @@ public class CableBusRenderState
|
||||
result = prime * result + ( ( this.channelsOnSide == null ) ? 0 : this.channelsOnSide.hashCode() );
|
||||
result = prime * result + ( ( this.connectionTypes == null ) ? 0 : this.connectionTypes.hashCode() );
|
||||
result = prime * result + ( ( this.coreType == null ) ? 0 : this.coreType.hashCode() );
|
||||
result = prime * result + ( ( this.partFlags == null ) ? 0 : this.partFlags.hashCode() );
|
||||
result = prime * result + ( ( this.partModelData == null ) ? 0 : this.partModelData.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -228,6 +230,6 @@ public class CableBusRenderState
|
||||
return this.cableColor == other.cableColor && this.cableType == other.cableType && this.coreType == other.coreType && Objects
|
||||
.equals( this.attachmentConnections, other.attachmentConnections ) && Objects.equals( this.cableBusAdjacent, other.cableBusAdjacent ) && Objects
|
||||
.equals( this.channelsOnSide, other.channelsOnSide ) && Objects.equals( this.connectionTypes, other.connectionTypes ) && Objects
|
||||
.equals( this.partFlags, other.partFlags );
|
||||
.equals( this.partModelData, other.partModelData);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,18 +12,19 @@ import com.google.common.cache.CacheBuilder;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
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.texture.TextureAtlasSprite;
|
||||
import net.minecraft.util.Direction;
|
||||
|
||||
import appeng.api.parts.IPartBakedModel;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.client.model.data.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedModel
|
||||
public class P2PTunnelFrequencyBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private final TextureAtlasSprite texture;
|
||||
|
||||
private final static Cache<Long, List<BakedQuad>> modelCache = CacheBuilder.newBuilder().maximumSize( 100 ).build();
|
||||
@@ -41,36 +42,16 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getPartQuads( Long partFlags, Random rand )
|
||||
public List<BakedQuad> getQuads( BlockState state, Direction side, Random rand, IModelData modelData )
|
||||
{
|
||||
try
|
||||
{
|
||||
return modelCache.get( partFlags, () ->
|
||||
{
|
||||
short frequency = 0;
|
||||
boolean active = false;
|
||||
if( partFlags != null )
|
||||
{
|
||||
frequency = (short) ( partFlags.longValue() & 0xffffL );
|
||||
active = ( partFlags.longValue() & 0x10000L ) != 0;
|
||||
}
|
||||
return this.getQuadsForFrequency( frequency, active );
|
||||
} );
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
if( side != null || !(modelData instanceof P2PTunnelFrequencyModelData) )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( BlockState state, Direction side, Random rand )
|
||||
{
|
||||
if( side != null )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return this.getPartQuads( null, rand );
|
||||
P2PTunnelFrequencyModelData freqModelData = (P2PTunnelFrequencyModelData) modelData;
|
||||
|
||||
return this.getPartQuads( freqModelData.getFrequency());
|
||||
}
|
||||
|
||||
private List<BakedQuad> getQuadsForFrequency( final short frequency, final boolean active )
|
||||
@@ -94,7 +75,7 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
}
|
||||
else
|
||||
{
|
||||
final float cv[] = c.dye.getColorComponentValues();
|
||||
final float[] cv = c.dye.getColorComponentValues();
|
||||
cb.setColorRGB( cv[0] * 0.5f, cv[1] * 0.5f, cv[2] * 0.5f );
|
||||
}
|
||||
|
||||
@@ -108,6 +89,23 @@ public class P2PTunnelFrequencyBakedModel implements IBakedModel, IPartBakedMode
|
||||
return cb.getOutput();
|
||||
}
|
||||
|
||||
private List<BakedQuad> getPartQuads(long partFlags)
|
||||
{
|
||||
try
|
||||
{
|
||||
return modelCache.get( partFlags, () ->
|
||||
{
|
||||
short frequency = (short) ( partFlags & 0xffffL );
|
||||
boolean active = ( partFlags & 0x10000L ) != 0;
|
||||
return this.getQuadsForFrequency( frequency, active );
|
||||
} );
|
||||
}
|
||||
catch( ExecutionException e )
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAmbientOcclusion()
|
||||
{
|
||||
|
||||
@@ -9,41 +9,25 @@ 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;
|
||||
|
||||
|
||||
public class P2PTunnelFrequencyModel implements IUnbakedModel
|
||||
public class P2PTunnelFrequencyModel implements IModelGeometry<P2PTunnelFrequencyModel>
|
||||
{
|
||||
private static final Material TEXTURE = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, new ResourceLocation( AppEng.MOD_ID, "parts/p2p_tunnel_frequency" ) );
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures( 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) {
|
||||
try
|
||||
{
|
||||
final TextureAtlasSprite texture = spriteGetterIn.apply( TEXTURE );
|
||||
final TextureAtlasSprite texture = spriteGetter.apply( TEXTURE );
|
||||
return new P2PTunnelFrequencyBakedModel( texture );
|
||||
}
|
||||
catch( Exception e )
|
||||
@@ -51,4 +35,10 @@ public class P2PTunnelFrequencyModel implements IUnbakedModel
|
||||
throw new RuntimeException( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Material> getTextures(IModelConfiguration owner, Function<ResourceLocation, IUnbakedModel> modelGetter, Set<Pair<String, String>> missingTextureErrors) {
|
||||
return Collections.singleton( TEXTURE );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package appeng.client.render.cablebus;
|
||||
|
||||
import appeng.client.render.model.AEInternalModelData;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public final class P2PTunnelFrequencyModelData extends AEInternalModelData {
|
||||
|
||||
public static final ModelProperty<Long> FREQUENCY = new ModelProperty<>();
|
||||
|
||||
private final long frequency;
|
||||
|
||||
public P2PTunnelFrequencyModelData(long frequency) {
|
||||
this.frequency = frequency;
|
||||
}
|
||||
|
||||
public long getFrequency() {
|
||||
return frequency;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package appeng.client.render.model;
|
||||
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class AEInternalModelData implements IModelData {
|
||||
|
||||
@Override
|
||||
public final boolean hasProperty(ModelProperty<?> prop) {
|
||||
throw new IllegalStateException("This model data must be used by internal models only.");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final <T> T getData(ModelProperty<T> prop) {
|
||||
throw new IllegalStateException("This model data must be used by internal models only.");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public final <T> T setData(ModelProperty<T> prop, T data) {
|
||||
throw new IllegalStateException("This model data must be used by internal models only.");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import appeng.client.ClientHelper;
|
||||
import appeng.client.render.DummyFluidItemModel;
|
||||
import appeng.client.render.SimpleModelLoader;
|
||||
import appeng.client.render.cablebus.CableBusModel;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.client.render.crafting.CraftingCubeModelLoader;
|
||||
import appeng.client.render.model.*;
|
||||
import appeng.client.render.spatial.SpatialPylonModel;
|
||||
@@ -43,6 +44,8 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.worlddata.WorldData;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.parts.PartPlacement;
|
||||
import appeng.parts.automation.PlaneModel;
|
||||
import appeng.parts.automation.PlaneModelLoader;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.server.ServerHelper;
|
||||
import com.google.common.base.Stopwatch;
|
||||
@@ -98,12 +101,11 @@ public final class AppEng
|
||||
|
||||
private static AppEng INSTANCE;
|
||||
|
||||
//FIXME private final Registration registration;
|
||||
private final Registration registration;
|
||||
|
||||
/**
|
||||
* determined in pre-init but used in init
|
||||
*/
|
||||
// FIXME private ExportConfig exportConfig;
|
||||
|
||||
public AppEng()
|
||||
{
|
||||
@@ -125,7 +127,7 @@ public final class AppEng
|
||||
CreativeTabFacade.init();
|
||||
|
||||
IEventBus modEventBus = FMLJavaModLoadingContext.get().getModEventBus();
|
||||
Registration registration = new Registration();
|
||||
registration = new Registration();
|
||||
modEventBus.addGenericListener(Block.class, registration::registerBlocks);
|
||||
modEventBus.addGenericListener(Item.class, registration::registerItems);
|
||||
modEventBus.addGenericListener(EntityType.class, registration::registerEntities);
|
||||
@@ -195,11 +197,12 @@ public final class AppEng
|
||||
addBuiltInModel("spatial_pylon", SpatialPylonModel::new);
|
||||
addBuiltInModel("paint_splotches", PaintSplotchesModel::new);
|
||||
addBuiltInModel("quantum_bridge_formed", QnbFormedModel::new);
|
||||
addBuiltInModel("p2p_tunnel_frequency", P2PTunnelFrequencyModel::new);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "part_plane"), PlaneModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "crafting_cube"), CraftingCubeModelLoader.INSTANCE);
|
||||
ModelLoaderRegistry.registerLoader(new ResourceLocation(AppEng.MOD_ID, "uvlightmap"), UVLModelLoader.INSTANCE);
|
||||
addBuiltInModel("cable_bus", () -> new CableBusModel((PartModels) Api.INSTANCE.registries().partModels()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static <T extends IModelGeometry<T>> void addBuiltInModel(String id, Supplier<T> modelFactory) {
|
||||
@@ -232,7 +235,7 @@ public final class AppEng
|
||||
|
||||
public AdvancementTriggers getAdvancementTriggers()
|
||||
{
|
||||
return null; // FIXME this.registration.advancementTriggers;
|
||||
return this.registration.advancementTriggers;
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
@@ -250,8 +253,6 @@ public final class AppEng
|
||||
// AEConfig.init( configFile );
|
||||
// FacadeConfig.init( facadeFile );
|
||||
//
|
||||
// this.exportConfig = new ForgeExportConfig( recipeConfiguration );
|
||||
//
|
||||
// AELog.info( "Pre Initialization ( started )" );
|
||||
//
|
||||
//
|
||||
@@ -286,35 +287,6 @@ public final class AppEng
|
||||
thread.start();
|
||||
}
|
||||
|
||||
// @EventHandler
|
||||
// private void init( final FMLCommonSetupEvent event )
|
||||
// {
|
||||
// final Stopwatch start = Stopwatch.createStarted();
|
||||
// AELog.info( "Initialization ( started )" );
|
||||
//
|
||||
// AppEng.proxy.init();
|
||||
//
|
||||
// if( this.exportConfig.isExportingItemNamesEnabled() )
|
||||
// {
|
||||
// if( FMLCommonHandler.instance().getSide().isClient() )
|
||||
// {
|
||||
// final ExportProcess process = new ExportProcess( this.configDirectory, this.exportConfig );
|
||||
// final Thread exportProcessThread = new Thread( process );
|
||||
//
|
||||
// this.startService( "AE2 CSV Export", exportProcessThread );
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// AELog.info( "Disabling item.csv export for custom recipes, since creative tab information is only available on the client." );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// this.registration.initialize( event, this.configDirectory );
|
||||
// IntegrationRegistry.INSTANCE.init();
|
||||
//
|
||||
// AELog.info( "Initialization ( ended after " + start.elapsed( TimeUnit.MILLISECONDS ) + "ms )" );
|
||||
// }
|
||||
|
||||
private void registerNetworkHandler()
|
||||
{
|
||||
final Stopwatch start = Stopwatch.createStarted();
|
||||
|
||||
@@ -36,6 +36,7 @@ import appeng.api.networking.security.ISecurityGrid;
|
||||
import appeng.api.networking.spatial.ISpatialCache;
|
||||
import appeng.api.networking.storage.IStorageGrid;
|
||||
import appeng.api.networking.ticking.ITickManager;
|
||||
import appeng.bootstrap.ICriterionTriggerRegistry;
|
||||
import appeng.bootstrap.IModelRegistry;
|
||||
import appeng.bootstrap.components.*;
|
||||
import appeng.client.gui.implementations.GuiCellWorkbench;
|
||||
@@ -86,6 +87,7 @@ import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.features.registries.cell.BasicCellHandler;
|
||||
import appeng.core.features.registries.cell.BasicItemCellGuiHandler;
|
||||
import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.stats.AeStats;
|
||||
import appeng.core.stats.PartItemPredicate;
|
||||
import appeng.fluids.client.gui.*;
|
||||
@@ -97,6 +99,9 @@ import appeng.recipes.game.DisassembleRecipe;
|
||||
import appeng.recipes.ingredients.PartIngredientSerializer;
|
||||
import appeng.server.AECommand;
|
||||
import appeng.tile.AEBaseTile;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.advancements.ICriterionInstance;
|
||||
import net.minecraft.advancements.ICriterionTrigger;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.ScreenManager;
|
||||
@@ -121,20 +126,24 @@ import net.minecraftforge.fml.DistExecutor;
|
||||
import net.minecraftforge.fml.event.server.FMLServerStartingEvent;
|
||||
import net.minecraftforge.fml.loading.FMLEnvironment;
|
||||
import net.minecraftforge.fml.network.IContainerFactory;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
import net.minecraftforge.registries.IForgeRegistry;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
|
||||
final class Registration
|
||||
{
|
||||
|
||||
public Registration() {
|
||||
AeStats.register();
|
||||
advancementTriggers = new AdvancementTriggers( CriteriaTriggers::register );
|
||||
}
|
||||
|
||||
// DimensionType storageDimensionType;
|
||||
// int storageDimensionID;
|
||||
// Biome storageBiome;
|
||||
// AdvancementTriggers advancementTriggers;
|
||||
AdvancementTriggers advancementTriggers;
|
||||
//
|
||||
// void preInitialize( final FMLPreInitializationEvent event )
|
||||
// {
|
||||
@@ -237,8 +246,6 @@ final class Registration
|
||||
} );
|
||||
|
||||
PartItemPredicate.register();
|
||||
// FIXME Stats.register();
|
||||
// FIXME this.advancementTriggers = new AdvancementTriggers( new CriterionTrigggerRegistry() );
|
||||
}
|
||||
|
||||
// @SubscribeEvent
|
||||
@@ -871,31 +878,6 @@ final class Registration
|
||||
// {
|
||||
// ModelLoader.setCustomStateMapper( block, mapper );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class CriterionTrigggerRegistry implements ICriterionTriggerRegistry
|
||||
// {
|
||||
// private Method method;
|
||||
//
|
||||
// CriterionTrigggerRegistry()
|
||||
// {
|
||||
// this.method = ReflectionHelper.findMethod( CriteriaTriggers.class, "register", "func_192118_a", ICriterionTrigger.class );
|
||||
// this.method.setAccessible( true );
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void register( ICriterionTrigger<? extends ICriterionInstance> trigger )
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// this.method.invoke( null, trigger );
|
||||
// }
|
||||
// catch( IllegalAccessException | IllegalArgumentException | InvocationTargetException e )
|
||||
// {
|
||||
// AELog.debug( e );
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
public void registerTextures(TextureStitchEvent.Pre event) {
|
||||
|
||||
@@ -27,10 +27,7 @@ import appeng.api.features.AEFeature;
|
||||
import appeng.client.render.crafting.EncodedPatternRenderer;
|
||||
import appeng.client.render.crafting.ItemEncodedPatternRendering;
|
||||
import appeng.core.CreativeTabFacade;
|
||||
import appeng.debug.ToolDebugCard;
|
||||
import appeng.debug.ToolEraser;
|
||||
import appeng.debug.ToolMeteoritePlacer;
|
||||
import appeng.debug.ToolReplicatorCard;
|
||||
import appeng.debug.*;
|
||||
import appeng.entity.EntityGrowingCrystal;
|
||||
import appeng.fluids.items.BasicFluidStorageCell;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
@@ -310,6 +307,7 @@ public final class ApiItems implements IItems
|
||||
this.toolMeteoritePlacer = debugTools.item( "debug_meteorite_placer", ToolMeteoritePlacer::new ).build();
|
||||
this.toolDebugCard = debugTools.item( "debug_card", ToolDebugCard::new ).build();
|
||||
this.toolReplicatorCard = debugTools.item( "debug_replicator_card", ToolReplicatorCard::new ).build();
|
||||
debugTools.item( "debug_part_placer", ToolDebugPartPlacer::new ).build();
|
||||
|
||||
this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build();
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import appeng.api.parts.IPart;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.api.util.AEColoredItemDefinition;
|
||||
import appeng.bootstrap.FeatureFactory;
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModel;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.CreativeTab;
|
||||
import appeng.core.features.*;
|
||||
@@ -145,71 +146,8 @@ public final class ApiParts implements IParts
|
||||
private void registerPartModels(PartModels partModels) {
|
||||
|
||||
// Register the built-in models for annihilation planes
|
||||
ResourceLocation annihilationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/annihilation_plane" );
|
||||
ResourceLocation annihilationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/annihilation_plane_on" );
|
||||
ResourceLocation fluidAnnihilationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/fluid_annihilation_plane" );
|
||||
ResourceLocation fluidAnnihilationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/fluid_annihilation_plane_on" );
|
||||
ResourceLocation identityAnnihilationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/identity_annihilation_plane" );
|
||||
ResourceLocation identityAnnihilationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/identity_annihilation_plane_on" );
|
||||
ResourceLocation formationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/formation_plane" );
|
||||
ResourceLocation formationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/formation_plane_on" );
|
||||
ResourceLocation fluidFormationPlaneTexture = new ResourceLocation( AppEng.MOD_ID, "item/part/fluid_formation_plane" );
|
||||
ResourceLocation fluidFormationPlaneOnTexture = new ResourceLocation( AppEng.MOD_ID, "parts/fluid_formation_plane_on" );
|
||||
ResourceLocation sidesTexture = new ResourceLocation( AppEng.MOD_ID, "parts/plane_sides" );
|
||||
ResourceLocation backTexture = new ResourceLocation( AppEng.MOD_ID, "parts/transition_plane_back" );
|
||||
|
||||
List<String> modelNames = new ArrayList<>();
|
||||
|
||||
// FIXME for( PlaneConnections connection : PlaneConnections.PERMUTATIONS )
|
||||
// FIXME {
|
||||
// FIXME PlaneModel model = new PlaneModel( annihilationPlaneTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/annihilation_plane_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/annihilation_plane_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( annihilationPlaneOnTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/annihilation_plane_on_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/annihilation_plane_on_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( fluidAnnihilationPlaneTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/fluid_annihilation_plane_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/fluid_annihilation_plane_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( fluidAnnihilationPlaneOnTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/fluid_annihilation_plane_on_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/fluid_annihilation_plane_on_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( identityAnnihilationPlaneTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/identity_annihilation_plane_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/identity_annihilation_plane_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( identityAnnihilationPlaneOnTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/identity_annihilation_plane_on_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/identity_annihilation_plane_on_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( formationPlaneTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/formation_plane_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/formation_plane_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( formationPlaneOnTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/formation_plane_on_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/formation_plane_on_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( fluidFormationPlaneTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/fluid_formation_plane_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/fluid_formation_plane_" + connection.getFilenameSuffix() );
|
||||
// FIXME
|
||||
// FIXME model = new PlaneModel( fluidFormationPlaneOnTexture, sidesTexture, backTexture, connection );
|
||||
// FIXME rendering.builtInModel( "models/part/fluid_formation_plane_on_" + connection.getFilenameSuffix(), model );
|
||||
// FIXME modelNames.add( "part/fluid_formation_plane_on_" + connection.getFilenameSuffix() );
|
||||
// FIXME }
|
||||
// FIXME
|
||||
// FIXME // base p2p model with frequency
|
||||
// FIXME rendering.builtInModel( "models/part/builtin/p2p_tunnel_frequency", new P2PTunnelFrequencyModel() );
|
||||
|
||||
List<ResourceLocation> partResourceLocs = modelNames.stream()
|
||||
.map( name -> new ResourceLocation( AppEng.MOD_ID, name ) )
|
||||
.collect( Collectors.toList() );
|
||||
partModels.registerModels( partResourceLocs );
|
||||
|
||||
// Register all part models
|
||||
for( PartType partType : PartType.values() )
|
||||
|
||||
@@ -91,17 +91,6 @@ public enum GuiText
|
||||
Inscriber,
|
||||
QuartzCuttingKnife,
|
||||
|
||||
// tunnel names
|
||||
METunnel,
|
||||
ItemTunnel,
|
||||
RedstoneTunnel,
|
||||
EUTunnel,
|
||||
FluidTunnel,
|
||||
OCTunnel,
|
||||
LightTunnel,
|
||||
FETunnel,
|
||||
PressureTunnel,
|
||||
|
||||
// spatial
|
||||
StoredSize,
|
||||
CellId,
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
package appeng.debug;
|
||||
|
||||
import appeng.api.parts.IPart;
|
||||
import appeng.api.parts.IPartHost;
|
||||
import appeng.api.parts.PartItemStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.items.AEBaseItem;
|
||||
import appeng.items.parts.ColoredPartItem;
|
||||
import appeng.items.parts.ItemPart;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemUseContext;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.ActionResultType;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This tool will try to place anything that is registered as a {@link ItemPart} (and not a colored one)
|
||||
* onto an existing cable to quickly test parts and their rendering.
|
||||
*/
|
||||
public class ToolDebugPartPlacer extends AEBaseItem {
|
||||
|
||||
public ToolDebugPartPlacer(Properties properties) {
|
||||
super(properties);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResultType onItemUseFirst(ItemStack stack, ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
if (world.isRemote()) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
PlayerEntity player = context.getPlayer();
|
||||
BlockPos pos = context.getPos();
|
||||
|
||||
if (player == null) {
|
||||
return ActionResultType.PASS;
|
||||
}
|
||||
|
||||
if (!player.abilities.isCreativeMode) {
|
||||
player.sendMessage(new StringTextComponent("Only usable in creative mode"));
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
TileEntity te = world.getTileEntity(pos);
|
||||
if (!(te instanceof IPartHost)) {
|
||||
player.sendMessage(new StringTextComponent("Right-click something that will accept parts"));
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
IPartHost center = (IPartHost) te;
|
||||
IPart cable = center.getPart(AEPartLocation.INTERNAL);
|
||||
if (cable == null) {
|
||||
player.sendMessage(new StringTextComponent("Clicked part host must have an INSIDE part"));
|
||||
return ActionResultType.FAIL;
|
||||
}
|
||||
|
||||
Direction face = context.getFace();
|
||||
Vec3i offset = face.getDirectionVec();
|
||||
Direction[] perpendicularFaces = Arrays.stream(Direction.values()).filter(d -> d.getAxis() != face.getAxis())
|
||||
.toArray(Direction[]::new);
|
||||
|
||||
BlockPos nextPos = pos;
|
||||
for (Item item : ForgeRegistries.ITEMS) {
|
||||
if (!(item instanceof ItemPart)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (item instanceof ColoredPartItem) {
|
||||
continue; // Cables and such
|
||||
}
|
||||
|
||||
nextPos = nextPos.add(offset);
|
||||
if (!world.setBlockState(nextPos, te.getBlockState())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity t = world.getTileEntity(nextPos);
|
||||
if (!(t instanceof IPartHost)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
IPartHost partHost = (IPartHost) t;
|
||||
if (partHost.addPart(cable.getItemStack(PartItemStack.PICK), AEPartLocation.INTERNAL, player, null) == null) {
|
||||
continue;
|
||||
}
|
||||
for (Direction dir : perpendicularFaces) {
|
||||
ItemStack itemStack = new ItemStack(item, 1);
|
||||
partHost.addPart(itemStack, AEPartLocation.fromFacing(dir), player, null);
|
||||
}
|
||||
}
|
||||
|
||||
return ActionResultType.SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ package appeng.fluids.parts;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.parts.automation.PlaneModelData;
|
||||
import net.minecraft.advancements.CriteriaTriggers;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
@@ -24,6 +25,7 @@ import net.minecraft.util.SoundEvents;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
@@ -64,10 +66,12 @@ import appeng.parts.automation.PlaneConnections;
|
||||
import appeng.parts.automation.PlaneModels;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public class PartFluidAnnihilationPlane extends PartBasicState implements IGridTickable
|
||||
{
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_annihilation_plane_", "part/fluid_annihilation_plane_on_" );
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_annihilation_plane", "part/fluid_annihilation_plane_on" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -335,6 +339,13 @@ public class PartFluidAnnihilationPlane extends PartBasicState implements IGridT
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new PlaneModelData(getConnections());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import appeng.container.ContainerLocator;
|
||||
import appeng.container.ContainerOpener;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.fluids.container.ContainerFluidFormationPlane;
|
||||
import appeng.parts.automation.PlaneModelData;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
@@ -22,6 +23,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.fluid.Fluid;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.fluids.FluidAttributes;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
@@ -57,10 +59,12 @@ import appeng.parts.automation.PlaneModels;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluidStack> implements IAEFluidInventory
|
||||
{
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_formation_plane_", "part/fluid_formation_plane_on_" );
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/fluid_formation_plane", "part/fluid_formation_plane_on" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -219,7 +223,13 @@ public class PartFluidFormationPlane extends PartAbstractFormationPlane<IAEFluid
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new PlaneModelData(getConnections());
|
||||
}
|
||||
|
||||
public IAEFluidTank getConfig()
|
||||
|
||||
@@ -1243,7 +1243,7 @@ public class CableBusContainer extends CableBusStorage implements AEMultiTile, I
|
||||
continue;
|
||||
}
|
||||
|
||||
renderState.getPartFlags().put( facing, part.getRenderFlag() );
|
||||
renderState.getPartModelData().put( facing, part.getModelData() );
|
||||
|
||||
// This will add the part's bounding boxes to the render state, which is required for facades
|
||||
final AEPartLocation loc = AEPartLocation.fromFacing( facing );
|
||||
|
||||
@@ -73,15 +73,18 @@ import appeng.util.Platform;
|
||||
import appeng.util.item.AEItemStack;
|
||||
import net.minecraft.world.storage.loot.LootContext;
|
||||
import net.minecraft.world.storage.loot.LootParameters;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.ToolType;
|
||||
import net.minecraftforge.common.util.FakePlayer;
|
||||
import net.minecraftforge.common.util.FakePlayerFactory;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
||||
public class PartAnnihilationPlane extends PartBasicState implements IGridTickable, IWorldCallable<TickRateModulation>
|
||||
{
|
||||
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/annihilation_plane_", "part/annihilation_plane_on_" );
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/annihilation_plane", "part/annihilation_plane_on" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -576,6 +579,8 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
{
|
||||
this.isAccepting = true;
|
||||
|
||||
getTile().requestModelDataUpdate();
|
||||
|
||||
try
|
||||
{
|
||||
this.getProxy().getTick().alertDevice( this.getProxy().getNode() );
|
||||
@@ -589,7 +594,13 @@ public class PartAnnihilationPlane extends PartBasicState implements IGridTickab
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new PlaneModelData(getConnections());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,6 +43,7 @@ import net.minecraft.util.math.BlockRayTraceResult;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
@@ -78,13 +79,14 @@ import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
|
||||
public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
{
|
||||
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/formation_plane_", "part/formation_plane_on_" );
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/formation_plane", "part/formation_plane_on" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -374,7 +376,13 @@ public class PartFormationPlane extends PartAbstractFormationPlane<IAEItemStack>
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new PlaneModelData(getConnections());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -32,14 +32,16 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.server.ServerWorld;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
|
||||
{
|
||||
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/identity_annihilation_plane_", "part/identity_annihilation_plane_on_" );
|
||||
private static final PlaneModels MODELS = new PlaneModels( "part/identity_annihilation_plane", "part/identity_annihilation_plane_on" );
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -90,7 +92,13 @@ public class PartIdentityAnnihilationPlane extends PartAnnihilationPlane
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.getConnections(), this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public IModelData getModelData() {
|
||||
return new PlaneModelData(getConnections());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,63 +19,70 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
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.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.IDynamicBakedModel;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
|
||||
|
||||
/**
|
||||
* Built-in model for annihilation planes that supports connected textures.
|
||||
*/
|
||||
public class PlaneBakedModel implements IBakedModel
|
||||
public class PlaneBakedModel implements IDynamicBakedModel
|
||||
{
|
||||
|
||||
private static final PlaneConnections DEFAULT_PERMUTATION = PlaneConnections.of(false, false, false, false);
|
||||
|
||||
private final TextureAtlasSprite frontTexture;
|
||||
|
||||
private final List<BakedQuad> quads;
|
||||
private final Map<PlaneConnections, List<BakedQuad>> quads;
|
||||
|
||||
PlaneBakedModel( TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture, PlaneConnections connections )
|
||||
PlaneBakedModel( TextureAtlasSprite frontTexture, TextureAtlasSprite sidesTexture, TextureAtlasSprite backTexture )
|
||||
{
|
||||
this.frontTexture = frontTexture;
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>( 4 * 6 );
|
||||
quads = new HashMap<>(PlaneConnections.PERMUTATIONS.size());
|
||||
// Create all possible permutations (16)
|
||||
for (PlaneConnections permutation : PlaneConnections.PERMUTATIONS) {
|
||||
List<BakedQuad> quads = new ArrayList<>(4 * 6);
|
||||
|
||||
CubeBuilder builder = new CubeBuilder( quads );
|
||||
CubeBuilder builder = new CubeBuilder(quads);
|
||||
|
||||
builder.setTextures( sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture );
|
||||
builder.setTextures(sidesTexture, sidesTexture, frontTexture, backTexture, sidesTexture, sidesTexture);
|
||||
|
||||
// Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front,
|
||||
// The X-axis points left
|
||||
int minX = connections.isRight() ? 0 : 1;
|
||||
int maxX = connections.isLeft() ? 16 : 15;
|
||||
int minY = connections.isDown() ? 0 : 1;
|
||||
int maxY = connections.isUp() ? 16 : 15;
|
||||
// Keep the orientation of the X axis in mind here. When looking at a quad facing north from the front,
|
||||
// The X-axis points left
|
||||
int minX = permutation.isRight() ? 0 : 1;
|
||||
int maxX = permutation.isLeft() ? 16 : 15;
|
||||
int minY = permutation.isDown() ? 0 : 1;
|
||||
int maxY = permutation.isUp() ? 16 : 15;
|
||||
|
||||
builder.addCube( minX, minY, 0, maxX, maxY, 1 );
|
||||
builder.addCube(minX, minY, 0, maxX, maxY, 1);
|
||||
|
||||
this.quads = ImmutableList.copyOf( quads );
|
||||
this.quads.put(permutation, ImmutableList.copyOf(quads));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BakedQuad> getQuads( @Nullable BlockState state, @Nullable Direction side, Random rand )
|
||||
public List<BakedQuad> getQuads(@Nullable BlockState state, @Nullable Direction side, Random rand, IModelData modelData)
|
||||
{
|
||||
if( side == null )
|
||||
{
|
||||
return this.quads;
|
||||
PlaneConnections connections = DEFAULT_PERMUTATION;
|
||||
if (modelData instanceof PlaneModelData) {
|
||||
connections = ((PlaneModelData) modelData).getConnections();
|
||||
}
|
||||
return this.quads.get(connections);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -28,55 +28,43 @@ 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.geometry.IModelGeometry;
|
||||
|
||||
|
||||
/**
|
||||
* Built-in model for annihilation planes that supports connected textures.
|
||||
*/
|
||||
public class PlaneModel implements IUnbakedModel
|
||||
public class PlaneModel implements IModelGeometry<PlaneModel>
|
||||
{
|
||||
|
||||
private final Material frontTexture;
|
||||
private final Material sidesTexture;
|
||||
private final Material backTexture;
|
||||
private final PlaneConnections connections;
|
||||
|
||||
public PlaneModel( ResourceLocation frontTexture, ResourceLocation sidesTexture, ResourceLocation backTexture, PlaneConnections connections )
|
||||
public PlaneModel( ResourceLocation frontTexture, ResourceLocation sidesTexture, ResourceLocation backTexture )
|
||||
{
|
||||
this.frontTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, frontTexture );
|
||||
this.sidesTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, sidesTexture );
|
||||
this.backTexture = new Material( AtlasTexture.LOCATION_BLOCKS_TEXTURE, backTexture );
|
||||
this.connections = connections;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<ResourceLocation> getDependencies()
|
||||
{
|
||||
return Collections.emptyList();
|
||||
public IBakedModel bake(IModelConfiguration owner, ModelBakery bakery, Function<Material, TextureAtlasSprite> spriteGetter, IModelTransform modelTransform, ItemOverrideList overrides, ResourceLocation modelLocation) {
|
||||
TextureAtlasSprite frontSprite = spriteGetter.apply( this.frontTexture );
|
||||
TextureAtlasSprite sidesSprite = spriteGetter.apply( this.sidesTexture );
|
||||
TextureAtlasSprite backSprite = spriteGetter.apply( this.backTexture );
|
||||
|
||||
return new PlaneBakedModel( frontSprite, sidesSprite, backSprite );
|
||||
}
|
||||
|
||||
@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( frontTexture, sidesTexture, backTexture );
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public IBakedModel bakeModel( ModelBakery modelBakeryIn, Function<Material, TextureAtlasSprite> spriteGetterIn, IModelTransform transformIn, ResourceLocation locationIn )
|
||||
{
|
||||
TextureAtlasSprite frontSprite = spriteGetterIn.apply( this.frontTexture );
|
||||
TextureAtlasSprite sidesSprite = spriteGetterIn.apply( this.sidesTexture );
|
||||
TextureAtlasSprite backSprite = spriteGetterIn.apply( this.backTexture );
|
||||
|
||||
return new PlaneBakedModel( frontSprite, sidesSprite, backSprite, this.connections );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import appeng.client.render.model.AEInternalModelData;
|
||||
|
||||
public class PlaneModelData extends AEInternalModelData {
|
||||
|
||||
private final PlaneConnections connections;
|
||||
|
||||
public PlaneModelData(PlaneConnections connections) {
|
||||
this.connections = connections;
|
||||
}
|
||||
|
||||
public PlaneConnections getConnections() {
|
||||
return connections;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.resources.IResourceManager;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.model.IModelLoader;
|
||||
|
||||
public class PlaneModelLoader implements IModelLoader<PlaneModel> {
|
||||
|
||||
public static final PlaneModelLoader INSTANCE = new PlaneModelLoader();
|
||||
|
||||
@Override
|
||||
public void onResourceManagerReload(IResourceManager resourceManager) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaneModel read(JsonDeserializationContext deserializationContext, JsonObject modelContents) {
|
||||
String frontTexture = modelContents.get("front").getAsString();
|
||||
String sidesTexture = modelContents.get("sides").getAsString();
|
||||
String backTexture = modelContents.get("back").getAsString();
|
||||
|
||||
return new PlaneModel(
|
||||
new ResourceLocation(frontTexture),
|
||||
new ResourceLocation(sidesTexture),
|
||||
new ResourceLocation(backTexture)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
@@ -43,56 +44,43 @@ public class PlaneModels
|
||||
public static final ResourceLocation MODEL_CHASSIS_ON = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_on" );
|
||||
public static final ResourceLocation MODEL_CHASSIS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/transition_plane_has_channel" );
|
||||
|
||||
private final Map<PlaneConnections, IPartModel> modelsOff;
|
||||
private final IPartModel modelOff;
|
||||
|
||||
private final Map<PlaneConnections, IPartModel> modelsOn;
|
||||
private final IPartModel modelOn;
|
||||
|
||||
private final Map<PlaneConnections, IPartModel> modelsHasChannel;
|
||||
private final IPartModel modelHasChannel;
|
||||
|
||||
public PlaneModels( String prefixOff, String prefixOn )
|
||||
public PlaneModels( String planeOffLocation, String planeOnLocation )
|
||||
{
|
||||
Map<PlaneConnections, IPartModel> modelsOff = new HashMap<>();
|
||||
Map<PlaneConnections, IPartModel> modelsOn = new HashMap<>();
|
||||
Map<PlaneConnections, IPartModel> modelsHasChannel = new HashMap<>();
|
||||
ResourceLocation planeOff = new ResourceLocation( AppEng.MOD_ID, planeOffLocation );
|
||||
ResourceLocation planeOn = new ResourceLocation( AppEng.MOD_ID, planeOnLocation );
|
||||
|
||||
for( PlaneConnections permutation : PlaneConnections.PERMUTATIONS )
|
||||
{
|
||||
ResourceLocation planeOff = new ResourceLocation( AppEng.MOD_ID, prefixOff + permutation.getFilenameSuffix() );
|
||||
ResourceLocation planeOn = new ResourceLocation( AppEng.MOD_ID, prefixOn + permutation.getFilenameSuffix() );
|
||||
|
||||
modelsOff.put( permutation, new PartModel( MODEL_CHASSIS_OFF, planeOff ) );
|
||||
modelsOn.put( permutation, new PartModel( MODEL_CHASSIS_ON, planeOff ) );
|
||||
modelsHasChannel.put( permutation, new PartModel( MODEL_CHASSIS_HAS_CHANNEL, planeOn ) );
|
||||
}
|
||||
|
||||
this.modelsOff = ImmutableMap.copyOf( modelsOff );
|
||||
this.modelsOn = ImmutableMap.copyOf( modelsOn );
|
||||
this.modelsHasChannel = ImmutableMap.copyOf( modelsHasChannel );
|
||||
this.modelOff = new PartModel( MODEL_CHASSIS_OFF, planeOff );
|
||||
this.modelOn = new PartModel( MODEL_CHASSIS_ON, planeOff );
|
||||
this.modelHasChannel = new PartModel( MODEL_CHASSIS_HAS_CHANNEL, planeOn );
|
||||
}
|
||||
|
||||
public IPartModel getModel( PlaneConnections connections, boolean hasPower, boolean hasChannel )
|
||||
public IPartModel getModel(boolean hasPower, boolean hasChannel)
|
||||
{
|
||||
if( hasPower && hasChannel )
|
||||
{
|
||||
return this.modelsHasChannel.get( connections );
|
||||
return modelHasChannel;
|
||||
}
|
||||
else if( hasPower )
|
||||
{
|
||||
return this.modelsOn.get( connections );
|
||||
return modelOn;
|
||||
}
|
||||
else
|
||||
{
|
||||
return this.modelsOff.get( connections );
|
||||
return modelOff;
|
||||
}
|
||||
}
|
||||
|
||||
public List<IPartModel> getModels()
|
||||
{
|
||||
List<IPartModel> result = new ArrayList<>();
|
||||
this.modelsOff.values().forEach( result::add );
|
||||
this.modelsOn.values().forEach( result::add );
|
||||
this.modelsHasChannel.values().forEach( result::add );
|
||||
return result;
|
||||
return ImmutableList.of(
|
||||
modelOff, modelOn, modelHasChannel
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ class P2PModels
|
||||
public static final ResourceLocation MODEL_STATUS_OFF = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_off" );
|
||||
public static final ResourceLocation MODEL_STATUS_ON = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_on" );
|
||||
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_status_has_channel" );
|
||||
public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation( AppEng.MOD_ID, "part/builtin/p2p_tunnel_frequency" );
|
||||
public static final ResourceLocation MODEL_FREQUENCY = new ResourceLocation( AppEng.MOD_ID, "part/p2p/p2p_tunnel_frequency" );
|
||||
|
||||
private final IPartModel modelsOff;
|
||||
private final IPartModel modelsOn;
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
import appeng.client.render.cablebus.P2PTunnelFrequencyModelData;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
@@ -52,6 +53,9 @@ import appeng.me.cache.P2PCache;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.util.Platform;
|
||||
import net.minecraftforge.client.model.data.IModelData;
|
||||
import net.minecraftforge.client.model.data.ModelDataMap;
|
||||
import net.minecraftforge.client.model.data.ModelProperty;
|
||||
|
||||
|
||||
public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicState
|
||||
@@ -437,7 +441,7 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getRenderFlag()
|
||||
public IModelData getModelData()
|
||||
{
|
||||
long ret = Short.toUnsignedLong( this.getFrequency() );
|
||||
|
||||
@@ -446,6 +450,6 @@ public abstract class PartP2PTunnel<T extends PartP2PTunnel> extends PartBasicSt
|
||||
ret |= 0x10000L;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return new P2PTunnelFrequencyModelData(ret);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user