Выход из космоса, шапки из грависуйта, разное говно и мелкие правки.
This commit is contained in:
parent
409b812061
commit
1543766132
14 changed files with 2474 additions and 2509 deletions
|
@ -92,13 +92,13 @@ public class BlockProtocol extends BlockContainer {
|
|||
@SideOnly(Side.SERVER)
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
TileEntityProtocol controller = (TileEntityProtocol)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
return false;
|
||||
TileEntityProtocol controller = (TileEntityProtocol)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (controller != null){
|
||||
controller.attachPlayer(par5EntityPlayer);
|
||||
par5EntityPlayer.sendChatToPlayer("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList());
|
||||
}
|
||||
if (controller != null){
|
||||
controller.attachPlayer(par5EntityPlayer);
|
||||
par5EntityPlayer.sendChatToPlayer("[WarpCtrlr] Attached players: " + controller.getAttachedPlayersList());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -87,12 +87,12 @@ public class BlockRadar extends BlockContainer {
|
|||
@SideOnly(Side.SERVER)
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
TileEntityRadar radar = (TileEntityRadar)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
return false;
|
||||
TileEntityRadar radar = (TileEntityRadar)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (radar != null){
|
||||
par5EntityPlayer.sendChatToPlayer("[Radar] Energy level: " + radar.getCurrentEnergyValue() + " Eu");
|
||||
}
|
||||
if (radar != null){
|
||||
par5EntityPlayer.sendChatToPlayer("[Radar] Energy level: " + radar.getCurrentEnergyValue() + " Eu");
|
||||
}
|
||||
|
||||
WarpDrive.instance.registry.printRegistry();
|
||||
|
|
|
@ -84,20 +84,14 @@ public class BlockReactor extends BlockContainer {
|
|||
@Override
|
||||
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the block is clicked by a player. Args: x, y, z, entityPlayer
|
||||
*/
|
||||
//@SideOnly(Side.SERVER)
|
||||
@Override
|
||||
public void onBlockClicked(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isClient())
|
||||
return false;
|
||||
TileEntityReactor reactor = (TileEntityReactor)par1World.getBlockTileEntity(par2, par3, par4);
|
||||
|
||||
if (reactor != null){
|
||||
par5EntityPlayer.sendChatToPlayer(reactor.getCoreState());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
10
src/cr0s/WarpDrive/ClientProxy.java
Normal file
10
src/cr0s/WarpDrive/ClientProxy.java
Normal file
|
@ -0,0 +1,10 @@
|
|||
package cr0s.WarpDrive;
|
||||
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -1,27 +1,27 @@
|
|||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package cr0s.WarpDrive;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
/**
|
||||
* Класс объекта движущегося в корабле энтити
|
||||
* @author user
|
||||
*/
|
||||
public class MovingEntity {
|
||||
public int oldX;
|
||||
public int oldY;
|
||||
public int oldZ;
|
||||
|
||||
public Entity entity;
|
||||
|
||||
public MovingEntity(Entity e, int x, int y, int z) {
|
||||
this.entity = e;
|
||||
|
||||
this.oldX = x;
|
||||
this.oldY = y;
|
||||
this.oldZ = z;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* To change this template, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package cr0s.WarpDrive;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
/**
|
||||
* Класс объекта движущегося в корабле энтити
|
||||
* @author user
|
||||
*/
|
||||
public class MovingEntity {
|
||||
public int oldX;
|
||||
public int oldY;
|
||||
public int oldZ;
|
||||
|
||||
public Entity entity;
|
||||
|
||||
public MovingEntity(Entity e, int x, int y, int z) {
|
||||
this.entity = e;
|
||||
|
||||
this.oldX = x;
|
||||
this.oldY = y;
|
||||
this.oldZ = z;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,127 +1,114 @@
|
|||
/*
|
||||
* Невесомость и отключение текучести жидкостей
|
||||
*/
|
||||
package cr0s.WarpDrive;
|
||||
|
||||
import keepcalm.mods.events.events.LiquidFlowEvent;
|
||||
import keepcalm.mods.events.events.PlayerMoveEvent;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
|
||||
/**
|
||||
* Обработчик событий в мире Space
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class SpaceEventHandler {
|
||||
@ForgeSubscribe
|
||||
public void onBlockFlow(LiquidFlowEvent lfe) {
|
||||
// В космосе жидкости не текут, так что событие отменяется
|
||||
System.out.println("onLiquidFlow: liquid is flowing");
|
||||
if (lfe.world.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
System.out.println("onLiquidFlow: [blocking flow]");
|
||||
lfe.setCanceled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onPlayerMove(PlayerMoveEvent pme) {
|
||||
final int HELMET_ID_SKUBA = 30082;
|
||||
final int HELMET_ID_QUANTUM = 30174;
|
||||
final int HELMET_HEAD = 397;
|
||||
//System.out.println("onPlayerMove(): event called.");
|
||||
|
||||
// Движение происходит в космическом пространстве
|
||||
if (pme.entity.worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
if (pme.entity instanceof EntityPlayer) {
|
||||
|
||||
if (isEntityInVacuum(pme.entity)) {
|
||||
if (!(pme.entityPlayer.getCurrentArmor(3) != null && pme.entityPlayer.getCurrentArmor(3).itemID == HELMET_ID_SKUBA) &&
|
||||
!(pme.entityPlayer.getCurrentArmor(3) != null && pme.entityPlayer.getCurrentArmor(3).itemID == HELMET_ID_QUANTUM) &&
|
||||
!(pme.entityPlayer.getCurrentArmor(3) != null && pme.entityPlayer.getCurrentArmor(3).itemID == HELMET_HEAD)) {
|
||||
pme.entity.attackEntityFrom(DamageSource.drown, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Отправить назад на Землю
|
||||
if (pme.newY < -50.0D) {
|
||||
((EntityPlayerMP)pme.entityPlayer).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) pme.entityPlayer), 0, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, MathHelper.floor_double(pme.newX), 5000, MathHelper.floor_double(pme.newZ)));
|
||||
((EntityPlayerMP)pme.entityPlayer).setFire(30);
|
||||
((EntityPlayerMP)pme.entityPlayer).setPositionAndUpdate(pme.newX, 5000D, pme.newZ);
|
||||
return;
|
||||
}
|
||||
}
|
||||
/*
|
||||
// Если это игрок в режиме Creative, то игнорируем
|
||||
if (pme.entity instanceof EntityPlayer && ((EntityPlayer)pme.entity).capabilities.isCreativeMode) {
|
||||
return;
|
||||
}
|
||||
|
||||
//System.out.println("onPlayerMove(): oldY: " + pme.oldY + " newY: " + pme.newY);
|
||||
// Происходит падение
|
||||
if (pme.oldY > pme.newY && pme.flying) {
|
||||
//System.out.println("onPlayerMove(): [blocking falling]");
|
||||
if (pme.entity instanceof EntityPlayer) {
|
||||
pme.entityPlayer.setPositionAndUpdate(pme.oldX, pme.oldY, pme.oldZ);
|
||||
} else {
|
||||
pme.entity.setPosition(pme.oldX, pme.oldY, pme.oldZ);
|
||||
}
|
||||
|
||||
pme.setCanceled(true); // Предотвращаем падение
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка, находится ли Entity в открытом космосе
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
private boolean isEntityInVacuum(Entity e) {
|
||||
|
||||
int x = MathHelper.floor_double(e.posX);
|
||||
int y = MathHelper.floor_double(e.posY);
|
||||
int z = MathHelper.floor_double(e.posZ);
|
||||
|
||||
final int CHECK_DISTANCE = 10;
|
||||
|
||||
if (e.onGround) { return false; }
|
||||
|
||||
for (int ny = y; ny > (y - CHECK_DISTANCE); ny--) {
|
||||
if (!e.worldObj.isAirBlock(x, ny, z)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.worldObj.canBlockSeeTheSky(x, y, z) || !e.worldObj.canBlockSeeTheSky(x, y - 1, z) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntityJoinedWorld(EntityJoinWorldEvent ejwe) {
|
||||
if (!(ejwe.entity instanceof EntityPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ejwe.world.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
((EntityPlayer)ejwe.entity).capabilities.allowFlying = true;
|
||||
} else
|
||||
{
|
||||
((EntityPlayer)ejwe.entity).capabilities.allowFlying = false;
|
||||
}
|
||||
|
||||
if (((EntityPlayer)ejwe.entity).username.contains(".")) {
|
||||
((EntityPlayer)ejwe.entity).username = ((EntityPlayer)ejwe.entity).username.split("\\.")[0];
|
||||
}
|
||||
|
||||
((EntityPlayer)ejwe.entity).skinUrl = "http://koprokubach.servegame.com/getskin.php?user=" + ((EntityPlayer)ejwe.entity).username;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Невесомость и отключение текучести жидкостей
|
||||
*/
|
||||
package cr0s.WarpDrive;
|
||||
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||
import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent;
|
||||
import net.minecraftforge.common.ForgeHooks;
|
||||
|
||||
/**
|
||||
* Обработчик событий в мире Space
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class SpaceEventHandler {
|
||||
/*
|
||||
@ForgeSubscribe
|
||||
public void onBlockFlow(LiquidFlowEvent lfe) {
|
||||
// В космосе жидкости не текут, так что событие отменяется
|
||||
System.out.println("onLiquidFlow: liquid is flowing");
|
||||
if (lfe.world.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
System.out.println("onLiquidFlow: [blocking flow]");
|
||||
lfe.setCanceled(true);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@ForgeSubscribe
|
||||
public void livingUpdate(LivingUpdateEvent event) {
|
||||
EntityLiving entity = event.entityLiving;
|
||||
|
||||
final int HELMET_ID_SKUBA = 30082;
|
||||
final int HELMET_ID_QUANTUM = 30174;
|
||||
final int HELMET_ID_ADV_SOLAR = 30832;
|
||||
final int HELMET_ID_HYB_SOLAR = 30833;
|
||||
final int HELMET_ID_ULT_SOLAR = 30834;
|
||||
final int HELMET_HEAD = 397;
|
||||
|
||||
// Движение происходит в космическом пространстве
|
||||
if (entity.worldObj.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
if (entity instanceof EntityPlayerMP) {
|
||||
|
||||
if (isEntityInVacuum(entity)) {
|
||||
if (!(entity.getCurrentArmor(3) != null && (entity.getCurrentArmor(3).itemID == HELMET_ID_SKUBA || entity.getCurrentArmor(3).itemID == HELMET_ID_QUANTUM || entity.getCurrentArmor(3).itemID == HELMET_HEAD
|
||||
|| entity.getCurrentArmor(3).itemID == HELMET_ID_ADV_SOLAR || entity.getCurrentArmor(3).itemID == HELMET_ID_HYB_SOLAR || entity.getCurrentArmor(3).itemID == HELMET_ID_ULT_SOLAR))) {
|
||||
entity.attackEntityFrom(DamageSource.drown, 3);
|
||||
}
|
||||
}
|
||||
|
||||
// Отправить назад на Землю
|
||||
if (entity.posY < -50.0D) {
|
||||
((EntityPlayerMP)entity).mcServer.getConfigurationManager().transferPlayerToDimension(((EntityPlayerMP) entity), 0, new SpaceTeleporter(DimensionManager.getWorld(WarpDrive.instance.spaceDimID), 0, MathHelper.floor_double(entity.posX), 250, MathHelper.floor_double(entity.posZ)));
|
||||
((EntityPlayerMP)entity).setFire(30);
|
||||
((EntityPlayerMP)entity).setPositionAndUpdate(entity.posX, 250D, entity.posZ);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка, находится ли Entity в открытом космосе
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
private boolean isEntityInVacuum(Entity e) {
|
||||
|
||||
int x = MathHelper.floor_double(e.posX);
|
||||
int y = MathHelper.floor_double(e.posY);
|
||||
int z = MathHelper.floor_double(e.posZ);
|
||||
|
||||
final int CHECK_DISTANCE = 10;
|
||||
|
||||
if (e.onGround) { return false; }
|
||||
|
||||
for (int ny = y; ny > (y - CHECK_DISTANCE); ny--) {
|
||||
if (!e.worldObj.isAirBlock(x, ny, z)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!e.worldObj.canBlockSeeTheSky(x, y, z) || !e.worldObj.canBlockSeeTheSky(x, y - 1, z) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ForgeSubscribe
|
||||
public void onEntityJoinedWorld(EntityJoinWorldEvent ejwe) {
|
||||
if (!(ejwe.entity instanceof EntityPlayer)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (ejwe.world.provider.dimensionId == WarpDrive.instance.spaceDimID) {
|
||||
((EntityPlayer)ejwe.entity).capabilities.allowFlying = true;
|
||||
} else
|
||||
{
|
||||
((EntityPlayer)ejwe.entity).capabilities.allowFlying = false;
|
||||
}
|
||||
|
||||
if (((EntityPlayer)ejwe.entity).username.contains(".")) {
|
||||
((EntityPlayer)ejwe.entity).username = ((EntityPlayer)ejwe.entity).username.split("\\.")[0];
|
||||
}
|
||||
|
||||
((EntityPlayer)ejwe.entity).skinUrl = "http://koprokubach.servegame.com/getskin.php?user=" + ((EntityPlayer)ejwe.entity).username;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -21,6 +21,7 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.biome.BiomeGenBase;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@Mod(modid = "WarpDrive", name = "WarpDrive", version = "1.0.0")
|
||||
@NetworkMod(clientSideRequired = false, serverSideRequired = true)
|
||||
|
@ -59,7 +60,7 @@ public class WarpDrive {
|
|||
public SpaceWorldGenerator spaceWorldGenerator;
|
||||
@Instance("WarpDrive")
|
||||
public static WarpDrive instance;
|
||||
@SidedProxy(clientSide = "cr0s.WarpDrive.client.ClientProxy", serverSide = "cr0s.WarpDrive.CommonProxy")
|
||||
@SidedProxy(clientSide = "cr0s.WarpDrive.ClientProxy", serverSide = "cr0s.WarpDrive.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
public WarpCoresRegistry registry;
|
||||
|
@ -87,17 +88,14 @@ public class WarpDrive {
|
|||
LanguageRegistry.addName(isolationBlock, "Warp-Field Isolation Block");
|
||||
GameRegistry.registerBlock(isolationBlock, "isolationBlock");
|
||||
|
||||
proxy.registerRenderers();
|
||||
|
||||
EntityRegistry.registerModEntity(EntitySphereGen.class, "EntitySphereGenerator", 1, WarpDrive.instance, 100, 1, false);
|
||||
proxy.registerJumpEntity();
|
||||
|
||||
//if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
|
||||
spaceWorldGenerator = new SpaceWorldGenerator();
|
||||
GameRegistry.registerWorldGenerator(spaceWorldGenerator);
|
||||
|
||||
registerSpaceDimension();
|
||||
//}
|
||||
MinecraftForge.EVENT_BUS.register(new SpaceEventHandler());
|
||||
}
|
||||
|
||||
@PostInit
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
package cr0s.WarpDrive.client;
|
||||
|
||||
import cr0s.WarpDrive.CommonProxy;
|
||||
import net.minecraftforge.client.MinecraftForgeClient;
|
||||
|
||||
public class ClientProxy extends CommonProxy {
|
||||
|
||||
@Override
|
||||
public void registerRenderers() {
|
||||
System.out.println("[WD] Preloading textures...");
|
||||
MinecraftForgeClient.preloadTexture(CommonProxy.BLOCK_TEXTURE);
|
||||
}
|
||||
}
|
|
@ -1,37 +1,37 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
/**
|
||||
* Гашение урона при падении с джетпаком или квантовыми бутсами
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class AntiFallDamage {
|
||||
private final int JETPACK_ID = 30210;
|
||||
private final int ELECTRIC_JETPACK_ID = 30209;
|
||||
private final int QUANTUM_BOOTS_ID = 30171;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void livingFall(LivingFallEvent event) {
|
||||
EntityLiving entity = event.entityLiving;
|
||||
float distance = event.distance;
|
||||
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
int check = MathHelper.ceiling_float_int(distance - 3.0F);
|
||||
if (check > 0) { // Падение может нанести урон
|
||||
// Проверяем наличие защиты
|
||||
if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == QUANTUM_BOOTS_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == JETPACK_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == ELECTRIC_JETPACK_ID)) {
|
||||
event.setCanceled(true); // Блокируем падение, если защита есть
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
package cr0s.serverMods;
|
||||
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraftforge.event.ForgeSubscribe;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
/**
|
||||
* Гашение урона при падении с джетпаком или квантовыми бутсами
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class AntiFallDamage {
|
||||
private final int JETPACK_ID = 30210;
|
||||
private final int ELECTRIC_JETPACK_ID = 30209;
|
||||
private final int QUANTUM_BOOTS_ID = 30171;
|
||||
|
||||
@ForgeSubscribe
|
||||
public void livingFall(LivingFallEvent event) {
|
||||
EntityLiving entity = event.entityLiving;
|
||||
float distance = event.distance;
|
||||
|
||||
if (entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) entity;
|
||||
|
||||
int check = MathHelper.ceiling_float_int(distance - 3.0F);
|
||||
if (check > 0) { // Падение может нанести урон
|
||||
// Проверяем наличие защиты
|
||||
if ((player.getCurrentArmor(0) != null && player.getCurrentArmor(0).itemID == QUANTUM_BOOTS_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == JETPACK_ID) ||
|
||||
(player.getCurrentArmor(2) != null && player.getCurrentArmor(2).itemID == ELECTRIC_JETPACK_ID)) {
|
||||
event.setCanceled(true); // Блокируем падение, если защита есть
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
public class CommonProxy {
|
||||
// some code goes here
|
||||
public void setupLoginHook() {
|
||||
|
||||
}
|
||||
}
|
|
@ -1,143 +1,143 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.io.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* Авторизация ник.пароль
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class LoginHookClass implements IConnectionHandler {
|
||||
|
||||
private String kickReason = "";
|
||||
private File uFile;
|
||||
|
||||
public LoginHookClass() {
|
||||
uFile = MinecraftServer.getServer().getFile("users.txt");
|
||||
}
|
||||
|
||||
private void checkLogin(NetLoginHandler netHandler) throws FileNotFoundException, IOException {
|
||||
String s = netHandler.clientUsername;
|
||||
System.out.println("[SERVER MODS] Logging in user: " + s);
|
||||
|
||||
BufferedReader bufferedreader = new BufferedReader(new FileReader(uFile));
|
||||
|
||||
if (s.indexOf(".") == -1 || s.split("\\.").length != 2) {
|
||||
kickReason = "Никнейм и пароль должны быть разделены точками.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s.matches("^[a-zA-Z0-9_.]+$")) {
|
||||
kickReason = "Имя пользователя или пароль содержат недопустимые символы.";
|
||||
return;
|
||||
}
|
||||
|
||||
String s4 = s.split("\\.")[0].trim();
|
||||
String s5 = s.split("\\.")[1].trim();
|
||||
|
||||
if (s4.length() < 2 && !s4.equals("Q")) {
|
||||
kickReason = "Имя пользователя слишком короткое.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s5.length() < 3) {
|
||||
kickReason = "Пароль слишком короткий.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s4.length() > 15) {
|
||||
kickReason = "\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0434\u043B\u0438\u043D\u043D\u044B\u0439 \u043B\u043E\u0433\u0438\u043D! (>15)";
|
||||
return;
|
||||
}
|
||||
|
||||
String s1;
|
||||
|
||||
while ((s1 = bufferedreader.readLine()) != null) {
|
||||
String s2;
|
||||
String s3;
|
||||
|
||||
try {
|
||||
s2 = s1.split("\\.")[0];
|
||||
s3 = s1.split("\\.")[1];
|
||||
} catch (Exception exception) {
|
||||
kickReason = "login.password error, database is corrupted.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s2.toLowerCase().equals(s4.toLowerCase())) {
|
||||
if (!s3.equals(s5)) {
|
||||
kickReason = "Неправильный пароль!";
|
||||
System.out.println((new StringBuilder()).append(netHandler.clientUsername).append(" failed to login (pwd: ").append(s3).append(")").toString());
|
||||
bufferedreader.close();
|
||||
return;
|
||||
} else {
|
||||
bufferedreader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bufferedreader.close();
|
||||
|
||||
// Создаём новый аккаунт
|
||||
PrintWriter printwriter = new PrintWriter(new FileWriter(uFile, true));
|
||||
printwriter.println(s);
|
||||
printwriter.close();
|
||||
|
||||
kickReason = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) {
|
||||
kickReason = "";
|
||||
|
||||
try {
|
||||
checkLogin(netHandler);
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
// Не кикать
|
||||
if (kickReason.isEmpty()) {
|
||||
// Удалить пароль из имени пользователя
|
||||
netHandler.clientUsername = netHandler.clientUsername.split("\\.")[0];
|
||||
}
|
||||
|
||||
return kickReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.network.IConnectionHandler;
|
||||
import cpw.mods.fml.common.network.Player;
|
||||
import java.io.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.network.INetworkManager;
|
||||
import net.minecraft.network.NetLoginHandler;
|
||||
import net.minecraft.network.packet.NetHandler;
|
||||
import net.minecraft.network.packet.Packet1Login;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
|
||||
/**
|
||||
* Авторизация ник.пароль
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class LoginHookClass implements IConnectionHandler {
|
||||
|
||||
private String kickReason = "";
|
||||
private File uFile;
|
||||
|
||||
public LoginHookClass() {
|
||||
uFile = MinecraftServer.getServer().getFile("users.txt");
|
||||
}
|
||||
|
||||
private void checkLogin(NetLoginHandler netHandler) throws FileNotFoundException, IOException {
|
||||
String s = netHandler.clientUsername;
|
||||
System.out.println("[SERVER MODS] Logging in user: " + s);
|
||||
|
||||
BufferedReader bufferedreader = new BufferedReader(new FileReader(uFile));
|
||||
|
||||
if (s.indexOf(".") == -1 || s.split("\\.").length != 2) {
|
||||
kickReason = "Никнейм и пароль должны быть разделены точками.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!s.matches("^[a-zA-Z0-9_.]+$")) {
|
||||
kickReason = "Имя пользователя или пароль содержат недопустимые символы.";
|
||||
return;
|
||||
}
|
||||
|
||||
String s4 = s.split("\\.")[0].trim();
|
||||
String s5 = s.split("\\.")[1].trim();
|
||||
|
||||
if (s4.length() < 2 && !s4.equals("Q")) {
|
||||
kickReason = "Имя пользователя слишком короткое.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s5.length() < 3) {
|
||||
kickReason = "Пароль слишком короткий.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s4.length() > 15) {
|
||||
kickReason = "\u0421\u043B\u0438\u0448\u043A\u043E\u043C \u0434\u043B\u0438\u043D\u043D\u044B\u0439 \u043B\u043E\u0433\u0438\u043D! (>15)";
|
||||
return;
|
||||
}
|
||||
|
||||
String s1;
|
||||
|
||||
while ((s1 = bufferedreader.readLine()) != null) {
|
||||
String s2;
|
||||
String s3;
|
||||
|
||||
try {
|
||||
s2 = s1.split("\\.")[0];
|
||||
s3 = s1.split("\\.")[1];
|
||||
} catch (Exception exception) {
|
||||
kickReason = "login.password error, database is corrupted.";
|
||||
return;
|
||||
}
|
||||
|
||||
if (s2.toLowerCase().equals(s4.toLowerCase())) {
|
||||
if (!s3.equals(s5)) {
|
||||
kickReason = "Неправильный пароль!";
|
||||
System.out.println((new StringBuilder()).append(netHandler.clientUsername).append(" failed to login (pwd: ").append(s3).append(")").toString());
|
||||
bufferedreader.close();
|
||||
return;
|
||||
} else {
|
||||
bufferedreader.close();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bufferedreader.close();
|
||||
|
||||
// Создаём новый аккаунт
|
||||
PrintWriter printwriter = new PrintWriter(new FileWriter(uFile, true));
|
||||
printwriter.println(s);
|
||||
printwriter.close();
|
||||
|
||||
kickReason = "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void playerLoggedIn(Player player, NetHandler netHandler, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String connectionReceived(NetLoginHandler netHandler, INetworkManager manager) {
|
||||
kickReason = "";
|
||||
|
||||
try {
|
||||
checkLogin(netHandler);
|
||||
} catch (FileNotFoundException ex) {
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(LoginHookClass.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
// Не кикать
|
||||
if (kickReason.isEmpty()) {
|
||||
// Удалить пароль из имени пользователя
|
||||
netHandler.clientUsername = netHandler.clientUsername.split("\\.")[0];
|
||||
}
|
||||
|
||||
return kickReason;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, String server, int port, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionOpened(NetHandler netClientHandler, MinecraftServer server, INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(INetworkManager manager) {
|
||||
//throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clientLoggedIn(NetHandler clientHandler, INetworkManager manager, Packet1Login login) {
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
|
@ -1,49 +1,46 @@
|
|||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
|
||||
@Mod(modid="ServerMods", name="ServerMods", version="0.0.1")
|
||||
@NetworkMod(clientSideRequired = false, serverSideRequired = true, connectionHandler = LoginHookClass.class)
|
||||
|
||||
/**
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class ServerMods {
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("ServerMods")
|
||||
public static ServerMods instance;
|
||||
|
||||
// Says where the client and server 'proxy' code is loaded.
|
||||
@SidedProxy(clientSide="cr0s.serverMods.ClientProxy", serverSide="cr0s.serverMods.CommonProxy")
|
||||
public static CommonProxy proxy;
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// Stub Method
|
||||
}
|
||||
|
||||
@Init
|
||||
public void load(FMLInitializationEvent event) {
|
||||
// Включить авторизацию (включается автоматически)
|
||||
//proxy.setupLoginHook();
|
||||
|
||||
// Снять урон от падения с джетпаком и крузис-тапками
|
||||
MinecraftForge.EVENT_BUS.register(new AntiFallDamage());
|
||||
}
|
||||
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// Stub Method
|
||||
}
|
||||
package cr0s.serverMods;
|
||||
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cr0s.WarpDrive.SpaceEventHandler;
|
||||
|
||||
@Mod(modid="ServerMods", name="ServerMods", version="0.0.1")
|
||||
@NetworkMod(clientSideRequired = false, serverSideRequired = true, connectionHandler = LoginHookClass.class)
|
||||
|
||||
/**
|
||||
* @author Cr0s
|
||||
*/
|
||||
public class ServerMods {
|
||||
|
||||
// The instance of your mod that Forge uses.
|
||||
@Instance("ServerMods")
|
||||
public static ServerMods instance;
|
||||
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event) {
|
||||
// Stub Method
|
||||
}
|
||||
|
||||
@Init
|
||||
public void load(FMLInitializationEvent event) {
|
||||
// Включить авторизацию (включается автоматически)
|
||||
//proxy.setupLoginHook();
|
||||
|
||||
// Снять урон от падения с джетпаком и крузис-тапками
|
||||
MinecraftForge.EVENT_BUS.register(new AntiFallDamage());
|
||||
MinecraftForge.EVENT_BUS.register(new SpaceEventHandler());
|
||||
}
|
||||
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event) {
|
||||
// Stub Method
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue