Fixes anchor rendering (#2698)
* Fixes #2680: Use a shorter cable anchor model when blocked by a facade. * Fixes #2664: Prevent anchors from creating intersection. Replaced the simple List<ResourceLocation> for the static models with a new container also indicating a solid part, which can be used to prevent the creation of an intersection.
This commit is contained in:
@@ -21,6 +21,7 @@ package appeng.client.render;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
@@ -22,6 +22,7 @@ package appeng.client.render;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.util.EnumMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
@@ -41,6 +43,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
import net.minecraftforge.common.property.IExtendedBlockState;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
import appeng.block.networking.BlockCableBus;
|
||||
@@ -81,8 +84,9 @@ public class CableBusBakedModel implements IBakedModel
|
||||
|
||||
List<BakedQuad> quads = new ArrayList<>();
|
||||
|
||||
// The core parts of the cable will only be rendered in the CUTOUT layer. TRANSLUCENT is used only for translucent facades further down below.
|
||||
if ( layer == BlockRenderLayer.CUTOUT )
|
||||
// The core parts of the cable will only be rendered in the CUTOUT layer. TRANSLUCENT is used only for
|
||||
// translucent facades further down below.
|
||||
if( layer == BlockRenderLayer.CUTOUT )
|
||||
{
|
||||
// First, handle the cable at the center of the cable bus
|
||||
addCableQuads( renderState, quads );
|
||||
@@ -90,13 +94,13 @@ public class CableBusBakedModel implements IBakedModel
|
||||
// Then handle attachments
|
||||
for( EnumFacing facing : EnumFacing.values() )
|
||||
{
|
||||
List<ResourceLocation> models = renderState.getAttachments().get( facing );
|
||||
if( models == null )
|
||||
final IPartModel partModel = renderState.getAttachments().get( facing );
|
||||
if( partModel == null )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for( ResourceLocation model : models )
|
||||
for( ResourceLocation model : partModel.getModels() )
|
||||
{
|
||||
IBakedModel bakedModel = partModels.get( model );
|
||||
|
||||
@@ -122,8 +126,7 @@ public class CableBusBakedModel implements IBakedModel
|
||||
renderState.getBoundingBoxes(),
|
||||
renderState.getAttachments().keySet(),
|
||||
rand,
|
||||
quads
|
||||
);
|
||||
quads );
|
||||
|
||||
return quads;
|
||||
}
|
||||
@@ -131,25 +134,30 @@ public class CableBusBakedModel implements IBakedModel
|
||||
// Determines whether a cable is connected to exactly two sides that are opposite each other
|
||||
private static boolean isStraightLine( AECableType cableType, EnumMap<EnumFacing, AECableType> sides )
|
||||
{
|
||||
Iterator<EnumFacing> it = sides.keySet().iterator();
|
||||
final Iterator<Entry<EnumFacing, AECableType>> it = sides.entrySet().iterator();
|
||||
if( !it.hasNext() )
|
||||
{
|
||||
return false; // No connections
|
||||
}
|
||||
EnumFacing firstSide = it.next();
|
||||
AECableType firstType = sides.get( firstSide );
|
||||
|
||||
final Entry<EnumFacing, AECableType> nextConnection = it.next();
|
||||
final EnumFacing firstSide = nextConnection.getKey();
|
||||
final AECableType firstType = nextConnection.getValue();
|
||||
|
||||
if( !it.hasNext() )
|
||||
{
|
||||
return false; // Only a single connection
|
||||
}
|
||||
if( firstSide.getOpposite() != it.next() )
|
||||
if( firstSide.getOpposite() != it.next().getKey() )
|
||||
{
|
||||
return false; // Connected to two sides that are not opposite each other
|
||||
}
|
||||
if (it.hasNext()) {
|
||||
if( it.hasNext() )
|
||||
{
|
||||
return false; // Must not have any other connection points
|
||||
}
|
||||
AECableType secondType = sides.get( firstSide.getOpposite() );
|
||||
|
||||
final AECableType secondType = sides.get( firstSide.getOpposite() );
|
||||
|
||||
// Certain cable types have restrictions on when they're rendered as a straight connection
|
||||
switch( cableType )
|
||||
@@ -176,8 +184,8 @@ public class CableBusBakedModel implements IBakedModel
|
||||
|
||||
// If the connection is straight, no busses are attached, and no covered core has been forced (in case of glass
|
||||
// cables), then render the cable as a simplified straight line.
|
||||
boolean noAttachments = renderState.getAttachments().isEmpty();
|
||||
if( isStraightLine( cableType, connectionTypes ) && noAttachments )
|
||||
boolean noAttachments = !renderState.getAttachments().values().stream().anyMatch( IPartModel::requireCableConnection );
|
||||
if( noAttachments && isStraightLine( cableType, connectionTypes ) )
|
||||
{
|
||||
EnumFacing facing = connectionTypes.keySet().iterator().next();
|
||||
|
||||
@@ -227,11 +235,12 @@ public class CableBusBakedModel implements IBakedModel
|
||||
}
|
||||
|
||||
// Render all outgoing connections using the appropriate type
|
||||
for( EnumFacing facing : connectionTypes.keySet() )
|
||||
for( final Entry<EnumFacing, AECableType> connection : connectionTypes.entrySet() )
|
||||
{
|
||||
AECableType connectionType = connectionTypes.get( facing );
|
||||
boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing );
|
||||
int channels = renderState.getChannelsOnSide().get( facing );
|
||||
final EnumFacing facing = connection.getKey();
|
||||
final AECableType connectionType = connection.getValue();
|
||||
final boolean cableBusAdjacent = renderState.getCableBusAdjacent().contains( facing );
|
||||
final int channels = renderState.getChannelsOnSide().get( facing );
|
||||
|
||||
switch( cableType )
|
||||
{
|
||||
@@ -269,9 +278,9 @@ public class CableBusBakedModel implements IBakedModel
|
||||
// If no core is present, just use the first part that comes into play
|
||||
for( EnumFacing side : renderState.getAttachments().keySet() )
|
||||
{
|
||||
List<ResourceLocation> models = renderState.getAttachments().get( side );
|
||||
IPartModel partModel = renderState.getAttachments().get( side );
|
||||
|
||||
for( ResourceLocation model : models )
|
||||
for( ResourceLocation model : partModel.getModels() )
|
||||
{
|
||||
IBakedModel bakedModel = partModels.get( model );
|
||||
|
||||
@@ -282,9 +291,11 @@ public class CableBusBakedModel implements IBakedModel
|
||||
|
||||
TextureAtlasSprite particleTexture = bakedModel.getParticleTexture();
|
||||
|
||||
// If a part sub-model has no particle texture (indicated by it being the missing texture), don't add it,
|
||||
// If a part sub-model has no particle texture (indicated by it being the missing texture), don't
|
||||
// add
|
||||
// it,
|
||||
// so we don't get ugly missing texture break particles.
|
||||
if ( textureMap.getMissingSprite() != particleTexture )
|
||||
if( textureMap.getMissingSprite() != particleTexture )
|
||||
{
|
||||
result.add( particleTexture );
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.api.util.AECableType;
|
||||
import appeng.api.util.AEColor;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class CableBusRenderState
|
||||
// connections contains a corresponding entry.
|
||||
private EnumMap<EnumFacing, Integer> channelsOnSide = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
private EnumMap<EnumFacing, List<ResourceLocation>> attachments = new EnumMap<>( EnumFacing.class );
|
||||
private EnumMap<EnumFacing, IPartModel> attachments = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
// For each attachment, this contains the distance from the edge until which a cable connection should be drawn
|
||||
private EnumMap<EnumFacing, Integer> attachmentConnections = new EnumMap<>( EnumFacing.class );
|
||||
@@ -68,7 +68,8 @@ public class CableBusRenderState
|
||||
// Contains the facade to use for each side that has a facade attached
|
||||
private EnumMap<EnumFacing, FacadeRenderState> facades = new EnumMap<>( EnumFacing.class );
|
||||
|
||||
// Contains the bounding boxes of all parts on the cable bus to allow facades to cut out holes for the parts. This list is only populated if there are
|
||||
// Contains the bounding boxes of all parts on the cable bus to allow facades to cut out holes for the parts. This
|
||||
// list is only populated if there are
|
||||
// facades on this cable bus
|
||||
private List<AxisAlignedBB> boundingBoxes = new ArrayList<>();
|
||||
|
||||
@@ -132,7 +133,7 @@ public class CableBusRenderState
|
||||
this.cableBusAdjacent = cableBusAdjacent;
|
||||
}
|
||||
|
||||
public EnumMap<EnumFacing, List<ResourceLocation>> getAttachments()
|
||||
public EnumMap<EnumFacing, IPartModel> getAttachments()
|
||||
{
|
||||
return attachments;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
|
||||
@@ -26,6 +26,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Vector3f;
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package appeng.client.render.crafting;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.client.render.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.vecmath.Vector3f;
|
||||
import javax.vecmath.Vector4f;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ package appeng.client.render.model;
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumMap;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.vecmath.Matrix4f;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import java.lang.reflect.Type;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
|
||||
Reference in New Issue
Block a user