Compare commits

...

3 Commits

Author SHA1 Message Date
yueh f0e45c7a3c Fixes #3288: Fixes various item rotations when held in 3rd person. (#3330) 2018-01-14 14:36:04 +01:00
fscan cbfc88c87f Fix light sync (#3304)
* Sync light opacity changes to client
* While at it, also fix Light P2P
* Use int for opacity, dont store it in NBT
2018-01-14 13:44:12 +01:00
yueh 8c5842aca9 Fixes #3315: Slightly more permissive checks for autocrafting (#3319)
* Fixes #3315: Slightly more permissive checks for autocrafting

Also fixes a bug in the fallback for looking up patterns to only use
ItemStack.EMPTY.
2018-01-14 13:43:31 +01:00
19 changed files with 71 additions and 37 deletions
@@ -47,7 +47,7 @@ public enum TickRates
ItemTunnel( 5, 60 ),
LightTunnel( 5, 120 ),
LightTunnel( 5, 60 ),
OpenComputersTunnel( 1, 5 ),
+2 -1
View File
@@ -489,7 +489,8 @@ public class CraftingGridCache implements ICraftingGrid, ICraftingProviderHelper
if( ais.getItem() == whatToCraft.getItem() && ( !ais.getItem().getHasSubtypes() || ais.getItemDamage() == whatToCraft.getItemDamage() ) )
{
// TODO: check if OK
if( details.isValidItemForSlot( slotIndex, ais.createItemStack(), world ) )
// TODO: this is slightly hacky, but fine as long as we only deal with itemstacks
if( details.isValidItemForSlot( slotIndex, ais.asItemStackRepresentation(), world ) )
{
return this.craftableItems.get( ais );
}
@@ -55,7 +55,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
}
private int lastValue = 0;
private float opacity = -1;
private int opacity = -1;
public PartP2PLight( final ItemStack is )
{
@@ -81,15 +81,21 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
{
super.writeToStream( data );
data.writeInt( this.isOutput() ? this.lastValue : 0 );
data.writeInt( this.opacity );
}
@Override
public boolean readFromStream( final ByteBuf data ) throws IOException
{
super.readFromStream( data );
final int oldValue = this.lastValue;
final int oldOpacity = this.opacity;
this.lastValue = data.readInt();
this.opacity = data.readInt();
this.setOutput( this.lastValue > 0 );
return false;
return lastValue != oldValue || oldOpacity != this.opacity;
}
private boolean doWork()
@@ -126,14 +132,15 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
this.opacity = -1;
this.doWork();
if( this.isOutput() )
if( this.isOutput() && pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
{
this.opacity = -1;
this.getHost().markForUpdate();
}
else
{
this.doWork();
}
}
@Override
@@ -168,10 +175,6 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
public void readFromNBT( final NBTTagCompound tag )
{
super.readFromNBT( tag );
if( tag.hasKey( "opacity" ) )
{
this.opacity = tag.getFloat( "opacity" );
}
this.lastValue = tag.getInteger( "lastValue" );
}
@@ -179,7 +182,6 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
public void writeToNBT( final NBTTagCompound tag )
{
super.writeToNBT( tag );
tag.setFloat( "opacity", this.opacity );
tag.setInteger( "lastValue", this.lastValue );
}
@@ -219,7 +221,7 @@ public class PartP2PLight extends PartP2PTunnel<PartP2PLight> implements IGridTi
@Override
public TickRateModulation tickingRequest( final IGridNode node, final int ticksSinceLastCall )
{
return this.doWork() ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
return this.doWork() ? TickRateModulation.URGENT : TickRateModulation.SLOWER;
}
public float getPowerDrainPerTick()
@@ -70,7 +70,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
private byte spin = 0; // 0-3
private int clientFlags = 0; // sent as byte.
private float opacity = -1;
private int opacity = -1;
public AbstractPartReporting( final ItemStack is )
{
@@ -128,10 +128,6 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
public void readFromNBT( final NBTTagCompound data )
{
super.readFromNBT( data );
if( data.hasKey( "opacity" ) )
{
this.opacity = data.getFloat( "opacity" );
}
this.spin = data.getByte( "spin" );
}
@@ -139,7 +135,6 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
public void writeToNBT( final NBTTagCompound data )
{
super.writeToNBT( data );
data.setFloat( "opacity", this.opacity );
data.setByte( "spin", this.getSpin() );
}
@@ -172,6 +167,7 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
}
data.writeByte( (byte) this.getClientFlags() );
data.writeInt( this.opacity );
}
@Override
@@ -179,9 +175,13 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
{
super.readFromStream( data );
final int oldFlags = this.getClientFlags();
final int oldOpacity = this.opacity;
this.clientFlags = data.readByte();
this.opacity = data.readInt();
this.spin = (byte) ( this.getClientFlags() & 3 );
if( this.getClientFlags() == oldFlags )
if( this.getClientFlags() == oldFlags && this.opacity == oldOpacity )
{
return false;
}
@@ -83,13 +83,14 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
protected boolean readFromStream( final ByteBuf data ) throws IOException
{
final boolean c = super.readFromStream( data );
final boolean ret = this.getCableBus().readFromStream( data );
boolean ret = this.getCableBus().readFromStream( data );
final int newLV = this.getCableBus().getLightValue();
if( newLV != this.oldLV )
{
this.oldLV = newLV;
this.world.checkLight( this.pos );
ret = true;
}
this.updateTileSetting();
@@ -189,7 +190,6 @@ public class TileCableBus extends AEBaseTile implements AEMultiTile, ICustomColl
{
this.oldLV = newLV;
this.world.checkLight( this.pos );
// world.updateAllLightTypes( xCoord, yCoord, zCoord );
}
super.markForUpdate();
@@ -180,10 +180,25 @@ public class ItemComparisonHelper
{
return true;
}
final boolean isLeftEmpty = left == null || left.hasNoTags();
final boolean isRightEmpty = right == null || right.hasNoTags();
if( isLeftEmpty && isRightEmpty )
{
return true;
}
if( isLeftEmpty != isRightEmpty )
{
return false;
}
if( left != null )
{
return left.equals( right );
}
return false;
}
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/certus_quartz_axe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/certus_quartz_hoe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/certus_quartz_pickaxe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/certus_quartz_spade"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/certus_quartz_sword"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/charged_staff"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/entropy_manipulator"
}
@@ -1,6 +1,22 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/matter_cannon"
},
"display": {
"thirdperson_righthand": {
"rotation": [
0,
-90,
0
]
},
"thirdperson_lefthand": {
"rotation": [
0,
90,
0
]
}
}
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/nether_quartz_axe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/nether_quartz_hoe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/nether_quartz_pickaxe"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/nether_quartz_spade"
}
@@ -1,5 +1,5 @@
{
"parent": "item/generated",
"parent": "item/handheld",
"textures": {
"layer0": "appliedenergistics2:items/nether_quartz_sword"
}