diff --git a/src/main/java/net/fabricmc/fabric/api/block/BreakInteractable.java b/src/main/java/net/fabricmc/fabric/api/block/AttackInteractable.java similarity index 96% rename from src/main/java/net/fabricmc/fabric/api/block/BreakInteractable.java rename to src/main/java/net/fabricmc/fabric/api/block/AttackInteractable.java index d7e024467..1785d69cc 100644 --- a/src/main/java/net/fabricmc/fabric/api/block/BreakInteractable.java +++ b/src/main/java/net/fabricmc/fabric/api/block/AttackInteractable.java @@ -26,7 +26,7 @@ import net.minecraft.world.World; /** * Convienence interface for blocks which listen to "break interactions" (left-click). */ -public interface BreakInteractable { +public interface AttackInteractable { /** * @return True if the block accepted the player and it should no longer be processed. */ diff --git a/src/main/java/net/fabricmc/fabric/api/client/gui/GuiFactory.java b/src/main/java/net/fabricmc/fabric/api/client/screen/ContainerScreenFactory.java similarity index 87% rename from src/main/java/net/fabricmc/fabric/api/client/gui/GuiFactory.java rename to src/main/java/net/fabricmc/fabric/api/client/screen/ContainerScreenFactory.java index 766f4d781..a8983f7b7 100644 --- a/src/main/java/net/fabricmc/fabric/api/client/gui/GuiFactory.java +++ b/src/main/java/net/fabricmc/fabric/api/client/screen/ContainerScreenFactory.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package net.fabricmc.fabric.api.client.gui; +package net.fabricmc.fabric.api.client.screen; import net.minecraft.client.gui.ContainerScreen; import net.minecraft.container.Container; @FunctionalInterface -public interface GuiFactory { +public interface ContainerScreenFactory { ContainerScreen create(C container); diff --git a/src/main/java/net/fabricmc/fabric/api/client/gui/GuiProviderRegistry.java b/src/main/java/net/fabricmc/fabric/api/client/screen/ScreenProviderRegistry.java similarity index 82% rename from src/main/java/net/fabricmc/fabric/api/client/gui/GuiProviderRegistry.java rename to src/main/java/net/fabricmc/fabric/api/client/screen/ScreenProviderRegistry.java index 573135f55..f6c6af1ad 100644 --- a/src/main/java/net/fabricmc/fabric/api/client/gui/GuiProviderRegistry.java +++ b/src/main/java/net/fabricmc/fabric/api/client/screen/ScreenProviderRegistry.java @@ -14,27 +14,27 @@ * limitations under the License. */ -package net.fabricmc.fabric.api.client.gui; +package net.fabricmc.fabric.api.client.screen; import net.fabricmc.fabric.api.container.ContainerFactory; import net.fabricmc.fabric.api.container.ContainerProviderRegistry; -import net.fabricmc.fabric.impl.client.gui.GuiProviderImpl; +import net.fabricmc.fabric.impl.client.gui.ScreenProviderRegistryImpl; import net.minecraft.client.gui.ContainerScreen; import net.minecraft.container.Container; import net.minecraft.util.Identifier; -public interface GuiProviderRegistry { +public interface ScreenProviderRegistry { - GuiProviderRegistry INSTANCE = GuiProviderImpl.INSTANCE; + ScreenProviderRegistry INSTANCE = ScreenProviderRegistryImpl.INSTANCE; /** * * Register a "Container -> ContainerScreen" factory. This is used only on the client side. * * @param identifier a shared identifier, this identifier should also be used to register a container using {@link ContainerProviderRegistry} - * @param guiFactory the supplier that should be used to create the new gui + * @param containerScreenFactory the supplier that should be used to create the new gui */ - void registerFactory(Identifier identifier, GuiFactory guiFactory); + void registerFactory(Identifier identifier, ContainerScreenFactory containerScreenFactory); /** * diff --git a/src/main/java/net/fabricmc/fabric/api/container/ContainerProviderRegistry.java b/src/main/java/net/fabricmc/fabric/api/container/ContainerProviderRegistry.java index 0d745c881..4acabaf35 100644 --- a/src/main/java/net/fabricmc/fabric/api/container/ContainerProviderRegistry.java +++ b/src/main/java/net/fabricmc/fabric/api/container/ContainerProviderRegistry.java @@ -16,7 +16,7 @@ package net.fabricmc.fabric.api.container; -import net.fabricmc.fabric.api.client.gui.GuiProviderRegistry; +import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; import net.fabricmc.fabric.impl.container.ContainerProviderImpl; import net.minecraft.container.Container; import net.minecraft.entity.player.PlayerEntity; @@ -34,7 +34,7 @@ public interface ContainerProviderRegistry { * * Register a "packet buffer -> container" factory. This is used both on the client and server side. * - * @param identifier a shared identifier, this identifier should also be used to register a container using {@link GuiProviderRegistry} + * @param identifier a shared identifier, this identifier should also be used to register a container using {@link ScreenProviderRegistry} * @param factory the ContainerFactory that should return a new {@link Container} */ void registerFactory(Identifier identifier, ContainerFactory factory); diff --git a/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java b/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java index aa05eb138..33457179d 100644 --- a/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java +++ b/src/main/java/net/fabricmc/fabric/impl/FabricAPIClientInitializer.java @@ -17,7 +17,7 @@ package net.fabricmc.fabric.impl; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.impl.client.gui.GuiProviderImpl; +import net.fabricmc.fabric.impl.client.gui.ScreenProviderRegistryImpl; import net.fabricmc.fabric.api.network.CustomPayloadPacketRegistry; import net.fabricmc.fabric.impl.registry.RegistrySyncManager; import net.minecraft.client.MinecraftClient; @@ -30,6 +30,6 @@ public class FabricAPIClientInitializer implements ClientModInitializer { RegistrySyncManager.receivePacket(ctx, buf, !MinecraftClient.getInstance().isInSingleplayer()); }); - ((GuiProviderImpl)GuiProviderImpl.INSTANCE).init(); + ((ScreenProviderRegistryImpl) ScreenProviderRegistryImpl.INSTANCE).init(); } } diff --git a/src/main/java/net/fabricmc/fabric/impl/FabricAPIInitializer.java b/src/main/java/net/fabricmc/fabric/impl/FabricAPIInitializer.java index 692ae4a62..6ea71ddd1 100644 --- a/src/main/java/net/fabricmc/fabric/impl/FabricAPIInitializer.java +++ b/src/main/java/net/fabricmc/fabric/impl/FabricAPIInitializer.java @@ -17,8 +17,8 @@ package net.fabricmc.fabric.impl; import net.fabricmc.api.ModInitializer; +import net.fabricmc.fabric.api.block.AttackInteractable; import net.fabricmc.fabric.api.event.player.AttackBlockCallback; -import net.fabricmc.fabric.api.block.BreakInteractable; import net.minecraft.block.BlockState; import net.minecraft.util.ActionResult; @@ -27,12 +27,12 @@ public class FabricAPIInitializer implements ModInitializer { public void onInitialize() { AttackBlockCallback.EVENT.register((player, world, hand, pos, direction) -> { BlockState state = world.getBlockState(pos); - if (state instanceof BreakInteractable) { - if (((BreakInteractable) state).onBreakInteract(state, world, pos, player, hand, direction)) { + if (state instanceof AttackInteractable) { + if (((AttackInteractable) state).onBreakInteract(state, world, pos, player, hand, direction)) { return ActionResult.FAILURE; } - } else if (state.getBlock() instanceof BreakInteractable) { - if (((BreakInteractable) state.getBlock()).onBreakInteract(state, world, pos, player, hand, direction)) { + } else if (state.getBlock() instanceof AttackInteractable) { + if (((AttackInteractable) state.getBlock()).onBreakInteract(state, world, pos, player, hand, direction)) { return ActionResult.FAILURE; } } diff --git a/src/main/java/net/fabricmc/fabric/impl/client/gui/GuiProviderImpl.java b/src/main/java/net/fabricmc/fabric/impl/client/gui/ScreenProviderRegistryImpl.java similarity index 85% rename from src/main/java/net/fabricmc/fabric/impl/client/gui/GuiProviderImpl.java rename to src/main/java/net/fabricmc/fabric/impl/client/gui/ScreenProviderRegistryImpl.java index 82695aaa6..51e5e73e2 100644 --- a/src/main/java/net/fabricmc/fabric/impl/client/gui/GuiProviderImpl.java +++ b/src/main/java/net/fabricmc/fabric/impl/client/gui/ScreenProviderRegistryImpl.java @@ -16,9 +16,9 @@ package net.fabricmc.fabric.impl.client.gui; -import net.fabricmc.fabric.api.client.gui.GuiProviderRegistry; +import net.fabricmc.fabric.api.client.screen.ContainerScreenFactory; +import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; import net.fabricmc.fabric.api.container.ContainerFactory; -import net.fabricmc.fabric.api.client.gui.GuiFactory; import net.fabricmc.fabric.impl.container.ContainerProviderImpl; import net.fabricmc.fabric.api.network.CustomPayloadPacketRegistry; import net.minecraft.client.MinecraftClient; @@ -31,12 +31,12 @@ import org.apache.logging.log4j.Logger; import java.util.HashMap; import java.util.Map; -public class GuiProviderImpl implements GuiProviderRegistry { +public class ScreenProviderRegistryImpl implements ScreenProviderRegistry { /** - * Use the instance provided by GuiProviderRegistry + * Use the instance provided by ScreenProviderRegistry */ - public static final GuiProviderRegistry INSTANCE = new GuiProviderImpl(); + public static final ScreenProviderRegistry INSTANCE = new ScreenProviderRegistryImpl(); private static final Logger LOGGER = LogManager.getLogger(); @@ -51,14 +51,14 @@ public class GuiProviderImpl implements GuiProviderRegistry { } @Override - public void registerFactory(Identifier identifier, GuiFactory guiFactory) { + public void registerFactory(Identifier identifier, ContainerScreenFactory containerScreenFactory) { registerFactory(identifier, (syncId, identifier1, player, buf) -> { C container = ContainerProviderImpl.INSTANCE.createContainer(syncId, identifier1, player, buf); if(container == null){ LOGGER.error("Could not open container for {} - a null object was created!", identifier1.toString()); return null; } - return guiFactory.create(container); + return containerScreenFactory.create(container); }); } diff --git a/src/test/java/net/fabricmc/fabric/containers/ContainerModClient.java b/src/test/java/net/fabricmc/fabric/containers/ContainerModClient.java index c851a9c9f..372225958 100644 --- a/src/test/java/net/fabricmc/fabric/containers/ContainerModClient.java +++ b/src/test/java/net/fabricmc/fabric/containers/ContainerModClient.java @@ -18,7 +18,7 @@ package net.fabricmc.fabric.containers; import com.mojang.blaze3d.platform.GlStateManager; import net.fabricmc.api.ClientModInitializer; -import net.fabricmc.fabric.api.client.gui.GuiProviderRegistry; +import net.fabricmc.fabric.api.client.screen.ScreenProviderRegistry; import net.minecraft.client.gui.ContainerScreen; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.text.StringTextComponent; @@ -30,16 +30,16 @@ public class ContainerModClient implements ClientModInitializer { @Override public void onInitializeClient() { //Registers a gui factory that opens our example gui, this reads the block pos from the buffer - GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER, (syncId, identifier, player, buf) -> { + ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER, (syncId, identifier, player, buf) -> { BlockPos pos = buf.readBlockPos(); return new ExampleContainerScreen(syncId, pos, player); }); //Registers a gui factory that opens our example gui, this uses the container created by ContainerProviderRegistry - GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER_2, ExampleContainerScreen2::new); + ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_CONTAINER_2, ExampleContainerScreen2::new); //Registers a gui factory that opens our example inventory gui - GuiProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_INVENTORY_CONTAINER, ExampleInventoryContainerScreen::new); + ScreenProviderRegistry.INSTANCE.registerFactory(ContainerMod.EXAMPLE_INVENTORY_CONTAINER, ExampleInventoryContainerScreen::new); } //A container gui that shows the block pos that was sent @@ -59,7 +59,7 @@ public class ContainerModClient implements ClientModInitializer { } - //A container gui that shows how you can take in a container provided by a GuiFactory + //A container gui that shows how you can take in a container provided by a ContainerScreenFactory public static class ExampleContainerScreen2 extends ContainerScreen { BlockPos pos;