mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Cherry pick several improvements from 1.13
- Move container opening (and gui handling) into a separate class
 - Move turtle/computer placement code onto the block
 - GUIs now use gui{Left,Top} instead of calculating it manually.
 - IPeripheralTile is now exposed in the API.
			
			
This commit is contained in:
		| @@ -7,6 +7,7 @@ | ||||
| package dan200.computercraft.api.media; | ||||
|  | ||||
| import dan200.computercraft.api.filesystem.IMount; | ||||
| import net.minecraft.item.Item; | ||||
| import net.minecraft.item.ItemStack; | ||||
| import net.minecraft.util.SoundEvent; | ||||
| import net.minecraft.world.World; | ||||
| @@ -16,7 +17,9 @@ import javax.annotation.Nullable; | ||||
|  | ||||
| /** | ||||
|  * Represents an item that can be placed in a disk drive and used by a Computer. | ||||
|  * Implement this interface on your Item class to allow it to be used in the drive. | ||||
|  * | ||||
|  * Implement this interface on your {@link Item} class to allow it to be used in the drive. Alternatively, register | ||||
|  * a {@link IMediaProvider}. | ||||
|  */ | ||||
| public interface IMedia | ||||
| { | ||||
|   | ||||
| @@ -23,7 +23,7 @@ public interface IMediaProvider | ||||
|      * Produce an IMedia implementation from an ItemStack. | ||||
|      * | ||||
|      * @param stack The stack from which to extract the media information. | ||||
|      * @return An IMedia implementation, or null if the item is not something you wish to handle | ||||
|      * @return An {@link IMedia} implementation, or {@code null} if the item is not something you wish to handle | ||||
|      * @see dan200.computercraft.api.ComputerCraftAPI#registerMediaProvider(IMediaProvider) | ||||
|      */ | ||||
|     @Nullable | ||||
|   | ||||
| @@ -6,6 +6,7 @@ | ||||
|  | ||||
| package dan200.computercraft.api.peripheral; | ||||
|  | ||||
| import net.minecraft.tileentity.TileEntity; | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.world.World; | ||||
| @@ -16,6 +17,8 @@ import javax.annotation.Nullable; | ||||
| /** | ||||
|  * This interface is used to create peripheral implementations for blocks. | ||||
|  * | ||||
|  * If you have a {@link TileEntity} which acts as a peripheral, you may alternatively implement {@link IPeripheralTile}. | ||||
|  * | ||||
|  * @see dan200.computercraft.api.ComputerCraftAPI#registerPeripheralProvider(IPeripheralProvider) | ||||
|  */ | ||||
| @FunctionalInterface | ||||
|   | ||||
| @@ -0,0 +1,32 @@ | ||||
| /* | ||||
|  * This file is part of the public ComputerCraft API - http://www.computercraft.info | ||||
|  * Copyright Daniel Ratcliffe, 2011-2019. This API may be redistributed unmodified and in full only. | ||||
|  * For help using the API, and posting your mods, visit the forums at computercraft.info. | ||||
|  */ | ||||
| package dan200.computercraft.api.peripheral; | ||||
|  | ||||
| import net.minecraft.util.EnumFacing; | ||||
| import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.world.World; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import javax.annotation.Nullable; | ||||
|  | ||||
| /** | ||||
|  * A {@link net.minecraft.tileentity.TileEntity} which may act as a peripheral. | ||||
|  * | ||||
|  * If you need more complex capabilities (such as handling TEs not belonging to your mod), you should use | ||||
|  * {@link IPeripheralProvider}. | ||||
|  */ | ||||
| public interface IPeripheralTile | ||||
| { | ||||
|     /** | ||||
|      * Get the peripheral on the given {@code side}. | ||||
|      * | ||||
|      * @param side The side to get the peripheral from. | ||||
|      * @return A peripheral, or {@code null} if there is not a peripheral here. | ||||
|      * @see IPeripheralProvider#getPeripheral(World, BlockPos, EnumFacing) | ||||
|      */ | ||||
|     @Nullable | ||||
|     IPeripheral getPeripheral( @Nonnull EnumFacing side ); | ||||
| } | ||||
| @@ -19,7 +19,6 @@ import net.minecraft.util.math.BlockPos; | ||||
| import net.minecraft.world.World; | ||||
| import net.minecraftforge.common.util.FakePlayer; | ||||
| import net.minecraftforge.event.world.BlockEvent; | ||||
| import net.minecraftforge.fml.common.eventhandler.Cancelable; | ||||
|  | ||||
| import javax.annotation.Nonnull; | ||||
| import java.util.Map; | ||||
| @@ -37,7 +36,6 @@ import java.util.Objects; | ||||
|  * Be aware that some events (such as {@link TurtleInventoryEvent}) do not necessarily interact | ||||
|  * with a block, simply objects within that block space. | ||||
|  */ | ||||
| @Cancelable | ||||
| public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
| { | ||||
|     private final World world; | ||||
| @@ -84,7 +82,6 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
|      * | ||||
|      * @see TurtleAction#DIG | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Dig extends TurtleBlockEvent | ||||
|     { | ||||
|         private final IBlockState block; | ||||
| @@ -142,7 +139,6 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
|      * | ||||
|      * @see TurtleAction#MOVE | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Move extends TurtleBlockEvent | ||||
|     { | ||||
|         public Move( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos ) | ||||
| @@ -156,7 +152,6 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
|      * | ||||
|      * @see TurtleAction#PLACE | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Place extends TurtleBlockEvent | ||||
|     { | ||||
|         private final ItemStack stack; | ||||
| @@ -188,7 +183,6 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
|      * | ||||
|      * @see TurtleAction#INSPECT | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Inspect extends TurtleBlockEvent | ||||
|     { | ||||
|         private final IBlockState state; | ||||
| @@ -229,7 +223,7 @@ public abstract class TurtleBlockEvent extends TurtlePlayerEvent | ||||
|         /** | ||||
|          * Add new information to the inspection result. Note this will override fields with the same name. | ||||
|          * | ||||
|          * @param newData The data to add. Note all values should be convertable to Lua (see | ||||
|          * @param newData The data to add. Note all values should be convertible to Lua (see | ||||
|          *                {@link dan200.computercraft.api.peripheral.IPeripheral#callMethod(IComputerAccess, ILuaContext, int, Object[])}). | ||||
|          */ | ||||
|         public void addData( @Nonnull Map<String, ?> newData ) | ||||
|   | ||||
| @@ -48,7 +48,6 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent | ||||
|      * | ||||
|      * @see TurtleAction#SUCK | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Suck extends TurtleInventoryEvent | ||||
|     { | ||||
|         public Suck( @Nonnull ITurtleAccess turtle, @Nonnull FakePlayer player, @Nonnull World world, @Nonnull BlockPos pos, @Nullable IItemHandler handler ) | ||||
| @@ -62,7 +61,6 @@ public abstract class TurtleInventoryEvent extends TurtleBlockEvent | ||||
|      * | ||||
|      * @see TurtleAction#DROP | ||||
|      */ | ||||
|     @Cancelable | ||||
|     public static class Drop extends TurtleInventoryEvent | ||||
|     { | ||||
|         private final ItemStack stack; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 SquidDev
					SquidDev