Misc fixes

This commit is contained in:
Vincent Lee committed 2019-06-22 14:04:02 -07:00
1 parent 0f8625adff
commit 898e15a221
13 files changed
+64 -38

No files matched your search

@@ -2,6 +2,7 @@ package vazkii.botania.common.core.handler;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.SpawnReason;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.potion.EffectInstance;
@@ -70,7 +71,8 @@ public final class PixieHandler {
dmg += 2;
pixie.setProps((LivingEntity) event.getSource().getTrueSource(), player, 0, dmg);
pixie.onInitialSpawn(player.world.getDifficultyForLocation(new BlockPos(pixie)), null, null);
pixie.onInitialSpawn(player.world, player.world.getDifficultyForLocation(new BlockPos(pixie)),
SpawnReason.EVENT, null, null);
player.world.addEntity(pixie);
}
}
@@ -33,9 +33,7 @@ public final class MathHelper {
if(finalVector.mag() > 1)
finalVector = finalVector.normalize();
entity.motionX = finalVector.x * modifier;
entity.motionY = finalVector.y * modifier;
entity.motionZ = finalVector.z * modifier;
entity.setMotion(finalVector.multiply(modifier).toVec3D());
}
private static final String[] ORDINAL_SUFFIXES = new String[]{ "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" };
@@ -55,7 +55,7 @@ public class Vector3
}
public static Vector3 fromEntityCenter(Entity e) {
return new Vector3(e.posX, e.posY - e.getYOffset() + e.height / 2, e.posZ);
return new Vector3(e.posX, e.posY - e.getYOffset() + e.getHeight() / 2, e.posZ);
}
public static Vector3 fromTileEntity(TileEntity e) {
@@ -3,6 +3,7 @@ package vazkii.botania.common.core.loot;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.ILootGenerator;
import net.minecraft.world.storage.loot.ILootGenerator;
import net.minecraft.world.storage.loot.LootEntry;
import net.minecraft.world.storage.loot.TableLootEntry;
import net.minecraft.world.storage.loot.LootPool;
import net.minecraft.world.storage.loot.RandomValueRange;
@@ -38,11 +39,16 @@ public final class LootHandler {
}
private static LootPool getInjectPool(String entryName) {
return new LootPool(new ILootGenerator[] { getInjectEntry(entryName, 1) }, new ILootCondition[0], new RandomValueRange(1), new RandomValueRange(0, 1), "botania_inject_pool");
return LootPool.builder()
.addEntry(getInjectEntry(entryName, 1))
// todo 1.14 can't set bonusRolls to [0, 1]
.build();
}
private static TableLootEntry getInjectEntry(String name, int weight) {
return new TableLootEntry(new ResourceLocation(LibMisc.MOD_ID, "inject/" + name), weight, 0, new ILootCondition[0], "botania_inject_entry");
private static LootEntry.Builder getInjectEntry(String name, int weight) {
ResourceLocation table = new ResourceLocation(LibMisc.MOD_ID, "inject/" + name);
return TableLootEntry.func_216171_a(table)
.weight(weight);
}
}
@@ -3,8 +3,10 @@ package vazkii.botania.common.core.loot;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.storage.loot.LootContext;
import net.minecraft.world.storage.loot.LootParameters;
import net.minecraft.world.storage.loot.conditions.ILootCondition;
import net.minecraft.world.storage.loot.conditions.ILootCondition;
import vazkii.botania.common.entity.EntityDoppleganger;
@@ -16,12 +18,13 @@ import java.util.Random;
public class TrueGuardianKiller implements ILootCondition {
@Override
public boolean testCondition(@Nonnull Random rand, @Nonnull LootContext context) {
return context.getLootedEntity() instanceof EntityDoppleganger
&& context.getKillerPlayer() == ((EntityDoppleganger) context.getLootedEntity()).trueKiller;
public boolean test(@Nonnull LootContext context) {
Entity victim = context.get(LootParameters.THIS_ENTITY);
return victim instanceof EntityDoppleganger
&& context.get(LootParameters.KILLER_ENTITY) == ((EntityDoppleganger) victim).trueKiller;
}
public static class Serializer extends ILootCondition.Serializer<TrueGuardianKiller> {
public static class Serializer extends ILootCondition.AbstractSerializer<TrueGuardianKiller> {
public Serializer() {
super(new ResourceLocation(LibMisc.MOD_ID, "true_guardian_killer"), TrueGuardianKiller.class);
}
@@ -144,7 +144,7 @@ public class ItemBrewBase extends ItemMod implements IBrewItem {
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
Brew brew = getBrew(stack);
for(EffectInstance effect : brew.getPotionEffects(stack)) {
TextFormatting format = effect.getPotion().isBadEffect() ? TextFormatting.RED : TextFormatting.GRAY;
TextFormatting format = !effect.getPotion().isBeneficial() ? TextFormatting.RED : TextFormatting.GRAY;
ITextComponent cmp = new TranslationTextComponent(effect.getEffectName());
if(effect.getAmplifier() > 0) {
cmp.appendText(" ");
@@ -142,7 +142,7 @@ public class ItemManasteelArmor extends ArmorItem implements IManaUsingItem, IPh
@OnlyIn(Dist.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<ITextComponent> list, ITooltipFlag flags) {
if(Screen.isShiftKeyDown())
if(Screen.hasShiftDown())
addInformationAfterShift(stack, world, list, flags);
else list.add(new TranslationTextComponent("botaniamisc.shiftinfo"));
}
@@ -60,9 +60,10 @@ public class ItemTerrasteelArmor extends ItemManasteelArmor {
public Multimap<String, AttributeModifier> getAttributeModifiers(@Nonnull EquipmentSlotType slot, ItemStack stack) {
Multimap<String, AttributeModifier> multimap = super.getAttributeModifiers(slot, stack);
UUID uuid = new UUID((getTranslationKey(stack) + slot.toString()).hashCode(), 0);
if (slot == armorType) {
if (slot == getEquipmentSlot()) {
int reduction = material.getDamageReductionAmount(slot);
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(), new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) reduction / 20, 0));
multimap.put(SharedMonsterAttributes.KNOCKBACK_RESISTANCE.getName(),
new AttributeModifier(uuid, "Terrasteel modifier " + type, (double) reduction / 20, AttributeModifier.Operation.ADDITION));
}
return multimap;
}
@@ -114,8 +114,8 @@ public class PacketBotaniaEffect {
double d2 = item.world.rand.nextGaussian() * m;
double d3 = 10.0D;
item.world.addParticle(ParticleTypes.POOF,
message.x + item.world.rand.nextFloat() * item.width * 2.0F - item.width - d0 * d3, message.y + item.world.rand.nextFloat() * item.height - d1 * d3,
message.z + item.world.rand.nextFloat() * item.width * 2.0F - item.width - d2 * d3, d0, d1, d2);
message.x + item.world.rand.nextFloat() * item.getWidth() * 2.0F - item.getWidth() - d0 * d3, message.y + item.world.rand.nextFloat() * item.getHeight() - d1 * d3,
message.z + item.world.rand.nextFloat() * item.getWidth() * 2.0F - item.getWidth() - d2 * d3, d0, d1, d2);
}
break;
}
@@ -259,7 +259,7 @@ public class PacketBotaniaEffect {
double z = target.posZ;
for(int i = 0; i < 50; i++)
Botania.proxy.sparkleFX(x + Math.random() * target.width, y + Math.random() * target.height, z + Math.random() * target.width, 1F, 1F, 0.25F, 1F, 3);
Botania.proxy.sparkleFX(x + Math.random() * target.getWidth(), y + Math.random() * target.getHeight(), z + Math.random() * target.getWidth(), 1F, 1F, 0.25F, 1F, 3);
break;
}
}
@@ -11,6 +11,7 @@ import net.minecraft.world.World;
import net.minecraft.world.ServerWorld;
import net.minecraftforge.fml.network.NetworkDirection;
import net.minecraftforge.fml.network.NetworkRegistry;
import net.minecraftforge.fml.network.PacketDistributor;
import net.minecraftforge.fml.network.simple.SimpleChannel;
import vazkii.botania.common.lib.LibMisc;
@@ -39,12 +40,9 @@ public final class PacketHandler {
if(world instanceof ServerWorld) {
ServerWorld ws = (ServerWorld) world;
for (PlayerEntity player : ws.playerEntities) {
ServerPlayerEntity playerMP = (ServerPlayerEntity) player;
if (playerMP.getDistanceSq(pos) < 64 * 64
&& ws.getPlayerChunkMap().isPlayerWatchingChunk(playerMP, pos.getX() >> 4, pos.getZ() >> 4)) {
HANDLER.sendTo(toSend, playerMP.connection.getNetworkManager(), NetworkDirection.PLAY_TO_CLIENT);
for (ServerPlayerEntity playerMP : ws.getPlayers()) {
if (playerMP.getDistanceSq(pos.getX(), pos.getY(), pos.getZ()) < 64 * 64) {
HANDLER.send(PacketDistributor.TRACKING_CHUNK.with(() -> world.getChunkAt(pos)), toSend);
}
}
@@ -1,8 +1,12 @@
package vazkii.botania.common.world;
import com.mojang.datafixers.Dynamic;
import com.mojang.datafixers.types.DynamicOps;
import net.minecraft.world.gen.feature.IFeatureConfig;
import vazkii.botania.common.core.handler.ConfigHandler;
import javax.annotation.Nonnull;
public class MysticalFlowerConfig implements IFeatureConfig {
public int getPatchSize() {
return ConfigHandler.COMMON.flowerPatchSize.get();
@@ -27,4 +31,11 @@ public class MysticalFlowerConfig implements IFeatureConfig {
public int getMushroomPatchSize() {
return ConfigHandler.COMMON.mushroomQuantity.get();
}
@Nonnull
@Override
public <T> Dynamic<T> serialize(@Nonnull DynamicOps<T> ops) {
// todo 1.14
return new Dynamic<>(ops);
}
}
@@ -1,5 +1,6 @@
package vazkii.botania.common.world;
import com.mojang.datafixers.Dynamic;
import net.minecraft.block.Block;
import net.minecraft.block.DoublePlantBlock;
import net.minecraft.block.BlockState;
@@ -19,8 +20,13 @@ import vazkii.botania.common.block.ModBlocks;
import javax.annotation.Nonnull;
import java.util.Random;
import java.util.function.Function;
public class MysticalFlowerFeature extends Feature<MysticalFlowerConfig> {
public MysticalFlowerFeature(Function<Dynamic<?>, ? extends MysticalFlowerConfig> configFactoryIn) {
super(configFactoryIn);
}
@Override
public boolean place(@Nonnull IWorld world, @Nonnull ChunkGenerator<? extends GenerationSettings> generator, @Nonnull Random rand, @Nonnull BlockPos pos, @Nonnull MysticalFlowerConfig config) {
boolean flowers = true;
@@ -49,7 +55,8 @@ public class MysticalFlowerFeature extends Feature<MysticalFlowerConfig> {
BlockPos pos2 = new BlockPos(x1, y1, z1);
if(world.isAirBlock(pos2) && (!world.getDimension().isNether() || y1 < 127) && flower.isValidPosition(world, pos2)) {
world.setBlockState(pos2, flower, 2);
if(rand.nextDouble() < config.getTallChance() && ((BlockModFlower) flower).canGrow(world, pos2, world.getBlockState(pos2), false)) {
if(rand.nextDouble() < config.getTallChance()
&& ((BlockModFlower) flower.getBlock()).canGrow(world, pos2, world.getBlockState(pos2), false)) {
Block block = ModBlocks.getDoubleFlower(color);
if(block instanceof DoublePlantBlock) {
((DoublePlantBlock) block).placeAt(world, pos2, 3);
@@ -33,6 +33,7 @@ import net.minecraft.util.ActionResultType;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.BlockRayTraceResult;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraft.world.dimension.DimensionType;
@@ -109,20 +110,19 @@ public final class SkyblockWorldEvents {
}
} else if(!equipped.isEmpty() && equipped.getItem() == Items.BOWL) {
RayTraceResult rtr = ToolCommons.raytraceFromEntity(event.getWorld(), event.getEntityPlayer(), true, 4.5F);
if(rtr != null) {
if (rtr.type == RayTraceResult.Type.BLOCK) {
if(event.getWorld().getBlockState(rtr.getBlockPos()).getMaterial() == Material.WATER) {
if(!event.getWorld().isRemote) {
equipped.shrink(1);
if(rtr.getType() == RayTraceResult.Type.BLOCK) {
BlockPos pos = ((BlockRayTraceResult) rtr).getPos();
if(event.getWorld().getBlockState(pos).getMaterial() == Material.WATER) {
if(!event.getWorld().isRemote) {
equipped.shrink(1);
if(equipped.isEmpty())
event.getEntityPlayer().setHeldItem(event.getHand(), new ItemStack(ModItems.waterBowl));
else ItemHandlerHelper.giveItemToPlayer(event.getEntityPlayer(), new ItemStack(ModItems.waterBowl));
}
event.setCanceled(true);
event.setCancellationResult(ActionResultType.SUCCESS);
if(equipped.isEmpty())
event.getEntityPlayer().setHeldItem(event.getHand(), new ItemStack(ModItems.waterBowl));
else ItemHandlerHelper.giveItemToPlayer(event.getEntityPlayer(), new ItemStack(ModItems.waterBowl));
}
event.setCanceled(true);
event.setCancellationResult(ActionResultType.SUCCESS);
}
}
}