Skip to content

Commit

Permalink
Code review, fixed the logic of embedded annotations, edits for AI sp…
Browse files Browse the repository at this point in the history
…iders (part 4)
  • Loading branch information
OldSerpskiStalker committed Oct 19, 2024
1 parent d987b93 commit 63f9f61
Show file tree
Hide file tree
Showing 79 changed files with 1,196 additions and 1,108 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@

import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import org.imesense.dynamicspawncontrol.ai.spider.utils.event.EventHandler;
import org.imesense.dynamicspawncontrol.ai.spider.utils.attackweb.WebSlingerCapability;
import org.imesense.dynamicspawncontrol.ai.spider.util.event.WebAttackEvent;
import org.imesense.dynamicspawncontrol.ai.spider.util.attackweb.WebSlingerCapability;
import org.imesense.dynamicspawncontrol.ai.zombie.event.BreakTorchEvent;
import org.imesense.dynamicspawncontrol.debug.CheckDebugger;
import org.imesense.dynamicspawncontrol.gameplay.recipes.IRecipes;
import org.imesense.dynamicspawncontrol.gameplay.recipes.CraftItemWeb;
import org.imesense.dynamicspawncontrol.technical.eventprocessor.primitive.OnUpdateTimeWorld;
import org.imesense.dynamicspawncontrol.technical.eventprocessor.primitive.OnWindowTitle;
import org.imesense.dynamicspawncontrol.technical.initializer.RegisterCfgClasses;
import org.imesense.dynamicspawncontrol.technical.initializer.RegisterConfigClasses;
import org.imesense.dynamicspawncontrol.technical.initializer.RegisterGameplayClasses;
import org.imesense.dynamicspawncontrol.technical.initializer.RegisterCommandsClasses;
import org.imesense.dynamicspawncontrol.technical.customlibrary.Log;
Expand All @@ -40,90 +41,12 @@
* Main class of modification
*/
@Mod(
modid = DynamicSpawnControl.STRUCT_INFO_MOD.MOD_ID,
name = DynamicSpawnControl.STRUCT_INFO_MOD.NAME,
version = DynamicSpawnControl.STRUCT_INFO_MOD.VERSION
modid = ProjectStructure.STRUCT_INFO_MOD.MOD_ID,
name = ProjectStructure.STRUCT_INFO_MOD.NAME,
version = ProjectStructure.STRUCT_INFO_MOD.VERSION
)
public class DynamicSpawnControl
{
/**
*
*/
public static final class STRUCT_INFO_MOD
{
/**
* Modification ID
*/
public static final String MOD_ID = "dynamicspawncontrol";

/**
* Modification name
*/
public static final String NAME = "Dynamic Spawn Control";

/**
* Minecraft version
*/
public static final String VERSION = "1.12.2-14.23.5.2860";
}

/**
*
*/
public static final class STRUCT_FILES_DIRS
{
/**
*
*/
public static final String NAME_DIRECTORY = "DynamicSpawnControl";

/**
*
*/
public static final String NAME_DIR_CONFIGS = "configs";

/**
*
*/
public static final String NAME_DIR_PLUGINS = "plugins";

/**
*
*/
public static final String NAME_DIR_SCRIPTS = "scripts";

/**
*
*/
public static final String NAME_DIR_SINGLE_SCRIPTS = "single_scripts";

/**
*
*/
public static final String NAME_DIR_LOGS = "logs";

/**
*
*/
public static final String NAME_DIR_CACHE = "cache";
}

/**
*
*/
public static final class STRUCT_FILES_EXTENSION
{
/**
*
*/
public static final String SCRIPT_FILE_EXTENSION = ".json";

/**
*
*/
public static final String LOG_FILE_EXTENSION = ".txt";
}

/**
* Main class instance
*/
Expand Down Expand Up @@ -193,7 +116,7 @@ public synchronized void preInit(FMLPreInitializationEvent event)
globalDirectory = event.getModConfigurationDirectory();

//
Log.createLogFile(globalDirectory.getPath() + File.separator + STRUCT_FILES_DIRS.NAME_DIRECTORY, CheckDebugger.instance.IsRunDebugger);
Log.createLogFile(globalDirectory.getPath() + File.separator + ProjectStructure.STRUCT_FILES_DIRS.NAME_DIRECTORY, CheckDebugger.instance.IsRunDebugger);
Log.writeDataToLogFile(1, "Debugger is running: " + (CheckDebugger.instance.IsRunDebugger ? "true" : "false"));

//
Expand All @@ -204,7 +127,7 @@ public synchronized void preInit(FMLPreInitializationEvent event)
PlayerInWebMessage.register(networkWrapper);

//
RegisterCfgClasses.initializeConfigs();
RegisterConfigClasses.initializeConfigs();

//
generalStorageData = new GeneralStorageData();
Expand Down Expand Up @@ -262,7 +185,9 @@ public synchronized void postInit(FMLPostInitializationEvent event)
//
Proxy.postInit(event);

MinecraftForge.EVENT_BUS.register( new EventHandler());
//-' TODO: перенести это в отдельную инициализацию
MinecraftForge.EVENT_BUS.register(new WebAttackEvent());
MinecraftForge.EVENT_BUS.register(new BreakTorchEvent());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
package org.imesense.dynamicspawncontrol;

/**
*
*/
public final class ProjectStructure
{
/**
*
*/
public static final class STRUCT_INFO_MOD
{
/**
* Modification ID
*/
public static final String MOD_ID = "dynamicspawncontrol";

/**
* Modification name
*/
public static final String NAME = "Dynamic Spawn Control";

/**
* Minecraft version
*/
public static final String VERSION = "1.12.2-14.23.5.2860";
}

/**
*
*/
public static final class STRUCT_FILES_DIRS
{
/**
*
*/
public static final String NAME_DIRECTORY = "DynamicSpawnControl";

/**
*
*/
public static final String NAME_DIR_CONFIGS = "configs";

/**
*
*/
public static final String NAME_DIR_PLUGINS = "plugins";

/**
*
*/
public static final String NAME_DIR_SCRIPTS = "scripts";

/**
*
*/
public static final String NAME_DIR_SINGLE_SCRIPTS = "single_scripts";

/**
*
*/
public static final String NAME_DIR_LOGS = "logs";

/**
*
*/
public static final String NAME_DIR_CACHE = "cache";
}

/**
*
*/
public static final class STRUCT_FILES_EXTENSION
{
/**
*
*/
public static final String SCRIPT_FILE_EXTENSION = ".json";

/**
*
*/
public static final String LOG_FILE_EXTENSION = ".txt";
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package org.imesense.dynamicspawncontrol.ai.spider.task;
package org.imesense.dynamicspawncontrol.ai.spider.entityaibase;

import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.world.World;
import org.imesense.dynamicspawncontrol.ai.spider.utils.attackweb.EntityThrowableWeb;
import org.imesense.dynamicspawncontrol.ai.spider.util.attackweb.EntityThrowableWeb;
import org.imesense.dynamicspawncontrol.debug.CodeGenericUtils;
import org.imesense.dynamicspawncontrol.technical.config.spiderattackweb.DataSpiderAttackWeb;
import org.imesense.dynamicspawncontrol.technical.customlibrary.Log;

/**
*
*/
public final class AISpiderWebAttackTask extends EntityAIBase
public final class WebAttackTask extends EntityAIBase
{
/**
*
Expand All @@ -26,8 +28,10 @@ public final class AISpiderWebAttackTask extends EntityAIBase
*
* @param entity
*/
public AISpiderWebAttackTask(EntityLiving entity)
public WebAttackTask(EntityLiving entity)
{
CodeGenericUtils.printInitClassToLog(this.getClass());

this.parentEntity = entity;
}

Expand All @@ -38,8 +42,11 @@ public AISpiderWebAttackTask(EntityLiving entity)
@Override
public boolean shouldExecute()
{
EntityLivingBase entitylivingbase = this.parentEntity != null ? this.parentEntity.getAttackTarget() : null;
return entitylivingbase != null && entitylivingbase.getDistanceSq(this.parentEntity) >= 4.0;
EntityLivingBase entitylivingbase = this.parentEntity != null ?
this.parentEntity.getAttackTarget() : null;

return entitylivingbase != null &&
entitylivingbase.getDistanceSq(this.parentEntity) >= 4.0;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
package org.imesense.dynamicspawncontrol.ai.spider.utils.attackweb;
package org.imesense.dynamicspawncontrol.ai.spider.util.attackweb;

import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.init.Blocks;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.datafix.DataFixer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import org.imesense.dynamicspawncontrol.DynamicSpawnControl;
import org.imesense.dynamicspawncontrol.debug.CodeGenericUtils;
import org.imesense.dynamicspawncontrol.technical.config.spiderattackweb.DataSpiderAttackWeb;
import org.imesense.dynamicspawncontrol.technical.customlibrary.Log;
import org.imesense.dynamicspawncontrol.technical.customlibrary.ObjectHandler;
import org.imesense.dynamicspawncontrol.technical.network.PlayerInWebMessage;

Expand All @@ -30,7 +30,7 @@ public final class EntityThrowableWeb extends EntityThrowable
/**
*
*/
public static final EnumParticleTypes particleType;
public static final EnumParticleTypes PARTICLE_TYPES;

/**
*
Expand All @@ -39,6 +39,8 @@ public final class EntityThrowableWeb extends EntityThrowable
public EntityThrowableWeb(World worldIn)
{
super(worldIn);

CodeGenericUtils.printInitClassToLog(this.getClass());
}

/**
Expand All @@ -49,53 +51,8 @@ public EntityThrowableWeb(World worldIn)
public EntityThrowableWeb(World worldIn, EntityLivingBase throwerIn)
{
super(worldIn, throwerIn);
}

/**
*
* @param worldIn
* @param x
* @param y
* @param z
*/
public EntityThrowableWeb(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}

/**
*
* @param worldIn
* @param x
* @param y
* @param z
* @param accelX
* @param accelY
* @param accelZ
*/
public EntityThrowableWeb(World worldIn, double x, double y, double z, double accelX, double accelY, double accelZ)
{
super(worldIn);
this.setSize(1.0f, 1.0f);
this.setLocationAndAngles(x, y, z, this.rotationYaw, this.rotationPitch);
this.setPosition(x, y, z);
}

/**
*
* @param id
*/
@SideOnly(Side.CLIENT)
public void handleStatusUpdate(byte id)
{
if (id == 3)
{
for(byte i = 0; i < 3; ++i)
{
this.world.spawnParticle(particleType,
this.posX, this.posY, this.posZ, 0.f, 0.f, 0.f);
}
}
CodeGenericUtils.printInitClassToLog(this.getClass());
}

/**
Expand Down Expand Up @@ -220,6 +177,6 @@ public static void onHit(World world, BlockPos pos, Entity source, Entity target
*/
static
{
particleType = EnumParticleTypes.SNOWBALL;
PARTICLE_TYPES = EnumParticleTypes.SNOWBALL;
}
}
Loading

0 comments on commit 63f9f61

Please sign in to comment.