Tweak Casting Table Texture Tweak Casting Table Recipe Update Mappings
This commit is contained in:
parent
7dac950cca
commit
a8b12d9d5c
@ -1,5 +1,10 @@
|
|||||||
### Changelog
|
### Changelog
|
||||||
|
|
||||||
|
**1.1.4**
|
||||||
|
* Tweak Casting Table Texture
|
||||||
|
* Tweak Casting Table Recipe
|
||||||
|
* Update Mappings
|
||||||
|
|
||||||
**1.1.3**
|
**1.1.3**
|
||||||
* Fix Shift-Clicking in Casting Table
|
* Fix Shift-Clicking in Casting Table
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
minecraft_version = 20w10a
|
minecraft_version = 20w10a
|
||||||
curseforge_id = 365308
|
curseforge_id = 365308
|
||||||
simple_minecraft_version = 1.16-Snapshot
|
simple_minecraft_version = 1.16-Snapshot
|
||||||
yarn_mappings = 20w10a+build.12
|
yarn_mappings = 20w10a+build.16
|
||||||
loader_version = 0.7.8+build.186
|
loader_version = 0.7.8+build.187
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
mod_version = 1.1.3
|
mod_version = 1.1.4
|
||||||
maven_group = com.thebrokenrail
|
maven_group = com.thebrokenrail
|
||||||
archives_base_name = sorcerycraft
|
archives_base_name = sorcerycraft
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.thebrokenrail.sorcerycraft;
|
package com.thebrokenrail.sorcerycraft;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.block.CastingTableBlock;
|
import com.thebrokenrail.sorcerycraft.block.CastingTableBlock;
|
||||||
import com.thebrokenrail.sorcerycraft.block.CastingTableContainer;
|
import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.client.block.CastingTableScreen;
|
import com.thebrokenrail.sorcerycraft.client.block.CastingTableScreen;
|
||||||
import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer;
|
import com.thebrokenrail.sorcerycraft.client.entity.SpellEntityRenderer;
|
||||||
import com.thebrokenrail.sorcerycraft.command.SpellCommand;
|
import com.thebrokenrail.sorcerycraft.command.SpellCommand;
|
||||||
@ -156,7 +156,7 @@ public class SorceryCraft implements ModInitializer, ClientModInitializer {
|
|||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
EntityRendererRegistry.INSTANCE.register(SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
EntityRendererRegistry.INSTANCE.register(SPELL_ENTITY, (entityRenderDispatcher, context) -> new SpellEntityRenderer(entityRenderDispatcher));
|
||||||
ScreenProviderRegistry.INSTANCE.<CastingTableContainer>registerFactory(new Identifier(NAMESPACE, "casting_table"), (container) -> {
|
ScreenProviderRegistry.INSTANCE.<CastingTableScreenHandler>registerFactory(new Identifier(NAMESPACE, "casting_table"), (container) -> {
|
||||||
assert MinecraftClient.getInstance().player != null;
|
assert MinecraftClient.getInstance().player != null;
|
||||||
return new CastingTableScreen(container, MinecraftClient.getInstance().player.inventory, new TranslatableText("block." + SorceryCraft.NAMESPACE + ".casting_table"));
|
return new CastingTableScreen(container, MinecraftClient.getInstance().player.inventory, new TranslatableText("block." + SorceryCraft.NAMESPACE + ".casting_table"));
|
||||||
});
|
});
|
||||||
|
@ -6,10 +6,11 @@ import net.fabricmc.fabric.api.container.ContainerProviderRegistry;
|
|||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.Material;
|
import net.minecraft.block.Material;
|
||||||
import net.minecraft.container.BlockContext;
|
import net.minecraft.client.gui.screen.ingame.CraftingTableScreen;
|
||||||
import net.minecraft.container.NameableContainerFactory;
|
|
||||||
import net.minecraft.container.SimpleNamedContainerFactory;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
|
import net.minecraft.screen.BlockContext;
|
||||||
|
import net.minecraft.screen.NameableScreenHandlerFactory;
|
||||||
|
import net.minecraft.screen.SimpleNamedScreenHandlerFactory;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.TranslatableText;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
@ -33,7 +34,7 @@ public class CastingTableBlock extends Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NameableContainerFactory createContainerFactory(BlockState state, World world, BlockPos pos) {
|
public NameableScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
|
||||||
return new SimpleNamedContainerFactory((i, playerInventory, playerEntity) -> new CastingTableContainer(i, playerInventory, BlockContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> new CastingTableScreenHandler(i, playerInventory, BlockContext.create(world, pos)), new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,16 +5,16 @@ import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
|||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.registry.SpellRegistry;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
||||||
import net.minecraft.container.BlockContext;
|
|
||||||
import net.minecraft.container.Container;
|
|
||||||
import net.minecraft.container.ContainerType;
|
|
||||||
import net.minecraft.container.Slot;
|
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.inventory.BasicInventory;
|
import net.minecraft.inventory.BasicInventory;
|
||||||
import net.minecraft.inventory.CraftingResultInventory;
|
import net.minecraft.inventory.CraftingResultInventory;
|
||||||
import net.minecraft.inventory.Inventory;
|
import net.minecraft.inventory.Inventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.screen.BlockContext;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
|
import net.minecraft.screen.ScreenHandlerType;
|
||||||
|
import net.minecraft.screen.slot.Slot;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
@ -24,20 +24,20 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class CastingTableContainer extends Container {
|
public class CastingTableScreenHandler extends ScreenHandler {
|
||||||
private final Inventory inventory;
|
private final Inventory inventory;
|
||||||
private final Inventory result;
|
private final Inventory result;
|
||||||
private final Spell[] spells;
|
private final Spell[] spells;
|
||||||
private final BlockContext context;
|
private final BlockContext context;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public CastingTableContainer(int syncId, PlayerInventory playerInventory, BlockContext blockContext) {
|
public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, BlockContext blockContext) {
|
||||||
super(ContainerType.STONECUTTER, syncId);
|
super(ScreenHandlerType.STONECUTTER, syncId);
|
||||||
|
|
||||||
inventory = new BasicInventory(2) {
|
inventory = new BasicInventory(2) {
|
||||||
public void markDirty() {
|
public void markDirty() {
|
||||||
super.markDirty();
|
super.markDirty();
|
||||||
CastingTableContainer.this.onContentChanged(this);
|
CastingTableScreenHandler.this.onContentChanged(this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
context = blockContext;
|
context = blockContext;
|
||||||
@ -99,8 +99,8 @@ public class CastingTableContainer extends Container {
|
|||||||
|
|
||||||
context.run((BiConsumer<World, BlockPos>) SorceryCraft::playSpellSound);
|
context.run((BiConsumer<World, BlockPos>) SorceryCraft::playSpellSound);
|
||||||
|
|
||||||
CastingTableContainer.this.inventory.setInvStack(0, ItemStack.EMPTY);
|
CastingTableScreenHandler.this.inventory.setInvStack(0, ItemStack.EMPTY);
|
||||||
CastingTableContainer.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount());
|
CastingTableScreenHandler.this.inventory.takeInvStack(1, spells[index].getItemCost().getCount());
|
||||||
return stack;
|
return stack;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -118,7 +118,7 @@ public class CastingTableContainer extends Container {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTakeResult(PlayerEntity playerEntity) {
|
public boolean canTakeResult(PlayerEntity playerEntity) {
|
||||||
return (playerEntity.isCreative() || playerEntity.experienceLevel >= spells[index].getXPCost()) && spells[index].getXPCost() > 0;
|
return playerEntity.isCreative() || playerEntity.experienceLevel >= spells[index].getXPCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIndex(int index) {
|
public void setIndex(int index) {
|
@ -2,14 +2,14 @@ package com.thebrokenrail.sorcerycraft.client.block;
|
|||||||
|
|
||||||
import com.mojang.blaze3d.systems.RenderSystem;
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.block.CastingTableContainer;
|
import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
import com.thebrokenrail.sorcerycraft.packet.SelectSpellC2SPacket;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellTag;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.font.TextRenderer;
|
import net.minecraft.client.font.TextRenderer;
|
||||||
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
import net.minecraft.client.gui.screen.ingame.ScreenWithHandler;
|
||||||
import net.minecraft.client.gui.widget.ButtonWidget;
|
import net.minecraft.client.gui.widget.ButtonWidget;
|
||||||
import net.minecraft.entity.player.PlayerInventory;
|
import net.minecraft.entity.player.PlayerInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
@ -19,22 +19,22 @@ import net.minecraft.util.Identifier;
|
|||||||
import net.minecraft.util.math.MathHelper;
|
import net.minecraft.util.math.MathHelper;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
public class CastingTableScreen extends ScreenWithHandler<CastingTableScreenHandler> {
|
||||||
private static final Identifier TEXTURE = new Identifier("textures/gui/container/villager2.png");
|
private static final Identifier TEXTURE = new Identifier("textures/gui/container/villager2.png");
|
||||||
private int selectedIndex;
|
private int selectedIndex;
|
||||||
private int indexStartOffset;
|
private int indexStartOffset;
|
||||||
private boolean scrolling;
|
private boolean scrolling;
|
||||||
|
|
||||||
public CastingTableScreen(CastingTableContainer container, PlayerInventory inventory, Text title) {
|
public CastingTableScreen(CastingTableScreenHandler container, PlayerInventory inventory, Text title) {
|
||||||
super(container, inventory, title);
|
super(container, inventory, title);
|
||||||
containerWidth = 276;
|
backgroundWidth = 276;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground(int mouseX, int mouseY) {
|
protected void drawForeground(int mouseX, int mouseY) {
|
||||||
int j = containerHeight - 94;
|
int titleY = backgroundHeight - 94;
|
||||||
textRenderer.draw(title.asFormattedString(), (float) (49 + this.containerWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
textRenderer.draw(title.asFormattedString(), (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
||||||
textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) j, 4210752);
|
textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) titleY, 4210752);
|
||||||
String spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells").getString();
|
String spells = new TranslatableText("container." + SorceryCraft.NAMESPACE + ".spells").getString();
|
||||||
textRenderer.draw(spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
textRenderer.draw(spells, (float) (5 - textRenderer.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
||||||
renderXPCost();
|
renderXPCost();
|
||||||
@ -45,9 +45,9 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - containerWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - containerHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
blit(i, j, getZOffset(), 0.0F, 0.0F, containerWidth, containerHeight, 256, 512);
|
blit(i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,9 +63,9 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
if (button.isHovered()) {
|
if (button.isHovered()) {
|
||||||
button.renderToolTip(mouseX, mouseY);
|
button.renderToolTip(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
button.visible = button.index < container.getRecipes().length;
|
button.visible = button.index < handler.getRecipes().length;
|
||||||
if (button.visible) {
|
if (button.visible) {
|
||||||
Spell spell = container.getRecipes()[button.getIndex() + indexStartOffset];
|
Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset];
|
||||||
button.setMessage(SpellTag.getTranslatedSpell(spell.getID(), spell.getLevel(), true).getString());
|
button.setMessage(SpellTag.getTranslatedSpell(spell.getID(), spell.getLevel(), true).getString());
|
||||||
button.setFocused((button.getIndex() + indexStartOffset) == selectedIndex);
|
button.setFocused((button.getIndex() + indexStartOffset) == selectedIndex);
|
||||||
}
|
}
|
||||||
@ -73,11 +73,11 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderScrollbar() {
|
private void renderScrollbar() {
|
||||||
Spell[] spells = container.getRecipes();
|
Spell[] spells = handler.getRecipes();
|
||||||
assert client != null;
|
assert client != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
client.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - containerWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - containerHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
int k = spells.length + 1 - 7;
|
int k = spells.length + 1 - 7;
|
||||||
|
|
||||||
if (k > 1) {
|
if (k > 1) {
|
||||||
@ -95,11 +95,11 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderItems() {
|
private void renderItems() {
|
||||||
int i = (width - containerWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - containerHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
int k = j + 16 + 1;
|
int k = j + 16 + 1;
|
||||||
|
|
||||||
Spell[] spells = container.getRecipes();
|
Spell[] spells = handler.getRecipes();
|
||||||
for (int x = 0; x < spells.length; x++) {
|
for (int x = 0; x < spells.length; x++) {
|
||||||
if (!canScroll(spells.length) || (x >= indexStartOffset && x < 7 + indexStartOffset)) {
|
if (!canScroll(spells.length) || (x >= indexStartOffset && x < 7 + indexStartOffset)) {
|
||||||
ItemStack itemStack = spells[x].getItemCost();
|
ItemStack itemStack = spells[x].getItemCost();
|
||||||
@ -115,20 +115,20 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderXPCost() {
|
private void renderXPCost() {
|
||||||
if (container.getRecipes().length > 0) {
|
if (handler.getRecipes().length > 0) {
|
||||||
int i = container.getRecipes()[selectedIndex].getXPCost();
|
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
||||||
int j = 8453920;
|
int color = 8453920;
|
||||||
assert client != null;
|
assert client != null;
|
||||||
assert client.player != null;
|
assert client.player != null;
|
||||||
String string = new TranslatableText("container.repair.cost", i).getString();
|
String string = new TranslatableText("container.repair.cost", cost).getString();
|
||||||
if (!container.canTakeResult(playerInventory.player)) {
|
if (!handler.canTakeResult(playerInventory.player)) {
|
||||||
j = 16736352;
|
color = 16736352;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x2 = containerWidth - 8;
|
int x2 = backgroundWidth - 8;
|
||||||
int x1 = x2 - textRenderer.getStringWidth(string);
|
int x1 = x2 - textRenderer.getStringWidth(string);
|
||||||
fill(x1, 65, x2, 77, 1325400064);
|
fill(x1, 65, x2, 77, 1325400064);
|
||||||
textRenderer.drawWithShadow(string, (float) x1, 67.0F, j);
|
textRenderer.drawWithShadow(string, (float) x1, 67.0F, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,7 +138,7 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double d, double e, double amount) {
|
public boolean mouseScrolled(double d, double e, double amount) {
|
||||||
int i = container.getRecipes().length;
|
int i = handler.getRecipes().length;
|
||||||
if (this.canScroll(i)) {
|
if (this.canScroll(i)) {
|
||||||
int j = i - 7;
|
int j = i - 7;
|
||||||
indexStartOffset = (int) ((double) indexStartOffset - amount);
|
indexStartOffset = (int) ((double) indexStartOffset - amount);
|
||||||
@ -150,7 +150,7 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
public boolean mouseDragged(double mouseX, double mouseY, int button, double deltaX, double deltaY) {
|
||||||
int i = container.getRecipes().length;
|
int i = handler.getRecipes().length;
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
int j = y + 18;
|
int j = y + 18;
|
||||||
int k = j + 139;
|
int k = j + 139;
|
||||||
@ -167,9 +167,9 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
scrolling = false;
|
scrolling = false;
|
||||||
int i = (width - containerWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - containerHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
if (canScroll(container.getRecipes().length) && mouseX > (double) (i + 94) && mouseX < (double) (i + 94 + 6) && mouseY > (double) (j + 18) && mouseY <= (double) (j + 18 + 139 + 1)) {
|
if (canScroll(handler.getRecipes().length) && mouseX > (double) (i + 94) && mouseX < (double) (i + 94 + 6) && mouseY > (double) (j + 18) && mouseY <= (double) (j + 18 + 139 + 1)) {
|
||||||
scrolling = true;
|
scrolling = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncRecipeIndex() {
|
private void syncRecipeIndex() {
|
||||||
container.setIndex(selectedIndex);
|
handler.setIndex(selectedIndex);
|
||||||
assert client != null;
|
assert client != null;
|
||||||
SelectSpellC2SPacket.send(client, selectedIndex);
|
SelectSpellC2SPacket.send(client, selectedIndex);
|
||||||
}
|
}
|
||||||
@ -187,8 +187,8 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
int i = (width - containerWidth) / 2;
|
int i = (width - backgroundWidth) / 2;
|
||||||
int j = (height - containerHeight) / 2;
|
int j = (height - backgroundHeight) / 2;
|
||||||
int k = j + 16 + 2;
|
int k = j + 16 + 2;
|
||||||
|
|
||||||
for (int l = 0; l < 7; ++l) {
|
for (int l = 0; l < 7; ++l) {
|
||||||
@ -220,8 +220,8 @@ public class CastingTableScreen extends ContainerScreen<CastingTableContainer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renderToolTip(int mouseX, int mouseY) {
|
public void renderToolTip(int mouseX, int mouseY) {
|
||||||
if (hovered && container.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
||||||
ItemStack itemStack = container.getRecipes()[index + indexStartOffset].getItemCost();
|
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
renderTooltip(itemStack, mouseX, mouseY);
|
renderTooltip(itemStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import net.fabricmc.api.EnvType;
|
|||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
import net.minecraft.client.render.entity.EntityRenderDispatcher;
|
||||||
import net.minecraft.client.render.entity.EntityRenderer;
|
import net.minecraft.client.render.entity.EntityRenderer;
|
||||||
import net.minecraft.container.PlayerContainer;
|
import net.minecraft.screen.PlayerScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
@ -16,6 +16,6 @@ public class SpellEntityRenderer extends EntityRenderer<SpellEntity> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Identifier getTexture(SpellEntity spellEntity) {
|
public Identifier getTexture(SpellEntity spellEntity) {
|
||||||
return PlayerContainer.BLOCK_ATLAS_TEXTURE;
|
return PlayerScreenHandler.BLOCK_ATLAS_TEXTURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,21 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.packet;
|
package com.thebrokenrail.sorcerycraft.packet;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
import com.thebrokenrail.sorcerycraft.block.CastingTableContainer;
|
import com.thebrokenrail.sorcerycraft.block.CastingTableScreenHandler;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import net.fabricmc.fabric.api.network.PacketContext;
|
import net.fabricmc.fabric.api.network.PacketContext;
|
||||||
import net.minecraft.client.MinecraftClient;
|
import net.minecraft.client.MinecraftClient;
|
||||||
import net.minecraft.container.Container;
|
|
||||||
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
import net.minecraft.network.packet.c2s.play.CustomPayloadC2SPacket;
|
||||||
|
import net.minecraft.screen.ScreenHandler;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.PacketByteBuf;
|
import net.minecraft.util.PacketByteBuf;
|
||||||
|
|
||||||
public class SelectSpellC2SPacket {
|
public class SelectSpellC2SPacket {
|
||||||
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
||||||
int index = bytes.readInt();
|
int index = bytes.readInt();
|
||||||
Container container = context.getPlayer().container;
|
ScreenHandler handler = context.getPlayer().currentScreenHandler;
|
||||||
if (container instanceof CastingTableContainer) {
|
if (handler instanceof CastingTableScreenHandler) {
|
||||||
CastingTableContainer merchantContainer = (CastingTableContainer) container;
|
CastingTableScreenHandler merchantContainer = (CastingTableScreenHandler) handler;
|
||||||
merchantContainer.setIndex(index);
|
merchantContainer.setIndex(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 362 B |
@ -1,19 +1,19 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:block",
|
"type": "minecraft:block",
|
||||||
"pools": [
|
"pools": [
|
||||||
{
|
|
||||||
"rolls": 1,
|
|
||||||
"entries": [
|
|
||||||
{
|
{
|
||||||
"type": "minecraft:item",
|
"rolls": 1,
|
||||||
"name": "sorcerycraft:casting_table"
|
"entries": [
|
||||||
|
{
|
||||||
|
"type": "minecraft:item",
|
||||||
|
"name": "sorcerycraft:casting_table"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"conditions": [
|
||||||
|
{
|
||||||
|
"condition": "minecraft:survives_explosion"
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
"conditions": [
|
|
||||||
{
|
|
||||||
"condition": "minecraft:survives_explosion"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
@ -1,24 +1,23 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
"LCL",
|
"LSL",
|
||||||
"CDC",
|
"SDS",
|
||||||
"LCL"
|
"LSL"
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"L": {
|
"L": {
|
||||||
"item": "minecraft:lapis_lazuli"
|
"item": "minecraft:lapis_lazuli"
|
||||||
|
},
|
||||||
|
"S": {
|
||||||
|
"item": "minecraft:smooth_stone"
|
||||||
|
},
|
||||||
|
"D": {
|
||||||
|
"item": "minecraft:diamond"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"C": {
|
"result": {
|
||||||
"item": "minecraft:cobblestone"
|
"item": "sorcerycraft:casting_table"
|
||||||
},
|
|
||||||
"D": {
|
|
||||||
"item": "minecraft:diamond"
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "sorcerycraft:casting_table",
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,21 @@
|
|||||||
{
|
{
|
||||||
"type": "minecraft:crafting_shaped",
|
"type": "minecraft:crafting_shaped",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
" L ",
|
" L ",
|
||||||
"LPL",
|
"LPL",
|
||||||
" L "
|
" L "
|
||||||
],
|
],
|
||||||
"key": {
|
"key": {
|
||||||
"L": {
|
"L": {
|
||||||
"item": "minecraft:lapis_lazuli"
|
"item": "minecraft:lapis_lazuli"
|
||||||
|
},
|
||||||
|
"P": {
|
||||||
|
"item": "minecraft:paper"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"P": {
|
"result": {
|
||||||
"item": "minecraft:paper"
|
"item": "sorcerycraft:spell",
|
||||||
|
"count": 1
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"result": {
|
|
||||||
"item": "sorcerycraft:spell",
|
|
||||||
"count": 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user