Compare commits
1 Commits
b8475b34ba
...
ae50cf0390
Author | SHA1 | Date | |
---|---|---|---|
ae50cf0390 |
2
API.md
2
API.md
@ -8,7 +8,7 @@
|
|||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
modImplementation 'com.thebrokenrail:sorcerycraft:VERSION'
|
modImplementation 'com.thebrokenrail:sorcerycraft:VERSION'
|
||||||
// VERSION = "<Mod Version>+<MC Version>", for example "1.2.4+20w12a"
|
// VERSION = "<Mod Version>+<MC Version>", for example "1.2.4+1.15.2"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
2. Add Dependency to ```fabric.mod.json```
|
2. Add Dependency to ```fabric.mod.json```
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
**1.15.2 Port**
|
||||||
|
* Tweak Steadfast Spell
|
||||||
|
|
||||||
**1.2.5**
|
**1.2.5**
|
||||||
* Fix Casting Table Bug
|
* Fix Casting Table Bug
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
# SorceryCraft
|
# SorceryCraft
|
||||||
|
**1.15.2 Port**
|
||||||
|
|
||||||
Cast Spells in Minecraft!
|
Cast Spells in Minecraft!
|
||||||
|
|
||||||
This mod currently supports the Minecraft 1.16 snapshots.
|
This mod currently supports the Minecraft 1.16 snapshots.
|
||||||
|
@ -84,7 +84,7 @@ if (project.hasProperty('curseforge.api_key')) {
|
|||||||
apiKey = project.getProperty('curseforge.api_key')
|
apiKey = project.getProperty('curseforge.api_key')
|
||||||
project {
|
project {
|
||||||
id = project.curseforge_id
|
id = project.curseforge_id
|
||||||
changelog = 'A changelog can be found at https://gitea.thebrokenrail.com/TheBrokenRail/SorceryCraft/src/branch/master/CHANGELOG.md'
|
changelog = 'A changelog can be found at https://gitea.thebrokenrail.com/TheBrokenRail/SorceryCraft/src/branch/1.15/CHANGELOG.md'
|
||||||
releaseType = 'release'
|
releaseType = 'release'
|
||||||
addGameVersion project.simple_minecraft_version
|
addGameVersion project.simple_minecraft_version
|
||||||
addGameVersion 'Fabric'
|
addGameVersion 'Fabric'
|
||||||
|
@ -3,10 +3,10 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
|
|
||||||
# Fabric Properties
|
# Fabric Properties
|
||||||
# check these on https://fabricmc.net/use
|
# check these on https://fabricmc.net/use
|
||||||
minecraft_version = 20w12a
|
minecraft_version = 1.15.2
|
||||||
curseforge_id = 365308
|
curseforge_id = 365308
|
||||||
simple_minecraft_version = 1.16-Snapshot
|
simple_minecraft_version = 1.15.2
|
||||||
yarn_build = 18
|
yarn_build = 14
|
||||||
fabric_loader_version = 0.7.8+build.189
|
fabric_loader_version = 0.7.8+build.189
|
||||||
|
|
||||||
# Mod Properties
|
# Mod Properties
|
||||||
@ -16,7 +16,7 @@ org.gradle.jvmargs = -Xmx1G
|
|||||||
|
|
||||||
# Dependencies
|
# Dependencies
|
||||||
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
|
||||||
fabric_api_version = 0.5.5+build.311-1.16
|
fabric_api_version = 0.5.1+build.294-1.15
|
||||||
cloth_config_version = 3.1.0-unstable
|
cloth_config_version = 2.9.3
|
||||||
auto_config_version = 1.2.4
|
auto_config_version = 1.2.4
|
||||||
mod_menu_version = 1.11.0+build.2
|
mod_menu_version = 1.10.2+build.32
|
||||||
|
@ -26,7 +26,7 @@ import net.minecraft.entity.EntityCategory;
|
|||||||
import net.minecraft.entity.EntityDimensions;
|
import net.minecraft.entity.EntityDimensions;
|
||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.ProjectileEntity;
|
import net.minecraft.entity.projectile.Projectile;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.BlockItem;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.item.ItemGroup;
|
import net.minecraft.item.ItemGroup;
|
||||||
@ -119,7 +119,7 @@ public class SorceryCraft implements ModInitializer {
|
|||||||
ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(NAMESPACE, "casting_table"), (syncId, identifier, player, buf) -> {
|
ContainerProviderRegistry.INSTANCE.registerFactory(new Identifier(NAMESPACE, "casting_table"), (syncId, identifier, player, buf) -> {
|
||||||
final World world = player.world;
|
final World world = player.world;
|
||||||
final BlockPos pos = buf.readBlockPos();
|
final BlockPos pos = buf.readBlockPos();
|
||||||
return Objects.requireNonNull(world.getBlockState(pos).createScreenHandlerFactory(player.world, pos)).createMenu(syncId, player.inventory, player);
|
return Objects.requireNonNull(world.getBlockState(pos).createContainerFactory(player.world, pos)).createMenu(syncId, player.inventory, player);
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandRegistry.INSTANCE.register(false, SpellCommand::register);
|
CommandRegistry.INSTANCE.register(false, SpellCommand::register);
|
||||||
@ -139,7 +139,7 @@ public class SorceryCraft implements ModInitializer {
|
|||||||
|
|
||||||
DispenserBlock.registerBehavior(SorceryCraft.SPELL_ITEM, new ProjectileDispenserBehavior() {
|
DispenserBlock.registerBehavior(SorceryCraft.SPELL_ITEM, new ProjectileDispenserBehavior() {
|
||||||
@Override
|
@Override
|
||||||
protected ProjectileEntity createProjectile(World position, Position stack, ItemStack itemStack) {
|
protected Projectile createProjectile(World position, Position stack, ItemStack itemStack) {
|
||||||
SpellEntity entity = new SpellEntity(position, stack.getX(), stack.getY(), stack.getZ());
|
SpellEntity entity = new SpellEntity(position, stack.getX(), stack.getY(), stack.getZ());
|
||||||
entity.setItem(itemStack);
|
entity.setItem(itemStack);
|
||||||
return entity;
|
return entity;
|
||||||
|
@ -8,10 +8,10 @@ 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.container.NameableContainerFactory;
|
||||||
|
import net.minecraft.container.SimpleNamedContainerFactory;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.screen.NamedScreenHandlerFactory;
|
|
||||||
import net.minecraft.screen.ScreenHandlerContext;
|
|
||||||
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;
|
||||||
@ -36,12 +36,12 @@ public class CastingTableBlock extends Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NamedScreenHandlerFactory createScreenHandlerFactory(BlockState state, World world, BlockPos pos) {
|
public NameableContainerFactory createContainerFactory(BlockState state, World world, BlockPos pos) {
|
||||||
return new SimpleNamedScreenHandlerFactory((i, playerInventory, playerEntity) -> {
|
return new SimpleNamedContainerFactory((i, playerInventory, playerEntity) -> {
|
||||||
if (!playerEntity.getEntityWorld().isClient()) {
|
if (!playerEntity.getEntityWorld().isClient()) {
|
||||||
((SpellServerPlayerEntity) playerEntity).sync();
|
((SpellServerPlayerEntity) playerEntity).sync();
|
||||||
}
|
}
|
||||||
return new CastingTableScreenHandler(i, playerInventory, ScreenHandlerContext.create(world, pos));
|
return new CastingTableScreenHandler(i, playerInventory, BlockContext.create(world, pos));
|
||||||
}, new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
}, new TranslatableText("container." + SorceryCraft.NAMESPACE + ".casting_table"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
|||||||
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.HandledScreen;
|
import net.minecraft.client.gui.screen.ingame.ContainerScreen;
|
||||||
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,7 +19,7 @@ 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 HandledScreen<CastingTableScreenHandler> {
|
public class CastingTableScreen extends ContainerScreen<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;
|
||||||
@ -27,27 +27,27 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
|
|
||||||
public CastingTableScreen(CastingTableScreenHandler container, PlayerInventory inventory, Text title) {
|
public CastingTableScreen(CastingTableScreenHandler container, PlayerInventory inventory, Text title) {
|
||||||
super(container, inventory, title);
|
super(container, inventory, title);
|
||||||
backgroundWidth = 276;
|
containerWidth = 276;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawForeground(int mouseX, int mouseY) {
|
protected void drawForeground(int mouseX, int mouseY) {
|
||||||
int titleY = backgroundHeight - 94;
|
int titleY = containerHeight - 94;
|
||||||
textRenderer.draw(title.asFormattedString(), (float) (49 + this.backgroundWidth / 2 - textRenderer.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
font.draw(title.asFormattedString(), (float) (49 + this.containerWidth / 2 - font.getStringWidth(title.asFormattedString()) / 2), 6.0F, 4210752);
|
||||||
textRenderer.draw(playerInventory.getDisplayName().asFormattedString(), 107.0F, (float) titleY, 4210752);
|
font.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);
|
font.draw(spells, (float) (5 - font.getStringWidth(spells) / 2 + 48), 6.0F, 4210752);
|
||||||
renderXPCost();
|
renderXPCost();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void drawBackground(float delta, int mouseX, int mouseY) {
|
protected void drawBackground(float delta, int mouseX, int mouseY) {
|
||||||
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
RenderSystem.color4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
assert client != null;
|
assert minecraft != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
minecraft.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - containerWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - containerHeight) / 2;
|
||||||
drawTexture(i, j, getZOffset(), 0.0F, 0.0F, backgroundWidth, backgroundHeight, 256, 512);
|
blit(i, j, getBlitOffset(), 0.0F, 0.0F, containerWidth, containerHeight, 256, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -63,36 +63,36 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
if (button.isHovered()) {
|
if (button.isHovered()) {
|
||||||
button.renderToolTip(mouseX, mouseY);
|
button.renderToolTip(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
button.visible = button.index < handler.getRecipes().length;
|
button.visible = button.index < container.getRecipes().length;
|
||||||
if (button.visible) {
|
if (button.visible) {
|
||||||
Spell spell = handler.getRecipes()[button.getIndex() + indexStartOffset];
|
Spell spell = container.getRecipes()[button.getIndex() + indexStartOffset];
|
||||||
button.setMessage(SpellHelper.getTranslatedSpell(spell.getID(), spell.getLevel()).getString());
|
button.setMessage(SpellHelper.getTranslatedSpell(spell.getID(), spell.getLevel()).getString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderScrollbar() {
|
private void renderScrollbar() {
|
||||||
Spell[] spells = handler.getRecipes();
|
Spell[] spells = container.getRecipes();
|
||||||
assert client != null;
|
assert minecraft != null;
|
||||||
client.getTextureManager().bindTexture(TEXTURE);
|
minecraft.getTextureManager().bindTexture(TEXTURE);
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - containerWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - containerHeight) / 2;
|
||||||
int k = spells.length - 7;
|
int k = spells.length - 7;
|
||||||
|
|
||||||
if (k > 0) {
|
if (k > 0) {
|
||||||
int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27));
|
int modifier = (int) (((float) indexStartOffset / k) * (1 + 139 - 27));
|
||||||
drawTexture(i + 94, j + 18 + modifier, getZOffset(), 0.0F, 199.0F, 6, 27, 256, 512);
|
blit(i + 94, j + 18 + modifier, getBlitOffset(), 0.0F, 199.0F, 6, 27, 256, 512);
|
||||||
} else {
|
} else {
|
||||||
drawTexture(i + 94, j + 18, getZOffset(), 6.0F, 199.0F, 6, 27, 256, 512);
|
blit(i + 94, j + 18, getBlitOffset(), 6.0F, 199.0F, 6, 27, 256, 512);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderItems() {
|
private void renderItems() {
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - containerWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - containerHeight) / 2;
|
||||||
int k = j + 16 + 1;
|
int k = j + 16 + 1;
|
||||||
|
|
||||||
Spell[] spells = handler.getRecipes();
|
Spell[] spells = container.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();
|
||||||
@ -100,7 +100,7 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
int y = k + 2;
|
int y = k + 2;
|
||||||
|
|
||||||
itemRenderer.renderGuiItem(itemStack, i + 5 + 68, y);
|
itemRenderer.renderGuiItem(itemStack, i + 5 + 68, y);
|
||||||
itemRenderer.renderGuiItemOverlay(textRenderer, itemStack, i + 5 + 68, y);
|
itemRenderer.renderGuiItemOverlay(font, itemStack, i + 5 + 68, y);
|
||||||
itemRenderer.zOffset = 0.0F;
|
itemRenderer.zOffset = 0.0F;
|
||||||
k += 20;
|
k += 20;
|
||||||
}
|
}
|
||||||
@ -108,20 +108,20 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void renderXPCost() {
|
private void renderXPCost() {
|
||||||
if (handler.getRecipes().length > 0) {
|
if (container.getRecipes().length > 0) {
|
||||||
int cost = handler.getRecipes()[selectedIndex].getXPCost();
|
int cost = container.getRecipes()[selectedIndex].getXPCost();
|
||||||
int color = 8453920;
|
int color = 8453920;
|
||||||
assert client != null;
|
assert minecraft != null;
|
||||||
assert client.player != null;
|
assert minecraft.player != null;
|
||||||
String string = new TranslatableText("container.repair.cost", cost).getString();
|
String string = new TranslatableText("container.repair.cost", cost).getString();
|
||||||
if (!handler.canTakeResult(playerInventory.player)) {
|
if (!container.canTakeResult(playerInventory.player)) {
|
||||||
color = 16736352;
|
color = 16736352;
|
||||||
}
|
}
|
||||||
|
|
||||||
int x2 = backgroundWidth - 8;
|
int x2 = containerWidth - 8;
|
||||||
int x1 = x2 - textRenderer.getStringWidth(string);
|
int x1 = x2 - font.getStringWidth(string);
|
||||||
fill(x1, 65, x2, 77, 1325400064);
|
fill(x1, 65, x2, 77, 1325400064);
|
||||||
textRenderer.drawWithShadow(string, (float) x1, 67.0F, color);
|
font.drawWithShadow(string, (float) x1, 67.0F, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseScrolled(double d, double e, double amount) {
|
public boolean mouseScrolled(double d, double e, double amount) {
|
||||||
int i = handler.getRecipes().length;
|
int i = container.getRecipes().length;
|
||||||
if (canScroll(i)) {
|
if (canScroll(i)) {
|
||||||
int j = i - 7;
|
int j = i - 7;
|
||||||
indexStartOffset = (int) ((double) indexStartOffset - amount);
|
indexStartOffset = (int) ((double) indexStartOffset - amount);
|
||||||
@ -143,7 +143,7 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
|
|
||||||
@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 = handler.getRecipes().length;
|
int i = container.getRecipes().length;
|
||||||
if (scrolling) {
|
if (scrolling) {
|
||||||
int j = y + 18;
|
int j = y + 18;
|
||||||
int k = j + 139;
|
int k = j + 139;
|
||||||
@ -160,9 +160,9 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
@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 - backgroundWidth) / 2;
|
int i = (width - containerWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - containerHeight) / 2;
|
||||||
if (canScroll(handler.getRecipes().length) && mouseX > (double) (i + 94) && mouseX < (double) (i + 94 + 6) && mouseY > (double) (j + 18) && mouseY <= (double) (j + 18 + 139 + 1)) {
|
if (canScroll(container.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,9 +170,9 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void syncRecipeIndex() {
|
private void syncRecipeIndex() {
|
||||||
handler.setIndex(selectedIndex);
|
container.setIndex(selectedIndex);
|
||||||
assert client != null;
|
assert minecraft != null;
|
||||||
SelectSpellC2SPacket.send(client, selectedIndex);
|
SelectSpellC2SPacket.send(minecraft, selectedIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final WidgetButtonPage[] buttons = new WidgetButtonPage[7];
|
private final WidgetButtonPage[] buttons = new WidgetButtonPage[7];
|
||||||
@ -180,8 +180,8 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
@Override
|
@Override
|
||||||
protected void init() {
|
protected void init() {
|
||||||
super.init();
|
super.init();
|
||||||
int i = (width - backgroundWidth) / 2;
|
int i = (width - containerWidth) / 2;
|
||||||
int j = (height - backgroundHeight) / 2;
|
int j = (height - containerHeight) / 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) {
|
||||||
@ -214,8 +214,8 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void renderToolTip(int mouseX, int mouseY) {
|
public void renderToolTip(int mouseX, int mouseY) {
|
||||||
if (hovered && handler.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
if (isHovered && container.getRecipes().length > index + indexStartOffset && mouseX > this.x + 65) {
|
||||||
ItemStack itemStack = handler.getRecipes()[index + indexStartOffset].getItemCost();
|
ItemStack itemStack = container.getRecipes()[index + indexStartOffset].getItemCost();
|
||||||
if (!itemStack.isEmpty()) {
|
if (!itemStack.isEmpty()) {
|
||||||
renderTooltip(itemStack, mouseX, mouseY);
|
renderTooltip(itemStack, mouseX, mouseY);
|
||||||
}
|
}
|
||||||
@ -223,8 +223,8 @@ public class CastingTableScreen extends HandledScreen<CastingTableScreenHandler>
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawCenteredString(TextRenderer textRenderer, String str, int centerX, int y, int color) {
|
public void drawCenteredString(TextRenderer font, String str, int centerX, int y, int color) {
|
||||||
drawString(textRenderer, str, x + 5, y, color);
|
drawString(font, str, x + 5, y, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import net.minecraft.entity.Entity;
|
|||||||
import net.minecraft.entity.EntityType;
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.entity.projectile.thrown.ThrownItemEntity;
|
import net.minecraft.entity.thrown.ThrownItemEntity;
|
||||||
import net.minecraft.item.Item;
|
import net.minecraft.item.Item;
|
||||||
import net.minecraft.network.Packet;
|
import net.minecraft.network.Packet;
|
||||||
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
import net.minecraft.network.packet.s2c.play.EntitySpawnS2CPacket;
|
||||||
@ -52,7 +52,6 @@ public class SpellEntity extends ThrownItemEntity {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCollision(HitResult hitResult) {
|
protected void onCollision(HitResult hitResult) {
|
||||||
super.onCollision(hitResult);
|
|
||||||
if (!getEntityWorld().isClient()) {
|
if (!getEntityWorld().isClient()) {
|
||||||
Map<Identifier, Integer> spells = SpellHelper.getSpells(getItem());
|
Map<Identifier, Integer> spells = SpellHelper.getSpells(getItem());
|
||||||
if (!spells.containsKey(Spells.INWARD_SPELL)) {
|
if (!spells.containsKey(Spells.INWARD_SPELL)) {
|
||||||
|
@ -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.api.registry.SpellRegistry;
|
import com.thebrokenrail.sorcerycraft.spell.api.registry.SpellRegistry;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
|
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.ScreenHandler;
|
|
||||||
import net.minecraft.screen.ScreenHandlerContext;
|
|
||||||
import net.minecraft.screen.ScreenHandlerType;
|
|
||||||
import net.minecraft.screen.slot.Slot;
|
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -25,15 +25,15 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.BiConsumer;
|
import java.util.function.BiConsumer;
|
||||||
|
|
||||||
public class CastingTableScreenHandler extends ScreenHandler {
|
public class CastingTableScreenHandler extends Container {
|
||||||
private final Inventory inventory;
|
private final Inventory inventory;
|
||||||
private final Inventory result;
|
private final Inventory result;
|
||||||
private Spell[] spells = new Spell[0];
|
private Spell[] spells = new Spell[0];
|
||||||
private final ScreenHandlerContext context;
|
private final BlockContext context;
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
|
||||||
public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, ScreenHandlerContext blockContext) {
|
public CastingTableScreenHandler(int syncId, PlayerInventory playerInventory, BlockContext blockContext) {
|
||||||
super(ScreenHandlerType.STONECUTTER, syncId);
|
super(ContainerType.STONECUTTER, syncId);
|
||||||
|
|
||||||
inventory = new BasicInventory(2) {
|
inventory = new BasicInventory(2) {
|
||||||
public void markDirty() {
|
public void markDirty() {
|
||||||
|
@ -14,11 +14,11 @@ import net.minecraft.item.ItemGroup;
|
|||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.util.ActionResult;
|
import net.minecraft.util.ActionResult;
|
||||||
|
import net.minecraft.util.DefaultedList;
|
||||||
import net.minecraft.util.Hand;
|
import net.minecraft.util.Hand;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.Rarity;
|
import net.minecraft.util.Rarity;
|
||||||
import net.minecraft.util.TypedActionResult;
|
import net.minecraft.util.TypedActionResult;
|
||||||
import net.minecraft.util.collection.DefaultedList;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -3,9 +3,9 @@ package com.thebrokenrail.sorcerycraft.mixin;
|
|||||||
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
|
import net.minecraft.container.Container;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.screen.ScreenHandler;
|
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import org.spongepowered.asm.mixin.Mixin;
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
import org.spongepowered.asm.mixin.Shadow;
|
import org.spongepowered.asm.mixin.Shadow;
|
||||||
@ -19,7 +19,7 @@ import java.util.Map;
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Mixin(PlayerEntity.class)
|
@Mixin(PlayerEntity.class)
|
||||||
public class MixinPlayerEntity implements SpellPlayerEntity {
|
public class MixinPlayerEntity implements SpellPlayerEntity {
|
||||||
@Shadow public ScreenHandler currentScreenHandler;
|
@Shadow public Container container;
|
||||||
// Namespace Fields
|
// Namespace Fields
|
||||||
private Map<Identifier, Integer> sorceryCraftDiscoveredSpells = new HashMap<>();
|
private Map<Identifier, Integer> sorceryCraftDiscoveredSpells = new HashMap<>();
|
||||||
|
|
||||||
@ -36,9 +36,9 @@ public class MixinPlayerEntity implements SpellPlayerEntity {
|
|||||||
@Override
|
@Override
|
||||||
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
||||||
this.sorceryCraftDiscoveredSpells = spells;
|
this.sorceryCraftDiscoveredSpells = spells;
|
||||||
if (currentScreenHandler instanceof CastingTableScreenHandler) {
|
if (container instanceof CastingTableScreenHandler) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
((CastingTableScreenHandler) currentScreenHandler).setSpells((PlayerEntity) (Object) this);
|
((CastingTableScreenHandler) container).setSpells((PlayerEntity) (Object) this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import com.thebrokenrail.sorcerycraft.packet.UpdateKnownSpellsS2CPacket;
|
|||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellServerPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellServerPlayerEntity;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
|
||||||
import net.minecraft.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
@ -30,7 +29,7 @@ public abstract class MixinServerPlayerEntity extends MixinPlayerEntity implemen
|
|||||||
@Override
|
@Override
|
||||||
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
public void setDiscoveredSpells(Map<Identifier, Integer> spells) {
|
||||||
super.setDiscoveredSpells(spells);
|
super.setDiscoveredSpells(spells);
|
||||||
if (currentScreenHandler instanceof CastingTableScreenHandler) {
|
if (container instanceof CastingTableScreenHandler) {
|
||||||
sync();
|
sync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,15 +7,15 @@ import net.fabricmc.api.EnvType;
|
|||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
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.network.PacketByteBuf;
|
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;
|
||||||
|
|
||||||
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();
|
||||||
ScreenHandler handler = context.getPlayer().currentScreenHandler;
|
Container handler = context.getPlayer().container;
|
||||||
if (handler instanceof CastingTableScreenHandler) {
|
if (handler instanceof CastingTableScreenHandler) {
|
||||||
CastingTableScreenHandler merchantContainer = (CastingTableScreenHandler) handler;
|
CastingTableScreenHandler merchantContainer = (CastingTableScreenHandler) handler;
|
||||||
merchantContainer.setIndex(index);
|
merchantContainer.setIndex(index);
|
||||||
|
@ -1,15 +1,16 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.packet;
|
package com.thebrokenrail.sorcerycraft.packet;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
import com.thebrokenrail.sorcerycraft.SorceryCraft;
|
||||||
|
import com.thebrokenrail.sorcerycraft.gui.CastingTableScreenHandler;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellPlayerEntity;
|
||||||
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
import com.thebrokenrail.sorcerycraft.spell.util.SpellHelper;
|
||||||
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.nbt.CompoundTag;
|
import net.minecraft.nbt.CompoundTag;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
|
||||||
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
import net.minecraft.network.packet.s2c.play.CustomPayloadS2CPacket;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
|
import net.minecraft.util.PacketByteBuf;
|
||||||
|
|
||||||
public class UpdateKnownSpellsS2CPacket {
|
public class UpdateKnownSpellsS2CPacket {
|
||||||
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
public static void handle(PacketContext context, PacketByteBuf bytes) {
|
||||||
@ -17,6 +18,9 @@ public class UpdateKnownSpellsS2CPacket {
|
|||||||
if (context.getPlayer() != null) {
|
if (context.getPlayer() != null) {
|
||||||
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer();
|
SpellPlayerEntity spellPlayer = (SpellPlayerEntity) context.getPlayer();
|
||||||
spellPlayer.setDiscoveredSpells(SpellHelper.getSpells(tag));
|
spellPlayer.setDiscoveredSpells(SpellHelper.getSpells(tag));
|
||||||
|
if (context.getPlayer().container instanceof CastingTableScreenHandler) {
|
||||||
|
((CastingTableScreenHandler) context.getPlayer().container).setSpells(context.getPlayer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell;
|
package com.thebrokenrail.sorcerycraft.spell;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Items;
|
import net.minecraft.item.Items;
|
||||||
import net.minecraft.state.property.Properties;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.tag.BlockTags;
|
import net.minecraft.state.property.Properties;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.hit.BlockHitResult;
|
import net.minecraft.util.hit.BlockHitResult;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
@ -24,7 +25,7 @@ public class CoolingSpell extends Spell {
|
|||||||
@Override
|
@Override
|
||||||
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
|
||||||
BlockPos blockPos = hitResult.getBlockPos();
|
BlockPos blockPos = hitResult.getBlockPos();
|
||||||
if (world.getBlockState(blockPos).isIn(BlockTags.FIRE)) {
|
if (world.getBlockState(blockPos).getBlock() == Blocks.FIRE) {
|
||||||
world.removeBlock(blockPos, false);
|
world.removeBlock(blockPos, false);
|
||||||
}
|
}
|
||||||
if (world.getBlockState(blockPos).get(Properties.LIT)) {
|
if (world.getBlockState(blockPos).get(Properties.LIT)) {
|
||||||
@ -32,7 +33,7 @@ public class CoolingSpell extends Spell {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BlockPos sideBlockPos = blockPos.offset(hitResult.getSide());
|
BlockPos sideBlockPos = blockPos.offset(hitResult.getSide());
|
||||||
if (world.getBlockState(sideBlockPos).isIn(BlockTags.FIRE)) {
|
if (world.getBlockState(sideBlockPos).getBlock() == Blocks.FIRE) {
|
||||||
world.removeBlock(sideBlockPos, false);
|
world.removeBlock(sideBlockPos, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package com.thebrokenrail.sorcerycraft.spell;
|
package com.thebrokenrail.sorcerycraft.spell;
|
||||||
|
|
||||||
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
import com.thebrokenrail.sorcerycraft.spell.api.Spell;
|
||||||
import net.minecraft.block.AbstractFireBlock;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.block.Blocks;
|
||||||
|
import net.minecraft.block.FireBlock;
|
||||||
import net.minecraft.block.TntBlock;
|
import net.minecraft.block.TntBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.LivingEntity;
|
import net.minecraft.entity.LivingEntity;
|
||||||
@ -40,7 +41,7 @@ public class FlameSpell extends Spell {
|
|||||||
TntBlock.primeTnt(world, blockPos);
|
TntBlock.primeTnt(world, blockPos);
|
||||||
world.removeBlock(blockPos, false);
|
world.removeBlock(blockPos, false);
|
||||||
} else if (FlintAndSteelItem.canIgnite(sideBlockState, world, sideBlockPos)) {
|
} else if (FlintAndSteelItem.canIgnite(sideBlockState, world, sideBlockPos)) {
|
||||||
world.setBlockState(sideBlockPos, AbstractFireBlock.getState(world, sideBlockPos));
|
world.setBlockState(sideBlockPos, ((FireBlock) Blocks.FIRE).getStateForPosition(world, sideBlockPos));
|
||||||
} else if (FlintAndSteelItem.isIgnitable(blockState)) {
|
} else if (FlintAndSteelItem.isIgnitable(blockState)) {
|
||||||
world.setBlockState(blockPos, blockState.with(Properties.LIT, true));
|
world.setBlockState(blockPos, blockState.with(Properties.LIT, true));
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@ public class SteadfastSpell extends Spell {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemCost() {
|
public ItemStack getItemCost() {
|
||||||
return new ItemStack(Items.NETHERITE_INGOT);
|
return new ItemStack(Items.DIAMOND);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,6 +32,6 @@
|
|||||||
"depends": {
|
"depends": {
|
||||||
"fabricloader": ">=0.7.4",
|
"fabricloader": ">=0.7.4",
|
||||||
"fabric": "*",
|
"fabric": "*",
|
||||||
"minecraft": "1.16.x"
|
"minecraft": "1.15.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user