mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-10-26 14:24:22 +00:00
Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8da80454b | ||
|
|
272075dd51 | ||
|
|
56bd18670f | ||
|
|
29f0c6af40 | ||
|
|
5ed33dfa4f | ||
|
|
7a74dabcea | ||
|
|
68518a7858 | ||
|
|
f83cd1ab0b | ||
|
|
5595d0377c | ||
|
|
6c4d37a345 | ||
|
|
77e14f3c8a | ||
|
|
71e00772b7 | ||
|
|
cf60696c68 |
No files matched your search
+54
-21
@@ -1,4 +1,4 @@
|
||||
//version: 1692122114
|
||||
//version: 1698936026
|
||||
/*
|
||||
DO NOT CHANGE THIS FILE!
|
||||
Also, you may replace this file at any time if there is an update available.
|
||||
@@ -89,6 +89,23 @@ def out = services.get(StyledTextOutputFactory).create('an-output')
|
||||
def projectJavaVersion = JavaLanguageVersion.of(8)
|
||||
|
||||
boolean disableSpotless = project.hasProperty("disableSpotless") ? project.disableSpotless.toBoolean() : false
|
||||
boolean disableCheckstyle = project.hasProperty("disableCheckstyle") ? project.disableCheckstyle.toBoolean() : false
|
||||
|
||||
final String CHECKSTYLE_CONFIG = """
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||
<module name="Checker">
|
||||
<module name="TreeWalker">
|
||||
<!-- Use CHECKSTYLE:OFF and CHECKSTYLE:ON comments to suppress checkstyle lints in a block -->
|
||||
<module name="SuppressionCommentFilter"/>
|
||||
<module name="AvoidStarImport">
|
||||
<!-- Allow static wildcard imports for cases like Opcodes and LWJGL classes, these don't get created accidentally by the IDE -->
|
||||
<property name="allowStaticMemberImports" value="true"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
"""
|
||||
|
||||
checkPropertyExists("modName")
|
||||
checkPropertyExists("modId")
|
||||
@@ -140,6 +157,17 @@ if (!disableSpotless) {
|
||||
apply from: Blowdryer.file('spotless.gradle')
|
||||
}
|
||||
|
||||
if (!disableCheckstyle) {
|
||||
apply plugin: 'checkstyle'
|
||||
tasks.named("checkstylePatchedMc") { enabled = false }
|
||||
tasks.named("checkstyleMcLauncher") { enabled = false }
|
||||
tasks.named("checkstyleIdeVirtualMain") { enabled = false }
|
||||
tasks.named("checkstyleInjectedTags") { enabled = false }
|
||||
checkstyle {
|
||||
config = resources.text.fromString(CHECKSTYLE_CONFIG)
|
||||
}
|
||||
}
|
||||
|
||||
String javaSourceDir = "src/main/java/"
|
||||
String scalaSourceDir = "src/main/scala/"
|
||||
String kotlinSourceDir = "src/main/kotlin/"
|
||||
@@ -600,15 +628,10 @@ repositories {
|
||||
}
|
||||
maven {
|
||||
name = "ic2"
|
||||
url = "https://maven.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
url = getURL("https://maven.ic2.player.to/", "https://maven2.ic2.player.to/")
|
||||
content {
|
||||
includeGroup "net.industrial-craft"
|
||||
}
|
||||
}
|
||||
maven {
|
||||
name = "ic2-mirror"
|
||||
url = "https://maven2.ic2.player.to/"
|
||||
metadataSources {
|
||||
mavenPom()
|
||||
artifact()
|
||||
@@ -623,7 +646,7 @@ repositories {
|
||||
|
||||
def mixinProviderGroup = "io.github.legacymoddingmc"
|
||||
def mixinProviderModule = "unimixins"
|
||||
def mixinProviderVersion = "0.1.7.1"
|
||||
def mixinProviderVersion = "0.1.13"
|
||||
def mixinProviderSpecNoClassifer = "${mixinProviderGroup}:${mixinProviderModule}:${mixinProviderVersion}"
|
||||
def mixinProviderSpec = "${mixinProviderSpecNoClassifer}:dev"
|
||||
ext.mixinProviderSpec = mixinProviderSpec
|
||||
@@ -770,23 +793,14 @@ ext.java17PatchDependenciesCfg = configurations.create("java17PatchDependencies"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
def lwjgl3ifyVersion = '1.4.0'
|
||||
def asmVersion = '9.4'
|
||||
def lwjgl3ifyVersion = '1.5.1'
|
||||
if (modId != 'lwjgl3ify') {
|
||||
java17Dependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}")
|
||||
}
|
||||
if (modId != 'hodgepodge') {
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.2.26')
|
||||
java17Dependencies('com.github.GTNewHorizons:Hodgepodge:2.3.17')
|
||||
}
|
||||
|
||||
java17PatchDependencies('net.minecraft:launchwrapper:1.17.2') {transitive = false}
|
||||
java17PatchDependencies("org.ow2.asm:asm:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-commons:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-tree:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-analysis:${asmVersion}")
|
||||
java17PatchDependencies("org.ow2.asm:asm-util:${asmVersion}")
|
||||
java17PatchDependencies('org.ow2.asm:asm-deprecated:7.1')
|
||||
java17PatchDependencies("org.apache.commons:commons-lang3:3.12.0")
|
||||
java17PatchDependencies("com.github.GTNewHorizons:lwjgl3ify:${lwjgl3ifyVersion}:forgePatches") {transitive = false}
|
||||
}
|
||||
|
||||
@@ -1576,6 +1590,25 @@ def getSecondaryArtifacts() {
|
||||
return secondaryArtifacts
|
||||
}
|
||||
|
||||
def getURL(String main, String fallback) {
|
||||
return pingURL(main, 10000) ? main : fallback
|
||||
}
|
||||
|
||||
// credit: https://stackoverflow.com/a/3584332
|
||||
def pingURL(String url, int timeout) {
|
||||
url = url.replaceFirst("^https", "http") // Otherwise an exception may be thrown on invalid SSL certificates.
|
||||
try {
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection()
|
||||
connection.setConnectTimeout(timeout)
|
||||
connection.setReadTimeout(timeout)
|
||||
connection.setRequestMethod("HEAD")
|
||||
int responseCode = connection.getResponseCode()
|
||||
return 200 <= responseCode && responseCode <= 399
|
||||
} catch (IOException ignored) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// For easier scripting of things that require variables defined earlier in the buildscript
|
||||
if (file('addon.late.gradle.kts').exists()) {
|
||||
apply from: 'addon.late.gradle.kts'
|
||||
|
||||
+2
-2
@@ -6,9 +6,9 @@ dependencies {
|
||||
compile('thaumcraft:Thaumcraft:1.7.10-4.2.3.5:dev')
|
||||
|
||||
compileOnly('com.github.GTNewHorizons:Railcraft:9.15.0:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.12.0-GTNH:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:StorageDrawers:1.12.1-GTNH:api') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:ForgeMultipart:1.3.4:dev') {transitive=false}
|
||||
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.4.2-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:NotEnoughItems:2.4.9-GTNH:dev')
|
||||
compileOnly('com.github.GTNewHorizons:BuildCraft:7.1.36:api') {transitive=false}
|
||||
compile('com.github.GTNewHorizons:GTNHLib:0.0.13:dev')
|
||||
|
||||
|
||||
@@ -43,11 +43,7 @@ public class RecipeElvenTrade {
|
||||
List<ItemStack> validStacks = OreDictionary.getOres((String) input);
|
||||
boolean found = false;
|
||||
for(ItemStack ostack : validStacks) {
|
||||
ItemStack cstack = ostack.copy();
|
||||
if(cstack.getItemDamage() == Short.MAX_VALUE)
|
||||
cstack.setItemDamage(stack.getItemDamage());
|
||||
|
||||
if(stack.isItemEqual(cstack)) {
|
||||
if(OreDictionary.itemMatches(ostack, stack, false)) {
|
||||
if(!stacksToRemove.contains(stack))
|
||||
stacksToRemove.add(stack);
|
||||
oredictIndex = j;
|
||||
|
||||
@@ -2,8 +2,8 @@ package vazkii.botania.client.core.handler;
|
||||
|
||||
import net.minecraft.client.settings.KeyBinding;
|
||||
import vazkii.botania.common.network.PacketHandler;
|
||||
import vazkii.botania.common.network.PacketLokiClear;
|
||||
import vazkii.botania.common.network.PacketLokiToggle;
|
||||
import vazkii.botania.common.network.PacketLokiToggleBreaking;
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -14,12 +14,12 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class KeyHandler {
|
||||
private static final KeyBinding keyToggleRingOfLoki= new KeyBinding("botaniamisc.toggleLoki", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyToggleRingOfLokiBreaking= new KeyBinding("botaniamisc.toggleLokiBreaking", 0, "botaniamisc.keyCategory");
|
||||
private static final KeyBinding keyRingOfLokiClear= new KeyBinding("botaniamisc.ringOfLokiClear", 0, "botaniamisc.keyCategory");
|
||||
|
||||
public KeyHandler() {
|
||||
FMLCommonHandler.instance().bus().register(this);
|
||||
ClientRegistry.registerKeyBinding(keyToggleRingOfLoki);
|
||||
ClientRegistry.registerKeyBinding(keyToggleRingOfLokiBreaking);
|
||||
ClientRegistry.registerKeyBinding(keyRingOfLokiClear);
|
||||
|
||||
}
|
||||
@SideOnly(Side.CLIENT)
|
||||
@@ -32,8 +32,8 @@ public class KeyHandler {
|
||||
if (keyToggleRingOfLoki.isPressed()){
|
||||
toggleRingLoki();
|
||||
}
|
||||
if(keyToggleRingOfLokiBreaking.isPressed()){
|
||||
toggleRingLokiBreaking();
|
||||
if(keyRingOfLokiClear.isPressed()){
|
||||
ringOfLokiClear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class KeyHandler {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiToggle());
|
||||
}
|
||||
|
||||
private static void toggleRingLokiBreaking() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiToggleBreaking());
|
||||
private static void ringOfLokiClear() {
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketLokiClear());
|
||||
}
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 16, 2015, 6:42:40 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.bag;
|
||||
|
||||
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;
|
||||
import vazkii.botania.client.gui.SlotLocked;
|
||||
|
||||
public class ContainerFlowerBag extends Container {
|
||||
|
||||
InventoryFlowerBag flowerBagInv;
|
||||
|
||||
public ContainerFlowerBag(EntityPlayer player) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
int slot = player.inventory.currentItem;
|
||||
IInventory playerInv = player.inventory;
|
||||
flowerBagInv = new InventoryFlowerBag(player, slot);
|
||||
|
||||
for(i = 0; i < 2; ++i)
|
||||
for(j = 0; j < 8; ++j) {
|
||||
int k = j + i * 8;
|
||||
addSlotToContainer(new SlotFlower(flowerBagInv, k, 17 + j * 18, 26 + i * 18, k));
|
||||
}
|
||||
|
||||
for(i = 0; i < 3; ++i)
|
||||
for(j = 0; j < 9; ++j)
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
|
||||
for(i = 0; i < 9; ++i) {
|
||||
if(player.inventory.currentItem == i)
|
||||
addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142));
|
||||
else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
boolean can = flowerBagInv.isUseableByPlayer(player);
|
||||
if(!can)
|
||||
onContainerClosed(player);
|
||||
|
||||
return can;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
flowerBagInv.pushInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(p_82846_2_);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if(p_82846_2_ < 16) {
|
||||
if(!mergeItemStack(itemstack1, 16, 52, true))
|
||||
return null;
|
||||
} else {
|
||||
int i = itemstack.getItemDamage();
|
||||
if(i < 16) {
|
||||
Slot slot1 = (Slot)inventorySlots.get(i);
|
||||
if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(itemstack1.stackSize == 0)
|
||||
slot.putStack((ItemStack)null);
|
||||
else slot.onSlotChanged();
|
||||
|
||||
if(itemstack1.stackSize == itemstack.stackSize)
|
||||
return null;
|
||||
|
||||
slot.onPickupFromSlot(p_82846_1_, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 16, 2015, 6:42:43 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.bag;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class GuiFlowerBag extends GuiContainer {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG);
|
||||
|
||||
public GuiFlowerBag(EntityPlayer player) {
|
||||
super(new ContainerFlowerBag(player));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String s = StatCollector.translateToLocal("item.botania:flowerBag.name");
|
||||
fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
List<Slot> slotList = inventorySlots.inventorySlots;
|
||||
for(Slot slot : slotList)
|
||||
if(slot instanceof SlotFlower) {
|
||||
SlotFlower slotf = (SlotFlower) slot;
|
||||
if(!slotf.getHasStack()) {
|
||||
ItemStack stack = new ItemStack(ModBlocks.flower, 0, slotf.color);
|
||||
int x = guiLeft + slotf.xDisplayPosition;
|
||||
int y = guiTop + slotf.yDisplayPosition;
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkHotbarKeys(int p_146983_1_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,160 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 16, 2015, 6:42:56 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.bag;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.ItemFlowerBag;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class InventoryFlowerBag implements IInventory {
|
||||
|
||||
private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16];
|
||||
|
||||
EntityPlayer player;
|
||||
int slot;
|
||||
ItemStack[] stacks = null;
|
||||
|
||||
boolean invPushed = false;
|
||||
ItemStack storedInv = null;
|
||||
|
||||
public InventoryFlowerBag(EntityPlayer player, int slot) {
|
||||
this.player = player;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
public static boolean isFlowerBag(ItemStack stack) {
|
||||
return stack != null && stack.getItem() == ModItems.flowerBag;
|
||||
}
|
||||
|
||||
ItemStack getStack() {
|
||||
ItemStack stack = player.inventory.getStackInSlot(slot);
|
||||
if(stack != null)
|
||||
storedInv = stack;
|
||||
return stack;
|
||||
}
|
||||
|
||||
ItemStack[] getInventory() {
|
||||
if(stacks != null)
|
||||
return stacks;
|
||||
|
||||
ItemStack stack = getStack();
|
||||
if(isFlowerBag(getStack())) {
|
||||
stacks = ItemFlowerBag.loadStacks(stack);
|
||||
return stacks;
|
||||
}
|
||||
|
||||
return FALLBACK_INVENTORY;
|
||||
}
|
||||
|
||||
public void pushInventory() {
|
||||
if(invPushed)
|
||||
return;
|
||||
|
||||
ItemStack stack = getStack();
|
||||
if(stack == null)
|
||||
stack = storedInv;
|
||||
|
||||
if(stack != null) {
|
||||
ItemStack[] inv = getInventory();
|
||||
ItemFlowerBag.setStacks(stack, inv);
|
||||
}
|
||||
|
||||
invPushed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return getInventory()[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
ItemStack[] inventorySlots = getInventory();
|
||||
if (inventorySlots[i] != null) {
|
||||
ItemStack stackAt;
|
||||
|
||||
if (inventorySlots[i].stackSize <= j) {
|
||||
stackAt = inventorySlots[i];
|
||||
inventorySlots[i] = null;
|
||||
return stackAt;
|
||||
} else {
|
||||
stackAt = inventorySlots[i].splitStack(j);
|
||||
|
||||
if (inventorySlots[i].stackSize == 0)
|
||||
inventorySlots[i] = null;
|
||||
|
||||
return stackAt;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int i) {
|
||||
return getStackInSlot(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
ItemStack[] inventorySlots = getInventory();
|
||||
inventorySlots[i] = itemstack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return isFlowerBag(getStack()) ? 64 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer entityplayer) {
|
||||
return isFlowerBag(getStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int i, ItemStack itemstack) {
|
||||
return isFlowerBag(getStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return LibItemNames.FLOWER_BAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 16, 2015, 7:20:05 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.client.gui.bag;
|
||||
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class SlotFlower extends Slot {
|
||||
|
||||
InventoryFlowerBag inv;
|
||||
int color;
|
||||
|
||||
public SlotFlower(InventoryFlowerBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) {
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
|
||||
this.color = color;
|
||||
inv = p_i1824_1_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(ItemStack oldStack, ItemStack newStack) {
|
||||
inv.setInventorySlotContents(color, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.getItemDamage() == color;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package vazkii.botania.client.gui.bags;
|
||||
|
||||
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;
|
||||
import vazkii.botania.client.gui.SlotLocked;
|
||||
|
||||
public abstract class ContainerMagicPlantBag extends Container {
|
||||
|
||||
protected InventoryMagicPlantBag magicPlantInv;
|
||||
public ContainerMagicPlantBag(EntityPlayer player) {
|
||||
int i;
|
||||
int j;
|
||||
|
||||
IInventory playerInv = player.inventory;
|
||||
|
||||
addMagicPlantSlots(player);
|
||||
|
||||
for(i = 0; i < 3; ++i) {
|
||||
for(j = 0; j < 9; ++j) {
|
||||
addSlotToContainer(new Slot(playerInv, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for(i = 0; i < 9; ++i) {
|
||||
if(player.inventory.currentItem == i) {
|
||||
addSlotToContainer(new SlotLocked(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
else addSlotToContainer(new Slot(playerInv, i, 8 + i * 18, 142));
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void addMagicPlantSlots(EntityPlayer player);
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer player) {
|
||||
boolean can = magicPlantInv.isUseableByPlayer(player);
|
||||
if(!can)
|
||||
onContainerClosed(player);
|
||||
|
||||
return can;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
magicPlantInv.pushInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer p_82846_1_, int p_82846_2_) {
|
||||
ItemStack itemstack = null;
|
||||
Slot slot = (Slot)inventorySlots.get(p_82846_2_);
|
||||
|
||||
if(slot != null && slot.getHasStack()) {
|
||||
ItemStack itemstack1 = slot.getStack();
|
||||
itemstack = itemstack1.copy();
|
||||
|
||||
if(p_82846_2_ < 16) {
|
||||
if(!mergeItemStack(itemstack1, 16, 52, true))
|
||||
return null;
|
||||
} else {
|
||||
int i = itemstack.getItemDamage();
|
||||
if(i < 16) {
|
||||
Slot slot1 = (Slot)inventorySlots.get(i);
|
||||
if(slot1.isItemValid(itemstack) && !mergeItemStack(itemstack1, i, i + 1, true))
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(itemstack1.stackSize == 0)
|
||||
slot.putStack((ItemStack)null);
|
||||
else slot.onSlotChanged();
|
||||
|
||||
if(itemstack1.stackSize == itemstack.stackSize)
|
||||
return null;
|
||||
|
||||
slot.onPickupFromSlot(p_82846_1_, itemstack1);
|
||||
}
|
||||
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
package vazkii.botania.client.gui.bags;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
public abstract class GuiMagicPlantBag extends GuiContainer {
|
||||
|
||||
private final ResourceLocation texture;
|
||||
public GuiMagicPlantBag(ContainerMagicPlantBag container, ResourceLocation texture) {
|
||||
super(container);
|
||||
this.texture = texture;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int p_146979_1_, int p_146979_2_) {
|
||||
String s = StatCollector.translateToLocal(getLocalizedNameKey());
|
||||
fontRendererObj.drawString(s, xSize / 2 - fontRendererObj.getStringWidth(s) / 2, 6, 4210752);
|
||||
fontRendererObj.drawString(I18n.format("container.inventory", new Object[0]), 8, ySize - 96 + 2, 4210752);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
mc.getTextureManager().bindTexture(texture);
|
||||
int k = (width - xSize) / 2;
|
||||
int l = (height - ySize) / 2;
|
||||
drawTexturedModalRect(k, l, 0, 0, xSize, ySize);
|
||||
|
||||
List<Slot> slotList = inventorySlots.inventorySlots;
|
||||
for(Slot slot : slotList)
|
||||
if(slot instanceof SlotMagicPlant) {
|
||||
SlotMagicPlant slotf = (SlotMagicPlant) slot;
|
||||
if(!slotf.getHasStack()) {
|
||||
ItemStack stack = new ItemStack(itemTypeAllowed(), 0, slotf.color);
|
||||
int x = guiLeft + slotf.xDisplayPosition;
|
||||
int y = guiTop + slotf.yDisplayPosition;
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
RenderItem.getInstance().renderItemIntoGUI(mc.fontRenderer, mc.renderEngine, stack, x, y);
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
mc.fontRenderer.drawStringWithShadow("0", x + 11, y + 9, 0xFF6666);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkHotbarKeys(int p_146983_1_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected abstract Block itemTypeAllowed();
|
||||
|
||||
protected abstract String getLocalizedNameKey();
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
package vazkii.botania.client.gui.bags;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.bag.ItemBagBase;
|
||||
|
||||
public abstract class InventoryMagicPlantBag implements IInventory {
|
||||
|
||||
private static final ItemStack[] FALLBACK_INVENTORY = new ItemStack[16];
|
||||
|
||||
EntityPlayer player;
|
||||
int slot;
|
||||
ItemStack[] stacks = null;
|
||||
|
||||
boolean invPushed = false;
|
||||
ItemStack storedInv = null;
|
||||
|
||||
public InventoryMagicPlantBag(EntityPlayer player, int slot) {
|
||||
this.player = player;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
ItemStack getStack() {
|
||||
ItemStack stack = player.inventory.getStackInSlot(slot);
|
||||
if(stack != null)
|
||||
storedInv = stack;
|
||||
return stack;
|
||||
}
|
||||
|
||||
|
||||
public void pushInventory() {
|
||||
if(invPushed)
|
||||
return;
|
||||
|
||||
ItemStack stack = getStack();
|
||||
if(stack == null)
|
||||
stack = storedInv;
|
||||
|
||||
if(stack != null) {
|
||||
ItemStack[] inv = getInventory();
|
||||
ItemBagBase.setStacks(stack, inv);
|
||||
}
|
||||
|
||||
invPushed = true;
|
||||
}
|
||||
|
||||
ItemStack[] getInventory() {
|
||||
if(stacks != null)
|
||||
return stacks;
|
||||
|
||||
ItemStack stack = getStack();
|
||||
if(isMagicPlantBag(getStack())) {
|
||||
stacks = ItemBagBase.loadStacks(stack);
|
||||
return stacks;
|
||||
}
|
||||
|
||||
return FALLBACK_INVENTORY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int slotIn) {
|
||||
return getInventory()[slotIn];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int index, int count) {
|
||||
ItemStack[] inventorySlots = getInventory();
|
||||
if (inventorySlots[index] != null) {
|
||||
ItemStack stackAt;
|
||||
|
||||
if (inventorySlots[index].stackSize <= count) {
|
||||
stackAt = inventorySlots[index];
|
||||
inventorySlots[index] = null;
|
||||
return stackAt;
|
||||
} else {
|
||||
stackAt = inventorySlots[index].splitStack(count);
|
||||
|
||||
if (inventorySlots[index].stackSize == 0)
|
||||
inventorySlots[index] = null;
|
||||
|
||||
return stackAt;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int index) {
|
||||
return getStackInSlot(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int index, ItemStack stack) {
|
||||
ItemStack[] inventorySlots = getInventory();
|
||||
inventorySlots[index] = stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return getBagName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return isMagicPlantBag(getStack()) ? 64 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer player) {
|
||||
return isMagicPlantBag(getStack());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
// NO-OP
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int index, ItemStack stack) {
|
||||
return isMagicPlantBag(getStack());
|
||||
}
|
||||
|
||||
protected abstract String getBagName();
|
||||
|
||||
public abstract boolean isMagicPlantBag(ItemStack stack);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
|
||||
package vazkii.botania.client.gui.bags;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public abstract class SlotMagicPlant extends Slot {
|
||||
|
||||
InventoryMagicPlantBag inv;
|
||||
int color;
|
||||
|
||||
public SlotMagicPlant(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) {
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_);
|
||||
this.color = color;
|
||||
inv = p_i1824_1_;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSlotChange(ItemStack oldStack, ItemStack newStack) {
|
||||
inv.setInventorySlotContents(color, newStack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack stack) {
|
||||
return stack.getItem() == Item.getItemFromBlock(getValidBlock()) && stack.getItemDamage() == color;
|
||||
}
|
||||
|
||||
protected abstract Block getValidBlock();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.client.gui.bags.flowerBag;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import vazkii.botania.client.gui.bags.ContainerMagicPlantBag;
|
||||
|
||||
public class ContainerFlowerBag extends ContainerMagicPlantBag {
|
||||
public ContainerFlowerBag(EntityPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMagicPlantSlots(EntityPlayer player) {
|
||||
int slot = player.inventory.currentItem;
|
||||
magicPlantInv = new InventoryFlowerBag(player, slot);
|
||||
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
int k = j + i * 8;
|
||||
addSlotToContainer(new SlotFlower(magicPlantInv, k, 17 + j * 18, 26 + i * 18, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package vazkii.botania.client.gui.bags.flowerBag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.client.gui.bags.GuiMagicPlantBag;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class GuiFlowerBag extends GuiMagicPlantBag {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_FLOWER_BAG);
|
||||
|
||||
public GuiFlowerBag(EntityPlayer player) {
|
||||
super(new ContainerFlowerBag(player), texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block itemTypeAllowed() {
|
||||
return ModBlocks.flower;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLocalizedNameKey() {
|
||||
return "item.botania:flowerBag.name";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.client.gui.bags.flowerBag;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.client.gui.bags.InventoryMagicPlantBag;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class InventoryFlowerBag extends InventoryMagicPlantBag {
|
||||
public InventoryFlowerBag(EntityPlayer player, int slot) {
|
||||
super(player, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMagicPlantBag(ItemStack stack) {
|
||||
return stack != null && stack.getItem() == ModItems.flowerBag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBagName() {
|
||||
return LibItemNames.FLOWER_BAG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package vazkii.botania.client.gui.bags.flowerBag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import vazkii.botania.client.gui.bags.InventoryMagicPlantBag;
|
||||
import vazkii.botania.client.gui.bags.SlotMagicPlant;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class SlotFlower extends SlotMagicPlant {
|
||||
public SlotFlower(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) {
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block getValidBlock() {
|
||||
return ModBlocks.flower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.client.gui.bags.shroomBag;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import vazkii.botania.client.gui.bags.ContainerMagicPlantBag;
|
||||
|
||||
public class ContainerShroomBag extends ContainerMagicPlantBag {
|
||||
public ContainerShroomBag(EntityPlayer player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addMagicPlantSlots(EntityPlayer player) {
|
||||
int slot = player.inventory.currentItem;
|
||||
magicPlantInv = new InventoryShroomBag(player, slot);
|
||||
|
||||
for(int i = 0; i < 2; ++i) {
|
||||
for (int j = 0; j < 8; ++j) {
|
||||
int k = j + i * 8;
|
||||
addSlotToContainer(new SlotShroom(magicPlantInv, k, 17 + j * 18, 26 + i * 18, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package vazkii.botania.client.gui.bags.shroomBag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import vazkii.botania.client.gui.bags.GuiMagicPlantBag;
|
||||
import vazkii.botania.client.lib.LibResources;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class GuiShroomBag extends GuiMagicPlantBag {
|
||||
|
||||
private static final ResourceLocation texture = new ResourceLocation(LibResources.GUI_SHROOM_BAG);
|
||||
|
||||
public GuiShroomBag(EntityPlayer player) {
|
||||
super(new ContainerShroomBag(player), texture);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block itemTypeAllowed() {
|
||||
return ModBlocks.mushroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLocalizedNameKey() {
|
||||
return "item.botania:shroomBag.name";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.client.gui.bags.shroomBag;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.client.gui.bags.InventoryMagicPlantBag;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class InventoryShroomBag extends InventoryMagicPlantBag {
|
||||
public InventoryShroomBag(EntityPlayer player, int slot) {
|
||||
super(player, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMagicPlantBag(ItemStack stack) {
|
||||
return stack != null && stack.getItem() == ModItems.shroomBag;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBagName() {
|
||||
return LibItemNames.SHROOM_BAG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package vazkii.botania.client.gui.bags.shroomBag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import vazkii.botania.client.gui.bags.InventoryMagicPlantBag;
|
||||
import vazkii.botania.client.gui.bags.SlotMagicPlant;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
|
||||
public class SlotShroom extends SlotMagicPlant {
|
||||
public SlotShroom(InventoryMagicPlantBag p_i1824_1_, int p_i1824_2_, int p_i1824_3_, int p_i1824_4_, int color) {
|
||||
super(p_i1824_1_, p_i1824_2_, p_i1824_3_, p_i1824_4_, color);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block getValidBlock() {
|
||||
return ModBlocks.mushroom;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,6 +44,7 @@ public final class LibResources {
|
||||
public static final String GUI_NEI_BLANK = PREFIX_GUI + "neiBlank.png";
|
||||
public static final String GUI_NEI_BREWERY = PREFIX_GUI + "neiBrewery.png";
|
||||
public static final String GUI_FLOWER_BAG = PREFIX_GUI + "flowerBag.png";
|
||||
public static final String GUI_SHROOM_BAG = PREFIX_GUI + "shroomBag.png";
|
||||
public static final String GUI_BAUBLE_BOX = PREFIX_GUI + "baubleBox.png";
|
||||
public static final String GUI_HUD_ICONS = PREFIX_GUI + "hudIcons.png";
|
||||
public static final String GUI_STENCIL = PREFIX_GUI + "stencil.png";
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
*/
|
||||
package vazkii.botania.client.render.tile;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
||||
@@ -16,11 +16,13 @@ import java.util.List;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.api.lexicon.ILexicon;
|
||||
import vazkii.botania.api.lexicon.multiblock.Multiblock;
|
||||
@@ -71,6 +73,7 @@ public class TileAlfPortal extends TileMod {
|
||||
int ticksSinceLastItem = 0;
|
||||
private boolean closeNow = false;
|
||||
private boolean hasUnloadedParts = false;
|
||||
private boolean explode = false;
|
||||
|
||||
private static final Function<int[], int[]> CONVERTER_X_Z = new Function<int[], int[]>() {
|
||||
@Override
|
||||
@@ -142,7 +145,9 @@ public class TileAlfPortal extends TileMod {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if(stack != null && (!(stack.getItem() instanceof IElvenItem) || !((IElvenItem) stack.getItem()).isElvenItem(stack)) && !item.getEntityData().hasKey(TAG_PORTAL_FLAG)) {
|
||||
item.setDead();
|
||||
addItem(stack);
|
||||
if (validateItemUsage(stack)) {
|
||||
addItem(stack);
|
||||
}
|
||||
ticksSinceLastItem = 0;
|
||||
}
|
||||
}
|
||||
@@ -164,11 +169,35 @@ public class TileAlfPortal extends TileMod {
|
||||
for(int i = 0; i < 36; i++)
|
||||
blockParticle(meta);
|
||||
worldObj.setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 1 | 2);
|
||||
} else if(explode) {
|
||||
worldObj.createExplosion(null, xCoord + .5, yCoord + 2.0, zCoord + .5, 3f, true);
|
||||
explode = false;
|
||||
}
|
||||
|
||||
hasUnloadedParts = false;
|
||||
}
|
||||
|
||||
private boolean validateItemUsage(ItemStack inputStack) {
|
||||
for(RecipeElvenTrade recipe : BotaniaAPI.elvenTradeRecipes) {
|
||||
for(Object o : recipe.getInputs()) {
|
||||
if(o instanceof String) {
|
||||
for(ItemStack target : OreDictionary.getOres((String) o)) {
|
||||
if(OreDictionary.itemMatches(target, inputStack, false))
|
||||
return true;
|
||||
}
|
||||
} else if(o instanceof ItemStack) {
|
||||
ItemStack target = (ItemStack) o;
|
||||
if(inputStack.getItem() == target.getItem() && inputStack.getItemDamage() == target.getItemDamage())
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(inputStack.getItem() == Items.bread) //Don't teleport bread. (See also: #2403)
|
||||
explode = true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void blockParticle(int meta) {
|
||||
int i = worldObj.rand.nextInt(AIR_POSITIONS.length);
|
||||
double[] pos = new double[] {
|
||||
|
||||
@@ -257,6 +257,7 @@ public final class ModCraftingRecipes {
|
||||
public static IRecipe recipeSwapRing;
|
||||
public static IRecipe recipeSnowHorn;
|
||||
public static IRecipe recipeFlowerBag;
|
||||
public static IRecipe recipeShroomBag;
|
||||
public static IRecipe recipePhantomInk;
|
||||
public static IRecipe recipePoolCart;
|
||||
public static IRecipe recipePump;
|
||||
@@ -1768,6 +1769,13 @@ public final class ModCraftingRecipes {
|
||||
'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE));
|
||||
recipeFlowerBag = BotaniaAPI.getLatestAddedRecipe();
|
||||
|
||||
// Mushroom Pouch Recipe
|
||||
GameRegistry.addShapedRecipe(new ItemStack(ModItems.shroomBag),
|
||||
"WPW", "W W", " W ",
|
||||
'P', new ItemStack(ModBlocks.mushroom, 1, Short.MAX_VALUE),
|
||||
'W', new ItemStack(Blocks.wool, 1, Short.MAX_VALUE));
|
||||
recipeShroomBag = BotaniaAPI.getLatestAddedRecipe();
|
||||
|
||||
// Phantom Ink Recipe
|
||||
addShapelessOreDictRecipe(new ItemStack(ModItems.phantomInk, 4), LibOreDict.MANA_PEARL, "dye", "blockGlass", new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle), new ItemStack(Items.glass_bottle));
|
||||
recipePhantomInk = BotaniaAPI.getLatestAddedRecipe();
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
/**
|
||||
* This class was created by <Vazkii>. It's distributed as
|
||||
* part of the Botania Mod. Get the Source Code in github:
|
||||
* https://github.com/Vazkii/Botania
|
||||
*
|
||||
* Botania is Open Source and distributed under the
|
||||
* Botania License: http://botaniamod.net/license.php
|
||||
*
|
||||
* File Created @ [Mar 16, 2015, 6:43:33 PM (GMT)]
|
||||
*/
|
||||
package vazkii.botania.common.item;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
|
||||
public class ItemFlowerBag extends ItemMod {
|
||||
|
||||
private static final String TAG_ITEMS = "InvItems";
|
||||
private static final String TAG_SLOT = "Slot";
|
||||
|
||||
public ItemFlowerBag() {
|
||||
setUnlocalizedName(LibItemNames.FLOWER_BAG);
|
||||
setMaxStackSize(1);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPickupItem(EntityItemPickupEvent event) {
|
||||
ItemStack stack = event.item.getEntityItem();
|
||||
if(stack.getItem() == Item.getItemFromBlock(ModBlocks.flower) && stack.stackSize > 0) {
|
||||
int color = stack.getItemDamage();
|
||||
if(color > 15)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) {
|
||||
if(i == event.entityPlayer.inventory.currentItem)
|
||||
continue; // prevent item deletion
|
||||
|
||||
ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i);
|
||||
if(invStack != null && invStack.getItem() == this) {
|
||||
ItemStack[] bagInv = loadStacks(invStack);
|
||||
ItemStack stackAt = bagInv[color];
|
||||
boolean didChange = false;
|
||||
if(stackAt == null) {
|
||||
bagInv[color] = stack.copy();
|
||||
stack.stackSize = 0;
|
||||
didChange = true;
|
||||
} else {
|
||||
int stackAtSize = stackAt.stackSize;
|
||||
int stackSize = stack.stackSize;
|
||||
int spare = 64 - stackAtSize;
|
||||
int pass = Math.min(spare, stackSize);
|
||||
if(pass > 0) {
|
||||
stackAt.stackSize += pass;
|
||||
stack.stackSize -= pass;
|
||||
didChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(didChange)
|
||||
setStacks(invStack, bagInv);
|
||||
}
|
||||
|
||||
if(stack.stackSize == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
player.openGui(Botania.instance, LibGuiIDs.FLOWER_BAG, world, 0, 0, 0);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof IInventory) {
|
||||
if(!world.isRemote) {
|
||||
ForgeDirection side = ForgeDirection.getOrientation(s);
|
||||
IInventory inv = (IInventory) tile;
|
||||
ItemStack[] stacks = loadStacks(stack);
|
||||
ItemStack[] newStacks = new ItemStack[stacks.length];
|
||||
boolean putAny = false;
|
||||
|
||||
int i = 0;
|
||||
for(ItemStack petal : stacks) {
|
||||
if(petal != null) {
|
||||
int count = InventoryHelper.testInventoryInsertion(inv, petal, side);
|
||||
InventoryHelper.insertItemIntoInventory(inv, petal, side, -1);
|
||||
|
||||
ItemStack newPetal = petal.copy();
|
||||
if(newPetal.stackSize == 0)
|
||||
newPetal = null;
|
||||
|
||||
newStacks[i] = newPetal;
|
||||
putAny |= count > 0;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
setStacks(stack, newStacks);
|
||||
if(putAny && inv instanceof TileEntityChest) {
|
||||
inv = InventoryHelper.getInventory(inv);
|
||||
player.displayGUIChest(inv);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack[] loadStacks(ItemStack stack) {
|
||||
NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false);
|
||||
ItemStack[] inventorySlots = new ItemStack[16];
|
||||
for(int var3 = 0; var3 < var2.tagCount(); ++var3) {
|
||||
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
|
||||
byte var5 = var4.getByte(TAG_SLOT);
|
||||
if(var5 >= 0 && var5 < inventorySlots.length)
|
||||
inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
|
||||
return inventorySlots;
|
||||
}
|
||||
|
||||
public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) {
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
for(int var3 = 0; var3 < inventorySlots.length; ++var3)
|
||||
if(inventorySlots[var3] != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte(TAG_SLOT, (byte)var3);
|
||||
inventorySlots[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
|
||||
ItemNBTHelper.setList(stack, TAG_ITEMS, var2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,6 +15,8 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
import vazkii.botania.api.BotaniaAPI;
|
||||
import vazkii.botania.common.item.bag.ItemFlowerBag;
|
||||
import vazkii.botania.common.item.bag.ItemShroomBag;
|
||||
import vazkii.botania.common.item.brew.ItemBrewFlask;
|
||||
import vazkii.botania.common.item.brew.ItemBrewVial;
|
||||
import vazkii.botania.common.item.brew.ItemIncenseStick;
|
||||
@@ -232,6 +234,7 @@ public final class ModItems {
|
||||
public static Item cosmetic;
|
||||
public static Item swapRing;
|
||||
public static Item flowerBag;
|
||||
public static Item shroomBag;
|
||||
public static Item phantomInk;
|
||||
public static Item poolMinecart;
|
||||
public static Item pinkinator;
|
||||
@@ -381,6 +384,7 @@ public final class ModItems {
|
||||
cosmetic = new ItemBaubleCosmetic();
|
||||
swapRing = new ItemSwapRing();
|
||||
flowerBag = new ItemFlowerBag();
|
||||
shroomBag = new ItemShroomBag();
|
||||
phantomInk = new ItemPhantomInk();
|
||||
poolMinecart = new ItemPoolMinecart();
|
||||
pinkinator = new ItemPinkinator();
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
package vazkii.botania.common.item.bag;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.core.helper.InventoryHelper;
|
||||
import vazkii.botania.common.core.helper.ItemNBTHelper;
|
||||
import vazkii.botania.common.item.ItemMod;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public abstract class ItemBagBase extends ItemMod {
|
||||
|
||||
private static final String TAG_ITEMS = "InvItems";
|
||||
private static final String TAG_SLOT = "Slot";
|
||||
|
||||
public ItemBagBase(String name) {
|
||||
setUnlocalizedName(name);
|
||||
setMaxStackSize(1);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onPickupItem(EntityItemPickupEvent event) {
|
||||
ItemStack stack = event.item.getEntityItem();
|
||||
if(stack.getItem() == Item.getItemFromBlock(getValidPickUp()) && stack.stackSize > 0) {
|
||||
int color = stack.getItemDamage();
|
||||
if(color > 15)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < event.entityPlayer.inventory.getSizeInventory(); i++) {
|
||||
if(i == event.entityPlayer.inventory.currentItem)
|
||||
continue; // prevent item deletion
|
||||
|
||||
ItemStack invStack = event.entityPlayer.inventory.getStackInSlot(i);
|
||||
if(invStack != null && invStack.getItem() == this) {
|
||||
ItemStack[] bagInv = loadStacks(invStack);
|
||||
ItemStack stackAt = bagInv[color];
|
||||
boolean didChange = false;
|
||||
if(stackAt == null) {
|
||||
bagInv[color] = stack.copy();
|
||||
stack.stackSize = 0;
|
||||
didChange = true;
|
||||
} else {
|
||||
int stackAtSize = stackAt.stackSize;
|
||||
int stackSize = stack.stackSize;
|
||||
int spare = 64 - stackAtSize;
|
||||
int pass = Math.min(spare, stackSize);
|
||||
if(pass > 0) {
|
||||
stackAt.stackSize += pass;
|
||||
stack.stackSize -= pass;
|
||||
didChange = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(didChange)
|
||||
setStacks(invStack, bagInv);
|
||||
}
|
||||
|
||||
if(stack.stackSize == 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
player.openGui(Botania.instance, getGuiID(), world, 0, 0, 0);
|
||||
return stack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int s, float xs, float ys, float zs) {
|
||||
TileEntity tile = world.getTileEntity(x, y, z);
|
||||
if(tile != null && tile instanceof IInventory) {
|
||||
if(!world.isRemote) {
|
||||
ForgeDirection side = ForgeDirection.getOrientation(s);
|
||||
IInventory inv = (IInventory) tile;
|
||||
ItemStack[] stacks = loadStacks(stack);
|
||||
ItemStack[] newStacks = new ItemStack[stacks.length];
|
||||
boolean putAny = false;
|
||||
|
||||
int i = 0;
|
||||
for(ItemStack petal : stacks) {
|
||||
if(petal != null) {
|
||||
int count = InventoryHelper.testInventoryInsertion(inv, petal, side);
|
||||
InventoryHelper.insertItemIntoInventory(inv, petal, side, -1);
|
||||
|
||||
ItemStack newPetal = petal.copy();
|
||||
if(newPetal.stackSize == 0)
|
||||
newPetal = null;
|
||||
|
||||
newStacks[i] = newPetal;
|
||||
putAny |= count > 0;
|
||||
}
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
setStacks(stack, newStacks);
|
||||
if(putAny && inv instanceof TileEntityChest) {
|
||||
inv = InventoryHelper.getInventory(inv);
|
||||
player.displayGUIChest(inv);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ItemStack[] loadStacks(ItemStack stack) {
|
||||
NBTTagList var2 = ItemNBTHelper.getList(stack, TAG_ITEMS, 10, false);
|
||||
ItemStack[] inventorySlots = new ItemStack[16];
|
||||
for(int var3 = 0; var3 < var2.tagCount(); ++var3) {
|
||||
NBTTagCompound var4 = var2.getCompoundTagAt(var3);
|
||||
byte var5 = var4.getByte(TAG_SLOT);
|
||||
if(var5 >= 0 && var5 < inventorySlots.length)
|
||||
inventorySlots[var5] = ItemStack.loadItemStackFromNBT(var4);
|
||||
}
|
||||
|
||||
return inventorySlots;
|
||||
}
|
||||
|
||||
public static void setStacks(ItemStack stack, ItemStack[] inventorySlots) {
|
||||
NBTTagList var2 = new NBTTagList();
|
||||
for(int var3 = 0; var3 < inventorySlots.length; ++var3)
|
||||
if(inventorySlots[var3] != null) {
|
||||
NBTTagCompound var4 = new NBTTagCompound();
|
||||
var4.setByte(TAG_SLOT, (byte)var3);
|
||||
inventorySlots[var3].writeToNBT(var4);
|
||||
var2.appendTag(var4);
|
||||
}
|
||||
|
||||
ItemNBTHelper.setList(stack, TAG_ITEMS, var2);
|
||||
}
|
||||
|
||||
protected abstract Block getValidPickUp();
|
||||
|
||||
protected abstract int getGuiID();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.common.item.bag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemFlowerBag extends ItemBagBase {
|
||||
|
||||
public ItemFlowerBag() {
|
||||
super(LibItemNames.FLOWER_BAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block getValidPickUp() {
|
||||
return ModBlocks.flower;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGuiID() {
|
||||
return LibGuiIDs.FLOWER_BAG;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package vazkii.botania.common.item.bag;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import vazkii.botania.common.block.ModBlocks;
|
||||
import vazkii.botania.common.lib.LibGuiIDs;
|
||||
import vazkii.botania.common.lib.LibItemNames;
|
||||
|
||||
public class ItemShroomBag extends ItemBagBase{
|
||||
|
||||
public ItemShroomBag() {
|
||||
super(LibItemNames.SHROOM_BAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Block getValidPickUp() {
|
||||
return ModBlocks.mushroom;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getGuiID() {
|
||||
return LibGuiIDs.SHROOM_BAG;
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ public abstract class ItemBauble extends ItemMod implements IBauble, ICosmeticAt
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.hasPhantomInk"), par3List);
|
||||
}
|
||||
|
||||
void addStringToTooltip(String s, List<String> tooltip) {
|
||||
public void addStringToTooltip(String s, List<String> tooltip) {
|
||||
tooltip.add(s.replaceAll("&", "\u00a7"));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
private boolean recursion = false;
|
||||
|
||||
public static enum HUD_MESSAGE {
|
||||
MODE, BREAKING
|
||||
MODE, BREAKING, CLEAR
|
||||
}
|
||||
|
||||
public ItemLokiRing() {
|
||||
@@ -122,12 +122,12 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
if (heldItemStack == null && event.action == Action.RIGHT_CLICK_BLOCK && player.isSneaking() && isRingEnabled(lokiRing)) {
|
||||
if(originCoords.posY == -1 && lookPos != null) {
|
||||
setOriginPos(lokiRing, lookPos.blockX, lookPos.blockY, lookPos.blockZ);
|
||||
setCursorList(lokiRing, null);
|
||||
clearCursors(lokiRing);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player);
|
||||
} else if(lookPos != null) {
|
||||
if(originCoords.posX == lookPos.blockX && originCoords.posY == lookPos.blockY && originCoords.posZ == lookPos.blockZ) {
|
||||
setOriginPos(lokiRing, 0, -1, 0);
|
||||
clearMasterCursor(lokiRing);
|
||||
if(player instanceof EntityPlayerMP)
|
||||
PacketHandler.INSTANCE.sendTo(new PacketSyncBauble(player, slot), (EntityPlayerMP) player);
|
||||
} else {
|
||||
@@ -215,6 +215,9 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
case BREAKING:
|
||||
text = getLokiBreakingModeText(getLokiRing(mc.thePlayer));
|
||||
break;
|
||||
case CLEAR:
|
||||
text = getLokiCearText(getLokiRing(mc.thePlayer));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -222,25 +225,39 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
|
||||
GTNHLib.proxy.printMessageAboveHotbar(text, 60, true, true);
|
||||
}
|
||||
|
||||
public static String getOnOffString(boolean state){
|
||||
return state ? EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.lokiOn") :
|
||||
EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.lokiOff");
|
||||
}
|
||||
|
||||
public static String getLokiModeText(ItemStack stack){
|
||||
return EnumChatFormatting.GOLD + StatCollector.translateToLocal("item.botania:lokiRing.name") + " " + (isRingEnabled(stack) ?
|
||||
EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.lokiOn") :
|
||||
EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.lokiOff"));
|
||||
return EnumChatFormatting.GOLD + StatCollector.translateToLocal("item.botania:lokiRing.name") + " " + getOnOffString(isRingEnabled(stack));
|
||||
}
|
||||
|
||||
public static String getLokiBreakingModeText(ItemStack stack){
|
||||
return EnumChatFormatting.GOLD + StatCollector.translateToLocal("item.botania:lokiRing.name") + " "+
|
||||
StatCollector.translateToLocal("botaniamisc.breaking") + " " + (isRingBreakingEnabled(stack) ?
|
||||
EnumChatFormatting.GREEN + StatCollector.translateToLocal("botaniamisc.lokiOn") :
|
||||
EnumChatFormatting.RED + StatCollector.translateToLocal("botaniamisc.lokiOff"));
|
||||
StatCollector.translateToLocal("botaniamisc.breaking") + " " + getOnOffString(isRingBreakingEnabled(stack));
|
||||
}
|
||||
|
||||
public static String getLokiCearText(ItemStack stack){
|
||||
return EnumChatFormatting.GOLD + StatCollector.translateToLocal("botaniamisc.lokiClear");
|
||||
}
|
||||
|
||||
public static boolean isRingEnabled (final ItemStack stack){
|
||||
return stack.stackTagCompound.getBoolean(TAG_MODE);
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
return stack.stackTagCompound.getBoolean(TAG_MODE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isRingBreakingEnabled (final ItemStack stack){
|
||||
return stack.stackTagCompound.getBoolean(TAG_BREAKING_MODE);
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
return stack.stackTagCompound.getBoolean(TAG_BREAKING_MODE);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void breakOnAllCursors(EntityPlayer player, Item item, ItemStack stack, int x, int y, int z, int side) {
|
||||
@@ -275,13 +292,28 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
|
||||
@Override
|
||||
public void onUnequipped(ItemStack stack, EntityLivingBase player) {
|
||||
setCursorList(stack, null);
|
||||
clearCursors(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean adv) {
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiDescription"), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiDescription2"), list);
|
||||
addStringToTooltip("", list);
|
||||
addStringToTooltip(EnumChatFormatting.WHITE +StatCollector.translateToLocal("botaniamisc.lokiCurrent"), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiState") + ": " + getOnOffString(isRingEnabled(stack)), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.breaking") + ": " + getOnOffString(isRingBreakingEnabled(stack)), list);
|
||||
addStringToTooltip("", list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiToggleDescription") + " " + getOnOffString(true) + EnumChatFormatting.RESET + "/"+ getOnOffString(false), list);
|
||||
addStringToTooltip(StatCollector.translateToLocal("botaniamisc.lokiBreakingDescription") + " " + getOnOffString(true) + EnumChatFormatting.RESET+"/" + getOnOffString(false), list);
|
||||
super.addInformation(stack, player, list, adv);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public List<ChunkCoordinates> getWireframesToDraw(EntityPlayer player, ItemStack stack) {
|
||||
if(getLokiRing(player) != stack)
|
||||
ItemStack lokiRing = getLokiRing(player);
|
||||
if(lokiRing != stack || !isRingEnabled(lokiRing) )
|
||||
return null;
|
||||
|
||||
MovingObjectPosition lookPos = Minecraft.getMinecraft().objectMouseOver;
|
||||
@@ -310,7 +342,15 @@ public class ItemLokiRing extends ItemRelicBauble implements IExtendedWireframeC
|
||||
|
||||
@Override
|
||||
public ChunkCoordinates getSourceWireframe(EntityPlayer player, ItemStack stack) {
|
||||
return getLokiRing(player) == stack ? getOriginPos(stack) : null;
|
||||
return getLokiRing(player) == stack && isRingEnabled(stack) ? getOriginPos(stack) : null;
|
||||
}
|
||||
|
||||
public static void clearCursors(ItemStack stack){
|
||||
setCursorList(stack, null);
|
||||
}
|
||||
|
||||
public static void clearMasterCursor(ItemStack stack){
|
||||
setOriginPos(stack, 0, -1, 0);
|
||||
}
|
||||
|
||||
public static ItemStack getLokiRing(EntityPlayer player) {
|
||||
|
||||
@@ -69,6 +69,7 @@ public final class LexiconData {
|
||||
public static LexiconEntry terrasteel;
|
||||
public static LexiconEntry blackLotus;
|
||||
public static LexiconEntry flowerBag;
|
||||
public static LexiconEntry shroomBag;
|
||||
public static LexiconEntry gardenOfGlass;
|
||||
|
||||
public static LexiconEntry manaIntro;
|
||||
@@ -395,6 +396,10 @@ public final class LexiconData {
|
||||
flowerBag.setLexiconPages(new PageText("0"), new PageText("2"),
|
||||
new PageCraftingRecipe("1", ModCraftingRecipes.recipeFlowerBag));
|
||||
|
||||
shroomBag = new BLexiconEntry(LibLexicon.BASICS_SHROOM_BAG, categoryBasics);
|
||||
shroomBag.setLexiconPages(new PageText("0"),
|
||||
new PageCraftingRecipe("1", ModCraftingRecipes.recipeShroomBag));
|
||||
|
||||
if (Botania.gardenOfGlassLoaded) {
|
||||
gardenOfGlass = new BLexiconEntry(LibLexicon.BASICS_GARDEN_OF_GLASS, categoryBasics);
|
||||
gardenOfGlass.setLexiconPages(new PageText("0"), new PageText("1"), new PageText("2"),
|
||||
|
||||
@@ -17,4 +17,6 @@ public final class LibGuiIDs {
|
||||
public static final int FLOWER_BAG = 2;
|
||||
public static final int BAUBLE_BOX = 3;
|
||||
|
||||
public static final int SHROOM_BAG = 4;
|
||||
|
||||
}
|
||||
@@ -126,6 +126,7 @@ public final class LibItemNames {
|
||||
public static final String COSMETIC = "cosmetic";
|
||||
public static final String SWAP_RING = "swapRing";
|
||||
public static final String FLOWER_BAG = "flowerBag";
|
||||
public static final String SHROOM_BAG = "shroomBag";
|
||||
public static final String PHANTOM_INK = "phantomInk";
|
||||
public static final String POOL_MINECART = "poolMinecart";
|
||||
public static final String PINKINATOR = "pinkinator";
|
||||
|
||||
@@ -38,6 +38,7 @@ public final class LibLexicon {
|
||||
public static final String BASICS_TERRASTEEL = "terrasteel";
|
||||
public static final String BASICS_BLACK_LOTUS = "blackLotus";
|
||||
public static final String BASICS_FLOWER_BAG = "flowerBag";
|
||||
public static final String BASICS_SHROOM_BAG = "shroomBag";
|
||||
public static final String BASICS_GARDEN_OF_GLASS = "gardenOfGlass";
|
||||
|
||||
public static final String MANA_INTRO = "mIntro";
|
||||
|
||||
@@ -12,8 +12,10 @@ package vazkii.botania.common.network;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
import vazkii.botania.client.gui.bag.ContainerFlowerBag;
|
||||
import vazkii.botania.client.gui.bag.GuiFlowerBag;
|
||||
import vazkii.botania.client.gui.bags.flowerBag.ContainerFlowerBag;
|
||||
import vazkii.botania.client.gui.bags.flowerBag.GuiFlowerBag;
|
||||
import vazkii.botania.client.gui.bags.shroomBag.ContainerShroomBag;
|
||||
import vazkii.botania.client.gui.bags.shroomBag.GuiShroomBag;
|
||||
import vazkii.botania.client.gui.box.ContainerBaubleBox;
|
||||
import vazkii.botania.client.gui.box.GuiBaubleBox;
|
||||
import vazkii.botania.client.gui.crafting.ContainerCraftingHalo;
|
||||
@@ -31,6 +33,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new ContainerCraftingHalo(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new ContainerFlowerBag(player);
|
||||
case LibGuiIDs.SHROOM_BAG:
|
||||
return new ContainerShroomBag(player);
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new ContainerBaubleBox(player);
|
||||
}
|
||||
@@ -48,6 +52,8 @@ public class GuiHandler implements IGuiHandler {
|
||||
return new GuiCraftingHalo(player.inventory, world);
|
||||
case LibGuiIDs.FLOWER_BAG :
|
||||
return new GuiFlowerBag(player);
|
||||
case LibGuiIDs.SHROOM_BAG:
|
||||
return new GuiShroomBag(player);
|
||||
case LibGuiIDs.BAUBLE_BOX :
|
||||
return new GuiBaubleBox(player);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ public class PacketHandler {
|
||||
public static void initPackets() {
|
||||
INSTANCE.registerMessage(PacketLokiToggle.class, PacketLokiToggle.class, 1, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiToggleAck.class, PacketLokiToggleAck.class, 2, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketLokiToggleBreaking.class, PacketLokiToggleBreaking.class, 3, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiToggleBreakingAck.class, PacketLokiToggleBreakingAck.class, 4, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketLokiToggleBreakingAck.class, PacketLokiToggleBreakingAck.class, 3, Side.CLIENT);
|
||||
INSTANCE.registerMessage(PacketLokiClear.class, PacketLokiClear.class, 4, Side.SERVER);
|
||||
INSTANCE.registerMessage(PacketLokiClearAck.class, PacketLokiClearAck.class, 5, Side.CLIENT);
|
||||
}
|
||||
}
|
||||
+5
-6
@@ -9,7 +9,7 @@ import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
|
||||
public class PacketLokiToggleBreaking implements IMessage, IMessageHandler<PacketLokiToggleBreaking, IMessage> {
|
||||
public class PacketLokiClear implements IMessage, IMessageHandler<PacketLokiClear, IMessage> {
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
// not needed
|
||||
@@ -21,14 +21,13 @@ public class PacketLokiToggleBreaking implements IMessage, IMessageHandler<Packe
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiToggleBreaking message, MessageContext ctx) {
|
||||
public IMessage onMessage(PacketLokiClear message, MessageContext ctx) {
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(player);
|
||||
if (aRing != null) {
|
||||
boolean ringState = !ItemLokiRing.isRingBreakingEnabled(aRing);
|
||||
ItemLokiRing.setBreakingMode(aRing, ringState);
|
||||
PacketLokiToggleBreakingAck ackMessage = new PacketLokiToggleBreakingAck();
|
||||
ackMessage.state = ringState;
|
||||
ItemLokiRing.clearCursors(aRing);
|
||||
ItemLokiRing.clearMasterCursor(aRing);
|
||||
PacketLokiClearAck ackMessage = new PacketLokiClearAck();
|
||||
PacketHandler.INSTANCE.sendTo(ackMessage, player);
|
||||
}
|
||||
return null;
|
||||
@@ -0,0 +1,39 @@
|
||||
package vazkii.botania.common.network;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import vazkii.botania.common.item.relic.ItemLokiRing;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class PacketLokiClearAck implements IMessage, IMessageHandler<PacketLokiClearAck, IMessage> {
|
||||
|
||||
public boolean state;
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf byteBuf) {
|
||||
state = byteBuf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf byteBuf) {
|
||||
byteBuf.writeBoolean(state);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public IMessage onMessage(PacketLokiClearAck message, MessageContext ctx) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(mc.thePlayer) ;
|
||||
if (aRing != null) {
|
||||
ItemLokiRing.renderHUDNotification(ItemLokiRing.HUD_MESSAGE.CLEAR);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -25,12 +25,22 @@ public class PacketLokiToggle implements IMessage, IMessageHandler<PacketLokiTog
|
||||
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
||||
final ItemStack aRing = ItemLokiRing.getLokiRing(player);
|
||||
if (aRing != null) {
|
||||
boolean ringState = !ItemLokiRing.isRingEnabled(aRing);
|
||||
ItemLokiRing.setMode(aRing, ringState);
|
||||
PacketLokiToggleAck ackMessage = new PacketLokiToggleAck();
|
||||
ackMessage.state = ringState;
|
||||
PacketHandler.INSTANCE.sendTo(ackMessage, player);
|
||||
if(player.isSneaking()){
|
||||
boolean ringState = !ItemLokiRing.isRingBreakingEnabled(aRing);
|
||||
ItemLokiRing.setBreakingMode(aRing, ringState);
|
||||
PacketLokiToggleBreakingAck ackMessage = new PacketLokiToggleBreakingAck();
|
||||
ackMessage.state = ringState;
|
||||
PacketHandler.INSTANCE.sendTo(ackMessage, player);
|
||||
}
|
||||
else
|
||||
{
|
||||
boolean ringState = !ItemLokiRing.isRingEnabled(aRing);
|
||||
ItemLokiRing.setMode(aRing, ringState);
|
||||
PacketLokiToggleAck ackMessage = new PacketLokiToggleAck();
|
||||
ackMessage.state = ringState;
|
||||
PacketHandler.INSTANCE.sendTo(ackMessage, player);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -155,11 +155,20 @@ botaniamisc.altarRefill1=add back the last recipe
|
||||
botaniamisc.santaweaveInfo=Manaweave, changed up for the &cs&fe&ca&fs&co&fn
|
||||
botaniamisc.enterToView=^ Press ENTER to view ^
|
||||
botaniamisc.keyCategory=Botania
|
||||
botaniamisc.toggleLoki=Toggle Ring of Loki
|
||||
botaniamisc.toggleLokiBreaking=Toggle Ring of Loki Breaking
|
||||
|
||||
#LOKI
|
||||
botaniamisc.toggleLoki=Ring of Loki Switch Key
|
||||
botaniamisc.ringOfLokiClear=Clear Ring of Loki Selection
|
||||
botaniamisc.lokiOn=On
|
||||
botaniamisc.lokiOff=Off
|
||||
botaniamisc.breaking=Breaking
|
||||
botaniamisc.lokiClear=Successfully cleared all selection
|
||||
botaniamisc.lokiDescription=Builder's wand but §c§oC§6§oo§e§oo§a§ol§9§oe§5§or
|
||||
botaniamisc.lokiDescription2=Can Place/Interact/Break with multiple blocks at once!
|
||||
botaniamisc.lokiToggleDescription=Mode Switch Key to turn ring
|
||||
botaniamisc.lokiBreakingDescription=Mode Switch Key + Shift to toggle breaking
|
||||
botaniamisc.lokiCurrent=Current
|
||||
botaniamisc.lokiState=Ring
|
||||
|
||||
# NEI INTEGRATION
|
||||
botania.nei.brewery=Botanical Brewery
|
||||
@@ -1621,6 +1630,7 @@ item.botania:cosmetic31.name=Questgiver Mark
|
||||
item.botania:manaString.name=Mana Infused String
|
||||
item.botania:swapRing.name=Ring of Correction
|
||||
item.botania:flowerBag.name=Flower Pouch
|
||||
item.botania:shroomBag.name=Mushroom Pouch
|
||||
item.botania:phantomInk.name=Phantom Ink
|
||||
item.botania:poolMinecart.name=Minecart with Mana Pool
|
||||
item.botania:pinkinator.name=The Pinkinator
|
||||
@@ -2112,6 +2122,12 @@ botania.page.flowerBag0=The laws of physics regarding one's &4Inventory&0 are so
|
||||
botania.page.flowerBag2=Items won't be added automatically to the pouch if that's the item being held.<br>Furthermore, shift-right clicking the pouch into a &1Chest&0 or other inventory will store the flowers it contains into said inventory.
|
||||
botania.page.flowerBag1=Pull a copter out of it (any colors work)
|
||||
|
||||
# -- MUSHROOM POUCH
|
||||
botania.entry.shroomBag=Mushroom Pouch
|
||||
botania.tagline.shroomBag=A trusty pouch to hold your mushroom goodness
|
||||
botania.page.shroomBag0=Similar to the &1Flower Pouch&0, the mushroom pouch will hold all of those pesky &1Mystical Mushrooms&0 that have been clogging up your inventory.<br>Remember the bag will not pick up items if you are holding it in your hand.<br>Furthermore, shift-right clicking the pouch into a &1Chest&0 or other inventory will store the flowers it contains into said inventory.
|
||||
botania.page.shroomBag1=Any colors work
|
||||
|
||||
# -- WRAP
|
||||
botania.entry.wrap=Wrap
|
||||
botania.tagline.wrap=It's a wrap
|
||||
|
||||
@@ -156,10 +156,11 @@ botaniamisc.santaweaveInfo=Манаткань изменилась из-за &c
|
||||
botaniamisc.enterToView=^ Нажмите ENTER для просмотра ^
|
||||
botaniamisc.keyCategory=Botania
|
||||
botaniamisc.toggleLoki=Переключение режимов Кольца Локи
|
||||
botaniamisc.toggleLokiBreaking=Переключение режимов ломания Кольца Локи
|
||||
botaniamisc.ringOfLokiClear=Очистить выделения для кольца локи
|
||||
botaniamisc.lokiOn=Вкл.
|
||||
botaniamisc.lokiOff=Выкл.
|
||||
botaniamisc.breaking=Ломание
|
||||
botaniamisc.lokiClear=Успешно удален все выделения
|
||||
|
||||
# NEI INTEGRATION
|
||||
botania.nei.brewery=Ботаническая зельеварка
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 506 B |
Reference in new issue
Block a user