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:
yueh
2016-12-14 22:37:10 +01:00
committed by GitHub
parent 8bed7f223e
commit a14cf2204d
74 changed files with 525 additions and 320 deletions
@@ -23,8 +23,6 @@ import java.io.IOException;
import java.util.List;
import java.util.Random;
import com.google.common.collect.ImmutableList;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
@@ -44,18 +42,23 @@ import appeng.api.parts.BusSupport;
import appeng.api.parts.IPart;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.parts.PartItemStack;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class PartCableAnchor implements IPart
{
@PartModels
public static final List<ResourceLocation> MODELS = ImmutableList.of( new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor" ) );
public static final PartModel DEFAULT_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor" ) );
@PartModels
public static final PartModel FACADE_MODELS = new PartModel( false, new ResourceLocation( AppEng.MOD_ID, "part/cable_anchor_short" ) );
private ItemStack is = null;
private IPartHost host = null;
@@ -237,9 +240,16 @@ public class PartCableAnchor implements IPart
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
return MODELS;
if( this.host != null && this.host.getFacadeContainer().getFacade( this.mySide ) != null )
{
return FACADE_MODELS;
}
else
{
return DEFAULT_MODELS;
}
}
}
@@ -22,7 +22,6 @@ package appeng.parts.misc;
import java.util.EnumSet;
import java.util.List;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import net.minecraft.entity.player.EntityPlayer;
@@ -52,6 +51,7 @@ import appeng.api.networking.ticking.IGridTickable;
import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.data.IAEFluidStack;
@@ -66,6 +66,7 @@ import appeng.helpers.IPriorityHost;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.parts.PartBasicState;
import appeng.parts.PartModel;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
@@ -76,21 +77,15 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/interface_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_off" )
);
public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_off" ) );
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_on" )
);
public static final PartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_on" ) );
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/interface_has_channel" )
);
public static final PartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/interface_has_channel" ) );
private final DualityInterface duality = new DualityInterface( this.getProxy(), this );
@@ -421,7 +416,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( isActive() && isPowered() )
{
@@ -19,16 +19,14 @@
package appeng.parts.misc;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import appeng.api.parts.IPartModel;
import appeng.core.AppEng;
import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.parts.PartModel;
public class PartInvertedToggleBus extends PartToggleBus
@@ -36,9 +34,9 @@ public class PartInvertedToggleBus extends PartToggleBus
@PartModels
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/inverted_toggle_bus_base" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(MODEL_BASE, MODEL_STATUS_OFF);
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(MODEL_BASE, MODEL_STATUS_ON);
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
public static final PartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_STATUS_OFF );
public static final PartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_STATUS_ON );
public static final PartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_STATUS_HAS_CHANNEL );
@Reflected
public PartInvertedToggleBus( final ItemStack is )
@@ -57,7 +55,7 @@ public class PartInvertedToggleBus extends PartToggleBus
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( hasRedstoneFlag() && isActive() && isPowered() )
{
@@ -23,8 +23,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
@@ -58,6 +56,7 @@ import appeng.api.networking.ticking.TickRateModulation;
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.storage.ICellContainer;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEInventoryHandler;
@@ -84,6 +83,7 @@ import appeng.me.GridAccessException;
import appeng.me.storage.ITickingMonitor;
import appeng.me.storage.MEInventoryHandler;
import appeng.me.storage.MEMonitorIInventory;
import appeng.parts.PartModel;
import appeng.parts.automation.PartUpgradeable;
import appeng.tile.inventory.AppEngInternalAEInventory;
import appeng.tile.inventory.InvOperation;
@@ -96,22 +96,16 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
{
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_base" );
@PartModels
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_off" )
);
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_off" ) ) ;
@PartModels
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_on" )
);
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_on" ) ) ;
@PartModels
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(
MODEL_BASE,
new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" )
);
public static final IPartModel MODELS_HAS_CHANNEL =new PartModel( MODEL_BASE, new ResourceLocation( AppEng.MOD_ID, "part/storage_bus_has_channel" ) );
private final BaseActionSource mySrc;
private final AppEngInternalAEInventory Config = new AppEngInternalAEInventory( this, 63 );
private int priority = 0;
@@ -223,7 +217,9 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
private void resetCache( final boolean fullReset )
{
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost().getTile().getWorld().isRemote )
if( this.getHost() == null || this.getHost().getTile() == null || this.getHost().getTile().getWorld() == null || this.getHost()
.getTile()
.getWorld().isRemote )
{
return;
}
@@ -465,7 +461,8 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
if( this.getInstalledUpgrades( Upgrades.FUZZY ) > 0 )
{
this.handler.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
this.handler
.setPartitionList( new FuzzyPriorityList( priorityList, (FuzzyMode) this.getConfigManager().getSetting( Settings.FUZZY_MODE ) ) );
}
else
{
@@ -587,7 +584,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( isActive() && isPowered() )
{
@@ -602,5 +599,5 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
return MODELS_OFF;
}
}
}
@@ -23,8 +23,6 @@ import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import com.google.common.collect.ImmutableList;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
@@ -38,6 +36,7 @@ import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode;
import appeng.api.parts.IPartCollisionHelper;
import appeng.api.parts.IPartHost;
import appeng.api.parts.IPartModel;
import appeng.api.util.AECableType;
import appeng.api.util.AEPartLocation;
import appeng.core.AppEng;
@@ -45,6 +44,7 @@ import appeng.helpers.Reflected;
import appeng.items.parts.PartModels;
import appeng.me.helpers.AENetworkProxy;
import appeng.parts.PartBasicState;
import appeng.parts.PartModel;
import appeng.util.Platform;
@@ -60,9 +60,9 @@ public class PartToggleBus extends PartBasicState
@PartModels
public static final ResourceLocation MODEL_STATUS_HAS_CHANNEL = new ResourceLocation( AppEng.MOD_ID, "part/toggle_bus_status_has_channel" );
public static final List<ResourceLocation> MODELS_OFF = ImmutableList.of(MODEL_BASE, MODEL_STATUS_OFF);
public static final List<ResourceLocation> MODELS_ON = ImmutableList.of(MODEL_BASE, MODEL_STATUS_ON);
public static final List<ResourceLocation> MODELS_HAS_CHANNEL = ImmutableList.of(MODEL_BASE, MODEL_STATUS_HAS_CHANNEL);
public static final IPartModel MODELS_OFF = new PartModel( MODEL_BASE, MODEL_STATUS_OFF );
public static final IPartModel MODELS_ON = new PartModel( MODEL_BASE, MODEL_STATUS_ON );
public static final IPartModel MODELS_HAS_CHANNEL = new PartModel( MODEL_BASE, MODEL_STATUS_HAS_CHANNEL );
private static final int REDSTONE_FLAG = 4;
private final AENetworkProxy outerProxy = new AENetworkProxy( this, "outer", null, true );
@@ -86,8 +86,9 @@ public class PartToggleBus extends PartBasicState
return cf | ( this.getIntention() ? REDSTONE_FLAG : 0 );
}
public boolean hasRedstoneFlag() {
return (getClientFlags() & REDSTONE_FLAG) == REDSTONE_FLAG;
public boolean hasRedstoneFlag()
{
return ( getClientFlags() & REDSTONE_FLAG ) == REDSTONE_FLAG;
}
protected boolean getIntention()
@@ -222,7 +223,7 @@ public class PartToggleBus extends PartBasicState
}
@Override
public List<ResourceLocation> getStaticModels()
public IPartModel getStaticModels()
{
if( hasRedstoneFlag() && isActive() && isPowered() )
{