Skip to content

Commit

Permalink
chore: progress save
Browse files Browse the repository at this point in the history
  • Loading branch information
WinDanesz committed Nov 2, 2023
1 parent e745090 commit 75d4dd7
Show file tree
Hide file tree
Showing 55 changed files with 1,610 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
Expand Down Expand Up @@ -89,7 +90,8 @@ public void preInit(FMLPreInitializationEvent event) {
settings = new Settings();

proxy.registerRenderers();

proxy.registerExtraHandbookContent();
FMLInterModComms.sendMessage("ebwizardry", "addon_content", "I have stuff");
ASLoot.preInit();
ASBlocks.registerTileEntities();
ASBiomes.preInit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,5 @@ public void checkTranslationKeys() {}

public void openBookGUI(EntityPlayer player, ItemStack book) {}

public void registerExtraHandbookContent() {}
}
6 changes: 6 additions & 0 deletions src/main/java/com/windanesz/ancientspellcraft/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,13 @@ public static class GeneralSettings {
@Config.RequiresMcRestart
public int wild_catalyst_max_distance = 10000;

@Config.Name("Runic Shield Armor Amount")
@Config.RequiresMcRestart
public float runic_shield_armor = 5.0f;

@Config.Name("Runic Shield Armor Toughness Amount")
@Config.RequiresMcRestart
public float runic_shield_armor_toughness = 5.0f;
}

public static class ClientSettings {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
import com.windanesz.ancientspellcraft.tileentity.TileSphereCognizance;
import com.windanesz.ancientspellcraft.util.ASParticles;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.client.gui.handbook.GuiWizardHandbook;
import electroblob.wizardry.client.particle.ParticleWizardry;
import electroblob.wizardry.client.renderer.entity.RenderBlank;
import electroblob.wizardry.client.renderer.entity.RenderMagicArrow;
Expand Down Expand Up @@ -126,6 +127,7 @@
import org.lwjgl.input.Keyboard;

import javax.annotation.Nullable;
import javax.swing.event.AncestorEvent;
import java.util.Collection;
import java.util.List;

Expand Down Expand Up @@ -440,4 +442,9 @@ private void missingKeyWarning(String type, String registryName, String expected
public void openBookGUI(EntityPlayer player, ItemStack book) {
Minecraft.getMinecraft().displayGuiScreen(new GuiScreenBook(Minecraft.getMinecraft().player, book, false));
}

@Override
public void registerExtraHandbookContent() {
GuiWizardHandbook.registerAddonHandbookContent(AncientSpellcraft.MODID);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
package com.windanesz.ancientspellcraft.client.gui;

import com.windanesz.ancientspellcraft.item.ItemGlyphArtefact;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;

public class ContainerInventoryInItemStack extends Container {
private final IInventory itemInventory;

public ContainerInventoryInItemStack(IInventory playerInventory, IInventory itemInventory, EntityPlayer player) {
this.itemInventory = itemInventory;
itemInventory.openInventory(player);

if (itemInventory instanceof InventoryInItemStack) {

int rowCount = ((InventoryInItemStack) itemInventory).getRowCount();
int columnCount = ((InventoryInItemStack) itemInventory).getColumnCount();
int index = 0;

int offsetX = itemInventory.getSizeInventory() == 9 ? 0 : -54;

this.addSlotToContainer(new Slot(itemInventory, index, 80, 36) {
@Override
public boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof ItemGlyphArtefact;
}
});
index++;
this.addSlotToContainer(new Slot(itemInventory, index, 60, 76) {
@Override
public boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof ItemGlyphArtefact;
}
});
index++;
this.addSlotToContainer(new Slot(itemInventory, index, 100, 76) {
@Override
public boolean isItemValid(ItemStack stack) {
return stack.getItem() instanceof ItemGlyphArtefact;
}
});

// player's inventory
for (int i1 = 0; i1 < 3; ++i1) {
for (int k1 = 0; k1 < 9; ++k1) {
this.addSlotToContainer(new Slot(playerInventory, k1 + i1 * 9 + 9, 8 + k1 * 18, 134 + i1 * 18));
}
}

// player's inventory hotbar
for (int j1 = 0; j1 < 9; ++j1) {
this.addSlotToContainer(new Slot(playerInventory, j1, 8 + j1 * 18, 192));
}
}
}

public boolean canInteractWith(EntityPlayer playerIn) {
return this.itemInventory.isUsableByPlayer(playerIn);
}

public ItemStack transferStackInSlot(EntityPlayer playerIn, int index) {
ItemStack itemstack = ItemStack.EMPTY;
Slot slot = this.inventorySlots.get(index);

if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();

if (index < this.itemInventory.getSizeInventory()) {
if (!this.mergeItemStack(itemstack1, this.itemInventory.getSizeInventory(), this.inventorySlots.size(), true)) {
return ItemStack.EMPTY;
}
} else if (this.getSlot(1).isItemValid(itemstack1) && !this.getSlot(1).getHasStack()) {
if (!this.mergeItemStack(itemstack1, 1, 2, false)) {
return ItemStack.EMPTY;
}
} else if (this.getSlot(0).isItemValid(itemstack1)) {
if (!this.mergeItemStack(itemstack1, 0, 1, false)) {
return ItemStack.EMPTY;
}
} else if (this.itemInventory.getSizeInventory() <= 2 || !this.mergeItemStack(itemstack1, 2, this.itemInventory.getSizeInventory(), false)) {
return ItemStack.EMPTY;
}

if (itemstack1.isEmpty()) {
slot.putStack(ItemStack.EMPTY);
} else {
slot.onSlotChanged();
}

}

return itemstack;
}

public void onContainerClosed(EntityPlayer playerIn) {
super.onContainerClosed(playerIn);
this.itemInventory.closeInventory(playerIn);
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.windanesz.ancientspellcraft.client.gui;

import com.windanesz.ancientspellcraft.item.IItemWithSlots;
import com.windanesz.ancientspellcraft.item.ItemASSpellBook;
import com.windanesz.ancientspellcraft.item.ItemBattlemageShield;
import com.windanesz.ancientspellcraft.item.ItemRitualBook;
import com.windanesz.ancientspellcraft.item.ItemRunicPlate;
import com.windanesz.ancientspellcraft.item.ItemSageTome;
Expand All @@ -12,6 +14,7 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.fml.common.network.IGuiHandler;
Expand All @@ -32,6 +35,7 @@ public class GuiHandlerAS implements IGuiHandler {
public static final int SAGE_LECTERN = nextGuiId++;
public static final int SPELL_GUI_LECTERN = nextGuiId++;
public static final int RUNIC_PLATE = nextGuiId++;
public static final int BATTLEMAGE_SHIELD = nextGuiId++;

@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
Expand All @@ -49,6 +53,10 @@ public Object getServerGuiElement(int id, EntityPlayer player, World world, int
} else if (id == SAGE_LECTERN) {
TileEntity tileEntity = world.getTileEntity(new BlockPos(x, y, z));
return new ContainerSageLectern(player, player.inventory, (TileSageLectern) tileEntity);
} else if (id == BATTLEMAGE_SHIELD) {
ItemStack stack = player.getHeldItem(EnumHand.values()[x]);
InventoryInItemStack inventory = new InventoryInItemStack("Runic Shield", true, (IItemWithSlots) stack.getItem(), stack);
return new ContainerInventoryInItemStack(player.inventory, inventory, player);
}
return null;
}
Expand Down Expand Up @@ -130,6 +138,15 @@ public Object getClientGuiElement(int id, EntityPlayer player, World world, int
return new GuiRunicPlate(player.getHeldItemOffhand());
}
}

if (id == BATTLEMAGE_SHIELD) {
if (player.getHeldItemMainhand().getItem() instanceof ItemBattlemageShield) {
ItemStack stack = player.getHeldItem(EnumHand.values()[x]);
InventoryInItemStack inventory = new InventoryInItemStack("Battlemage Shield", true, (IItemWithSlots) stack.getItem(), stack);
return new GuiScreenInventoryInItem(inventory, player, "battlemage_shield");
}
}

return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.windanesz.ancientspellcraft.client.gui;

import com.windanesz.ancientspellcraft.AncientSpellcraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class GuiScreenInventoryInItem extends GuiContainer {

private final ResourceLocation GUI_BACKGROUND;

public GuiScreenInventoryInItem(IInventory inventory, EntityPlayer player, String texture) {
super(new ContainerInventoryInItemStack(player.inventory, inventory, player));
this.xSize = 176;
this.ySize = 223;
this.GUI_BACKGROUND = new ResourceLocation(AncientSpellcraft.MODID, "textures/gui/" + texture + ".png");
}

protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(GUI_BACKGROUND);
int i = (this.width - this.xSize) / 2;
int j = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(i, j, 0, 0, this.xSize, this.ySize);

}

public void drawScreen(int mouseX, int mouseY, float partialTicks) {
this.drawDefaultBackground();
super.drawScreen(mouseX, mouseY, partialTicks);
this.renderHoveredToolTip(mouseX, mouseY);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package com.windanesz.ancientspellcraft.client.gui;

import com.windanesz.ancientspellcraft.item.IItemWithSlots;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;

public class InventoryInItemStack extends InventoryBasic {

private final ItemStack stack;

public InventoryInItemStack(String title, boolean customName, IItemWithSlots itemWithSlots, ItemStack stack) {
super(title, customName, itemWithSlots.getSlotCount());
this.stack = stack;
}

public int getRowCount() {
return ((IItemWithSlots) (stack.getItem())).getRowCount();
}

public int getColumnCount() {
return ((IItemWithSlots) (stack.getItem())).getColumnCount();
}

@Override
public void openInventory(EntityPlayer player) {
super.openInventory(player);
NBTTagCompound nbt = this.stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
}

if (nbt.hasKey("Items")) {

NBTTagList items = nbt.getTagList("Items", 10);

for (int i = 0; i < items.tagCount(); ++i) {
NBTTagCompound nbttagcompound = items.getCompoundTagAt(i);
int j = nbttagcompound.getByte("Slot") & 255;

if (j < this.getSizeInventory()) {
this.setInventorySlotContents(j, new ItemStack(nbttagcompound));
}
}
}
}

@Override
public void closeInventory(EntityPlayer player) {

NBTTagCompound nbt = this.stack.getTagCompound();
if (nbt == null) {
nbt = new NBTTagCompound();
}

NBTTagList items = new NBTTagList();

for (int i = 0; i < this.getSizeInventory(); ++i) {
ItemStack itemstack = this.getStackInSlot(i);

if (!itemstack.isEmpty()) {
NBTTagCompound nbttagcompound = new NBTTagCompound();
nbttagcompound.setByte("Slot", (byte) i);
itemstack.writeToNBT(nbttagcompound);
items.appendTag(nbttagcompound);
}
}

nbt.setTag("Items", items);
stack.setTagCompound(nbt);
}

@Override
public boolean isItemValidForSlot(int index, ItemStack stack) {
if (((IItemWithSlots) (stack.getItem())).isItemValid(stack.getItem())) {
return false;
}
return super.isItemValidForSlot(index, stack);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;

// TODO: Possibly convert this to EntityScaledConstruct
@Mod.EventBusSubscriber
Expand Down Expand Up @@ -453,6 +454,18 @@ public static void onExplosionEvent(ExplosionEvent event) {
event.getExplosion().getPlayerKnockbackMap().keySet().removeIf(p -> getSurroundingForcefield(p) != forcefield);
}

@Nullable
@Override
public UUID getOwnerId() {
return null;
}

@Nullable
@Override
public Entity getOwner() {
return null;
}

public enum Colour {
MAGENTA(13, 0.67f, 0.28f, 0.85f),
RED(1, 0.85f, 0.27f, 0.27f),
Expand Down
Loading

0 comments on commit 75d4dd7

Please sign in to comment.