package net.minecraft.world.demo;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.network.play.server.S2BPacketChangeGameState;
import net.minecraft.server.management.ItemInWorldManager;
import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.world.World;
public class DemoWorldManager extends ItemInWorldManager
{
private boolean field_73105_c;
private boolean demoTimeExpired;
private int field_73104_e;
private int field_73102_f;
private static final String __OBFID = "CL_00001429";
public DemoWorldManager(World p_i1513_1_)
{
super(p_i1513_1_);
}
public void updateBlockRemoving()
{
super.updateBlockRemoving();
++this.field_73102_f;
long i = this.theWorld.getTotalWorldTime();
long j = i / 24000L + 1L;
if (!this.field_73105_c && this.field_73102_f > 20)
{
this.field_73105_c = true;
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 0.0F));
}
this.demoTimeExpired = i > 120500L;
if (this.demoTimeExpired)
{
++this.field_73104_e;
}
if (i % 24000L == 500L)
{
if (j <= 6L)
{
this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.day." + j, new Object[0]));
}
}
else if (j == 1L)
{
if (i == 100L)
{
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 101.0F));
}
else if (i == 175L)
{
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 102.0F));
}
else if (i == 250L)
{
this.thisPlayerMP.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(5, 103.0F));
}
}
else if (j == 5L && i % 24000L == 22000L)
{
this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.day.warning", new Object[0]));
}
}
/**
* Sends a message to the player reminding them that this is the demo version
*/
private void sendDemoReminder()
{
if (this.field_73104_e > 100)
{
this.thisPlayerMP.addChatMessage(new ChatComponentTranslation("demo.reminder", new Object[0]));
this.field_73104_e = 0;
}
}
/**
* if not creative, it calls destroyBlockInWorldPartially untill the block is broken first. par4 is the specific
* side. tryHarvestBlock can also be the result of this call
*/
public void onBlockClicked(int p_73074_1_, int p_73074_2_, int p_73074_3_, int p_73074_4_)
{
if (this.demoTimeExpired)
{
this.sendDemoReminder();
}
else
{
super.onBlockClicked(p_73074_1_, p_73074_2_, p_73074_3_, p_73074_4_);
}
}
public void blockRemoving(int p_73082_1_, int p_73082_2_, int p_73082_3_)
{
if (!this.demoTimeExpired)
{
super.blockRemoving(p_73082_1_, p_73082_2_, p_73082_3_);
}
}
/**
* Attempts to harvest a block at the given coordinate
*/
public boolean tryHarvestBlock(int p_73084_1_, int p_73084_2_, int p_73084_3_)
{
return this.demoTimeExpired ? false : super.tryHarvestBlock(p_73084_1_, p_73084_2_, p_73084_3_);
}
/**
* Attempts to right-click use an item by the given EntityPlayer in the given World
*/
public boolean tryUseItem(EntityPlayer p_73085_1_, World p_73085_2_, ItemStack p_73085_3_)
{
if (this.demoTimeExpired)
{
this.sendDemoReminder();
return false;
}
else
{
return super.tryUseItem(p_73085_1_, p_73085_2_, p_73085_3_);
}
}
/**
* Activate the clicked on block, otherwise use the held item. Args: player, world, itemStack, x, y, z, side,
* xOffset, yOffset, zOffset
*/
public boolean activateBlockOrUseItem(EntityPlayer player, World worldIn, ItemStack stack, int p_73078_4_, int p_73078_5_, int p_73078_6_, int p_73078_7_, float p_73078_8_, float p_73078_9_, float p_73078_10_)
{
if (this.demoTimeExpired)
{
this.sendDemoReminder();
return false;
}
else
{
return super.activateBlockOrUseItem(player, worldIn, stack, p_73078_4_, p_73078_5_, p_73078_6_, p_73078_7_, p_73078_8_, p_73078_9_, p_73078_10_);
}
}
}