-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
671 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
LittleMaidDragon(リトルメイドドラゴン) | ||
==================== | ||
|
||
## 概要 | ||
|
||
DragonMounts のエンダードラゴンに、littleMaidMob のメイドさんへの変身能力を追加します。 | ||
|
||
|
||
## スクリーンショット | ||
![スクリーンショット](README_LittleMaidDragon.png "スクリーンショット") | ||
|
||
|
||
## 前提 | ||
|
||
- Minecraft 1.5.1 | ||
- MinecraftForge universal 1.5.1-7.7.1.611 | ||
- YMTLib 151v3 | ||
- MMM 氏製作の littleMaidMob 1.5.1-1 | ||
- BarracudaATA 氏製作の Dragon Mounts v0.99 (Forge版) | ||
|
||
|
||
## 導入 | ||
|
||
mods に zip のまま放り込んでください。 | ||
導入前にバックアップを取るのも忘れずに。".minecraft" 自体をバックアップするのがお手軽です。 | ||
|
||
|
||
## 利用条件 | ||
|
||
この MOD は Apache License(ver2.0) の下で配布されます。 | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
- この MOD を使用したことにより発生したいかなる結果についても、製作者は一切の責任を負いません。 | ||
- この MOD は変更の有無にかかわらず再頒布が可能です。Apache License を確認してください。 | ||
|
||
この MOD または派生成果物は、それが minecraft を前提としている場合に、 | ||
minecraft 自体の利用条件に縛られることに注意してください。 | ||
利用条件の詳細は minecraft の利用規約を確認してください。 | ||
|
||
|
||
## Tips | ||
|
||
- テイム中のエンダードラゴンに砂糖を与えると、メイドさんに変身します。 | ||
- メイドさんに変身したエンダードラゴンは、サドルを持たせてアクティブにすると元の姿に戻ります。 | ||
- その他の挙動は、DragonMounts および littleMaidMob とだいたい同じです。 | ||
|
||
|
||
## 注意点 | ||
|
||
mods から zip を除去すると、メイドさん形態の情報は世界から消失しますが、DragonMounts のエンダードラゴンの情報は残ります。 | ||
なのでアンインストールの時には、メイドさんから貴重品を預かって、ドラゴンの姿に戻してから行うと良いと思います。 | ||
|
||
|
||
## Copyright 2013 Yamato | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
|
||
|
||
## History | ||
|
||
- 151v3: バグ修正 | ||
- 151v2: MOD 読み込み順、およびDragonEggBlockの右クリックオーバーライドが上手く機能していなかったことに対処。 | ||
- 151v1: Minecraft1.5.1 対応。なおプレイヤー落下中に救出する機能は取り外し。 | ||
- 147v2: プレイヤー落下中に救出する機能をデフォルトOFFに。設定はConfigから。 | ||
- 147v1: 初版 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package mod.ymt.lmd; | ||
|
||
import info.ata4.minecraft.dragon.server.block.DragonEggBlock; | ||
import info.ata4.minecraft.dragon.server.entity.DragonLifeStage; | ||
import info.ata4.minecraft.dragon.server.entity.EntityTameableDragon; | ||
import net.minecraft.src.EntityPlayer; | ||
import net.minecraft.src.World; | ||
|
||
public class DragonMaidEggBlock extends DragonEggBlock { | ||
|
||
// このクラスは reobfuscate_srg したものを実機に載せること | ||
// DragonEggBlock が reobfuscate_srg しているため | ||
|
||
@Override | ||
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { | ||
// this is the server's job | ||
if (world.isRemote) { | ||
return true; | ||
} | ||
|
||
// clear placed block | ||
if (world.getBlockId(x, y, z) == blockID) { | ||
world.setBlock(x, y, z, 0); | ||
} | ||
|
||
// create dragon egg | ||
EntityTameableDragon dragon = new EntityLmdDragon(world); | ||
dragon.setPosition(x + 0.5, y + 0.5, z + 0.5); | ||
dragon.setBreederName(player.username); | ||
dragon.setLifeStage(DragonLifeStage.EGG); | ||
world.spawnEntityInWorld(dragon); | ||
|
||
LittleMaidDragonCore.getInstance().debugPrint("spawn EntityLmdDragon"); | ||
return true; | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
/** | ||
* Copyright 2013 Yamato | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package mod.ymt.lmd; | ||
|
||
import info.ata4.minecraft.dragon.server.entity.DragonLifeStage; | ||
import info.ata4.minecraft.dragon.server.entity.EntityTameableDragon; | ||
import java.lang.reflect.AccessibleObject; | ||
import java.lang.reflect.Field; | ||
import java.lang.reflect.Method; | ||
import mod.ymt.cmn.Utils; | ||
import net.minecraft.src.EntityLiving; | ||
import net.minecraft.src.EntityPlayer; | ||
import net.minecraft.src.Item; | ||
import net.minecraft.src.MathHelper; | ||
import net.minecraft.src.NBTTagCompound; | ||
import net.minecraft.src.World; | ||
|
||
public class EntityLmdDragon extends EntityTameableDragon { | ||
|
||
// このクラスは reobfuscate_srg したものを実機に載せること | ||
// EntityTameableDragon が reobfuscate_srg しているため | ||
|
||
private final LittleMaidDragonCore core = LittleMaidDragonCore.getInstance(); | ||
|
||
private NBTTagCompound maidsanData = null; | ||
|
||
public EntityLmdDragon(World world) { | ||
super(world); | ||
} | ||
|
||
@Override | ||
public boolean interact(EntityPlayer player) { | ||
if (isTamed() && isOwner(player) && Utils.tryUseItems(player, Item.sugar, false)) { // いったん消費なしでアイテム判定して、飛行中判定後に再度消費させる | ||
if (isOnFlyingWithPlayer(player)) { // 飛行中なら何もしない | ||
return false; | ||
} | ||
if (Utils.tryUseItems(player, Item.sugar, true) && switchToMaidsan(player, maidsanData)) { // メイドさんに変身 | ||
setDead(); | ||
} | ||
return true; | ||
} | ||
return super.interact(player); | ||
} | ||
|
||
@Override | ||
public void readEntityFromNBT(NBTTagCompound nbt) { | ||
super.readEntityFromNBT(nbt); | ||
if (nbt.hasKey("maidsan")) { | ||
maidsanData = nbt.getCompoundTag("maidsan"); | ||
} | ||
} | ||
|
||
public void setEntityMaid(EntityLiving maid) { | ||
if (maid == null) { | ||
maidsanData = null; | ||
} | ||
else { | ||
maidsanData = new NBTTagCompound(); | ||
maid.writeEntityToNBT(maidsanData); | ||
} | ||
} | ||
|
||
public void setLifeStageForce(DragonLifeStage lifeStage) { | ||
setLifeStage(lifeStage); | ||
try { | ||
Field f_lifeStage = EntityTameableDragon.class.getDeclaredField("lifeStage"); | ||
Field f_lifeStagePrev = EntityTameableDragon.class.getDeclaredField("lifeStagePrev"); | ||
Method m_onNewLifeStage = EntityTameableDragon.class.getDeclaredMethod("onNewLifeStage"); | ||
AccessibleObject.setAccessible(new AccessibleObject[]{ | ||
f_lifeStage, f_lifeStagePrev, m_onNewLifeStage | ||
}, true); | ||
f_lifeStage.set(this, lifeStage); | ||
f_lifeStagePrev.set(this, lifeStage); | ||
m_onNewLifeStage.invoke(this); | ||
} | ||
catch (Exception e) { | ||
core.debugPrint(e, "set LifeStage failed"); | ||
} | ||
} | ||
|
||
@Override | ||
public void setRidingPlayer(EntityPlayer player) { | ||
if (isOnFlyingWithPlayer(player)) { // 飛行中なら何もしない | ||
return; | ||
} | ||
super.setRidingPlayer(player); | ||
} | ||
|
||
public boolean switchToMaidsan(EntityPlayer player, NBTTagCompound tag) { | ||
if (Utils.isClientSide(player.worldObj)) | ||
return false; | ||
EntityLmdMaidsan maid = new EntityLmdMaidsan(player.worldObj); | ||
if (tag != null && !tag.hasNoTags()) { | ||
maid.readEntityFromNBT(tag); | ||
} | ||
else { | ||
maid.initNewMaidsan(player, isSaddled()); | ||
} | ||
maid.setEntityDragon(this); // メイドさんをロードした後に改めて設定 | ||
maid.setEntityHealth(MathHelper.ceiling_double_int(this.getHealth() * (double) maid.getMaxHealth() / this.getMaxHealth())); | ||
maid.setPathToEntity(null); | ||
maid.setAttackTarget(null); | ||
maid.setLocationAndAngles(posX, posY, posZ, MathHelper.wrapAngleTo180_float(player.worldObj.rand.nextFloat() * 360.0F), 0); | ||
maid.rotationYawHead = maid.rotationYaw; | ||
maid.renderYawOffset = maid.rotationYaw; | ||
maid.setMaidMode("Escorter"); | ||
maid.setMaidWait(true); | ||
maid.setFreedom(false); | ||
maid.changedFromDragon = true; // 竜へ変身した時の動作 | ||
return player.worldObj.spawnEntityInWorld(maid); | ||
} | ||
|
||
@Override | ||
public void writeEntityToNBT(NBTTagCompound nbt) { | ||
super.writeEntityToNBT(nbt); | ||
if (maidsanData != null) { | ||
nbt.setTag("maidsan", maidsanData.copy()); | ||
} | ||
} | ||
|
||
private boolean isOnFlyingWithPlayer(EntityPlayer player) { | ||
if (onGround) // 地上なら false | ||
return false; | ||
if (riddenByEntity != player) // 乗っているのが player でないなら false | ||
return false; | ||
// 現在地から地面までの距離を調べる | ||
{ | ||
final int DISTANCE = 5; | ||
int x = MathHelper.floor_double(posX); | ||
int y = MathHelper.floor_double(posY); | ||
int z = MathHelper.floor_double(posZ); | ||
for (int i = 0; i < DISTANCE && 0 < y - i; i++) { | ||
if (worldObj.getBlockId(x, y - i, z) != 0) { | ||
return false; // 一定距離内に空気ブロック以外のブロックがある | ||
} | ||
} | ||
} | ||
return true; // いずれでもない | ||
} | ||
|
||
public static boolean switchDragon(EntityPlayer player, EntityLmdMaidsan maid) { | ||
LittleMaidDragonCore core = LittleMaidDragonCore.getInstance(); | ||
NBTTagCompound tag = maid.getDragonData(); | ||
if (Utils.isClientSide(player.worldObj)) | ||
return true; | ||
EntityLmdDragon dragon = new EntityLmdDragon(player.worldObj); | ||
if (tag != null && !tag.hasNoTags()) { | ||
dragon.readEntityFromNBT(tag); | ||
} | ||
if (!dragon.isTamed()) { | ||
dragon.setTamed(true); | ||
} | ||
if (!dragon.isSaddled()) { | ||
dragon.setSaddled(true); | ||
} | ||
dragon.setLifeStageForce(DragonLifeStage.ADULT); | ||
dragon.setEntityMaid(maid); // ドラゴンをロードした後に改めて設定 | ||
dragon.setEntityHealth(MathHelper.ceiling_double_int(maid.getHealth() * (double) dragon.getMaxHealth() / maid.getMaxHealth())); | ||
dragon.setPathToEntity(null); | ||
dragon.setAttackTarget(null); | ||
dragon.setLocationAndAngles(maid.posX, maid.posY, maid.posZ, MathHelper.wrapAngleTo180_float(player.worldObj.rand.nextFloat() * 360.0F), 0); | ||
dragon.rotationYawHead = dragon.rotationYaw; | ||
dragon.renderYawOffset = dragon.rotationYaw; | ||
return player.worldObj.spawnEntityInWorld(dragon); | ||
} | ||
} |
Binary file not shown.
Oops, something went wrong.