From 9761fbcd03048d82d9f4e56a2d2df51527a5a6f0 Mon Sep 17 00:00:00 2001 From: derican Date: Fri, 22 Apr 2022 23:17:44 +0800 Subject: [PATCH] remove Witchskall to be compatible --- build.gradle | 2 +- .../iskallia/vault/easteregg/Witchskall.java | 130 ------------------ .../java/iskallia/vault/init/ModSounds.java | 2 - .../vault/mixin/MixinWitchEntity.java | 38 ----- .../vault/mixin/MixinWitchRenderer.java | 27 ---- .../vault/util/data/WeightedList.java | 14 ++ .../gen/structure/VaultJigsawHelper.java | 2 + .../resources/assets/the_vault/sounds.json | 17 --- .../assets/the_vault/the_vault.mixins.json | 6 +- .../processor_list/lakes/hanging_large.json | 13 -- .../processor_list/pirate_cove/pallet4.json | 16 --- .../processor_list/treasure/pallet4.json | 21 --- .../processor_list/treasure/pallet5.json | 13 -- .../processor_list/treasure/pallet9.json | 32 ----- .../processor_list/tunnels/pallet7.json | 16 --- .../processor_list/wildwest/pallet1.json | 49 ------- 16 files changed, 19 insertions(+), 379 deletions(-) delete mode 100644 src/main/java/iskallia/vault/easteregg/Witchskall.java delete mode 100644 src/main/java/iskallia/vault/mixin/MixinWitchEntity.java delete mode 100644 src/main/java/iskallia/vault/mixin/MixinWitchRenderer.java diff --git a/build.gradle b/build.gradle index 5621bdc0..08bf496c 100644 --- a/build.gradle +++ b/build.gradle @@ -134,7 +134,7 @@ dependencies { // Specify the version of Minecraft to use, If this is any group other then 'net.minecraft' it is assumed // that the dep is a ForgeGradle 'patcher' dependency. And it's patches will be applied. // The userdev artifact is a special name and will get all sorts of transformations applied to it. - minecraft 'net.minecraftforge:forge:1.16.5-36.2.20' + minecraft 'net.minecraftforge:forge:1.16.5-36.2.34' annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' // You may put jars on which you depend on in ./libs or you may define them like so.. diff --git a/src/main/java/iskallia/vault/easteregg/Witchskall.java b/src/main/java/iskallia/vault/easteregg/Witchskall.java deleted file mode 100644 index 801b8d7f..00000000 --- a/src/main/java/iskallia/vault/easteregg/Witchskall.java +++ /dev/null @@ -1,130 +0,0 @@ -package iskallia.vault.easteregg; - -import iskallia.vault.Vault; -import iskallia.vault.init.ModItems; -import iskallia.vault.init.ModModels; -import iskallia.vault.init.ModParticles; -import iskallia.vault.init.ModSounds; -import iskallia.vault.item.gear.VaultGear; -import iskallia.vault.util.AdvancementHelper; -import iskallia.vault.util.GearItemStackBuilder; -import net.minecraft.entity.Entity; -import net.minecraft.entity.LivingEntity; -import net.minecraft.entity.item.ItemEntity; -import net.minecraft.entity.monster.WitchEntity; -import net.minecraft.entity.player.PlayerEntity; -import net.minecraft.entity.player.ServerPlayerEntity; -import net.minecraft.item.Item; -import net.minecraft.item.ItemStack; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.particles.IParticleData; -import net.minecraft.util.SoundCategory; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.world.World; -import net.minecraft.world.server.ServerWorld; -import net.minecraftforge.event.entity.living.LivingDeathEvent; -import net.minecraftforge.event.entity.living.LivingDropsEvent; -import net.minecraftforge.event.entity.living.LivingEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -import java.util.Random; - -@Mod.EventBusSubscriber -public class Witchskall { - public static final float WITCHSKALL_CHANCE = 0.001f; - public static final int WITCHSKALLIFICATION_TICKS = 100; - public static DataParameter WITCHSKALL_TICKS; - public static DataParameter IS_WITCHSKALL; - - public static int getWitchskallificationTicks(final WitchEntity witchEntity) { - return (int) witchEntity.getEntityData().get((DataParameter) Witchskall.WITCHSKALL_TICKS); - } - - public static boolean isWitchskall(final WitchEntity witchEntity) { - return (boolean) witchEntity.getEntityData().get((DataParameter) Witchskall.IS_WITCHSKALL); - } - - public static int setWitchskallificationTicks(final WitchEntity witchEntity, final int ticks) { - witchEntity.getEntityData().set((DataParameter) Witchskall.WITCHSKALL_TICKS, ticks); - return ticks; - } - - public static void witchskallificate(final WitchEntity witchEntity) { - setWitchskallificationTicks(witchEntity, 0); - witchEntity.getEntityData().set((DataParameter) Witchskall.IS_WITCHSKALL, true); - witchEntity.setCustomName((ITextComponent) new StringTextComponent("Witchskall")); - } - - @SubscribeEvent - public static void onWitchTick(final LivingEvent.LivingUpdateEvent event) { - final LivingEntity entity = event.getEntityLiving(); - final World world = entity.level; - if (world.isClientSide) { - return; - } - if (!(entity instanceof WitchEntity)) { - return; - } - final WitchEntity witchEntity = (WitchEntity) entity; - if (isWitchskall(witchEntity)) { - return; - } - final int witchskallTicks = getWitchskallificationTicks(witchEntity); - if (witchskallTicks == 0) { - return; - } - if (witchskallTicks <= -1) { - if (new Random().nextFloat() <= 0.001f) { - setWitchskallificationTicks(witchEntity, 100); - } else { - setWitchskallificationTicks(witchEntity, 0); - } - return; - } - final int setWitchskallTicks = setWitchskallificationTicks(witchEntity, witchskallTicks - 1); - if (setWitchskallTicks == 0) { - final ServerWorld serverWorld = (ServerWorld) world; - serverWorld.sendParticles((IParticleData) ModParticles.GREEN_FLAME.get(), entity.getX(), entity.getY(), entity.getZ(), 100, 0.5, 1.0, 0.5, 0.1); - serverWorld.playSound((PlayerEntity) null, entity.getX(), entity.getY(), entity.getZ(), ModSounds.WITCHSKALL_IDLE, SoundCategory.MASTER, 1.1f, 1.0f); - witchskallificate(witchEntity); - } - } - - @SubscribeEvent - public static void onWitchskallDeath(final LivingDeathEvent event) { - final Entity entity = event.getEntity(); - if (entity.level.isClientSide()) { - return; - } - if (!(entity instanceof WitchEntity) || !isWitchskall((WitchEntity) entity)) { - return; - } - final Entity trueSource = event.getSource().getEntity(); - if (!(trueSource instanceof ServerPlayerEntity)) { - return; - } - final ServerPlayerEntity player = (ServerPlayerEntity) trueSource; - AdvancementHelper.grantCriterion(player, Vault.id("main/witchskall"), "witchskall_killed"); - } - - @SubscribeEvent - public static void onWitchskallDrops(final LivingDropsEvent event) { - final Entity entity = event.getEntity(); - if (entity.level.isClientSide()) { - return; - } - if (!(entity instanceof WitchEntity)) { - return; - } - if (!isWitchskall((WitchEntity) entity)) { - return; - } - final ServerWorld world = (ServerWorld) entity.level; - final ItemStack itemStack = new GearItemStackBuilder((Item) ModItems.HELMET).setGearRarity(VaultGear.Rarity.UNIQUE).setColor(-5384139).setSpecialModelId(ModModels.SpecialGearModel.ISKALL_HOLOLENS.getId()).build(); - final ItemEntity itemEntity = new ItemEntity((World) world, entity.getX(), entity.getY(), entity.getZ(), itemStack); - itemEntity.setDefaultPickUpDelay(); - event.getDrops().add(itemEntity); - } -} diff --git a/src/main/java/iskallia/vault/init/ModSounds.java b/src/main/java/iskallia/vault/init/ModSounds.java index 6fd814d0..b9bb8e93 100644 --- a/src/main/java/iskallia/vault/init/ModSounds.java +++ b/src/main/java/iskallia/vault/init/ModSounds.java @@ -53,7 +53,6 @@ public class ModSounds { public static SoundEvent VAULT_CHEST_EPIC_OPEN; public static SoundEvent VAULT_CHEST_OMEGA_OPEN; public static SoundEvent VAULT_CHEST_RARE_OPEN; - public static SoundEvent WITCHSKALL_IDLE; public static SoundEvent FAVOUR_UP; public static LazySoundType VAULT_GEM; @@ -104,7 +103,6 @@ public static void registerSounds(final RegistryEvent.Register event ModSounds.VAULT_CHEST_EPIC_OPEN = registerSound(event, "vault_chest_epic_open"); ModSounds.VAULT_CHEST_OMEGA_OPEN = registerSound(event, "vault_chest_omega_open"); ModSounds.VAULT_CHEST_RARE_OPEN = registerSound(event, "vault_chest_rare_open"); - ModSounds.WITCHSKALL_IDLE = registerSound(event, "witchskall_idle"); ModSounds.FAVOUR_UP = registerSound(event, "favour_up"); } diff --git a/src/main/java/iskallia/vault/mixin/MixinWitchEntity.java b/src/main/java/iskallia/vault/mixin/MixinWitchEntity.java deleted file mode 100644 index be1de557..00000000 --- a/src/main/java/iskallia/vault/mixin/MixinWitchEntity.java +++ /dev/null @@ -1,38 +0,0 @@ -package iskallia.vault.mixin; - -import iskallia.vault.easteregg.Witchskall; -import iskallia.vault.init.ModSounds; -import net.minecraft.entity.monster.WitchEntity; -import net.minecraft.network.datasync.DataParameter; -import net.minecraft.network.datasync.DataSerializers; -import net.minecraft.network.datasync.EntityDataManager; -import net.minecraft.util.SoundEvent; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin({WitchEntity.class}) -public abstract class MixinWitchEntity { - @Inject(method = {"defineSynchedData"}, at = {@At("TAIL")}) - protected void registerData(final CallbackInfo ci) { - final WitchEntity thiz = (WitchEntity) (Object) this; - if (Witchskall.WITCHSKALL_TICKS == null) { - Witchskall.WITCHSKALL_TICKS = (DataParameter) EntityDataManager.defineId((Class) WitchEntity.class, DataSerializers.INT); - } - thiz.getEntityData().define((DataParameter) Witchskall.WITCHSKALL_TICKS, (-1)); - if (Witchskall.IS_WITCHSKALL == null) { - Witchskall.IS_WITCHSKALL = (DataParameter) EntityDataManager.defineId((Class) WitchEntity.class, DataSerializers.BOOLEAN); - } - thiz.getEntityData().define((DataParameter) Witchskall.IS_WITCHSKALL, false); - } - - @Inject(method = {"getAmbientSound"}, at = {@At("HEAD")}, cancellable = true) - protected void getAmbientSound(final CallbackInfoReturnable ci) { - final WitchEntity thiz = (WitchEntity) (Object) this; - if (Witchskall.isWitchskall(thiz)) { - ci.setReturnValue(ModSounds.WITCHSKALL_IDLE); - } - } -} diff --git a/src/main/java/iskallia/vault/mixin/MixinWitchRenderer.java b/src/main/java/iskallia/vault/mixin/MixinWitchRenderer.java deleted file mode 100644 index d294800e..00000000 --- a/src/main/java/iskallia/vault/mixin/MixinWitchRenderer.java +++ /dev/null @@ -1,27 +0,0 @@ -package iskallia.vault.mixin; - -import iskallia.vault.Vault; -import iskallia.vault.easteregg.Witchskall; -import net.minecraft.client.renderer.entity.WitchRenderer; -import net.minecraft.entity.monster.WitchEntity; -import net.minecraft.util.ResourceLocation; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin({WitchRenderer.class}) -public class MixinWitchRenderer { - private static final ResourceLocation WITCHSKALL_TEXTURE; - - @Inject(method = {"getTextureLocation"}, at = {@At("HEAD")}, cancellable = true) - public void getEntityTexture(final WitchEntity entity, final CallbackInfoReturnable ci) { - if (Witchskall.isWitchskall(entity)) { - ci.setReturnValue(MixinWitchRenderer.WITCHSKALL_TEXTURE); - } - } - - static { - WITCHSKALL_TEXTURE = Vault.id("textures/entity/witchskall.png"); - } -} diff --git a/src/main/java/iskallia/vault/util/data/WeightedList.java b/src/main/java/iskallia/vault/util/data/WeightedList.java index 89def978..8ebbc7cb 100644 --- a/src/main/java/iskallia/vault/util/data/WeightedList.java +++ b/src/main/java/iskallia/vault/util/data/WeightedList.java @@ -4,6 +4,7 @@ import javax.annotation.Nullable; import java.util.*; +import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.BiConsumer; import java.util.function.Predicate; @@ -25,6 +26,19 @@ public WeightedList add(final T value, final int weight) { return this; } + public WeightedList addOne(T value){ + AtomicBoolean flag= new AtomicBoolean(false); + this.entries.forEach(tEntry -> { + if(tEntry.value==value) { + tEntry.weight += 1; + flag.set(true); + } + }); + if(!flag.get()) + this.add(new Entry<>(value,1)); + return this; + } + @Override public int size() { return this.entries.size(); diff --git a/src/main/java/iskallia/vault/world/gen/structure/VaultJigsawHelper.java b/src/main/java/iskallia/vault/world/gen/structure/VaultJigsawHelper.java index bb2f8aba..ba7929d3 100644 --- a/src/main/java/iskallia/vault/world/gen/structure/VaultJigsawHelper.java +++ b/src/main/java/iskallia/vault/world/gen/structure/VaultJigsawHelper.java @@ -171,6 +171,8 @@ private static WeightedList getRoomList(final ResourceLocation key) final JigsawPattern roomPool = getPool(key); final WeightedList pool = new WeightedList(); // roomPool.rawTemplates.forEach(weightedPiece -> pool.add(weightedPiece.getFirst(), (int) weightedPiece.getSecond())); +// TODO: check if the following overwrite is runnable + roomPool.getShuffledTemplates(rand).forEach(pool::addOne); return pool; } diff --git a/src/main/resources/assets/the_vault/sounds.json b/src/main/resources/assets/the_vault/sounds.json index df4b1afc..430ee402 100644 --- a/src/main/resources/assets/the_vault/sounds.json +++ b/src/main/resources/assets/the_vault/sounds.json @@ -118,23 +118,6 @@ "the_vault:treasure_goblin/idle_3" ] }, - "witchskall_idle": { - "category": "neutral", - "sounds": [ - { - "name": "the_vault:witchskall/idle", - "pitch": 1.00 - }, - { - "name": "the_vault:witchskall/idle", - "pitch": 0.95 - }, - { - "name": "the_vault:witchskall/idle", - "pitch": 1.05 - } - ] - }, "puzzle_completion_major": { "category": "master", "sounds": [ diff --git a/src/main/resources/assets/the_vault/the_vault.mixins.json b/src/main/resources/assets/the_vault/the_vault.mixins.json index 9f24043d..a8a59251 100644 --- a/src/main/resources/assets/the_vault/the_vault.mixins.json +++ b/src/main/resources/assets/the_vault/the_vault.mixins.json @@ -35,8 +35,7 @@ "MixinSingleJigsawPiece", "MixinSlot", "MixinStructureBlockTileEntity", - "MixinStructureProcessor", - "MixinWitchEntity" + "MixinStructureProcessor" ], "client": [ "MixinAnvilScreen", @@ -47,8 +46,7 @@ "MixinEnchantedBookItem", "MixinItem", "MixinItemStackClient", - "MixinLivingRenderer", - "MixinWitchRenderer" + "MixinLivingRenderer" ], "server": [], "injectors": { diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/lakes/hanging_large.json b/src/main/resources/data/the_vault/worldgen/processor_list/lakes/hanging_large.json index ac4eb0f7..9be05c0a 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/lakes/hanging_large.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/lakes/hanging_large.json @@ -2,19 +2,6 @@ "processors": [ { "rules": [ - { - "output_state": { - "Name": "minecraft:dead_bush" - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "byg:firecracker_flower_bush", - "probability": 0.5 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:light_gray_terracotta" diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/pirate_cove/pallet4.json b/src/main/resources/data/the_vault/worldgen/processor_list/pirate_cove/pallet4.json index d7409873..ebcfb832 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/pirate_cove/pallet4.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/pirate_cove/pallet4.json @@ -277,22 +277,6 @@ "location_predicate": { "predicate_type": "minecraft:always_true" } - }, - { - "output_state": { - "Name": "byg:stripped_palm_wood", - "Properties": { - "axis": "y" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:stripped_oak_wood", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } } ], "processor_type": "minecraft:rule" diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet4.json b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet4.json index 1a31d7b1..f3e36379 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet4.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet4.json @@ -150,27 +150,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "byg:polished_soapstone_wall", - "Properties": { - "east": "none", - "north": "none", - "south": "none", - "up": "true", - "waterlogged": "false", - "west": "none" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:cobblestone_wall", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:damaged_anvil", diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet5.json b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet5.json index f56a8f95..86499b87 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet5.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet5.json @@ -86,19 +86,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "byg:black_chiseled_sandstone" - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:chiseled_stone_bricks", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:polished_diorite" diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet9.json b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet9.json index 9dca91e0..d9b91b60 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet9.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/treasure/pallet9.json @@ -15,22 +15,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "byg:embur_nylium", - "Properties": { - "snowy": "false" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:stone", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:black_concrete_powder" @@ -70,22 +54,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "byg:nightshade_log", - "Properties": { - "axis": "y" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:cobblestone", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:polished_diorite_stairs", diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/tunnels/pallet7.json b/src/main/resources/data/the_vault/worldgen/processor_list/tunnels/pallet7.json index 8a4a8d1d..8283e2dd 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/tunnels/pallet7.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/tunnels/pallet7.json @@ -15,22 +15,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "byg:stripped_cherry_wood", - "Properties": { - "axis": "y" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "minecraft:stone", - "probability": 0.5 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:crimson_hyphae", diff --git a/src/main/resources/data/the_vault/worldgen/processor_list/wildwest/pallet1.json b/src/main/resources/data/the_vault/worldgen/processor_list/wildwest/pallet1.json index 21aef961..11831a81 100644 --- a/src/main/resources/data/the_vault/worldgen/processor_list/wildwest/pallet1.json +++ b/src/main/resources/data/the_vault/worldgen/processor_list/wildwest/pallet1.json @@ -54,22 +54,6 @@ "predicate_type": "minecraft:always_true" } }, - { - "output_state": { - "Name": "minecraft:stripped_acacia_wood", - "Properties": { - "axis": "y" - } - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "byg:stripped_palo_verde_wood", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, { "output_state": { "Name": "minecraft:smooth_red_sandstone_slab", @@ -365,39 +349,6 @@ "location_predicate": { "predicate_type": "minecraft:always_true" } - }, - { - "output_state": { - "Name": "minecraft:acacia_planks" - }, - "input_predicate": { - "predicate_type": "minecraft:random_block_match", - "block": "byg:holly_planks", - "probability": 1.0 - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } - }, - { - "output_state": { - "Name": "minecraft:acacia_pressure_plate", - "Properties": { - "powered": "false" - } - }, - "input_predicate": { - "block_state": { - "Name": "byg:holly_pressure_plate", - "Properties": { - "powered": "false" - } - }, - "predicate_type": "minecraft:blockstate_match" - }, - "location_predicate": { - "predicate_type": "minecraft:always_true" - } } ], "processor_type": "minecraft:rule"