by Ho9tocraft » 2023年3月12日(日) 11:52
!?
まさかソースコード書いてくれる人がいたとは…!
ありがとうございます!ですけど…申し訳ありません!この記事を投稿した数週~数ヶ月後に、当該コードに類似したソースコードを書き上げることに成功していました…。
以下、当該部分になります。
コード: 全て選択
@SubscribeEvent
public void onPlayerDeathAndDrops(LivingDropsEvent event) {
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)event.entityLiving;
if (player.worldObj.provider.dimensionId == -1 || player.worldObj.provider.dimensionId == 1) {
for (EntityItem itemEntity : event.drops) {
if (itemEntity.getEntityItem().getItem() instanceof IItemRejectLost) {
if (((IItemRejectLost)itemEntity.getEntityItem().getItem()).isCAAttributes()) {
continue;
}
}
NBTTagList enchList = ItemNBTHelper.getList(itemEntity.getEntityItem(), "ench", 10, true);
boolean hasEnchCA = false;
if (enchList != null) {
for (int i = 0; i < enchList.tagCount(); i++) {
NBTTagCompound enchSingle = enchList.getCompoundTagAt(i);
if (enchSingle.getInteger("id") == ConfigHandler.EnchantmentCA && ConfigHandler.EnchantmentCA >= 0) {
hasEnchCA = true;
break;
}
}
if (hasEnchCA) continue;
}
itemEntity.setDead();
}
} else {
for (EntityItem itemEntity : event.drops) {
if (itemEntity.getEntityItem().getItem() instanceof IItemRejectLost) {
if (!((IItemRejectLost)itemEntity.getEntityItem().getItem()).isDyingInOverworldTypes()) {
continue;
}
}
NBTTagList enchList = ItemNBTHelper.getList(itemEntity.getEntityItem(), "ench", 10, true);
boolean hasEnchCA = false;
if (enchList != null) {
for (int i = 0; i < enchList.tagCount(); i++) {
NBTTagCompound enchSingle = enchList.getCompoundTagAt(i);
if (enchSingle.getInteger("id") == ConfigHandler.EnchantmentCA && ConfigHandler.EnchantmentCA >= 0) {
hasEnchCA = true;
break;
}
}
if (!hasEnchCA) continue;
}
itemEntity.setDead();
}
}
}
}
!?
まさかソースコード書いてくれる人がいたとは…!
ありがとうございます!ですけど…申し訳ありません!この記事を投稿した数週~数ヶ月後に、当該コードに類似したソースコードを書き上げることに成功していました…。
以下、当該部分になります。
[code]
@SubscribeEvent
public void onPlayerDeathAndDrops(LivingDropsEvent event) {
if (event.entityLiving instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer)event.entityLiving;
if (player.worldObj.provider.dimensionId == -1 || player.worldObj.provider.dimensionId == 1) {
for (EntityItem itemEntity : event.drops) {
if (itemEntity.getEntityItem().getItem() instanceof IItemRejectLost) {
if (((IItemRejectLost)itemEntity.getEntityItem().getItem()).isCAAttributes()) {
continue;
}
}
NBTTagList enchList = ItemNBTHelper.getList(itemEntity.getEntityItem(), "ench", 10, true);
boolean hasEnchCA = false;
if (enchList != null) {
for (int i = 0; i < enchList.tagCount(); i++) {
NBTTagCompound enchSingle = enchList.getCompoundTagAt(i);
if (enchSingle.getInteger("id") == ConfigHandler.EnchantmentCA && ConfigHandler.EnchantmentCA >= 0) {
hasEnchCA = true;
break;
}
}
if (hasEnchCA) continue;
}
itemEntity.setDead();
}
} else {
for (EntityItem itemEntity : event.drops) {
if (itemEntity.getEntityItem().getItem() instanceof IItemRejectLost) {
if (!((IItemRejectLost)itemEntity.getEntityItem().getItem()).isDyingInOverworldTypes()) {
continue;
}
}
NBTTagList enchList = ItemNBTHelper.getList(itemEntity.getEntityItem(), "ench", 10, true);
boolean hasEnchCA = false;
if (enchList != null) {
for (int i = 0; i < enchList.tagCount(); i++) {
NBTTagCompound enchSingle = enchList.getCompoundTagAt(i);
if (enchSingle.getInteger("id") == ConfigHandler.EnchantmentCA && ConfigHandler.EnchantmentCA >= 0) {
hasEnchCA = true;
break;
}
}
if (!hasEnchCA) continue;
}
itemEntity.setDead();
}
}
}
}
[/code]