Experimental armor changes
Changes to be committed: modified: src/main/java/org/dimdev/dimdoors/entity/MonolithEntity.java modified: src/main/java/org/dimdev/dimdoors/entity/ai/MonolithTask.java new file: src/main/java/org/dimdev/dimdoors/item/ModArmorMaterials.java modified: src/main/java/org/dimdev/dimdoors/item/ModItems.java deleted: src/main/java/org/dimdev/dimdoors/item/WorldThreadArmorItem.java modified: src/main/java/org/dimdev/dimdoors/rift/targets/RandomTarget.java
This commit is contained in:
parent
f6e39ed861
commit
363767dc9c
6 changed files with 118 additions and 83 deletions
|
@ -4,6 +4,7 @@ import java.util.Random;
|
||||||
|
|
||||||
import org.dimdev.dimdoors.ModConfig;
|
import org.dimdev.dimdoors.ModConfig;
|
||||||
import org.dimdev.dimdoors.entity.ai.MonolithTask;
|
import org.dimdev.dimdoors.entity.ai.MonolithTask;
|
||||||
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||||
import org.dimdev.dimdoors.world.ModDimensions;
|
import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
|
|
||||||
|
@ -151,6 +152,10 @@ public class MonolithEntity extends MobEntity {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if((player.inventory.armor.get(0).getItem() == ModItems.WORLD_THREAD_HELMET && player.inventory.armor.get(1).getItem() == ModItems.WORLD_THREAD_CHESTPLATE && player.inventory.armor.get(2).getItem() == ModItems.WORLD_THREAD_LEGGINGS && player.inventory.armor.get(3).getItem() == ModItems.WORLD_THREAD_BOOTS)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!world.isClient) {
|
if (!world.isClient) {
|
||||||
if(player.distanceTo(this) > 70) {
|
if(player.distanceTo(this) > 70) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -3,16 +3,19 @@ package org.dimdev.dimdoors.entity.ai;
|
||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||||
import org.dimdev.dimdoors.ModConfig;
|
import org.dimdev.dimdoors.ModConfig;
|
||||||
import org.dimdev.dimdoors.entity.MonolithEntity;
|
import org.dimdev.dimdoors.entity.MonolithEntity;
|
||||||
|
import org.dimdev.dimdoors.item.ModItems;
|
||||||
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
import org.dimdev.dimdoors.sound.ModSoundEvents;
|
||||||
|
|
||||||
import net.minecraft.entity.ai.TargetPredicate;
|
import net.minecraft.entity.ai.TargetPredicate;
|
||||||
import net.minecraft.entity.ai.goal.Goal;
|
import net.minecraft.entity.ai.goal.Goal;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.network.PacketByteBuf;
|
import net.minecraft.network.PacketByteBuf;
|
||||||
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.sound.SoundCategory;
|
import net.minecraft.sound.SoundCategory;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
|
||||||
|
@ -60,6 +63,20 @@ public class MonolithTask extends Goal {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(target != null && (target.inventory.armor.get(0).getItem() == ModItems.WORLD_THREAD_HELMET && target.inventory.armor.get(1).getItem() == ModItems.WORLD_THREAD_CHESTPLATE && target.inventory.armor.get(2).getItem() == ModItems.WORLD_THREAD_LEGGINGS && target.inventory.armor.get(3).getItem() == ModItems.WORLD_THREAD_BOOTS)) {
|
||||||
|
Random random = new Random();
|
||||||
|
int i = random.nextInt(64);
|
||||||
|
if(this.target instanceof ServerPlayerEntity) {
|
||||||
|
if(i < 6) {
|
||||||
|
target.inventory.armor.get(0).damage(i, random, (ServerPlayerEntity) this.target);
|
||||||
|
target.inventory.armor.get(1).damage(i, random, (ServerPlayerEntity) this.target);
|
||||||
|
target.inventory.armor.get(2).damage(i, random, (ServerPlayerEntity) this.target);
|
||||||
|
target.inventory.armor.get(3).damage(i, random, (ServerPlayerEntity) this.target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
boolean visibility = target != null;
|
boolean visibility = target != null;
|
||||||
mob.updateAggroLevel(target, visibility);
|
mob.updateAggroLevel(target, visibility);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,73 @@
|
||||||
|
package org.dimdev.dimdoors.item;
|
||||||
|
|
||||||
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
|
import net.minecraft.item.ArmorMaterial;
|
||||||
|
import net.minecraft.recipe.Ingredient;
|
||||||
|
import net.minecraft.sound.SoundEvent;
|
||||||
|
import net.minecraft.sound.SoundEvents;
|
||||||
|
import net.minecraft.util.Lazy;
|
||||||
|
|
||||||
|
public enum ModArmorMaterials implements ArmorMaterial {
|
||||||
|
WORLD_THREAD(5, 15, SoundEvents.ITEM_ARMOR_EQUIP_LEATHER, new Lazy<>(() -> Ingredient.ofItems(ModItems.WORLD_THREAD)), "world_thread", new int[]{1, 2, 3, 1}, 0.0F, 0.0F);
|
||||||
|
|
||||||
|
private static final int[] BASE_DURABILITY = new int[]{13, 15, 16, 11};
|
||||||
|
private final int durabilityMultiplier;
|
||||||
|
private final int enchantability;
|
||||||
|
private final SoundEvent equipSound;
|
||||||
|
private final Lazy<Ingredient> repairIngredient;
|
||||||
|
private final String name;
|
||||||
|
private final int[] protectionAmounts;
|
||||||
|
private final float toughness;
|
||||||
|
private final float knockbackResistance;
|
||||||
|
|
||||||
|
ModArmorMaterials(int durabilityMultiplier, int enchantability, SoundEvent equipSound, Lazy<Ingredient> repairIngredient, String name, int[] protectionAmounts, float toughness, float knockbackResistance) {
|
||||||
|
this.durabilityMultiplier = durabilityMultiplier;
|
||||||
|
this.enchantability = enchantability;
|
||||||
|
this.equipSound = equipSound;
|
||||||
|
this.repairIngredient = repairIngredient;
|
||||||
|
this.name = name;
|
||||||
|
this.protectionAmounts = protectionAmounts;
|
||||||
|
this.toughness = toughness;
|
||||||
|
this.knockbackResistance = knockbackResistance;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getDurability(EquipmentSlot slot) {
|
||||||
|
return BASE_DURABILITY[slot.getEntitySlotId()] * this.durabilityMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getProtectionAmount(EquipmentSlot slot) {
|
||||||
|
return this.protectionAmounts[slot.getEntitySlotId()];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getEnchantability() {
|
||||||
|
return this.enchantability;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SoundEvent getEquipSound() {
|
||||||
|
return this.equipSound;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Ingredient getRepairIngredient() {
|
||||||
|
return this.repairIngredient.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getToughness() {
|
||||||
|
return this.toughness;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getKnockbackResistance() {
|
||||||
|
return this.knockbackResistance;
|
||||||
|
}
|
||||||
|
}
|
|
@ -13,10 +13,7 @@ import org.dimdev.dimdoors.world.ModDimensions;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
import net.minecraft.entity.EquipmentSlot;
|
||||||
import net.minecraft.item.BlockItem;
|
import net.minecraft.item.*;
|
||||||
import net.minecraft.item.BucketItem;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.item.Items;
|
|
||||||
import net.minecraft.sound.SoundEvent;
|
import net.minecraft.sound.SoundEvent;
|
||||||
import net.minecraft.util.Identifier;
|
import net.minecraft.util.Identifier;
|
||||||
import net.minecraft.util.registry.Registry;
|
import net.minecraft.util.registry.Registry;
|
||||||
|
@ -105,10 +102,10 @@ public final class ModItems {
|
||||||
public static final Item STABILIZED_RIFT_SIGNATURE = register(new Identifier("dimdoors:stabilized_rift_signature"), new StabilizedRiftSignatureItem(new Item.Settings().maxCount(1).maxDamage(20).group(DIMENSIONAL_DOORS)));
|
public static final Item STABILIZED_RIFT_SIGNATURE = register(new Identifier("dimdoors:stabilized_rift_signature"), new StabilizedRiftSignatureItem(new Item.Settings().maxCount(1).maxDamage(20).group(DIMENSIONAL_DOORS)));
|
||||||
public static final Item RIFT_STABILIZER = register(new Identifier("dimdoors:rift_stabilizer"), new RiftStabilizerItem(new Item.Settings().maxCount(1).maxDamage(6).group(DIMENSIONAL_DOORS)));
|
public static final Item RIFT_STABILIZER = register(new Identifier("dimdoors:rift_stabilizer"), new RiftStabilizerItem(new Item.Settings().maxCount(1).maxDamage(6).group(DIMENSIONAL_DOORS)));
|
||||||
|
|
||||||
public static final Item WORLD_THREAD_HELMET = register(new Identifier("dimdoors:world_thread_helmet"), new WorldThreadArmorItem(EquipmentSlot.HEAD, new Item.Settings()));
|
public static final Item WORLD_THREAD_HELMET = register(new Identifier("dimdoors:world_thread_helmet"), new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.HEAD, new Item.Settings()));
|
||||||
public static final Item WORLD_THREAD_CHESTPLATE = register(new Identifier("dimdoors:world_thread_chestplate"), new WorldThreadArmorItem(EquipmentSlot.CHEST, new Item.Settings()));
|
public static final Item WORLD_THREAD_CHESTPLATE = register(new Identifier("dimdoors:world_thread_chestplate"), new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.CHEST, new Item.Settings()));
|
||||||
public static final Item WORLD_THREAD_LEGGINGS = register(new Identifier("dimdoors:world_thread_leggings"), new WorldThreadArmorItem(EquipmentSlot.LEGS, new Item.Settings()));
|
public static final Item WORLD_THREAD_LEGGINGS = register(new Identifier("dimdoors:world_thread_leggings"), new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.LEGS, new Item.Settings()));
|
||||||
public static final Item WORLD_THREAD_BOOTS = register(new Identifier("dimdoors:world_thread_boots"), new WorldThreadArmorItem(EquipmentSlot.FEET, new Item.Settings()));
|
public static final Item WORLD_THREAD_BOOTS = register(new Identifier("dimdoors:world_thread_boots"), new ArmorItem(ModArmorMaterials.WORLD_THREAD, EquipmentSlot.FEET, new Item.Settings()));
|
||||||
|
|
||||||
public static final Item STABLE_FABRIC = register(new Identifier("dimdoors:stable_fabric"), new Item(new Item.Settings().group(DIMENSIONAL_DOORS)));
|
public static final Item STABLE_FABRIC = register(new Identifier("dimdoors:stable_fabric"), new Item(new Item.Settings().group(DIMENSIONAL_DOORS)));
|
||||||
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
package org.dimdev.dimdoors.item;
|
|
||||||
|
|
||||||
import net.minecraft.entity.EquipmentSlot;
|
|
||||||
import net.minecraft.item.ArmorItem;
|
|
||||||
import net.minecraft.item.ArmorMaterial;
|
|
||||||
import net.minecraft.item.Item;
|
|
||||||
import net.minecraft.recipe.Ingredient;
|
|
||||||
import net.minecraft.sound.SoundEvent;
|
|
||||||
import net.minecraft.sound.SoundEvents;
|
|
||||||
|
|
||||||
public class WorldThreadArmorItem extends ArmorItem {
|
|
||||||
public static final ArmorMaterial MATERIAL = new ArmorMaterial() {
|
|
||||||
@Override
|
|
||||||
public int getDurability(EquipmentSlot equipmentSlot) {
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getProtectionAmount(EquipmentSlot equipmentSlot) {
|
|
||||||
return new int[]{2, 3, 4, 5}[equipmentSlot.getEntitySlotId()];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getEnchantability() {
|
|
||||||
return 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SoundEvent getEquipSound() {
|
|
||||||
return SoundEvents.ITEM_ARMOR_EQUIP_GENERIC;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Ingredient getRepairIngredient() {
|
|
||||||
return Ingredient.ofItems(ModItems.WORLD_THREAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getName() {
|
|
||||||
return "world_thread";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getToughness() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public float getKnockbackResistance() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public WorldThreadArmorItem(EquipmentSlot equipmentSlot, Item.Settings settings) {
|
|
||||||
super(MATERIAL, equipmentSlot, settings);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -117,24 +117,24 @@ public class RandomTarget extends VirtualTarget { // TODO: Split into DungeonTar
|
||||||
|
|
||||||
// Check if we have to generate a new rift
|
// Check if we have to generate a new rift
|
||||||
if (selectedLink == null) {
|
if (selectedLink == null) {
|
||||||
// Randomly select a distance from the distribution f(x) = 1/(m^2/x + x)^2. We use the same distribution as the
|
// Randomly select a distance from the distribution f(x) = 1/(m^2/x + x)^2. We use the same distribution as the
|
||||||
// weighting function. The idea is that there is some kind of "field" formed by the rift, with the field's
|
// weighting function. The idea is that there is some kind of "field" formed by the rift, with the field's
|
||||||
// intensity decreasing proportionally to the area of the sphere. The product of the area of the sphere and
|
// intensity decreasing proportionally to the area of the sphere. The product of the area of the sphere and
|
||||||
// the intesity of the field at that radius is therefore constant, so the infinitsimal weight of any layer
|
// the intesity of the field at that radius is therefore constant, so the infinitsimal weight of any layer
|
||||||
// will be constant and its weight will therefore simply be the original weight function at that value.
|
// will be constant and its weight will therefore simply be the original weight function at that value.
|
||||||
//
|
//
|
||||||
// The inverse of the normalized distribution function can be generated by this Mathematica code:
|
// The inverse of the normalized distribution function can be generated by this Mathematica code:
|
||||||
// distribution = 1/(m^2/x + x)^2
|
// distribution = 1/(m^2/x + x)^2
|
||||||
// totalDistributionIntegral = Integrate[distribution, {x, 0, Infinity}, Assumptions -> m > 0];
|
// totalDistributionIntegral = Integrate[distribution, {x, 0, Infinity}, Assumptions -> m > 0];
|
||||||
// normalizedDistribution = Simplify[distribution/totalDistributionIntegral]
|
// normalizedDistribution = Simplify[distribution/totalDistributionIntegral]
|
||||||
// cummulativeNormalizedDistribution = Simplify[Integrate[normalizedDistribution, x] - (Integrate[normalizedDistribution, x] /. x -> 0)]
|
// cummulativeNormalizedDistribution = Simplify[Integrate[normalizedDistribution, x] - (Integrate[normalizedDistribution, x] /. x -> 0)]
|
||||||
//
|
//
|
||||||
// m = 1; (*Doesn't matter which m you use, it's proportional*)
|
// m = 1; (*Doesn't matter which m you use, it's proportional*)
|
||||||
// table = Table[{r, x /. FindRoot[cummulativeNormalizedDistribution - r, {x, m}]}, {r, 0.01, 0.99, 0.01}];
|
// table = Table[{r, x /. FindRoot[cummulativeNormalizedDistribution - r, {x, m}]}, {r, 0.01, 0.99, 0.01}];
|
||||||
// fit = NonlinearModelFit[table, m (2 Tan[Pi/2 x] + a Log[x] Sqrt[x]), {a}, x]
|
// fit = NonlinearModelFit[table, m (2 Tan[Pi/2 x] + a Log[x] Sqrt[x]), {a}, x]
|
||||||
// Show[ListPlot[table], Plot[fit[x], {x, 0, 1}]]
|
// Show[ListPlot[table], Plot[fit[x], {x, 0, 1}]]
|
||||||
// Clear[m];
|
// Clear[m];
|
||||||
// inverseCummulativeNormalizedDistribution = Normal[fit]
|
// inverseCummulativeNormalizedDistribution = Normal[fit]
|
||||||
double r = Math.random();
|
double r = Math.random();
|
||||||
double distance = weightMaximum * (2 * Math.tan(Math.PI / 2 * r) - 0.5578284481138029 * Math.sqrt(r) * Math.log(r));
|
double distance = weightMaximum * (2 * Math.tan(Math.PI / 2 * r) - 0.5578284481138029 * Math.sqrt(r) * Math.log(r));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue