Skip to content

Commit

Permalink
Merge branch 'master' of [email protected]:TeamLapen/Vampirism.git
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxanier committed Apr 7, 2015
2 parents bd2b8d5 + 29ef07b commit 277214c
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 124 deletions.
4 changes: 2 additions & 2 deletions src/main/java/de/teamlapen/vampirism/ModBlocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ public static void init() {
GameRegistry.registerBlock(bloodAltarTier4Tip, ItemBlock.class,BlockBloodAltarTier4Tip.name);
GameRegistry.registerBlock(cursedEarth, BlockCursedEarth.name);
GameRegistry.registerBlock(churchAltar, BlockChurchAltar.name);
//GameRegistry.registerBlock(coffin, BlockCoffin.name);
GameRegistry.registerBlock(coffin, BlockCoffin.name);
GameRegistry.registerTileEntity(TileEntityBloodAltar.class, "TileEntityBloodAltar");
GameRegistry.registerTileEntity(TileEntityBloodAltarTier2.class, "TileEntityBloodAltarTier2");
//GameRegistry.registerTileEntity(TileEntityBloodAltarTier3.class, "TileEntityBloodAltarTier3");
GameRegistry.registerTileEntity(TileEntityBloodAltarTier4.class, "TileEntityBloodAltarTier4");
GameRegistry.registerTileEntity(TileEntityChurchAltar.class, "TileEntityChurchAltar");
GameRegistry.registerTileEntity(TileEntityBloodAltarTier4Tip.class, "TileEntityBloodAltarTier4Tip");
//GameRegistry.registerTileEntity(TileEntityCoffin.class, "TileEntityCoffin");
GameRegistry.registerTileEntity(TileEntityCoffin.class, "TileEntityCoffin");

// Flowers
GameRegistry.registerBlock(vampireFlower, VampireFlower.name);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/de/teamlapen/vampirism/ModItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static void init() {
GameRegistry.registerItem(humanHeart, ItemHumanHeart.name);
GameRegistry.registerItem(pureBlood,ItemPureBlood.name);
GameRegistry.registerItem(sunscreen, ItemSunscreen.name);
//GameRegistry.registerItem(coffin, ItemCoffin.name);
GameRegistry.registerItem(coffin, ItemCoffin.name);
}

public static void registerRecipes(){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public boolean onBlockActivated(World world, int x, int y, int z,
public void setCoffinOccupied(World world, int x, int y, int z, EntityPlayer player, boolean flag) {
int newMeta = world.getBlockMetadata(x, y, z);
if(flag)
newMeta = newMeta & 7 + 8;
newMeta = newMeta | 8;
else
newMeta = newMeta & 7;
world.setBlockMetadataWithNotify(x, y, z, newMeta, 3);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -806,13 +806,13 @@ protected void fillBloodIntoInventory(int amt){
*/
public EntityPlayer.EnumStatus sleepInCoffinAt(int x,
int y, int z) {
//TODO Understand the event stuff
//TODO Workaround for event stuff
PlayerSleepInBedEvent event = new PlayerSleepInBedEvent(this.player,
x, y, z);
MinecraftForge.EVENT_BUS.post(event);
if (event.result != null) {
return event.result;
}
// if (event.result != null) {
// return event.result;
// }


if (!this.player.worldObj.isRemote) {
Expand Down Expand Up @@ -894,21 +894,21 @@ public EntityPlayer.EnumStatus sleepInCoffinAt(int x,
(double) ((float) z + 0.5F));
}

//Following method will replace: this.player.sleeping = true;
// Helper.Reflection.setPrivateField(EntityPlayer.class, this.player,
// true, Helper.Obfuscation.getPosNames("EntityPlayer/sleeping"));
// Following method will replace: this.player.sleeping = true;
Helper.Reflection.setPrivateField(EntityPlayer.class, this.player,
true, Helper.Obfuscation.getPosNames("EntityPlayer/sleeping"));
this.sleepingCoffin = true;
//Following method will replace: this.player.sleepTimer = 0;
// Helper.Reflection.setPrivateField(EntityPlayer.class, this.player, 0,
// Helper.Obfuscation.getPosNames("EntityPlayer/sleepTimer"));
// Following method will replace: this.player.sleepTimer = 0;
Helper.Reflection.setPrivateField(EntityPlayer.class, this.player, 0,
Helper.Obfuscation.getPosNames("EntityPlayer/sleepTimer"));
this.sleeptimerCoffin = 0;

this.player.playerLocation = new ChunkCoordinates(x,
y, z);
this.player.motionX = this.player.motionZ = this.player.motionY = 0.0D;

if (!this.player.worldObj.isRemote) {
//TODO this.player.worldObj.updateAllPlayersSleepingFlag();
this.player.worldObj.updateAllPlayersSleepingFlag();
}

return EntityPlayer.EnumStatus.OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import de.teamlapen.vampirism.util.REFERENCE;

public class ItemVampiresFear extends ItemSword {
public static final int MAX_BLOOD = 100;

public static int getBlood(ItemStack itemStack) {
if (itemStack == null || itemStack.stackTagCompound == null) {
Expand All @@ -46,7 +47,7 @@ public ItemVampiresFear() {
public void addInformation(ItemStack itemStack, EntityPlayer player, List list, boolean par4) {
if (itemStack.stackTagCompound != null) {
int blood = itemStack.stackTagCompound.getInteger("blood");
list.add(EnumChatFormatting.RED + "Blood: " + blood + "/" + 1);//TODO adjust
list.add(EnumChatFormatting.RED + "Blood: " + blood + "/" + MAX_BLOOD);
}
}

Expand Down Expand Up @@ -89,8 +90,8 @@ public boolean hitEntity(ItemStack itemStack, EntityLivingBase entityTarget, Ent
itemStack.stackTagCompound.setInteger("blood", 0);
}
itemStack.stackTagCompound.setInteger("blood", itemStack.stackTagCompound.getInteger("blood") + VampireMob.getMaxBloodAmount((EntityCreature) entityTarget));
if(itemStack.stackTagCompound.getInteger("blood") > 20)
itemStack.stackTagCompound.setInteger("blood", 20);
if(itemStack.stackTagCompound.getInteger("blood") > MAX_BLOOD)
itemStack.stackTagCompound.setInteger("blood", MAX_BLOOD);
else if (itemStack.stackTagCompound.getInteger("blood") < 0)
itemStack.stackTagCompound.setInteger("blood", 0);
}
Expand Down
36 changes: 18 additions & 18 deletions src/main/java/de/teamlapen/vampirism/proxy/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void registerRenderer() {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBloodAltarTier4Tip.class,tier4Tip);
MinecraftForgeClient.registerItemRenderer(Item.getItemFromBlock(ModBlocks.bloodAltarTier4Tip), new RenderTileEntityItem(tier4Tip,new TileEntityBloodAltarTier4Tip()));

//ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoffin.class, new RendererCoffin());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityCoffin.class, new RendererCoffin());
}

@Override
Expand Down Expand Up @@ -203,21 +203,21 @@ else if(entity instanceof EntityCreature){
return loc;
}

// @Override
// public void wakeAllPlayers() {
// // TODO Auto-generated method stub
//
// }
//
// @Override
// public boolean areAllPlayersAsleepCoffin() {
// // TODO Auto-generated method stub
// return false;
// }
//
// @Override
// public void updateAllPlayersSleepingFlagCoffin() {
// // TODO Auto-generated method stub
//
// }

public void wakeAllPlayers() {
// TODO Auto-generated method stub

}


public boolean areAllPlayersAsleepCoffin() {
// TODO Auto-generated method stub
return false;
}


public void updateAllPlayersSleepingFlagCoffin() {
// TODO Auto-generated method stub

}
}
117 changes: 59 additions & 58 deletions src/main/java/de/teamlapen/vampirism/proxy/ServerProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ServerProxy extends CommonProxy {

private boolean allPlayersSleepingInCoffin;
private List playerEntities;
//private WorldServer server = MinecraftServer.getServer().worldServerForDimension(0);
private WorldServer server = MinecraftServer.getServer().worldServerForDimension(0);

@Override
public void registerKeyBindings() {
Expand Down Expand Up @@ -51,63 +51,64 @@ public String translateToLocal(String s) {
return s;
}

// public void updateAllPlayersSleepingFlagCoffin() {
// this.playerEntities = server.playerEntities;
//
// this.allPlayersSleepingInCoffin = !this.playerEntities.isEmpty();
// Iterator iterator = this.playerEntities.iterator();
//
// while (iterator.hasNext()) {
// EntityPlayer entityplayer = (EntityPlayer) iterator.next();
//
// if (!entityplayer.isPlayerSleeping()) {
// this.allPlayersSleepingInCoffin = false;
// break;
// }
// }
// }
//
// public boolean areAllPlayersAsleepCoffin()
// {
// if (this.allPlayersSleepingInCoffin) //&& !this.isRemote()
// {
// Iterator iterator = this.playerEntities.iterator();
// EntityPlayer entityplayer;
//
// do
// {
// if (!iterator.hasNext())
// {
// return true;
// }
//
// entityplayer = (EntityPlayer)iterator.next();
// }
// while (VampirePlayer.get(entityplayer).isPlayerFullyAsleepCoffin());
//
// return false;
// }
// else
// {
// return false;
// }
// }
//
// public void wakeAllPlayers() {
// this.allPlayersSleepingInCoffin = false;
// Iterator iterator = this.playerEntities.iterator();
//
// while (iterator.hasNext())
// {
// EntityPlayer entityplayer = (EntityPlayer)iterator.next();
//
// if (VampirePlayer.get(entityplayer).sleepingCoffin)
// {
// entityplayer.wakeUpPlayer(false, false, true);
// }
// }
// server.provider.resetRainAndThunder();
// }
public void updateAllPlayersSleepingFlagCoffin() {
this.playerEntities = server.playerEntities;

this.allPlayersSleepingInCoffin = !this.playerEntities.isEmpty();
Iterator iterator = this.playerEntities.iterator();

while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();

if (!entityplayer.isPlayerSleeping()) {
this.allPlayersSleepingInCoffin = false;
break;
}
}
}

public boolean areAllPlayersAsleepCoffin()
{
if (this.allPlayersSleepingInCoffin) //&& !this.isRemote()
{
Iterator iterator = this.playerEntities.iterator();
EntityPlayer entityplayer;

do
{
if (!iterator.hasNext())
{
return true;
}

entityplayer = (EntityPlayer)iterator.next();
}
while (VampirePlayer.get(entityplayer).isPlayerFullyAsleepCoffin());

return false;
}
else
{
return false;
}
}

public void wakeAllPlayers() {
this.allPlayersSleepingInCoffin = false;
Iterator iterator = this.playerEntities.iterator();

while (iterator.hasNext())
{
EntityPlayer entityplayer = (EntityPlayer)iterator.next();

if (VampirePlayer.get(entityplayer).sleepingCoffin)
{
entityplayer.wakeUpPlayer(false, false, true);
}
}
server.provider.resetRainAndThunder();
}

@Override
public ResourceLocation checkVampireTexture(Entity entity, ResourceLocation loc) {
return loc;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,6 @@ public Packet getDescriptionPacket() {
this.zCoord, 1, nbtTag);
}

/**
* Gets a list of all the villagers in entityList that are near this
* TileEntity
*
* @param entityList
* A list of all the entities to check
* @param distance
* The maximum distance from this TileEntity
* @return List with with all the villagers that are found around this
* TileEntity
*/
private ArrayList<EntityVillager> getVillagersInRadius(List entityList,
double distance) {
ArrayList<EntityVillager> list = new ArrayList<EntityVillager>();
for (Object entity : entityList) {
if (EntityVillager.class.isInstance(entity)) {
EntityVillager v = (EntityVillager) entity;
if (Math.sqrt(Math.pow(v.posX - xCoord, 2)
+ Math.pow(v.posY - yCoord, 2)
+ Math.pow(v.posZ - zCoord, 2)) <= distance)
list.add((EntityVillager) entity);
}
}
Logger.i(TAG, list.size() + "villagers found in a " + distance
+ " block radius around the altar");
return list;
}

public boolean isOccupied() {
return occupied;
}
Expand Down Expand Up @@ -106,7 +78,7 @@ public void startVampirismRitual(EntityPlayer player, ItemStack itemStack) {
Logger.i(TAG, "Starting Vampirism-Ritual");
if (VampirePlayer.get(player).getLevel() == 0) {
player.addChatMessage(new ChatComponentTranslation(
"text.vampirism:ritual_level_wrong"));
"text.vampirism:ritual_no_vampire"));
return;
}
// Put sword into altar
Expand All @@ -116,7 +88,7 @@ public void startVampirismRitual(EntityPlayer player, ItemStack itemStack) {
// TODO small animation
this.worldObj.spawnEntityInWorld(new EntityLightningBolt(worldObj, player.posX, player.posY, player.posZ));

if(itemStack.stackTagCompound != null && itemStack.stackTagCompound.getInteger("blood") <= ItemVampiresFear.getBlood(itemStack))
if(ItemVampiresFear.MAX_BLOOD <= ItemVampiresFear.getBlood(itemStack))
player.addPotionEffect(new PotionEffect(Potion.regeneration.id,
20 * 60, 1));
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/vampirism/lang/de_DE.lang
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ text.vampirism:ritual_requirements_not_met=Nicht alle Vorraussetzungen wurden er
text.vampirism:purity=Reinheit
text.vampirism:auto_fill_enabled=Automatisches Füllen aktiviert
text.vampirism:auto_fill_disabled=Automatisches Füllen deaktiviert
text.vampirism:ritual_no_vampire=F�r dieses Ritual musst du ein Vampir sein

#Config
category.vampirism.balance=Balance Einstellungen
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/assets/vampirism/lang/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ text.vampirism:purity=Purity
text.vampirism:auto_fill_enabled=Auto Fill Enabled
text.vampirism:auto_fill_disabled=Auto Fill Disabled
text.vampirism:skill.deactivated_by_serveradmin=This skill is deactivated by your serveradmin
text.vampirism:ritual_no_vampire=You need to be a vampire for this ritual

#Config
category.vampirism.balance=Balance settings
Expand Down

0 comments on commit 277214c

Please sign in to comment.