Merge branch '1.12.2' into 4.3-dev

This commit is contained in:
Electroblob77
2020-04-14 17:41:33 +01:00
32 changed files with 869 additions and 1313 deletions
@@ -250,6 +250,13 @@ public class CommonProxy {
* @param intensity The amplitude of the shaking (around 10 looks about right)
*/
public void shakeScreen(EntityPlayer player, float intensity){}
/**
* Loads the given shader for the given player, if they have shaders enabled.
* @param player The player to load the shader for
* @param shader The location of the shader to load
*/
public void loadShader(EntityPlayer player, ResourceLocation shader){}
/**
* Gets the client side world using Minecraft.getMinecraft().world. <b>Only to be called client side!</b> Returns
@@ -321,6 +321,10 @@ public final class Settings {
public boolean booksPauseGame = true;
/** <b>[Client-only]</b> Whether to use custom shaders for certain spells. */
public boolean useShaders = true;
/** <b>[Client-only]</b> Whether to use the screen shake effect for certain spells. */
public boolean screenShake = true;
/** <b>[Client-only]</b> Whether to use the screen blink effect for teleportation spells. */
public boolean blinkEffect = true;
/** <b>[Client-only]</b> The position of the spell HUD. */
public GuiPosition spellHUDPosition = GuiPosition.BOTTOM_LEFT;
@@ -939,6 +943,18 @@ public final class Settings {
useShaders = property.getBoolean();
propOrder.add(property.getName());
property = config.get(CLIENT_CATEGORY, "screenShake", true, "Whether to use the screen shake effect for certain spells.");
property.setLanguageKey("config." + Wizardry.MODID + ".screen_shake");
Wizardry.proxy.setToNamedBooleanEntry(property);
screenShake = property.getBoolean();
propOrder.add(property.getName());
property = config.get(CLIENT_CATEGORY, "blinkEffect", true, "Whether to use the screen blink effect for teleportation spells.");
property.setLanguageKey("config." + Wizardry.MODID + ".blink_effect");
Wizardry.proxy.setToNamedBooleanEntry(property);
blinkEffect = property.getBoolean();
propOrder.add(property.getName());
config.setCategoryPropertyOrder(CLIENT_CATEGORY, propOrder);
}
@@ -107,7 +107,9 @@ public class BlockPedestal extends Block implements ITileEntityProvider {
natural = true;
metadata -= ELEMENT.getAllowedValues().size();
}
return this.getDefaultState().withProperty(ELEMENT, Element.values()[metadata]).withProperty(NATURAL, natural);
Element element = Element.values()[metadata];
if(!ELEMENT.getAllowedValues().contains(element)) return this.getDefaultState().withProperty(NATURAL, natural);
return this.getDefaultState().withProperty(ELEMENT, element).withProperty(NATURAL, natural);
}
@Override
@@ -69,7 +69,9 @@ public class BlockRunestone extends Block {
@Override
public IBlockState getStateFromMeta(int metadata){
return this.getDefaultState().withProperty(ELEMENT, Element.values()[metadata]);
Element element = Element.values()[metadata];
if(!ELEMENT.getAllowedValues().contains(element)) return this.getDefaultState();
return this.getDefaultState().withProperty(ELEMENT, element);
}
@Override
@@ -199,6 +199,13 @@ public class ClientProxy extends CommonProxy {
if(Minecraft.getMinecraft().player == player) WizardryClientEventHandler.shakeScreen(intensity);
}
@Override
public void loadShader(EntityPlayer player, ResourceLocation shader){
if(Minecraft.getMinecraft().player == player && Wizardry.settings.useShaders
&& !Minecraft.getMinecraft().entityRenderer.isShaderActive())
Minecraft.getMinecraft().entityRenderer.loadShader(shader);
}
@Override
public Set<String> getSpellHUDSkins(){
return GuiSpellDisplay.getSkinKeys();
@@ -568,6 +575,12 @@ public class ClientProxy extends CommonProxy {
data.randomDescriptions = new HashMap<>();
for(Spell spell : Spell.getAllSpells()){
if(spell.networkID() > message.names.size()){
Wizardry.logger.warn("Received no glyph data for spell {}, skipping", spell.getRegistryName());
continue;
}
// -1 because the none spell isn't included
// This is a case where we must use the network ID, not the metadata
data.randomNames.put(spell, message.names.get(spell.networkID() - 1));
@@ -91,13 +91,15 @@ public final class WizardryClientEventHandler {
/** Starts the first-person blink overlay effect. */
public static void playBlinkEffect(){
blinkEffectTimer = BLINK_EFFECT_DURATION;
if(Wizardry.settings.blinkEffect) blinkEffectTimer = BLINK_EFFECT_DURATION;
}
/** Starts the client-side screen shake effect. */
public static void shakeScreen(float intensity){
screenShakeCounter = (int)(intensity / SHAKINESS);
Minecraft.getMinecraft().player.rotationPitch -= intensity * 0.5f; // Start halfway down
if(Wizardry.settings.screenShake){
screenShakeCounter = (int)(intensity / SHAKINESS);
Minecraft.getMinecraft().player.rotationPitch -= intensity * 0.5f; // Start halfway down
}
}
@SubscribeEvent
@@ -105,12 +107,20 @@ public final class WizardryClientEventHandler {
if(event.player == Minecraft.getMinecraft().player && event.phase == TickEvent.Phase.END){
if(blinkEffectTimer > 0) blinkEffectTimer--;
if(Wizardry.settings.blinkEffect){
if(blinkEffectTimer > 0) blinkEffectTimer--;
}else{
blinkEffectTimer = 0;
}
if(screenShakeCounter > 0){
float magnitude = screenShakeCounter * SHAKINESS;
Minecraft.getMinecraft().player.rotationPitch += screenShakeCounter % 2 == 0 ? magnitude : -magnitude;
screenShakeCounter--;
if(Wizardry.settings.screenShake){
if(screenShakeCounter > 0){
float magnitude = screenShakeCounter * SHAKINESS;
Minecraft.getMinecraft().player.rotationPitch += screenShakeCounter % 2 == 0 ? magnitude : -magnitude;
screenShakeCounter--;
}
}else{
screenShakeCounter = 0;
}
// Only seems to work here...
@@ -20,9 +20,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.relauncher.Side;
import org.lwjgl.opengl.GL11;
import java.util.ArrayList;
import java.util.List;
@Mod.EventBusSubscriber(Side.CLIENT)
public class RenderArcaneLock {
@@ -39,36 +36,44 @@ public class RenderArcaneLock {
EntityPlayer player = Minecraft.getMinecraft().player;
World world = Minecraft.getMinecraft().world;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
boolean lighting = GL11.glIsEnabled(GL11.GL_LIGHTING);
GlStateManager.disableLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
Vec3d origin = player.getPositionEyes(event.getPartialTicks());
GlStateManager.translate(-origin.x, -origin.y + player.getEyeHeight(), -origin.z);
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[(player.ticksExisted % (TEXTURES.length * 2))/2]);
Tessellator tessellator = Tessellator.getInstance();
BufferBuilder buffer = tessellator.getBuffer();
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
// Someone managed to get a CME here so let's just copy the list to be safe
boolean flag = false;
boolean lighting = false;
// Someone managed to get a CME here so let's iterate manually to be safe (don't copy the list, it's expensive!)
// It's only cosmetic so if a tileentity somehow gets removed while we're rendering them it's not a big deal
List<TileEntity> tileentities = new ArrayList<>(world.loadedTileEntityList);
for(int i=0; i<world.loadedTileEntityList.size(); i++){
TileEntity tileentity = world.loadedTileEntityList.get(i);
for(TileEntity tileentity : tileentities){
if(tileentity == null) continue; // What the heck VoxelMap
if(tileentity.getDistanceSq(origin.x, origin.y, origin.z) <= tileentity.getMaxRenderDistanceSquared()
&& tileentity.getTileData().hasUniqueId(ArcaneLock.NBT_KEY)){
if(!flag){
flag = true;
GlStateManager.pushMatrix();
GlStateManager.enableBlend();
lighting = GL11.glIsEnabled(GL11.GL_LIGHTING);
GlStateManager.disableLighting();
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240, 240);
GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GlStateManager.translate(-origin.x, -origin.y + player.getEyeHeight(), -origin.z);
GlStateManager.color(1, 1, 1, 1);
Minecraft.getMinecraft().renderEngine.bindTexture(TEXTURES[(player.ticksExisted % (TEXTURES.length * 2))/2]);
buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);
}
Vec3d[] vertices = WizardryUtilities.getVertices(world.getBlockState(tileentity.getPos()).getBoundingBox(world, tileentity.getPos()).grow(0.05).offset(tileentity.getPos()));
drawFace(buffer, vertices[0], vertices[1], vertices[3], vertices[2], 0, 0, 1, 1); // Bottom
@@ -81,15 +86,19 @@ public class RenderArcaneLock {
}
}
tessellator.draw();
if(flag){
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
if (lighting) {
GlStateManager.enableLighting();
tessellator.draw();
GlStateManager.disableBlend();
GlStateManager.enableTexture2D();
if(lighting){
GlStateManager.enableLighting();
}
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
GlStateManager.disableRescaleNormal();
GlStateManager.popMatrix();
}
private static void drawFace(BufferBuilder buffer, Vec3d topLeft, Vec3d topRight, Vec3d bottomLeft, Vec3d bottomRight, float u1, float v1, float u2, float v2){
@@ -120,8 +120,10 @@ public class EntityMagicSlime extends EntitySlime implements ISummonedCreature {
&& ((EntityLivingBase)this.getRidingEntity()).getHealth() > 0){
if(this.ticksExisted % 16 == 1){
this.getRidingEntity().attackEntityFrom(DamageSource.MAGIC, 1);
((EntityLivingBase)this.getRidingEntity())
.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 2));
if(this.getRidingEntity() != null){ // Some mobs force-dismount when attacked (normally when dying)
((EntityLivingBase)this.getRidingEntity())
.addPotionEffect(new PotionEffect(MobEffects.SLOWNESS, 20, 2));
}
this.playSound(WizardrySounds.ENTITY_MAGIC_SLIME_ATTACK, 1.0f, 1.0f);
this.squishAmount = 0.5F;
}
@@ -13,6 +13,8 @@ import electroblob.wizardry.registry.WizardryRecipes;
import electroblob.wizardry.registry.WizardryTabs;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentMending;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
@@ -194,7 +196,13 @@ public class ItemWizardArmour extends ItemArmor implements IWorkbenchItem, IMana
public boolean getIsRepairable(ItemStack stack, ItemStack material){
return false;
}
// This is misleadingly-named, it also applies to enchanting with books at an anvil
@Override
public boolean canApplyAtEnchantingTable(ItemStack stack, Enchantment enchantment){
return !(enchantment instanceof EnchantmentMending) && super.canApplyAtEnchantingTable(stack, enchantment);
}
/**
* Properly handles the defence value of the armour. This method is responsible for the tooltip on top of
* the armour value. It is also what handles armour toughness.
@@ -172,9 +172,9 @@ public class PotionSlowTime extends PotionMagicEffect implements ISyncedPotion {
@SubscribeEvent
public static void onPotionAddedEvent(PotionEvent.PotionAddedEvent event){
if(event.getEntity().world.isRemote && event.getPotionEffect().getPotion() == WizardryPotions.slow_time
&& event.getEntity() == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SlowTime.SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
&& event.getEntity() instanceof EntityPlayer){
Wizardry.proxy.loadShader((EntityPlayer)event.getEntity(), SlowTime.SHADER);
Wizardry.proxy.playBlinkEffect((EntityPlayer)event.getEntity());
}
}
@@ -67,6 +67,9 @@ public final class WizardryLoot {
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/wizard_armour"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/arcane_tomes"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/wand_upgrades"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/uncommon_artefacts"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/rare_artefacts"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "subsets/epic_artefacts"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/evil_wizard"));
LootTableList.register(new ResourceLocation(Wizardry.MODID, "entities/mob_additions"));
@@ -91,9 +91,6 @@ public class Divination extends Spell {
(float)(target.getY() + 0.5 - (caster.getEntityBoundingBox().minY + caster.getEyeHeight())),
(float)(target.getZ() + 0.5 - caster.posZ));
if(world.isRemote) ParticleBuilder.create(ParticleBuilder.Type.SPARKLE).pos(target.getX() + 0.5,
target.getY() + 1.5, target.getZ() + 0.5).spawn(world);
strength = Strength.forWeight(calculateWeight(world, caster, target, range, modifiers));
}
@@ -210,6 +210,8 @@ public class Grapple extends Spell {
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
if(target == null) return false;
Vec3d origin = new Vec3d(caster.posX, caster.getEntityBoundingBox().minY + caster.getEyeHeight(), caster.posZ);
// If the target is an entity, we need to use the entity's centre rather than the original hit position
@@ -212,6 +212,7 @@ public class Possession extends SpellRay {
possessor.eyeHeight = target.getEyeHeight();
setSize(possessor, target.width, target.height);
target.dismountRidingEntity();
target.setDead();
target.setNoAI(true);
target.setAttackTarget(null);
@@ -251,10 +252,10 @@ public class Possession extends SpellRay {
}
}
if(possessor.world.isRemote && possessor == net.minecraft.client.Minecraft.getMinecraft().player){
if(possessor.world.isRemote){
// Shaders and effects
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect(); // Looks quite nice...
Wizardry.proxy.loadShader(possessor, SHADER);
Wizardry.proxy.playBlinkEffect(possessor);
}else{
@@ -348,7 +349,7 @@ public class Possession extends SpellRay {
if(player.world.isRemote && player == net.minecraft.client.Minecraft.getMinecraft().player){
net.minecraft.client.Minecraft.getMinecraft().entityRenderer.stopUseShader();
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect(); // Looks quite nice...
Wizardry.proxy.playBlinkEffect(player);
}
for(IAttribute attribute : INHERITED_ATTRIBUTES.keySet()){
@@ -399,9 +400,7 @@ public class Possession extends SpellRay {
if(player.world.isRemote){
ParticleBuilder.create(Type.DARK_MAGIC, player).clr(0.1f, 0, 0.3f).spawn(player.world);
// TODO: This (and a few other similar uses) needs ClientProxy-ing.
if(!net.minecraft.client.Minecraft.getMinecraft().entityRenderer.isShaderActive())
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
Wizardry.proxy.loadShader(player, SHADER);
}
}else{
@@ -39,9 +39,9 @@ public class SixthSense extends Spell {
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)),
(int)((modifiers.get(WizardryItems.range_upgrade) - 1f) / Constants.RANGE_INCREASE_PER_LEVEL)));
if(world.isRemote && caster == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
if(world.isRemote){
Wizardry.proxy.loadShader(caster, SHADER);
Wizardry.proxy.playBlinkEffect(caster);
}
this.playSound(world, caster, ticksInUse, -1, modifiers);
@@ -51,9 +51,9 @@ public class SixthSense extends Spell {
@SubscribeEvent
public static void onPotionAddedEvent(PotionEvent.PotionAddedEvent event){
if(event.getEntity().world.isRemote && event.getPotionEffect().getPotion() == WizardryPotions.sixth_sense
&& event.getEntity() == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
&& event.getEntity() instanceof EntityPlayer){
Wizardry.proxy.loadShader((EntityPlayer)event.getEntity(), SHADER);
Wizardry.proxy.playBlinkEffect((EntityPlayer)event.getEntity());
}
}
@@ -24,8 +24,8 @@ public class SlowTime extends SpellBuff {
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(caster.world.isRemote && caster == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
if(caster.world.isRemote){
Wizardry.proxy.loadShader(caster, SHADER);
}
return super.cast(world, caster, hand, ticksInUse, modifiers);
@@ -38,9 +38,9 @@ public class Transience extends Spell {
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
if(world.isRemote && caster == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
if(world.isRemote){
Wizardry.proxy.loadShader(caster, SHADER);
Wizardry.proxy.playBlinkEffect(caster);
}
if(!caster.isPotionActive(WizardryPotions.transience)){
@@ -87,9 +87,9 @@ public class Transience extends Spell {
@SubscribeEvent
public static void onPotionAddedEvent(PotionEvent.PotionAddedEvent event){
if(event.getEntity().world.isRemote && event.getPotionEffect().getPotion() == WizardryPotions.transience
&& event.getEntity() == net.minecraft.client.Minecraft.getMinecraft().player){
if(Wizardry.settings.useShaders) net.minecraft.client.Minecraft.getMinecraft().entityRenderer.loadShader(SHADER);
electroblob.wizardry.client.WizardryClientEventHandler.playBlinkEffect();
&& event.getEntity() instanceof EntityPlayer){
Wizardry.proxy.loadShader((EntityPlayer)event.getEntity(), SHADER);
Wizardry.proxy.playBlinkEffect((EntityPlayer)event.getEntity());
}
}
@@ -636,7 +636,7 @@ public final class WizardryUtilities {
// This is a perfect example of where you need to use .equals() and not ==. For most applications,
// this was unnoticeable until world reload because the UUID instance or entity instance is stored.
// Fixed now though.
if(entity.getUniqueID().equals(id)){
if(entity != null && entity.getUniqueID() != null && entity.getUniqueID().equals(id)){
return entity;
}
}