mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Added more ways of getting cloud lumps
This commit is contained in:
parent
3a9978a6b1
commit
16b90e208b
4 changed files with 122 additions and 6 deletions
|
@ -6,30 +6,42 @@ import java.util.function.Consumer;
|
|||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.minelittlepony.unicopia.EquineContext;
|
||||
import com.minelittlepony.unicopia.USounds;
|
||||
import com.minelittlepony.unicopia.entity.MagicImmune;
|
||||
import com.minelittlepony.unicopia.particle.UParticles;
|
||||
import com.minelittlepony.unicopia.server.world.WeatherConditions;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityStatuses;
|
||||
import net.minecraft.entity.EntityType;
|
||||
import net.minecraft.entity.ItemEntity;
|
||||
import net.minecraft.entity.LightningEntity;
|
||||
import net.minecraft.entity.boss.ServerBossBar;
|
||||
import net.minecraft.entity.damage.DamageSource;
|
||||
import net.minecraft.entity.damage.DamageTypes;
|
||||
import net.minecraft.entity.data.DataTracker;
|
||||
import net.minecraft.entity.data.TrackedData;
|
||||
import net.minecraft.entity.data.TrackedDataHandlerRegistry;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.loot.context.LootContextParameterSet;
|
||||
import net.minecraft.loot.context.LootContextParameters;
|
||||
import net.minecraft.loot.context.LootContextTypes;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.nbt.NbtElement;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.predicate.entity.EntityPredicates;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Direction;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.GameRules;
|
||||
import net.minecraft.world.Heightmap.Type;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
|
@ -140,8 +152,6 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
float targetY = isStormy() ? STORMY_TARGET_ALTITUDE : CLEAR_TARGET_ALTITUDE;
|
||||
float cloudY = (float)getY() - targetY;
|
||||
|
||||
System.out.println("Ground Y: " + groundY + ", TargetY: " + targetY + ", Stormy: " + isStormy());
|
||||
|
||||
addVelocity(0, 0.0003F * (groundY - cloudY), 0);
|
||||
|
||||
if (!cursed && !isStormy()) {
|
||||
|
@ -293,10 +303,46 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void onDamaged(DamageSource damageSource) {
|
||||
if (random.nextInt(35) == 0) {
|
||||
split(2 + random.nextInt(4));
|
||||
public boolean damage(DamageSource source, float amount) {
|
||||
super.damage(source, amount);
|
||||
if (!cursed) {
|
||||
if (random.nextInt(35) == 0 || (source.isOf(DamageTypes.PLAYER_ATTACK) && EquineContext.of(source.getAttacker()).collidesWithClouds())) {
|
||||
if (getSize(1) < 2) {
|
||||
if (!getWorld().isClient() && getWorld().getGameRules().getBoolean(GameRules.DO_MOB_LOOT)) {
|
||||
Identifier identifier = getType().getLootTableId();
|
||||
LootContextParameterSet.Builder builder = new LootContextParameterSet.Builder((ServerWorld)this.getWorld())
|
||||
.add(LootContextParameters.THIS_ENTITY, this)
|
||||
.add(LootContextParameters.ORIGIN, this.getPos())
|
||||
.add(LootContextParameters.DAMAGE_SOURCE, source)
|
||||
.addOptional(LootContextParameters.KILLER_ENTITY, source.getAttacker())
|
||||
.addOptional(LootContextParameters.DIRECT_KILLER_ENTITY, source.getSource());
|
||||
if (source.getAttacker() instanceof PlayerEntity player) {
|
||||
builder = builder.add(LootContextParameters.LAST_DAMAGE_PLAYER, player).luck(player.getLuck());
|
||||
}
|
||||
getWorld().getServer().getLootManager().getLootTable(identifier)
|
||||
.generateLoot(builder.build(LootContextTypes.ENTITY), 0L, this::dropStack);
|
||||
}
|
||||
kill();
|
||||
getWorld().sendEntityStatus(this, EntityStatuses.ADD_DEATH_PARTICLES);
|
||||
} else {
|
||||
split(2 + random.nextInt(4));
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public ItemEntity dropStack(ItemStack stack) {
|
||||
stack = stack.copy();
|
||||
while (!stack.isEmpty()) {
|
||||
ItemEntity drop = super.dropStack(stack.split(1));
|
||||
if (drop != null) {
|
||||
drop.addVelocity(random.nextTriangular(0, 0.3), 0, random.nextTriangular(0, 0.3));
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void split(int splitCount) {
|
||||
|
@ -326,7 +372,29 @@ public class StormCloudEntity extends Entity implements MagicImmune {
|
|||
|
||||
@Override
|
||||
public void handleStatus(byte status) {
|
||||
super.handleStatus(status);
|
||||
switch (status) {
|
||||
case EntityStatuses.ADD_DEATH_PARTICLES:
|
||||
for (int i = 0; i < 20; ++i) {
|
||||
double d = random.nextGaussian() * 0.02;
|
||||
double e = random.nextGaussian() * 0.02;
|
||||
double f = random.nextGaussian() * 0.02;
|
||||
getWorld().addParticle(ParticleTypes.POOF, getParticleX(1), getRandomBodyY(), getParticleZ(1), d, e, f);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
super.handleStatus(status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHitByProjectile() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean canHit() {
|
||||
return true;
|
||||
}
|
||||
|
||||
private ServerBossBar getBossBar() {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
"type": "minecraft:entity",
|
||||
"pools": [
|
||||
{
|
||||
"rolls": 1,
|
||||
"bonus_rolls": 0,
|
||||
"entries": [
|
||||
{
|
||||
"type": "minecraft:item",
|
||||
"functions": [
|
||||
{
|
||||
"add": false,
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"max": 12.0,
|
||||
"min": 6.0
|
||||
},
|
||||
"function": "minecraft:set_count"
|
||||
},
|
||||
{
|
||||
"function": "minecraft:looting_enchant",
|
||||
"count": {
|
||||
"type": "minecraft:uniform",
|
||||
"min": 0.0,
|
||||
"max": 1.0
|
||||
}
|
||||
}
|
||||
],
|
||||
"name": "unicopia:cloud_lump"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
7
src/main/resources/data/unicopia/recipes/cloud_lump.json
Normal file
7
src/main/resources/data/unicopia/recipes/cloud_lump.json
Normal file
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"type": "minecraft:crafting_shapeless",
|
||||
"ingredients": [
|
||||
{ "tag": "cloud_jars" }
|
||||
],
|
||||
"result": { "item": "unicopia:cloud_lump", "count": 4 }
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"replace": false,
|
||||
"values": [
|
||||
"unicopia:rain_cloud_jar",
|
||||
"unicopia:storm_cloud_jar"
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue