Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'forge'

version = " 1.1.5 - MC 1.7.10"
version = " 1.1.6-LE - MC 1.7.10"
group = "electroblob.wizardry"// http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "Electroblob's Wizardry "

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/electroblob/wizardry/MagicDamage.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ public class MagicDamage extends EntityDamageSource implements IElementalDamage
* references get changed automatically. */
public static final String INDIRECT_MAGIC_DAMAGE = "indirectWizardryMagic";
// Technically, I don't need to specify that the classes in this map must extend entity, but it's good practice to.

public static final String REFLECTIVE_MAGIC_DAMAGE = "reflectiveWizardryMagic";

private static final Map<Class<? extends Entity>, DamageType[]> immunityMapping = new HashMap<Class<? extends Entity>, DamageType[]>();

private final DamageType type;
Expand Down Expand Up @@ -208,6 +211,11 @@ public static DamageSource causeIndirectEntityMagicDamage(Entity magic, EntityLi
return new IndirectMagicDamage(INDIRECT_MAGIC_DAMAGE, magic, caster, type);
}

public static DamageSource causeReflectiveMagicDamage(EntityLivingBase caster, DamageType type)
{
return new MagicDamage(REFLECTIVE_MAGIC_DAMAGE, caster, type);
}

@Override
public DamageType getType(){
return type;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/electroblob/wizardry/Wizardry.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,12 @@ public class Wizardry {
public static int[] flowerDimensions = {0};
/** List of dimension ids in which to generate crystal ore. */
public static int[] towerDimensions = {0};
/** List of dimension ids in which evil wizards can spawn. */
public static int[] evilWizardDimensions = {0};
/** Chance (out of 200) for mobs to drop spell books. */

/**Should flowers generate on bonemeal */
public static boolean bonemealMagicalFlower = true;
public static int spellBookDropChance = 3;
/** Whether or not wizardry loot should generate in dungeon chests. */
public static boolean generateLoot = true;
Expand Down Expand Up @@ -755,6 +760,18 @@ private static void setupGeneralConfig(){
towerDimensions = property.getIntList();
propOrder.add(property.getName());

property = config.get(config.CATEGORY_GENERAL, "evilWizardDimensions", evilWizardDimensions, "List of dimension ids in which evil wizards can spawn.");
property.setLanguageKey("config.evil_Wizard_Dimensions");
property.setRequiresWorldRestart(true);
evilWizardDimensions = property.getIntList();
propOrder.add(property.getName());

property = config.get(config.CATEGORY_GENERAL, "bonemealMagicalFlower", true, "Whether Magical Flowers spawn with bonemeal.");
property.setLanguageKey("config.bonemealMagicalFlower");
property.setRequiresWorldRestart(true);
bonemealMagicalFlower = property.getBoolean();
propOrder.add(property.getName());

property = config.get(config.CATEGORY_GENERAL, "generateLoot", true, "Whether to generate wizardry loot in dungeon chests.");
property.setLanguageKey("config.generate_loot");
property.setRequiresWorldRestart(true);
Expand Down
64 changes: 38 additions & 26 deletions src/main/java/electroblob/wizardry/WizardryEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
Expand Down Expand Up @@ -154,7 +155,7 @@ public void onLivingAttackEvent(LivingAttackEvent event){
return;
}

if(event.source != null && event.source.getEntity() instanceof EntityLivingBase){
if(event.source != null && !Objects.equals(event.source.damageType, MagicDamage.REFLECTIVE_MAGIC_DAMAGE) && event.source.getEntity() instanceof EntityLivingBase){

// Cancels the mind trick effect if the creature takes damage
// This has been moved to within the (event.source.getEntity() instanceof EntityLivingBase) check so it doesn't
Expand Down Expand Up @@ -193,7 +194,7 @@ public void onLivingAttackEvent(LivingAttackEvent event){
}
}

attacker.attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.entityLiving, DamageType.SHOCK), 4.0f);
attacker.attackEntityFrom(MagicDamage.causeReflectiveMagicDamage(event.entityLiving, DamageType.SHOCK), 4.0f);
world.playSoundAtEntity(attacker, "wizardry:arc", 1.0F, world.rand.nextFloat() * 0.4F + 1.5F);
}

Expand Down Expand Up @@ -798,20 +799,31 @@ public void onEntityJoinWorld(EntityJoinWorldEvent event){

}

public boolean hasValidWand(final EntityPlayer player) {
for (int i = 0; i < 9; ++i) {
final ItemStack stack = player.inventory.mainInventory[i];
if (stack != null && stack.getItem() instanceof ItemWand) {
return true;
}
}
return false;
}

@SubscribeEvent
public void onLivingDropsEvent(LivingDropsEvent event){
// Evil wizards drop spell books themselves
if(event.entityLiving instanceof EntityMob && !(event.entityLiving instanceof EntityEvilWizard) && event.source.getEntity() instanceof EntityPlayer && !(event.source.getEntity() instanceof FakePlayer) && Wizardry.spellBookDropChance > 0){

// This does exactly what the entity drop method does, but with a different random number so that the
// spell book doesn't always drop with other rare drops.
int rareDropNumber = event.entity.worldObj.rand.nextInt(200) - event.lootingLevel;
if(rareDropNumber < Wizardry.spellBookDropChance){
// Drops a spell book
int id = WizardryUtilities.getStandardWeightedRandomSpellId(event.entity.worldObj.rand);

event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ,
new ItemStack(Wizardry.spellBook, 1, id)));
if (hasValidWand((EntityPlayer) event.source.getEntity())) {
// This does exactly what the entity drop method does, but with a different random number so that the
// spell book doesn't always drop with other rare drops.
int rareDropNumber = event.entity.worldObj.rand.nextInt(200) - event.lootingLevel;
if (rareDropNumber < Wizardry.spellBookDropChance) {
// Drops a spell book
int id = WizardryUtilities.getStandardWeightedRandomSpellId(event.entity.worldObj.rand);

event.drops.add(new EntityItem(event.entityLiving.worldObj, event.entityLiving.posX, event.entityLiving.posY, event.entityLiving.posZ,
new ItemStack(Wizardry.spellBook, 1, id)));
}
}
}

Expand Down Expand Up @@ -955,19 +967,19 @@ public void onPlayerInteractEvent(PlayerInteractEvent event){
}
}

@SubscribeEvent
public void onBonemealEvent(BonemealEvent event){
// Grows crystal flowers when bonemeal is used on grass
if(event.block == Blocks.grass){
@SubscribeEvent
public void onBonemealEvent(BonemealEvent event){
// Grows crystal flowers when bonemeal is used on grass
if(Wizardry.bonemealMagicalFlower && event.block == Blocks.grass){

int x = event.x + event.world.rand.nextInt(8) - event.world.rand.nextInt(8);
int y = event.y + event.world.rand.nextInt(4) - event.world.rand.nextInt(4);
int z = event.z + event.world.rand.nextInt(8) - event.world.rand.nextInt(8);

if (event.world.isAirBlock(x, y, z) && (!event.world.provider.hasNoSky || y < 127) && Wizardry.crystalFlower.canBlockStay(event.world, x, y, z))
{
event.world.setBlock(x, y, z, Wizardry.crystalFlower, 0, 2);
}
}
}
int x = event.x + event.world.rand.nextInt(8) - event.world.rand.nextInt(8);
int y = event.y + event.world.rand.nextInt(4) - event.world.rand.nextInt(4);
int z = event.z + event.world.rand.nextInt(8) - event.world.rand.nextInt(8);

if (event.world.isAirBlock(x, y, z) && (!event.world.provider.hasNoSky || y < 127) && Wizardry.crystalFlower.canBlockStay(event.world, x, y, z))
{
event.world.setBlock(x, y, z, Wizardry.crystalFlower, 0, 2);
}
}
}
}
15 changes: 9 additions & 6 deletions src/main/java/electroblob/wizardry/WizardryUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,15 @@ public static MovingObjectPosition rayTrace(double range, World world, EntityLiv
* @return
*/
public static MovingObjectPosition standardEntityRayTrace(World world, EntityLivingBase entity, double range){
double dx = entity.getLookVec().xCoord * range;
double dy = entity.getLookVec().yCoord * range;
double dz = entity.getLookVec().zCoord * range;
HashSet hashset = new HashSet(1);
hashset.add(entity);
return WizardryUtilities.tracePath(world, (float)entity.posX, (float)(entity.posY + entity.getEyeHeight()), (float)entity.posZ, (float)(entity.posX + dx), (float)(entity.posY + entity.getEyeHeight() + dy), (float)(entity.posZ + dz), 1.0f, hashset, false);
if (world != null) {
double dx = entity.getLookVec().xCoord * range;
double dy = entity.getLookVec().yCoord * range;
double dz = entity.getLookVec().zCoord * range;
HashSet hashset = new HashSet(1);
hashset.add(entity);
return WizardryUtilities.tracePath(world, (float) entity.posX, (float) (entity.posY + entity.getEyeHeight()), (float) entity.posZ, (float) (entity.posX + dx), (float) (entity.posY + entity.getEyeHeight() + dy), (float) (entity.posZ + dz), 1.0f, hashset, false);
}
return null;
}

/**
Expand Down
50 changes: 26 additions & 24 deletions src/main/java/electroblob/wizardry/client/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,30 +349,32 @@ public void handleTransportationPacket(PacketTransportation.Message message){

World world = Minecraft.getMinecraft().theWorld;
Entity caster = world.getEntityByID(message.casterID);

for(int i=0; i<20; i++){
double radius = 1;
double angle = world.rand.nextDouble()*Math.PI*2;
double x = caster.posX + radius*Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble()*2;
double z = caster.posZ + radius*Math.sin(angle);
Minecraft.getMinecraft().effectRenderer.addEffect(new EntitySparkleFX(world, x, y, z, 0, 0.02, 0, 0.6f, 1.0f, 0.6f, 80 + world.rand.nextInt(10)));
}
for(int i=0; i<20; i++){
double radius = 1;
double angle = world.rand.nextDouble()*Math.PI*2;
double x = caster.posX + radius*Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble()*2;
double z = caster.posZ + radius*Math.sin(angle);
world.spawnParticle("happyVillager", x, y, z, 0, 0.02, 0);
}
for(int i=0; i<20; i++){
double radius = 1;
double angle = world.rand.nextDouble()*Math.PI*2;
double x = caster.posX + radius*Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble()*2;
double z = caster.posZ + radius*Math.sin(angle);
world.spawnParticle("enchantmenttable", x, y, z, 0, 0.02, 0);

if (caster != null) {
for (int i = 0; i < 20; i++) {
double radius = 1;
double angle = world.rand.nextDouble() * Math.PI * 2;
double x = caster.posX + radius * Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * Math.sin(angle);
Minecraft.getMinecraft().effectRenderer.addEffect(new EntitySparkleFX(world, x, y, z, 0, 0.02, 0, 0.6f, 1.0f, 0.6f, 80 + world.rand.nextInt(10)));
}
for (int i = 0; i < 20; i++) {
double radius = 1;
double angle = world.rand.nextDouble() * Math.PI * 2;
double x = caster.posX + radius * Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * Math.sin(angle);
world.spawnParticle("happyVillager", x, y, z, 0, 0.02, 0);
}
for (int i = 0; i < 20; i++) {
double radius = 1;
double angle = world.rand.nextDouble() * Math.PI * 2;
double x = caster.posX + radius * Math.cos(angle);
double y = WizardryUtilities.getEntityFeetPos(caster) + world.rand.nextDouble() * 2;
double z = caster.posZ + radius * Math.sin(angle);
world.spawnParticle("enchantmenttable", x, y, z, 0, 0.02, 0);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import electroblob.wizardry.WandHelper;
import electroblob.wizardry.Wizardry;
import electroblob.wizardry.item.ItemWand;
import electroblob.wizardry.item.ItemWizardArmour;
import electroblob.wizardry.packet.PacketControlInput;
import electroblob.wizardry.packet.WizardryPacketHandler;
import electroblob.wizardry.spell.Spell;
Expand Down Expand Up @@ -418,7 +419,7 @@ public VisiblityData modifyVisiblity(GuiContainer gui, VisiblityData currentVisi

private boolean hasWand() {
return this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getHasStack()
&& this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand;
&& (this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWand || this.inventorySlots.getSlot(ContainerArcaneWorkbench.WAND_SLOT).getStack().getItem() instanceof ItemWizardArmour);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,14 @@ public void onRenderLivingEvent(RenderLivingEvent.Post event){
GL11.glPopMatrix();
}
*/

Minecraft mc = Minecraft.getMinecraft();
if (mc.theWorld == null) return;

ExtendedPlayer properties = ExtendedPlayer.get(mc.thePlayer);
MovingObjectPosition rayTrace = WizardryUtilities.standardEntityRayTrace(mc.theWorld, mc.thePlayer, 16);

// Target selection pointer
if(mc.thePlayer.isSneaking() && mc.thePlayer.getHeldItem() != null
if(mc.thePlayer != null && mc.thePlayer.isSneaking() && mc.thePlayer.getHeldItem() != null
&& mc.thePlayer.getHeldItem().getItem() instanceof ItemWand && rayTrace != null
&& rayTrace.entityHit instanceof EntityLivingBase && rayTrace.entityHit == event.entity
&& properties != null && properties.selectedMinion != null){
Expand Down Expand Up @@ -306,7 +307,7 @@ public void onRenderLivingEvent(RenderLivingEvent.Post event){
}

// Sixth sense
if(mc.thePlayer.isPotionActive(Wizardry.sixthSense) && event.entity != mc.thePlayer
if(mc.thePlayer != null && mc.thePlayer.isPotionActive(Wizardry.sixthSense) && event.entity != mc.thePlayer
&& mc.thePlayer.getActivePotionEffect(Wizardry.sixthSense) != null
&& event.entity.getDistanceToEntity(mc.thePlayer) < 20*(1+mc.thePlayer.getActivePotionEffect(Wizardry.sixthSense).getAmplifier()*Wizardry.RANGE_INCREASE_PER_LEVEL)){

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,5 +444,15 @@ public void writeSpawnData(ByteBuf data){
public void readSpawnData(ByteBuf data){
textureIndex = data.readInt();
}

@Override
public boolean getCanSpawnHere(){
// Evil wizards can only spawn in the specified dimensions
for(int id : Wizardry.evilWizardDimensions){
if(this.dimension == id) return super.getCanSpawnHere();
}

return false;
}

}
1 change: 1 addition & 0 deletions src/main/resources/assets/wizardry/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ key.previous_spell=Previous Spell

death.attack.wizardryMagic=%1$s was killed by %2$s using magic
death.attack.indirectWizardryMagic=%1$s was killed by %2$s using magic
death.attack.reflectiveWizardryMagic=%1$s was killed by %2$s using magic

commands.cast.usage=/%1$s <spell> [player] [damage multiplier] [range multiplier] [duration multiplier] [blast multiplier]
commands.cast.success=Successfully cast %1$s
Expand Down