-
-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IntelligenceModding/Advanced-Peripherals-Features#59] Keyboard item …
…and simple screen to unlock the mouse
- Loading branch information
Showing
7 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/main/java/de/srendi/advancedperipherals/client/screens/KeyboardScreen.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package de.srendi.advancedperipherals.client.screens; | ||
|
||
import com.mojang.blaze3d.vertex.PoseStack; | ||
import de.srendi.advancedperipherals.client.screens.base.BaseScreen; | ||
import de.srendi.advancedperipherals.common.container.KeyboardContainer; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* A simple screen but without any rendering calls. Used to unlock the mouse so we can freely write stuff | ||
*/ | ||
public class KeyboardScreen extends BaseScreen<KeyboardContainer> { | ||
|
||
public KeyboardScreen(KeyboardContainer screenContainer, Inventory inv, Component titleIn) { | ||
super(screenContainer, inv, titleIn); | ||
} | ||
|
||
@Override | ||
public void render(@NotNull PoseStack matrixStack, int x, int y, float partialTicks) { | ||
} | ||
|
||
@Override | ||
protected void renderBg(@NotNull PoseStack matrixStack, float partialTicks, int x, int y) { | ||
} | ||
|
||
@Override | ||
public void renderBackground(@NotNull PoseStack pPoseStack) { | ||
} | ||
|
||
@Override | ||
public int getSizeX() { | ||
return 256; | ||
} | ||
|
||
@Override | ||
public int getSizeY() { | ||
return 256; | ||
} | ||
|
||
@Override | ||
public ResourceLocation getTexture() { | ||
return null; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
src/main/java/de/srendi/advancedperipherals/common/container/KeyboardContainer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package de.srendi.advancedperipherals.common.container; | ||
|
||
import de.srendi.advancedperipherals.AdvancedPeripherals; | ||
import de.srendi.advancedperipherals.common.container.base.BaseContainer; | ||
import de.srendi.advancedperipherals.common.setup.APContainerTypes; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class KeyboardContainer extends BaseContainer { | ||
|
||
public KeyboardContainer(int id, Inventory inventory, BlockPos pos, Level level) { | ||
super(APContainerTypes.KEYBOARD_CONTAINER.get(), id, inventory, pos, level); | ||
AdvancedPeripherals.debug("test"); | ||
} | ||
|
||
@Override | ||
public boolean stillValid(@NotNull Player playerIn) { | ||
return true; | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/de/srendi/advancedperipherals/common/items/KeyboardItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package de.srendi.advancedperipherals.common.items; | ||
|
||
import de.srendi.advancedperipherals.common.container.KeyboardContainer; | ||
import de.srendi.advancedperipherals.common.items.base.BaseItem; | ||
import de.srendi.advancedperipherals.common.items.base.IInventoryItem; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.world.MenuProvider; | ||
import net.minecraft.world.entity.player.Inventory; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.inventory.AbstractContainerMenu; | ||
import net.minecraft.world.item.ItemStack; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class KeyboardItem extends BaseItem implements IInventoryItem { | ||
|
||
public KeyboardItem() { | ||
super(new Properties().stacksTo(1)); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public MenuProvider createContainer(Player playerEntity, ItemStack itemStack) { | ||
return new MenuProvider() { | ||
@NotNull | ||
@Override | ||
public Component getDisplayName() { | ||
return Component.literal(""); | ||
} | ||
|
||
@Override | ||
public AbstractContainerMenu createMenu(int pContainerId, @NotNull Inventory playerInv, @NotNull Player player) { | ||
return new KeyboardContainer(pContainerId, playerInv, player.blockPosition(), player.getLevel()); | ||
} | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters