mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 11:36:43 +01:00
Updating to 1.21 (part 4)
This commit is contained in:
parent
5dd90c42aa
commit
8fdb173e4b
22 changed files with 188 additions and 168 deletions
|
@ -17,7 +17,7 @@ import net.minecraft.util.Identifier;
|
|||
|
||||
public class DiscoveryToast implements Toast {
|
||||
private static final long MAX_AGE = 5000L;
|
||||
private static final Identifier TEXTURE = new Identifier("toast/advancement");
|
||||
private static final Identifier TEXTURE = Identifier.ofVanilla("toast/advancement");
|
||||
private static final Text TITLE = Text.translatable("unicopia.toast.discoveries.title");
|
||||
private static final Text DESCRIPTION = Text.translatable("unicopia.toast.discoveries.description");
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ public class FirstPersonRendererOverrides {
|
|||
}
|
||||
|
||||
if (Pony.of(player).getAnimation().renderBothArms()) {
|
||||
float swingProgress = player.getHandSwingProgress(MinecraftClient.getInstance().getTickDelta());
|
||||
float swingProgress = player.getHandSwingProgress(MinecraftClient.getInstance().getRenderTickCounter().getTickDelta(false));
|
||||
|
||||
Hand hand = MoreObjects.firstNonNull(player.preferredHand, Hand.MAIN_HAND);
|
||||
|
||||
|
|
|
@ -1,49 +1,25 @@
|
|||
package com.minelittlepony.unicopia.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.minelittlepony.unicopia.entity.Equine;
|
||||
import com.minelittlepony.unicopia.entity.mob.UEntityAttributes;
|
||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||
import com.minelittlepony.unicopia.item.enchantment.AttributedEnchantment;
|
||||
import net.fabricmc.fabric.api.client.item.v1.ItemTooltipCallback;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.entity.attribute.EntityAttribute;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
import net.minecraft.entity.attribute.EntityAttributes;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier.Operation;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.tooltip.TooltipType;
|
||||
import net.minecraft.nbt.NbtCompound;
|
||||
import net.minecraft.screen.ScreenTexts;
|
||||
import net.minecraft.text.Text;
|
||||
import net.minecraft.util.Formatting;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.Pair;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
|
||||
public class ModifierTooltipRenderer implements ItemTooltipCallback {
|
||||
|
||||
@Override
|
||||
public void getTooltip(ItemStack stack, Item.TooltipContext tooltipContext, TooltipType tooltipType, List<Text> lines) {
|
||||
|
||||
int flags = stack.hasNbt() && stack.getNbt().contains("HideFlags", 99) ? stack.getNbt().getInt("HideFlags") : 0;
|
||||
// TODO: Evaluate if we still need this
|
||||
/*int flags = stack.hasNbt() && stack.getNbt().contains("HideFlags", 99) ? stack.getNbt().getInt("HideFlags") : 0;
|
||||
|
||||
if (isShowing(flags, ItemStack.TooltipSection.MODIFIERS)) {
|
||||
|
||||
Enchantment s;
|
||||
Map<EquipmentSlot, Multimap<EntityAttribute, EntityAttributeModifier>> modifiers = new HashMap<>();
|
||||
|
||||
Equine.<PlayerEntity, Pony>of(MinecraftClient.getInstance().player).ifPresent(eq -> {
|
||||
|
@ -72,13 +48,13 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}*/
|
||||
|
||||
if (MinecraftClient.getInstance().player != null) {
|
||||
Pony.of(MinecraftClient.getInstance().player).getDiscoveries().appendTooltip(stack, MinecraftClient.getInstance().world, lines);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
private int getInsertPosition(ItemStack stack, Text category, int flags, List<Text> lines, boolean advanced) {
|
||||
int insertPosition = lines.indexOf(category);
|
||||
|
||||
|
@ -166,5 +142,5 @@ public class ModifierTooltipRenderer implements ItemTooltipCallback {
|
|||
|
||||
return Stream.empty();
|
||||
}
|
||||
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -48,7 +48,6 @@ import net.minecraft.block.BlockState;
|
|||
import net.minecraft.block.entity.BlockEntity;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.color.world.BiomeColors;
|
||||
import net.minecraft.client.color.world.FoliageColors;
|
||||
import net.minecraft.client.item.ClampedModelPredicateProvider;
|
||||
import net.minecraft.client.item.ModelPredicateProviderRegistry;
|
||||
import net.minecraft.client.particle.Particle;
|
||||
|
@ -61,14 +60,17 @@ import net.minecraft.client.render.item.ItemRenderer;
|
|||
import net.minecraft.client.render.model.json.ModelTransformationMode;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.component.type.DyedColorComponent;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.item.*;
|
||||
import net.minecraft.particle.ParticleEffect;
|
||||
import net.minecraft.util.Colors;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.BlockRenderView;
|
||||
import net.minecraft.world.biome.FoliageColors;
|
||||
|
||||
public interface URenderers {
|
||||
BlockEntity CHEST_RENDER_ENTITY = new CloudChestBlock.TileData(BlockPos.ORIGIN, UBlocks.CLOUD_CHEST.getDefaultState());
|
||||
|
@ -126,10 +128,10 @@ public interface URenderers {
|
|||
register(URenderers::renderBedItem, UItems.CLOTH_BED, UItems.CLOUD_BED);
|
||||
register(URenderers::renderChestItem, UBlocks.CLOUD_CHEST.asItem());
|
||||
PolearmRenderer.register(UItems.WOODEN_POLEARM, UItems.STONE_POLEARM, UItems.IRON_POLEARM, UItems.GOLDEN_POLEARM, UItems.DIAMOND_POLEARM, UItems.NETHERITE_POLEARM);
|
||||
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("affinity"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getAffinity().getAlignment());
|
||||
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, new Identifier("shape"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getGemShape().getId());
|
||||
ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, new Identifier("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount());
|
||||
ModelPredicateProviderRegistry.register(UItems.BUTTERFLY, new Identifier("variant"), (stack, world, entity, seed) -> (float)ButterflyItem.getVariant(stack).ordinal() / ButterflyEntity.Variant.VALUES.length);
|
||||
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, Identifier.ofVanilla("affinity"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getAffinity().getAlignment());
|
||||
ModelPredicateProviderRegistry.register(UItems.GEMSTONE, Identifier.ofVanilla("shape"), (stack, world, entity, seed) -> EnchantableItem.getSpellKey(stack).getGemShape().getId());
|
||||
ModelPredicateProviderRegistry.register(UItems.ROCK_CANDY, Identifier.ofVanilla("count"), (stack, world, entity, seed) -> stack.getCount() / (float)stack.getMaxCount());
|
||||
ModelPredicateProviderRegistry.register(UItems.BUTTERFLY, Identifier.ofVanilla("variant"), (stack, world, entity, seed) -> (float)ButterflyItem.getVariant(stack).ordinal() / ButterflyEntity.Variant.VALUES.length);
|
||||
ModelPredicateProviderRegistry.register(Unicopia.id("zap_cycle"), new ClampedModelPredicateProvider() {
|
||||
private double targetAngle;
|
||||
private double lastAngle;
|
||||
|
@ -159,7 +161,7 @@ public interface URenderers {
|
|||
|
||||
ColorProviderRegistry.BLOCK.register(URenderers::getTintedBlockColor, TintedBlock.REGISTRY.stream().toArray(Block[]::new));
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> getTintedBlockColor(Block.getBlockFromItem(stack.getItem()).getDefaultState(), null, null, i), TintedBlock.REGISTRY.stream().map(Block::asItem).filter(i -> i != Items.AIR).toArray(Item[]::new));
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> i > 0 ? -1 : ((DyeableItem)stack.getItem()).getColor(stack), UItems.FRIENDSHIP_BRACELET);
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> i > 0 ? -1 : DyedColorComponent.getColor(stack, Colors.WHITE), UItems.FRIENDSHIP_BRACELET);
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> i > 0 || !EnchantableItem.isEnchanted(stack) ? -1 : EnchantableItem.getSpellKey(stack).getColor(), UItems.GEMSTONE);
|
||||
ColorProviderRegistry.ITEM.register((stack, i) -> i == 1 && EnchantableItem.isEnchanted(stack) ? EnchantableItem.getSpellKey(stack).getColor() : -1, UItems.MAGIC_STAFF);
|
||||
|
||||
|
@ -240,11 +242,7 @@ public interface URenderers {
|
|||
}
|
||||
|
||||
private static int getTintedBlockColor(BlockState state, @Nullable BlockRenderView view, @Nullable BlockPos pos, int color) {
|
||||
if (view == null || pos == null) {
|
||||
color = FoliageColors.getDefaultColor();
|
||||
} else {
|
||||
color = BiomeColors.getFoliageColor(view, pos);
|
||||
}
|
||||
color = view == null || pos == null ? FoliageColors.getDefaultColor() : BiomeColors.getFoliageColor(view, pos);
|
||||
|
||||
if (state.getBlock() instanceof TintedBlock block) {
|
||||
return block.getTint(state, view, pos, color);
|
||||
|
|
|
@ -4,13 +4,13 @@ import com.minelittlepony.unicopia.particle.ParticleUtils;
|
|||
import com.minelittlepony.unicopia.util.shape.Sphere;
|
||||
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class CloudsEscapingParticle extends GroundPoundParticle {
|
||||
|
||||
public CloudsEscapingParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double dX, double dY, double dZ) {
|
||||
public CloudsEscapingParticle(SimpleParticleType effect, ClientWorld world, double x, double y, double z, double dX, double dY, double dZ) {
|
||||
super(effect, world, x, y, z, dX, dY, dZ);
|
||||
maxAge = 200;
|
||||
collidesWithWorld = false;
|
||||
|
|
|
@ -11,14 +11,14 @@ import net.minecraft.client.render.Camera;
|
|||
import net.minecraft.client.render.VertexConsumer;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.BlockStateParticleEffect;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.ParticleTypes;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class GroundPoundParticle extends Particle {
|
||||
|
||||
public GroundPoundParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double dX, double dY, double dZ) {
|
||||
public GroundPoundParticle(SimpleParticleType effect, ClientWorld world, double x, double y, double z, double dX, double dY, double dZ) {
|
||||
super(world, x, y, z, dX, dY, dZ);
|
||||
maxAge = 10;
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.minecraft.client.render.LightmapTextureManager;
|
|||
import net.minecraft.client.render.Tessellator;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.world.ClientWorld;
|
||||
import net.minecraft.particle.DefaultParticleType;
|
||||
import net.minecraft.particle.SimpleParticleType;
|
||||
import net.minecraft.sound.SoundCategory;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
@ -19,7 +19,7 @@ import net.minecraft.util.math.RotationAxis;
|
|||
public class ShockwaveParticle extends AbstractBillboardParticle {
|
||||
private static final Identifier TEXTURE = Unicopia.id("textures/particles/shockwave.png");
|
||||
|
||||
public ShockwaveParticle(DefaultParticleType effect, ClientWorld world, double x, double y, double z, double velocityX, double velocityY,
|
||||
public ShockwaveParticle(SimpleParticleType effect, ClientWorld world, double x, double y, double z, double velocityX, double velocityY,
|
||||
double velocityZ) {
|
||||
super(world, x, y, z, 0, 0, 0);
|
||||
maxAge = 20;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.datagen.providers.loot;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.Function;
|
||||
|
||||
|
@ -31,25 +32,42 @@ import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
|||
import net.minecraft.predicate.NumberRange;
|
||||
import net.minecraft.predicate.entity.LocationPredicate;
|
||||
import net.minecraft.predicate.item.EnchantmentPredicate;
|
||||
import net.minecraft.predicate.item.EnchantmentsPredicate;
|
||||
import net.minecraft.predicate.item.ItemPredicate;
|
||||
import net.minecraft.predicate.item.ItemSubPredicateTypes;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.biome.BiomeKeys;
|
||||
|
||||
public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvider {
|
||||
public static final LootCondition.Builder WITH_GEM_FINDER = MatchToolLootCondition.builder(ItemPredicate.Builder.create().enchantment(new EnchantmentPredicate(UEnchantments.GEM_FINDER, NumberRange.IntRange.atLeast(1))));
|
||||
|
||||
public static final LootCondition.Builder WITHOUT_SILK_TOUCH_AND_GEM_FINDER = WITHOUT_SILK_TOUCH.and(WITH_GEM_FINDER);
|
||||
public static final float[] GEMSTONES_FORTUNE_CHANCE = { 0.1F, 0.14285715F, 0.25F, 1F };
|
||||
|
||||
public static final LootCondition.Builder NEEDS_OCEAN_OR_BEACH_BIOME =
|
||||
LocationCheckLootCondition.builder(LocationPredicate.Builder.create().biome(BiomeKeys.OCEAN))
|
||||
.or(LocationCheckLootCondition.builder(LocationPredicate.Builder.create().biome(BiomeKeys.BEACH)));
|
||||
|
||||
public UBlockAdditionsLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(dataOutput, registryLookup);
|
||||
}
|
||||
|
||||
public LootCondition.Builder createNeedsOceanOrBeachCondition() {
|
||||
return LocationCheckLootCondition.builder(LocationPredicate.Builder.createBiome(entryOf(BiomeKeys.OCEAN)))
|
||||
.or(LocationCheckLootCondition.builder(LocationPredicate.Builder.createBiome(entryOf(BiomeKeys.BEACH))));
|
||||
}
|
||||
|
||||
public LootCondition.Builder createWithoutSilkTouchOrGemFinderCondition() {
|
||||
return createWithoutSilkTouchCondition().and(createWithGemFinderCondition());
|
||||
}
|
||||
|
||||
public LootCondition.Builder createWithGemFinderCondition() {
|
||||
return MatchToolLootCondition.builder(ItemPredicate.Builder.create().subPredicate(ItemSubPredicateTypes.ENCHANTMENTS, EnchantmentsPredicate.enchantments(List.of(
|
||||
new EnchantmentPredicate(UEnchantments.GEM_FINDER, NumberRange.IntRange.atLeast(1))
|
||||
))));
|
||||
}
|
||||
|
||||
public <T> RegistryEntry<T> entryOf(RegistryKey<T> key) {
|
||||
return registryLookup.getWrapperOrThrow(key.getRegistryRef()).getOrThrow(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "Block Loot Table Additions";
|
||||
|
@ -73,17 +91,17 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
}
|
||||
|
||||
private void addVanillaDrop(Block block, Function<Block, LootTable.Builder> lootTableFunction) {
|
||||
lootTables.put(new Identifier("unicopiamc", block.getLootTableId().getPath()), lootTableFunction.apply(block));
|
||||
lootTables.put(RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of("unicopiamc", block.getLootTableKey().getValue().getPath())), lootTableFunction.apply(block));
|
||||
}
|
||||
|
||||
public LootTable.Builder shellDrops(Block block) {
|
||||
return LootTable.builder().pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH.and(NEEDS_OCEAN_OR_BEACH_BIOME))
|
||||
.conditionally(createWithoutSilkTouchCondition().and(createNeedsOceanOrBeachCondition()))
|
||||
.with(applyExplosionDecay(block, TagEntry.builder(UTags.Items.SHELLS)
|
||||
.apply(SetCountLootFunction.builder(ConstantLootNumberProvider.create(1)))
|
||||
)
|
||||
.conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, GEMSTONES_FORTUNE_CHANCE)))
|
||||
.conditionally(TableBonusLootCondition.builder(entryOf(Enchantments.FORTUNE), GEMSTONES_FORTUNE_CHANCE)))
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -91,7 +109,7 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH.and(WITH_SHEARS))
|
||||
.conditionally(createWithoutSilkTouchCondition().and(WITH_SHEARS))
|
||||
.with(chanceDrops(block, drop, 1, chance))
|
||||
);
|
||||
}
|
||||
|
@ -100,7 +118,7 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH)
|
||||
.conditionally(createWithoutSilkTouchCondition())
|
||||
.with(chanceDrops(block, UItems.WHEAT_WORMS, max, chance))
|
||||
);
|
||||
}
|
||||
|
@ -109,7 +127,7 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH)
|
||||
.conditionally(createWithoutSilkTouchCondition())
|
||||
.with(gemstoneDrops(block, 0.1F))
|
||||
.with(chanceDrops(block, UItems.WHEAT_WORMS, max, chance))
|
||||
);
|
||||
|
@ -119,7 +137,7 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH)
|
||||
.conditionally(createWithoutSilkTouchCondition())
|
||||
.with(gemstoneDrops(block, 0.1F))
|
||||
);
|
||||
}
|
||||
|
@ -128,10 +146,10 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH)
|
||||
.conditionally(createWithoutSilkTouchCondition())
|
||||
.with(applyExplosionDecay(block, ItemEntry.builder(UItems.CRYSTAL_SHARD)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2)))
|
||||
.apply(ApplyBonusLootFunction.oreDrops(Enchantments.FORTUNE))
|
||||
.apply(ApplyBonusLootFunction.oreDrops(entryOf(Enchantments.FORTUNE)))
|
||||
)
|
||||
.conditionally(RandomChanceLootCondition.builder(0.25F))
|
||||
)
|
||||
|
@ -142,19 +160,19 @@ public class UBlockAdditionsLootTableProvider extends FabricBlockLootTableProvid
|
|||
return applyExplosionDecay(block, ItemEntry.builder(UItems.GEMSTONE)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 2)))
|
||||
)
|
||||
.conditionally(WITH_GEM_FINDER)
|
||||
.conditionally(createWithGemFinderCondition())
|
||||
.conditionally(RandomChanceLootCondition.builder(0.1F))
|
||||
.conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, GEMSTONES_FORTUNE_CHANCE));
|
||||
.conditionally(TableBonusLootCondition.builder(entryOf(Enchantments.FORTUNE), GEMSTONES_FORTUNE_CHANCE));
|
||||
}
|
||||
|
||||
public LootPoolEntry.Builder<?> chanceDrops(Block block, ItemConvertible drop, int max, float...chance) {
|
||||
return applyExplosionDecay(block, ItemEntry.builder(drop)
|
||||
.apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, max)))
|
||||
)
|
||||
.conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, chance));
|
||||
.conditionally(TableBonusLootCondition.builder(entryOf(Enchantments.FORTUNE), chance));
|
||||
}
|
||||
|
||||
public static LootTable.Builder dropsWithGemfinding(Block drop, LootPoolEntry.Builder<?> child) {
|
||||
return BlockLootTableGenerator.drops(drop, WITHOUT_SILK_TOUCH_AND_GEM_FINDER, child);
|
||||
public LootTable.Builder dropsWithGemfinding(Block drop, LootPoolEntry.Builder<?> child) {
|
||||
return BlockLootTableGenerator.drops(drop, createWithoutSilkTouchOrGemFinderCondition(), child);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.minelittlepony.unicopia.datagen.providers.loot;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.block.EdibleBlock;
|
||||
|
@ -19,7 +20,7 @@ import com.minelittlepony.unicopia.server.world.UTreeGen;
|
|||
|
||||
import net.fabricmc.fabric.api.datagen.v1.FabricDataOutput;
|
||||
import net.fabricmc.fabric.api.datagen.v1.provider.FabricBlockLootTableProvider;
|
||||
import net.fabricmc.fabric.api.resource.conditions.v1.DefaultResourceConditions;
|
||||
import net.fabricmc.fabric.api.resource.conditions.v1.ResourceConditions;
|
||||
import net.minecraft.block.BedBlock;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.Blocks;
|
||||
|
@ -46,6 +47,9 @@ import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
|||
import net.minecraft.loot.provider.number.LootNumberProvider;
|
||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||
import net.minecraft.predicate.StatePredicate;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.state.property.BooleanProperty;
|
||||
import net.minecraft.state.property.IntProperty;
|
||||
import net.minecraft.state.property.Properties;
|
||||
|
@ -54,12 +58,23 @@ import net.minecraft.util.Identifier;
|
|||
import net.minecraft.util.StringIdentifiable;
|
||||
|
||||
public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
||||
protected static final float[] SAPLING_DROP_CHANCE = new float[]{0.05F, 0.0625F, 0.083333336F, 0.1F};
|
||||
private static final float[] LEAVES_STICK_DROP_CHANCE = new float[]{0.02F, 0.022222223F, 0.025F, 0.033333335F, 0.1F};
|
||||
|
||||
private static final ConditionalLootFunction.Builder<?> BASE_PRESERVING_FORTUNE_BONUS = ApplyBonusLootFunction.binomialWithBonusCount(Enchantments.FORTUNE, 0.8714286F, 0);
|
||||
private static final ConditionalLootFunction.Builder<?> CROPS_FORTUNE_BONUS = ApplyBonusLootFunction.binomialWithBonusCount(Enchantments.FORTUNE, 0.5714286F, 3);
|
||||
public UBlockLootTableProvider(FabricDataOutput output, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(output, registryLookup);
|
||||
}
|
||||
|
||||
public UBlockLootTableProvider(FabricDataOutput output) {
|
||||
super(output);
|
||||
public <T> RegistryEntry<T> entryOf(RegistryKey<T> key) {
|
||||
return registryLookup.getWrapperOrThrow(key.getRegistryRef()).getOrThrow(key);
|
||||
}
|
||||
|
||||
private ConditionalLootFunction.Builder<?> createBasePreservingFortuneBonusCondition() {
|
||||
return ApplyBonusLootFunction.binomialWithBonusCount(entryOf(Enchantments.FORTUNE), 0.8714286F, 0);
|
||||
}
|
||||
|
||||
private ConditionalLootFunction.Builder<?> createCropsFortuneBonusCondition() {
|
||||
return ApplyBonusLootFunction.binomialWithBonusCount(entryOf(Enchantments.FORTUNE), 0.5714286F, 3);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -109,8 +124,8 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
});
|
||||
addDrop(UBlocks.GOLDEN_APPLE, LootTable.builder().pool(LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(applyStateCondition(UBlocks.GOLDEN_APPLE, EnchantedFruitBlock.ENCHANTED, false, applyExplosionDecay(UBlocks.GOLDEN_APPLE, ItemEntry.builder(Items.GOLDEN_APPLE))).apply(BASE_PRESERVING_FORTUNE_BONUS))
|
||||
.with(applyStateCondition(UBlocks.GOLDEN_APPLE, EnchantedFruitBlock.ENCHANTED, true, applyExplosionDecay(UBlocks.GOLDEN_APPLE, ItemEntry.builder(Items.ENCHANTED_GOLDEN_APPLE))).apply(BASE_PRESERVING_FORTUNE_BONUS))
|
||||
.with(applyStateCondition(UBlocks.GOLDEN_APPLE, EnchantedFruitBlock.ENCHANTED, false, applyExplosionDecay(UBlocks.GOLDEN_APPLE, ItemEntry.builder(Items.GOLDEN_APPLE))).apply(createBasePreservingFortuneBonusCondition()))
|
||||
.with(applyStateCondition(UBlocks.GOLDEN_APPLE, EnchantedFruitBlock.ENCHANTED, true, applyExplosionDecay(UBlocks.GOLDEN_APPLE, ItemEntry.builder(Items.ENCHANTED_GOLDEN_APPLE))).apply(createBasePreservingFortuneBonusCondition()))
|
||||
));
|
||||
List.of(UBlocks.GREEN_APPLE_LEAVES, UBlocks.SOUR_APPLE_LEAVES, UBlocks.SWEET_APPLE_LEAVES, UBlocks.GOLDEN_OAK_LEAVES).forEach(block -> addDrop(block, this::fruitLeavesDrops));
|
||||
addDrop(UBlocks.MANGO_LEAVES, block -> leavesDrops(block, UTreeGen.MANGO_TREE.sapling().get(), 0.025F, 0.027777778F, 0.03125F, 0.041666668F, 0.1F)); // same chance as jungle
|
||||
|
@ -126,7 +141,7 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
// jars
|
||||
List.of(
|
||||
UBlocks.JAR, UBlocks.CLOUD_JAR, UBlocks.STORM_JAR, UBlocks.LIGHTNING_JAR, UBlocks.STORM_JAR
|
||||
).forEach(jar -> addDrop(jar, UBlockLootTableProvider::dropsWithSilkTouch));
|
||||
).forEach(jar -> addDrop(jar, this::dropsWithSilkTouch));
|
||||
|
||||
// doors
|
||||
List.of(
|
||||
|
@ -148,7 +163,7 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
.pool(applyStateCondition(UBlocks.SLIME_PUSTULE, SlimePustuleBlock.SHAPE, SlimePustuleBlock.Shape.POD,
|
||||
addSurvivesExplosionCondition(UBlocks.SLIME_PUSTULE, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(UBlocks.SLIME_PUSTULE)).conditionally(WITH_SILK_TOUCH_OR_SHEARS))
|
||||
.with(ItemEntry.builder(UBlocks.SLIME_PUSTULE)).conditionally(createWithShearsOrSilkTouchCondition()))
|
||||
)));
|
||||
addDrop(UBlocks.MYSTERIOUS_EGG, LootTable.builder()
|
||||
.pool(addSurvivesExplosionCondition(UBlocks.MYSTERIOUS_EGG, LootPool.builder()
|
||||
|
@ -178,13 +193,13 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
addDrop(UBlocks.BANANAS, LootTable.builder()
|
||||
.pool(addSurvivesExplosionCondition(UBlocks.BANANAS, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(item(UItems.BANANA, between(6, 12F)).apply(CROPS_FORTUNE_BONUS))
|
||||
.with(item(UItems.BANANA, between(6, 12F)).apply(createCropsFortuneBonusCondition()))
|
||||
)));
|
||||
addDrop(UBlocks.PINEAPPLE, LootTable.builder()
|
||||
.pool(addSurvivesExplosionCondition(UBlocks.PINEAPPLE, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(item(UItems.PINEAPPLE, between(6, 12F))
|
||||
.apply(BASE_PRESERVING_FORTUNE_BONUS)
|
||||
.apply(createBasePreservingFortuneBonusCondition())
|
||||
.conditionally(BlockStatePropertyLootCondition.builder(UBlocks.PINEAPPLE).properties(StatePredicate.Builder.create()
|
||||
.exactMatch(Properties.BLOCK_HALF, BlockHalf.TOP)
|
||||
.exactMatch(Properties.AGE_7, Properties.AGE_7_MAX))))
|
||||
|
@ -192,8 +207,8 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
addDrop(UBlocks.ROCKS, applyExplosionDecay(UBlocks.ROCKS, LootTable.builder()
|
||||
.pool(applyStateCondition(UBlocks.ROCKS, Properties.AGE_7, Properties.AGE_7_MAX, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(UItems.WEIRD_ROCK).conditionally(RandomChanceLootCondition.builder(0.25F)).apply(CROPS_FORTUNE_BONUS))
|
||||
.with(ItemEntry.builder(UItems.ROCK).apply(CROPS_FORTUNE_BONUS))))
|
||||
.with(ItemEntry.builder(UItems.WEIRD_ROCK).conditionally(RandomChanceLootCondition.builder(0.25F)).apply(createCropsFortuneBonusCondition()))
|
||||
.with(ItemEntry.builder(UItems.ROCK).apply(createCropsFortuneBonusCondition()))))
|
||||
.pool(LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(UItems.PEBBLES)))
|
||||
|
@ -201,7 +216,7 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
addDrop(UBlocks.GOLD_ROOT, applyExplosionDecay(UBlocks.GOLD_ROOT, LootTable.builder()
|
||||
.pool(LootPool.builder().with(ItemEntry.builder(Items.GOLDEN_CARROT)))
|
||||
.pool(applyStateCondition(UBlocks.GOLD_ROOT, CarrotsBlock.AGE, 7, LootPool.builder())
|
||||
.with(ItemEntry.builder(Items.GOLDEN_CARROT).apply(CROPS_FORTUNE_BONUS)))));
|
||||
.with(ItemEntry.builder(Items.GOLDEN_CARROT).apply(createCropsFortuneBonusCondition())))));
|
||||
/*
|
||||
addDrop(UBlocks.PLUNDER_VINE, applyExplosionDecay(UBlocks.PLUNDER_VINE, LootTable.builder()
|
||||
.pool(LootPool.builder().rolls(exactly(1)).conditionally(RandomChanceLootCondition.builder(0.25F))
|
||||
|
@ -219,9 +234,9 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
addDrop(UBlocks.SCALLOP_SHELL, shellDrops(UBlocks.SCALLOP_SHELL, UItems.SCALLOP_SHELL));
|
||||
addDrop(UBlocks.TURRET_SHELL, shellDrops(UBlocks.TURRET_SHELL, UItems.TURRET_SHELL));
|
||||
|
||||
var farmersDelightGenerator = withConditions(DefaultResourceConditions.allModsLoaded("farmersdelight"));
|
||||
farmersDelightGenerator.addDrop(Datagen.getOrCreateBaleBlock(Unicopia.id("rice_block")), b -> edibleBlockDrops(b, Datagen.getOrCreateItem(new Identifier("farmersdelight", "rice_panicle"))));
|
||||
farmersDelightGenerator.addDrop(Datagen.getOrCreateBaleBlock(Unicopia.id("straw_block")), b -> edibleBlockDrops(b, Datagen.getOrCreateItem(new Identifier("farmersdelight", "straw"))));
|
||||
var farmersDelightGenerator = withConditions(ResourceConditions.allModsLoaded("farmersdelight"));
|
||||
farmersDelightGenerator.addDrop(Datagen.getOrCreateBaleBlock(Unicopia.id("rice_block")), b -> edibleBlockDrops(b, Datagen.getOrCreateItem(Identifier.of("farmersdelight", "rice_panicle"))));
|
||||
farmersDelightGenerator.addDrop(Datagen.getOrCreateBaleBlock(Unicopia.id("straw_block")), b -> edibleBlockDrops(b, Datagen.getOrCreateItem(Identifier.of("farmersdelight", "straw"))));
|
||||
}
|
||||
|
||||
private void addTallCropDrops(SegmentedCropBlock baseCrop, ItemConvertible crop) {
|
||||
|
@ -231,7 +246,7 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
.with(ItemEntry.builder(baseCrop.getSeedsItem()))))
|
||||
.pool(applyStateCondition(baseCrop, baseCrop.getAgeProperty(), baseCrop.getMaxAge(), LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(baseCrop.getSeedsItem()).apply(CROPS_FORTUNE_BONUS)))));
|
||||
.with(ItemEntry.builder(baseCrop.getSeedsItem()).apply(createCropsFortuneBonusCondition())))));
|
||||
|
||||
SegmentedCropBlock stage = baseCrop;
|
||||
while ((stage = stage.getNext()) != null) {
|
||||
|
@ -254,20 +269,20 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
return LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(leaves).conditionally(WITH_SILK_TOUCH_OR_SHEARS)))
|
||||
.with(ItemEntry.builder(leaves).conditionally(createWithShearsOrSilkTouchCondition())))
|
||||
.pool(applyExplosionDecay(leaves, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.conditionally(WITHOUT_SILK_TOUCH_NOR_SHEARS)
|
||||
.with(item(Items.STICK, between(1, 2)).conditionally(TableBonusLootCondition.builder(Enchantments.FORTUNE, LEAVES_STICK_DROP_CHANCE)))));
|
||||
.conditionally(createWithoutShearsOrSilkTouchCondition())
|
||||
.with(item(Items.STICK, between(1, 2)).conditionally(TableBonusLootCondition.builder(entryOf(Enchantments.FORTUNE), LEAVES_STICK_DROP_CHANCE)))));
|
||||
}
|
||||
|
||||
private LootTable.Builder hullDrops(Block hull, ItemConvertible inner, ItemConvertible outer) {
|
||||
return LootTable.builder()
|
||||
.pool(addSurvivesExplosionCondition(hull, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(item(hull, exactly(2)).conditionally(WITHOUT_SILK_TOUCH))
|
||||
.with(item(inner, exactly(2)).conditionally(WITHOUT_SILK_TOUCH))
|
||||
.with(item(outer, exactly(2)).conditionally(WITH_SILK_TOUCH))));
|
||||
.with(item(hull, exactly(2)).conditionally(createWithoutSilkTouchCondition()))
|
||||
.with(item(inner, exactly(2)).conditionally(createWithoutSilkTouchCondition()))
|
||||
.with(item(outer, exactly(2)).conditionally(createSilkTouchCondition()))));
|
||||
}
|
||||
|
||||
private LootTable.Builder edibleBlockDrops(Block block, ItemConvertible drop) {
|
||||
|
@ -284,7 +299,7 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
private LootTable.Builder pieDrops(Block block, Item drop, Item stomped) {
|
||||
return LootTable.builder()
|
||||
.pool(applyExplosionDecay(block, LootPool.builder()
|
||||
.rolls(exactly(1)).conditionally(WITH_SILK_TOUCH)
|
||||
.rolls(exactly(1)).conditionally(createSilkTouchCondition())
|
||||
.with(applyStateCondition(block, PieBlock.STOMPED, false, ItemEntry.builder(drop)))
|
||||
.with(applyStateCondition(block, PieBlock.STOMPED, true, ItemEntry.builder(stomped)))));
|
||||
}
|
||||
|
@ -295,14 +310,14 @@ public class UBlockLootTableProvider extends FabricBlockLootTableProvider {
|
|||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(shell))
|
||||
.apply(ShellsBlock.COUNT.getValues(), count -> applyStateCondition(block, ShellsBlock.COUNT, count, SetCountLootFunction.builder(exactly(count))))
|
||||
.apply(BASE_PRESERVING_FORTUNE_BONUS)));
|
||||
.apply(createBasePreservingFortuneBonusCondition())));
|
||||
}
|
||||
|
||||
|
||||
public LootTable.Builder fortuneBonusDrops(ItemConvertible drop) {
|
||||
return LootTable.builder().pool(addSurvivesExplosionCondition(drop, LootPool.builder()
|
||||
.rolls(exactly(1))
|
||||
.with(ItemEntry.builder(drop).apply(BASE_PRESERVING_FORTUNE_BONUS))));
|
||||
.with(ItemEntry.builder(drop).apply(createBasePreservingFortuneBonusCondition()))));
|
||||
}
|
||||
|
||||
public static ConstantLootNumberProvider exactly(float n) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.minelittlepony.unicopia.datagen.providers.loot;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
import com.minelittlepony.unicopia.UConventionalTags;
|
||||
|
@ -18,12 +19,15 @@ import net.minecraft.loot.entry.TagEntry;
|
|||
import net.minecraft.loot.function.SetCountLootFunction;
|
||||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.registry.RegistryWrapper;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class UChestAdditionsLootTableProvider extends SimpleFabricLootTableProvider {
|
||||
|
||||
public UChestAdditionsLootTableProvider(FabricDataOutput dataOutput) {
|
||||
super(dataOutput, LootContextTypes.CHEST);
|
||||
public UChestAdditionsLootTableProvider(FabricDataOutput dataOutput, CompletableFuture<RegistryWrapper.WrapperLookup> registryLookup) {
|
||||
super(dataOutput, registryLookup, LootContextTypes.CHEST);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,11 +36,11 @@ public class UChestAdditionsLootTableProvider extends SimpleFabricLootTableProvi
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(BiConsumer<Identifier, Builder> exporter) {
|
||||
acceptAdditions((id, builder) -> exporter.accept(new Identifier("unicopiamc", id.getPath()), builder));
|
||||
public void accept(BiConsumer<RegistryKey<LootTable>, LootTable.Builder> exporter) {
|
||||
acceptAdditions((id, builder) -> exporter.accept(RegistryKey.of(RegistryKeys.LOOT_TABLE, Identifier.of("unicopiamc", id.getValue().getPath())), builder));
|
||||
}
|
||||
|
||||
public void acceptAdditions(BiConsumer<Identifier, Builder> exporter) {
|
||||
public void acceptAdditions(BiConsumer<RegistryKey<LootTable>, Builder> exporter) {
|
||||
exporter.accept(LootTables.ABANDONED_MINESHAFT_CHEST, LootTable.builder().pool(LootPool.builder()
|
||||
.rolls(UniformLootNumberProvider.create(2, 4))
|
||||
.with(ItemEntry.builder(UItems.GRYPHON_FEATHER).weight(2).apply(SetCountLootFunction.builder(UniformLootNumberProvider.create(1, 4))))
|
||||
|
|
|
@ -18,6 +18,8 @@ import net.minecraft.loot.function.SetPotionLootFunction;
|
|||
import net.minecraft.loot.provider.number.ConstantLootNumberProvider;
|
||||
import net.minecraft.loot.provider.number.UniformLootNumberProvider;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.registry.RegistryKey;
|
||||
import net.minecraft.registry.RegistryKeys;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class UChestLootTableProvider extends SimpleFabricLootTableProvider {
|
||||
|
@ -26,8 +28,8 @@ public class UChestLootTableProvider extends SimpleFabricLootTableProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void accept(BiConsumer<Identifier, Builder> exporter) {
|
||||
exporter.accept(Unicopia.id("chests/changeling_hive_trap"), LootTable.builder()
|
||||
public void accept(BiConsumer<RegistryKey<LootTable>, Builder> exporter) {
|
||||
exporter.accept(RegistryKey.of(RegistryKeys.LOOT_TABLE, Unicopia.id("chests/changeling_hive_trap")), LootTable.builder()
|
||||
.pool(LootPool.builder()
|
||||
.rolls(ConstantLootNumberProvider.create(6))
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ import net.minecraft.world.WorldEvents;
|
|||
public class CorruptInfluenceStatusEffect extends StatusEffect {
|
||||
CorruptInfluenceStatusEffect(int color) {
|
||||
super(StatusEffectCategory.NEUTRAL, color);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 15, EntityAttributeModifier.Operation.ADDITION);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 10, EntityAttributeModifier.Operation.ADDITION);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_DAMAGE, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 15, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
addAttributeModifier(EntityAttributes.GENERIC_ATTACK_SPEED, "6D706448-6A60-4F59-BE8A-C23A6DD2C7A9", 10, EntityAttributeModifier.Operation.ADD_VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,11 +81,11 @@ public class CorruptInfluenceStatusEffect extends StatusEffect {
|
|||
float maxHealthDifference = mob.getMaxHealth() - clone.getMaxHealth();
|
||||
clone.addStatusEffect(new StatusEffectInstance(StatusEffects.STRENGTH, 900000, 2));
|
||||
clone.getAttributeInstance(EntityAttributes.GENERIC_MAX_HEALTH)
|
||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Strength Modifier", maxHealthDifference + 1, EntityAttributeModifier.Operation.ADDITION));
|
||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Strength Modifier", maxHealthDifference + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||
}
|
||||
if (clone.getAttributes().hasAttribute(EntityAttributes.GENERIC_ATTACK_DAMAGE)) {
|
||||
clone.getAttributeInstance(EntityAttributes.GENERIC_ATTACK_DAMAGE)
|
||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Damage Modifier", mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADDITION));
|
||||
.addPersistentModifier(new EntityAttributeModifier(UUID.randomUUID(), "Corruption Damage Modifier", mob.getAttributeValue(EntityAttributes.GENERIC_ATTACK_DAMAGE) + 1, EntityAttributeModifier.Operation.ADD_VALUE));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -11,34 +11,36 @@ import net.minecraft.entity.effect.StatusEffect;
|
|||
import net.minecraft.entity.effect.StatusEffectCategory;
|
||||
import net.minecraft.registry.Registries;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
public class MetamorphosisStatusEffect extends StatusEffect {
|
||||
public static final int MAX_DURATION = 20 * 60;
|
||||
|
||||
private static final Map<Race, StatusEffect> REGISTRY = new HashMap<>();
|
||||
private static final Map<Race, RegistryEntry<StatusEffect>> REGISTRY = new HashMap<>();
|
||||
|
||||
public static final StatusEffect EARTH = register(0x886F0F, Race.EARTH);
|
||||
public static final StatusEffect UNICORN = register(0x88FFFF, Race.UNICORN);
|
||||
public static final StatusEffect PEGASUS = register(0x00C0ff, Race.PEGASUS);
|
||||
public static final StatusEffect BAT = register(0x152F13, Race.BAT);
|
||||
public static final StatusEffect CHANGELING = register(0xFFFF00, Race.CHANGELING);
|
||||
public static final StatusEffect KIRIN = register(0xFF8800, Race.KIRIN);
|
||||
public static final StatusEffect HIPPOGRIFF = register(0xE04F77, Race.HIPPOGRIFF);
|
||||
public static final RegistryEntry<StatusEffect> EARTH = register(0x886F0F, Race.EARTH);
|
||||
public static final RegistryEntry<StatusEffect> UNICORN = register(0x88FFFF, Race.UNICORN);
|
||||
public static final RegistryEntry<StatusEffect> PEGASUS = register(0x00C0ff, Race.PEGASUS);
|
||||
public static final RegistryEntry<StatusEffect> BAT = register(0x152F13, Race.BAT);
|
||||
public static final RegistryEntry<StatusEffect> CHANGELING = register(0xFFFF00, Race.CHANGELING);
|
||||
public static final RegistryEntry<StatusEffect> KIRIN = register(0xFF8800, Race.KIRIN);
|
||||
public static final RegistryEntry<StatusEffect> HIPPOGRIFF = register(0xE04F77, Race.HIPPOGRIFF);
|
||||
|
||||
@Nullable
|
||||
public static StatusEffect forRace(Race race) {
|
||||
public static RegistryEntry<StatusEffect> forRace(Race race) {
|
||||
return REGISTRY.get(race);
|
||||
}
|
||||
|
||||
public static StatusEffect register(int color, Race race) {
|
||||
public static RegistryEntry<StatusEffect> register(int color, Race race) {
|
||||
Identifier id = Race.REGISTRY.getId(race);
|
||||
StatusEffect effect = new MetamorphosisStatusEffect(color, race);
|
||||
REGISTRY.put(race, effect);
|
||||
return Registry.register(Registries.STATUS_EFFECT,
|
||||
var reference = Registry.registerReference(Registries.STATUS_EFFECT,
|
||||
id.withPath(p -> "morph_race_" + p),
|
||||
effect
|
||||
);
|
||||
REGISTRY.put(race, reference);
|
||||
return reference;
|
||||
}
|
||||
|
||||
public static Race getEffectiveRace(LivingEntity entity, Race fallback) {
|
||||
|
|
|
@ -25,34 +25,39 @@ import net.minecraft.text.Text;
|
|||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.world.World.ExplosionSourceType;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.registry.Registries;
|
||||
|
||||
public class RaceChangeStatusEffect extends StatusEffect {
|
||||
public static final int STAGE_DURATION = 200;
|
||||
public static final int MAX_DURATION = Stage.VALUES.length * STAGE_DURATION + 1;
|
||||
|
||||
private static final Map<Race, StatusEffect> REGISTRY = new HashMap<>();
|
||||
private static final Map<Race, RegistryEntry<StatusEffect>> REGISTRY = new HashMap<>();
|
||||
|
||||
@Nullable
|
||||
public static StatusEffect forRace(Race race) {
|
||||
public static RegistryEntry<StatusEffect> forRace(Race race) {
|
||||
return REGISTRY.get(race);
|
||||
}
|
||||
|
||||
public static final StatusEffect EARTH = register(0x886F0F, Race.EARTH);
|
||||
public static final StatusEffect UNICORN = register(0x88FFFF, Race.UNICORN);
|
||||
public static final StatusEffect PEGASUS = register(0x00C0ff, Race.PEGASUS);
|
||||
public static final StatusEffect BAT = register(0x152F13, Race.BAT);
|
||||
public static final StatusEffect CHANGELING = register(0xFFFF00, Race.CHANGELING);
|
||||
public static final StatusEffect KIRIN = register(0xFF8800, Race.KIRIN);
|
||||
public static final StatusEffect HIPPOGRIFF = register(0xE04F77, Race.HIPPOGRIFF);
|
||||
public static final RegistryEntry<StatusEffect> EARTH = register(0x886F0F, Race.EARTH);
|
||||
public static final RegistryEntry<StatusEffect> UNICORN = register(0x88FFFF, Race.UNICORN);
|
||||
public static final RegistryEntry<StatusEffect> PEGASUS = register(0x00C0ff, Race.PEGASUS);
|
||||
public static final RegistryEntry<StatusEffect> BAT = register(0x152F13, Race.BAT);
|
||||
public static final RegistryEntry<StatusEffect> CHANGELING = register(0xFFFF00, Race.CHANGELING);
|
||||
public static final RegistryEntry<StatusEffect> KIRIN = register(0xFF8800, Race.KIRIN);
|
||||
public static final RegistryEntry<StatusEffect> HIPPOGRIFF = register(0xE04F77, Race.HIPPOGRIFF);
|
||||
|
||||
private final Race race;
|
||||
|
||||
public static StatusEffect register(int color, Race race) {
|
||||
public static RegistryEntry<StatusEffect> register(int color, Race race) {
|
||||
Identifier id = race.getId();
|
||||
StatusEffect effect = new RaceChangeStatusEffect(color, race);
|
||||
REGISTRY.put(race, effect);
|
||||
return Registry.register(Registries.STATUS_EFFECT, id.withPath(p -> "change_race_" + id.getPath()), effect);
|
||||
var reference = Registry.registerReference(
|
||||
Registries.STATUS_EFFECT,
|
||||
id.withPath(p -> "change_race_" + id.getPath()),
|
||||
new RaceChangeStatusEffect(color, race)
|
||||
);
|
||||
REGISTRY.put(race, reference);
|
||||
return reference;
|
||||
}
|
||||
|
||||
private RaceChangeStatusEffect(int color, Race race) {
|
||||
|
@ -64,28 +69,23 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
return race;
|
||||
}
|
||||
|
||||
private void removeEffect(LivingEntity entity) {
|
||||
entity.removeStatusEffect(this);
|
||||
resetTicks(entity);
|
||||
}
|
||||
|
||||
private void resetTicks(LivingEntity entity) {
|
||||
Pony.of(entity).ifPresent(pony -> pony.setTicksmetamorphising(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
StatusEffectInstance state = entity.getStatusEffect(this);
|
||||
public boolean applyUpdateEffect(LivingEntity entity, int amplifier) {
|
||||
StatusEffectInstance state = entity.getStatusEffect(forRace(race));
|
||||
|
||||
if (state == null || entity.isDead()) {
|
||||
resetTicks(entity);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
Equine<?> eq = Equine.of(entity).orElse(null);
|
||||
|
||||
if (eq == null) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
int metaTicks = 0;
|
||||
|
@ -100,7 +100,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
Stage stage = Stage.forDuration(ticks / STAGE_DURATION);
|
||||
|
||||
if (stage == Stage.INITIAL) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
int progression = ticks % (stage.ordinal() * STAGE_DURATION);
|
||||
|
@ -109,8 +109,7 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
if (progression == 0 && entity instanceof PlayerEntity player && stage == Stage.CRAWLING) {
|
||||
player.sendMessage(Stage.INITIAL.getMessage(race), true);
|
||||
}
|
||||
removeEffect(entity);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (progression == 0 && stage != Stage.DEATH && entity instanceof PlayerEntity player) {
|
||||
|
@ -133,8 +132,6 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
}
|
||||
|
||||
if (stage == Stage.DEATH) {
|
||||
removeEffect(entity);
|
||||
|
||||
if (eq instanceof Caster) {
|
||||
((Caster<?>)eq).getSpellSlot().clear();
|
||||
}
|
||||
|
@ -172,7 +169,11 @@ public class RaceChangeStatusEffect extends StatusEffect {
|
|||
eq.setSpecies(race);
|
||||
entity.getWorld().createExplosion(entity, null, ExplosionUtil.NON_DESTRUCTIVE, entity.getPos(), 5, true, ExplosionSourceType.MOB);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,20 +2,19 @@ package com.minelittlepony.unicopia.entity.effect;
|
|||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.spongepowered.include.com.google.common.base.Preconditions;
|
||||
|
||||
import com.minelittlepony.unicopia.Race;
|
||||
import com.minelittlepony.unicopia.Unicopia;
|
||||
import com.minelittlepony.unicopia.item.UItems;
|
||||
|
||||
import net.fabricmc.fabric.api.registry.FabricBrewingRecipeRegistryBuilder;
|
||||
import net.minecraft.entity.effect.StatusEffect;
|
||||
import net.minecraft.entity.effect.StatusEffectInstance;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.Potions;
|
||||
import net.minecraft.recipe.BrewingRecipeRegistry;
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.registry.entry.RegistryEntry;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.registry.Registries;
|
||||
|
||||
|
@ -28,22 +27,25 @@ public interface UPotions {
|
|||
MorphingPotion MORPH_KIRIN = new MorphingPotion(Race.KIRIN).registerBaseRecipes(Potions.FIRE_RESISTANCE, Items.MAGMA_CREAM);
|
||||
MorphingPotion MORPH_HIPPOGRIFF = new MorphingPotion(Race.HIPPOGRIFF).registerBaseRecipes(Potions.WATER_BREATHING, UItems.CLAM_SHELL, UItems.TURRET_SHELL, UItems.SCALLOP_SHELL);
|
||||
|
||||
static Potion register(String name, Potion potion) {
|
||||
static RegistryEntry<Potion> register(String name, Potion potion) {
|
||||
return register(Unicopia.id(name), potion);
|
||||
}
|
||||
|
||||
static Potion register(Identifier id, Potion potion) {
|
||||
return Registry.register(Registries.POTION, id, potion);
|
||||
static RegistryEntry<Potion> register(Identifier id, Potion potion) {
|
||||
return Registry.registerReference(Registries.POTION, id, potion);
|
||||
}
|
||||
|
||||
static void addRecipe(Potion result, Potion basePotion, Item...items) {
|
||||
Preconditions.checkArgument(BrewingRecipeRegistry.isBrewable(basePotion), "Base potion is not craftable. " + Registries.POTION.getId(basePotion) + " required for crafting " + Registries.POTION.getId(result));
|
||||
for (Item item : items) {
|
||||
BrewingRecipeRegistry.registerPotionRecipe(basePotion, item, result);
|
||||
}
|
||||
static void addRecipe(RegistryEntry<Potion> result, RegistryEntry<Potion> basePotion, Item...items) {
|
||||
FabricBrewingRecipeRegistryBuilder.BUILD.register(registry -> {
|
||||
//Preconditions.checkArgument(BrewingRecipeRegistry.isBrewable(basePotion), "Base potion is not craftable. " + basePotion.getIdAsString() + " required for crafting " + result.getIdAsString());
|
||||
for (Item item : items) {
|
||||
registry.registerPotionRecipe(basePotion, item, result);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
record MorphingPotion(Identifier id, Potion shortEffect, Potion longEffect, Potion permanentEffect) {
|
||||
record MorphingPotion(Identifier id, RegistryEntry<Potion> shortEffect, RegistryEntry<Potion> longEffect, RegistryEntry<Potion> permanentEffect) {
|
||||
public MorphingPotion(Race race) {
|
||||
this(race.getId(),
|
||||
Objects.requireNonNull(MetamorphosisStatusEffect.forRace(race), "No metamorphosis status effect registered for " + race.getId()),
|
||||
|
@ -51,7 +53,7 @@ public interface UPotions {
|
|||
);
|
||||
}
|
||||
|
||||
public MorphingPotion(Identifier id, StatusEffect morphEffect, StatusEffect permanentEffect) {
|
||||
public MorphingPotion(Identifier id, RegistryEntry<StatusEffect> morphEffect, RegistryEntry<StatusEffect> permanentEffect) {
|
||||
this(id,
|
||||
register(id.withPath(p -> "short_morph_" + p), new Potion(id.getNamespace() + ".short_morph_" + id.getPath(), new StatusEffectInstance(morphEffect, MetamorphosisStatusEffect.MAX_DURATION))),
|
||||
register(id.withPath(p -> "long_morph_" + p), new Potion(id.getNamespace() + ".long_morph_" + id.getPath(), new StatusEffectInstance(morphEffect, MetamorphosisStatusEffect.MAX_DURATION * 10))),
|
||||
|
@ -59,7 +61,7 @@ public interface UPotions {
|
|||
);
|
||||
}
|
||||
|
||||
public MorphingPotion registerBaseRecipes(Potion basePotion, Item...items) {
|
||||
public MorphingPotion registerBaseRecipes(RegistryEntry<Potion> basePotion, Item...items) {
|
||||
addRecipe(shortEffect, basePotion, items);
|
||||
addRecipe(longEffect, shortEffect, Items.REDSTONE);
|
||||
addRecipe(permanentEffect, longEffect, UItems.CURING_JOKE);
|
||||
|
|
|
@ -352,7 +352,7 @@ public class IgnominiousBulbEntity extends MobEntity {
|
|||
var tentacles = new HashMap<BlockPos, EntityReference<TentacleEntity>>();
|
||||
nbt.getList("tentacles", NbtElement.COMPOUND_TYPE).forEach(tag -> {
|
||||
var compound = (NbtCompound)tag;
|
||||
tentacles.put(NbtSerialisable.BLOCK_POS.read(compound.getCompound("pos")), new EntityReference<>(compound.getCompound("target")));
|
||||
tentacles.put(NbtSerialisable.BLOCK_POS.read(compound.getCompound("pos"), getWorld().getRegistryManager()), new EntityReference<>(compound.getCompound("target"), getWorld().getRegistryManager()));
|
||||
});
|
||||
this.tentacles = tentacles;
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ public class SpecterEntity extends HostileEntity {
|
|||
super.tick();
|
||||
|
||||
if (getTarget() != null) {
|
||||
ParticleUtils.spawnParticles(ParticleTypes.AMBIENT_ENTITY_EFFECT, this, 6);
|
||||
ParticleUtils.spawnParticles(ParticleTypes.EFFECT, this, 6);
|
||||
|
||||
if (getWorld().getGameRules().getBoolean(GameRules.DO_MOB_GRIEFING)) {
|
||||
if (getWorld().getBlockState(getBlockPos()).isIn(BlockTags.REPLACEABLE_BY_TREES)) {
|
||||
|
|
|
@ -321,7 +321,7 @@ public class TentacleEntity extends AbstractDecorationEntity {
|
|||
@Override
|
||||
protected void updateAttachmentPosition() {
|
||||
visibilityBox = null;
|
||||
Vec3d pos = attachmentPos.toCenterPos();
|
||||
Vec3d pos = attachedBlockPos.toCenterPos();
|
||||
setPos(pos.x, pos.y, pos.z);
|
||||
setBoundingBox(Box.of(pos, 1, 1, 1).stretch(0, 2, 0));
|
||||
}
|
||||
|
|
|
@ -107,10 +107,10 @@ public interface UItems {
|
|||
Item PEBBLES = register("pebbles", new AliasedBlockItem(UBlocks.ROCKS, new Item.Settings()), ItemGroups.NATURAL);
|
||||
Item ROCK = register("rock", new HeavyProjectileItem(new Item.Settings(), 3), ItemGroups.NATURAL);
|
||||
Item WEIRD_ROCK = register("weird_rock", new BluntWeaponItem(new Item.Settings(), ImmutableMultimap.of(
|
||||
EntityAttributes.GENERIC_LUCK, new EntityAttributeModifier(BluntWeaponItem.LUCK_MODIFIER_ID, "Weapon modifier", 9, EntityAttributeModifier.Operation.ADDITION)
|
||||
EntityAttributes.GENERIC_LUCK, new EntityAttributeModifier(BluntWeaponItem.LUCK_MODIFIER_ID, "Weapon modifier", 9, EntityAttributeModifier.Operation.ADD_VALUE)
|
||||
)), ItemGroups.NATURAL);
|
||||
Item TOM = register("tom", new BluntWeaponItem(new Item.Settings(), ImmutableMultimap.of(
|
||||
EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(BluntWeaponItem.KNOCKBACK_MODIFIER_ID, "Weapon modifier", 0.9, EntityAttributeModifier.Operation.ADDITION)
|
||||
EntityAttributes.GENERIC_KNOCKBACK_RESISTANCE, new EntityAttributeModifier(BluntWeaponItem.KNOCKBACK_MODIFIER_ID, "Weapon modifier", 0.9, EntityAttributeModifier.Operation.ADD_VALUE)
|
||||
)), ItemGroups.NATURAL);
|
||||
Item ROCK_STEW = register("rock_stew", new StewItem(new Item.Settings().food(FoodComponents.MUSHROOM_STEW).maxCount(1).recipeRemainder(Items.BOWL)), ItemGroups.FOOD_AND_DRINK);
|
||||
Item ROCK_CANDY = register("rock_candy", new Item(new Item.Settings().food(UFoodComponents.CANDY).maxCount(16)), ItemGroups.FOOD_AND_DRINK);
|
||||
|
|
|
@ -12,6 +12,8 @@ import net.minecraft.entity.attribute.EntityAttribute;
|
|||
import net.minecraft.entity.attribute.EntityAttributeInstance;
|
||||
import net.minecraft.entity.attribute.EntityAttributeModifier;
|
||||
|
||||
// TODO: Replaced with EnchantmentEffectComponentTypes.ATTRIBUTES
|
||||
@Deprecated
|
||||
public class AttributedEnchantment extends SimpleEnchantment {
|
||||
|
||||
private final Map<EntityAttribute, ModifierFactory> modifiers = new HashMap<>();
|
||||
|
|
|
@ -23,7 +23,7 @@ public class CollaboratorEnchantment extends AttributedEnchantment {
|
|||
}
|
||||
|
||||
private EntityAttributeModifier getModifier(Living<?> user, int level) {
|
||||
return new EntityAttributeModifier(TEAM_STRENGTH_UUID, "Team Strength", user.getEnchants().computeIfAbsent(this, Data::new).level / 2, Operation.ADDITION);
|
||||
return new EntityAttributeModifier(TEAM_STRENGTH_UUID, "Team Strength", user.getEnchants().computeIfAbsent(this, Data::new).level / 2, Operation.ADD_VALUE);
|
||||
}
|
||||
|
||||
private int getTeamCollectiveLevel(Living<?> user, int radius) {
|
||||
|
|
|
@ -3,10 +3,10 @@ package com.minelittlepony.unicopia.item.enchantment;
|
|||
import com.minelittlepony.unicopia.entity.Living;
|
||||
|
||||
import net.minecraft.enchantment.Enchantment;
|
||||
import net.minecraft.enchantment.EnchantmentTarget;
|
||||
import net.minecraft.entity.EquipmentSlot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@Deprecated
|
||||
public class SimpleEnchantment extends Enchantment {
|
||||
|
||||
private final Options options;
|
||||
|
|
Loading…
Reference in a new issue