FarmingPlugin class

Пакет: com.hypixel.hytale.builtin.adventure.farming

Файл: com/hypixel/hytale/builtin/adventure/farming/FarmingPlugin.java

extends: JavaPlugin

Поля (12)

МодификаторыТипИмя
static FarmingPlugin instance
instance
AssetRegistry var1
BlockComponentSection var1
FarmingBlock var1
ComponentRegistryProxy var2
Short2ObjectMap var2
ComponentRegistryProxy var3
ComponentType var4
ComponentType var5
ComponentType var6
ComponentType var7

Методы (9)

МодификаторыВозвратСигнатура
static FarmingPlugin getFarmingPlugin get()
public ComponentType<ChunkStore, CoopBlock> getCoopBlockStateComponentTypeComponentType<ChunkStore, CoopBlock> getCoopBlockStateComponentType()
public ComponentType<EntityStore, CoopResidentComponent> getCoopResidentComponentTypeComponentType<EntityStore, CoopResidentComponent> getCoopResidentComponentType()
public ComponentType<ChunkStore, FarmingBlock> getFarmingBlockComponentTypeComponentType<ChunkStore, FarmingBlock> getFarmingBlockComponentType()
public ComponentType<ChunkStore, TilledSoilBlock> getTiledSoilBlockComponentTypeComponentType<ChunkStore, TilledSoilBlock> getTiledSoilBlockComponentType()
if if(var1 != null)
if if(var1 != null)
static void preventSpreadOnNewvoid preventSpreadOnNew(@Nonnull ChunkSectionPreLoadProcessEvent var0)
abstract super super(var1)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.farming;

class="kw">import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.component.CoopResidentComponent;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.FarmingCoopAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.modifiers.FertilizerGrowthModifierAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.modifiers.LightLevelGrowthModifierAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.modifiers.WaterGrowthModifierAsset;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.BlockStateFarmingStageData;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.BlockTypeFarmingStageData;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.PrefabFarmingStageData;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.spread.DirectionalGrowthBehaviour;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.spread.SpreadFarmingStageData;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.config.stages.spread.SpreadGrowthBehaviour;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.ChangeFarmingStageInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.FertilizeSoilInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.HarvestCropInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.UseCaptureCrateInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.UseCoopInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.interactions.UseWateringCanInteraction;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.states.CoopBlock;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.states.FarmingBlock;
class="kw">import com.hypixel.hytale.builtin.adventure.farming.states.TilledSoilBlock;
class="kw">import com.hypixel.hytale.builtin.tagset.config.NPCGroup;
class="kw">import com.hypixel.hytale.component.ComponentRegistryProxy;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Holder;
class="kw">import com.hypixel.hytale.event.EventPriority;
class="kw">import com.hypixel.hytale.server.core.asset.HytaleAssetStore;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.farming.FarmingStageData;
class="kw">import com.hypixel.hytale.server.core.asset.type.blocktype.config.farming.GrowthModifierAsset;
class="kw">import com.hypixel.hytale.server.core.asset.type.item.config.ItemDropList;
class="kw">import com.hypixel.hytale.server.core.asset.type.weather.config.Weather;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.modules.block.BlockModule;
class="kw">import com.hypixel.hytale.server.core.modules.interaction.interaction.config.Interaction;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPlugin;
class="kw">import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
class="kw">import com.hypixel.hytale.server.core.plugin.registry.AssetRegistry;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockComponentSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.BlockSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.chunk.section.ChunkSection;
class="kw">import com.hypixel.hytale.server.core.universe.world.events.ChunkSectionPreLoadProcessEvent;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import it.unimi.dsi.fastutil.shorts.Short2ObjectMap;
class="kw">import javax.annotation.Nonnull;

class="kw">public class FarmingPlugin class="kw">extends JavaPlugin {
   class="kw">protected class="kw">static FarmingPlugin instance;
   class="kw">private ComponentType<ChunkStore, TilledSoilBlock> tiledSoilBlockComponentType;
   class="kw">private ComponentType<ChunkStore, FarmingBlock> farmingBlockComponentType;
   class="kw">private ComponentType<ChunkStore, CoopBlock> coopBlockStateComponentType;
   class="kw">private ComponentType<EntityStore, CoopResidentComponent> coopResidentComponentType;

   class="kw">public class="kw">static FarmingPlugin get() {
      class="kw">return instance;
   }

   class="kw">public FarmingPlugin(@Nonnull JavaPluginInit var1) {
      super(var1);
   }

   @Override
   class="kw">protected void setup() {
      instance = this;
      AssetRegistry var1 = this.getAssetRegistry();
      ComponentRegistryProxy var2 = this.getChunkStoreRegistry();
      ComponentRegistryProxy var3 = this.getEntityStoreRegistry();
      var1.register(
         ((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)HytaleAssetStore.builder(
                           GrowthModifierAsset.class, new DefaultAssetMap()
                        )
                        .setPath("Farming/Modifiers"))
                     .setCodec(GrowthModifierAsset.CODEC))
                  .loadsAfter(Weather.class))
               .setKeyFunction(GrowthModifierAsset::getId))
            .build()
      );
      var1.register(
         ((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)((HytaleAssetStore.Builder)HytaleAssetStore.builder(
                           FarmingCoopAsset.class, new DefaultAssetMap()
                        )
                        .setPath("Farming/Coops"))
                     .setCodec(FarmingCoopAsset.CODEC))
                  .loadsAfter(ItemDropList.class, NPCGroup.class))
               .setKeyFunction(FarmingCoopAsset::getId))
            .build()
      );
      this.getCodecRegistry(Interaction.CODEC)
         .register("HarvestCrop", HarvestCropInteraction.class, HarvestCropInteraction.CODEC)
         .register("FertilizeSoil", FertilizeSoilInteraction.class, FertilizeSoilInteraction.CODEC)
         .register("ChangeFarmingStage", ChangeFarmingStageInteraction.class, ChangeFarmingStageInteraction.CODEC)
         .register("UseWateringCan", UseWateringCanInteraction.class, UseWateringCanInteraction.CODEC)
         .register("UseCoop", UseCoopInteraction.class, UseCoopInteraction.CODEC)
         .register("UseCaptureCrate", UseCaptureCrateInteraction.class, UseCaptureCrateInteraction.CODEC);
      this.getCodecRegistry(GrowthModifierAsset.CODEC).register("Fertilizer", FertilizerGrowthModifierAsset.class, FertilizerGrowthModifierAsset.CODEC);
      this.getCodecRegistry(GrowthModifierAsset.CODEC).register("LightLevel", LightLevelGrowthModifierAsset.class, LightLevelGrowthModifierAsset.CODEC);
      this.getCodecRegistry(GrowthModifierAsset.CODEC).register("Water", WaterGrowthModifierAsset.class, WaterGrowthModifierAsset.CODEC);
      this.getCodecRegistry(FarmingStageData.CODEC).register("BlockType", BlockTypeFarmingStageData.class, BlockTypeFarmingStageData.CODEC);
      this.getCodecRegistry(FarmingStageData.CODEC).register("BlockState", BlockStateFarmingStageData.class, BlockStateFarmingStageData.CODEC);
      this.getCodecRegistry(FarmingStageData.CODEC).register("Prefab", PrefabFarmingStageData.class, PrefabFarmingStageData.CODEC);
      this.getCodecRegistry(FarmingStageData.CODEC).register("Spread", SpreadFarmingStageData.class, SpreadFarmingStageData.CODEC);
      this.getCodecRegistry(SpreadGrowthBehaviour.CODEC).register("Directional", DirectionalGrowthBehaviour.class, DirectionalGrowthBehaviour.CODEC);
      this.tiledSoilBlockComponentType = var2.registerComponent(TilledSoilBlock.class, "TilledSoil", TilledSoilBlock.CODEC);
      this.farmingBlockComponentType = var2.registerComponent(FarmingBlock.class, "FarmingBlock", FarmingBlock.CODEC);
      this.coopBlockStateComponentType = var2.registerComponent(CoopBlock.class, "Coop", CoopBlock.CODEC);
      this.coopResidentComponentType = var3.registerComponent(CoopResidentComponent.class, "CoopResident", CoopResidentComponent.CODEC);
      ComponentType var4 = BlockModule.BlockStateInfo.getComponentType();
      ComponentType var5 = BlockSection.getComponentType();
      ComponentType var6 = ChunkSection.getComponentType();
      ComponentType var7 = UUIDComponent.getComponentType();
      var2.registerSystem(new FarmingSystems.OnSoilAdded(var4, this.tiledSoilBlockComponentType));
      var2.registerSystem(new FarmingSystems.OnFarmBlockAdded(var4, this.farmingBlockComponentType));
      var2.registerSystem(
         new FarmingSystems.Ticking(var5, var6, this.farmingBlockComponentType, this.tiledSoilBlockComponentType, this.coopBlockStateComponentType)
      );
      var2.registerSystem(new FarmingSystems.OnCoopAdded(var4, this.coopBlockStateComponentType));
      var3.registerSystem(new FarmingSystems.CoopResidentEntitySystem(this.coopResidentComponentType, var7));
      var3.registerSystem(new FarmingSystems.CoopResidentTicking(this.coopResidentComponentType));
      this.getEventRegistry().registerGlobal(EventPriority.LAST, ChunkSectionPreLoadProcessEvent.class, FarmingPlugin::preventSpreadOnNew);
   }

   class="kw">private class="kw">static void preventSpreadOnNew(@Nonnull ChunkSectionPreLoadProcessEvent var0) {
      if (var0.isNewlyGenerated()) {
         BlockComponentSection var1 = var0.getHolder().getComponent(BlockComponentSection.getComponentType());
         if (var1 != null) {
            Short2ObjectMap var2 = var1.getBlockHolders();
            var2.values().forEach(var0x -> {
               FarmingBlock var1 = var0x.getComponent(FarmingBlock.getComponentType());
               if (var1 != null) {
                  var1.setSpreadRate(0.0F);
               }
            });
         }
      }
   }

   class="kw">public ComponentType<ChunkStore, TilledSoilBlock> getTiledSoilBlockComponentType() {
      class="kw">return this.tiledSoilBlockComponentType;
   }

   class="kw">public ComponentType<ChunkStore, FarmingBlock> getFarmingBlockComponentType() {
      class="kw">return this.farmingBlockComponentType;
   }

   class="kw">public ComponentType<ChunkStore, CoopBlock> getCoopBlockStateComponentType() {
      class="kw">return this.coopBlockStateComponentType;
   }

   class="kw">public ComponentType<EntityStore, CoopResidentComponent> getCoopResidentComponentType() {
      class="kw">return this.coopResidentComponentType;
   }
}