Fixes #2561: Do not use unchecked casts for IContainerListener.

This commit is contained in:
yueh 2016-11-04 09:40:21 +01:00
parent d891e5da15
commit 6f15c2921a
4 changed files with 23 additions and 23 deletions

View File

@ -438,13 +438,11 @@ public abstract class AEBaseContainer extends Container
if( Platform.isServer() )
{
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
for( final SyncData sd : this.syncData.values() )
{
sd.tick( IContainerListener );
sd.tick( listener );
}
}
}

View File

@ -26,6 +26,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
@ -151,22 +152,24 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
this.setValidContainer( false );
}
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
if( this.prevStack != is )
{
// if the bars changed an item was probably made, so just send shit!
for( final Object s : this.inventorySlots )
for( final Slot s : this.inventorySlots )
{
if( s instanceof OptionalSlotRestrictedInput )
{
final OptionalSlotRestrictedInput sri = (OptionalSlotRestrictedInput) s;
IContainerListener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
listener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
}
}
( (EntityPlayerMP) IContainerListener ).isChangingQuantityOnly = false;
if( listener instanceof EntityPlayerMP )
{
( (EntityPlayerMP) listener ).isChangingQuantityOnly = false;
}
}
}

View File

@ -200,7 +200,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if( output != null && !this.isPattern( output ) )
{
return;
}// if nothing is there we should snag a new pattern.
} // if nothing is there we should snag a new pattern.
else if( output == null )
{
output = this.patternSlotIN.getStack();
@ -483,19 +483,19 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
{
if( s == this.patternSlotOUT && Platform.isServer() )
{
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
for( final Object g : this.inventorySlots )
for( final Slot slot : this.inventorySlots )
{
if( g instanceof OptionalSlotFake || g instanceof SlotFakeCraftingMatrix )
if( slot instanceof OptionalSlotFake || slot instanceof SlotFakeCraftingMatrix )
{
final Slot sri = (Slot) g;
IContainerListener.sendSlotContents( this, sri.slotNumber, sri.getStack() );
listener.sendSlotContents( this, slot.slotNumber, slot.getStack() );
}
}
( (EntityPlayerMP) IContainerListener ).isChangingQuantityOnly = false;
if( listener instanceof EntityPlayerMP )
{
( (EntityPlayerMP) listener ).isChangingQuantityOnly = false;
}
}
this.detectAndSendChanges();
}

View File

@ -168,11 +168,10 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
this.wirelessOut.putStack( term );
// update the two slots in question...
for( final Object crafter : this.listeners )
for( final IContainerListener listener : this.listeners )
{
final IContainerListener IContainerListener = (IContainerListener) crafter;
IContainerListener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
IContainerListener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
listener.sendSlotContents( this, this.wirelessIn.slotNumber, this.wirelessIn.getStack() );
listener.sendSlotContents( this, this.wirelessOut.slotNumber, this.wirelessOut.getStack() );
}
}
}