Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.minecraft.src;
- import de.matthiasmann.twl.Button;
- import de.matthiasmann.twl.Widget;
- import de.matthiasmann.twl.model.SimpleButtonModel;
- import java.util.List;
- import net.minecraft.src.Block;
- import net.minecraft.src.Entity;
- import net.minecraft.src.EntityArrow303;
- import net.minecraft.src.EntityLiving;
- import net.minecraft.src.EntityPlayer;
- import net.minecraft.src.EntitySlimeFX;
- import net.minecraft.src.GuiModScreen;
- import net.minecraft.src.Item;
- import net.minecraft.src.ItemStack;
- import net.minecraft.src.Material;
- import net.minecraft.src.MathHelper;
- import net.minecraft.src.ModAction;
- import net.minecraft.src.ModSettingScreen;
- import net.minecraft.src.ModSettings;
- import net.minecraft.src.SettingFloat;
- import net.minecraft.src.SettingInt;
- import net.minecraft.src.WidgetClassicTwocolumn;
- import net.minecraft.src.WidgetFloat;
- import net.minecraft.src.WidgetInt;
- import net.minecraft.src.WidgetSimplewindow;
- import net.minecraft.src.World;
- import net.minecraft.src.mod_Arrows303;
- public class EntityArrow303Ice extends EntityArrow303 {
- public static ModSettings Settings;
- public static ModSettingScreen screen;
- public static SettingInt mobFreezeTime;
- public static SettingInt playerFreezeTime;
- public static SettingFloat playerFreezeFactor;
- public static SettingFloat mobFreezeFactor;
- public static WidgetSimplewindow subscreenwin;
- public EntityLiving victim;
- public float freezeFactor;
- public int freezeTimer;
- public void subscreen() {
- GuiModScreen.show((Widget)subscreenwin);
- }
- public void setupConfig() {
- SimpleButtonModel var1 = new SimpleButtonModel();
- var1.addActionCallback(new ModAction(this, "subscreen", new Class[0]));
- Button var2 = new Button(var1);
- var2.setText("Ice Arrow");
- mod_Arrows303.screen.append(var2);
- WidgetClassicTwocolumn var3 = new WidgetClassicTwocolumn(new Widget[0]);
- mod_Arrows303.Settings.append(mobFreezeTime = new SettingInt("icearrow_mob_freeze_time", 10, 1, 30));
- var3.add(new WidgetInt(mobFreezeTime, "Mob freeze time"));
- mod_Arrows303.Settings.append(mobFreezeFactor = new SettingFloat("icearrow_mob_freeze_factor", 0.1F, 0.0F, 0.1F, 1.0F));
- var3.add(new WidgetFloat(mobFreezeFactor, "Mob freeze factor"));
- mod_Arrows303.Settings.append(playerFreezeTime = new SettingInt("icearrow_player_freeze_time", 5, 1, 30));
- var3.add(new WidgetInt(playerFreezeTime, "Player freeze time"));
- mod_Arrows303.Settings.append(playerFreezeFactor = new SettingFloat("icearrow_player_freeze_factor", 0.5F, 0.0F, 0.1F, 1.0F));
- var3.add(new WidgetFloat(playerFreezeFactor, "Player freeze factor"));
- subscreenwin = new WidgetSimplewindow(var3, "Ice Arrow");
- }
- public void entityInit() {
- super.entityInit();
- this.name = "IceArrow";
- this.craftingResults = 1;
- this.itemId = 130 + Block.blocksList.length;
- this.tip = Item.snowball;
- this.item = new ItemStack(this.itemId, 1, 0);
- this.spriteFile = "/arrows/icearrow.png";
- }
- public EntityArrow303Ice(World var1) {
- super(var1);
- }
- public EntityArrow303Ice(World var1, double var2, double var4, double var6) {
- super(var1, var2, var4, var6);
- }
- public EntityArrow303Ice(World var1, EntityLiving var2) {
- super(var1, var2);
- }
- public boolean onHitBlock() {
- if(this.victim == null) {
- this.setEntityDead();
- return true;
- } else {
- return false;
- }
- }
- public boolean onHitTarget(Entity var1) {
- if(var1 instanceof EntityLiving && this.victim == null) {
- List var2 = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, var1.boundingBox.expand(3.0D, 3.0D, 3.0D));
- for(int var3 = 0; var3 < var2.size(); ++var3) {
- Entity var4 = (Entity)var2.get(var3);
- if(var4 instanceof EntityArrow303Ice) {
- EntityArrow303Ice var5 = (EntityArrow303Ice)var4;
- if(var5.victim == var1) {
- var5.freezeTimer += this.getFreezeTimer((EntityLiving)var1);
- var5.isDead = false;
- var1.attackEntityFrom(this.shooter, 4);
- this.setEntityDead();
- return false;
- }
- }
- }
- var1.attackEntityFrom(this.shooter, 4);
- this.freezeMob((EntityLiving)var1);
- return false;
- } else {
- return false;
- }
- }
- public int getFreezeTimer(EntityLiving var1) {
- return (var1 instanceof EntityPlayer?(Integer)playerFreezeTime.get():(Integer)mobFreezeTime.get()).intValue() * 20;
- }
- public void freezeMob(EntityLiving var1) {
- this.victim = var1;
- this.freezeFactor = (var1 instanceof EntityPlayer?(Float)playerFreezeFactor.get():(Float)mobFreezeFactor.get()).floatValue();
- this.freezeTimer = this.getFreezeTimer(var1);
- this.motionX = this.motionY = this.motionZ = 0.0D;
- }
- public void unfreezeMob() {
- this.victim = null;
- }
- public void setEntityDead() {
- if(this.victim != null) {
- this.unfreezeMob();
- }
- super.setEntityDead();
- }
- public void onUpdate() {
- super.onUpdate();
- if(this.victim != null) {
- if(this.victim.isDead || this.victim.deathTime > 0) {
- this.setEntityDead();
- return;
- }
- this.isDead = false;
- this.inGround = false;
- this.posX = this.victim.posX;
- this.posY = this.victim.boundingBox.minY + (double)this.victim.height * 0.5D;
- this.posZ = this.victim.posZ;
- this.setPosition(this.posX, this.posY, this.posZ);
- this.victim.motionX *= (double)this.freezeFactor;
- this.victim.motionY *= (double)this.freezeFactor;
- this.victim.motionZ *= (double)this.freezeFactor;
- --this.freezeTimer;
- if(this.freezeTimer <= 0) {
- this.setEntityDead();
- }
- }
- }
- public boolean onHit() {
- if(this.victim != null) {
- return false;
- } else {
- int var1 = MathHelper.floor_double(this.posX);
- int var2 = MathHelper.floor_double(this.posY);
- int var3 = MathHelper.floor_double(this.posZ);
- for(int var4 = var1 - 1; var4 <= var1 + 1; ++var4) {
- for(int var5 = var2 - 1; var5 <= var2 + 1; ++var5) {
- for(int var6 = var3 - 1; var6 <= var3 + 1; ++var6) {
- if(this.worldObj.getBlockMaterial(var4, var5, var6) == Material.water && this.worldObj.getBlockMetadata(var4, var5, var6) == 0) {
- this.worldObj.setBlockWithNotify(var4, var5, var6, 79);
- } else if(this.worldObj.getBlockMaterial(var4, var5, var6) == Material.lava && this.worldObj.getBlockMetadata(var4, var5, var6) == 0) {
- this.worldObj.setBlockWithNotify(var4, var5, var6, 49);
- } else if(this.worldObj.getBlockId(var4, var5, var6) == 51) {
- this.worldObj.setBlockWithNotify(var4, var5, var6, 0);
- } else if(this.worldObj.getBlockId(var4, var5, var6) == 50) {
- Block.blocksList[50].dropBlockAsItemWithChance(this.worldObj, var4, var5, var6, this.worldObj.getBlockMetadata(var4, var5, var6), 1.0F);
- this.worldObj.setBlockWithNotify(var4, var5, var6, 0);
- Block.blocksList[50].onBlockDestroyedByExplosion(this.worldObj, var4, var5, var6);
- }
- }
- }
- }
- return true;
- }
- }
- public void tickFlying() {
- super.tickFlying();
- if(((Boolean)mod_Arrows303.particles.get()).booleanValue()) {
- EntitySlimeFX var1 = new EntitySlimeFX(this.worldObj, this.posX, this.posY, this.posZ, Item.snowball);
- var1.motionX = var1.motionZ = var1.motionY = 0.01D;
- var1.renderDistanceWeight = 10.0D;
- mod_Arrows303.mc.effectRenderer.addEffect(var1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement