|
1 | 1 | package top.ctnstudio.futurefood.common.block.tile; |
2 | 2 |
|
3 | 3 | import net.minecraft.core.BlockPos; |
| 4 | +import net.minecraft.core.Direction; |
4 | 5 | import net.minecraft.core.HolderLookup; |
5 | 6 | import net.minecraft.core.component.DataComponents; |
6 | 7 | import net.minecraft.nbt.CompoundTag; |
@@ -227,6 +228,71 @@ protected void saveAdditional(CompoundTag nbt, HolderLookup.Provider provider) { |
227 | 228 | return new GluttonyMenu(containerId, playerInventory, itemHandler, energyData, workProgress); |
228 | 229 | } |
229 | 230 |
|
| 231 | + @Override |
| 232 | + public int[] getSlotsForFace(Direction direction) { |
| 233 | + if (direction == Direction.DOWN) { |
| 234 | + return new int[] { 0 }; |
| 235 | + } else if (direction == Direction.UP) { |
| 236 | + return new int[] { 1 }; |
| 237 | + } |
| 238 | + |
| 239 | + return new int[] { 2 }; |
| 240 | + } |
| 241 | + |
| 242 | + @Override |
| 243 | + public boolean canPlaceItemThroughFace(int i, ItemStack itemStack, @Nullable Direction direction) { |
| 244 | + // TODO true 改成检查 ItemStack 可以存储电力。 |
| 245 | + return i != 2 && (direction == Direction.UP || true); |
| 246 | + } |
| 247 | + |
| 248 | + @Override |
| 249 | + public boolean canTakeItemThroughFace(int i, ItemStack itemStack, Direction direction) { |
| 250 | + return direction == Direction.DOWN && i == 2; |
| 251 | + } |
| 252 | + |
| 253 | + @Override |
| 254 | + public int getContainerSize() { |
| 255 | + return this.itemHandler.getSlots(); |
| 256 | + } |
| 257 | + |
| 258 | + @Override |
| 259 | + public boolean isEmpty() { |
| 260 | + for(int i = 0; i < this.itemHandler.getSlots(); i++) { |
| 261 | + if (!this.itemHandler.getStackInSlot(i).isEmpty()) { |
| 262 | + return false; |
| 263 | + } |
| 264 | + } |
| 265 | + |
| 266 | + return true; |
| 267 | + } |
| 268 | + |
| 269 | + @Override |
| 270 | + public ItemStack getItem(int i) { |
| 271 | + return this.itemHandler.getStackInSlot(i); |
| 272 | + } |
| 273 | + |
| 274 | + @Override |
| 275 | + public ItemStack removeItem(int i, int i1) { |
| 276 | + return this.itemHandler.extractItem(i, i1, false); |
| 277 | + } |
| 278 | + |
| 279 | + @Override |
| 280 | + public ItemStack removeItemNoUpdate(int i) { |
| 281 | + return this.itemHandler.extractItem(i, i, false); |
| 282 | + } |
| 283 | + |
| 284 | + @Override |
| 285 | + public void setItem(int i, ItemStack itemStack) { |
| 286 | + this.itemHandler.setStackInSlot(i, itemStack); |
| 287 | + } |
| 288 | + |
| 289 | + @Override |
| 290 | + public void clearContent() { |
| 291 | + for(int i = 0; i < this.itemHandler.getSlots(); i++) { |
| 292 | + this.itemHandler.setStackInSlot(i, ItemStack.EMPTY); |
| 293 | + } |
| 294 | + } |
| 295 | + |
230 | 296 | public record Data(GluttonyBlockEntity blockEntity) implements ContainerData { |
231 | 297 | @Override |
232 | 298 | public int get(int index) { |
|
0 commit comments