Skip to content

Commit

Permalink
Complete inspirations support
Browse files Browse the repository at this point in the history
  • Loading branch information
democat3457 committed Jun 14, 2022
1 parent 8371196 commit a69d17a
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 18 deletions.
16 changes: 10 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@ dependencies {
compileOnly "org.apache.logging.log4j:log4j-core:2.17+"
compileOnly "io.netty:netty-all:4.1.77+"

deobfCompile("knightminer:Inspirations:1.12.2-0.2.9.9") {
exclude group: 'mezz.jei'
}
runtimeOnly "slimeknights.mantle:Mantle:1.12-1.3.3.7"
deobfCompile "slimeknights.mantle:Mantle:1.12-1.3.3.55"

// deobfCompile "slimeknights.mantle:Mantle:1.12-1.3.3.55"
// deobfCompile "knightminer:Inspirations:1.12.2-0.2.9.9"
if (runInspirations.toBoolean()) {
deobfCompile(inspirationsString) { // run w/ inspirations
exclude group: 'mezz.jei'
}
} else {
compileOnly(inspirationsString) { // run w/o inspirations
exclude group: 'mezz.jei'
}
}
}


Expand Down
3 changes: 3 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
# This is required to provide enough memory for the Minecraft decompilation process.
org.gradle.jvmargs=-Xmx3G

runInspirations = true
inspirationsString = knightminer:Inspirations:1.12.2-0.2.9.9
2 changes: 1 addition & 1 deletion src/main/java/de/ellpeck/nyx/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public static void load() {


lunarWater = instance.get("lunarWater", "lunarWater", true, "If lunar water should be enabled").getBoolean();
lunarWaterItemParts = instance.get("lunarWater", "lunarWaterItem", "minecraft:dye:11", "The item that needs to be dropped into a cauldron to turn it into lunar water.\nExamples include 'minecraft:stick', 'minecraft:wool:3', and 'ore:stone'").getString().split(":");
lunarWaterItemParts = instance.get("lunarWater", "lunarWaterItem", "minecraft:dye:4", "The item that needs to be dropped into a cauldron to turn it into lunar water.\nExamples include 'minecraft:stick', 'minecraft:wool:3', and 'ore:stone'").getString().split(":");
lunarWaterTicks = instance.get("lunarWater", "lunarWaterTicks", new int[]{1200, -1, 4800, 4800, 3600, 3600, 2400, 2400, 600, -1},
"The amount of ticks that a cauldron of water must be exposed to the night sky to be ready to turn into lunar water, per moon phase.\n" +
"From first to last, the entries are: Full moon, new moon, waning crescent, waxing crescent, third quarter, first quarter, waning gibbous, waxing gibbous, harvest moon and blood moon.\n" +
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/de/ellpeck/nyx/compat/CauldronProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,12 @@ public void setLunarWaterCauldron(World world, BlockPos pos, int level) {
public boolean isLunarWaterCauldron(World world, BlockPos pos) {
return world.getBlockState(pos).getBlock() instanceof LunarWaterCauldron;
}

public int getLevel(World world, BlockPos pos) {
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockCauldron) {
return state.getValue(BlockCauldron.LEVEL);
}
return 0;
}
}
15 changes: 12 additions & 3 deletions src/main/java/de/ellpeck/nyx/compat/InspirationsProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ public class InspirationsProxy extends CauldronProxy {
@Override
public void setLunarWaterCauldron(World world, BlockPos pos, int level) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileCauldron) {
if (te != null && te instanceof TileCauldron) {
TileCauldron tc = (TileCauldron) te;
tc.setFluidLevel(level);
tc.setState(CauldronState.fluid(Registry.lunarWaterFluid), true);
tc.setFluidLevel(level);
} else {
// Fallback
super.setLunarWaterCauldron(world, pos, level);
Expand All @@ -24,12 +24,21 @@ public void setLunarWaterCauldron(World world, BlockPos pos, int level) {
@Override
public boolean isLunarWaterCauldron(World world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileCauldron) {
if (te != null && te instanceof TileCauldron) {
CauldronState state = ((TileCauldron) te).getState();
return state.getFluid() != null && state.getFluid() == Registry.lunarWaterFluid;
} else {
// Fallback
return super.isLunarWaterCauldron(world, pos);
}
}

@Override
public int getLevel(World world, BlockPos pos) {
TileEntity te = world.getTileEntity(pos);
if (te != null && te instanceof TileCauldron) {
return ((TileCauldron) te).getFluidLevel();
}
return super.getLevel(world, pos);
}
}
2 changes: 1 addition & 1 deletion src/main/java/de/ellpeck/nyx/entities/CauldronTracker.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public void onEntityUpdate() {

if (!toMatch.apply(item.getItem()))
continue;

item.setDead();

Nyx.cauldronProxy.setLunarWaterCauldron(this.world, this.trackingPos, level);
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/de/ellpeck/nyx/entities/FallingMeteor.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,12 @@ protected void customUpdate() {
return;
}

// meteors are disabled
if (!Config.meteors) {
this.setDead();
return;
}

// Apparently this doesn't get called because unloaded entities don't update
// Moved to Events.java

Expand Down
42 changes: 35 additions & 7 deletions src/main/java/de/ellpeck/nyx/events/Events.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.google.common.collect.Streams;
import de.ellpeck.nyx.Config;
import de.ellpeck.nyx.LunarWaterSource;
import de.ellpeck.nyx.Nyx;
import de.ellpeck.nyx.Registry;
import de.ellpeck.nyx.capabilities.NyxWorld;
Expand All @@ -10,6 +11,7 @@
import de.ellpeck.nyx.entities.FallingMeteor;
import de.ellpeck.nyx.entities.FallingStar;
import de.ellpeck.nyx.entities.WolfAiSpecialMoon;
import de.ellpeck.nyx.items.LunarWaterBottle;
import de.ellpeck.nyx.lunarevents.BloodMoon;
import de.ellpeck.nyx.lunarevents.FullMoon;
import de.ellpeck.nyx.lunarevents.HarvestMoon;
Expand Down Expand Up @@ -81,10 +83,13 @@ public final class Events {
public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
if (event.phase != TickEvent.Phase.END)
return;
EntityPlayer player = event.player;
if (player == null)
return;
World world = player.world;
if (Config.meteors) {
EntityPlayer player = event.player;
// meteor armor speed reduction
if (player.world.getTotalWorldTime() % 20 == 0) {
if (world.getTotalWorldTime() % 20 == 0) {
IAttributeInstance speed = player.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
String key = Nyx.ID + ":meteor_equipped";
NBTTagCompound nbt = player.getEntityData();
Expand All @@ -106,14 +111,14 @@ public static void onPlayerTick(TickEvent.PlayerTickEvent event) {
// meteor hammer ability executions
// we check fall distance because we need the player to be done falling when removing the tag
if (player.onGround && player.fallDistance <= 0 && player.getEntityData().hasKey(Nyx.ID + ":leap_start")) {
if (!player.world.isRemote) {
long leapTime = player.world.getTotalWorldTime() - player.getEntityData().getLong(Nyx.ID + ":leap_start");
if (!world.isRemote) {
long leapTime = world.getTotalWorldTime() - player.getEntityData().getLong(Nyx.ID + ":leap_start");
if (leapTime >= 5) {
int r = 3;
AxisAlignedBB area = new AxisAlignedBB(player.posX - r, player.posY - r, player.posZ - r, player.posX + r, player.posY + r, player.posZ + r);
DamageSource source = DamageSource.causePlayerDamage(player);
float damage = Config.hammerDamage * Math.min((leapTime - 5) / 35F, 1);
for (EntityLivingBase entity : player.world.getEntitiesWithinAABB(EntityLivingBase.class, area, EntitySelectors.IS_ALIVE)) {
for (EntityLivingBase entity : world.getEntitiesWithinAABB(EntityLivingBase.class, area, EntitySelectors.IS_ALIVE)) {
if (entity == player)
continue;
entity.attackEntityFrom(source, damage);
Expand Down Expand Up @@ -301,10 +306,33 @@ public static void onChunkUnload(ChunkEvent.Unload event) {
@SubscribeEvent
public static void onLivingTick(LivingEvent.LivingUpdateEvent event) {
EntityLivingBase entity = event.getEntityLiving();
World world = entity.world;
// Delet monsters spawned by blood moon
if (Config.bloodMoonVanish && !entity.world.isRemote && NyxWorld.isDaytime(entity.world) && entity.getEntityData().getBoolean(Nyx.ID + ":blood_moon_spawn")) {
((WorldServer) entity.world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, entity.posX, entity.posY, entity.posZ, 10, 0.5, 1, 0.5, 0);
if (Config.bloodMoonVanish && !world.isRemote && NyxWorld.isDaytime(world) && entity.getEntityData().getBoolean(Nyx.ID + ":blood_moon_spawn")) {
((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, entity.posX, entity.posY, entity.posZ, 10, 0.5, 1, 0.5, 0);
entity.setDead();
return;
}
// Replicate lunar water cauldron behavior w/ inspirations cauldron
if (Nyx.cauldronProxy instanceof InspirationsProxy) {
if (!world.isRemote) {
BlockPos pos = entity.getPosition();
if (Nyx.cauldronProxy.isLunarWaterCauldron(world, pos)) {
int currentLevel = Nyx.cauldronProxy.getLevel(world, pos);
if (currentLevel > 0) {
boolean did = false;
if (entity.isBurning()) {
entity.extinguish();
did = true;
}
if (LunarWaterBottle.applyLunarWater(entity,
LunarWaterSource.CAULDRON))
did = true;
if (did)
Nyx.cauldronProxy.setLunarWaterCauldron(world, pos, currentLevel - 1);
}
}
}
}
}

Expand Down

0 comments on commit a69d17a

Please sign in to comment.