Fix syncing of everything
This commit is contained in:
@@ -2,9 +2,11 @@ package electroblob.wizardry.client;
|
||||
|
||||
import electroblob.wizardry.CommonProxy;
|
||||
import electroblob.wizardry.Wizardry;
|
||||
import electroblob.wizardry.block.BlockBookshelf;
|
||||
import electroblob.wizardry.client.audio.MovingSoundEntity;
|
||||
import electroblob.wizardry.client.audio.SoundLoop;
|
||||
import electroblob.wizardry.client.audio.SoundLoopSpell;
|
||||
import electroblob.wizardry.client.gui.GuiLectern;
|
||||
import electroblob.wizardry.client.gui.GuiSpellDisplay;
|
||||
import electroblob.wizardry.client.gui.config.NamedBooleanEntry;
|
||||
import electroblob.wizardry.client.gui.config.SpellHUDSkinChooserEntry;
|
||||
@@ -202,6 +204,20 @@ public class ClientProxy extends CommonProxy {
|
||||
return GuiSpellDisplay.getSkinKeys();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyBookshelfChange(World world, BlockPos pos){
|
||||
|
||||
super.notifyBookshelfChange(world, pos);
|
||||
|
||||
EntityPlayer player = Minecraft.getMinecraft().player;
|
||||
|
||||
if(player.getDistanceSq(pos) < BlockBookshelf.PLAYER_NOTIFY_RANGE * BlockBookshelf.PLAYER_NOTIFY_RANGE){
|
||||
if(Minecraft.getMinecraft().currentScreen instanceof GuiLectern){
|
||||
((GuiLectern)Minecraft.getMinecraft().currentScreen).refreshAvailableSpells();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// SECTION Items
|
||||
// ===============================================================================================================
|
||||
|
||||
|
||||
@@ -127,8 +127,6 @@ public class GuiLectern extends GuiSpellInfo implements ISpellSortable {
|
||||
|
||||
super.initGui();
|
||||
|
||||
updateAvailableSpells();
|
||||
|
||||
final int left = this.width / 2 - this.xSize / 2;
|
||||
final int top = this.height / 2 - this.ySize / 2;
|
||||
|
||||
@@ -181,8 +179,7 @@ public class GuiLectern extends GuiSpellInfo implements ISpellSortable {
|
||||
this.searchField.setCanLoseFocus(false);
|
||||
this.searchField.setFocused(true);
|
||||
|
||||
updateMatchingSpells();
|
||||
updateButtonVisiblity();
|
||||
refreshAvailableSpells(); // Must be done last
|
||||
|
||||
}
|
||||
|
||||
@@ -383,9 +380,9 @@ public class GuiLectern extends GuiSpellInfo implements ISpellSortable {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// TODO: Call this when a bookshelf is added or removed
|
||||
// TODO: Config option to always display all spells when in creative
|
||||
private void updateAvailableSpells(){
|
||||
/** Called on initialisation and whenever a bookshelf is added or removed, to update the list of spells. */
|
||||
public void refreshAvailableSpells(){
|
||||
|
||||
availableSpells.clear();
|
||||
|
||||
@@ -405,6 +402,9 @@ public class GuiLectern extends GuiSpellInfo implements ISpellSortable {
|
||||
|
||||
if(!availableSpells.contains(currentSpell)) currentSpell = Spells.none; // TODO: Do we want this?
|
||||
|
||||
updateMatchingSpells();
|
||||
updateButtonVisiblity();
|
||||
|
||||
}
|
||||
|
||||
private class GuiButtonLocateBook extends GuiButton {
|
||||
|
||||
@@ -36,7 +36,9 @@ public class BakedModelBookshelf implements IBakedModel {
|
||||
IExtendedBlockState extendedState = (IExtendedBlockState)state;
|
||||
|
||||
for(int i = 0; i<BlockBookshelf.SLOT_COUNT; i++){
|
||||
if(extendedState.getValue(BlockBookshelf.BOOKS[i])) quads.addAll(books[i].getQuads(state, side, rand));
|
||||
Boolean value = extendedState.getValue(BlockBookshelf.BOOKS[i]);
|
||||
if(value == null) return fallback.getQuads(null, side, rand);
|
||||
if(value) quads.addAll(books[i].getQuads(state, side, rand));
|
||||
}
|
||||
|
||||
return quads;
|
||||
|
||||
Reference in New Issue
Block a user