Listen to correct block update
We now listen to neighborChanged instead of onNeighborChange. This means computers correctly detect redstone updates. However, this leads to issues when moving turtles, so we defer the block update until the turtle has finished moving.
This commit is contained in:
parent
9b5f4a877c
commit
77d225d1fe
|
@ -14,6 +14,7 @@
|
|||
import dan200.computercraft.shared.computer.core.ComputerFamily;
|
||||
import dan200.computercraft.shared.computer.items.ItemComputer;
|
||||
import dan200.computercraft.shared.media.inventory.ContainerHeldItem;
|
||||
import dan200.computercraft.shared.media.items.ItemDiskLegacy;
|
||||
import dan200.computercraft.shared.media.items.ItemPrintout;
|
||||
import dan200.computercraft.shared.network.ComputerCraftPacket;
|
||||
import dan200.computercraft.shared.peripheral.diskdrive.TileDiskDrive;
|
||||
|
@ -28,6 +29,7 @@
|
|||
import net.minecraft.client.renderer.ItemMeshDefinition;
|
||||
import net.minecraft.client.renderer.block.model.ModelBakery;
|
||||
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
|
||||
import net.minecraft.client.renderer.color.IItemColor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
|
@ -47,6 +49,8 @@
|
|||
import net.minecraftforge.fml.common.FMLCommonHandler;
|
||||
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraftforge.fml.common.gameevent.TickEvent;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -62,12 +66,12 @@ public class ComputerCraftProxyClient extends ComputerCraftProxyCommon
|
|||
public ComputerCraftProxyClient()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
// IComputerCraftProxy implementation
|
||||
|
||||
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
{
|
||||
super.init();
|
||||
m_tick = 0;
|
||||
m_renderFrame = 0;
|
||||
|
@ -172,6 +176,10 @@ public ModelResourceLocation getModelLocation( ItemStack stack )
|
|||
"advanced_pocket_computer_off", "advanced_pocket_computer_on", "advanced_pocket_computer_blinking", "advanced_pocket_computer_on_modem_on", "advanced_pocket_computer_blinking_modem_on",
|
||||
} );
|
||||
|
||||
// Setup item colours
|
||||
mc.getItemColors().registerItemColorHandler(new DiskColorHandler(ComputerCraft.Items.disk), ComputerCraft.Items.disk);
|
||||
mc.getItemColors().registerItemColorHandler(new DiskColorHandler(ComputerCraft.Items.diskExpanded), ComputerCraft.Items.diskExpanded);
|
||||
|
||||
// Setup renderers
|
||||
ClientRegistry.bindTileEntitySpecialRenderer( TileMonitor.class, new TileEntityMonitorRenderer() );
|
||||
|
||||
|
@ -225,7 +233,7 @@ private void registerItemModel( Item item, ItemMeshDefinition definition, String
|
|||
ModelBakery.registerItemVariants( item, resources );
|
||||
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register( item, definition );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isClient()
|
||||
{
|
||||
|
@ -255,7 +263,7 @@ public Object getFixedWidthFontRenderer()
|
|||
{
|
||||
return m_fixedWidthFontRenderer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getRecordInfo( ItemStack recordStack )
|
||||
{
|
||||
|
@ -267,7 +275,7 @@ public String getRecordInfo( ItemStack recordStack )
|
|||
return super.getRecordInfo( recordStack );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void playRecord( SoundEvent record, String recordInfo, World world, BlockPos pos )
|
||||
{
|
||||
|
@ -278,19 +286,19 @@ public void playRecord( SoundEvent record, String recordInfo, World world, Block
|
|||
mc.ingameGUI.setRecordPlayingMessage( recordInfo );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getDiskDriveGUI( InventoryPlayer inventory, TileDiskDrive drive )
|
||||
{
|
||||
return new GuiDiskDrive( inventory, drive );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getComputerGUI( TileComputer computer )
|
||||
{
|
||||
return new GuiComputer( computer );
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Object getPrinterGUI( InventoryPlayer inventory, TilePrinter printer )
|
||||
{
|
||||
|
@ -405,7 +413,7 @@ private void registerForgeHandlers()
|
|||
FMLCommonHandler.instance().bus().register( handlers );
|
||||
MinecraftForge.EVENT_BUS.register( handlers );
|
||||
}
|
||||
|
||||
|
||||
public class ForgeHandlers
|
||||
{
|
||||
public ForgeHandlers()
|
||||
|
@ -491,4 +499,21 @@ public void onRenderTick( TickEvent.RenderTickEvent event )
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
private static class DiskColorHandler implements IItemColor
|
||||
{
|
||||
private final ItemDiskLegacy disk;
|
||||
|
||||
private DiskColorHandler(ItemDiskLegacy disk)
|
||||
{
|
||||
this.disk = disk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColorFromItemstack(ItemStack stack, int layer)
|
||||
{
|
||||
return layer == 0 ? 0xFFFFFF : disk.getColor(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ public final boolean onBlockActivated( World world, BlockPos pos, IBlockState st
|
|||
}
|
||||
|
||||
@Override
|
||||
public final void onNeighborChange( IBlockAccess world, BlockPos pos, BlockPos neighborPos )
|
||||
public final void neighborChanged( IBlockState state, World world, BlockPos pos, Block block )
|
||||
{
|
||||
TileEntity tile = world.getTileEntity( pos );
|
||||
if( tile != null && tile instanceof TileGeneric )
|
||||
|
|
|
@ -505,7 +505,7 @@ public boolean teleportTo( World world, BlockPos pos )
|
|||
}
|
||||
|
||||
// Create a new turtle
|
||||
if( world.isBlockLoaded( pos ) && world.setBlockState( pos, oldBlock.getDefaultState(), 3 ) )
|
||||
if( world.isBlockLoaded( pos ) && world.setBlockState( pos, oldBlock.getDefaultState(), 0 ) )
|
||||
{
|
||||
Block block = world.getBlockState( pos ).getBlock();
|
||||
if( block == oldBlock )
|
||||
|
@ -525,6 +525,7 @@ public boolean teleportTo( World world, BlockPos pos )
|
|||
oldWorld.setBlockToAir( oldPos );
|
||||
|
||||
// Make sure everybody knows about it
|
||||
newTurtle.updateBlock();
|
||||
newTurtle.updateInput();
|
||||
newTurtle.updateOutput();
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue