-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/day-night-rituals'
- Loading branch information
Showing
12 changed files
with
475 additions
and
4 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
src/main/java/com/github/klikli_dev/occultism/common/job/ChangeTimeJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2020 klikli-dev | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT | ||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.github.klikli_dev.occultism.common.job; | ||
|
||
import com.github.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import net.minecraft.entity.effect.LightningBoltEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.nbt.CompoundNBT; | ||
import net.minecraft.particles.ParticleTypes; | ||
import net.minecraft.util.DamageSource; | ||
import net.minecraft.util.Hand; | ||
import net.minecraft.util.SoundCategory; | ||
import net.minecraft.util.SoundEvents; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public abstract class ChangeTimeJob extends SpiritJob { | ||
|
||
//region Fields | ||
protected int currentChangeTicks; | ||
protected int requiredChangeTicks; | ||
//endregion Fields | ||
|
||
|
||
//region Initialization | ||
public ChangeTimeJob(SpiritEntity entity, int requiredChangeTicks) { | ||
super(entity); | ||
this.requiredChangeTicks = requiredChangeTicks; | ||
} | ||
//endregion Initialization | ||
|
||
//region Overrides | ||
|
||
@Override | ||
public void init() { | ||
|
||
} | ||
|
||
@Override | ||
public void cleanup() { | ||
//in this case called on spirit death | ||
for(int i = 0; i < 5; i++){ | ||
((ServerWorld) this.entity.world) | ||
.spawnParticle(ParticleTypes.PORTAL, this.entity.getPosX() + this.entity.world.getRandom().nextGaussian(), | ||
this.entity.getPosY() + 0.5 + this.entity.world.getRandom().nextGaussian(), this.entity.getPosZ()+ this.entity.world.getRandom().nextGaussian(), 5, | ||
0.0, 0.0, 0.0, | ||
0.0); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
public void update() { | ||
super.update(); | ||
|
||
this.currentChangeTicks++; | ||
if(!this.entity.isSwingInProgress){ | ||
this.entity.swingArm(Hand.MAIN_HAND); | ||
} | ||
if(this.entity.world.getGameTime() % 2 == 0){ | ||
((ServerWorld) this.entity.world) | ||
.spawnParticle(ParticleTypes.PORTAL, this.entity.getPosX(), | ||
this.entity.getPosY() + 0.5, this.entity.getPosZ(), 3, | ||
0.5, 0.0, 0.0, | ||
0.0); | ||
} | ||
|
||
if (this.currentChangeTicks == this.requiredChangeTicks) { | ||
this.changeTime(); | ||
this.entity.world.playSound(null, this.entity.getPosition(), SoundEvents.BLOCK_BEACON_ACTIVATE, SoundCategory.NEUTRAL, 1, 1); | ||
this.entity.onDeath(DamageSource.OUT_OF_WORLD); | ||
this.entity.remove(); | ||
} | ||
} | ||
|
||
@Override | ||
public CompoundNBT writeJobToNBT(CompoundNBT compound) { | ||
compound.putInt("currentChangeTicks", this.currentChangeTicks); | ||
compound.putInt("requiredChangeTicks", this.requiredChangeTicks); | ||
return super.writeJobToNBT(compound); | ||
} | ||
|
||
@Override | ||
public void readJobFromNBT(CompoundNBT compound) { | ||
super.readJobFromNBT(compound); | ||
this.currentChangeTicks = compound.getInt("currentChangeTicks"); | ||
this.requiredChangeTicks = compound.getInt("requiredChangeTicks"); | ||
} | ||
|
||
@Override | ||
public boolean canPickupItem(ItemStack stack) { | ||
return false; | ||
} | ||
//endregion Overrides | ||
|
||
//region Methods | ||
public abstract void changeTime(); | ||
//endregion Methods | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/main/java/com/github/klikli_dev/occultism/common/job/DayTimeJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2020 klikli-dev | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT | ||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.github.klikli_dev.occultism.common.job; | ||
|
||
import com.github.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class DayTimeJob extends ChangeTimeJob { | ||
|
||
//region Initialization | ||
public DayTimeJob(SpiritEntity entity, int ticksToClear) { | ||
super(entity, ticksToClear); | ||
} | ||
//endregion Initialization | ||
|
||
//region Overrides | ||
@Override | ||
public void changeTime() { | ||
ServerWorld world = (ServerWorld) this.entity.world; | ||
world.setDayTime(1000); | ||
} | ||
//endregion Overrides | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
src/main/java/com/github/klikli_dev/occultism/common/job/NightTimeJob.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2020 klikli-dev | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT | ||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.github.klikli_dev.occultism.common.job; | ||
|
||
import com.github.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class NightTimeJob extends ChangeTimeJob { | ||
|
||
//region Initialization | ||
public NightTimeJob(SpiritEntity entity, int ticksToClear) { | ||
super(entity, ticksToClear); | ||
} | ||
//endregion Initialization | ||
|
||
//region Overrides | ||
@Override | ||
public void changeTime() { | ||
ServerWorld world = (ServerWorld) this.entity.world; | ||
world.setDayTime(13000); | ||
} | ||
//endregion Overrides | ||
|
||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/com/github/klikli_dev/occultism/common/ritual/SummonDjinniDayTimeRitual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2020 klikli-dev | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT | ||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.github.klikli_dev.occultism.common.ritual; | ||
|
||
import com.github.klikli_dev.occultism.Occultism; | ||
import com.github.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import com.github.klikli_dev.occultism.common.job.SpiritJob; | ||
import com.github.klikli_dev.occultism.common.tile.GoldenSacrificialBowlTileEntity; | ||
import com.github.klikli_dev.occultism.registry.OccultismEntities; | ||
import com.github.klikli_dev.occultism.registry.OccultismItems; | ||
import com.github.klikli_dev.occultism.registry.OccultismRituals; | ||
import com.github.klikli_dev.occultism.registry.OccultismSpiritJobs; | ||
import com.github.klikli_dev.occultism.util.ItemNBTUtil; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import net.minecraft.particles.ParticleTypes; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class SummonDjinniDayTimeRitual extends SummonSpiritRitual { | ||
|
||
//region Initialization | ||
public SummonDjinniDayTimeRitual() { | ||
super(null, | ||
OccultismRituals.SUMMON_DJINNI_PENTACLE.get(), | ||
Ingredient.fromItems(OccultismItems.BOOK_OF_BINDING_BOUND_DJINNI.get()), | ||
"summon_djinni_day_time", 60); | ||
} | ||
//endregion Initialization | ||
|
||
//region Overrides | ||
@Override | ||
public void finish(World world, BlockPos goldenBowlPosition, GoldenSacrificialBowlTileEntity tileEntity, | ||
PlayerEntity castingPlayer, ItemStack activationItem) { | ||
|
||
super.finish(world, goldenBowlPosition, tileEntity, castingPlayer, activationItem); | ||
|
||
//consume activation item | ||
ItemStack copy = activationItem.copy(); | ||
activationItem.shrink(1); | ||
|
||
((ServerWorld) world).spawnParticle(ParticleTypes.LARGE_SMOKE, goldenBowlPosition.getX() + 0.5, | ||
goldenBowlPosition.getY() + 0.5, goldenBowlPosition.getZ() + 0.5, 1, 0, 0, 0, 0); | ||
|
||
//set up the djinni entity | ||
SpiritEntity spirit = OccultismEntities.DJINNI.get().create(world); | ||
this.prepareSpiritForSpawn(spirit, world, goldenBowlPosition, castingPlayer, | ||
ItemNBTUtil.getBoundSpiritName(copy)); | ||
|
||
//set up the job | ||
SpiritJob job = OccultismSpiritJobs.DAY_TIME.get().create(spirit); | ||
job.init(); | ||
spirit.setJob(job); | ||
spirit.setSpiritMaxAge(60); | ||
|
||
//notify players nearby and spawn | ||
this.spawnEntity(spirit, world); | ||
} | ||
|
||
@Override | ||
public boolean identify(World world, BlockPos goldenBowlPosition, ItemStack activationItem) { | ||
return Occultism.CONFIG.rituals.enableDayTimeRitual.get() && | ||
super.identify(world, goldenBowlPosition, activationItem); | ||
} | ||
//endregion Overrides | ||
} |
88 changes: 88 additions & 0 deletions
88
src/main/java/com/github/klikli_dev/occultism/common/ritual/SummonDjinniNightTimeRitual.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
* MIT License | ||
* | ||
* Copyright 2020 klikli-dev | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and | ||
* associated documentation files (the "Software"), to deal in the Software without restriction, including | ||
* without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
* of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following | ||
* conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial | ||
* portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR | ||
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT | ||
* OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
* OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.github.klikli_dev.occultism.common.ritual; | ||
|
||
import com.github.klikli_dev.occultism.Occultism; | ||
import com.github.klikli_dev.occultism.common.entity.spirit.SpiritEntity; | ||
import com.github.klikli_dev.occultism.common.job.SpiritJob; | ||
import com.github.klikli_dev.occultism.common.tile.GoldenSacrificialBowlTileEntity; | ||
import com.github.klikli_dev.occultism.registry.OccultismEntities; | ||
import com.github.klikli_dev.occultism.registry.OccultismItems; | ||
import com.github.klikli_dev.occultism.registry.OccultismRituals; | ||
import com.github.klikli_dev.occultism.registry.OccultismSpiritJobs; | ||
import com.github.klikli_dev.occultism.util.ItemNBTUtil; | ||
import net.minecraft.entity.player.PlayerEntity; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.item.crafting.Ingredient; | ||
import net.minecraft.particles.ParticleTypes; | ||
import net.minecraft.util.math.BlockPos; | ||
import net.minecraft.world.World; | ||
import net.minecraft.world.server.ServerWorld; | ||
|
||
public class SummonDjinniNightTimeRitual extends SummonSpiritRitual { | ||
|
||
//region Initialization | ||
public SummonDjinniNightTimeRitual() { | ||
super(null, | ||
OccultismRituals.SUMMON_DJINNI_PENTACLE.get(), | ||
Ingredient.fromItems(OccultismItems.BOOK_OF_BINDING_BOUND_DJINNI.get()), | ||
"summon_djinni_night_time", 60); | ||
} | ||
//endregion Initialization | ||
|
||
//region Overrides | ||
@Override | ||
public void finish(World world, BlockPos goldenBowlPosition, GoldenSacrificialBowlTileEntity tileEntity, | ||
PlayerEntity castingPlayer, ItemStack activationItem) { | ||
|
||
super.finish(world, goldenBowlPosition, tileEntity, castingPlayer, activationItem); | ||
|
||
//consume activation item | ||
ItemStack copy = activationItem.copy(); | ||
activationItem.shrink(1); | ||
|
||
((ServerWorld) world).spawnParticle(ParticleTypes.LARGE_SMOKE, goldenBowlPosition.getX() + 0.5, | ||
goldenBowlPosition.getY() + 0.5, goldenBowlPosition.getZ() + 0.5, 1, 0, 0, 0, 0); | ||
|
||
//set up the djinni entity | ||
SpiritEntity spirit = OccultismEntities.DJINNI.get().create(world); | ||
this.prepareSpiritForSpawn(spirit, world, goldenBowlPosition, castingPlayer, | ||
ItemNBTUtil.getBoundSpiritName(copy)); | ||
|
||
//set up the job | ||
SpiritJob job = OccultismSpiritJobs.NIGHT_TIME.get().create(spirit); | ||
job.init(); | ||
spirit.setJob(job); | ||
spirit.setSpiritMaxAge(60); | ||
|
||
//notify players nearby and spawn | ||
this.spawnEntity(spirit, world); | ||
} | ||
|
||
@Override | ||
public boolean identify(World world, BlockPos goldenBowlPosition, ItemStack activationItem) { | ||
return Occultism.CONFIG.rituals.enableNightTimeRitual.get() && | ||
super.identify(world, goldenBowlPosition, activationItem); | ||
} | ||
//endregion Overrides | ||
} |
Oops, something went wrong.